新增参数清单截止时间定时任务,认证参数任务模块消息处理完毕

This commit is contained in:
CD
2022-10-26 14:33:21 +08:00
parent 69e26ff9bb
commit 6794e56cfe
6 changed files with 193 additions and 2 deletions
@@ -26,4 +26,6 @@ public interface ParamsCollectManifestEOMapper extends BaseMapper<ParamsCollectM
List<ParamsCollectManifestEO> listInfoOfTitle(@Param("paramsManifestId") String paramsManifestId);
IPage pageInfo(@Param("page") IPage page, @Param("paramsCollectManifestEO") ParamsCollectManifestEO paramsCollectManifestEO);
}
List<ParamsCollectManifestEO> queryByParamManifestId(@Param("paramsManifestId") String paramsManifestIdString);
}
@@ -108,4 +108,8 @@
order by del_flag desc, add_flag desc, change_flag desc, nio_number asc
</select>
</mapper>
<select id="queryByParamManifestId" resultMap="ParamsCollectManifestEOResultMap">
select * from params_collect_manifest where params_manifest_id = #{paramsManifestId}
</select>
</mapper>
@@ -164,4 +164,8 @@ public interface IParamsCollectManifestEOService extends IService<ParamsCollectM
// 调整责任领域
List<String> updateBatchDutyTerritory(ParamsCollectManifestVO paramsCollectManifestVO);
//监控参数收集任务的截止时间,并根据时间段发送飞书
void checkDeadline();
}
@@ -2871,4 +2871,153 @@ public class ParamsCollectManifestEOServiceImpl extends ServiceImpl<ParamsCollec
// return map;
// }
/**
* 监控参数收集任务的截止时间,并根据时间段发送飞书
*/
@Override
public void checkDeadline() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String now = sdf.format(new Date());// 当前时间
QueryWrapper<ParamsManifestEO> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("state", ManifestStateEnum.COLLECTING.getValue());
List<ParamsManifestEO> manifestEOS = paramsManifestEOService.list(queryWrapper);
for (ParamsManifestEO manifestEO : manifestEOS) {
//项目名称
ParamsManifestVO projectInfo = paramsManifestEOService.getProjectById(manifestEO.getProjectId());
if (ObjectUtils.isNotEmpty(projectInfo)) {
//url
String urlParamsStr = parseUrlParams(manifestEO);
String hrefFeishu = backUrl + "/ParameterItemCollection" + urlParamsStr;
//查出对应清单
List<ParamsCollectManifestEO> collectManifestEOS = paramsCollectManifestEOMapper.queryByParamManifestId(manifestEO.getId());
Map<String, List<String>> seven = new HashMap<>();
Map<String, List<String>> three = new HashMap<>();
Map<String, List<String>> today = new HashMap<>();
for (ParamsCollectManifestEO collectManifestEO : collectManifestEOS) {
String thirdId = null;
if (CollectManifestStateEnum.WAIT_SDT.getValue().equals(collectManifestEO.getState())
||CollectManifestStateEnum.DRE_BACK.getValue().equals(collectManifestEO.getState())) {
//工程接口人
if (ObjectUtils.isNotEmpty(collectManifestEO.getSdt())) {
SysUser sdt = sysUserService.getUserByName(collectManifestEO.getSdt());
if (ObjectUtils.isNotEmpty(sdt)) {
thirdId = sdt.getThirdId();
}
}
} else if (CollectManifestStateEnum.WAIT_FILL.getValue().equals(collectManifestEO.getState())
||CollectManifestStateEnum.CERT_BACK.getValue().equals(collectManifestEO.getState())) {
//填写人
if (ObjectUtils.isNotEmpty(collectManifestEO.getDre())) {
SysUser dre = sysUserService.getUserByName(collectManifestEO.getDre());
if (ObjectUtils.isNotEmpty(dre)) {
thirdId = dre.getThirdId();
}
}
}
//截止时间
if (ObjectUtils.isNotEmpty(thirdId) && ObjectUtils.isNotEmpty(collectManifestEO.getDeadline())) {
String deadline =sdf.format(collectManifestEO.getDeadline());
//判断日期
int days = 0;
try {
days = (int) (sdf.parse(deadline).getTime() - sdf.parse(now).getTime()) / (24 * 60 * 60 * 1000);
} catch (Exception e) {
e.printStackTrace();
throw new JeroBootException("时间获取失败");
}
if (days == 7) {
deadlineDateMap(seven, collectManifestEO, thirdId);
} else if (days == 3) {
deadlineDateMap(three, collectManifestEO, thirdId);
} else if (now.equals(deadline)) {
deadlineDateMap(today, collectManifestEO, thirdId);
}
}
}
String title = MessageType2Enum.HOMO_PARAMETER_COLLECTION.getCn() + "/" + MessageType2Enum.HOMO_PARAMETER_COLLECTION.getEn();
String cnContentLower = "项目: " + projectInfo.getProjectName() +
"\n发起人: 系统";
String enContentLower = "Project: " + projectInfo.getProjectName() +
"\nInitiator: system";
if (!seven.isEmpty()) {
for (String key : seven.keySet()) {
String[] thirds = new String[1];
thirds[0] = key;
List<String> stringList = seven.get(key);
String join = StringUtils.join(stringList, ",");
try {
FeishuMsg2Vo feishuMsgVo = new FeishuMsg2Vo();
feishuMsgVo.setTitle(title);
feishuMsgVo.setCnContentUpper("您参与填写的参数"+ join +",还有7天到期,请及时查看处理");
feishuMsgVo.setCnContentLower(cnContentLower);
feishuMsgVo.setEnContentUpper("The parameter "+ join +" you filled in will expire in 7 days. Please check and address it in a timely manner");
feishuMsgVo.setEnContentLower(enContentLower);
feishuMsgVo.setUrl(hrefFeishu);
feishuMsgVo.setColor(MsgColorEnum.GREEN.getValue()); // 颜色
feishuService.sendCard(thirds, feishuMsgVo);
} catch (IOException e) {
log.error("飞书消息推送失败");
}
}
}
if (!three.isEmpty()) {
for (String key : three.keySet()) {
String[] thirds = new String[1];
thirds[0] = key;
List<String> stringList = three.get(key);
String join = StringUtils.join(stringList, ",");
try {
FeishuMsg2Vo feishuMsgVo = new FeishuMsg2Vo();
feishuMsgVo.setTitle(title);
feishuMsgVo.setCnContentUpper("您参与填写的参数"+ join +",还有3天到期,请及时查看处理");
feishuMsgVo.setCnContentLower(cnContentLower);
feishuMsgVo.setEnContentUpper("The parameter "+ join +" you filled in will expire in 3 days. Please check and address it in a timely manner");
feishuMsgVo.setEnContentLower(enContentLower);
feishuMsgVo.setUrl(hrefFeishu);
feishuMsgVo.setColor(MsgColorEnum.GREEN.getValue()); // 颜色
feishuService.sendCard(thirds, feishuMsgVo);
} catch (IOException e) {
log.error("飞书消息推送失败");
}
}
}
if (!today.isEmpty()) {
for (String key : today.keySet()) {
String[] thirds = new String[1];
thirds[0] = key;
List<String> stringList = today.get(key);
String join = StringUtils.join(stringList, ",");
try {
FeishuMsg2Vo feishuMsgVo = new FeishuMsg2Vo();
feishuMsgVo.setTitle(title);
feishuMsgVo.setCnContentUpper("您参与填写的参数"+ join +",将于今天到期,请及时查看处理");
feishuMsgVo.setCnContentLower(cnContentLower);
feishuMsgVo.setEnContentUpper("The parameter "+ join +" you filled in will expire today. Please check and address it in a timely manner");
feishuMsgVo.setEnContentLower(enContentLower);
feishuMsgVo.setUrl(hrefFeishu);
feishuMsgVo.setColor(MsgColorEnum.GREEN.getValue()); // 颜色
feishuService.sendCard(thirds, feishuMsgVo);
} catch (IOException e) {
log.error("飞书消息推送失败");
}
}
}
}
}
}
private void deadlineDateMap(Map<String, List<String>> today, ParamsCollectManifestEO collectManifestEO, String thirdId) {
List<String> stringList = today.get(thirdId);
if (ObjectUtils.isEmpty(stringList)) {
stringList = new ArrayList<>();
stringList.add("NIO-" + collectManifestEO.getNioNumber());
today.put(thirdId, stringList);
} else {
stringList.add("NIO-" + collectManifestEO.getNioNumber());
}
}
}
@@ -0,0 +1,30 @@
package com.jero.modules.cert.collect.task;
import com.jero.modules.cert.collect.service.IParamsCollectManifestEOService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
@Slf4j
public class ScheduledTask {
@Autowired
private IParamsCollectManifestEOService paramsCollectManifestEOServicea;
/**
* 监控参数收集任务的截止时间,并根据时间段发送飞书
*/
//@Scheduled(cron = "0 30 14 * * ?")
@Scheduled(cron = "0 0 0 */1 * ?")
public void checkTime() {
log.info("-----checkDeadline-----begin-----------");
paramsCollectManifestEOServicea.checkDeadline();
log.info("-----checkDeadline------end-----------");
}
}
@@ -11,6 +11,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
import java.net.InetAddress;
@@ -25,6 +26,7 @@ import java.net.UnknownHostException;
@SpringBootApplication
@EnableEurekaClient
@EnableFeignClients
@EnableScheduling
public class LawNioApplication extends SpringBootServletInitializer {
@Override