|
|
@@ -0,0 +1,557 @@
|
|
|
+package com.malk.yibaoju.service.impl;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.malk.server.aliwork.YDConf;
|
|
|
+import com.malk.server.aliwork.YDParam;
|
|
|
+import com.malk.service.aliwork.YDClient;
|
|
|
+import com.malk.service.aliwork.YDService;
|
|
|
+import com.malk.utils.UtilDateTime;
|
|
|
+import com.malk.utils.UtilMap;
|
|
|
+import com.malk.yibaoju.service.YBJService;
|
|
|
+import lombok.SneakyThrows;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.format.TextStyle;
|
|
|
+import java.time.temporal.TemporalAdjusters;
|
|
|
+import java.util.*;
|
|
|
+import java.util.concurrent.ExecutionException;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+
|
|
|
+@Service
|
|
|
+@Slf4j
|
|
|
+public class YBJServiceImpl implements YBJService {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private YDClient ydClient;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private YDService ydService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 每月创建护理计划
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @SneakyThrows
|
|
|
+ public void syncNursePlan() {
|
|
|
+
|
|
|
+ YDParam ydParam = new YDParam();
|
|
|
+ log.info("创建护理计划定时任务Start",new Date());
|
|
|
+
|
|
|
+ ydParam = YDParam.builder()
|
|
|
+ .formUuid("FORM-RK966E7105DFD27FA7EQHAOH9IFS2RN6MP3OL2") //获取护理计划
|
|
|
+ .searchFieldJson(JSON.toJSONString(UtilMap.map("selectField_lo2b6bvf","正常")))//护理对象暂停和正常、月度计划创建只查询正常的护理计划
|
|
|
+ .build();
|
|
|
+ //pagesize设为1获取总数
|
|
|
+ ydParam.setPageSize(1);
|
|
|
+ long totalCount = ydClient.queryData(ydParam, YDConf.FORM_QUERY.retrieve_search_form).getTotalCount();
|
|
|
+
|
|
|
+ float pageSize = 50;
|
|
|
+ ydParam.setCurrentPage(1);
|
|
|
+ ydParam.setPageSize((int) pageSize);
|
|
|
+ List<Map> dataList = new ArrayList<>();
|
|
|
+ for (int page = 1; page <= Math.ceil(totalCount / pageSize); page++) {
|
|
|
+ ydParam.setCurrentPage(page);
|
|
|
+ //创建护理计划 1次获取50条
|
|
|
+ dataList = (List<Map>) ydClient.queryData(ydParam, YDConf.FORM_QUERY.retrieve_search_form).getData();
|
|
|
+
|
|
|
+ log.info("dataList:{}-----page:"+page+"---",dataList.size());
|
|
|
+
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
+ //获取当前日期是本月几号
|
|
|
+ int dayOfMonth = currentDate.getDayOfMonth();
|
|
|
+ //获取本月天数
|
|
|
+ int daysInMonth = currentDate.lengthOfMonth();
|
|
|
+
|
|
|
+ dataList.forEach(dataItem -> {
|
|
|
+
|
|
|
+ Map formMap = (Map) dataItem.get("formData");
|
|
|
+
|
|
|
+ List<Map> mapList = (List<Map>) formMap.get("tableField_lo3pmohx");
|
|
|
+
|
|
|
+ for (int i =0 ; i <=(daysInMonth-dayOfMonth) ; i++) {
|
|
|
+ //获取当前日期是本月几号
|
|
|
+ LocalDate currentDay = LocalDate.now();
|
|
|
+ //获取是周几
|
|
|
+ String dayOfWeek = currentDay.plusDays(i).getDayOfWeek().getDisplayName(TextStyle.FULL, new Locale("zh", "CN"));
|
|
|
+ //获取循环每天的日期
|
|
|
+ LocalDate nextDay = currentDate.plusDays(i);
|
|
|
+ List<Map> maps = mapList.stream().filter(items -> items.get("selectField_lo3pmohy").equals(dayOfWeek.replace("星期","周"))).collect(Collectors.toList());
|
|
|
+
|
|
|
+ for (Map map : maps) {
|
|
|
+ Map hashMap = new HashMap();
|
|
|
+ try {
|
|
|
+ Thread.sleep(100);
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ //通过护理时间 护理对象 护理人员验证数据是否已经存在
|
|
|
+ YDParam ydParam1 = YDParam.builder()
|
|
|
+ .formUuid("FORM-IY966L71PJ8FV10D61M1HBHU6FB320M2765OLM")
|
|
|
+ .searchFieldJson(JSON.toJSONString(UtilMap.map("dateField_lred6eoj, textField_lnyhv5tn, textField_lombve2g",Arrays.asList(UtilDateTime.parse( nextDay+ " 00:00:01","yyyy-MM-dd HH:mm:ss"),UtilDateTime.parse( currentDate.with(TemporalAdjusters.lastDayOfMonth())+ " 23:59:59","yyyy-MM-dd HH:mm:ss")),formMap.get("textField_lnyhv5tn"),map.get("textField_lomchzi3"))))
|
|
|
+ .build();
|
|
|
+ List<Map> dataLists = (List<Map>) ydClient.queryData(ydParam1, YDConf.FORM_QUERY.retrieve_search_form).getData();
|
|
|
+
|
|
|
+
|
|
|
+ if (dataLists.size()<1){
|
|
|
+
|
|
|
+ hashMap.put("associationFormField_lo3pmohz",JSON.parse(map.get("associationFormField_lo3pmohz_id").toString())); //护理人员名称
|
|
|
+ hashMap.put("textField_lo3pmoi0",map.get("textField_lo3pmoi0")); //护理人员所属机构
|
|
|
+ hashMap.put("textField_lombve2g",map.get("textField_lomchzi3")); //护理人员身份证
|
|
|
+ hashMap.put("textField_lo3pmoi3",map.get("textField_lo3pmoi3")); //护理人员手机号
|
|
|
+ hashMap.put("associationFormField_lo3pmohw",JSON.parse(formMap.get("associationFormField_lo3pmohw_id").toString())); //护理对象姓名
|
|
|
+ hashMap.put("textField_lnyhv5tn",formMap.get("textField_lnyhv5tn")); //护理对象身份证
|
|
|
+ hashMap.put("selectField_lnyhv5tp",formMap.get("selectField_lnyhv5tp")); //护理对象等级
|
|
|
+ hashMap.put("textField_lnyhv5tr",formMap.get("textField_lnyhv5tr")); //护理对象住址
|
|
|
+ hashMap.put("selectField_lo3pmohy",dayOfWeek.replace("星期","周")); //护理时间 (星期几)
|
|
|
+ hashMap.put("dateField_lred6eoj", UtilDateTime.parse(String.valueOf(nextDay)+" "+map.get("selectField_lr1uxpu3"),"yyyy-MM-dd HH:mm")); //护理开始时间。 用当前日期+护理计划的 时分 转成时间戳
|
|
|
+ hashMap.put("dateField_lred6eok", UtilDateTime.parse(String.valueOf(nextDay)+" "+map.get("selectField_lr1uxpu4"),"yyyy-MM-dd HH:mm")); //护理结束时间。 用当前日期+护理计划的 时分 转成时间戳
|
|
|
+ hashMap.put("selectField_lqcgsbw2","未执行"); //执行情况
|
|
|
+ hashMap.put("selectField_lo56u5fn","待上报"); //任务状态
|
|
|
+
|
|
|
+
|
|
|
+ hashMap.put("textField_lrx0r38x",String.valueOf(nextDay)); //护理日期-文本
|
|
|
+ hashMap.put("selectField_lr36z6hd","是"); //任务状态
|
|
|
+ hashMap.put("textField_lo55rupj",formMap.get("textField_lo55rupj")); //护理对象姓名-文本
|
|
|
+ hashMap.put("textField_lo3pmoi4",map.get("textField_lo3pmoi4")); //护理证书类型
|
|
|
+ hashMap.put("employeeField_lo3pmoi6",JSON.parse(map.get("employeeField_lo3pmoi6_id").toString())); //护理人员姓名-成员
|
|
|
+ hashMap.put("textField_lpgi8scj",map.get("textField_lo701pwy")); //计划明细id
|
|
|
+ hashMap.put("textField_lq9llmhl",formMap.get("textField_lop4v4qx")); //护理对象ID
|
|
|
+
|
|
|
+ try {
|
|
|
+ ydClient.operateData(YDParam.builder()
|
|
|
+ .formUuid("FORM-IY966L71PJ8FV10D61M1HBHU6FB320M2765OLM")
|
|
|
+ .formDataJson(JSON.toJSONString(hashMap))
|
|
|
+ .build(), YDConf.FORM_OPERATION.create);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.info("异常数据{}",hashMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("创建护理计划定时任务end",new Date());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ *每天同步护理状态
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void syncUpdatePlanStatus() {
|
|
|
+ log.info("每天同步护理状态开始{}",new Date());
|
|
|
+ syncPlanStatus();
|
|
|
+ log.info("每天同步护理状态结束{}",new Date());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @SneakyThrows
|
|
|
+ public void syncPlanStatus() {
|
|
|
+
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
+ //获取需要更新的护理任务 护理日期是当天 且状态为未上报
|
|
|
+ YDParam ydParam = YDParam.builder()
|
|
|
+ .formUuid("FORM-IY966L71PJ8FV10D61M1HBHU6FB320M2765OLM")
|
|
|
+ .searchFieldJson(JSON.toJSONString(UtilMap.map("selectField_lo56u5fn, dateField_lred6eoj","待上报",Arrays.asList(UtilDateTime.parse( currentDate+ " 00:00:59","yyyy-MM-dd HH:mm:ss"),UtilDateTime.parse( currentDate+ " 23:59:59","yyyy-MM-dd HH:mm:ss")))))
|
|
|
+ .build();
|
|
|
+ //pagesize设为1获取总数
|
|
|
+ ydParam.setPageSize(1);
|
|
|
+ long totalCount = ydClient.queryData(ydParam, YDConf.FORM_QUERY.retrieve_search_form).getTotalCount();
|
|
|
+ log.info("totalCount{}",totalCount);
|
|
|
+
|
|
|
+ //如果条数不为0 就一直递归
|
|
|
+ if (totalCount>0){
|
|
|
+ ydParam.setPageSize(50);
|
|
|
+ List<Map> dataList = new ArrayList<>();
|
|
|
+ dataList = (List<Map>) ydClient.queryData(ydParam, YDConf.FORM_QUERY.retrieve_search_form).getData();
|
|
|
+ log.info("dataList:{}",dataList.size());
|
|
|
+ //循环处理修改状态为已上报
|
|
|
+ dataList.forEach(item -> {
|
|
|
+ //修改状态为已上报
|
|
|
+ ydClient.operateData(YDParam.builder()
|
|
|
+ .formInstanceId(item.get("formInstanceId").toString())
|
|
|
+ .updateFormDataJson(JSON.toJSONString(UtilMap.map("selectField_lo56u5fn","已上报")))
|
|
|
+ .build(), YDConf.FORM_OPERATION.update);
|
|
|
+ });
|
|
|
+ Thread.sleep(5000);
|
|
|
+ syncUpdatePlanStatus();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增护理计划1条 生成本月护理数据
|
|
|
+ * @param formInstId
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void creatInfo(String formInstId) {
|
|
|
+ log.info("新增护理计划",new Date());
|
|
|
+ //根据实例ID 查询护理计划
|
|
|
+ YDParam ydParam = YDParam.builder()
|
|
|
+ .formInstId(formInstId)
|
|
|
+ .build();
|
|
|
+ Map formData = ydClient.queryData(ydParam, YDConf.FORM_QUERY.retrieve_id).getFormData();
|
|
|
+ log.info("formData{}",formData);
|
|
|
+ List<Map> mapList = (List<Map>) formData.get("tableField_lo3pmohx");
|
|
|
+
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
+ //获取当前日期是本月几号
|
|
|
+ int dayOfMonth = currentDate.getDayOfMonth();
|
|
|
+ //获取本月天数
|
|
|
+ int daysInMonth = currentDate.lengthOfMonth();
|
|
|
+
|
|
|
+ for (int i = 0; i <(daysInMonth-dayOfMonth)+1 ; i++) {
|
|
|
+ //获取当前日期是本月几号
|
|
|
+ LocalDate currentDay = LocalDate.now();
|
|
|
+ //获取是周几
|
|
|
+ String dayOfWeek = currentDay.plusDays(i).getDayOfWeek().getDisplayName(TextStyle.FULL, new Locale("zh", "CN"));
|
|
|
+ //获取循环每天的日期
|
|
|
+ LocalDate nextDay = currentDate.plusDays(i);
|
|
|
+ List<Map> maps = mapList.stream().filter(item -> item.get("selectField_lo3pmohy").equals(dayOfWeek.replace("星期","周"))).collect(Collectors.toList());
|
|
|
+ for (Map map : maps) {
|
|
|
+
|
|
|
+ Map hashMap = new HashMap();
|
|
|
+ hashMap.put("associationFormField_lo3pmohz",JSON.parse(map.get("associationFormField_lo3pmohz_id").toString())); //护理人员名称
|
|
|
+ hashMap.put("textField_lo3pmoi0",map.get("textField_lo3pmoi0")); //护理人员所属机构
|
|
|
+ hashMap.put("textField_lombve2g",map.get("textField_lomchzi3")); //护理人员身份证
|
|
|
+ hashMap.put("textField_lo3pmoi3",map.get("textField_lo3pmoi3")); //护理人员手机号
|
|
|
+ hashMap.put("associationFormField_lo3pmohw",JSON.parse(formData.get("associationFormField_lo3pmohw_id").toString())); //护理对象姓名
|
|
|
+ hashMap.put("textField_lnyhv5tn",formData.get("textField_lnyhv5tn")); //护理对象身份证
|
|
|
+ hashMap.put("selectField_lnyhv5tp",formData.get("selectField_lnyhv5tp")); //护理对象等级
|
|
|
+ hashMap.put("textField_lnyhv5tr",formData.get("textField_lnyhv5tr")); //护理对象住址
|
|
|
+ hashMap.put("selectField_lo3pmohy",dayOfWeek.replace("星期","周")); //护理时间 (星期几)
|
|
|
+ hashMap.put("dateField_lred6eoj", UtilDateTime.parse(String.valueOf(nextDay)+" "+map.get("selectField_lr1uxpu3"),"yyyy-MM-dd HH:mm")); //护理开始时间。 用当前日期+护理计划的 时分 转成时间戳
|
|
|
+ hashMap.put("dateField_lred6eok",UtilDateTime.parse(String.valueOf(nextDay)+" "+map.get("selectField_lr1uxpu4"),"yyyy-MM-dd HH:mm")); //护理结束时间。 用当前日期+护理计划的 时分 转成时间戳
|
|
|
+ hashMap.put("selectField_lqcgsbw2","未执行"); //执行情况
|
|
|
+ hashMap.put("selectField_lo56u5fn","待上报"); //任务状态
|
|
|
+
|
|
|
+ hashMap.put("textField_lrx0r38x",String.valueOf(nextDay)); //护理日期-文本
|
|
|
+ hashMap.put("selectField_lr36z6hd","是"); //任务状态
|
|
|
+ hashMap.put("textField_lo55rupj",formData.get("textField_lo55rupj")); //护理对象姓名-文本
|
|
|
+ hashMap.put("textField_lo3pmoi4",map.get("textField_lo3pmoi4")); //护理证书类型
|
|
|
+ hashMap.put("employeeField_lo3pmoi6",map.get("employeeField_lo3pmoi6_id")); //护理人员姓名-成员
|
|
|
+ hashMap.put("textField_lpgi8scj",map.get("textField_lo701pwy")); //计划明细id
|
|
|
+ hashMap.put("textField_lq9llmhl",formData.get("textField_lop4v4qx")); //护理对象ID
|
|
|
+
|
|
|
+ //通过护理时间 护理对象ID 证数据是否已经存在
|
|
|
+ YDParam ydParam1 = YDParam.builder()
|
|
|
+ .formUuid("FORM-IY966L71PJ8FV10D61M1HBHU6FB320M2765OLM")
|
|
|
+ .searchFieldJson(JSON.toJSONString(UtilMap.map("dateField_lred6eoj, textField_lnyhv5tn, textField_lombve2g",Arrays.asList(UtilDateTime.parse( nextDay+ " 00:00:01","yyyy-MM-dd HH:mm:ss"),UtilDateTime.parse( currentDate.with(TemporalAdjusters.lastDayOfMonth())+ " 23:59:59","yyyy-MM-dd HH:mm:ss")),formData.get("textField_lnyhv5tn"),map.get("textField_lomchzi3"))))
|
|
|
+ .build();
|
|
|
+ List<Map> dataList = (List<Map>) ydClient.queryData(ydParam1, YDConf.FORM_QUERY.retrieve_search_form).getData();
|
|
|
+
|
|
|
+ //判断是否存在
|
|
|
+ if (dataList.size()<1){
|
|
|
+ try {
|
|
|
+ ydClient.operateData(YDParam.builder()
|
|
|
+ .formUuid("FORM-IY966L71PJ8FV10D61M1HBHU6FB320M2765OLM")
|
|
|
+ .formDataJson(JSON.toJSONString(hashMap))
|
|
|
+ .build(), YDConf.FORM_OPERATION.create);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.info("定时任务创建计划失败:{}",e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增护理计划下月月数据
|
|
|
+ * @param formInstId
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void creatNextInfo(String formInstId) {
|
|
|
+ log.info("新增护理计划下月数据",new Date());
|
|
|
+ //根据实例ID 查询护理计划
|
|
|
+ YDParam ydParam = YDParam.builder()
|
|
|
+ .formInstId(formInstId)
|
|
|
+ .build();
|
|
|
+ Map formData = ydClient.queryData(ydParam, YDConf.FORM_QUERY.retrieve_id).getFormData();
|
|
|
+
|
|
|
+ List<Map> mapList = (List<Map>) formData.get("tableField_lo3pmohx");
|
|
|
+
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
+ //获取下月1号的日期
|
|
|
+ LocalDate firstDayOfNextMonth = currentDate.plusMonths(1).with(TemporalAdjusters.firstDayOfMonth());
|
|
|
+ //获取下月1号
|
|
|
+ int dayOfMonth = firstDayOfNextMonth.getDayOfMonth();
|
|
|
+ //获取下月月天数
|
|
|
+ int daysInMonth = firstDayOfNextMonth.lengthOfMonth();
|
|
|
+
|
|
|
+ for (int i = 0; i <=(daysInMonth-dayOfMonth)+1 ; i++) {
|
|
|
+ //获取是周几
|
|
|
+ String dayOfWeek = firstDayOfNextMonth.plusDays(i).getDayOfWeek().getDisplayName(TextStyle.FULL, new Locale("zh", "CN"));
|
|
|
+ //获取循环每天的日期
|
|
|
+ LocalDate nextDay = firstDayOfNextMonth.plusDays(i);
|
|
|
+
|
|
|
+ List<Map> maps = mapList.stream().filter(item -> item.get("selectField_lo3pmohy").equals(dayOfWeek.replace("星期","周"))).collect(Collectors.toList());
|
|
|
+ for (Map map : maps) {
|
|
|
+
|
|
|
+ Map hashMap = new HashMap();
|
|
|
+ hashMap.put("associationFormField_lo3pmohz",JSON.parse(map.get("associationFormField_lo3pmohz_id").toString())); //护理人员名称
|
|
|
+ hashMap.put("textField_lo3pmoi0",map.get("textField_lo3pmoi0")); //护理人员所属机构
|
|
|
+ hashMap.put("textField_lombve2g",map.get("textField_lomchzi3")); //护理人员身份证
|
|
|
+ hashMap.put("textField_lo3pmoi3",map.get("textField_lo3pmoi3")); //护理人员手机号
|
|
|
+ hashMap.put("associationFormField_lo3pmohw",JSON.parse(formData.get("associationFormField_lo3pmohw_id").toString())); //护理对象姓名
|
|
|
+ hashMap.put("textField_lnyhv5tn",formData.get("textField_lnyhv5tn")); //护理对象身份证
|
|
|
+ hashMap.put("selectField_lnyhv5tp",formData.get("selectField_lnyhv5tp")); //护理对象等级
|
|
|
+ hashMap.put("textField_lnyhv5tr",formData.get("textField_lnyhv5tr")); //护理对象住址
|
|
|
+ hashMap.put("selectField_lo3pmohy",dayOfWeek.replace("星期","周")); //护理时间 (星期几)
|
|
|
+ hashMap.put("dateField_lred6eoj", UtilDateTime.parse(String.valueOf(nextDay)+" "+map.get("selectField_lr1uxpu3"),"yyyy-MM-dd HH:mm")); //护理开始时间。 用当前日期+护理计划的 时分 转成时间戳
|
|
|
+ hashMap.put("dateField_lred6eok",UtilDateTime.parse(String.valueOf(nextDay)+" "+map.get("selectField_lr1uxpu4"),"yyyy-MM-dd HH:mm")); //护理结束时间。 用当前日期+护理计划的 时分 转成时间戳
|
|
|
+ hashMap.put("selectField_lqcgsbw2","未执行"); //执行情况
|
|
|
+ hashMap.put("selectField_lo56u5fn","待上报"); //任务状态
|
|
|
+
|
|
|
+ hashMap.put("textField_lrx0r38x",String.valueOf(nextDay)); //护理日期-文本
|
|
|
+ hashMap.put("selectField_lr36z6hd","是"); //任务状态
|
|
|
+ hashMap.put("textField_lo55rupj",formData.get("textField_lo55rupj")); //护理对象姓名-文本
|
|
|
+ hashMap.put("textField_lo3pmoi4",map.get("textField_lo3pmoi4")); //护理证书类型
|
|
|
+ hashMap.put("employeeField_lo3pmoi6",map.get("employeeField_lo3pmoi6_id")); //护理人员姓名-成员
|
|
|
+ hashMap.put("textField_lpgi8scj",map.get("textField_lo701pwy")); //计划明细id
|
|
|
+ hashMap.put("textField_lq9llmhl",formData.get("textField_lop4v4qx")); //护理对象ID
|
|
|
+
|
|
|
+ //通过护理时间 护理对象ID 证数据是否已经存在
|
|
|
+ YDParam ydParam1 = YDParam.builder()
|
|
|
+ .formUuid("FORM-IY966L71PJ8FV10D61M1HBHU6FB320M2765OLM")
|
|
|
+ .searchFieldJson(JSON.toJSONString(UtilMap.map("dateField_lred6eoj, textField_lnyhv5tn, textField_lombve2g",Arrays.asList(UtilDateTime.parse( nextDay+ " 00:00:01","yyyy-MM-dd HH:mm:ss"),UtilDateTime.parse( currentDate.with(TemporalAdjusters.lastDayOfMonth())+ " 23:59:59","yyyy-MM-dd HH:mm:ss")),formData.get("textField_lnyhv5tn"),map.get("textField_lomchzi3"))))
|
|
|
+ .build();
|
|
|
+ List<Map> dataList = (List<Map>) ydClient.queryData(ydParam1, YDConf.FORM_QUERY.retrieve_search_form).getData();
|
|
|
+
|
|
|
+ //判断是否存在
|
|
|
+ if (dataList.size()<1){
|
|
|
+ try {
|
|
|
+ ydClient.operateData(YDParam.builder()
|
|
|
+ .formUuid("FORM-IY966L71PJ8FV10D61M1HBHU6FB320M2765OLM")
|
|
|
+ .formDataJson(JSON.toJSONString(hashMap))
|
|
|
+ .build(), YDConf.FORM_OPERATION.create);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.info("定时任务创建计划失败:{}",e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 编辑护理计划
|
|
|
+ * @param formInstId
|
|
|
+ */
|
|
|
+ @SneakyThrows
|
|
|
+ @Override
|
|
|
+ @Async
|
|
|
+ public void updateInfo(String formInstId) {
|
|
|
+ Thread.sleep(2000);
|
|
|
+ //根据实例ID 查询护理计划
|
|
|
+ YDParam ydParam = YDParam.builder()
|
|
|
+ .formInstId(formInstId)
|
|
|
+ .build();
|
|
|
+ Map formData = ydClient.queryData(ydParam, YDConf.FORM_QUERY.retrieve_id).getFormData();
|
|
|
+
|
|
|
+ List<Map> mapList = (List<Map>) formData.get("tableField_lo3pmohx");
|
|
|
+
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
+
|
|
|
+ //获取下月1号的日期
|
|
|
+ LocalDate firstDayOfNextMonth = currentDate.plusMonths(1).with(TemporalAdjusters.firstDayOfMonth());
|
|
|
+ //删除当前时间节点以后得数据
|
|
|
+ //获取需要更新的护理任务 状态为待上报 护理对象身份证 护理日期是当天
|
|
|
+ YDParam ydParamDelete = YDParam.builder()
|
|
|
+ .formUuid("FORM-IY966L71PJ8FV10D61M1HBHU6FB320M2765OLM")
|
|
|
+ .searchFieldJson(JSON.toJSONString(UtilMap.map("selectField_lo56u5fn, textField_lnyhv5tn, dateField_lred6eoj","待上报",formData.get("textField_lnyhv5tn"),Arrays.asList(UtilDateTime.parse( currentDate+ " 00:00:01","yyyy-MM-dd HH:mm:ss"),UtilDateTime.parse( firstDayOfNextMonth.with(TemporalAdjusters.lastDayOfMonth())+ " 23:59:59","yyyy-MM-dd HH:mm:ss")))))
|
|
|
+ .build();
|
|
|
+
|
|
|
+ List<Map> queryAllFormData = ydService.queryAllFormData(ydParamDelete);
|
|
|
+ queryAllFormData.forEach(item -> {
|
|
|
+ //删除
|
|
|
+ ydClient.operateData(YDParam.builder()
|
|
|
+ .formInstanceId(item.get("formInstanceId").toString())
|
|
|
+ .build(), YDConf.FORM_OPERATION.delete);
|
|
|
+ });
|
|
|
+ //获取当前日期是本月几号
|
|
|
+ int dayOfMonth = currentDate.getDayOfMonth();
|
|
|
+ //获取本月天数
|
|
|
+ int daysInMonth = currentDate.lengthOfMonth();
|
|
|
+ //重新创建计划任务
|
|
|
+ for (int i = 0; i <(daysInMonth-dayOfMonth)+1 ; i++) {
|
|
|
+ //获取是周几
|
|
|
+ String dayOfWeek = currentDate.plusDays(i).getDayOfWeek().getDisplayName(TextStyle.FULL, new Locale("zh", "CN"));
|
|
|
+ //获取循环每天的日期
|
|
|
+ LocalDate nextDay = currentDate.plusDays(i);
|
|
|
+ List<Map> maps = mapList.stream().filter(item -> item.get("selectField_lo3pmohy").equals(dayOfWeek.replace("星期","周"))).collect(Collectors.toList());
|
|
|
+ for (Map map : maps) {
|
|
|
+ Map hashMap = new HashMap();
|
|
|
+ hashMap.put("associationFormField_lo3pmohz",JSON.parse(map.get("associationFormField_lo3pmohz_id").toString())); //护理人员名称
|
|
|
+ hashMap.put("textField_lo3pmoi0",map.get("textField_lo3pmoi0")); //护理人员所属机构
|
|
|
+ hashMap.put("textField_lombve2g",map.get("textField_lomchzi3")); //护理人员身份证
|
|
|
+ hashMap.put("textField_lo3pmoi3",map.get("textField_lo3pmoi3")); //护理人员手机号
|
|
|
+ hashMap.put("associationFormField_lo3pmohw",JSON.parse(formData.get("associationFormField_lo3pmohw_id").toString())); //护理对象姓名
|
|
|
+ hashMap.put("textField_lnyhv5tn",formData.get("textField_lnyhv5tn")); //护理对象身份证
|
|
|
+ hashMap.put("selectField_lnyhv5tp",formData.get("selectField_lnyhv5tp")); //护理对象等级
|
|
|
+ hashMap.put("textField_lnyhv5tr",formData.get("textField_lnyhv5tr")); //护理对象住址
|
|
|
+ hashMap.put("selectField_lo3pmohy",dayOfWeek.replace("星期","周")); //护理时间 (星期几)
|
|
|
+ hashMap.put("dateField_lred6eoj", UtilDateTime.parse(String.valueOf(nextDay)+" "+map.get("selectField_lr1uxpu3"),"yyyy-MM-dd HH:mm")); //护理开始时间。 用当前日期+护理计划的 时分 转成时间戳
|
|
|
+ hashMap.put("dateField_lred6eok",UtilDateTime.parse(String.valueOf(nextDay)+" "+map.get("selectField_lr1uxpu4"),"yyyy-MM-dd HH:mm")); //护理结束时间。 用当前日期+护理计划的 时分 转成时间戳
|
|
|
+ hashMap.put("selectField_lqcgsbw2","未执行"); //执行情况
|
|
|
+ hashMap.put("selectField_lo56u5fn","待上报"); //任务状态
|
|
|
+
|
|
|
+
|
|
|
+ hashMap.put("textField_lrx0r38x",String.valueOf(nextDay)); //护理日期-文本
|
|
|
+ hashMap.put("selectField_lr36z6hd","是"); //任务状态
|
|
|
+ hashMap.put("textField_lo55rupj",formData.get("textField_lo55rupj")); //护理对象姓名-文本
|
|
|
+ hashMap.put("textField_lo3pmoi4",map.get("textField_lo3pmoi4")); //护理证书类型
|
|
|
+ hashMap.put("employeeField_lo3pmoi6",JSON.parse(map.get("employeeField_lo3pmoi6_id").toString())); //护理人员姓名-成员
|
|
|
+ hashMap.put("textField_lpgi8scj",map.get("textField_lo701pwy")); //计划明细id
|
|
|
+ hashMap.put("textField_lq9llmhl",formData.get("textField_lop4v4qx")); //护理对象ID
|
|
|
+
|
|
|
+ //通过护理时间 护理对象CID 护理人员CID验证数据是否已经存在
|
|
|
+ YDParam ydParam1 = YDParam.builder()
|
|
|
+ .formUuid("FORM-IY966L71PJ8FV10D61M1HBHU6FB320M2765OLM")
|
|
|
+ .searchFieldJson(JSON.toJSONString(UtilMap.map("dateField_lred6eoj, textField_lnyhv5tn, textField_lombve2g",Arrays.asList(UtilDateTime.parse( nextDay+ " 00:00:01","yyyy-MM-dd HH:mm:ss"),UtilDateTime.parse( currentDate.with(TemporalAdjusters.lastDayOfMonth())+ " 23:59:59","yyyy-MM-dd HH:mm:ss")),formData.get("textField_lnyhv5tn"),map.get("textField_lomchzi3"))))
|
|
|
+ .build();
|
|
|
+ List<Map> dataList = (List<Map>) ydClient.queryData(ydParam1, YDConf.FORM_QUERY.retrieve_search_form).getData();
|
|
|
+
|
|
|
+ if (dataList.size()<1){
|
|
|
+ ydClient.operateData(YDParam.builder()
|
|
|
+ .formUuid("FORM-IY966L71PJ8FV10D61M1HBHU6FB320M2765OLM")
|
|
|
+ .formDataJson(JSON.toJSONString(hashMap))
|
|
|
+ .build(), YDConf.FORM_OPERATION.create);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除护理任务
|
|
|
+ * @param cId 护理对象身份证
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void deletePlan(String cId) {
|
|
|
+
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
+
|
|
|
+ //获取下月1号的日期
|
|
|
+ LocalDate firstDayOfNextMonth = currentDate.plusMonths(1).with(TemporalAdjusters.firstDayOfMonth());
|
|
|
+
|
|
|
+ //获取需要删除护理任务 执行状态为未执行 护理对象身份证 护理日期是当天以后
|
|
|
+ YDParam ydParamDelete = YDParam.builder()
|
|
|
+ .formUuid("FORM-IY966L71PJ8FV10D61M1HBHU6FB320M2765OLM")
|
|
|
+ .searchFieldJson(JSON.toJSONString(UtilMap.map("selectField_lqcgsbw2, textField_lnyhv5tn, dateField_lred6eoj","未执行",cId,Arrays.asList(UtilDateTime.parse( currentDate+ " 00:00:01","yyyy-MM-dd HH:mm:ss"),UtilDateTime.parse( firstDayOfNextMonth.with(TemporalAdjusters.lastDayOfMonth())+ " 23:59:59","yyyy-MM-dd HH:mm:ss")))))
|
|
|
+ .build();
|
|
|
+ List<Map> mapList = ydService.queryAllFormData(ydParamDelete);
|
|
|
+ //删除当前时间节点以后得数据
|
|
|
+ mapList.forEach(item -> {
|
|
|
+ //删除
|
|
|
+ ydClient.operateData(YDParam.builder()
|
|
|
+ .formInstanceId(item.get("formInstanceId").toString())
|
|
|
+ .build(), YDConf.FORM_OPERATION.delete);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ *定时任务每月25号创建下月的数据
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @SneakyThrows
|
|
|
+ public void syncCreatePlan() {
|
|
|
+
|
|
|
+ YDParam ydParam = new YDParam();
|
|
|
+ log.info("创建护理计划定时任务Start",new Date());
|
|
|
+
|
|
|
+ ydParam = YDParam.builder()
|
|
|
+ .formUuid("FORM-RK966E7105DFD27FA7EQHAOH9IFS2RN6MP3OL2") //获取护理计划
|
|
|
+ .searchFieldJson(JSON.toJSONString(UtilMap.map("selectField_lo2b6bvf","正常")))//护理对象暂停和正常、月度计划创建只查询正常的护理计划
|
|
|
+ .build();
|
|
|
+ //pagesize设为1获取总数
|
|
|
+ ydParam.setPageSize(1);
|
|
|
+ long totalCount = ydClient.queryData(ydParam, YDConf.FORM_QUERY.retrieve_search_form).getTotalCount();
|
|
|
+ float pageSize = 50;
|
|
|
+ ydParam.setCurrentPage(1);
|
|
|
+ ydParam.setPageSize((int) pageSize);
|
|
|
+ List<Map> dataList = new ArrayList<>();
|
|
|
+ for (int page = 1; page <= Math.ceil(totalCount / pageSize); page++) {
|
|
|
+ ydParam.setCurrentPage(page);
|
|
|
+ //创建护理计划 1次获取50条
|
|
|
+ dataList = (List<Map>) ydClient.queryData(ydParam, YDConf.FORM_QUERY.retrieve_search_form).getData();
|
|
|
+ log.info("dataList:{}-----page:"+page+"---",dataList.size());
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
+ //获取下月1号的日期
|
|
|
+ LocalDate firstDayOfNextMonth = currentDate.plusMonths(1).with(TemporalAdjusters.firstDayOfMonth());
|
|
|
+ //获取当前日期是本月几号
|
|
|
+ int dayOfMonth = firstDayOfNextMonth .getDayOfMonth();
|
|
|
+ //获取本月天数
|
|
|
+ int daysInMonth = firstDayOfNextMonth.lengthOfMonth();
|
|
|
+ dataList.forEach(dataItem -> {
|
|
|
+ Map formMap = (Map) dataItem.get("formData");
|
|
|
+ List<Map> mapList = (List<Map>) formMap.get("tableField_lo3pmohx");
|
|
|
+ for (int i =0 ; i <=(daysInMonth-dayOfMonth) ; i++) {
|
|
|
+ //获取是周几
|
|
|
+ String dayOfWeek = firstDayOfNextMonth.plusDays(i).getDayOfWeek().getDisplayName(TextStyle.FULL, new Locale("zh", "CN"));
|
|
|
+ //获取循环每天的日期
|
|
|
+ LocalDate nextDay = firstDayOfNextMonth.plusDays(i);
|
|
|
+ List<Map> maps = mapList.stream().filter(items -> items.get("selectField_lo3pmohy").equals(dayOfWeek.replace("星期","周"))).collect(Collectors.toList());
|
|
|
+ for (Map map : maps) {
|
|
|
+ Map hashMap = new HashMap();
|
|
|
+ try {
|
|
|
+ Thread.sleep(100);
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ //通过护理时间 护理对象 护理人员验证数据是否已经存在
|
|
|
+ YDParam ydParam1 = YDParam.builder()
|
|
|
+ .formUuid("FORM-IY966L71PJ8FV10D61M1HBHU6FB320M2765OLM")
|
|
|
+ .searchFieldJson(JSON.toJSONString(UtilMap.map("dateField_lred6eoj, textField_lnyhv5tn, textField_lombve2g",Arrays.asList(UtilDateTime.parse( nextDay+ " 00:00:01","yyyy-MM-dd HH:mm:ss"),UtilDateTime.parse( nextDay.with(TemporalAdjusters.lastDayOfMonth())+ " 23:59:59","yyyy-MM-dd HH:mm:ss")),formMap.get("textField_lnyhv5tn"),map.get("textField_lomchzi3"))))
|
|
|
+ .build();
|
|
|
+ List<Map> dataLists = (List<Map>) ydClient.queryData(ydParam1, YDConf.FORM_QUERY.retrieve_search_form).getData();
|
|
|
+ if (dataLists.size()<1){
|
|
|
+ hashMap.put("associationFormField_lo3pmohz",JSON.parse(map.get("associationFormField_lo3pmohz_id").toString())); //护理人员名称
|
|
|
+ hashMap.put("textField_lo3pmoi0",map.get("textField_lo3pmoi0")); //护理人员所属机构
|
|
|
+ hashMap.put("textField_lombve2g",map.get("textField_lomchzi3")); //护理人员身份证
|
|
|
+ hashMap.put("textField_lo3pmoi3",map.get("textField_lo3pmoi3")); //护理人员手机号
|
|
|
+ hashMap.put("associationFormField_lo3pmohw",JSON.parse(formMap.get("associationFormField_lo3pmohw_id").toString())); //护理对象姓名
|
|
|
+ hashMap.put("textField_lnyhv5tn",formMap.get("textField_lnyhv5tn")); //护理对象身份证
|
|
|
+ hashMap.put("selectField_lnyhv5tp",formMap.get("selectField_lnyhv5tp")); //护理对象等级
|
|
|
+ hashMap.put("textField_lnyhv5tr",formMap.get("textField_lnyhv5tr")); //护理对象住址
|
|
|
+ hashMap.put("selectField_lo3pmohy",dayOfWeek.replace("星期","周")); //护理时间 (星期几)
|
|
|
+ hashMap.put("dateField_lred6eoj", UtilDateTime.parse(String.valueOf(nextDay)+" "+map.get("selectField_lr1uxpu3"),"yyyy-MM-dd HH:mm")); //护理开始时间。 用当前日期+护理计划的 时分 转成时间戳
|
|
|
+ hashMap.put("dateField_lred6eok", UtilDateTime.parse(String.valueOf(nextDay)+" "+map.get("selectField_lr1uxpu4"),"yyyy-MM-dd HH:mm")); //护理结束时间。 用当前日期+护理计划的 时分 转成时间戳
|
|
|
+ hashMap.put("selectField_lqcgsbw2","未执行"); //执行情况
|
|
|
+ hashMap.put("selectField_lo56u5fn","待上报"); //任务状态
|
|
|
+ hashMap.put("textField_lrx0r38x",String.valueOf(nextDay)); //护理日期-文本
|
|
|
+ hashMap.put("selectField_lr36z6hd","是"); //任务状态
|
|
|
+ hashMap.put("textField_lo55rupj",formMap.get("textField_lo55rupj")); //护理对象姓名-文本
|
|
|
+ hashMap.put("textField_lo3pmoi4",map.get("textField_lo3pmoi4")); //护理证书类型
|
|
|
+ hashMap.put("employeeField_lo3pmoi6",JSON.parse(map.get("employeeField_lo3pmoi6_id").toString())); //护理人员姓名-成员
|
|
|
+ hashMap.put("textField_lpgi8scj",map.get("textField_lo701pwy")); //计划明细id
|
|
|
+ hashMap.put("textField_lq9llmhl",formMap.get("textField_lop4v4qx")); //护理对象ID
|
|
|
+ try {
|
|
|
+ ydClient.operateData(YDParam.builder()
|
|
|
+ .formUuid("FORM-IY966L71PJ8FV10D61M1HBHU6FB320M2765OLM")
|
|
|
+ .formDataJson(JSON.toJSONString(hashMap))
|
|
|
+ .build(), YDConf.FORM_OPERATION.create);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.info("异常数据{}",hashMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ log.info("创建护理计划定时任务end",new Date());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|