LIJU hai 3 meses
pai
achega
009e0bd7af

+ 2 - 2
src/main/java/cn/hnthyy/thmz/controller/mz/MzPharmacyController.java

@@ -816,9 +816,9 @@ public class MzPharmacyController {
             return resultMap;
         } catch (Exception e) {
             e.printStackTrace();
-            log.error("发药处理失败,错误信息{}", e);
+            log.error("发药处理失败,错误信息{}", e.getMessage(), e);
             resultMap.put("code", -1);
-            resultMap.put("message", "发药处理失败");
+            resultMap.put("message", "发药处理失败" + e.getMessage());
             return resultMap;
         }
     }

+ 33 - 4
src/main/java/cn/hnthyy/thmz/service/impl/his/mz/MzDrugTracCodgServiceImpl.java

@@ -12,6 +12,7 @@ import cn.hnthyy.thmz.mapper.his.yp.YpZdDictMapper;
 import cn.hnthyy.thmz.service.his.mz.MzDrugTracCodgService;
 import cn.hnthyy.thmz.vo.MzRefundMedicineVo;
 import cn.hnthyy.thmz.vo.MzSendMedicineVo;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -31,6 +32,7 @@ import java.util.List;
  * @Version 1.0
  * @Description 门诊药品追溯码业务
  **/
+@Slf4j
 @Service
 public class MzDrugTracCodgServiceImpl implements MzDrugTracCodgService {
     @SuppressWarnings("all")
@@ -46,12 +48,24 @@ public class MzDrugTracCodgServiceImpl implements MzDrugTracCodgService {
     @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = Exception.class)
     @Override
     public int saveMzDrugTracCodgData(List<MzDrugTracCodg> list, User user) throws MzException {
+        if (list == null || list.isEmpty()) {
+            log.warn("保存药品追溯码数据失败,参数为空");
+            return 0;
+        }
+        
+        log.info("开始处理追溯码数据,原始列表大小:{}", list.size());
+        
         List<MzDrugTracCodg> l = new ArrayList<>();
         for(MzDrugTracCodg mzDrugTracCodg : list){
             String drugTracCodg = mzDrugTracCodg.getDrugTracCodg();
+            log.info("处理追溯码:{}", drugTracCodg);
+            
             if(StringUtils.isNotBlank(drugTracCodg)){
                 String[] ds = drugTracCodg.split("<br>");
+                log.info("分割后追溯码数组大小:{}", ds.length);
+                
                 for(String sym : ds){
+                    log.info("检查追溯码片段:'{}'", sym);
                     if(StringUtils.isNotBlank(sym)){
                         MzDrugTracCodg drug = new MzDrugTracCodg();
                         BeanUtils.copyProperties(mzDrugTracCodg, drug);
@@ -61,18 +75,32 @@ public class MzDrugTracCodgServiceImpl implements MzDrugTracCodgService {
                         drug.setConfirmId(user.getUserIdCode());
                         drug.setConfirmName(user.getUserName());
                         l.add(drug);
+                        log.info("添加有效追溯码:{}", sym);
                     }
                 }
             }
         }
+        
+        log.info("处理后的追溯码列表大小:{}", l.size());
+        
+        // 检查处理后的列表是否为空
+        if(l.isEmpty()) {
+            log.warn("处理后的追溯码列表为空,跳过保存操作");
+            return 0;
+        }
+        
         // 删除病人该处方之前存的药品追溯码信息
+        log.info("删除之前的追溯码记录,病人ID:{},次数:{},发票号:{},项目号:{}", 
+                list.get(0).getPatientId(), list.get(0).getTimes(), 
+                list.get(0).getReceiptNo(), list.get(0).getItemNo());
+        
         mzDrugTracCodgMapper.deleteMzDrugTracCodg(list.get(0).getPatientId(), list.get(0).getTimes(),
                 list.get(0).getReceiptNo(), list.get(0).getItemNo());
+        
         // 保存病人处方药品追溯码信息
-        if(!l.isEmpty()){
-            return mzDrugTracCodgMapper.insertMzDrugTracCodgData(l);
-        }
-        return 0;
+        int result = mzDrugTracCodgMapper.insertMzDrugTracCodgData(l);
+        log.info("保存追溯码数据完成,影响行数:{}", result);
+        return result;
     }
 
     @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = Exception.class)
@@ -215,3 +243,4 @@ public class MzDrugTracCodgServiceImpl implements MzDrugTracCodgService {
         }
     }
 }
+

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

@@ -47,7 +47,7 @@ spring:
       # jdbc-url: "jdbc:sqlserver://130.150.161.124:1433;databaseName=po"
       # username: "sa"
       # password: "root"
-      # jdbc-url: "jdbc:sqlserver://130.150.161.123:1433;databaseName=hisdb"
+      # jdbc-url: "jdbc:sqlserver://130.150.161.123:1433;databaseName=lijuSql"
       # username: "sa"
       # password: "root"      
       driver-class-name: "com.microsoft.sqlserver.jdbc.SQLServerDriver"

+ 13 - 13
src/main/resources/static/js/mz/west_pharmacy_send.js

@@ -1498,25 +1498,25 @@ function prescriptionDetail(realNo, orderNo, receiptNo, times, patientId, confir
                     
                     // 设置防抖定时器,0.5秒后触发验证
                     inputTimer = setTimeout(function() {
-                        if (inputValue && inputValue.trim().length > 0) {
+                        if (inputValue && inputValue.length > 0) {
                             // 直接按<br>分割,获取所有追溯码
-                            let codes = inputValue.split('<br>').filter(code => code.trim().length > 0);
+                            let codes = inputValue.split('<br>').filter(code => code.length > 0);
                             console.log('分割后的追溯码列表:', codes);
                             
-                            // 检查最后一个追溯码是否为20位
+                            // 检查最后一个追溯码是否为20位或以上
                             if (codes.length > 0) {
                                 let lastCode = codes[codes.length - 1];
                                 console.log('最后一个追溯码:', lastCode);
                                 console.log('最后一个追溯码长度:', lastCode.length);
                                 
-                                if (lastCode.length === 20) {
+                                if (lastCode.length >= 20) {
                                     console.log('防抖触发,准备验证追溯码:', lastCode);
                                     // 验证最后一个完整的追溯码
                                     validateAndAddTracCodg(lastCode, row, $element);
                                 } else {
                                     console.log('最后一个追溯码长度不正确,不进行验证:', lastCode.length);
                                     // 添加报错提示
-                                    errorMesageSimaple('追溯码长度不正确,应为20位,当前为' + lastCode.length + '位');
+                                    errorMesageSimaple('追溯码长度不正确,应为20位或以上,当前为' + lastCode.length + '位');
                                     // 去掉长度不正确的追溯码
                                     codes.pop();
                                     // 重新设置单元格内容
@@ -3127,7 +3127,7 @@ function validateAndAddTracCodg(tracCodg, rowData, $element) {
                 errorMesage(res);
                 // 验证失败时,清理掉无效的追溯码
                 let currentContent = $element.html();
-                let codes = currentContent.split('<br>').filter(code => code.trim().length > 0);
+                let codes = currentContent.split('<br>').filter(code => code.length > 0);
                 
                 // 去掉最后一个追溯码(无效的追溯码)
                 if (codes.length > 0) {
@@ -3155,7 +3155,7 @@ function validateAndAddTracCodg(tracCodg, rowData, $element) {
             errorMesageSimaple("验证请求失败");
             // 错误时也清理掉无效的追溯码
             let currentContent = $element.html();
-            let codes = currentContent.split('<br>').filter(code => code.trim().length > 0);
+            let codes = currentContent.split('<br>').filter(code => code.length > 0);
             
             // 去掉最后一个追溯码(无效的追溯码)
             if (codes.length > 0) {
@@ -3328,11 +3328,11 @@ function callYbSaleGoodsItem(realNo, orderNo, receiptNo, times, patientId, name,
         // 追溯码信息
         let drugtracinfo = []
         // 处理追溯码
-        if (item.drugTracCodg && item.drugTracCodg.trim() !== '') {
-            let tracCodes = item.drugTracCodg.split('<br>').filter(code => code.trim() !== '');
+        if (item.drugTracCodg && item.drugTracCodg !== '') {
+            let tracCodes = item.drugTracCodg.split('<br>').filter(code => code !== '');
             for (let j = 0; j < tracCodes.length; j++) {
                 drugtracinfo.push({
-                    drugTracCodg: tracCodes[j].trim()
+                    drugTracCodg: tracCodes[j]
                 });
             }
         }
@@ -3497,9 +3497,9 @@ function callYbReturnGoodsItem(realNo, orderNo, receiptNo, times, patientId, nam
                     // 将追溯码添加到医保接口参数中
                     for (let k = 0; k < tracRes.data.length; k++) {
                         let tracItem = tracRes.data[k];
-                        if (tracItem.drugTracCodg && tracItem.drugTracCodg.trim() !== '') {
+                        if (tracItem.drugTracCodg && tracItem.drugTracCodg !== '') {
                             ybData.drugtracinfo.push({
-                                drugTracCodg: tracItem.drugTracCodg.trim()
+                                drugTracCodg: tracItem.drugTracCodg
                             });
                         }
                     }
@@ -3585,7 +3585,7 @@ function validateTracCodgQuantity(realNo, orderNo, receiptNo, times, patientId,
         // 计算该药品的追溯码数量
         if (!isEmpty(drug.drugTracCodg)) {
             // 按<br>分割追溯码,过滤空值
-            let tracCodgList = drug.drugTracCodg.split('<br>').filter(code => code.trim().length > 0);
+            let tracCodgList = drug.drugTracCodg.split('<br>').filter(code => code.length > 0);
             tracCodgCount = tracCodgList.length;
         }
         

+ 5 - 5
src/main/resources/static/js/yf/ward_prescription.js

@@ -1127,9 +1127,9 @@ function initDetailTable() {
                 let $cell = $("#" + rowid + "_drugTracCodg");
                 
                 // 如果输入的是追溯码(通常是一串数字或字母组合)
-                if (value && value.trim().length > 0) {
+                if (value && value.length > 0) {
                     // 验证并添加追溯码
-                    validateAndAddTracCodgWard(value.trim(), rowData, $cell);
+                    validateAndAddTracCodgWard(value, rowData, $cell);
                     return false; // 阻止默认的单元格保存行为
                 }
                 return true;
@@ -1212,7 +1212,7 @@ function initDetailTable() {
         // 保存追溯码
         if (tracCodgArrayData.length > 0) {
             request({
-                url: '/thmz/saveDrugTracCodg',
+                url: '/thmz/zyyp/saveZyDrugTracCodgData',
                 method: 'POST',
                 data: JSON.stringify(tracCodgArrayData)
             }).then((res) => {
@@ -2220,7 +2220,7 @@ function validateAndAddTracCodgWard(tracCodg, rowData, $element) {
                 errorMesage(res);
                 // 验证失败时,清理掉无效的追溯码
                 let currentContent = $element.html();
-                let codes = currentContent.split('<br>').filter(code => code.trim().length > 0);
+                let codes = currentContent.split('<br>').filter(code => code.length > 0);
                 
                 // 去掉最后一个追溯码(无效的追溯码)
                 if (codes.length > 0) {
@@ -2248,7 +2248,7 @@ function validateAndAddTracCodgWard(tracCodg, rowData, $element) {
             errorMesageSimaple("验证请求失败");
             // 错误时也清理掉无效的追溯码
             let currentContent = $element.html();
-            let codes = currentContent.split('<br>').filter(code => code.trim().length > 0);
+            let codes = currentContent.split('<br>').filter(code => code.length > 0);
             
             // 去掉最后一个追溯码(无效的追溯码)
             if (codes.length > 0) {

+ 4 - 4
src/main/resources/static/js/yk/drug_storage.js

@@ -505,7 +505,7 @@ $(function () {
                             return item.code;
                         })
                         .filter(function(code) {
-                            return code && code.trim() !== '';
+                            return code && code !== '';
                         });
                     
                     // 将提取的 code 值用换行符连接
@@ -536,7 +536,7 @@ $(function () {
             }
             
             // 合并到现有追溯码中
-            if (currentTraceCodes && currentTraceCodes.trim() !== '') {
+            if (currentTraceCodes && currentTraceCodes !== '') {
                 // 如果已有追溯码,在末尾添加新的
                 $("#drugTracCodgStr").val(currentTraceCodes + '\n' + newTraceCodes);
             } else {
@@ -1315,10 +1315,10 @@ function drugBarStat(){
         let barInfo = str.replaceAll('\n', ',').split(',')
         if(barInfo.length > 0) {
             for(let i in barInfo){
-                if(barInfo[i].length === 20){
+                if(barInfo[i].length >= 20){
                     sum++;
                 } else {
-                    if(barInfo[i] > 0 && barInfo[i].length !== 20){
+                    if(barInfo[i] > 0 && barInfo[i].length < 20){
                         sum++;
                         barFor = true
                         infoErr += barInfo[i] + '\n';