|
@@ -2,6 +2,9 @@ package com.malk.yibaoju.controller;
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.malk.server.aliwork.YDConf;
|
|
|
import com.malk.server.aliwork.YDParam;
|
|
|
import com.malk.server.common.McException;
|
|
@@ -11,6 +14,11 @@ import com.malk.service.aliwork.YDService;
|
|
|
import com.malk.service.dingtalk.DDService;
|
|
|
import com.malk.utils.UtilMap;
|
|
|
import com.malk.utils.UtilServlet;
|
|
|
+import com.malk.yibaoju.entity.ObjectInfo;
|
|
|
+import com.malk.yibaoju.entity.Plan;
|
|
|
+import com.malk.yibaoju.mapper.ObjectInfoMapper;
|
|
|
+import com.malk.yibaoju.mapper.PlanMapper;
|
|
|
+import com.malk.yibaoju.service.PlanService;
|
|
|
import com.malk.yibaoju.service.YBJService;
|
|
|
import lombok.SneakyThrows;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -19,9 +27,6 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
-import java.sql.Connection;
|
|
|
-import java.sql.DriverManager;
|
|
|
-import java.sql.PreparedStatement;
|
|
|
import java.time.LocalDate;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
@@ -52,6 +57,13 @@ public class YBJController {
|
|
|
@Autowired
|
|
|
private YDClient ydClient;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ PlanService planService;
|
|
|
+ @Autowired
|
|
|
+ PlanMapper planMapper;
|
|
|
+ @Autowired
|
|
|
+ ObjectInfoMapper planCopyMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 图片免登
|
|
|
*/
|
|
@@ -80,7 +92,7 @@ public class YBJController {
|
|
|
}
|
|
|
//编辑只做删除数据操作。新增在页面保存完之后操作。
|
|
|
//获取当前日期是本月几号
|
|
|
- Thread.sleep(2000);
|
|
|
+// Thread.sleep(2000);
|
|
|
ybjService.creatInfo(data.get("formInstId").toString());
|
|
|
if (dayOfMonth>24){
|
|
|
Thread.sleep(2000);
|
|
@@ -310,28 +322,128 @@ public class YBJController {
|
|
|
return McR.success();
|
|
|
}
|
|
|
|
|
|
- @PostMapping("test1")
|
|
|
- McR test1(@RequestBody Map data) {
|
|
|
- try {
|
|
|
- String insertSql = "INSERT INTO `error_insts`(`form_inst_id`) VALUES ('123123');";
|
|
|
- Class.forName(driver);
|
|
|
- Connection connection = DriverManager.getConnection(url, username, password);
|
|
|
- // 创建Statement对象,用于执行SQL语句
|
|
|
- PreparedStatement preparedStatement = connection.prepareStatement(insertSql);
|
|
|
-// preparedStatement.setString("123123");
|
|
|
- // 执行SQL查询
|
|
|
- int resultSet = preparedStatement.executeUpdate();
|
|
|
-// if (resultSet > 0) {
|
|
|
-// log.info("插入一条数据实例id为:{}",dataList.get(j).get("formInstanceId"));
|
|
|
-// }
|
|
|
- // 关闭资源
|
|
|
- preparedStatement.close();
|
|
|
- connection.close();
|
|
|
- } catch (Exception ex) {
|
|
|
-// log.info("插入失败,数据实例id为:{}",dataList.get(j).get("formInstanceId"));
|
|
|
- ex.printStackTrace();
|
|
|
+ /**
|
|
|
+ * 根据护理安排创建护理计划
|
|
|
+ * 通过参数 1个护理安排创建多条护理计划
|
|
|
+ */
|
|
|
+ @SneakyThrows
|
|
|
+ @PostMapping("createDatabasePlan")
|
|
|
+ McR createDatabasePlan(@RequestBody Map data){
|
|
|
+
|
|
|
+ log.info("createPlan 护理计划:{}",data);
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
+ //获取当前日期是本月几号
|
|
|
+ int dayOfMonth = currentDate.getDayOfMonth();
|
|
|
+ if ("2".equals(data.get("status"))){
|
|
|
+ ybjService.deleteDatabaseInfo(data.get("formInstId").toString());
|
|
|
+ }
|
|
|
+ //编辑只做删除数据操作。新增在页面保存完之后操作。
|
|
|
+ //获取当前日期是本月几号
|
|
|
+// Thread.sleep(2000);
|
|
|
+ //生成当月数据库护理计划
|
|
|
+ ybjService.thisMonthDataBase(data.get("formInstId").toString());
|
|
|
+ if (dayOfMonth>24){
|
|
|
+ Thread.sleep(2000);
|
|
|
+ ybjService.insertDatabaseNextMonth(data.get("formInstId").toString());
|
|
|
}
|
|
|
return McR.success();
|
|
|
}
|
|
|
|
|
|
+ @RequestMapping("testApi")
|
|
|
+ McR testApi(HttpServletRequest request) {
|
|
|
+ return McR.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 护理计划看板、护理地图查询
|
|
|
+ * @param data 护理计划看板筛选条件
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("boardQuery")
|
|
|
+ McR boardQuery(@RequestBody Map<String,Object> data) {
|
|
|
+ QueryWrapper<Plan> planQuery = new QueryWrapper<>();
|
|
|
+ IPage<Plan> planPage = new Page<>();
|
|
|
+ data.forEach((k,v)->{
|
|
|
+ if (k.equals("currentPage")){
|
|
|
+ planPage.setCurrent(Long.parseLong(v.toString()));
|
|
|
+ } else if (k.equals("pageSize")) {
|
|
|
+ planPage.setSize(Long.parseLong(v.toString()));
|
|
|
+ } else if (k.equals("date_between")){
|
|
|
+ Map<String,Object> formInstId = (Map<String,Object>) data.get("date_between");
|
|
|
+ planQuery.ge("care_start_time",formInstId.get("start"));
|
|
|
+ planQuery.le("care_start_time",formInstId.get("end"));
|
|
|
+ }else{
|
|
|
+ planQuery.eq(k,v);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ planQuery.eq("is_delete",0);
|
|
|
+ IPage<Plan> selectPage = planMapper.selectPage(planPage, planQuery);
|
|
|
+ return McR.success(selectPage);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 看板和地图获取去重的过滤条件
|
|
|
+ * @param column
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("selectDistinct/{column}")
|
|
|
+ McR selectDistinct(@PathVariable("column") String column) {
|
|
|
+ QueryWrapper<Plan> planQuery = new QueryWrapper<>();
|
|
|
+ planQuery.select("distinct " + column).lambda();
|
|
|
+ List<Plan> plans = planMapper.selectList(planQuery);
|
|
|
+ List<Map<String, Object>> objects = new ArrayList<>();
|
|
|
+ plans.forEach(e->{
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+ if ("caregiver_name".equals(column)){
|
|
|
+ result.put("label",e.getCaregiverName());
|
|
|
+ result.put("value",e.getCaregiverName());
|
|
|
+ } else if ("caregiver_department".equals(column)) {
|
|
|
+ result.put("label",e.getCaregiverDepartment());
|
|
|
+ result.put("value",e.getCaregiverDepartment());
|
|
|
+ }
|
|
|
+ objects.add(result);
|
|
|
+ });
|
|
|
+ return McR.success(objects);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 看板和地图获取去重的过滤条件
|
|
|
+ * @param column
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("selectDistinctCareObject/{column}")
|
|
|
+ McR selectDistinctCareObject(@PathVariable("column") String column) {
|
|
|
+ QueryWrapper<ObjectInfo> planQuery = new QueryWrapper<>();
|
|
|
+ planQuery.select("distinct " + column).lambda();
|
|
|
+ List<ObjectInfo> plans = planCopyMapper.selectList(planQuery);
|
|
|
+ List<Map<String, Object>> objects = new ArrayList<>();
|
|
|
+ plans.forEach(e->{
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+ result.put("label",e.getName());
|
|
|
+ result.put("value",e.getName());
|
|
|
+ objects.add(result);
|
|
|
+ });
|
|
|
+ log.info("McR.success(objects):{}",McR.success(objects));
|
|
|
+ return McR.success(objects);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 打卡更新数据库
|
|
|
+ * @param data
|
|
|
+ */
|
|
|
+ @PostMapping("updateFromClock")
|
|
|
+ void updateFromClock(@RequestBody Map<String,Object> data) {
|
|
|
+ ybjService.updateFromClock(data);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 前端调用获取表单id
|
|
|
+ * @param strDate
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("getFormId/{strDate}")
|
|
|
+ McR getFormId(@PathVariable("strDate") String strDate) {
|
|
|
+ String formId = ybjService.getFormId(strDate);
|
|
|
+ return McR.success(formId);
|
|
|
+ }
|
|
|
}
|