Pārlūkot izejas kodu

优化项目录入中的退费使用新的接口,上线毒麻药不能只退费不退药。

xiaochan 2 gadi atpakaļ
vecāks
revīzija
a1bc6b9d72

+ 25 - 0
src/main/java/thyyxxk/webserver/controller/hospitalizationCosts/HospitalizationCostsController.java

@@ -0,0 +1,25 @@
+package thyyxxk.webserver.controller.hospitalizationCosts;
+
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.entity.hospitalizationCosts.ZyDetailRefundParam;
+import thyyxxk.webserver.service.hospitalizationCosts.HospitalizationCostsService;
+
+@RestController
+@RequestMapping("/hospitalizationCosts")
+public class HospitalizationCostsController {
+    private final HospitalizationCostsService service;
+
+    public HospitalizationCostsController(HospitalizationCostsService service) {
+        this.service = service;
+    }
+
+    @PostMapping("/refund")
+    public ResultVo<String> refund(@RequestBody @Validated ZyDetailRefundParam param) {
+        return service.refund(param);
+    }
+}

+ 12 - 1
src/main/java/thyyxxk/webserver/dao/his/PublicDao.java

@@ -139,7 +139,18 @@ public interface PublicDao {
     Integer getLedgerSn(@Param("inpatientNo") String inpatient, @Param("admissTimes") Integer admissTimes);
 
 
-    @Select("select rtrim(inpatient_no) inpatient_no,admiss_times,admiss_date,dis_date,name, " + "responce_name = (select rtrim(name) name from zy_zd_responce_type where code = responce_type)," + "responce_type,  " + "ward,ward_name = (select rtrim(name) name from zd_unit_code where code = ward), " + "ledger_sn = (select max(ledger_sn) from zy_ledger_file where a.inpatient_no = zy_ledger_file.inpatient_no and a.admiss_times = zy_ledger_file.admiss_times), " + "chu_yuan_yi_zhu = (case when (select count(1) from yz_act_order where inpatient_no= a.inpatient_no and admiss_times= a.admiss_times " + "and status_flag > '2' and isnull(group_no,'00' )='00' and order_code in ('06026','06053','05973')) > 0 " + "then 1 " + "when (select count(1) from yz_inact_order where inpatient_no= a.inpatient_no and admiss_times= a.admiss_times " + "and status_flag > '2' and isnull(group_no,'00' )='00' and order_code in ('06026','06053','05973')) > 0 " + "then 1 else 0 end  ), " + "bed_no,total_charge,balance from zy_actpatient a where inpatient_no = #{inpatientNo} ")
+    @Select("select rtrim(inpatient_no) inpatient_no,admiss_times,admiss_date,dis_date,name, " +
+            "responce_name = (select rtrim(name) name from zy_zd_responce_type where code = responce_type)," +
+            "responce_type,  " + "rtrim(zk_ward) as dept,ward,ward_name = (select rtrim(name) name from zd_unit_code where code = ward), " +
+            "ledger_sn = (select max(ledger_sn) from zy_ledger_file where a.inpatient_no = zy_ledger_file.inpatient_no and a.admiss_times = zy_ledger_file.admiss_times), " +
+            "chu_yuan_yi_zhu = (case when (select count(1) from yz_act_order where inpatient_no= a.inpatient_no and admiss_times= a.admiss_times " +
+            "and status_flag > '2' and isnull(group_no,'00' )='00' and order_code in ('06026','06053','05973')) > 0 " +
+            "then 1 " +
+            "when (select count(1) from yz_inact_order where inpatient_no= a.inpatient_no and admiss_times= a.admiss_times " +
+            "and status_flag > '2' and isnull(group_no,'00' )='00' and order_code in ('06026','06053','05973')) > 0 " +
+            "then 1 else 0 end  ), " + "bed_no,total_charge,balance,zy_serial_no " +
+            " from zy_actpatient a " +
+            "where inpatient_no = #{inpatientNo} ")
     ZyActpatient getHuanZheJiBenXinXi(@Param("inpatientNo") String inpatientNo);
 
     @Update("update zy_detail_charge set ori_detail_sn = null where inpatient_no = #{inpatientNo} " + "and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} and ori_detail_sn = -1 and charge_amount > 0")

+ 120 - 0
src/main/java/thyyxxk/webserver/dao/his/hospitalizationCosts/HospitalizationCostsDao.java

@@ -0,0 +1,120 @@
+package thyyxxk.webserver.dao.his.hospitalizationCosts;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.*;
+import thyyxxk.webserver.entity.datamodify.ZyDetailCharge;
+import thyyxxk.webserver.entity.hospitalizationCosts.ZyDetailChargeTable;
+import thyyxxk.webserver.entity.inpatient.ZyActpatient;
+import thyyxxk.webserver.service.hospitalizationCosts.HospitalizationCostsService;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+@Mapper
+public interface HospitalizationCostsDao extends BaseMapper<ZyDetailChargeTable> {
+
+    @Select("select count(1) from  yp_zd_dict where code = #{code} and serial = #{serial} and drug_kind = '0013'")
+    Integer getDrugKing(String code, String serial);
+
+    @Select("select b.class as class_code," +
+            "       a.drug_flag as drug_class," +
+            "       a.mini_unit " +
+            "from yz_act_order a, " +
+            "     yz_supply_type b " +
+            "where a.supply_code = b.supply_code " +
+            "  and a.act_order_no = #{order} ")
+    HospitalizationCostsService.OrderInfo selectDrugClassByOrderNo(BigDecimal order);
+
+
+    /**
+     * 插入数据
+     *
+     * @param list 插入退费的数据 生成一条一样的数据 只是 费用和数量不一致 以及录入人 和 录入时间 ori_detail_sn 保存退费的原流水号
+     */
+    @Insert("<script>" +
+            "insert into zy_detail_charge(inpatient_no, admiss_times, ledger_sn, detail_sn, " +
+            "charge_date, op_id_code, charge_code, infant_flag, " +
+            "charge_status, retprice, charge_amount, charge_fee, self_flag, separate_flag," +
+            " suppress_flag, ward_code, dept_code, order_no, ope_flag, exec_unit, gen_time, " +
+            "pay_percent, zj_flag, zfl, charge_code_mx, serial, zy_serial_no, doctor_code, " +
+            "yb_self_flag, orig_charge_fee, confirm_id, trans_flag_yb, ss_code, gs_flag, " +
+            "refer_physician, consult_physician, ori_detail_sn)   " +
+            "values " +
+            "<foreach collection='list' item='item' index='index' separator=','>" +
+            "(#{item.inpatientNo},#{item.admissTimes},#{item.ledgerSn},#{item.detailSn}," +
+            "#{item.chargeDate},#{item.opIdCode},#{item.chargeCode},#{item.infantFlag}," +
+            "#{item.chargeStatus},cast(#{item.retprice,jdbcType=DECIMAL} as decimal(14,5))," +
+            "cast(#{item.chargeAmount,jdbcType=DECIMAL} as decimal(14,5))," +
+            "cast(#{item.chargeFee,jdbcType=DECIMAL} as decimal(14,5))," +
+            "#{item.selfFlag},#{item.separateFlag},#{item.suppressFlag},#{item.wardCode},#{item.deptCode},#{item.orderNo}," +
+            "#{item.opeFlag},#{item.execUnit},#{item.genTime}," +
+            "cast(#{item.payPercent,jdbcType=DECIMAL} as decimal(14,5)),#{item.zjFlag},cast(#{item.zfl,jdbcType=DECIMAL} as decimal(14,5)),#{item.chargeCodeMx},#{item.serial},#{item.zySerialNo}," +
+            "#{item.doctorCode}," +
+            "#{item.ybSelfFlag},cast(#{item.origChargeFee,jdbcType=DECIMAL} as decimal(14,5)),#{item.confirmId},0," +
+            "#{item.ssCode},#{item.gsFlag}," +
+            "#{item.referPhysician},#{item.consultPhysician},#{item.oriDetailSn})" +
+            "</foreach>" +
+            "</script>")
+    void insertRefundData(@Param("list") List<ZyDetailChargeTable> list);
+
+
+    @Insert("<script>" +
+            "insert into yz_yp_zy_order (inpatient_no, admiss_times, name, bed_no, dept_code, ward_code, charge_code, amount, " +
+            "                            retprice, charge_date, infant_flag, drawer, always_flag, status_flag, drug_class,  " +
+            "                            occ_time, act_order_no, serial, group_no, doctor_name, page_no_ty,ledger_sn,detail_sn,serail,page_class) " +
+            "values " +
+            "<foreach collection='list' item='item' index='index' separator=','>" +
+            "(#{patNo}, #{times}, #{name}, #{bedNo}, #{wardCode},  #{wardCode}, #{item.chargeCodeMx}, #{item.chargeAmount,jdbcType=REAL}, " +
+            "       (select pack_retprice from yp_zd_dict where code = #{item.chargeCodeMx} and serial = #{item.serial}), getdate(), #{infantFlag}, #{userCode}, 'a', '1', " +
+            "       #{item.drugClass},  getdate(), ${index}, #{item.serial}, #{groupNo}, " +
+            "       #{item.doctorCode}, '-1',#{ledgerSn},#{item.detailSn},0,'HT')" +
+            "</foreach>" +
+            "</script>")
+    void detailsOfDrugReturnForm(@Param("list") List<ZyDetailChargeTable> list,
+                                 @Param("patNo") String patNo,
+                                 @Param("times") Integer times,
+                                 @Param("name") String name,
+                                 @Param("bedNo") String bedNo,
+                                 @Param("wardCode") String wardCode,
+                                 @Param("infantFlag") Integer infantFlag,
+                                 @Param("groupNo") String groupNo,
+                                 @Param("userCode") String userCode,
+                                 @Param("ledgerSn") Integer ledgerSn);
+
+
+    @Insert("<script>" +
+            "insert into zy_drug ( inpatient_no , admiss_times , ledger_sn , detail_sn , charge_date , op_id_code , charge_code , infant_flag , " +
+            "charge_fee , self_flag , separate_flag , supress_flag , ward_code , dept_code , ope_flag , exec_unit , retprice , amount , zy_serial_no , " +
+            "serial , group_no , occ_cate ) values " +
+            "<foreach collection='list' item='item' separator=','>" +
+            "( #{yz.inpatientNo} , #{yz.admissTimes} , #{ledgerSn} , #{item.detailSn} , getdate() , #{opIdCode} , " +
+            "#{item.chargeCodeMx} ,  #{infantFlag} , " +
+            // 金额
+            "cast(#{item.chargeFee,jdbcType=DECIMAL} as decimal(14,5))," +
+            " '0' , '0' , null , #{yz.ward} , #{yz.dept} , '0' , #{item.deptCode} ," +
+            // 单价
+            "  cast(#{item.chargeFee,jdbcType=DECIMAL} / #{item.chargeAmount,jdbcType=DECIMAL} as decimal(14,5)) , " +
+            // 数量
+            "cast(#{item.chargeAmount,jdbcType=DECIMAL} as decimal(14,5)) " +
+            ", #{yz.zySerialNo} , #{item.serial} , '73' ,'1' )" +
+            "</foreach>" +
+            "</script>")
+    void shenQingYaoPing(@Param("yz") ZyActpatient yz,
+                         @Param("list") List<ZyDetailChargeTable> list,
+                         @Param("infantFlag") int infantFlag,
+                         @Param("ledgerSn") Integer ledgerSn,
+                         @Param("opIdCode") String opIdCode);
+
+
+    @Update("<script>" +
+            "<foreach collection='list' item='item' separator=';'>" +
+            "update zy_detail_charge " +
+            "set ori_detail_sn = #{item.oriDetailSn} " +
+            "where inpatient_no = #{item.inpatientNo} " +
+            "  and admiss_times = #{item.admissTimes} " +
+            "  and ledger_sn = #{item.ledgerSn} " +
+            "  and detail_sn = #{item.detailSn}" +
+            "</foreach> " +
+            "</script>")
+    void updateOriFlag(@Param("list") List<ZyDetailChargeTable> list);
+}

+ 2 - 1
src/main/java/thyyxxk/webserver/dao/his/inpatient/TransferInOfExpensesDao.java

@@ -227,7 +227,8 @@ public interface TransferInOfExpensesDao {
      * @param admissTimes 住院次数
      * @return 返回最大的流水号
      */
-    @Select("select isnull(max(detail_sn),0) from zy_detail_charge where inpatient_no=#{inpatientNo} and admiss_times=#{admissTimes}")
+    @Select("select isnull(max(detail_sn),0) from zy_detail_charge where " +
+            "inpatient_no=#{inpatientNo} and admiss_times=#{admissTimes}")
     Integer getMaxDetailSn(@Param("inpatientNo") String inpatientNo,
                            @Param("admissTimes") Integer admissTimes);
 

+ 3 - 0
src/main/java/thyyxxk/webserver/dao/his/inpatient/XiangMuLuRuDao.java

@@ -447,6 +447,9 @@ public interface XiangMuLuRuDao extends BaseMapper<ZyDetailCharge> {
             "  and a.act_order_no = #{order} ")
     ZyDetailCharge selectDrugClassByOrderNo(BigDecimal order);
 
+    @Select("select count(1) from  yp_zd_dict where code = #{code} and serial = #{serial} and drug_kind = '0013'")
+    Integer getDrugKing(String code, String serial);
+
     @Insert("<script>" +
             "insert into zy_drug ( inpatient_no , admiss_times , ledger_sn , detail_sn , charge_date , op_id_code , charge_code , infant_flag , " +
             "charge_fee , self_flag , separate_flag , supress_flag , ward_code , dept_code , ope_flag , exec_unit , retprice , amount , zy_serial_no , " +

+ 1 - 1
src/main/java/thyyxxk/webserver/dao/his/ybkf/YbUtilDao.java

@@ -34,7 +34,7 @@ public interface YbUtilDao {
      * @author: hsh
      * @date: 2022/11/1 11:20
      * @param: [patNo, times, ledgerSn]
-     * @return: List<ZyDetailCharge>
+     * @return: List<ZyDetailChargeTable>
      **/
     @Select(" select * from zy_detail_charge " +
             "where inpatient_no = #{patNo} and admiss_times = #{times} and ledger_sn = #{ledgerSn} " +

+ 253 - 0
src/main/java/thyyxxk/webserver/entity/hospitalizationCosts/ZyDetailChargeTable.java

@@ -0,0 +1,253 @@
+package thyyxxk.webserver.entity.hospitalizationCosts;
+
+import java.io.Serializable;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+
+@Data
+@TableName(value = "zy_detail_charge")
+public class ZyDetailChargeTable implements Serializable {
+
+    private static final long serialVersionUID = 8458093229289020697L;
+
+    /**
+     * 住院号
+     */
+    @TableField(value = "inpatient_no")
+    private String inpatientNo;
+
+    /**
+     * 住院次数
+     */
+    @TableField(value = "admiss_times")
+    private Integer admissTimes;
+
+    /**
+     * 账页码,在表select isnull(max(ledger_sn),1)  from zy_ledger_file where inpatient_no = ? and admiss_times = ?这样获取
+     */
+    @TableField(value = "ledger_sn")
+    private Integer ledgerSn;
+
+    /**
+     * 流水号,select isnull(max(detail_sn),0) from zy_detail_charge where inpatient_no=? and admiss_times=?
+     */
+    @TableField(value = "detail_sn")
+    private Integer detailSn;
+
+    /**
+     * 收费日期
+     */
+    @TableField(value = "charge_date")
+    private Date chargeDate;
+
+    /**
+     * opIdCode
+     */
+    @TableField(value = "op_id_code")
+    private String opIdCode;
+
+    /**
+     * 收费编码,项目时和charge_code_mx一致,药品不一样。
+     */
+    @TableField(value = "charge_code")
+    private String chargeCode;
+
+    /**
+     * 婴儿标志
+     */
+    @TableField(value = "infant_flag")
+    private String infantFlag;
+
+    /**
+     * chargeStatus
+     */
+    @TableField(value = "charge_status")
+    private String chargeStatus;
+
+    /**
+     * retprice
+     */
+    @TableField(value = "retprice")
+    private BigDecimal retprice;
+
+    /**
+     * 费用 数量
+     */
+    @TableField(value = "charge_amount")
+    private BigDecimal chargeAmount;
+
+    /**
+     * 费用 金额
+     */
+    @TableField(value = "charge_fee")
+    private BigDecimal chargeFee;
+
+    /**
+     * selfFlag
+     */
+    @TableField(value = "self_flag")
+    private String selfFlag;
+
+    /**
+     * separateFlag
+     */
+    @TableField(value = "separate_flag")
+    private String separateFlag;
+
+    /**
+     * suppressFlag
+     */
+    @TableField(value = "suppress_flag")
+    private String suppressFlag;
+
+    /**
+     * 患者的病区
+     */
+    @TableField(value = "ward_code")
+    private String wardCode;
+
+    /**
+     * 申请科室,(取患者的科室入院科室  admissDept)
+     */
+    @TableField(value = "dept_code")
+    private String deptCode;
+
+    /**
+     * 医嘱号 0-住院费用,3-医技费用,6-门诊转入费用,长度大于2就是医嘱号了。
+     */
+    @TableField(value = "order_no")
+    private BigDecimal orderNo;
+
+    /**
+     * opeFlag
+     */
+    @TableField(value = "ope_flag")
+    private String opeFlag;
+
+    /**
+     * 执行科室,这个项目是哪个科室执行的。
+     */
+    @TableField(value = "exec_unit")
+    private String execUnit;
+
+    /**
+     * 费用执行时间
+     */
+    @TableField(value = "gen_time")
+    private Date genTime;
+
+    /**
+     * payPercent
+     */
+    @TableField(value = "pay_percent")
+    private BigDecimal payPercent;
+
+    /**
+     * zjFlag
+     */
+    @TableField(value = "zj_flag")
+    private String zjFlag;
+
+    /**
+     * zfl
+     */
+    @TableField(value = "zfl")
+    private BigDecimal zfl;
+
+    /**
+     * 收费编码明细,查询编码以这个为准。
+     */
+    @TableField(value = "charge_code_mx")
+    private String chargeCodeMx;
+
+    /**
+     * 00 | null-项目, 01 - 小包装药品 09 - 大包装药品
+     */
+    @TableField(value = "serial")
+    private String serial;
+
+    /**
+     * 住院流水号
+     */
+    @TableField(value = "zy_serial_no")
+    private String zySerialNo;
+
+    /**
+     * 医生编码
+     */
+    @TableField(value = "doctor_code")
+    private String doctorCode;
+
+    /**
+     * ybSelfFlag
+     */
+    @TableField(value = "yb_self_flag")
+    private String ybSelfFlag;
+
+    /**
+     * origChargeFee
+     */
+    @TableField(value = "orig_charge_fee")
+    private BigDecimal origChargeFee;
+
+    /**
+     * confirmId
+     */
+    @TableField(value = "confirm_id")
+    private String confirmId;
+
+    /**
+     * transFlagYb
+     */
+    @TableField(value = "trans_flag_yb")
+    private String transFlagYb;
+
+    /**
+     * 手术编码
+     */
+    @TableField(value = "ss_code")
+    private String ssCode;
+
+    /**
+     * gsFlag
+     */
+    @TableField(value = "gs_flag")
+    private String gsFlag;
+
+    /**
+     * referPhysician
+     */
+    @TableField(value = "refer_physician")
+    private String referPhysician;
+
+    /**
+     * consultPhysician
+     */
+    @TableField(value = "consult_physician")
+    private String consultPhysician;
+
+    /**
+     * 原退费流水号
+     */
+    @TableField(value = "ori_detail_sn")
+    private Integer oriDetailSn;
+
+    /**
+     * hospApprFlag
+     */
+    @TableField(value = "hosp_appr_flag")
+    private Integer hospApprFlag;
+
+    /**
+     * 药品的类型,在生成药单时使用
+     */
+    @TableField(exist = false)
+    private String drugClass;
+
+}

+ 50 - 0
src/main/java/thyyxxk/webserver/entity/hospitalizationCosts/ZyDetailRefundParam.java

@@ -0,0 +1,50 @@
+package thyyxxk.webserver.entity.hospitalizationCosts;
+
+import lombok.Data;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Data
+public class ZyDetailRefundParam {
+    /**
+     * 这个是一个组合 id
+     * 用 zy_detail_charge 中的 inpatient_no,admiss_times,ledger_sn,detail_sn
+     * 这些参数相加,得出的组合id
+     */
+    private List<String> rowId;
+
+    private List<ZyDetailChargeTable> list;
+
+    /**
+     * 住院号
+     */
+    private String inpatientNo;
+
+    /**
+     * 住院次数
+     */
+    private Integer admissTimes;
+
+    /**
+     * 退药的药房
+     */
+    private String groupNo;
+
+    /**
+     * 退药标志 refundOnly 只退费 drugWithdrawal 退费也退药
+     */
+    private String refundFlag;
+
+
+
+
+    public List<Integer> getDetailSn() {
+        List<Integer> detailSn = new ArrayList<>();
+        for (ZyDetailChargeTable item : list) {
+            detailSn.add(item.getDetailSn());
+        }
+        return detailSn;
+    }
+
+}

+ 876 - 0
src/main/java/thyyxxk/webserver/entity/inpatient/YpZdDict.java

@@ -0,0 +1,876 @@
+package thyyxxk.webserver.entity.inpatient;
+
+import java.io.Serializable;
+
+import lombok.Data;
+
+import java.util.Date;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+
+@Data
+@TableName(value = "yp_zd_dict")
+public class YpZdDict implements Serializable {
+
+    private static final long serialVersionUID = 8219827811262103881L;
+
+    /**
+     * code
+     */
+    @TableField(value = "code")
+    private String code;
+
+    /**
+     * serial
+     */
+    @TableField(value = "serial")
+    private String serial;
+
+    /**
+     * name
+     */
+    @TableField(value = "name")
+    private String name;
+
+    /**
+     * classCode
+     */
+    @TableField(value = "class_code")
+    private String classCode;
+
+    /**
+     * dosage
+     */
+    @TableField(value = "dosage")
+    private String dosage;
+
+    /**
+     * concentration
+     */
+    @TableField(value = "concentration")
+    private String concentration;
+
+    /**
+     * weight
+     */
+    @TableField(value = "weight")
+    private Double weight;
+
+    /**
+     * weighUnit
+     */
+    @TableField(value = "weigh_unit")
+    private String weighUnit;
+
+    /**
+     * volum
+     */
+    @TableField(value = "volum")
+    private Double volum;
+
+    /**
+     * volUnit
+     */
+    @TableField(value = "vol_unit")
+    private String volUnit;
+
+    /**
+     * miniUnit
+     */
+    @TableField(value = "mini_unit")
+    private String miniUnit;
+
+    /**
+     * packSize
+     */
+    @TableField(value = "pack_size")
+    private Double packSize;
+
+    /**
+     * packUnit
+     */
+    @TableField(value = "pack_unit")
+    private String packUnit;
+
+    /**
+     * specification
+     */
+    @TableField(value = "specification")
+    private String specification;
+
+    /**
+     * specification2
+     */
+    @TableField(value = "specification2")
+    private String specification2;
+
+    /**
+     * packRetprice
+     */
+    @TableField(value = "pack_retprice")
+    private Double packRetprice;
+
+    /**
+     * retprice
+     */
+    @TableField(value = "retprice")
+    private Double retprice;
+
+    /**
+     * percentGroupMz
+     */
+    @TableField(value = "percent_group_mz")
+    private String percentGroupMz;
+
+    /**
+     * percentGroupZy
+     */
+    @TableField(value = "percent_group_zy")
+    private String percentGroupZy;
+
+    /**
+     * selfFlag
+     */
+    @TableField(value = "self_flag")
+    private String selfFlag;
+
+    /**
+     * separateFlag
+     */
+    @TableField(value = "separate_flag")
+    private String separateFlag;
+
+    /**
+     * supriceFlag
+     */
+    @TableField(value = "suprice_flag")
+    private String supriceFlag;
+
+    /**
+     * drugFlag
+     */
+    @TableField(value = "drug_flag")
+    private String drugFlag;
+
+    /**
+     * pyCode
+     */
+    @TableField(value = "py_code")
+    private String pyCode;
+
+    /**
+     * dCode
+     */
+    @TableField(value = "d_code")
+    private String dCode;
+
+    /**
+     * infusionFlag
+     */
+    @TableField(value = "infusion_flag")
+    private String infusionFlag;
+
+    /**
+     * visibleFlag
+     */
+    @TableField(value = "visible_flag")
+    private String visibleFlag;
+
+    /**
+     * delFlag
+     */
+    @TableField(value = "del_flag")
+    private String delFlag;
+
+    /**
+     * countryFlag
+     */
+    @TableField(value = "country_flag")
+    private String countryFlag;
+
+    /**
+     * fixPrice
+     */
+    @TableField(value = "fix_price")
+    private Double fixPrice;
+
+    /**
+     * newFlag
+     */
+    @TableField(value = "new_flag")
+    private String newFlag;
+
+    /**
+     * manuCode
+     */
+    @TableField(value = "manu_code")
+    private String manuCode;
+
+    /**
+     * ybFlag
+     */
+    @TableField(value = "yb_flag")
+    private String ybFlag;
+
+    /**
+     * sortCode
+     */
+    @TableField(value = "sort_code")
+    private String sortCode;
+
+    /**
+     * gmpFlag
+     */
+    @TableField(value = "gmp_flag")
+    private String gmpFlag;
+
+    /**
+     * coldFlag
+     */
+    @TableField(value = "cold_flag")
+    private String coldFlag;
+
+    /**
+     * chemRemark
+     */
+    @TableField(value = "chem_remark")
+    private String chemRemark;
+
+    /**
+     * drugKind
+     */
+    @TableField(value = "drug_kind")
+    private String drugKind;
+
+    /**
+     * zbFlag
+     */
+    @TableField(value = "zb_flag")
+    private String zbFlag;
+
+    /**
+     * zbSupplyer
+     */
+    @TableField(value = "zb_supplyer")
+    private String zbSupplyer;
+
+    /**
+     * nCode
+     */
+    @TableField(value = "n_code")
+    private String nCode;
+
+    /**
+     * billItemMz
+     */
+    @TableField(value = "bill_item_mz")
+    private String billItemMz;
+
+    /**
+     * billItemZy
+     */
+    @TableField(value = "bill_item_zy")
+    private String billItemZy;
+
+    /**
+     * supplyType
+     */
+    @TableField(value = "supply_type")
+    private String supplyType;
+
+    /**
+     * frequency
+     */
+    @TableField(value = "frequency")
+    private String frequency;
+
+    /**
+     * psFlag
+     */
+    @TableField(value = "ps_flag")
+    private String psFlag;
+
+    /**
+     * exCode
+     */
+    @TableField(value = "ex_code")
+    private String exCode;
+
+    /**
+     * kssFlag
+     */
+    @TableField(value = "kss_flag")
+    private String kssFlag;
+
+    /**
+     * zjFlag
+     */
+    @TableField(value = "zj_flag")
+    private String zjFlag;
+
+    /**
+     * specB
+     */
+    @TableField(value = "spec_b")
+    private String specB;
+
+    /**
+     * ybCode
+     */
+    @TableField(value = "yb_code")
+    private String ybCode;
+
+    /**
+     * ybType
+     */
+    @TableField(value = "yb_type")
+    private String ybType;
+
+    /**
+     * ybCodeZf
+     */
+    @TableField(value = "yb_code_zf")
+    private String ybCodeZf;
+
+    /**
+     * initFlag
+     */
+    @TableField(value = "init_flag")
+    private String initFlag;
+
+    /**
+     * ypLevel
+     */
+    @TableField(value = "yp_level")
+    private String ypLevel;
+
+    /**
+     * drugId
+     */
+    @TableField(value = "drug_id")
+    private String drugId;
+
+    /**
+     * serialOld
+     */
+    @TableField(value = "serial_old")
+    private String serialOld;
+
+    /**
+     * specPack
+     */
+    @TableField(value = "spec_pack")
+    private String specPack;
+
+    /**
+     * xnhFlag
+     */
+    @TableField(value = "xnh_flag")
+    private String xnhFlag;
+
+    /**
+     * buyPrice
+     */
+    @TableField(value = "buy_price")
+    private Double buyPrice;
+
+    /**
+     * selfFlagYb
+     */
+    @TableField(value = "self_flag_yb")
+    private String selfFlagYb;
+
+    /**
+     * orderDosage
+     */
+    @TableField(value = "order_dosage")
+    private Double orderDosage;
+
+    /**
+     * dosageUnit
+     */
+    @TableField(value = "dosage_unit")
+    private String dosageUnit;
+
+    /**
+     * ybComment
+     */
+    @TableField(value = "yb_comment")
+    private String ybComment;
+
+    /**
+     * jbFlag
+     */
+    @TableField(value = "jb_flag")
+    private String jbFlag;
+
+    /**
+     * location
+     */
+    @TableField(value = "location")
+    private String location;
+
+    /**
+     * zsFlag
+     */
+    @TableField(value = "zs_flag")
+    private String zsFlag;
+
+    /**
+     * auditCode
+     */
+    @TableField(value = "audit_code")
+    private String auditCode;
+
+    /**
+     * comment
+     */
+    @TableField(value = "comment")
+    private String comment;
+
+    /**
+     * categoriesFlag
+     */
+    @TableField(value = "categories_flag")
+    private String categoriesFlag;
+
+    /**
+     * fatherFlag
+     */
+    @TableField(value = "father_flag")
+    private String fatherFlag;
+
+    /**
+     * ybxjPrice
+     */
+    @TableField(value = "ybxj_price")
+    private Double ybxjPrice;
+
+    /**
+     * ymFlag
+     */
+    @TableField(value = "ym_flag")
+    private String ymFlag;
+
+    /**
+     * dpymFlag
+     */
+    @TableField(value = "dpym_flag")
+    private String dpymFlag;
+
+    /**
+     * ybComment2
+     */
+    @TableField(value = "yb_comment2")
+    private String ybComment2;
+
+    /**
+     * ybCode2
+     */
+    @TableField(value = "yb_code2")
+    private String ybCode2;
+
+    /**
+     * kjywFlag
+     */
+    @TableField(value = "kjyw_flag")
+    private String kjywFlag;
+
+    /**
+     * ygyyjcType
+     */
+    @TableField(value = "ygyyjc_type")
+    private String ygyyjcType;
+
+    /**
+     * dddValue
+     */
+    @TableField(value = "ddd_value")
+    private Double dddValue;
+
+    /**
+     * kjLimitFlag
+     */
+    @TableField(value = "kj_limit_flag")
+    private String kjLimitFlag;
+
+    /**
+     * ypId
+     */
+    @TableField(value = "yp_id")
+    private String ypId;
+
+    /**
+     * xtppName
+     */
+    @TableField(value = "xtpp_name")
+    private String xtppName;
+
+    /**
+     * spName
+     */
+    @TableField(value = "sp_name")
+    private String spName;
+
+    /**
+     * qjFlag
+     */
+    @TableField(value = "qj_flag")
+    private String qjFlag;
+
+    /**
+     * jsFlag
+     */
+    @TableField(value = "js_flag")
+    private String jsFlag;
+
+    /**
+     * pzwh
+     */
+    @TableField(value = "pzwh")
+    private String pzwh;
+
+    /**
+     * xnhCode
+     */
+    @TableField(value = "xnh_code")
+    private String xnhCode;
+
+    /**
+     * xnhName
+     */
+    @TableField(value = "xnh_name")
+    private String xnhName;
+
+    /**
+     * xnhRatio
+     */
+    @TableField(value = "xnh_ratio")
+    private Double xnhRatio;
+
+    /**
+     * xnhQuotamoney
+     */
+    @TableField(value = "xnh_quotamoney")
+    private Double xnhQuotamoney;
+
+    /**
+     * xnhStatus
+     */
+    @TableField(value = "xnh_status")
+    private String xnhStatus;
+
+    /**
+     * xnhBl
+     */
+    @TableField(value = "xnh_bl")
+    private String xnhBl;
+
+    /**
+     * cityBl
+     */
+    @TableField(value = "city_bl")
+    private String cityBl;
+
+    /**
+     * sybBl
+     */
+    @TableField(value = "syb_bl")
+    private String sybBl;
+
+    /**
+     * clFlag
+     */
+    @TableField(value = "cl_flag")
+    private String clFlag;
+
+    /**
+     * avgPrice
+     */
+    @TableField(value = "avg_price")
+    private Double avgPrice;
+
+    /**
+     * ybFlagCity
+     */
+    @TableField(value = "yb_flag_city")
+    private String ybFlagCity;
+
+    /**
+     * ybFlagXnh
+     */
+    @TableField(value = "yb_flag_xnh")
+    private String ybFlagXnh;
+
+    /**
+     * ybCodeCity
+     */
+    @TableField(value = "yb_code_city")
+    private String ybCodeCity;
+
+    /**
+     * ybCodeXnh
+     */
+    @TableField(value = "yb_code_xnh")
+    private String ybCodeXnh;
+
+    /**
+     * ybCommentCity
+     */
+    @TableField(value = "yb_comment_city")
+    private String ybCommentCity;
+
+    /**
+     * ybCommentXnh
+     */
+    @TableField(value = "yb_comment_xnh")
+    private String ybCommentXnh;
+
+    /**
+     * dddUnit
+     */
+    @TableField(value = "ddd_unit")
+    private Double dddUnit;
+
+    /**
+     * wgType
+     */
+    @TableField(value = "wg_type")
+    private String wgType;
+
+    /**
+     * fhName
+     */
+    @TableField(value = "fh_name")
+    private String fhName;
+
+    /**
+     * ybFlagNew
+     */
+    @TableField(value = "yb_flag_new")
+    private String ybFlagNew;
+
+    /**
+     * ybCommentNew
+     */
+    @TableField(value = "yb_comment_new")
+    private String ybCommentNew;
+
+    /**
+     * ybBlNew
+     */
+    @TableField(value = "yb_bl_new")
+    private String ybBlNew;
+
+    /**
+     * wjwYpid
+     */
+    @TableField(value = "wjw_ypid")
+    private String wjwYpid;
+
+    /**
+     * yjjYpid
+     */
+    @TableField(value = "yjj_ypid")
+    private String yjjYpid;
+
+    /**
+     * rsbYpid
+     */
+    @TableField(value = "rsb_ypid")
+    private String rsbYpid;
+
+    /**
+     * mzRestrict
+     */
+    @TableField(value = "mz_restrict")
+    private Integer mzRestrict;
+
+    /**
+     * byjFlag
+     */
+    @TableField(value = "byj_flag")
+    private String byjFlag;
+
+    /**
+     * nationalCode
+     */
+    @TableField(value = "national_code")
+    private String nationalCode;
+
+    /**
+     * nationalName
+     */
+    @TableField(value = "national_name")
+    private String nationalName;
+
+    /**
+     * nationalStatus
+     */
+    @TableField(value = "national_status")
+    private Integer nationalStatus;
+
+    /**
+     * matchOper
+     */
+    @TableField(value = "match_oper")
+    private String matchOper;
+
+    /**
+     * matchDate
+     */
+    @TableField(value = "match_date")
+    private Date matchDate;
+
+    /**
+     * cancelMatchOper
+     */
+    @TableField(value = "cancel_match_oper")
+    private String cancelMatchOper;
+
+    /**
+     * cancelMatchDate
+     */
+    @TableField(value = "cancel_match_date")
+    private Date cancelMatchDate;
+
+    /**
+     * newName
+     */
+    @TableField(value = "new_name")
+    private String newName;
+
+    /**
+     * operId
+     */
+    @TableField(value = "oper_id")
+    private String operId;
+
+    /**
+     * operDate
+     */
+    @TableField(value = "oper_date")
+    private Date operDate;
+
+    /**
+     * uploadedFlag
+     */
+    @TableField(value = "uploaded_flag")
+    private Integer uploadedFlag;
+
+    /**
+     * 处方限制天数
+     */
+    @TableField(value = "prescription_limit_days")
+    private Integer prescriptionLimitDays;
+
+    /**
+     * 是辅助用药
+     */
+    @TableField(value = "fz_flag")
+    private Integer fzFlag;
+
+    /**
+     * 是否统一采购 1是
+     */
+    @TableField(value = "is_central_purchase")
+    private Integer isCentralPurchase;
+
+    /**
+     * 药品采购编码
+     */
+    @TableField(value = "purchase_code")
+    private String purchaseCode;
+
+    /**
+     * 药管平台码
+     */
+    @TableField(value = "drug_control_code")
+    private String drugControlCode;
+
+    /**
+     * selfpayProp
+     */
+    @TableField(value = "selfpay_prop")
+    private String selfpayProp;
+
+    /**
+     * unit
+     */
+    @TableField(value = "unit")
+    private String unit;
+
+    /**
+     * 工伤目录匹配状态
+     */
+    @TableField(value = "injury_match_status")
+    private Integer injuryMatchStatus;
+
+    /**
+     * 社保三大目录(工伤)
+     */
+    @TableField(value = "aaz231")
+    private String aaz231;
+
+    /**
+     * 社保三大目录编码(工伤)
+     */
+    @TableField(value = "ake001")
+    private String ake001;
+
+    /**
+     * 社保三大目录名称(工伤)
+     */
+    @TableField(value = "ake002")
+    private String ake002;
+
+    /**
+     * 三大目录类别(工伤)
+     */
+    @TableField(value = "ake003")
+    private String ake003;
+
+    /**
+     * 自付比例类型(工伤)(A000_100 自付   A000_00 工伤保险基金支付)
+     */
+    @TableField(value = "bke215")
+    private String bke215;
+
+    /**
+     * 工伤匹配人
+     */
+    @TableField(value = "injury_match_oper")
+    private String injuryMatchOper;
+
+    /**
+     * 工伤匹配时间
+     */
+    @TableField(value = "injury_match_datetime")
+    private Date injuryMatchDatetime;
+
+    /**
+     * cancelInjuryMatchOper
+     */
+    @TableField(value = "cancel_injury_match_oper")
+    private String cancelInjuryMatchOper;
+
+    /**
+     * injuryUploadFlag
+     */
+    @TableField(value = "injury_upload_flag")
+    private Integer injuryUploadFlag;
+
+    /**
+     * 医疗机构三大目录匹配申请明细id
+     */
+    @TableField(value = "aaz278")
+    private String aaz278;
+
+    /**
+     * antitumorLevel
+     */
+    @TableField(value = "antitumor_level")
+    private Integer antitumorLevel;
+
+}

+ 3 - 3
src/main/java/thyyxxk/webserver/service/PublicServer.java

@@ -136,12 +136,12 @@ public class PublicServer {
     }
 
     public Boolean getaBoolean(int[] jueSeBianMa, List<Integer> roleCode) {
-        if (ListUtil.isBlank(roleCode)) {
-            return true;
-        }
         if (roleCode.contains(1)) {
             return false;
         }
+        if (ListUtil.isBlank(roleCode)) {
+            return true;
+        }
         for (Integer i : jueSeBianMa) {
             if (roleCode.contains(i)) {
                 return false;

+ 270 - 0
src/main/java/thyyxxk/webserver/service/hospitalizationCosts/HospitalizationCostsService.java

@@ -0,0 +1,270 @@
+package thyyxxk.webserver.service.hospitalizationCosts;
+
+import cn.hutool.core.util.ObjectUtil;
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import thyyxxk.webserver.config.exception.BizException;
+import thyyxxk.webserver.config.exception.ExceptionEnum;
+import thyyxxk.webserver.dao.his.hospitalizationCosts.HospitalizationCostsDao;
+import thyyxxk.webserver.dao.his.inpatient.XiangMuLuRuDao;
+import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.entity.hospitalizationCosts.ZyDetailChargeTable;
+import thyyxxk.webserver.entity.hospitalizationCosts.ZyDetailRefundParam;
+import thyyxxk.webserver.entity.inpatient.ZyActpatient;
+import thyyxxk.webserver.entity.login.UserInfo;
+import thyyxxk.webserver.service.PublicServer;
+import thyyxxk.webserver.service.redislike.RedisLikeService;
+import thyyxxk.webserver.utils.*;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Set;
+
+@Service
+@Slf4j
+public class HospitalizationCostsService {
+    private final HospitalizationCostsDao dao;
+    private final RedisLikeService redisLikeService;
+    private final XiangMuLuRuDao luRuDao;
+    private final PublicServer publicServer;
+
+    @Data
+    public static class OrderInfo {
+        private String classCode;
+        private String drugClass;
+        private String miniUnit;
+    }
+
+    public HospitalizationCostsService(HospitalizationCostsDao dao, RedisLikeService redisLikeService, XiangMuLuRuDao luRuDao, PublicServer publicServer) {
+        this.dao = dao;
+        this.redisLikeService = redisLikeService;
+        this.luRuDao = luRuDao;
+        this.publicServer = publicServer;
+    }
+
+    public ResultVo<String> refund(ZyDetailRefundParam param) {
+        log.info("退费数组: {}", JSON.toJSONString(param));
+        UserInfo userInfo = redisLikeService.getUserInfoByToken();
+        if (userInfo == null) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "退费人员信息不存在,请重新登录。");
+        }
+        // 婴儿标志
+        int infantFlag = PublicServer.getInfantFlag(param.getInpatientNo());
+        if (infantFlag == 1) {
+            param.setInpatientNo(param.getInpatientNo().split("\\$")[0]);
+        }
+
+        preCheck(param, userInfo);
+
+        // 获取 患者的账页号
+        Integer ledgerSn = publicServer.getLedgerSn(param.getInpatientNo(), param.getAdmissTimes());
+        // 查询原来的数据
+        QueryWrapper<ZyDetailChargeTable> qw = new QueryWrapper<>();
+        qw.eq("inpatient_no", param.getInpatientNo())
+                .eq("admiss_times", param.getAdmissTimes())
+                .eq("ledger_sn", ledgerSn)
+                .in("detail_sn", param.getDetailSn());
+
+        List<ZyDetailChargeTable> tables = dao.selectList(qw);
+
+        // 获取患者自己的科室和下面的子科室
+        Set<String> deptList;
+
+        if (userInfo.getDeptCode().startsWith("8")) {
+            deptList = luRuDao.chaXunZhiZXinKeShi(userInfo.getDeptCode());
+            deptList.add(userInfo.getDeptCode());
+        } else {
+            deptList = publicServer.getChildDeptByUserCode();
+        }
+        // 需要生成退药单
+        List<ZyDetailChargeTable> generateAReturnOrder = new ArrayList<>();
+        // 只退费
+        List<ZyDetailChargeTable> refundOnly = new ArrayList<>();
+        // 医技录入的药品退费
+        List<ZyDetailChargeTable> medicalTechnologyDrugReturnForm = new ArrayList<>();
+
+        // 是否是毒麻药品
+        CacheOnce<Integer> drugKind = new CacheOnce<>();
+        // 药品的详细信息
+        CacheOnce<OrderInfo> orderCacheOnce = new CacheOnce<>();
+
+        // 患者最大的 detail_sn
+        int maxDetailSn = publicServer.getMaxDetailSn(param.getInpatientNo(), param.getAdmissTimes());
+
+        StringBuilder error = new StringBuilder();
+
+        for (ZyDetailChargeTable item : tables) {
+            maxDetailSn += 1;
+
+            StringBuilder sb = new StringBuilder();
+            if (StringUtil.isBlank(item.getSerial())) {
+                item.setSerial("00");
+            }
+            // -3 退药申请,拒绝退药申请是可以重新申请的
+            if (item.getOriDetailSn() != null && item.getOriDetailSn().equals(-3)) {
+                item.setOriDetailSn(null);
+            }
+            if (item.getOriDetailSn() != null && item.getOriDetailSn().equals(-2)) {
+                sb.append("该药品在申请退药。");
+            }
+            if (item.getOriDetailSn() != null) {
+                sb.append("该数据为退费数据。");
+            }
+            if (BigUtils.bigXiaoYu(item.getChargeFee(), 0) || BigUtils.bigXiaoYu(item.getChargeAmount(), 0)) {
+                sb.append("该数据为负数。");
+            }
+            if (StringUtil.isBlank(item.getExecUnit())) {
+                item.setExecUnit(userInfo.getDeptCode());
+            }
+            if ("BILL02".equals(item.getChargeCode())) {
+                sb.append("中药无法退费。");
+            }
+            String orderNo = item.getOrderNo() == null ?
+                    "" : item.getOrderNo().stripTrailingZeros().toPlainString();
+            // 项目判断
+            if ("00".equals(item.getSerial())) {
+                if (publicServer.noNeedRule() && !deptList.contains(item.getExecUnit())) {
+                    sb.append("请对应的执行科室进行退费。");
+                }
+                // 只退费设置
+                refundOnly.add(设置默认值以及自增(item, maxDetailSn, -1));
+            } else {
+                // 药品判断
+                // 医技科室录入的费用
+                if ("3".equals(orderNo)) {
+                    if (!deptList.contains(item.getExecUnit())) {
+                        sb.append("此药品为医技科室录入,请对应的医技科室退费。");
+                    }
+                    refundOnly.add(设置默认值以及自增(item, maxDetailSn, -1));
+                    medicalTechnologyDrugReturnForm.add(设置默认值以及自增(item, maxDetailSn, -1));
+                } else {
+                    // 仅退费不退药品
+                    if ("refundOnly".equals(param.getRefundFlag())) {
+                        refundOnly.add(设置默认值以及自增(item, maxDetailSn, -1));
+                    } else {
+                        // 退费又退药.不需要向refundOnly中添加数据,且oriDetailSn 要设置为 -2 代表申请退费
+                        generateAReturnOrder.add(设置默认值以及自增(item, maxDetailSn, -2));
+                    }
+
+                    OrderInfo order = orderCacheOnce.get(orderNo, (key) -> dao.selectDrugClassByOrderNo(new BigDecimal(orderNo)));
+
+                    if (order == null) {
+                        sb.append("没有查询到原药品对应的医嘱");
+                    } else {
+                        // 口服药无法退费 包装规格是 09,盒,15,瓶 的可以退费
+                        if ("1".equals(order.getClassCode())) {
+                            if (!(order.getMiniUnit().equals("09") || order.getMiniUnit().equals("15"))) {
+                                sb.append("原因原医嘱的给药方式为口服药,口服无法退费。");
+                            }
+                        }
+                        if ("d".equals(order.getDrugClass())) {
+                            order.setDrugClass("j");
+                        }
+                        // 医嘱表中会有 z 所以把所有 z 的换成 j
+                        item.setDrugClass("z".equals(order.getDrugClass()) ? "j" : order.getDrugClass());
+                    }
+                }
+                Integer count = drugKind.get(item.getChargeCodeMx().trim() + "_" + item.getSerial().trim(), (key) -> dao.getDrugKing(item.getChargeCodeMx().trim(), item.getSerial().trim()));
+                if (count > 0 && "refundOnly".equals(param.getRefundFlag())) {
+                    sb.append("药剂科要求,毒麻药药品无法,仅退费不退药品,请选择退费且退药。");
+                }
+            }
+            if (StringUtil.notBlank(sb.toString())) {
+                error.append("流水号:【").append(item.getDetailSn()).append("】").append(sb).append("<br />");
+            }
+        }
+        // 循环结束
+        if (StringUtil.notBlank(error.toString())) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_HTML_ERROR, error.toString());
+        }
+        ZyActpatient patientInfo = publicServer.huoQuHuanZheXinXi(param.getInpatientNo());
+        // 需要生成退药单
+        if (ListUtil.notBlank(generateAReturnOrder)) {
+            // 插入退费数据
+            dao.detailsOfDrugReturnForm(generateAReturnOrder,
+                    patientInfo.getInpatientNo(),
+                    patientInfo.getAdmissTimes(),
+                    patientInfo.getName(),
+                    patientInfo.getBedNo(),
+                    userInfo.getDeptCode(),
+                    infantFlag,
+                    param.getGroupNo(),
+                    TokenUtil.getTokenUserId(),
+                    ledgerSn);
+        }
+
+        // 直接退费
+        if (ListUtil.notBlank(refundOnly)) {
+            // 插入退费数据
+            dao.insertRefundData(refundOnly);
+        }
+        // 医技科室退费数据
+        if (ListUtil.notBlank(medicalTechnologyDrugReturnForm)) {
+            dao.shenQingYaoPing(patientInfo, medicalTechnologyDrugReturnForm, infantFlag, ledgerSn, userInfo.getCode());
+        }
+
+        dao.updateOriFlag(tables);
+
+        return ResultVoUtil.success();
+    }
+
+    /**
+     * 退费前置校验
+     *
+     * @param param    参数
+     * @param userInfo 用户信息
+     */
+    private void preCheck(ZyDetailRefundParam param, UserInfo userInfo) {
+        if (!userInfo.getRoles().contains(36) && !userInfo.getRoles().contains(1)) {
+            throw new BizException(ExceptionEnum.LOGICAL_ERROR, "您没有权限退费。");
+        }
+        if (param.getList() == null || param.getList().isEmpty()) {
+            throw new BizException(ExceptionEnum.LOGICAL_ERROR, "请先选择需要退费的数据,一次性退费不得超过100条");
+        } else if (param.getList().size() > 100) {
+            throw new BizException(ExceptionEnum.LOGICAL_ERROR, "项目退费一次性大于100条数据");
+        }
+        if (StringUtil.isBlank(param.getInpatientNo()) || param.getAdmissTimes() == null || param.getList().size() == 0) {
+            throw new BizException(ExceptionEnum.NULL_POINTER, "患者信息不全");
+        }
+        if (luRuDao.getHuanZheSFZaiYuan(param.getInpatientNo(), param.getAdmissTimes()) == 0) {
+            throw new BizException(ExceptionEnum.LOGICAL_ERROR, "该患者已出院");
+        }
+        Integer settlementFlag = luRuDao.getHuanZheSFJieSuan(param.getInpatientNo(), param.getAdmissTimes());
+
+        if (settlementFlag == null || settlementFlag != 0) {
+            throw new BizException(ExceptionEnum.LOGICAL_ERROR, "该患者已经结算了");
+        }
+
+    }
+
+    public ZyDetailChargeTable 设置默认值以及自增(ZyDetailChargeTable item, int maxDetailSn, int oriDetailSn) {
+        String userCode = TokenUtil.getTokenUserId();
+        // 克隆一下 item 的数据
+        ZyDetailChargeTable clone = EntityCopy.Copy(item, ZyDetailChargeTable.class);
+        // 取负数的费用
+        clone.setChargeFee(item.getChargeFee().negate());
+        clone.setChargeAmount(item.getChargeAmount().negate());
+        // 执行人
+        clone.setOpIdCode(userCode);
+        clone.setConfirmId(userCode);
+        clone.setOriDetailSn(item.getDetailSn());
+        Date now = new Date();
+        clone.setGenTime(now);
+        clone.setChargeDate(now);
+        // 设置原来的流水号
+        clone.setOriDetailSn(item.getDetailSn());
+        // 设置新的流水号
+        clone.setDetailSn(maxDetailSn);
+        // 这个是唯一要改变的东西
+        item.setOriDetailSn(oriDetailSn);
+
+        return clone;
+    }
+
+
+}

+ 6 - 1
src/main/java/thyyxxk/webserver/service/inpatient/XiangMuLuRuService.java

@@ -281,10 +281,16 @@ public class XiangMuLuRuService {
                 }
             }
         }
+
         // 护士退药单
         if (ListUtil.notBlank(drug)) {
             for (ZyDetailCharge item : drug) {
                 ZyDetailCharge a = dao.selectDrugClassByOrderNo(item.getOrderNo());
+                if ("refundOnly".equals(param.getRefundFlag())) {
+                    if (dao.getDrugKing(item.getChargeCodeMx(), item.getSerial()) > 0) {
+                        return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("流水号:【%s】,药品无法退费,毒麻药药品无法仅退费不退药品,编码为:【%s】。", item.getDetailSn(), item.getChargeCodeMx()));
+                    }
+                }
                 if (a == null) {
                     return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("流水号:【%s】,药品无法退费,原因没有查询到原药品对应的医嘱,编码为:【%s】。", item.getDetailSn(), item.getChargeCodeMx()));
                 } else {
@@ -300,7 +306,6 @@ public class XiangMuLuRuService {
                     // 医嘱表中会有 z 所以把所有 z 的换成 j
                     item.setDrugClass("z".equals(a.getDrugClass()) ? "j" : a.getDrugClass());
                 }
-
             }
 
             ZyActpatient patientInfo = publicServer.huoQuHuanZheXinXi(param.getInpatientNo());

+ 4 - 0
src/main/java/thyyxxk/webserver/utils/ListUtil.java

@@ -29,4 +29,8 @@ public class ListUtil {
         }
     }
 
+    public static <T> void partitionAndFunc(List<T> list, Consumer<List<T>> a) {
+        partitionAndFunc(list, 20, a);
+    }
+
 }

+ 1 - 1
src/main/resources/application.yml

@@ -8,7 +8,7 @@ spring:
     cache: false
   datasource:
     dynamic:
-      primary: his
+      primary: dev
       strict: false
       datasource:
         his: