Browse Source

易诊通修改

xdd 1 week ago
parent
commit
d26f9252f6

+ 21 - 4
fs-service/src/main/java/com/fs/erp/service/impl/HzOMSErpOrderServiceImpl.java

@@ -13,8 +13,11 @@ import com.fs.erp.service.IErpOrderService;
 import com.fs.his.domain.*;
 import com.fs.his.service.*;
 import com.fs.his.utils.PhoneUtil;
+import io.jsonwebtoken.lang.Assert;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.http.util.Asserts;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Primary;
 import org.springframework.stereotype.Service;
 
@@ -50,6 +53,9 @@ public class HzOMSErpOrderServiceImpl implements IErpOrderService {
     @Autowired
     HzOMSClient hzOMSClient;
 
+    @Value("${erp.hzOmsErpShopCode}")
+    private String hzOmsErpShopCode = "8080";
+
     @Override
     public ErpOrderResponse addOrder(ErpOrder order) {
         try {
@@ -57,7 +63,14 @@ public class HzOMSErpOrderServiceImpl implements IErpOrderService {
 
             JSONObject omsOpenPtorderCreate = hzOMSClient.send("oms_open_ptorder_create", hzOrder);
             ErpOrderResponse res = new ErpOrderResponse();
-            res.setCode(order.getPlatform_code());
+
+            if("200".equals(omsOpenPtorderCreate.getString("code"))){
+                res.setCode(order.getPlatform_code());
+                res.setSuccess(true);
+            } else {
+                String message = omsOpenPtorderCreate.getString("message");
+                throw new RuntimeException(String.format("推送ERP失败 原因:%s",message));
+            }
             return res;
         } catch (Exception ex) {
             ex.printStackTrace();
@@ -95,7 +108,7 @@ public class HzOMSErpOrderServiceImpl implements IErpOrderService {
 
         JSONObject jsonObject = new JSONObject();
         //平台店铺编码 todo 测试环境只能写死 110111 用于联调测试 fsStoreOrder.getStoreId()
-        jsonObject.put("cptshopcode", 110111);
+        jsonObject.put("cptshopcode", hzOmsErpShopCode);
         //平台订单号
         jsonObject.put("cptordercode", orderCode);
         //平台售后单号
@@ -176,7 +189,7 @@ public class HzOMSErpOrderServiceImpl implements IErpOrderService {
         //订单单号
         obj.put("cptordercode", fsOrder.getOrderCode());
         //平台店铺编码 todo 测试环境只能写死 110111 用于联调测试 fsOrder.getStoreId()
-        obj.put("cptshopcode", 8080);
+        obj.put("cptshopcode", hzOmsErpShopCode);
         //平台店铺名称
         obj.put("cptshopname", fsStore.getStoreName());
         Integer iorderstatus = null;
@@ -254,6 +267,7 @@ public class HzOMSErpOrderServiceImpl implements IErpOrderService {
         //实际送达时间  格式 yyyy-MM-dd hh:mm:ss 如:2025-01-01 00:11:22 f
 //        obj.put("dconfirmtime", "");
         List<FsStoreOrderItem> fsStoreOrderItems = fsStoreOrderItemService.selectFsStoreOrderItemListByOrderId(fsOrder.getOrderId());
+
         int totalOrderItemCount = fsStoreOrderItems.size();
         BigDecimal divide = fsOrder.getDiscountMoney().divide(BigDecimal.valueOf(totalOrderItemCount), 2, BigDecimal.ROUND_HALF_UP);
         JSONArray goodArr = new JSONArray();
@@ -271,10 +285,13 @@ public class HzOMSErpOrderServiceImpl implements IErpOrderService {
             goodItem.put("cptspeccode", fsStoreOrderItem.getProductAttrValueId());
 
             FsStoreProduct fsStoreProduct = fsStoreProductService.selectFsStoreProductById(fsStoreOrderItem.getProductId());
+            Assert.notNull(fsStoreProduct,String.format("当前产品 %d 没有找到", fsStoreOrderItem.getProductId()));
+
             FsStoreProductAttrValue fsStoreProductAttrValue = new FsStoreProductAttrValue();
             //判断是否含有商品规格信息 有则查询商品规格信息 没有取商品的价格
             if (null != fsStoreOrderItem.getProductAttrValueId()) {
                 fsStoreProductAttrValue = fsStoreProductAttrValueService.selectFsStoreProductAttrValueById(fsStoreOrderItem.getProductAttrValueId());
+                Asserts.notNull(fsStoreProductAttrValue,String.format("商品 %d 属性 %d 没有找到",fsStoreOrderItem.getProductId(), fsStoreOrderItem.getProductAttrValueId()));
             } else {
                 fsStoreProductAttrValue.setPrice(fsStoreProduct.getPrice());
             }
@@ -324,7 +341,7 @@ public class HzOMSErpOrderServiceImpl implements IErpOrderService {
 
         JSONObject obj = new JSONObject();
         //平台店铺编码 todo 测试环境只能写死 110111 用于联调测试 fsStoreAfterSales.getStoreId()
-        obj.put("cptshopcode", 110111);
+        obj.put("cptshopcode", hzOmsErpShopCode);
         //平台订单号
         obj.put("cptordercode", orderCode);
         //平台售后单号

+ 13 - 8
fs-service/src/main/java/com/fs/his/domain/FsPrescribe.java

@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fs.common.annotation.Excel;
 import com.fs.common.core.domain.BaseEntity;
 import com.vdurmont.emoji.EmojiParser;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
@@ -16,6 +17,7 @@ import java.util.Date;
  * @author fs
  * @date 2023-06-13
  */
+@Slf4j
 public class FsPrescribe extends BaseEntity
 {
     private static final long serialVersionUID = 1L;
@@ -356,15 +358,18 @@ public class FsPrescribe extends BaseEntity
     {
         return prescribeCode;
     }
-    public void setPatientDescs(String patientJson)
-    {
-        if(StringUtils.isNotEmpty(patientJson)){
-            this.patientDescs= EmojiParser.parseToHtmlDecimal(patientJson);
-        }
-        else{
-            this.patientDescs= patientJson;
+    public void setPatientDescs(String patientJson) {
+        try {
+            if (StringUtils.isNotEmpty(patientJson)) {
+                this.patientDescs = EmojiParser.parseToHtmlDecimal(patientJson);
+            } else {
+                this.patientDescs = patientJson;
+            }
+        } catch (Exception e) {
+            // 记录异常并使用原始值
+            log.error("处理patientDescs时发生错误: {}", patientJson, e);
+            this.patientDescs = patientJson;
         }
-
     }
 
     public String getPatientDescs()

+ 4 - 0
fs-service/src/main/java/com/fs/his/service/impl/FsPackageOrderServiceImpl.java

@@ -465,6 +465,10 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
             return R.error("套餐名已下架");
         }
         FsDoctor doctor=null;
+
+        if(param.getDoctorId() == null) {
+            return R.error("当前产品没有找到对应的医生,请联系管理员!");
+        }
         if(param.getDoctorId()!=null){
             doctor=doctorMapper.selectFsDoctorByDoctorId(param.getDoctorId());
             if(doctor==null||doctor.getStatus().equals(0)){

+ 4 - 0
fs-service/src/main/resources/application-config-druid-yzt.yml

@@ -89,3 +89,7 @@ wx_miniapp_temp:
 mybatis:
   configuration:
     log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+
+
+erp:
+  hzOmsErpShopCode: "8080"