Browse Source

执行输液之前,先进行CA签名

lighter 3 weeks ago
parent
commit
1839d74bbf

+ 15 - 0
src/main/java/thyyxxk/webserver/controller/PublicController.java

@@ -12,6 +12,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 import thyyxxk.webserver.config.auth.PassToken;
+import thyyxxk.webserver.config.exception.BizException;
+import thyyxxk.webserver.config.exception.ExceptionEnum;
 import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.datamodify.GetDropdownBox;
 import thyyxxk.webserver.entity.login.UserInfo;
@@ -21,6 +23,7 @@ import thyyxxk.webserver.entity.publicapi.ZkList;
 import thyyxxk.webserver.entity.zhuyuanyisheng.PatientAllergenInfo;
 import thyyxxk.webserver.service.PublicServer;
 import thyyxxk.webserver.utils.ListUtil;
+import thyyxxk.webserver.utils.PasswordGenerator;
 import thyyxxk.webserver.utils.ResultVoUtil;
 import thyyxxk.webserver.utils.SnowFlakeId;
 
@@ -271,4 +274,16 @@ public class PublicController {
         return ResultVoUtil.success(NetUtil.localIpv4s());
     }
 
+    @PassToken
+    @GetMapping("/generateRandomPassword")
+    public ResultVo<List<String>> generateRandomPassword(@RequestParam("length") int length,
+                                                         @RequestParam("size") int size) {
+        if (length < 12) {
+            throw new BizException(ExceptionEnum.LOGICAL_ERROR, "密码长度不能小于12位");
+        }
+        if (size < 1) {
+            throw new BizException(ExceptionEnum.LOGICAL_ERROR, "密码数量不能小于1");
+        }
+        return ResultVoUtil.success(PasswordGenerator.generate(length, size));
+    }
 }

+ 7 - 4
src/main/java/thyyxxk/webserver/dao/his/inpatient/nursemodule/PrintInfusionCardDao.java

@@ -200,21 +200,24 @@ public interface PrintInfusionCardDao {
             "order by a.act_order_no")
     List<YzActOccInfusionNew> selectSideDrugsByPatNo(InfusionInsert insert);
 
-    @Select("select rtrim(charge_code) as chargeCode,b.drug_occ as drug_quan,execute_staff,execute_time " +
+    @Select("select rtrim(charge_code) as chargeCode,b.drug_occ as drug_quan," +
+            "execute_staff,execute_time,occ_name,inpatient_name " +
             "from yz_act_occ a left join yz_act_order b on a.act_order_no=b.act_order_no " +
             "where a.inpatient_no=#{patNo} and a.act_order_no=#{actOrderNo} " +
             "and occ_time=#{occTime} " +
             "union all " +
-            "select rtrim(charge_code) as chargeCode,b.drug_occ as drug_quan,execute_staff,execute_time " +
+            "select rtrim(charge_code) as chargeCode,b.drug_occ as drug_quan," +
+            "execute_staff,execute_time,occ_name,inpatient_name " +
             "from yz_act_occ a left join yz_act_order b on a.act_order_no=b.act_order_no " +
             "where a.inpatient_no=#{patNo} and a.parent_no=#{actOrderNo} " +
             "and occ_time=#{occTime} and a.act_order_no>0")
     List<YzActOcc> getInfusionDrugsByScan(String patNo, String actOrderNo, Date occTime);
 
-    @Update("update yz_act_occ set execute_staff=#{staff},execute_time=getdate() " +
+    @Update("update yz_act_occ set execute_staff=#{staff},execute_time=getdate()," +
+            "execute_ca_sign_id=#{caId} " +
             "where inpatient_no=#{patNo} and occ_time=#{occTime} and " +
             "(act_order_no=#{actOrderNo} or parent_no=#{actOrderNo})")
-    int updateExecutor(String patNo, String actOrderNo, Date occTime, String staff);
+    int updateExecutor(String patNo, String actOrderNo, Date occTime, String staff, String caId);
 
     @Update("update yz_act_occ set prepare_staff=#{staff},prepare_time=getdate() " +
             "where inpatient_no=#{patNo} and occ_time=#{occTime} and " +

+ 32 - 3
src/main/java/thyyxxk/webserver/service/inpatient/nursemodule/PrintInfusionCardService.java

@@ -6,12 +6,15 @@ import org.springframework.stereotype.Service;
 import thyyxxk.webserver.config.exception.ExceptionEnum;
 import thyyxxk.webserver.dao.his.inpatient.nursemodule.PrintInfusionCardDao;
 import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.entity.ca.CaReturn;
+import thyyxxk.webserver.entity.ca.CaSignClass;
 import thyyxxk.webserver.entity.executeItem.YzActOcc;
 import thyyxxk.webserver.entity.inpatient.nursemodule.request.CardType;
 import thyyxxk.webserver.entity.inpatient.nursemodule.request.InfusionInsert;
 import thyyxxk.webserver.entity.inpatient.nursemodule.request.UpdatePrintStatus;
 import thyyxxk.webserver.entity.inpatient.nursemodule.response.*;
 import thyyxxk.webserver.entity.inpatient.nursemodule.request.QueryInfusionCard;
+import thyyxxk.webserver.service.ca.CaServer;
 import thyyxxk.webserver.utils.*;
 
 import java.math.BigDecimal;
@@ -21,10 +24,12 @@ import java.util.*;
 @Service
 public class PrintInfusionCardService {
     private final PrintInfusionCardDao dao;
+    private final CaServer caService;
 
     @Autowired
-    public PrintInfusionCardService(PrintInfusionCardDao dao) {
+    public PrintInfusionCardService(PrintInfusionCardDao dao, CaServer caService) {
         this.dao = dao;
+        this.caService = caService;
     }
 
     public ResultVo<List<PatientBed>> getPatientBeds(String wardCode) {
@@ -248,8 +253,17 @@ public class PrintInfusionCardService {
         }
 
         List<YzActOcc> drugs = dao.getInfusionDrugsByScan(patNo, actOrderNo, occTime);
+        if (drugs.isEmpty()) {
+            return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST, "没有找到医嘱用药内容!");
+        }
         int checkedCount = 0;
-        for (YzActOcc occ : drugs) {
+        StringBuilder caMsbBuilder = new StringBuilder();
+        caMsbBuilder
+                .append("为患者【")
+                .append(drugs.get(0).getInpatientName().trim())
+                .append("】执行输液:");
+        for (int i = 0; i < drugs.size(); i++) {
+            YzActOcc occ = drugs.get(i);
             if (StringUtil.notBlank(occ.getExecuteStaff()) && null != occ.getExecuteTime()) {
                 String executeTime = DateUtil.formatDatetime(occ.getExecuteTime());
                 return ResultVoUtil.fail(ExceptionEnum.SLIGHTLY_ERROR,
@@ -262,12 +276,27 @@ public class PrintInfusionCardService {
             if (mapQuan.compareTo(occ.getDrugQuan()) != 0) {
                 return ResultVoUtil.fail(ExceptionEnum.SLIGHTLY_ERROR, "用药与医嘱不匹配,请检查!");
             }
+            caMsbBuilder.append(occ.getOccName().trim()).append(" x ").append(occ.getDrugQuan());
+            if (i == drugs.size() - 1) {
+                caMsbBuilder.append("。");
+            } else {
+                caMsbBuilder.append(";");
+            }
             checkedCount++;
             drugMap.remove(occ.getChargeCode());
         }
         if (checkedCount == drugs.size() && drugMap.isEmpty()) {
             String staff = TokenUtil.getInstance().getTokenUserId();
-            int updatedRows = dao.updateExecutor(patNo, actOrderNo, occTime, staff);
+
+            CaSignClass.Send caParams = new CaSignClass.Send();
+            caParams.setId(staff);
+            caParams.setMsg(caMsbBuilder.toString());
+            caParams.setDesc("执行输液医嘱。");
+            log.info("执行输液CA签名入参:{}", caParams);
+            CaReturn.CaSignReturn caRes = caService.sendByCode(caParams);
+            log.info("执行输液CA签名返回:{}", caRes);
+
+            int updatedRows = dao.updateExecutor(patNo, actOrderNo, occTime, staff, caRes.getId());
             if (updatedRows > 0) {
                 return ResultVoUtil.success("核对执行成功。");
             }

+ 0 - 1
src/main/java/thyyxxk/webserver/service/zhuyuanyisheng/YiZhuLuRuServer.java

@@ -10,7 +10,6 @@ import com.alibaba.fastjson.JSONObject;
 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.sun.org.apache.regexp.internal.RE;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.ibatis.session.ExecutorType;

+ 9 - 23
src/main/java/thyyxxk/webserver/utils/PasswordGenerator.java

@@ -5,9 +5,9 @@ import java.util.List;
 import java.util.Random;
 
 public class PasswordGenerator {
-    public static final String[] SOURCE =  {"abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "0123456789", "!@#$%^&*()_+,.<>/?{}[]"};
+    public static final String[] SOURCE =  {"abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "0123456789", "!@#$%^&*()_+,.<>?{}[]"};
 
-    public static String generatePassword(List<Integer> usedSourceIndexes, int passwordLength) {
+    private static String generatePassword(List<Integer> usedSourceIndexes, int passwordLength) {
         usedSourceIndexes.clear();
         StringBuilder passwordBuilder = new StringBuilder();
         for (int i = 0; i < passwordLength; i++) {
@@ -16,36 +16,22 @@ public class PasswordGenerator {
                 usedSourceIndexes.add(sourceIndex);
             }
             int sourceItemIndex = new Random().nextInt(SOURCE[sourceIndex].length());
-            passwordBuilder.append(SOURCE[sourceIndex].split("")[sourceItemIndex]);
+            passwordBuilder.append(SOURCE[sourceIndex].charAt(sourceItemIndex));
         }
         return passwordBuilder.toString();
     }
 
-
-
-
-
-    public static void main(String[] args) throws Exception {
-//        for (ChargeStatus type : ChargeStatus.values()) {
-//            System.out.println(
-//                    SnowFlakeId.instance().nextId() + "," +
-//                            "charge_status," +
-//                            type.getCode() + "," +
-//                            type.getName() + "," +
-//                            PingYinUtils.pyShouZiMuDaXie(type.getName()) + "," +
-//                            PingYinUtils.getWBCode(type.getName())
-//            );
-//        }
-
+    public static List<String> generate(int length, int size) {
         List<Integer> usedSourceIndexes = new ArrayList<>();
-        int passwordLength = 16;
+        List<String> result = new ArrayList<>();
         String password;
-        for (int i = 0; i < passwordLength; i++) {
+        for (int i = 0; i < size; i++) {
             do {
-                password = generatePassword(usedSourceIndexes, passwordLength);
+                password = generatePassword(usedSourceIndexes, length);
             } while (usedSourceIndexes.size() < SOURCE.length);
-            System.out.println(password);
+            result.add(password);
         }
+        return result;
     }
 
 }

+ 3 - 0
update/2025-11-10.md

@@ -0,0 +1,3 @@
+```sql
+alter table yz_act_occ add execute_ca_sign_id varchar(32)
+```