|
|
@@ -58,6 +58,9 @@ public class EquipmentMaintenancePlanJob extends AbstractJob {
|
|
|
// 根据设备检定校准计划 开启检定校准记录
|
|
|
startSbjdjzjlFlow();
|
|
|
|
|
|
+ //设备期间核查
|
|
|
+ periodicVerification();
|
|
|
+
|
|
|
// 设备使用年限到期预提醒
|
|
|
equipmentScrapReminder();
|
|
|
|
|
|
@@ -310,7 +313,80 @@ public class EquipmentMaintenancePlanJob extends AbstractJob {
|
|
|
if(Collections.isEmpty(dislodge)){
|
|
|
return;
|
|
|
}
|
|
|
- this.startWorkflow(dislodge);
|
|
|
+ this.startWorkflow(dislodge,"yqsbjdxzjlb","Process_1drpy0r");
|
|
|
+ }
|
|
|
+
|
|
|
+ //期间核查
|
|
|
+ private void periodicVerification()throws Exception{
|
|
|
+ List<Map<String, Object>> addList = new ArrayList<>();
|
|
|
+ //1查出所有计划的数据并且去重
|
|
|
+ String sql = "SELECT " +
|
|
|
+ " s.yi_qi_she_bei_min, " +
|
|
|
+ " s.she_bei_id_, " +
|
|
|
+ " s.bian_hao_, " +
|
|
|
+ " s.he_cha_ri_qi_, " +
|
|
|
+ " s.he_cha_pin_ci_, " +
|
|
|
+ " s.he_cha_can_shu_, " +
|
|
|
+ " s.he_cha_fang_fa_, " +
|
|
|
+ " s.he_cha_jie_guo_pa, " +
|
|
|
+ " s.he_cha_ren_yuan_, " +
|
|
|
+ " s.shang_ci_he_cha_r, " +
|
|
|
+ " s.di_dian_, " +
|
|
|
+ " a.gui_ge_xing_hao_, " +
|
|
|
+ " a.bian_zhi_bu_men_, " +
|
|
|
+ " s.id_ AS zid_, " +
|
|
|
+ " f.id_ AS fid_ " +
|
|
|
+ "FROM t_sbqjhcjhzb s JOIN t_sbqjhcjhb f ON s.parent_id_ = f.id_ JOIN t_sbdj a ON s.she_bei_id_ = a.id_ " +
|
|
|
+ " JOIN ( " +
|
|
|
+ "SELECT s2.she_bei_id_, MAX( s2.create_time_ ) AS max_create_time_ " +
|
|
|
+ "FROM t_sbqjhcjhzb s2 JOIN t_sbqjhcjhb f2 ON s2.parent_id_ = f2.id_ JOIN t_sbdj a2 ON s2.she_bei_id_ = a2.id_ " +
|
|
|
+ "WHERE f2.shi_fou_guo_shen_ = '已完成' AND f2.nian_du_ = YEAR ( NOW( ) ) AND a2.she_bei_zhuang_ta = '正常使用' " +
|
|
|
+ "GROUP BY s2.she_bei_id_ ) t ON s.she_bei_id_ = t.she_bei_id_ " +
|
|
|
+ " AND s.create_time_ = t.max_create_time_ " +
|
|
|
+ "WHERE f.shi_fou_guo_shen_ = '已完成' AND f.nian_du_ = YEAR ( NOW( ) ) AND a.she_bei_zhuang_ta = '正常使用' " ;
|
|
|
+ List<Map<String, Object>> list = (List<Map<String, Object>>) commonDao.query(sql);
|
|
|
+ if(Collections.isEmpty(list)){
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ //2根据上面的数据分别计算上次校准日期+校准周期是否等于今天,是则推送校准记录
|
|
|
+ LocalDate today = LocalDate.now();
|
|
|
+ int currentYear = today.getYear();
|
|
|
+
|
|
|
+ for (Map<String,Object> item:list) {
|
|
|
+ String startData = item.get("he_cha_ri_qi_").toString();
|
|
|
+ LocalDate start = LocalDate.parse(startData, FMT);
|
|
|
+ //开始计算
|
|
|
+ int cycleMonths = Integer.parseInt(item.get("he_cha_pin_ci_").toString());
|
|
|
+ if (cycleMonths <= 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // 保持原始"日",用于月末边界(如 1-31 + 1月 → 2-28)
|
|
|
+ int originalDay = start.getDayOfMonth();
|
|
|
+
|
|
|
+ // 从 start 往后推,找到本年内第一个周期日
|
|
|
+ LocalDate cursor = start;
|
|
|
+ while (cursor.getYear() < currentYear) {
|
|
|
+ cursor = plusMonthsKeepDay(cursor, cycleMonths, originalDay);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 判断今天是否是周期日
|
|
|
+ while (cursor.getYear() == currentYear) {
|
|
|
+ if (cursor.equals(today)) {
|
|
|
+ addList.add(item);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (cursor.isAfter(today)) {
|
|
|
+ break; // 已超过今天,不用再往后看
|
|
|
+ }
|
|
|
+ cursor = plusMonthsKeepDay(cursor, cycleMonths, originalDay);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //需要查询当天是否已经推送过了,不能重复推送
|
|
|
+ List<String> dislodge = without(addList);
|
|
|
+ if(Collections.isEmpty(dislodge)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.startWorkflow(dislodge,"yqsbqjhcjlb","Process_094si21");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -375,7 +451,55 @@ public class EquipmentMaintenancePlanJob extends AbstractJob {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ private List<String> without(List<Map<String, Object>> added) throws Exception{
|
|
|
+ List<Map<String, Object>> addList = new ArrayList<>();
|
|
|
+ List<String> result = new ArrayList<>();
|
|
|
+ if(Collections.isEmpty(added)){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ String ids = added.stream()
|
|
|
+ .map(map -> String.valueOf(map.get("she_bei_id_")))
|
|
|
+ .collect(Collectors.joining(","));
|
|
|
+ String date = LocalDate.now().toString();
|
|
|
+ String sql = "select * from t_yqsbqjhcjlb where find_in_set(she_bei_id_,'"+ids+"') and he_cha_ri_qi_ = '" + date + "'";
|
|
|
+ List<Map<String, Object>> list = (List<Map<String, Object>>) commonDao.query(sql);
|
|
|
+ if(Collections.isNotEmpty(list)){
|
|
|
+ Set<String> bCodes = list.stream()
|
|
|
+ .map(it -> (String) it.get("she_bei_id_"))
|
|
|
+ .collect(Collectors.toSet());
|
|
|
+ addList = added.stream()
|
|
|
+ .filter(it -> !bCodes.contains(it.get("she_bei_id_")))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }else{
|
|
|
+ //当天还没有进行推送
|
|
|
+ addList=added;
|
|
|
+ }
|
|
|
+ for (Map<String,Object> item:addList) {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ String id = UniqueIdUtil.getId();
|
|
|
+ map.put("id_",id);
|
|
|
+ map.put("bian_zhi_bu_men_",item.get("bian_zhi_bu_men_").toString());
|
|
|
+ map.put("di_dian_",item.get("di_dian_").toString());
|
|
|
+ map.put("bian_zhi_ren_",item.get("he_cha_ren_yuan_").toString());
|
|
|
+ map.put("bian_zhi_shi_jian",date+" 06:00");
|
|
|
+ map.put("he_cha_ri_qi_",date);
|
|
|
+ map.put("she_bei_id_",item.get("she_bei_id_").toString());
|
|
|
+ map.put("yi_qi_bian_hao_",item.get("bian_hao_").toString());
|
|
|
+ map.put("yi_qi_she_bei_min",item.get("yi_qi_she_bei_min").toString());
|
|
|
+ map.put("yi_qi_gui_ge_",item.get("gui_ge_xing_hao_,").toString());
|
|
|
+ map.put("he_cha_nei_rong_",item.get("he_cha_can_shu_").toString());
|
|
|
+ map.put("xiao_zhun_dian_bi",item.get("xiu_zheng_yin_zi_").toString());
|
|
|
+ map.put("he_cha_yi_ju_",item.get("he_cha_jie_guo_pa").toString());
|
|
|
+ map.put("shang_yi_ci_he_ch",item.get("shang_ci_he_cha_r").toString());
|
|
|
+ map.put("he_cha_zhou_qi_",item.get("he_cha_pin_ci_").toString());
|
|
|
+ map.put("ji_hua_zi_biao_id",item.get("zid_").toString());
|
|
|
+ map.put("ji_hua_zhu_biao_i",item.get("fid_").toString());
|
|
|
+ map.put("shi_fou_guo_shen_","待处理");
|
|
|
+ result.add(id);
|
|
|
+ commonDao.execute(this.buildInsertSql(map, "t_yqsbqjhcjlb"));
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
// 设备档案增加使用年限字段,并且到期提前1年提醒设备保管人到期,需要进行报废的消息
|
|
|
// 根据 出厂日期 和使用年限判断
|
|
|
private void equipmentScrapReminder(){
|
|
|
@@ -547,7 +671,7 @@ public class EquipmentMaintenancePlanJob extends AbstractJob {
|
|
|
}
|
|
|
|
|
|
|
|
|
- protected void startWorkflow(List<String> dislodge) {
|
|
|
+ protected void startWorkflow(List<String> dislodge,String formKey,String defKey) {
|
|
|
if (Collections.isEmpty(dislodge)) return;
|
|
|
IBpmInstService bpmInstService = AppUtil.getBean(IBpmInstService.class);
|
|
|
if (StringUtils.isBlank(ContextUtil.getCurrentAccessToken())) {
|
|
|
@@ -556,7 +680,7 @@ public class EquipmentMaintenancePlanJob extends AbstractJob {
|
|
|
ContextUtil.setCurrentAccessToken(accessToken);
|
|
|
}
|
|
|
String[] arr = dislodge.toArray(new String[0]);
|
|
|
- bpmInstService.startFlowFromList(arr, "yqsbjdxzjlb", "Process_1drpy0r");
|
|
|
+ bpmInstService.startFlowFromList(arr, formKey, defKey);
|
|
|
}
|
|
|
|
|
|
public String getSetting() {
|