认证-参数项收集-变更:一键下发收集

This commit is contained in:
liyawei
2022-07-19 09:14:45 +08:00
parent 7207132f01
commit f4def64e10
3 changed files with 286 additions and 64 deletions
@@ -381,13 +381,24 @@ public class ParamsCollectManifestEOController extends JeroController<ParamsColl
@ApiOperation(value="参数项收集清单-下发收集", notes="参数项收集清单-下发收集")
@PostMapping(value = "/issueCollection")
// @RequiresPermissions("params:collectManifest:issue")
public Result<?> issueCollection(ParamsCollectManifestVO paramsCollectManifestVO) {
boolean isSuccess = paramsCollectManifestEOService.issueCollection(paramsCollectManifestVO);
if (isSuccess) {
return Result.OK("下发收集成功!");
} else {
return Result.error("下发收集失败!");
}
public Result<List<String>> issueCollection(ParamsCollectManifestVO paramsCollectManifestVO) {
List<String> 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<List<String>> issueCollectionAll(ParamsCollectManifestVO paramsCollectManifestVO) {
List<String> msgList = paramsCollectManifestEOService.issueCollectionAll(paramsCollectManifestVO);
return Result.OK(msgList);
}
/**
@@ -126,7 +126,10 @@ public interface IParamsCollectManifestEOService extends IService<ParamsCollectM
boolean updateDreBatch(ParamsCollectManifestVO paramsCollectManifestVO);
// 下发收集
boolean issueCollection(ParamsCollectManifestVO paramsCollectManifestVO);
List<String> issueCollection(ParamsCollectManifestVO paramsCollectManifestVO);
// 一键下发收集
List<String> issueCollectionAll(ParamsCollectManifestVO paramsCollectManifestVO);
// 配置-下拉选项
List<Map<String, String>> getConfigLabelList(ParamsCollectManifestVO paramsCollectManifestVO);
@@ -1351,82 +1351,290 @@ public class ParamsCollectManifestEOServiceImpl extends ServiceImpl<ParamsCollec
}
@Override
public boolean issueCollection(ParamsCollectManifestVO paramsCollectManifestVO) {
public List<String> 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<ParamsCollectManifestEO> updateEOList = new ArrayList<>();
List<Map<String, String>> msgMapList = new ArrayList<>();
List<String> updateEOIdList = new ArrayList<>();
for (int i=0; i<paramsCollectManifestIdStr.length; i++) {
ParamsCollectManifestEO updateEO = new ParamsCollectManifestEO();
updateEO.setId(paramsCollectManifestIdStr[i]);
updateEO.setState(CollectManifestStateEnum.WAIT_SDT.getValue()); // 设置状态为:待工程接口人处理
updateEOList.add(updateEO);
List<ParamsCollectManifestEO> 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<String, String> msgMap = new HashMap<>();
msgMap.put("nioNumber", paramsCollectManifestEO.getNioNumber());
msgMap.put("state", paramsCollectManifestEO.getState());
msgMap.put("type", "1");
msgMapList.add(msgMap);
}
} else {
Map<String, String> 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<ParamsCollectManifestEO> paramsCollectManifestEOList = listByIds(Arrays.asList(paramsCollectManifestIdStr));
List<String> sdtList = paramsCollectManifestEOList.stream().map(ParamsCollectManifestEO::getSdt).distinct().collect(Collectors.toList());
if (CollectionUtil.isEmpty(sdtList)) {
throw new JeroBootException("没有可下发的工程接口人!");
}
for(String sdt : sdtList) {
if (isSuccess) {
// 消息内容
List<ParamsCollectManifestEO> afterUpdateEOList = listByIds(updateEOIdList);
List<String> 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<paramsCollectManifestEOList.size(); i++) {
ParamsCollectManifestEO paramsCollectManifestEO = paramsCollectManifestEOList.get(i);
if (sdt.equals(paramsCollectManifestEO.getSdt()) && i<3) {
connectBuilder.append(paramsCollectManifestEO.getNioNumber()).append("-").append(paramsCollectManifestEO.getParamsName()).append(",");
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 = "<a href='/ParameterItemCollection?id=" + paramsManifestId + "&projectId=" + projectId + "'" + " target='_blank'>the link</a>,";
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<String> 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<ParamsCollectManifestEO> updateEOList = new ArrayList<>();
List<Map<String, String>> msgMapList = new ArrayList<>();
List<String> updateEOIdList = new ArrayList<>();
LambdaQueryWrapper<ParamsCollectManifestEO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ParamsCollectManifestEO::getParamsManifestId, paramsManifestId)
.notIn(ParamsCollectManifestEO::getControlType, ControlTypeEnum.Title.getValue())
.orderByAsc(ParamsCollectManifestEO::getNioNumber);
List<ParamsCollectManifestEO> 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<String, String> msgMap = new HashMap<>();
msgMap.put("nioNumber", paramsCollectManifestEO.getNioNumber());
msgMap.put("state", paramsCollectManifestEO.getState());
msgMap.put("state", "1");
msgMapList.add(msgMap);
}
} else {
Map<String, String> 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<ParamsCollectManifestEO> afterUpdateEOList = listByIds(updateEOIdList);
List<String> 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 = "<a href='/ParameterItemCollection?id=" + paramsManifestId + "&projectId=" + projectId + "'" + " target='_blank'>the link</a>,";
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 = "<a href='/ParameterItemCollection?id=" + paramsManifestId + "&projectId=" + projectId + "'" + " target='_blank'>the link</a>,";
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<String> getMsgOfIssueCollection(List<Map<String, String>> msgMapList, String cut) {
List<String> msgList = new ArrayList<>();
Map<String,String> collectManifestStateEnumMap = CollectManifestStateEnum.toMap(cut);
for (Map<String, String> 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("<span style='color: red'>").append(nioNumber).append("</span>").append(" ,the sdt has not been filled in. Please fill in the sdt before issuing and collecting.");
} else {
stringBuilder.append("NIO编号为").append("<span style='color: red'>").append(nioNumber).append("</span>").append("工程接口人没有填写,请填写完工程接口人再进行下发收集。");
}
} else {
if (CutEnum.EN.getValue().equals(cut)) {
stringBuilder.append("NIO number is ").append(nioNumber).append(",state is ").append("<span style='color: red'>").append(stateName).append("</span>").append(",no operation permission for this button.");
} else {
stringBuilder.append("NIO编号为").append(nioNumber).append(",状态为").append("<span style='color: red'>").append(stateName).append("</span>").append(",没有此按钮的操作权限。");
}
}
msgList.add(stringBuilder.toString());
}
if (CutEnum.EN.getValue().equals(cut)) {
msgList.add("<span style='color: red'>Homologation Engineer can operate when data state is 'Wait Collect'、'Sdt Back' or 'Change'</span>");
} else {
msgList.add("<span style='color: red'>认证工程师数据状态为 '待发起收集'、'工程接口人退回'或'变更' 时,才有权限操作此按钮。</span>");
}
return msgList;
}
@Override
public List<Map<String, String>> getConfigLabelList(ParamsCollectManifestVO paramsCollectManifestVO) {
String paramsManifestId = paramsCollectManifestVO.getParamsManifestId();