From e4b19876d10f08aa15c4be019935731fa2ad61f6 Mon Sep 17 00:00:00 2001 From: zy_Java <654600784@qq.com> Date: Fri, 4 Mar 2022 18:49:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0sdk=EF=BC=88=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E5=AF=BC=E5=87=BA=EF=BC=8C=E6=B6=88=E6=81=AF=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ptos_tall/api/BusinessController.java | 2 +- .../ccsens/ptos_tall/api/UserController.java | 9 + .../ptos_tall/persist/dao/SysUserDao.java | 9 + .../ptos_tall/service/IUserService.java | 8 + .../ccsens/ptos_tall/service/UserService.java | 10 + .../main/resources/mapper_dao/SysUserDao.xml | 13 ++ .../tallsdk/api/ProjectController.java | 11 + .../tallsdk/api/RoleController.java | 2 + .../tallsdk/api/TaskController.java | 20 ++ .../tallsdk/bean/dto/TallTaskDto.java | 22 ++ .../ccsensptos/tallsdk/bean/vo/TallWbsVo.java | 145 ++++++++++++ .../tallsdk/service/ITallService.java | 24 +- .../com/ccsensptos/tallsdk/util/Constant.java | 4 + .../ccsensptos/tallsdk/util/MessageUtil.java | 94 ++++++++ .../main/java/com/ccsens/util/ExcelUtil.java | 33 +++ .../java/com/ccsens/util/ExportPoiUtil.java | 24 ++ .../main/java/com/ccsens/util/PoiUtil.java | 212 +++++------------- 17 files changed, 481 insertions(+), 161 deletions(-) create mode 100644 tall_sdk/src/main/java/com/ccsensptos/tallsdk/bean/vo/TallWbsVo.java create mode 100644 tall_sdk/src/main/java/com/ccsensptos/tallsdk/util/MessageUtil.java create mode 100644 util/src/main/java/com/ccsens/util/ExportPoiUtil.java diff --git a/ptos_tall/src/main/java/com/ccsens/ptos_tall/api/BusinessController.java b/ptos_tall/src/main/java/com/ccsens/ptos_tall/api/BusinessController.java index ac5a467..e5ffcec 100644 --- a/ptos_tall/src/main/java/com/ccsens/ptos_tall/api/BusinessController.java +++ b/ptos_tall/src/main/java/com/ccsens/ptos_tall/api/BusinessController.java @@ -29,7 +29,7 @@ public class BusinessController { private IBusinessService businessService; - @ApiOperation(value = "缓存时查找域内插件类表", notes = "只查在线、启用且开放的业务,不包括零号业务") + @ApiOperation(value = "缓存时查找域内插件列表", notes = "只查在线、启用且开放的业务,不包括零号业务") @ApiImplicitParams({ }) @RequestMapping(value = "/query/plugin", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) diff --git a/ptos_tall/src/main/java/com/ccsens/ptos_tall/api/UserController.java b/ptos_tall/src/main/java/com/ccsens/ptos_tall/api/UserController.java index af411c3..fe127dd 100644 --- a/ptos_tall/src/main/java/com/ccsens/ptos_tall/api/UserController.java +++ b/ptos_tall/src/main/java/com/ccsens/ptos_tall/api/UserController.java @@ -94,4 +94,13 @@ public class UserController { } + @ApiOperation(value = "通过手机号获取userId",notes = "") + @ApiImplicitParams({ + }) + @RequestMapping(value = "userIdByPhone",method = RequestMethod.POST,produces = {"application/json;charset=UTF-8"}) + public JsonResponse> getUserIdByPhone(@ApiParam @Validated @RequestBody List phoneList) throws Exception { + log.info("通过手机号获取userId:{}",phoneList); + List userIdList = userService.getUserIdByPhone(phoneList); + return JsonResponse.newInstance().ok(userIdList); + } } diff --git a/ptos_tall/src/main/java/com/ccsens/ptos_tall/persist/dao/SysUserDao.java b/ptos_tall/src/main/java/com/ccsens/ptos_tall/persist/dao/SysUserDao.java index 25f4177..a626208 100644 --- a/ptos_tall/src/main/java/com/ccsens/ptos_tall/persist/dao/SysUserDao.java +++ b/ptos_tall/src/main/java/com/ccsens/ptos_tall/persist/dao/SysUserDao.java @@ -4,6 +4,8 @@ import com.ccsens.ptos_tall.bean.po.SysUser; import com.ccsens.ptos_tall.persist.mapper.SysUserMapper; import org.apache.ibatis.annotations.Param; +import java.util.List; + /** * @author 逗 */ @@ -14,4 +16,11 @@ public interface SysUserDao extends SysUserMapper { * @return 返回用户信息 */ SysUser getVisitorUser(@Param("deviceId") String deviceId); + + /** + * 通过手机号获取userId + * @param phoneList 手机号列表 + * @return userId列表 + */ + List getUserIdByPhone(@Param("phoneList") List phoneList); } diff --git a/ptos_tall/src/main/java/com/ccsens/ptos_tall/service/IUserService.java b/ptos_tall/src/main/java/com/ccsens/ptos_tall/service/IUserService.java index 6b6a283..f8afe2c 100644 --- a/ptos_tall/src/main/java/com/ccsens/ptos_tall/service/IUserService.java +++ b/ptos_tall/src/main/java/com/ccsens/ptos_tall/service/IUserService.java @@ -3,6 +3,7 @@ package com.ccsens.ptos_tall.service; import com.ccsens.ptos_tall.bean.dto.UserDto; import com.ccsens.ptos_tall.bean.vo.UserVo; +import java.util.List; import java.util.Map; /** @@ -57,4 +58,11 @@ public interface IUserService { * @return 返回重新生成的token */ String getTokenByRefreshToken(String refreshToken); + + /** + * 通过手机号获取userId + * @param phoneList 手机号列表 + * @return 用户列表 + */ + List getUserIdByPhone(List phoneList); } diff --git a/ptos_tall/src/main/java/com/ccsens/ptos_tall/service/UserService.java b/ptos_tall/src/main/java/com/ccsens/ptos_tall/service/UserService.java index 4392ee4..2afbce0 100644 --- a/ptos_tall/src/main/java/com/ccsens/ptos_tall/service/UserService.java +++ b/ptos_tall/src/main/java/com/ccsens/ptos_tall/service/UserService.java @@ -25,6 +25,7 @@ import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.regex.Matcher; @@ -572,4 +573,13 @@ public class UserService implements IUserService { //返回用户信息 return getUserByToken(params.getToken()); } + + @Override + public List getUserIdByPhone(List phoneList) { + List userIdByPhone = null; + if(CollectionUtil.isNotEmpty(phoneList)){ + userIdByPhone = sysUserDao.getUserIdByPhone(phoneList); + } + return userIdByPhone; + } } diff --git a/ptos_tall/src/main/resources/mapper_dao/SysUserDao.xml b/ptos_tall/src/main/resources/mapper_dao/SysUserDao.xml index 0f12616..480880b 100644 --- a/ptos_tall/src/main/resources/mapper_dao/SysUserDao.xml +++ b/ptos_tall/src/main/resources/mapper_dao/SysUserDao.xml @@ -13,4 +13,17 @@ and rec_status = 0 limit 1 + \ No newline at end of file diff --git a/tall_sdk/src/main/java/com/ccsensptos/tallsdk/api/ProjectController.java b/tall_sdk/src/main/java/com/ccsensptos/tallsdk/api/ProjectController.java index ffbf786..b80446d 100644 --- a/tall_sdk/src/main/java/com/ccsensptos/tallsdk/api/ProjectController.java +++ b/tall_sdk/src/main/java/com/ccsensptos/tallsdk/api/ProjectController.java @@ -3,6 +3,7 @@ package com.ccsensptos.tallsdk.api; import com.ccsens.util.WebConstant; import com.ccsens.util.bean.dto.QueryDto; import com.ccsensptos.tallsdk.bean.dto.TallProjectDto; +import com.ccsensptos.tallsdk.bean.vo.TallWbsVo; import com.ccsensptos.tallsdk.service.ITallService; import com.ccsensptos.tallsdk.bean.vo.TallProjectVo; import com.ccsens.util.JsonResponse; @@ -52,6 +53,16 @@ public class ProjectController { return JsonResponse.newInstance().ok(projectInfoList); } + + @ApiOperation(value = "导出Wbs", notes = "") + @RequestMapping(value = "/exportWbs", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) + public JsonResponse exportWbs(HttpServletRequest request,@ApiParam @Validated @RequestBody QueryDto params) throws Exception{ + log.info("导出Wbs:{}",params); + TallWbsVo.WbsPath wbsPath = tallService.exportWbs(request.getHeader(WebConstant.HEADER_KEY_TOKEN),params.getParam()); + log.info("Wbs的路径:{}",wbsPath); + return JsonResponse.newInstance().ok(wbsPath); + } + @ApiOperation(value = "根据id查询项目信息", notes = "根据id查询项目信息") @RequestMapping(value = "/findProjectById", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) public JsonResponse findProjectById(HttpServletRequest request,@ApiParam @Validated @RequestBody QueryDto params) throws Exception{ diff --git a/tall_sdk/src/main/java/com/ccsensptos/tallsdk/api/RoleController.java b/tall_sdk/src/main/java/com/ccsensptos/tallsdk/api/RoleController.java index 797a1a2..d299b2b 100644 --- a/tall_sdk/src/main/java/com/ccsensptos/tallsdk/api/RoleController.java +++ b/tall_sdk/src/main/java/com/ccsensptos/tallsdk/api/RoleController.java @@ -32,6 +32,7 @@ public class RoleController { private ITallService tallService; + @ApiOperation(value = "根据项目id查找角色", notes = "") @RequestMapping(value = "/show", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) public JsonResponse queryByProjectId(HttpServletRequest request, @ApiParam @Validated @RequestBody QueryDto params) { @@ -40,4 +41,5 @@ public class RoleController { log.info("项目id查找角色列表{}",queryRole); return JsonResponse.newInstance().ok(queryRole); } + } diff --git a/tall_sdk/src/main/java/com/ccsensptos/tallsdk/api/TaskController.java b/tall_sdk/src/main/java/com/ccsensptos/tallsdk/api/TaskController.java index 1197fbd..d090836 100644 --- a/tall_sdk/src/main/java/com/ccsensptos/tallsdk/api/TaskController.java +++ b/tall_sdk/src/main/java/com/ccsensptos/tallsdk/api/TaskController.java @@ -6,6 +6,8 @@ import com.ccsensptos.tallsdk.service.ITallService; import com.ccsensptos.tallsdk.bean.dto.TallTaskDto; import com.ccsensptos.tallsdk.bean.vo.TallTaskVo; import com.ccsens.util.JsonResponse; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -36,7 +38,9 @@ public class TaskController { @ApiOperation(value = "查找永久日常任务", notes = "") @RequestMapping(value = "/permanent", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) public JsonResponse> queryPermanentGlobalTask(HttpServletRequest request, @ApiParam @Validated @RequestBody QueryDto params) { + log.info("查找永久日常任务:{}",params); List queryTasks = tallService.queryPermanentGlobalTask(request.getHeader(WebConstant.HEADER_KEY_TOKEN),params.getParam()); + log.info("返回日常任务"); return JsonResponse.newInstance().ok(queryTasks); } @@ -44,7 +48,9 @@ public class TaskController { @ApiOperation(value = "查找带时间的日常任务", notes = "") @RequestMapping(value = "/global", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) public JsonResponse> queryGlobalTask(HttpServletRequest request, @ApiParam @Validated @RequestBody QueryDto params) { + log.info("查找带时间的日常任务:{}",params); List queryTasks = tallService.queryGlobalTask(request.getHeader(WebConstant.HEADER_KEY_TOKEN),params.getParam()); + log.info("返回带时间的日常任务"); return JsonResponse.newInstance().ok(queryTasks); } @@ -52,14 +58,28 @@ public class TaskController { @ApiOperation(value = "查找定期任务", notes = "") @RequestMapping(value = "/regular", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) public JsonResponse> queryRegularTask(HttpServletRequest request, @ApiParam @Validated @RequestBody QueryDto params) { + log.info("查找定期任务:{}",params); List queryTasks = tallService.queryRegularTask(request.getHeader(WebConstant.HEADER_KEY_TOKEN),params.getParam()); + log.info("返回定期任务"); return JsonResponse.newInstance().ok(queryTasks); } @ApiOperation(value = "查找定期任务和相应的插件展示信息", notes = "") @RequestMapping(value = "/regular/plugin", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) public JsonResponse> queryRegularTaskAndPlugin(HttpServletRequest request, @ApiParam @Validated @RequestBody QueryDto params) { + log.info("查找定期任务和相应的插件展示信息:{}",params); List queryTasks = tallService.queryRegularTaskAndPlugin(request.getHeader(WebConstant.HEADER_KEY_TOKEN),params.getParam()); + log.info("返回定期任务和相应的插件展示信息"); return JsonResponse.newInstance().ok(queryTasks); } + + @ApiOperation(value = "分页查找定期任务", notes = "") + @RequestMapping(value = "/regular/page", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) + public JsonResponse> pageQueryRegularTask(HttpServletRequest request, @ApiParam @Validated @RequestBody QueryDto params) { + log.info("分页查找定期任务:{}",params); + PageInfo queryTasks = tallService.pageQueryRegularTask(request.getHeader(WebConstant.HEADER_KEY_TOKEN),params.getParam()); + log.info("返回分页查找定期任务"); + return JsonResponse.newInstance().ok(queryTasks); + } + } diff --git a/tall_sdk/src/main/java/com/ccsensptos/tallsdk/bean/dto/TallTaskDto.java b/tall_sdk/src/main/java/com/ccsensptos/tallsdk/bean/dto/TallTaskDto.java index 9c8964c..a62ad3e 100644 --- a/tall_sdk/src/main/java/com/ccsensptos/tallsdk/bean/dto/TallTaskDto.java +++ b/tall_sdk/src/main/java/com/ccsensptos/tallsdk/bean/dto/TallTaskDto.java @@ -43,4 +43,26 @@ public class TallTaskDto { @ApiModelProperty("查找颗粒度数量 默认3个") private int queryNum = 3; } + + @Data + @ApiModel("分期查看定期任务") + public static class PageQueryRegularTask{ + @NotNull(message = "角色id不能为空") + @ApiModelProperty("角色id") + private Long roleId; + @ApiModelProperty("项目id") + private Long projectId; + @ApiModelProperty("任务id") + private Long taskId; + @ApiModelProperty("时间基准点 默认当前") + private Long timeNode = System.currentTimeMillis(); + @ApiModelProperty("时间颗粒度 默认天") + private int timeUnit = 4; + @ApiModelProperty("0向上查找 1向下查找(默认) 下查包含自己,上查不包含") + private int queryType = 1; + @ApiModelProperty("第几页") + private Integer pageNum = 1; + @ApiModelProperty("每页几条信息") + private Integer pageSize = 10; + } } diff --git a/tall_sdk/src/main/java/com/ccsensptos/tallsdk/bean/vo/TallWbsVo.java b/tall_sdk/src/main/java/com/ccsensptos/tallsdk/bean/vo/TallWbsVo.java new file mode 100644 index 0000000..c1718e3 --- /dev/null +++ b/tall_sdk/src/main/java/com/ccsensptos/tallsdk/bean/vo/TallWbsVo.java @@ -0,0 +1,145 @@ +package com.ccsensptos.tallsdk.bean.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author 逗 + */ +@Data +public class TallWbsVo { + + @Data + @ApiModel("wbs文件下载链接") + public static class WbsPath{ + @ApiModelProperty("下载链接") + private String url; + } + + /** + * 项目信息 + */ + @Data + public static class WbsProjectInfo{ + //项目id + private String projectId; + //项目名称 + private String projectName; + //描述 + private String description; + //地点 + private String address; + //开始时间(yyyy/MM/dd HH:mm) + private String startTime; + //结束时间(yyyy/MM/dd HH:mm) + private String endTime; + //版本号 + private String version; + } + + /** + * 任务信息 + */ + @Data + public static class WbsTaskInfo{ + //一级任务id + private String firstId; + //一级任务名称 + private String firstName; + //二级任务信息 + private List secondTaskList; + } + + /** + * 二级任务信息 + */ + @Data + public static class WbsSecondTask{ + //二级任务id + private String detailId; + //分解后的任务id + private String subId; + //二级任务名称 + private String taskName; + //任务描述 + private String description; + //开始时间(yyyy/MM/dd HH:mm) 如果有实际时间则以实际时间为准 + private String startTime; + //结束时间(yyyy/MM/dd HH:mm) 如果有实际时间则以实际时间为准 + private String endTime; + //任务时长 + private String duration; + //重要性标签 + private String label; + //负责人 + private String executor; + //检查人 + private String checker; + //交付物id + private String deliverId; + //交付物名称 + private String deliverName; + //绩效/即使奖惩 + private String reward; + //任务插件1关联id + private String pluginOneId; + //插件1名称 + private String pluginOneName; + //任务插件2关联id + private String pluginTwoId; + //插件2名称 + private String pluginTwoName; + //任务插件3关联id + private String pluginThreeId; + //插件3名称 + private String pluginThreeName; + } + + /** + * 角色成员表信息 + */ + @Data + public static class WbsRoleInfo{ + //项目经理 + private List pmList; + //项目成员 + private List roleList; + } + + /** + * 角色信息 + */ + @Data + public static class WbsRole{ + //角色id + private String roleId; + //角色名 + private String roleName; + //对谁不可见 + private String repulsion; + //成员信息 + private List memberList; + } + + /** + * 成员信息 + */ + @Data + public static class WbsMember{ + //成员id + private String memberId; + //成员名 + private String memberName; + //成员手机号 + private String memberPhone; + //奖惩干系人id + private String stakeholderId; + //奖惩干系人名 + private String stakeholderName; + //奖惩干系人手机号 + private String stakeholderPhone; + } +} diff --git a/tall_sdk/src/main/java/com/ccsensptos/tallsdk/service/ITallService.java b/tall_sdk/src/main/java/com/ccsensptos/tallsdk/service/ITallService.java index baedd57..9f0cf31 100644 --- a/tall_sdk/src/main/java/com/ccsensptos/tallsdk/service/ITallService.java +++ b/tall_sdk/src/main/java/com/ccsensptos/tallsdk/service/ITallService.java @@ -6,6 +6,8 @@ import com.ccsensptos.tallsdk.bean.dto.TallTaskDto; import com.ccsensptos.tallsdk.bean.vo.TallProjectVo; import com.ccsensptos.tallsdk.bean.vo.TallRoleVo; import com.ccsensptos.tallsdk.bean.vo.TallTaskVo; +import com.ccsensptos.tallsdk.bean.vo.TallWbsVo; +import com.github.pagehelper.PageInfo; import org.springframework.web.multipart.MultipartFile; import java.util.List; @@ -59,13 +61,29 @@ public interface ITallService { /** * 根据id查询项目信息 */ - TallProjectVo.ProjectInfo findProjectById(String header, TallProjectDto.ProjectById params); + TallProjectVo.ProjectInfo findProjectById(String token, TallProjectDto.ProjectById params); /** * 查询定期任务包括插件展示的信息 - * @param header token + * @param token token * @param param 任务id信息 * @return 返回任务洗洗和插件展示的信息 */ - List queryRegularTaskAndPlugin(String header, TallTaskDto.QueryRegularTask param); + List queryRegularTaskAndPlugin(String token, TallTaskDto.QueryRegularTask param); + + /** + * 分页查找定期任务 + * @param token token + * @param param 角色时间分页等信息 + * @return 任务列表 + */ + PageInfo pageQueryRegularTask(String token, TallTaskDto.PageQueryRegularTask param); + + /** + * 导出wbs + * @param token token + * @param param 项目id + * @return 返回wbs的下载路径 + */ + TallWbsVo.WbsPath exportWbs(String token, TallProjectDto.ProjectById param); } diff --git a/tall_sdk/src/main/java/com/ccsensptos/tallsdk/util/Constant.java b/tall_sdk/src/main/java/com/ccsensptos/tallsdk/util/Constant.java index ed1d02b..c99aa73 100644 --- a/tall_sdk/src/main/java/com/ccsensptos/tallsdk/util/Constant.java +++ b/tall_sdk/src/main/java/com/ccsensptos/tallsdk/util/Constant.java @@ -12,8 +12,12 @@ public class Constant { public static final String TALL_USER_TOKEN = "ptostall/users/businessToken"; /**tall-获取accessToken*/ public static final String TALL_GET_ACCESS_TOKEN = "ptostall/business/accessToken"; + /**tall-通过手机号获取userId*/ + public static final String TALL_GET_USER_ID = "ptostall/users/userIdByPhone"; /**开放平台-获取插件信息*/ public static final String OPEN_GET_PLUGIN = "opt/business/businessPluginByName"; + /**消息系统-发送消息*/ + public static final String MESSAGE_SEND_TO = "http://101.201.226.163:8194/message/v4.0/message/send"; /**请求头--accessToken*/ public static final String ACCESS_TOKEN = "accessToken"; diff --git a/tall_sdk/src/main/java/com/ccsensptos/tallsdk/util/MessageUtil.java b/tall_sdk/src/main/java/com/ccsensptos/tallsdk/util/MessageUtil.java new file mode 100644 index 0000000..b7bd9e6 --- /dev/null +++ b/tall_sdk/src/main/java/com/ccsensptos/tallsdk/util/MessageUtil.java @@ -0,0 +1,94 @@ +package com.ccsensptos.tallsdk.util; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.ccsens.util.RestTemplateUtil; +import com.ccsens.util.bean.message.common.InMessage; +import com.ccsens.util.bean.message.common.MessageConstant; +import com.ccsens.util.bean.message.common.MessageRule; +import com.ccsens.util.exception.BaseException; +import com.ccsensptos.tallsdk.bean.dto.TallTokenDto; +import com.ccsensptos.tallsdk.bean.vo.TallTokenVo; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * @author 逗 + */ +@Component +@Slf4j +public class MessageUtil { + + public static void sendToUser(List phoneList, Set userIdSet,Object data,MessageConstant.DomainType toDomain,MessageRule rule){ + if(userIdSet == null){ + userIdSet = new HashSet<>(); + } + //通过手机号获取接收者的userId + if(CollectionUtil.isNotEmpty(phoneList)) { + String getUserIdByPhoneUrl = Constant.GATEWAY_URL + Constant.TALL_GET_USER_ID; + log.info("调用获取userId接口:{}--{}", getUserIdByPhoneUrl, phoneList); + String strBody = null; + try { + strBody = HttpUtil.post(getUserIdByPhoneUrl, JSON.toJSONString(phoneList)); + log.info("接口返回信息:{}",strBody); + } catch (Exception e) { + log.error("消息发送失败--" + e); + } + JSONObject jsonObject = JSONObject.parseObject(strBody); + if(ObjectUtil.isNotNull(jsonObject)){ + //请求正确返回则,否则无操作 + Integer code = jsonObject.getInteger("code"); + if (code == null || code != 200) { + throw new BaseException("返回参数异常"); + } + //userId + JSONArray dataArray = jsonObject.getJSONArray("data"); + if (CollectionUtil.isNotEmpty(dataArray)) { + for (Object object : dataArray) { + userIdSet.add(object.toString()); + } + } + } + } + //创建InMessage对象 + InMessage inMessage = new InMessage(); + if(ObjectUtil.isNull(toDomain)){ + toDomain = MessageConstant.DomainType.User; + } + inMessage.setToDomain(toDomain); + inMessage.setTos(userIdSet); + //如果 + if(ObjectUtil.isNull(rule)){ + switch (toDomain){ + case Server: + rule = new MessageRule((byte) 1, MessageRule.AckRule.ALWAYS, 10, (byte) 1,0L); + break; + case User: + rule = new MessageRule((byte)0, MessageRule.AckRule.ALWAYS,100,(byte)0,0L); + break; + default: + rule = new MessageRule((byte)0, MessageRule.AckRule.ALWAYS,10,(byte)1,0L); + break; + } + } + inMessage.setRule(rule); + inMessage.setData(JSONObject.toJSONString(data)); + + String url = Constant.MESSAGE_SEND_TO; + log.info("调用发送消息接口:{}--{}", url, inMessage); + try{ + RestTemplateUtil.postBody(url,inMessage); + }catch (Exception e){ + log.error("消息发送失败--" + e); + } + } +} diff --git a/util/src/main/java/com/ccsens/util/ExcelUtil.java b/util/src/main/java/com/ccsens/util/ExcelUtil.java index e66f2c1..331b8fe 100644 --- a/util/src/main/java/com/ccsens/util/ExcelUtil.java +++ b/util/src/main/java/com/ccsens/util/ExcelUtil.java @@ -102,4 +102,37 @@ public class ExcelUtil { return ret; } + /** + * 获取单元格内的跳转链接 + * @param cell 单元格信息 + * @return 返回跳转链接 + */ + public static String getCellJumpLink (Cell cell) { + String param = null; + if(ObjectUtil.isNull(cell)){ + return null; + } + Hyperlink link = cell.getHyperlink(); + if(link != null){ + param = link.getAddress(); + } + return param; + } + + /** + * 获取单元格内的批注信息 + * @param cell 单元格信息 + * @return 返回批注信息 + */ + public static String getCellComment (Cell cell) { + String param = null; + if(ObjectUtil.isNull(cell)){ + return null; + } + if(cell.getCellComment() != null) { + param = cell.getCellComment().getString().toString(); + } + return param; + } + } diff --git a/util/src/main/java/com/ccsens/util/ExportPoiUtil.java b/util/src/main/java/com/ccsens/util/ExportPoiUtil.java new file mode 100644 index 0000000..396d879 --- /dev/null +++ b/util/src/main/java/com/ccsens/util/ExportPoiUtil.java @@ -0,0 +1,24 @@ +package com.ccsens.util; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * @author 逗 + */ +@Slf4j +@Component +public class ExportPoiUtil { + + + + public static void main(String[] args) { + + //生成一个单元格 + //将单元格加到行内 + //将行添加至sheet内 + //将sheet加到表格内 + //生成文件 + } + +} diff --git a/util/src/main/java/com/ccsens/util/PoiUtil.java b/util/src/main/java/com/ccsens/util/PoiUtil.java index 8a5edee..fd1ff7b 100644 --- a/util/src/main/java/com/ccsens/util/PoiUtil.java +++ b/util/src/main/java/com/ccsens/util/PoiUtil.java @@ -66,7 +66,7 @@ public class PoiUtil { /** * 跳转的路径 */ - private String path; + private String jumpLink; /** * 函数 */ @@ -77,6 +77,11 @@ public class PoiUtil { */ private byte num = 0; + /** + * 批注 + */ + private String comment; + public PoiUtilCell() { } @@ -85,6 +90,7 @@ public class PoiUtil { this.value = value; } + public PoiUtilCell(String value,String function) { this.value = value; this.function = function; @@ -97,6 +103,13 @@ public class PoiUtil { this.rowspan = rowspan; } + public PoiUtilCell(String value, String comment, int colspan, int rowspan) { + this.value = value; + this.comment = comment; + this.colspan = colspan; + this.rowspan = rowspan; + } + public PoiUtilCell(String value, Integer height, Integer wight) { this.value = value; this.height = height; @@ -206,16 +219,27 @@ public class PoiUtil { style.setAlignment(cell.style); style.setVerticalAlignment(cell.verticalAlignment); //设置跳转路径 - if (StrUtil.isNotEmpty(cell.path)) { + if (StrUtil.isNotEmpty(cell.jumpLink)) { XSSFCreationHelper createHelper = (XSSFCreationHelper) wb.getCreationHelper(); XSSFHyperlink link = createHelper.createHyperlink(HyperlinkType.URL); - link.setAddress(cell.path); + link.setAddress(cell.jumpLink); newCell.setHyperlink(link); //设置字体颜色 Font font = wb.createFont(); font.setColor(Font.COLOR_RED); style.setFont(font); } + //添加单元格批注 + if(StrUtil.isNotEmpty(cell.comment)){ + // 创建绘图对象 + XSSFDrawing p = (XSSFDrawing) sheet.createDrawingPatriarch(); + // 前四个参数是坐标点,后四个参数是编辑和显示批注时的大小. + XSSFComment comment = p.createCellComment(new XSSFClientAnchor(0, 0, 0,0, (short) 0, 1, (short) 0, 1)); + // 输入批注信息 + comment.setString(new XSSFRichTextString(cell.comment)); + // 将批注添加到单元格对象中 + newCell.setCellComment(comment); + } //添加函数 if(StrUtil.isNotEmpty(cell.getFunction())) { newCell.setCellFormula(cell.getFunction()); @@ -224,47 +248,6 @@ public class PoiUtil { style.setWrapText(true); //将样式添加至单元格 newCell.setCellStyle(style); - -// CellStyle style = wb.createCellStyle(); -// 将内容按顺序赋给对应的列对象 -// 如果value是cell_null代表次单元格不需要赋值 -// if (cell.value.equals(WebConstant.CELL_NULL)){ -// continue; -// } -// Cell newCell = row.createCell(j); -// //设置行高 -// if (ObjectUtil.isNotNull(cell.height)) { -// if (j == 0) { -// row.setHeight(cell.height.shortValue()); -// } -// } -// -// if(cell.num == 1){ -// newCell.setCellValue(Integer.parseInt(cell.value)); -// }else { -// newCell.setCellValue(cell.value); -// } -// style.setAlignment(cell.style); -// style.setVerticalAlignment(cell.verticalAlignment); - -// //设置跳转路径 -// if (StrUtil.isNotEmpty(cell.path)) { -// XSSFCreationHelper createHelper = (XSSFCreationHelper) wb.getCreationHelper(); -// XSSFHyperlink link = createHelper.createHyperlink(HyperlinkType.URL); -// link.setAddress(cell.path); -// newCell.setHyperlink(link); -// //设置字体颜色 -// Font font = wb.createFont(); -// font.setColor(Font.COLOR_RED); -// style.setFont(font); -// } -// //添加函数 -// if(StrUtil.isNotEmpty(cell.getFunction())) { -// newCell.setCellFormula(cell.getFunction()); -// } -// //设置自动换行 -// style.setWrapText(true); -// newCell.setCellStyle(style); } } return wb; @@ -334,8 +317,8 @@ public class PoiUtil { if (row == null || row.getLastCellNum() <= 0) { continue; } - System.out.println(row); - System.out.println(row.getLastCellNum()); +// System.out.println(row); +// System.out.println(row.getLastCellNum()); Object[] objects = new Object[row.getLastCellNum()]; if (hasImg && imgMap != null) { for (String key : imgMap.keySet()) { @@ -609,130 +592,45 @@ public class PoiUtil { public static void main(String[] args) throws Exception { - String s = toRadix(3); - System.out.println(s); - - -// File file = new File("F:\\wenjian\\3.xlsx"); -// file.createNewFile(); -// InputStream inputStream = new FileInputStream(file); - Workbook workbook = new XSSFWorkbook(); -// XSSFSheet sheet = (XSSFSheet) workbook.getSheetAt(0); -// XSSFRow row = sheet.getRow(6); -// XSSFCell newCell = row.createCell(2); -// XSSFCell newCell1 = row.createCell(3); -// //添加公式 -// newCell.setCellFormula("A7+B7"); -// newCell1.setCellFormula("A8/B8"); -// //设置打印区域 -// workbook.setPrintArea( -// 0, //工作薄 下标0开始 -// 0, //起始列 下标0开始 -// 20, //终止列 下标0开始 -// 0, //起始行 下标0开始 -// 20 //终止行 下标0开始 -// ); -//// CellStyle style = workbook.createCellStyle(); -//// style.setFillBackgroundColor(); -// -// OutputStream stream = new FileOutputStream(new File("D:\\1.xlsx")); -// workbook.write(stream); -// stream.close(); - - //第一行 - PoiUtilCell blank = new PoiUtilCell(); - PoiUtilCell poiUtilCell = new PoiUtilCell(); - poiUtilCell.setValue("空白"); - poiUtilCell.setColspan(1); - poiUtilCell.setRowspan(2); - PoiUtilCell poiUtilCell1 = new PoiUtilCell(); - poiUtilCell1.setValue("2021.8.31"); - poiUtilCell1.setColspan(2); - poiUtilCell1.setRowspan(1); - PoiUtilCell poiUtilCell3 = new PoiUtilCell(); - poiUtilCell3.setValue("2021.9.1"); - poiUtilCell3.setColspan(2); - poiUtilCell3.setRowspan(1); - //第二行 - PoiUtilCell poiUtilCellTwo1 = new PoiUtilCell(); - poiUtilCellTwo1.setValue(""); - poiUtilCellTwo1.setValue(""); - PoiUtilCell poiUtilCellTwo2 = new PoiUtilCell(); - poiUtilCellTwo2.setValue("早"); - PoiUtilCell poiUtilCellTwo3 = new PoiUtilCell(); - poiUtilCellTwo3.setValue("晚"); - PoiUtilCell poiUtilCellTwo4 = new PoiUtilCell(); - poiUtilCellTwo2.setValue("早"); - PoiUtilCell poiUtilCellTwo5 = new PoiUtilCell(); - poiUtilCellTwo3.setValue("晚"); - //poiUtilCell2.setFunction("SUM(A1:C1)"); - //第三行 - PoiUtilCell poiUtilCellThree1 = new PoiUtilCell(); - poiUtilCellThree1.setValue("张三"); - PoiUtilCell poiUtilCellThree2 = new PoiUtilCell(); - poiUtilCellThree2.setValue("10:43"); - PoiUtilCell poiUtilCellThree3 = new PoiUtilCell(); - poiUtilCellThree3.setValue("20:00"); - - - List cells = new ArrayList<>(); - cells.add(poiUtilCell); - cells.add(poiUtilCell1); - cells.add(blank); - cells.add(poiUtilCell3); - cells.add(blank); - - List cells2 = new ArrayList<>(); - cells2.add(poiUtilCellTwo1); - cells2.add(poiUtilCellTwo2); - cells2.add(poiUtilCellTwo3); - cells2.add(poiUtilCellTwo4); - cells2.add(poiUtilCellTwo5); - - List cells3 = new ArrayList<>(); - cells3.add(poiUtilCellThree1); - cells3.add(poiUtilCellThree2); - cells3.add(poiUtilCellThree3); - + //生成一个excel List> list = new ArrayList<>(); + List cells = new ArrayList<>(); + cells.add(new PoiUtilCell("第一格","11111",1,1)); + cells.add(new PoiUtilCell("第二格","22222",1,1)); + cells.add(new PoiUtilCell("第三格","33333",1,1)); + cells.add(new PoiUtilCell("第四格","44444",1,1)); + cells.add(new PoiUtilCell("第五格","55555",1,5)); list.add(cells); - list.add(cells2); - list.add(cells3); - - -// list.add(cells); -// -// List cells1 = new ArrayList<>(); -// cells1.add(new PoiUtilCell("两列一行", 2, 1)); -// list.add(cells1); -// -// List cells2 = new ArrayList<>(); -// cells2.add(new PoiUtilCell("一列两行", 1, 2)); -// list.add(cells2); -// List cells3 = new ArrayList<>(); -// cells3.add(new PoiUtilCell("5")); -// cells3.add(new PoiUtilCell("6")); -// list.add(cells3); -// List cells4 = new ArrayList<>(); -// list.add(cells4); -// List cells5 = new ArrayList<>(); -// cells5.add(new PoiUtilCell("9", 2, 2)); -// cells5.add(new PoiUtilCell("9")); -// list.add(cells5); - String fileName = "zzz/" + cn.hutool.core.date.DateUtil.today() + "/" + System.currentTimeMillis() + ".xlsx"; - String path = WebConstant.UPLOAD_PATH_BASE + fileName; + String path = "/home/zzz/" + cn.hutool.core.date.DateUtil.today() + "/" + System.currentTimeMillis() + ".xlsx"; File tmpFile = new File(path); if (!tmpFile.getParentFile().exists()) { tmpFile.getParentFile().mkdirs(); } - + Workbook workbook = new XSSFWorkbook(); Workbook wbs = exportWB("Sheet1", list, workbook); OutputStream stream = new FileOutputStream(tmpFile); wbs.write(stream); stream.close(); + +// //读取一个excel +// String path = "F:\\home\\zzz\\2022-03-03\\1646269559234.xlsx"; +// FileInputStream is = new FileInputStream(path); +// +// XSSFWorkbook wb = new XSSFWorkbook(is); +// XSSFSheet sheet = wb.getSheetAt(0); +// XSSFRow row = sheet.getRow(0); +// for (int i = 0; i < row.getLastCellNum(); i++) { +// XSSFCell cell = row.getCell(i); +// System.out.println(ExcelUtil.getCellValue(cell)); +// System.out.println(ExcelUtil.getCellJumpLink(cell)); +// +// if(cell.getCellComment()!=null) { +// System.out.println(cell.getCellComment().getString().toString()); +// } +// } } }