LIJU 2 týždňov pred
rodič
commit
fd7b48b06c

+ 154 - 0
src/main/java/cn/hnthyy/thmz/controller/yf/ZyDrugTracCodgController.java

@@ -0,0 +1,154 @@
+package cn.hnthyy.thmz.controller.yf;
+
+import cn.hnthyy.thmz.comment.UserLoginToken;
+import cn.hnthyy.thmz.entity.his.zy.ZyDrugTracCodg;
+import cn.hnthyy.thmz.entity.thmz.User;
+import cn.hnthyy.thmz.service.his.zy.ZyDrugTracCodgService;
+import cn.hnthyy.thmz.Utils.TokenUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 住院发药追溯码Controller
+ */
+@Slf4j
+@RestController
+@RequestMapping("/zyyp")
+public class ZyDrugTracCodgController {
+    
+    @Autowired
+    private ZyDrugTracCodgService zyDrugTracCodgService;
+    
+    /**
+     * 保存住院发药追溯码数据
+     * @param list 追溯码列表
+     * @param httpServletRequest 请求对象
+     * @return 结果
+     */
+    @UserLoginToken
+    @RequestMapping(value = "/saveZyDrugTracCodgData", method = {RequestMethod.POST})
+    public Map<String, Object> saveZyDrugTracCodgData(@RequestBody List<ZyDrugTracCodg> list, HttpServletRequest httpServletRequest) {
+        Map<String, Object> resultMap = new HashMap<>();
+        try {
+            User tokenUser = TokenUtil.getUser(httpServletRequest);
+            
+            if (list == null || list.isEmpty()) {
+                resultMap.put("code", -1);
+                resultMap.put("message", "保存住院发药追溯码失败,参数为空");
+                return resultMap;
+            }
+            
+            if (StringUtils.isBlank(list.get(0).getInpatientNo())) {
+                resultMap.put("code", -1);
+                resultMap.put("message", "保存住院发药追溯码失败,住院号为空");
+                return resultMap;
+            }
+            
+            if (list.get(0).getAdmissTimes() == null) {
+                resultMap.put("code", -1);
+                resultMap.put("message", "保存住院发药追溯码失败,住院次数为空");
+                return resultMap;
+            }
+            
+            int result = zyDrugTracCodgService.saveZyDrugTracCodgData(list, tokenUser);
+            
+            resultMap.put("code", 0);
+            resultMap.put("message", "保存住院发药追溯码成功");
+            resultMap.put("data", result);
+            return resultMap;
+        } catch (Exception e) {
+            log.error("保存住院发药追溯码失败,错误信息:{}", e.getMessage(), e);
+            resultMap.put("code", -1);
+            resultMap.put("message", "保存住院发药追溯码失败:" + e.getMessage());
+            return resultMap;
+        }
+    }
+    
+    /**
+     * 查询住院发药追溯码数据
+     * @param zyDrugTracCodg 查询条件
+     * @return 结果
+     */
+    @RequestMapping(value = "/getZyDrugTracCodgData", method = {RequestMethod.POST})
+    public Map<String, Object> getZyDrugTracCodgData(@RequestBody ZyDrugTracCodg zyDrugTracCodg) {
+        Map<String, Object> resultMap = new HashMap<>();
+        try {
+            if (zyDrugTracCodg == null) {
+                resultMap.put("code", -1);
+                resultMap.put("message", "查询住院发药追溯码失败,参数为空");
+                return resultMap;
+            }
+            
+            if (StringUtils.isBlank(zyDrugTracCodg.getInpatientNo())) {
+                resultMap.put("code", -1);
+                resultMap.put("message", "查询住院发药追溯码失败,住院号为空");
+                return resultMap;
+            }
+            
+            if (zyDrugTracCodg.getAdmissTimes() == null) {
+                resultMap.put("code", -1);
+                resultMap.put("message", "查询住院发药追溯码失败,住院次数为空");
+                return resultMap;
+            }
+            
+            List<ZyDrugTracCodg> list = zyDrugTracCodgService.getZyDrugTracCodgData(zyDrugTracCodg);
+            
+            resultMap.put("code", 0);
+            resultMap.put("message", "查询住院发药追溯码成功");
+            resultMap.put("data", list);
+            return resultMap;
+        } catch (Exception e) {
+            log.error("查询住院发药追溯码失败,错误信息:{}", e.getMessage(), e);
+            resultMap.put("code", -1);
+            resultMap.put("message", "查询住院发药追溯码失败:" + e.getMessage());
+            return resultMap;
+        }
+    }
+    
+    
+    /**
+     * 验证住院追溯码
+     * @param request 请求参数
+     * @param httpServletRequest 请求对象
+     * @return 结果
+     */
+    @UserLoginToken
+    @RequestMapping(value = "/validateZyDrugTracCodg", method = {RequestMethod.POST})
+    public Map<String, Object> validateZyDrugTracCodg(@RequestBody Map<String, Object> request, HttpServletRequest httpServletRequest) {
+        Map<String, Object> resultMap = new HashMap<>();
+        try {
+            String drugTracCodg = (String) request.get("drugTracCodg");
+            String chargeItemCode = (String) request.get("chargeItemCode");
+            
+            if (StringUtils.isBlank(drugTracCodg) || StringUtils.isBlank(chargeItemCode)) {
+                resultMap.put("code", -1);
+                resultMap.put("message", "追溯码或药品编码不能为空");
+                return resultMap;
+            }
+            
+            boolean isValid = zyDrugTracCodgService.validateZyDrugTracCodg(drugTracCodg, chargeItemCode);
+            
+            if (isValid) {
+                resultMap.put("code", 0);
+                resultMap.put("message", "追溯码验证成功");
+            } else {
+                resultMap.put("code", -1);
+                resultMap.put("message", "追溯码验证失败");
+            }
+            
+            return resultMap;
+        } catch (Exception e) {
+            log.error("验证住院追溯码失败,错误信息:{}", e.getMessage(), e);
+            resultMap.put("code", -1);
+            resultMap.put("message", "验证住院追溯码失败:" + e.getMessage());
+            return resultMap;
+        }
+    }
+} 

+ 154 - 0
src/main/java/cn/hnthyy/thmz/controller/yf/ZyDrugTracCodgTyController.java

@@ -0,0 +1,154 @@
+package cn.hnthyy.thmz.controller.yf;
+
+import cn.hnthyy.thmz.comment.UserLoginToken;
+import cn.hnthyy.thmz.entity.his.zy.ZyDrugTracCodgTy;
+import cn.hnthyy.thmz.entity.thmz.User;
+import cn.hnthyy.thmz.service.his.zy.ZyDrugTracCodgTyService;
+import cn.hnthyy.thmz.Utils.TokenUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 住院退药追溯码Controller
+ */
+@Slf4j
+@RestController
+@RequestMapping("/zyyp")
+public class ZyDrugTracCodgTyController {
+    
+    @Autowired
+    private ZyDrugTracCodgTyService zyDrugTracCodgTyService;
+    
+    /**
+     * 保存住院退药追溯码数据
+     * @param list 追溯码列表
+     * @param httpServletRequest 请求对象
+     * @return 结果
+     */
+    @UserLoginToken
+    @RequestMapping(value = "/saveZyDrugTracCodgTyData", method = {RequestMethod.POST})
+    public Map<String, Object> saveZyDrugTracCodgTyData(@RequestBody List<ZyDrugTracCodgTy> list, HttpServletRequest httpServletRequest) {
+        Map<String, Object> resultMap = new HashMap<>();
+        try {
+            User tokenUser = TokenUtil.getUser(httpServletRequest);
+            
+            if (list == null || list.isEmpty()) {
+                resultMap.put("code", -1);
+                resultMap.put("message", "保存住院退药追溯码失败,参数为空");
+                return resultMap;
+            }
+            
+            if (StringUtils.isBlank(list.get(0).getInpatientNo())) {
+                resultMap.put("code", -1);
+                resultMap.put("message", "保存住院退药追溯码失败,住院号为空");
+                return resultMap;
+            }
+            
+            if (list.get(0).getAdmissTimes() == null) {
+                resultMap.put("code", -1);
+                resultMap.put("message", "保存住院退药追溯码失败,住院次数为空");
+                return resultMap;
+            }
+            
+            int result = zyDrugTracCodgTyService.saveZyDrugTracCodgTyData(list, tokenUser);
+            
+            resultMap.put("code", 0);
+            resultMap.put("message", "保存住院退药追溯码成功");
+            resultMap.put("data", result);
+            return resultMap;
+        } catch (Exception e) {
+            log.error("保存住院退药追溯码失败,错误信息:{}", e.getMessage(), e);
+            resultMap.put("code", -1);
+            resultMap.put("message", "保存住院退药追溯码失败:" + e.getMessage());
+            return resultMap;
+        }
+    }
+    
+    /**
+     * 查询住院退药追溯码数据
+     * @param zyDrugTracCodgTy 查询条件
+     * @return 结果
+     */
+    @RequestMapping(value = "/getZyDrugTracCodgTyData", method = {RequestMethod.POST})
+    public Map<String, Object> getZyDrugTracCodgTyData(@RequestBody ZyDrugTracCodgTy zyDrugTracCodgTy) {
+        Map<String, Object> resultMap = new HashMap<>();
+        try {
+            if (zyDrugTracCodgTy == null) {
+                resultMap.put("code", -1);
+                resultMap.put("message", "查询住院退药追溯码失败,参数为空");
+                return resultMap;
+            }
+            
+            if (StringUtils.isBlank(zyDrugTracCodgTy.getInpatientNo())) {
+                resultMap.put("code", -1);
+                resultMap.put("message", "查询住院退药追溯码失败,住院号为空");
+                return resultMap;
+            }
+            
+            if (zyDrugTracCodgTy.getAdmissTimes() == null) {
+                resultMap.put("code", -1);
+                resultMap.put("message", "查询住院退药追溯码失败,住院次数为空");
+                return resultMap;
+            }
+            
+            List<ZyDrugTracCodgTy> list = zyDrugTracCodgTyService.getZyDrugTracCodgTyData(zyDrugTracCodgTy);
+            
+            resultMap.put("code", 0);
+            resultMap.put("message", "查询住院退药追溯码成功");
+            resultMap.put("data", list);
+            return resultMap;
+        } catch (Exception e) {
+            log.error("查询住院退药追溯码失败,错误信息:{}", e.getMessage(), e);
+            resultMap.put("code", -1);
+            resultMap.put("message", "查询住院退药追溯码失败:" + e.getMessage());
+            return resultMap;
+        }
+    }
+    
+    /**
+     * 验证住院退药追溯码
+     * @param request 请求参数
+     * @param httpServletRequest 请求对象
+     * @return 结果
+     */
+    @UserLoginToken
+    @RequestMapping(value = "/validateZyDrugTracCodgTy", method = {RequestMethod.POST})
+    public Map<String, Object> validateZyDrugTracCodgTy(@RequestBody Map<String, Object> request, HttpServletRequest httpServletRequest) {
+        Map<String, Object> resultMap = new HashMap<>();
+        try {
+            String drugTracCodg = (String) request.get("drugTracCodg");
+            String chargeItemCode = (String) request.get("chargeItemCode");
+            
+            if (StringUtils.isBlank(drugTracCodg) || StringUtils.isBlank(chargeItemCode)) {
+                resultMap.put("code", -1);
+                resultMap.put("message", "追溯码或药品编码不能为空");
+                return resultMap;
+            }
+            
+            boolean isValid = zyDrugTracCodgTyService.validateZyDrugTracCodgTy(drugTracCodg, chargeItemCode);
+            
+            if (isValid) {
+                resultMap.put("code", 0);
+                resultMap.put("message", "退药追溯码验证成功");
+            } else {
+                resultMap.put("code", -1);
+                resultMap.put("message", "退药追溯码验证失败");
+            }
+            
+            return resultMap;
+        } catch (Exception e) {
+            log.error("验证住院退药追溯码失败,错误信息:{}", e.getMessage(), e);
+            resultMap.put("code", -1);
+            resultMap.put("message", "验证住院退药追溯码失败:" + e.getMessage());
+            return resultMap;
+        }
+    }
+} 
+ 

+ 58 - 0
src/main/java/cn/hnthyy/thmz/entity/his/zy/ZyDrugTracCodg.java

@@ -0,0 +1,58 @@
+package cn.hnthyy.thmz.entity.his.zy;
+
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * 住院发药追溯码实体类
+ */
+@Data
+public class ZyDrugTracCodg {
+    
+    // 核心追溯码字段
+    private String drugTracCodg;        // 药品追溯码
+    private String patientId;            // 病人门诊id
+    private Integer times;               // 病人就诊次数
+    private Integer receiptNo;           // 发票分票号
+    private Integer orderNo;             // 处方号
+    private Integer itemNo;              // 项目数
+    private String chargeItemCode;       // 药品编码
+    private String serial;               // 包装大小
+    private String flag;                 // 标志
+    private String groupNo;              // 药房编码
+    
+    // 发药操作字段
+    private String confirmId;            // 发药人id
+    private Date confirmTime;            // 发药时间
+    private String confirmName;          // 发药人姓名
+    
+    // 药品信息字段
+    private Integer realNo;              // 发票流水号
+    private String drugName;             // 品名
+    private String specification;        // 规格
+    private String abbrName;             // 生产厂家
+    private Double unitPrice;            // 单价
+    
+    // 批号和质量追溯字段
+    private String manuNo;               // 批号
+    private String manuDate;             // 生产日期
+    private String expyEnd;              // 有效期至
+    private String matchFlag;            // 匹配标志
+    private String matchMessage;         // 匹配信息/消息
+    
+    // 住院特有字段
+    private String inpatientNo;          // 住院号
+    private Integer admissTimes;         // 住院次数
+    private String zySerialNo;           // 住院流水号
+    private Integer pageNo;              // 页号
+    private String deptCode;             // 科室编码
+    private String wardCode;             // 病区编码
+    private String chargeCode;           // 收费编码
+    private Integer detailSn;            // 明细序号
+    private Integer ledgerSn;            // 台账序号
+    
+    // 时间戳
+    private Date createTime;             // 创建时间
+    private Date updateTime;             // 更新时间
+} 

+ 58 - 0
src/main/java/cn/hnthyy/thmz/entity/his/zy/ZyDrugTracCodgTy.java

@@ -0,0 +1,58 @@
+package cn.hnthyy.thmz.entity.his.zy;
+
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * 住院退药追溯码实体类
+ */
+@Data
+public class ZyDrugTracCodgTy {
+    
+    // 核心追溯码字段
+    private String drugTracCodg;        // 药品追溯码
+    private String patientId;            // 病人门诊id
+    private Integer times;               // 病人就诊次数
+    private Integer receiptNo;           // 发票分票号
+    private Integer orderNo;             // 处方号
+    private Integer itemNo;              // 项目数
+    private String chargeItemCode;       // 药品编码
+    private String serial;               // 包装大小
+    private String flag;                 // 标志
+    private String groupNo;              // 药房编码
+    
+    // 退药操作字段
+    private String refundId;             // 退药人id
+    private Date refundTime;             // 退药时间
+    private String refundName;           // 退药人姓名
+    
+    // 药品信息字段
+    private Integer realNo;              // 发票流水号
+    private String drugName;             // 品名
+    private String specification;        // 规格
+    private String abbrName;             // 生产厂家
+    private Double unitPrice;            // 单价
+    
+    // 批号和质量追溯字段
+    private String manuNo;               // 批号
+    private String manuDate;             // 生产日期
+    private String expyEnd;              // 有效期至
+    private String matchFlag;            // 匹配标志
+    private String matchMessage;         // 匹配信息/消息
+    
+    // 住院特有字段
+    private String inpatientNo;          // 住院号
+    private Integer admissTimes;         // 住院次数
+    private String zySerialNo;           // 住院流水号
+    private Integer pageNo;              // 页号
+    private String deptCode;             // 科室编码
+    private String wardCode;             // 病区编码
+    private String chargeCode;           // 收费编码
+    private Integer detailSn;            // 明细序号
+    private Integer ledgerSn;            // 台账序号
+    
+    // 时间戳
+    private Date createTime;             // 创建时间
+    private Date updateTime;             // 更新时间
+} 

+ 96 - 0
src/main/java/cn/hnthyy/thmz/mapper/his/zy/ZyDrugTracCodgMapper.java

@@ -0,0 +1,96 @@
+package cn.hnthyy.thmz.mapper.his.zy;
+
+import cn.hnthyy.thmz.entity.his.zy.ZyDrugTracCodg;
+import org.apache.ibatis.annotations.Delete;
+import org.apache.ibatis.annotations.Insert;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
+
+/**
+ * 住院发药追溯码Mapper接口
+ */
+@Mapper
+public interface ZyDrugTracCodgMapper {
+    
+    /**
+     * 保存住院发药追溯码数据
+     * @param list 追溯码列表
+     * @return 影响行数
+     */
+    @Insert({
+        "<script>",
+        "insert into zy_drug_trac_codg(drug_trac_codg,patient_id,times,receipt_no,order_no,item_no,charge_item_code,serial,flag,group_no,",
+        "confirm_time,confirm_id,confirm_name,real_no,drug_name,specification,abbr_name,unit_price,manu_no,manu_date,expy_end,match_flag,match_message,",
+        "inpatient_no,admiss_times,zy_serial_no,page_no,dept_code,ward_code,charge_code,detail_sn,ledger_sn,create_time,update_time) values ",
+        "<foreach collection='list' item='item' index='index' separator=','>",
+        " (#{item.drugTracCodg,jdbcType=VARCHAR},#{item.patientId,jdbcType=VARCHAR},#{item.times,jdbcType=INTEGER},#{item.receiptNo,jdbcType=SMALLINT},",
+        "#{item.orderNo,jdbcType=TINYINT},#{item.itemNo,jdbcType=TINYINT},#{item.chargeItemCode,jdbcType=VARCHAR},#{item.serial,jdbcType=VARCHAR},",
+        "#{item.flag,jdbcType=VARCHAR},#{item.groupNo,jdbcType=VARCHAR},#{item.confirmTime,jdbcType=TIMESTAMP},#{item.confirmId,jdbcType=VARCHAR},",
+        "#{item.confirmName,jdbcType=VARCHAR},#{item.realNo,jdbcType=INTEGER},#{item.drugName,jdbcType=VARCHAR},#{item.specification,jdbcType=VARCHAR},",
+        "#{item.abbrName,jdbcType=VARCHAR},#{item.unitPrice,jdbcType=FLOAT},#{item.manuNo,jdbcType=VARCHAR},#{item.manuDate,jdbcType=VARCHAR},",
+        "#{item.expyEnd,jdbcType=VARCHAR},#{item.matchFlag,jdbcType=VARCHAR},#{item.matchMessage,jdbcType=VARCHAR},#{item.inpatientNo,jdbcType=VARCHAR},",
+        "#{item.admissTimes,jdbcType=INTEGER},#{item.zySerialNo,jdbcType=VARCHAR},#{item.pageNo,jdbcType=INTEGER},#{item.deptCode,jdbcType=VARCHAR},",
+        "#{item.wardCode,jdbcType=VARCHAR},#{item.chargeCode,jdbcType=VARCHAR},#{item.detailSn,jdbcType=INTEGER},#{item.ledgerSn,jdbcType=INTEGER},",
+        "#{item.createTime,jdbcType=TIMESTAMP},#{item.updateTime,jdbcType=TIMESTAMP}) ",
+        "</foreach>",
+        "</script>"
+    })
+    int insertZyDrugTracCodgData(@Param("list") List<ZyDrugTracCodg> list);
+    
+    /**
+     * 查询住院发药追溯码数据
+     * @param zyDrugTracCodg 查询条件
+     * @return 追溯码列表
+     */
+    @Select("<script>" +
+            " select * from zy_drug_trac_codg " +
+            "where inpatient_no = #{inpatientNo,jdbcType=VARCHAR} " +
+            "and admiss_times = #{admissTimes,jdbcType=INTEGER} " +
+            "and receipt_no = #{receiptNo,jdbcType=SMALLINT} " +
+            "and order_no = #{orderNo,jdbcType=TINYINT} " +
+            "and group_no = #{groupNo,jdbcType=VARCHAR} " +
+            "<when test='chargeItemCode != null'>" +
+            " and charge_item_code =#{chargeItemCode,jdbcType=VARCHAR}" +
+            "</when>" +
+            "<when test='serial != null'>" +
+            " and serial = #{serial,jdbcType=VARCHAR} " +
+            "</when>" +
+            "<when test='realNo != null'>" +
+            " and real_no =#{realNo,jdbcType=INTEGER}" +
+            "</when>" +
+            "<when test='pageNo != null'>" +
+            " and page_no =#{pageNo,jdbcType=INTEGER}" +
+            "</when>" +
+            "<when test='zySerialNo != null'>" +
+            " and zy_serial_no =#{zySerialNo,jdbcType=VARCHAR}" +
+            "</when>" +
+            "</script>")
+    List<ZyDrugTracCodg> selectZyDrugTracCodgData(ZyDrugTracCodg zyDrugTracCodg);
+    
+    
+    /**
+     * 删除住院发药追溯码数据
+     * @param zyDrugTracCodg 删除条件
+     * @return 影响行数
+     */
+    @Delete("delete from zy_drug_trac_codg " +
+            " where inpatient_no=#{inpatientNo,jdbcType=VARCHAR} " +
+            "   and admiss_times = #{admissTimes,jdbcType=INTEGER} " +
+            "   and receipt_no = #{receiptNo,jdbcType=SMALLINT} " +
+            "   and item_no = #{itemNo,jdbcType=TINYINT} " +
+            "   and charge_item_code = #{chargeItemCode,jdbcType=VARCHAR} " +
+            "   and drug_trac_codg = #{drugTracCodg,jdbcType=VARCHAR}")
+    int deleteZyDrugTracCodgData(ZyDrugTracCodg zyDrugTracCodg);
+    
+    
+    /**
+     * 根据追溯码查询药品信息
+     * @param drugTracCodg 追溯码
+     * @return 药品信息
+     */
+    @Select("select * from zy_drug_trac_codg where drug_trac_codg = #{drugTracCodg,jdbcType=VARCHAR}")
+    ZyDrugTracCodg selectByDrugTracCodg(@Param("drugTracCodg") String drugTracCodg);
+} 

+ 94 - 0
src/main/java/cn/hnthyy/thmz/mapper/his/zy/ZyDrugTracCodgTyMapper.java

@@ -0,0 +1,94 @@
+package cn.hnthyy.thmz.mapper.his.zy;
+
+import cn.hnthyy.thmz.entity.his.zy.ZyDrugTracCodgTy;
+import org.apache.ibatis.annotations.Delete;
+import org.apache.ibatis.annotations.Insert;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
+
+/**
+ * 住院退药追溯码Mapper接口
+ */
+@Mapper
+public interface ZyDrugTracCodgTyMapper {
+    
+    /**
+     * 保存住院退药追溯码数据
+     * @param list 追溯码列表
+     * @return 影响行数
+     */
+    @Insert({
+        "<script>",
+        "insert into zy_drug_trac_codg_ty(drug_trac_codg,patient_id,times,receipt_no,order_no,item_no,charge_item_code,serial,flag,group_no,",
+        "refund_time,refund_id,refund_name,real_no,drug_name,specification,abbr_name,unit_price,manu_no,manu_date,expy_end,match_flag,match_message,",
+        "inpatient_no,admiss_times,zy_serial_no,page_no,dept_code,ward_code,charge_code,detail_sn,ledger_sn,create_time,update_time) values ",
+        "<foreach collection='list' item='item' index='index' separator=','>",
+        " (#{item.drugTracCodg,jdbcType=VARCHAR},#{item.patientId,jdbcType=VARCHAR},#{item.times,jdbcType=INTEGER},#{item.receiptNo,jdbcType=SMALLINT},",
+        "#{item.orderNo,jdbcType=TINYINT},#{item.itemNo,jdbcType=TINYINT},#{item.chargeItemCode,jdbcType=VARCHAR},#{item.serial,jdbcType=VARCHAR},",
+        "#{item.flag,jdbcType=VARCHAR},#{item.groupNo,jdbcType=VARCHAR},#{item.refundTime,jdbcType=TIMESTAMP},#{item.refundId,jdbcType=VARCHAR},",
+        "#{item.refundName,jdbcType=VARCHAR},#{item.realNo,jdbcType=INTEGER},#{item.drugName,jdbcType=VARCHAR},#{item.specification,jdbcType=VARCHAR},",
+        "#{item.abbrName,jdbcType=VARCHAR},#{item.unitPrice,jdbcType=FLOAT},#{item.manuNo,jdbcType=VARCHAR},#{item.manuDate,jdbcType=VARCHAR},",
+        "#{item.expyEnd,jdbcType=VARCHAR},#{item.matchFlag,jdbcType=VARCHAR},#{item.matchMessage,jdbcType=VARCHAR},#{item.inpatientNo,jdbcType=VARCHAR},",
+        "#{item.admissTimes,jdbcType=INTEGER},#{item.zySerialNo,jdbcType=VARCHAR},#{item.pageNo,jdbcType=INTEGER},#{item.deptCode,jdbcType=VARCHAR},",
+        "#{item.wardCode,jdbcType=VARCHAR},#{item.chargeCode,jdbcType=VARCHAR},#{item.detailSn,jdbcType=INTEGER},#{item.ledgerSn,jdbcType=INTEGER},",
+        "#{item.createTime,jdbcType=TIMESTAMP},#{item.updateTime,jdbcType=TIMESTAMP}) ",
+        "</foreach>",
+        "</script>"
+    })
+    int insertZyDrugTracCodgTyData(@Param("list") List<ZyDrugTracCodgTy> list);
+    
+    /**
+     * 查询住院退药追溯码数据
+     * @param zyDrugTracCodgTy 查询条件
+     * @return 追溯码列表
+     */
+    @Select("<script>" +
+            " select * from zy_drug_trac_codg_ty " +
+            "where inpatient_no = #{inpatientNo,jdbcType=VARCHAR} " +
+            "and admiss_times = #{admissTimes,jdbcType=INTEGER} " +
+            "and receipt_no = #{receiptNo,jdbcType=SMALLINT} " +
+            "and order_no = #{orderNo,jdbcType=TINYINT} " +
+            "and group_no = #{groupNo,jdbcType=VARCHAR} " +
+            "<when test='chargeItemCode != null'>" +
+            " and charge_item_code =#{chargeItemCode,jdbcType=VARCHAR}" +
+            "</when>" +
+            "<when test='serial != null'>" +
+            " and serial = #{serial,jdbcType=VARCHAR} " +
+            "</when>" +
+            "<when test='realNo != null'>" +
+            " and real_no =#{realNo,jdbcType=INTEGER}" +
+            "</when>" +
+            "<when test='pageNo != null'>" +
+            " and page_no =#{pageNo,jdbcType=INTEGER}" +
+            "</when>" +
+            "<when test='zySerialNo != null'>" +
+            " and zy_serial_no =#{zySerialNo,jdbcType=VARCHAR}" +
+            "</when>" +
+            "</script>")
+    List<ZyDrugTracCodgTy> selectZyDrugTracCodgTyData(ZyDrugTracCodgTy zyDrugTracCodgTy);
+    
+    /**
+     * 删除住院退药追溯码数据
+     * @param zyDrugTracCodgTy 删除条件
+     * @return 影响行数
+     */
+    @Delete("delete from zy_drug_trac_codg_ty " +
+            " where inpatient_no=#{inpatientNo,jdbcType=VARCHAR} " +
+            "   and admiss_times = #{admissTimes,jdbcType=INTEGER} " +
+            "   and receipt_no = #{receiptNo,jdbcType=SMALLINT} " +
+            "   and item_no = #{itemNo,jdbcType=TINYINT} " +
+            "   and charge_item_code = #{chargeItemCode,jdbcType=VARCHAR} " +
+            "   and drug_trac_codg = #{drugTracCodg,jdbcType=VARCHAR}")
+    int deleteZyDrugTracCodgTyData(ZyDrugTracCodgTy zyDrugTracCodgTy);
+    
+    /**
+     * 根据追溯码查询退药药品信息
+     * @param drugTracCodg 追溯码
+     * @return 药品信息
+     */
+    @Select("select * from zy_drug_trac_codg_ty where drug_trac_codg = #{drugTracCodg,jdbcType=VARCHAR}")
+    ZyDrugTracCodgTy selectByDrugTracCodgTy(@Param("drugTracCodg") String drugTracCodg);
+} 

+ 36 - 0
src/main/java/cn/hnthyy/thmz/service/his/zy/ZyDrugTracCodgService.java

@@ -0,0 +1,36 @@
+package cn.hnthyy.thmz.service.his.zy;
+
+import cn.hnthyy.thmz.entity.his.zy.ZyDrugTracCodg;
+import cn.hnthyy.thmz.entity.thmz.User;
+
+import java.util.List;
+
+/**
+ * 住院发药追溯码Service接口
+ */
+public interface ZyDrugTracCodgService {
+    
+    /**
+     * 保存住院发药追溯码数据
+     * @param list 追溯码列表
+     * @param user 操作用户
+     * @return 影响行数
+     */
+    int saveZyDrugTracCodgData(List<ZyDrugTracCodg> list, User user);
+    
+    /**
+     * 查询住院发药追溯码数据
+     * @param zyDrugTracCodg 查询条件
+     * @return 追溯码列表
+     */
+    List<ZyDrugTracCodg> getZyDrugTracCodgData(ZyDrugTracCodg zyDrugTracCodg);
+    
+    
+    /**
+     * 验证追溯码
+     * @param drugTracCodg 追溯码
+     * @param chargeItemCode 药品编码
+     * @return 验证结果
+     */
+    boolean validateZyDrugTracCodg(String drugTracCodg, String chargeItemCode);
+} 

+ 35 - 0
src/main/java/cn/hnthyy/thmz/service/his/zy/ZyDrugTracCodgTyService.java

@@ -0,0 +1,35 @@
+package cn.hnthyy.thmz.service.his.zy;
+
+import cn.hnthyy.thmz.entity.his.zy.ZyDrugTracCodgTy;
+import cn.hnthyy.thmz.entity.thmz.User;
+
+import java.util.List;
+
+/**
+ * 住院退药追溯码Service接口
+ */
+public interface ZyDrugTracCodgTyService {
+    
+    /**
+     * 保存住院退药追溯码数据
+     * @param list 追溯码列表
+     * @param user 操作用户
+     * @return 影响行数
+     */
+    int saveZyDrugTracCodgTyData(List<ZyDrugTracCodgTy> list, User user);
+    
+    /**
+     * 查询住院退药追溯码数据
+     * @param zyDrugTracCodgTy 查询条件
+     * @return 追溯码列表
+     */
+    List<ZyDrugTracCodgTy> getZyDrugTracCodgTyData(ZyDrugTracCodgTy zyDrugTracCodgTy);
+    
+    /**
+     * 验证退药追溯码
+     * @param drugTracCodg 追溯码
+     * @param chargeItemCode 药品编码
+     * @return 验证结果
+     */
+    boolean validateZyDrugTracCodgTy(String drugTracCodg, String chargeItemCode);
+} 

+ 84 - 0
src/main/java/cn/hnthyy/thmz/service/impl/his/zy/ZyDrugTracCodgServiceImpl.java

@@ -0,0 +1,84 @@
+package cn.hnthyy.thmz.service.impl.his.zy;
+
+import cn.hnthyy.thmz.entity.his.zy.ZyDrugTracCodg;
+import cn.hnthyy.thmz.entity.thmz.User;
+import cn.hnthyy.thmz.mapper.his.zy.ZyDrugTracCodgMapper;
+import cn.hnthyy.thmz.service.his.zy.ZyDrugTracCodgService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 住院发药追溯码Service实现类
+ */
+@Slf4j
+@Service
+public class ZyDrugTracCodgServiceImpl implements ZyDrugTracCodgService {
+    
+    @Autowired
+    private ZyDrugTracCodgMapper zyDrugTracCodgMapper;
+    
+    @Override
+    @Transactional
+    public int saveZyDrugTracCodgData(List<ZyDrugTracCodg> list, User user) {
+        if (list == null || list.isEmpty()) {
+            log.warn("保存住院发药追溯码数据失败,参数为空");
+            return 0;
+        }
+        
+        // 设置操作人信息
+        Date now = new Date();
+        for (ZyDrugTracCodg zyDrugTracCodg : list) {
+            zyDrugTracCodg.setConfirmId(user.getUserCode());
+            zyDrugTracCodg.setConfirmName(user.getUserName());
+            zyDrugTracCodg.setConfirmTime(now);
+            zyDrugTracCodg.setCreateTime(now);
+            zyDrugTracCodg.setUpdateTime(now);
+        }
+        
+        int result = zyDrugTracCodgMapper.insertZyDrugTracCodgData(list);
+        log.info("保存住院发药追溯码数据成功,影响行数:{}", result);
+        return result;
+    }
+    
+    @Override
+    public List<ZyDrugTracCodg> getZyDrugTracCodgData(ZyDrugTracCodg zyDrugTracCodg) {
+        if (zyDrugTracCodg == null) {
+            log.warn("查询住院发药追溯码数据失败,参数为空");
+            return null;
+        }
+        
+        List<ZyDrugTracCodg> result = zyDrugTracCodgMapper.selectZyDrugTracCodgData(zyDrugTracCodg);
+        log.info("查询住院发药追溯码数据成功,结果数量:{}", result != null ? result.size() : 0);
+        return result;
+    }
+    
+    
+    @Override
+    public boolean validateZyDrugTracCodg(String drugTracCodg, String chargeItemCode) {
+        if (drugTracCodg == null || chargeItemCode == null) {
+            log.warn("验证住院追溯码失败,参数为空");
+            return false;
+        }
+        
+        ZyDrugTracCodg result = zyDrugTracCodgMapper.selectByDrugTracCodg(drugTracCodg);
+        if (result == null) {
+            log.warn("追溯码不存在:{}", drugTracCodg);
+            return false;
+        }
+        
+        // 验证药品编码是否匹配
+        if (!chargeItemCode.equals(result.getChargeItemCode())) {
+            log.warn("追溯码与药品编码不匹配,追溯码:{},期望编码:{},实际编码:{}", 
+                    drugTracCodg, chargeItemCode, result.getChargeItemCode());
+            return false;
+        }
+        
+        log.info("追溯码验证成功:{}", drugTracCodg);
+        return true;
+    }
+} 

+ 83 - 0
src/main/java/cn/hnthyy/thmz/service/impl/his/zy/ZyDrugTracCodgTyServiceImpl.java

@@ -0,0 +1,83 @@
+package cn.hnthyy.thmz.service.impl.his.zy;
+
+import cn.hnthyy.thmz.entity.his.zy.ZyDrugTracCodgTy;
+import cn.hnthyy.thmz.entity.thmz.User;
+import cn.hnthyy.thmz.mapper.his.zy.ZyDrugTracCodgTyMapper;
+import cn.hnthyy.thmz.service.his.zy.ZyDrugTracCodgTyService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 住院退药追溯码Service实现类
+ */
+@Slf4j
+@Service
+public class ZyDrugTracCodgTyServiceImpl implements ZyDrugTracCodgTyService {
+    
+    @Autowired
+    private ZyDrugTracCodgTyMapper zyDrugTracCodgTyMapper;
+    
+    @Override
+    @Transactional
+    public int saveZyDrugTracCodgTyData(List<ZyDrugTracCodgTy> list, User user) {
+        if (list == null || list.isEmpty()) {
+            log.warn("保存住院退药追溯码数据失败,参数为空");
+            return 0;
+        }
+        
+        // 设置操作人信息
+        Date now = new Date();
+        for (ZyDrugTracCodgTy zyDrugTracCodgTy : list) {
+            zyDrugTracCodgTy.setRefundId(user.getUserCode());
+            zyDrugTracCodgTy.setRefundName(user.getUserName());
+            zyDrugTracCodgTy.setRefundTime(now);
+            zyDrugTracCodgTy.setCreateTime(now);
+            zyDrugTracCodgTy.setUpdateTime(now);
+        }
+        
+        int result = zyDrugTracCodgTyMapper.insertZyDrugTracCodgTyData(list);
+        log.info("保存住院退药追溯码数据成功,影响行数:{}", result);
+        return result;
+    }
+    
+    @Override
+    public List<ZyDrugTracCodgTy> getZyDrugTracCodgTyData(ZyDrugTracCodgTy zyDrugTracCodgTy) {
+        if (zyDrugTracCodgTy == null) {
+            log.warn("查询住院退药追溯码数据失败,参数为空");
+            return null;
+        }
+        
+        List<ZyDrugTracCodgTy> result = zyDrugTracCodgTyMapper.selectZyDrugTracCodgTyData(zyDrugTracCodgTy);
+        log.info("查询住院退药追溯码数据成功,结果数量:{}", result != null ? result.size() : 0);
+        return result;
+    }
+    
+    @Override
+    public boolean validateZyDrugTracCodgTy(String drugTracCodg, String chargeItemCode) {
+        if (drugTracCodg == null || chargeItemCode == null) {
+            log.warn("验证住院退药追溯码失败,参数为空");
+            return false;
+        }
+        
+        ZyDrugTracCodgTy result = zyDrugTracCodgTyMapper.selectByDrugTracCodgTy(drugTracCodg);
+        if (result == null) {
+            log.warn("退药追溯码不存在:{}", drugTracCodg);
+            return false;
+        }
+        
+        // 验证药品编码是否匹配
+        if (!chargeItemCode.equals(result.getChargeItemCode())) {
+            log.warn("退药追溯码与药品编码不匹配,追溯码:{},期望编码:{},实际编码:{}", 
+                    drugTracCodg, chargeItemCode, result.getChargeItemCode());
+            return false;
+        }
+        
+        log.info("退药追溯码验证成功:{}", drugTracCodg);
+        return true;
+    }
+}