Browse Source

打印机配置

lihong 1 month ago
parent
commit
fe4ccae73b

+ 22 - 0
src/main/java/thyyxxk/webserver/controller/zygl/AdmissionRegistrationController.java

@@ -275,6 +275,28 @@ public class AdmissionRegistrationController {
         return service.queryLastWindowsIpAddress(ipAddress);
     }
 
+    @GetMapping("/getMzZdDeptNos")
+    public ResultVo getMzZdDeptNos() {
+        return service.getMzZdDeptNos();
+    }
+
+    /**
+     * @description: 保存打印机设置
+     * @author: lihong
+     * @date: 2025/7/3 9:33
+     * @param: windows
+     * @param: request
+     * @return: thyyxxk.webserver.entity.ResultVo<java.lang.String>
+     **/
+    @PostMapping("/saveWindowPrint")
+    public ResultVo<String> saveWindowPrint(@RequestBody Windows windows,HttpServletRequest request) {
+        String ipAddress = IpAddressUtil.getIPAddress(request);
+        windows.setIpAddress(ipAddress);
+        return service.saveWindowPrint(windows);
+    }
+
+
+
     @PostMapping("/querySfzOrHkb")
     public ResultVo querySfzOrHkb(@RequestBody Map<String, Object> param) {
         Integer type = Convert.toInt(param.get("type"));

+ 3 - 4
src/main/java/thyyxxk/webserver/dao/his/inpatient/charge/CashierProcessDao.java

@@ -25,8 +25,7 @@ import java.util.Map;
 public interface CashierProcessDao {
 
     @Select("<script>" +
-            " select top ${pageSize} * from ( " +
-            "                       SELECT    ROW_NUMBER() OVER (ORDER BY  zy_actpatient.inpatient_no,zy_actpatient.admiss_times desc   ) AS rowNumber, " +
+            "                       SELECT   " +
             "                              zy_actpatient.inpatient_no, " +
             "                              zy_actpatient.admiss_times, " +
             "                              zy_actpatient.name, " +
@@ -64,7 +63,7 @@ public interface CashierProcessDao {
             "                         and zy_actpatient.ward = b.code " +
             "                         and zy_actpatient.responce_type = c.code " +
             "                         and zy_actpatient.charge_type = d.code " +
-            "                       ) aa where rowNumber >  (#{currentPage}-1)*#{pageSize}"+
+            "  order by  inpatient_no ,admiss_times desc" +
             "</script>")
     List<ZyActpatient> selectPatientInfoPage(PatientParam param);
 
@@ -355,7 +354,7 @@ public interface CashierProcessDao {
             "where    a.inpatient_no=#{inpatientNo}    and " +
             "        a.admiss_times=#{admissTimes} and " +
             "        a.ledger_sn   =#{ledgerSn}    and " +
-            "        isnull(a.responce_unit,'') in ('01') " +
+            "        isnull(a.responce_unit,'')  = #{responceUnit} " +
             "group by a.inpatient_no,a.admiss_times,a.ledger_sn,a.receipt_sn,isnull(a.responce_unit,'') ")
     ZyReceipt selectPrintZyFpData(PatientParam param);
     @Select("select rtrim(name) name ,cast(sex as int ) sex  from a_patient_mi where inpatient_no = #{inpatientNo} ")

+ 2 - 0
src/main/java/thyyxxk/webserver/dao/his/zygl/AdmissionRegistrationDao.java

@@ -232,4 +232,6 @@ public interface AdmissionRegistrationDao {
     @Insert("INSERT INTO patient_mi_sfz(social_no, name, sex, nation, birth_day, address, agency, expirestart, expireend, tx_image, sfz_image, inpatient_no, patient_id) VALUES" +
             " (#{socialNo}, #{name}, #{sex}, #{nation}, #{birthDay}, #{address}, #{agency}, #{expirestart}, #{expireend}, #{txImage}, #{sfzImage}, #{inpatientNo},#{patientId}) ")
     int insertPatientMiSfz(PatientMiSfz patientMiSfz);
+    @Select(" select code,name from mz_zd_dept_no WITH(NOLOCK) ")
+    List<Map<String, Object>> selectMzZdDeptNos();
 }

+ 4 - 0
src/main/java/thyyxxk/webserver/entity/inpatient/charge/PatientParam.java

@@ -25,7 +25,11 @@ public class PatientParam extends BasePage {
     private String printFlag;
     //发票号
     private String receiptNo;
+    //发票序号 1 是大人 4 是 小孩
+    private Integer receiptSn;
     private String tableName;
+    //大人 传 01   小孩 传04
+    private String responceUnit;
     //操作员
     private String opId;
     private Date opDate;

+ 2 - 0
src/main/java/thyyxxk/webserver/entity/inpatient/charge/Windows.java

@@ -23,6 +23,8 @@ public class Windows {
     private Integer zyPrintIndex;
     //默认常规打印机下标 一般用途打印机
     private Integer cgPrintIndex;
+    //住院预交金打印机下标 zy_yjj_print_index
+    private Integer zyYjjPrintIndex;
     //普通住院腕带打印机
     private Integer normalWristStrapPrintIndex;
     //儿童住院腕带打印机

+ 54 - 19
src/main/java/thyyxxk/webserver/service/inpatient/charge/CashierProcessService.java

@@ -77,8 +77,13 @@ public class CashierProcessService {
         }
         List<ZyActpatient> list = dao.selectPatientInfoPage(param);
         CommonUtil.BeanTrim(list);
-        result.put("data", list);
-        result.put("total", dao.selectPatientInfoCount(param));
+        if(CollUtil.isNotEmpty(list)){
+            List<ZyActpatient> collect = list.stream().skip((param.getCurrentPage() - 1) * param.getPageSize()).limit(param.getPageSize()).collect(Collectors.toList());
+            result.put("data", collect);
+        }else {
+            result.put("data", list);
+        }
+        result.put("total", list.size());
         return result;
     }
 
@@ -298,6 +303,7 @@ public class CashierProcessService {
     public List<ZyReceipt> queryZyReceipt(PatientParam param) {
         List<ZyReceipt> zyReceipt = dao.selectZyReceipt(param);
         if (CollUtil.isNotEmpty(zyReceipt)) {
+            CommonUtil.BeanTrim(zyReceipt);
             ZyReceipt temp = new ZyReceipt();
             temp.setTotalCharge(zyReceipt.stream().map(item -> Convert.toBigDecimal(item.getTotalCharge(), BigDecimal.ZERO)).reduce(BigDecimal.ZERO, BigDecimal::add));
             zyReceipt.add(temp);
@@ -373,12 +379,18 @@ public class CashierProcessService {
         checkLedgerSn(param);
        String fpVersion = Convert.toStr(queryFpVersion().getData());
         String fpVersionStr = NumberEnum.ZERO.getCode().equals(fpVersion) ? "打印" : "上传";
+        if(Convert.toInt(NumberEnum.FOUR.getCode()).equals(Convert.toInt(param.getReceiptSn(),1))){
+            param.setResponceUnit("04");
+        }else {
+            param.setResponceUnit("01");
+        }
         ZyReceipt zyReceipt = dao.selectPrintZyFpData(param);
         AssertUtil.isnotBlank(zyReceipt, "没可打印发票信息");
+        BeanUtil.trimStrFields(zyReceipt);
         List<ZyLedgerFile> list = dao.selectZyLedgerFile(param);
         AssertUtil.isnotBlank(list, "没有账页信息");
         ZyActpatient zyActpatient = dao.selectApatienInfo(param.getInpatientNo());
-        zyReceipt.setName(zyActpatient.getName());
+        zyReceipt.setName(Convert.toInt(NumberEnum.FOUR.getCode()).equals(Convert.toInt(param.getReceiptSn(),1)) ? zyActpatient.getName()+"(婴儿)":zyActpatient.getName());
         zyReceipt.setStartDate(DateUtil.format(zyReceipt.getDate1(), "yyyy-MM-dd"));
         zyReceipt.setEndDate(DateUtil.format(zyReceipt.getDate2(), "yyyy-MM-dd"));
         long diff = DateUtil.betweenDay(DateUtil.parseDate(zyReceipt.getStartDate()), DateUtil.parseDate(zyReceipt.getEndDate()), true);
@@ -393,23 +405,31 @@ public class CashierProcessService {
                 throw new BizException(ExceptionEnum.LOGICAL_ERROR, "未出纳处理,不能"+fpVersionStr+"发票");
             }
         }
-        zyReceipt.setYbTcZfJe(Convert.toBigDecimal(zyLedgerFile.getFundPaySumamt(), BigDecimal.ZERO).setScale(2, BigDecimal.ROUND_HALF_UP));
-        zyReceipt.setGrZhZfJe(Convert.toBigDecimal(zyLedgerFile.getAcctPay(), BigDecimal.ZERO).setScale(2, BigDecimal.ROUND_HALF_UP));
-        zyReceipt.setGrZfJe(zyReceipt.getTotalCharge().subtract(zyReceipt.getYbTcZfJe()).subtract(zyReceipt.getGrZhZfJe()));
-        zyReceipt.setGrZfHjJe(zyReceipt.getGrZfJe());
-        zyReceipt.setGrZfHjJeChinese(Convert.digitToChinese(zyReceipt.getGrZfHjJe()));
-        zyReceipt.setResponceTypeName(zyLedgerFile.getResponceTypeName());
-        zyReceipt.setYsHjJe(zyLedgerFile.getDeposit());
-        if (Convert.toBigDecimal(zyLedgerFile.getSettle(), BigDecimal.ZERO).compareTo(BigDecimal.ZERO) >= 0) {
-            zyReceipt.setTkHjJe(zyLedgerFile.getSettle());
-            zyReceipt.setBsHjJe(BigDecimal.ZERO);
-        } else {
-            zyReceipt.setBsHjJe(zyLedgerFile.getSettle().abs());
-            zyReceipt.setTkHjJe(BigDecimal.ZERO);
+        if(Convert.toInt(NumberEnum.FOUR.getCode()).equals(Convert.toInt(param.getReceiptSn(),1))){
+            zyReceipt.setGrZfHjJe(zyReceipt.getGrZfJe());
+            zyReceipt.setGrZfHjJeChinese(Convert.digitToChinese(zyReceipt.getGrZfHjJe()));
+        }else {
+            zyReceipt.setYbTcZfJe(Convert.toBigDecimal(zyLedgerFile.getFundPaySumamt(), BigDecimal.ZERO).setScale(2, BigDecimal.ROUND_HALF_UP));
+            zyReceipt.setGrZhZfJe(Convert.toBigDecimal(zyLedgerFile.getAcctPay(), BigDecimal.ZERO).setScale(2, BigDecimal.ROUND_HALF_UP));
+            zyReceipt.setGrZfJe(zyReceipt.getTotalCharge().subtract(zyReceipt.getYbTcZfJe()).subtract(zyReceipt.getGrZhZfJe()));
+            zyReceipt.setGrZfHjJe(zyReceipt.getGrZfJe());
+            zyReceipt.setGrZfHjJeChinese(Convert.digitToChinese(zyReceipt.getGrZfHjJe()));
+            zyReceipt.setResponceTypeName(zyLedgerFile.getResponceTypeName());
+            zyReceipt.setYsHjJe(zyLedgerFile.getDeposit());
+            if (Convert.toBigDecimal(zyLedgerFile.getSettle(), BigDecimal.ZERO).compareTo(BigDecimal.ZERO) >= 0) {
+                zyReceipt.setTkHjJe(zyLedgerFile.getSettle());
+                zyReceipt.setBsHjJe(BigDecimal.ZERO);
+            } else {
+                zyReceipt.setBsHjJe(zyLedgerFile.getSettle().abs());
+                zyReceipt.setTkHjJe(BigDecimal.ZERO);
+            }
+            zyReceipt.setYsHjJe(Convert.toBigDecimal(zyLedgerFile.getDeposit(), BigDecimal.ZERO));
         }
-        zyReceipt.setYsHjJe(Convert.toBigDecimal(zyLedgerFile.getDeposit(), BigDecimal.ZERO));
-        BeanUtil.trimStrFields(zyReceipt);
         if(NumberEnum.ONE.getCode().equals(fpVersion)){
+             //小孩  加 $1
+            if(Convert.toInt(NumberEnum.FOUR.getCode()).equals(param.getReceiptSn())){
+                param.setInpatientNo(param.getInpatientNo()+"$1");
+            }
             ResultVo resultVo = uploadDzInvoice(param);
             String typeFlagName = param.getTypeFlag() == 3 ? "上传电子发票" : "作废电子发票";
             if(resultVo == null){
@@ -489,6 +509,18 @@ public class CashierProcessService {
     }
 
     public ResultVo<Map<String, Object>> downDzInvoice(PatientParam param) {
+        if(Convert.toInt(NumberEnum.FOUR.getCode()).equals(Convert.toInt(param.getReceiptSn(),1))){
+            param.setResponceUnit("04");
+        }else {
+            param.setResponceUnit("01");
+        }
+        ZyReceipt zyReceipt = dao.selectPrintZyFpData(param);
+        AssertUtil.isnotBlank(zyReceipt, "没有发票信息");
+        ZyActpatient zyActpatient = dao.selectApatienInfo(param.getInpatientNo());
+        zyReceipt.setName(Convert.toInt(NumberEnum.FOUR.getCode()).equals(Convert.toInt(param.getReceiptSn(),1)) ? zyActpatient.getName()+"(婴儿)":zyActpatient.getName());
+        if(Convert.toInt(NumberEnum.FOUR.getCode()).equals(param.getReceiptSn())){
+            param.setInpatientNo(param.getInpatientNo()+"$1");
+        }
         Map<String, Object> paramMap = dealInvoiceParam(param);
         ResultVo response = template.postForObject(thmzApiUrl +"/queryInvoiceFile", paramMap, ResultVo.class);
         if(response == null ){
@@ -513,7 +545,10 @@ public class CashierProcessService {
                }
            }
         }
-        return ResultVoUtil.success(ExceptionEnum.SUCCESS, (Map)response.getData());
+        Map<String, Object> res = new HashMap<>();
+        res.put("zyReceipt", zyReceipt);
+        res.put("fpInfo", response.getData());
+        return ResultVoUtil.success(ExceptionEnum.SUCCESS,res);
     }
 
     public ResultVo<String> queryFpVersion() {

+ 29 - 1
src/main/java/thyyxxk/webserver/service/zygl/AdmissionRegistrationService.java

@@ -30,6 +30,8 @@ import thyyxxk.webserver.entity.zygl.PatientMiSfz;
 import thyyxxk.webserver.entity.zygl.ZyXnhRecord;
 import thyyxxk.webserver.utils.AssertUtil;
 import thyyxxk.webserver.utils.CommonUtil;
+import thyyxxk.webserver.utils.ResultVoUtil;
+import thyyxxk.webserver.utils.TokenUtil;
 
 import javax.annotation.Resource;
 import java.util.ArrayList;
@@ -55,6 +57,8 @@ public class AdmissionRegistrationService {
     private ZyConfigService zyConfigService;
     @Resource
     private ZyActpatientService zyActpatientService;
+    @Resource
+    private  RestTemplate template;
 
     @Value("${thmz-api-url}")
     private String thmzApiUrl;
@@ -305,7 +309,7 @@ public class AdmissionRegistrationService {
         String realUrl = thmzApiUrl + "/api/v1/queryWindowsByIp?ip=" + ipAddress;
         ResultVo<Windows> response = new ResultVo();
         try {
-             response = new RestTemplate().getForObject(realUrl, ResultVo.class);
+             response = template.getForObject(realUrl, ResultVo.class);
             if (response == null || response.getCode() == -1) {
                 throw new BizException(ExceptionEnum.INTERNAL_SERVER_ERROR, "获取窗口信息失败");
             }
@@ -419,4 +423,28 @@ public class AdmissionRegistrationService {
         dao.deletePatientMiSfzByPatientId(patientMiSfz.getPatientId());
         return dao.insertPatientMiSfz(patientMiSfz);
     }
+
+    public ResultVo<String> saveWindowPrint(Windows windows) {
+        String realUrl = thmzApiUrl + "/saveWindowPrint";
+        ResultVo response = null;
+        try {
+            windows.setUserIdCode(TokenUtil.getInstance().getTokenUserId());
+            response = template.postForObject(realUrl,windows, ResultVo.class);
+            if (response == null) {
+                throw new BizException(ExceptionEnum.INTERNAL_SERVER_ERROR, "保存打印机配置失败");
+            }
+            if (response.getCode() == -1) {
+                throw new BizException(ExceptionEnum.INTERNAL_SERVER_ERROR, response.getMessage());
+            }
+        }catch (Exception e){
+            log.error("[saveWindowPrint]报错:",e);
+            throw new BizException(ExceptionEnum.INTERNAL_SERVER_ERROR, "保存打印机配置失败:"+e.getMessage());
+        }
+        return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_EL_MESSAGE);
+    }
+
+    public ResultVo getMzZdDeptNos() {
+        List<Map<String, Object>> list = dao.selectMzZdDeptNos();
+        return ResultVoUtil.success(list);
+    }
 }

+ 4 - 0
src/main/java/thyyxxk/webserver/service/zygl/ZyActpatientService.java

@@ -42,6 +42,7 @@ import thyyxxk.webserver.entity.zygl.ZyConfig;
 import thyyxxk.webserver.entity.zygl.ZyWorkLog;
 import thyyxxk.webserver.service.hutoolcache.UserCache;
 import thyyxxk.webserver.utils.AssertUtil;
+import thyyxxk.webserver.utils.CommonUtil;
 import thyyxxk.webserver.utils.TokenUtil;
 
 import javax.annotation.Resource;
@@ -106,6 +107,9 @@ public class ZyActpatientService {
         AssertUtil.isnotBlank(zyActpatient.getAdmissDate(),"入院日期不能为空");
         AssertUtil.isnotBlank(zyActpatient.getAdmissPhysician(),"入院医生不能为空");
         AssertUtil.isnotBlank(zyActpatient.getClinicDiag(),"门诊诊断编码不能为空");
+        if(!CommonUtil.validateClinicDiagnose(zyActpatient.getClinicDiag())){
+            throw new BizException(ExceptionEnum.LOGICAL_ERROR, "入院登记诊断编码范围应为:A~U开头和Z开头的编码;不包括字母V、W、X、Y开头的编码,请重新开具住院证");
+        }
         AssertUtil.isnotBlank(zyActpatient.getClinicDiagStr(),"门诊诊断不能为空");
         AssertUtil.isnotBlank(zyActpatient.getAdmissDiagStr(),"住院诊断不能为空");
         AssertUtil.isnotBlank(zyActpatient.getAdmissDiag(),"住院诊断编码不能为空");

+ 18 - 0
src/main/java/thyyxxk/webserver/utils/CommonUtil.java

@@ -3,6 +3,7 @@ package thyyxxk.webserver.utils;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.io.IoUtil;
+import cn.hutool.core.util.NumberUtil;
 import cn.hutool.core.util.ReflectUtil;
 import cn.hutool.core.util.StrUtil;
 import lombok.extern.slf4j.Slf4j;
@@ -427,4 +428,21 @@ public class CommonUtil {
 
         g.drawString(iter, (Integer) map.get("x"), (Integer) map.get("y")); // 添加水印的文字和设置水印文字出现的内容
     }
+
+    /**
+     * @description: 检查门诊诊断
+     * @author: lihong  门(急)诊诊断编码范围应为:A~U开头和Z开头的编码;不包括字母V、W、X、Y开头的编码。
+     * @date: 2025/7/3 15:21
+     * @return: boolean
+     **/
+    public static boolean validateClinicDiagnose(String diagCode){
+        if(StrUtil.isBlank(diagCode)) return false;
+        String first = diagCode.substring(0, 1).toUpperCase();
+        List<String> list = CollUtil.newArrayList(new String[]{"V", "W", "X", "Y"});
+        if(!NumberUtil.isNumber(first) && !list.contains(first)){
+            return true;
+        }
+        return false;
+    }
+
 }