diff --git a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/controller/ParamsCollectManifestEOController.java b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/controller/ParamsCollectManifestEOController.java index 682af6d01..925d7a8a8 100644 --- a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/controller/ParamsCollectManifestEOController.java +++ b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/controller/ParamsCollectManifestEOController.java @@ -381,13 +381,24 @@ public class ParamsCollectManifestEOController extends JeroController issueCollection(ParamsCollectManifestVO paramsCollectManifestVO) { - boolean isSuccess = paramsCollectManifestEOService.issueCollection(paramsCollectManifestVO); - if (isSuccess) { - return Result.OK("下发收集成功!"); - } else { - return Result.error("下发收集失败!"); - } + public Result> issueCollection(ParamsCollectManifestVO paramsCollectManifestVO) { + List msgList = paramsCollectManifestEOService.issueCollection(paramsCollectManifestVO); + return Result.OK(msgList); + } + + /** + * 一键下发收集 + * + * @param paramsCollectManifestVO + * @return + */ + @AutoLog(value = "参数项收集清单-一键下发收集") + @ApiOperation(value="参数项收集清单-一键下发收集", notes="参数项收集清单-一键下发收集") + @PostMapping(value = "/issueCollectionAll") +// @RequiresPermissions("params:collectManifest:issue") + public Result> issueCollectionAll(ParamsCollectManifestVO paramsCollectManifestVO) { + List msgList = paramsCollectManifestEOService.issueCollectionAll(paramsCollectManifestVO); + return Result.OK(msgList); } /** diff --git a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/service/IParamsCollectManifestEOService.java b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/service/IParamsCollectManifestEOService.java index b86067b96..73681d6b6 100644 --- a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/service/IParamsCollectManifestEOService.java +++ b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/service/IParamsCollectManifestEOService.java @@ -126,7 +126,10 @@ public interface IParamsCollectManifestEOService extends IService issueCollection(ParamsCollectManifestVO paramsCollectManifestVO); + + // 一键下发收集 + List issueCollectionAll(ParamsCollectManifestVO paramsCollectManifestVO); // 配置-下拉选项 List> getConfigLabelList(ParamsCollectManifestVO paramsCollectManifestVO); diff --git a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/service/impl/ParamsCollectManifestEOServiceImpl.java b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/service/impl/ParamsCollectManifestEOServiceImpl.java index 418d04fe3..4a80c1927 100644 --- a/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/service/impl/ParamsCollectManifestEOServiceImpl.java +++ b/jero-boot/jero-boot-module-certification/src/main/java/com/jero/modules/cert/collect/service/impl/ParamsCollectManifestEOServiceImpl.java @@ -1351,82 +1351,290 @@ public class ParamsCollectManifestEOServiceImpl extends ServiceImpl issueCollection(ParamsCollectManifestVO paramsCollectManifestVO) { if (StringUtils.isEmpty(paramsCollectManifestVO.getIds()) - || StringUtils.isEmpty(paramsCollectManifestVO.getProjectId()) || StringUtils.isEmpty(paramsCollectManifestVO.getParamsManifestId())) { + || StringUtils.isEmpty(paramsCollectManifestVO.getProjectId()) + || StringUtils.isEmpty(paramsCollectManifestVO.getParamsManifestId()) + || StringUtils.isEmpty(paramsCollectManifestVO.getCut()) + || paramsCollectManifestVO.getDeadline() == null ) { throw new JeroBootException("参数不能为空!"); } String paramsCollectManifestIds = paramsCollectManifestVO.getIds(); String projectId = paramsCollectManifestVO.getProjectId(); String paramsManifestId = paramsCollectManifestVO.getParamsManifestId(); + String cut = paramsCollectManifestVO.getCut(); + Date deadline = paramsCollectManifestVO.getDeadline(); + LoginUser currentUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); // 获取当前登录人 + ParamsManifestVO projectInfo = paramsManifestEOService.getProjectById(projectId); // 获取项目信息 + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); String[] paramsCollectManifestIdStr = paramsCollectManifestIds.split(","); List updateEOList = new ArrayList<>(); + List> msgMapList = new ArrayList<>(); + List updateEOIdList = new ArrayList<>(); - for (int i=0; i paramsCollectManifestEOList = listByIds(Arrays.asList(paramsCollectManifestIdStr)); + paramsCollectManifestEOList = paramsCollectManifestEOList.stream().sorted(Comparator.comparing(ParamsCollectManifestBaseEO::getNioNumber)).collect(Collectors.toList()); // 按NIO编号升序 + for (ParamsCollectManifestEO paramsCollectManifestEO : paramsCollectManifestEOList) { + // 判断参数项状态 + if (CollectManifestStateEnum.WAIT_COLLECT.getValue().equals(paramsCollectManifestEO.getState())) { + if (StringUtils.isNotBlank(paramsCollectManifestEO.getSdt())) { + ParamsCollectManifestEO updateEO = new ParamsCollectManifestEO(); + updateEO.setId(paramsCollectManifestEO.getId()); + updateEO.setState(CollectManifestStateEnum.WAIT_SDT.getValue()); // 设置状态为:待工程接口人处理 + updateEO.setDeadline(deadline); + updateEOList.add(updateEO); + + updateEOIdList.add(paramsCollectManifestEO.getId()); + } else { + Map msgMap = new HashMap<>(); + msgMap.put("nioNumber", paramsCollectManifestEO.getNioNumber()); + msgMap.put("state", paramsCollectManifestEO.getState()); + msgMap.put("type", "1"); + msgMapList.add(msgMap); + } + + } else { + Map msgMap = new HashMap<>(); + msgMap.put("nioNumber", paramsCollectManifestEO.getNioNumber()); + msgMap.put("state", paramsCollectManifestEO.getState()); + msgMap.put("type", "2"); + msgMapList.add(msgMap); + } } boolean isSuccess = updateBatchById(updateEOList); - // 消息内容 - List paramsCollectManifestEOList = listByIds(Arrays.asList(paramsCollectManifestIdStr)); - List sdtList = paramsCollectManifestEOList.stream().map(ParamsCollectManifestEO::getSdt).distinct().collect(Collectors.toList()); - if (CollectionUtil.isEmpty(sdtList)) { - throw new JeroBootException("没有可下发的工程接口人!"); - } - for(String sdt : sdtList) { + if (isSuccess) { + // 消息内容 + List afterUpdateEOList = listByIds(updateEOIdList); + List sdtList = afterUpdateEOList.stream() + .map(ParamsCollectManifestEO::getSdt) + .distinct() + .collect(Collectors.toList()); + if (CollectionUtil.isEmpty(sdtList)) { + throw new JeroBootException("没有可下发的工程接口人!"); + } + for (String sdt : sdtList) { - StringBuilder connectBuilder = new StringBuilder(); - connectBuilder.append("You are required to fill in "); - for (int i=0; ithe link,"; + String contentInfo = connectBuilder.substring(0, connectBuilder.toString().length() - 1) + " and other parameter items, please enter " + href + " and fill in the relevant information."; + String msgTitle = "You have a homo parameter task to complete"; + + // 发送系统消息 + SysAnnouncement sysAnnouncement = new SysAnnouncement(); + sysAnnouncement.setDelFlag("0"); + sysAnnouncement.setSendStatus("0"); + sysAnnouncement.setSendTime(new Date()); + sysAnnouncement.setMsgCategory(MessageTypeEnum.HOMO_TASK.getValue());//消息类型 + sysAnnouncement.setMsgType(CommonConstant.MSG_TYPE_UESR);//指定用户 + sysAnnouncement.setTitile(msgTitle); + sysAnnouncement.setMsgContent(content); + sysAnnouncement.setMsgContentInfo(contentInfo); + sysAnnouncement.setUserIds(sysUser.getId()); + sysAnnouncementService.saveAnnouncement(sysAnnouncement); + + JSONObject obj = new JSONObject(); + obj.put(WebsocketConst.MSG_CMD, WebsocketConst.CMD_TOPIC); + obj.put(WebsocketConst.MSG_ID, paramsManifestId); + obj.put(WebsocketConst.MSG_TXT, contentInfo); + webSocket.sendMessage(obj.toJSONString()); + + // 发送飞书消息 + try { + FeishuMsgVo feishuMsgVo = new FeishuMsgVo(); + feishuMsgVo.setTitle(MessageTypeEnum.HOMO_TASK.getName()); + feishuMsgVo.setContent(content); + feishuMsgVo.setUrl(hrefFeishu); + feishuMsgVo.setTaskType(MessageTypeEnum.HOMO_TASK.getName()); + feishuMsgVo.setProject(projectInfo.getProjectName()); // 车型-年款 区域 + feishuMsgVo.setInitiator(currentUser.getUsername()); + feishuMsgVo.setDueDate(sdf.format(deadline)); // 最早时间 + feishuService.sendCardMsg(thirdIds, feishuMsgVo); + } catch (IOException e) { + log.error("飞书消息推送失败"); + } + } + } + + return getMsgOfIssueCollection(msgMapList, cut); + } + + @Override + public List issueCollectionAll(ParamsCollectManifestVO paramsCollectManifestVO) { + if (StringUtils.isEmpty(paramsCollectManifestVO.getProjectId()) + || StringUtils.isEmpty(paramsCollectManifestVO.getParamsManifestId()) + || StringUtils.isEmpty(paramsCollectManifestVO.getCut()) + || paramsCollectManifestVO.getDeadline() == null ) { + throw new JeroBootException("参数不能为空!"); + } + String projectId = paramsCollectManifestVO.getProjectId(); + String paramsManifestId = paramsCollectManifestVO.getParamsManifestId(); + String cut = paramsCollectManifestVO.getCut(); + Date deadline = paramsCollectManifestVO.getDeadline(); + + LoginUser currentUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); // 获取当前登录人 + ParamsManifestVO projectInfo = paramsManifestEOService.getProjectById(projectId); // 获取项目信息 + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + List updateEOList = new ArrayList<>(); + List> msgMapList = new ArrayList<>(); + List updateEOIdList = new ArrayList<>(); + + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(ParamsCollectManifestEO::getParamsManifestId, paramsManifestId) + .notIn(ParamsCollectManifestEO::getControlType, ControlTypeEnum.Title.getValue()) + .orderByAsc(ParamsCollectManifestEO::getNioNumber); + List paramsCollectManifestEOList = list(queryWrapper); + for (ParamsCollectManifestEO paramsCollectManifestEO : paramsCollectManifestEOList) { + // 判断参数项状态 + if (CollectManifestStateEnum.WAIT_COLLECT.getValue().equals(paramsCollectManifestEO.getState())) { + if (StringUtils.isNotBlank(paramsCollectManifestEO.getSdt())) { + ParamsCollectManifestEO updateEO = new ParamsCollectManifestEO(); + updateEO.setId(paramsCollectManifestEO.getId()); + updateEO.setState(CollectManifestStateEnum.WAIT_SDT.getValue()); // 设置状态为:待工程接口人处理 + updateEO.setDeadline(deadline); + updateEOList.add(updateEO); + + updateEOIdList.add(paramsCollectManifestEO.getId()); + } else { + Map msgMap = new HashMap<>(); + msgMap.put("nioNumber", paramsCollectManifestEO.getNioNumber()); + msgMap.put("state", paramsCollectManifestEO.getState()); + msgMap.put("state", "1"); + msgMapList.add(msgMap); + } + + } else { + Map msgMap = new HashMap<>(); + msgMap.put("nioNumber", paramsCollectManifestEO.getNioNumber()); + msgMap.put("state", paramsCollectManifestEO.getState()); + msgMap.put("type", "2"); + msgMapList.add(msgMap); + } + } + boolean isSuccess = updateBatchById(updateEOList); + + if (isSuccess) { + // 消息内容 + List afterUpdateEOList = listByIds(updateEOIdList); + List sdtList = afterUpdateEOList.stream() + .map(ParamsCollectManifestEO::getSdt) + .distinct() + .collect(Collectors.toList()); + if (CollectionUtil.isEmpty(sdtList)) { + throw new JeroBootException("没有可下发的工程接口人!"); + } + for (String sdt : sdtList) { + + StringBuilder connectBuilder = new StringBuilder(); + connectBuilder.append("You are required to fill in "); + for (int i = 0; i < afterUpdateEOList.size(); i++) { + ParamsCollectManifestEO paramsCollectManifestEO = afterUpdateEOList.get(i); + if (sdt.equals(paramsCollectManifestEO.getSdt()) && i < 3) { + connectBuilder.append(paramsCollectManifestEO.getNioNumber()).append("-").append(paramsCollectManifestEO.getParamsName()).append(","); + } + } + String content = connectBuilder.substring(0, connectBuilder.toString().length() - 1) + " and other parameter items, please enter the link to handle it."; + + SysUser sysUser = sysUserService.getUserByName(sdt); + String[] thirdIds = new String[1]; + thirdIds[0] = sysUser.getThirdId(); + String hrefFeishu = backUrl + "/ParameterItemCollection?id=" + paramsManifestId + "&projectId=" + projectId; + String href = "the link,"; + String contentInfo = connectBuilder.substring(0, connectBuilder.toString().length() - 1) + " and other parameter items, please enter " + href + " and fill in the relevant information."; + String msgTitle = "You have a homo parameter task to complete"; + + // 发送系统消息 + SysAnnouncement sysAnnouncement = new SysAnnouncement(); + sysAnnouncement.setDelFlag("0"); + sysAnnouncement.setSendStatus("0"); + sysAnnouncement.setSendTime(new Date()); + sysAnnouncement.setMsgCategory(MessageTypeEnum.HOMO_TASK.getValue());//消息类型 + sysAnnouncement.setMsgType(CommonConstant.MSG_TYPE_UESR);//指定用户 + sysAnnouncement.setTitile(msgTitle); + sysAnnouncement.setMsgContent(content); + sysAnnouncement.setMsgContentInfo(contentInfo); + sysAnnouncement.setUserIds(sysUser.getId()); + sysAnnouncementService.saveAnnouncement(sysAnnouncement); + + JSONObject obj = new JSONObject(); + obj.put(WebsocketConst.MSG_CMD, WebsocketConst.CMD_TOPIC); + obj.put(WebsocketConst.MSG_ID, paramsManifestId); + obj.put(WebsocketConst.MSG_TXT, contentInfo); + webSocket.sendMessage(obj.toJSONString()); + + // 发送飞书消息 + try { + FeishuMsgVo feishuMsgVo = new FeishuMsgVo(); + feishuMsgVo.setTitle(MessageTypeEnum.HOMO_TASK.getName()); + feishuMsgVo.setContent(content); + feishuMsgVo.setUrl(hrefFeishu); + feishuMsgVo.setTaskType(MessageTypeEnum.HOMO_TASK.getName()); + feishuMsgVo.setProject(projectInfo.getProjectName()); // 车型-年款 区域 + feishuMsgVo.setInitiator(currentUser.getUsername()); + feishuMsgVo.setDueDate(sdf.format(deadline)); + feishuService.sendCardMsg(thirdIds, feishuMsgVo); + } catch (IOException e) { + log.error("飞书消息推送失败"); } } - String content = connectBuilder.substring(0, connectBuilder.toString().length()-1) + " and other parameter items, please enter the link to handle it."; - - SysUser sysUser = sysUserService.getUserByName(sdt); - String[] thirdIds = new String[1]; - thirdIds[0] = sysUser.getThirdId(); - String hrefFeishu = backUrl + "/ParameterItemCollection?id=" + paramsManifestId + "&projectId=" + projectId; - String href = "the link,"; - String contentInfo = connectBuilder.substring(0, connectBuilder.toString().length()-1) + " and other parameter items, please enter " + href + " and fill in the relevant information."; - String msgTitle = "You have a homo parameter task to complete"; - - // TODO 为什么不用SendMessageUtils工具类呢? - // 发送系统消息 - SysAnnouncement sysAnnouncement = new SysAnnouncement(); - sysAnnouncement.setDelFlag("0"); - sysAnnouncement.setSendStatus("0"); - sysAnnouncement.setSendTime(new Date()); - sysAnnouncement.setMsgCategory(MessageTypeEnum.HOMO_TASK.getValue());//消息类型 - sysAnnouncement.setMsgType(CommonConstant.MSG_TYPE_UESR);//指定用户 - sysAnnouncement.setTitile(msgTitle); - sysAnnouncement.setMsgContent(content); - sysAnnouncement.setMsgContentInfo(contentInfo); - sysAnnouncement.setUserIds(sysUser.getId()); - sysAnnouncementService.saveAnnouncement(sysAnnouncement); - - // 发送飞书消息 - try { - FeishuMsgVo feishuMsgVo = new FeishuMsgVo(); - feishuMsgVo.setTitle(MessageTypeEnum.HOMO_TASK.getName()); - feishuMsgVo.setContent(content); - feishuMsgVo.setUrl(hrefFeishu); - feishuMsgVo.setTaskType(MessageTypeEnum.HOMO_TASK.getName()); - feishuService.sendCardMsg(thirdIds, feishuMsgVo); - } catch (IOException e) { - log.error("飞书消息推送失败"); - } } - return isSuccess; + return getMsgOfIssueCollection(msgMapList, cut); } + private List getMsgOfIssueCollection(List> msgMapList, String cut) { + List msgList = new ArrayList<>(); + Map collectManifestStateEnumMap = CollectManifestStateEnum.toMap(cut); + + for (Map msgMap : msgMapList) { + String nioNumber = msgMap.get("nioNumber"); + String state = msgMap.get("state"); + String stateName = collectManifestStateEnumMap.get(state); + String type = msgMap.get("type"); + StringBuilder stringBuilder = new StringBuilder(); + if ("1".equals(type)) { + if (CutEnum.EN.getValue().equals(cut)) { + stringBuilder.append("NIO number is ").append("").append(nioNumber).append("").append(" ,the sdt has not been filled in. Please fill in the sdt before issuing and collecting."); + } else { + stringBuilder.append("NIO编号为").append("").append(nioNumber).append("").append("工程接口人没有填写,请填写完工程接口人再进行下发收集。"); + } + + } else { + if (CutEnum.EN.getValue().equals(cut)) { + stringBuilder.append("NIO number is ").append(nioNumber).append(",state is ").append("").append(stateName).append("").append(",no operation permission for this button."); + } else { + stringBuilder.append("NIO编号为").append(nioNumber).append(",状态为").append("").append(stateName).append("").append(",没有此按钮的操作权限。"); + } + + } + + msgList.add(stringBuilder.toString()); + } + if (CutEnum.EN.getValue().equals(cut)) { + msgList.add("Homologation Engineer can operate when data state is 'Wait Collect'、'Sdt Back' or 'Change'"); + } else { + msgList.add("认证工程师数据状态为 '待发起收集'、'工程接口人退回'或'变更' 时,才有权限操作此按钮。"); + } + return msgList; + } + + @Override public List> getConfigLabelList(ParamsCollectManifestVO paramsCollectManifestVO) { String paramsManifestId = paramsCollectManifestVO.getParamsManifestId();