ソースを参照

优化父子节点

xiaochan 2 年 前
コミット
8af0f65d81

+ 1 - 1
src/main/java/thyyxxk/webserver/controller/zhuyuanyizheng/YizhuLuRuController.java

@@ -218,7 +218,7 @@ public class YizhuLuRuController {
     }
 
     @PostMapping("/associateOrders")
-    public ResultVo<String> associateOrders(@RequestBody XinZhenYiZhu param) {
+    public ResultVo<List<XinZhenYzActOrder>> associateOrders(@RequestBody XinZhenYiZhu param) {
         return server.associateOrders(param);
     }
 

+ 5 - 4
src/main/java/thyyxxk/webserver/dao/his/zhuyuanyisheng/YiZhuLuRuDao.java

@@ -1382,7 +1382,7 @@ public interface YiZhuLuRuDao {
 
     @Update("update yz_act_order " +
             "    set " +
-            "    parent_no =    ${order.actOrderNo}," +
+            "    parent_no   = ${order.actOrderNo}," +
             "    order_time  = #{order.orderTime,jdbcType=TIMESTAMP}, " +
             "    start_time  = #{order.startTime,jdbcType=TIMESTAMP}, " +
             "    end_time    = #{order.endTime,jdbcType=TIMESTAMP}, " +
@@ -1416,9 +1416,10 @@ public interface YiZhuLuRuDao {
             "    dept_code        = (select name from zd_unit_code where code = a.ward_code), " +
             "                       isnull(a.ori_detail_sn, 0) as ori_detail_sn " +
             "FROM zy_detail_charge a " +
-            "where order_no = #{yz.actOrderNo} " +
-            "  and inpatient_no = #{yz.inpatientNo} " +
-            "  and admiss_times = #{yz.admissTimes} order by charge_date desc ")
+            "where abs(order_no) = #{yz.actOrderNo} " +
+            "  and inpatient_no  = #{yz.inpatientNo} " +
+            "  and admiss_times  = #{yz.admissTimes} " +
+            "order by charge_date desc ")
     List<ZyDetailCharge> selectOrderFee(@Param("yz") XinZhenYzActOrder yz);
 
     @Update("update yz_act_order " +

+ 17 - 13
src/main/java/thyyxxk/webserver/service/zhuyuanyisheng/YiZhuLuRuServer.java

@@ -3,6 +3,7 @@ package thyyxxk.webserver.service.zhuyuanyisheng;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.extra.spring.SpringUtil;
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -449,18 +450,16 @@ public class YiZhuLuRuServer {
         qw.eq("a.admiss_times", param.getAdmissTimes());
         qw.eq("a.status_flag", "1");
 
-        if (data.getParentNo() != null) {
-            qw.and(
-                    wrapper -> wrapper.eq("a.act_order_no", data.getParentNo())
-                            .or()
-                            .eq("a.parent_no", data.getParentNo())
-            );
-        } else {
+        // 不是子节点,就需要查询是否存在子节点
+        if (data.getParentNo() == null) {
             qw.and(wrapper -> wrapper.eq("a.act_order_no", param.getActOrderNo())
                     .or()
                     .eq("a.parent_no", param.getActOrderNo())
             );
+        } else {
+            qw.eq("a.act_order_no", data.getParentNo());
         }
+
         qw.orderByAsc("a.act_order_no");
 
         Map<String, Object> successMap = new HashMap<>();
@@ -1254,16 +1253,24 @@ public class YiZhuLuRuServer {
      * @param param 主医嘱 和 多个子医嘱
      * @return 返回数据
      */
-    public ResultVo<String> associateOrders(XinZhenYiZhu param) {
+    public ResultVo<List<XinZhenYzActOrder>> associateOrders(XinZhenYiZhu param) {
         log.info("数据:{}", JSON.toJSONString(param));
         XinZhenYzActOrder order = dao.getActOrderNoOne(param.getActOrderNo());
         if (order.getParentNo() != null) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "操作失败,父医嘱不能为子医嘱。");
         }
+        Set<BigDecimal> orderList = new HashSet<>();
+        orderList.add(order.getActOrderNo());
+
         param.getAssociatedGroup().forEach(item -> {
             dao.associateOrders(item, order);
+            orderList.add(item);
         });
-        return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "关联成功。");
+
+        QueryWrapper<?> qw = new QueryWrapper<>();
+        qw.in("a.act_order_no", orderList);
+
+        return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "关联成功。", dao.selectOrderNo(qw));
     }
 
     /**
@@ -1405,13 +1412,10 @@ public class YiZhuLuRuServer {
 
     public ResultVo<List<ZyDetailCharge>> queryFeeByOrderNo(BigDecimal actOrderNo) {
         XinZhenYzActOrder yz = dao.getActOrderNoOne(actOrderNo.stripTrailingZeros().toPlainString());
-
         if (yz == null) {
-            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR,"该医嘱未产生费用。");
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "该医嘱未产生费用。");
         }
-
         List<ZyDetailCharge> feeList = dao.selectOrderFee(yz);
-
         return ResultVoUtil.success(feeList);
     }