Prechádzať zdrojové kódy

销售端-手写初诊单,手写信息采集增删改查语句

cgp 2 dní pred
rodič
commit
3fc530c6ad

+ 12 - 0
fs-company/src/main/java/com/fs/company/controller/handwrite/HandwriteCollectionController.java

@@ -3,6 +3,7 @@ package com.fs.company.controller.handwrite;
 import java.util.List;
 import javax.servlet.http.HttpServletResponse;
 
+import com.fs.common.utils.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import com.fs.common.core.controller.BaseController;
@@ -82,4 +83,15 @@ public class HandwriteCollectionController extends BaseController
     {
         return toAjax(handwriteCollectionService.deleteHandwriteCollectionByIds(ids));
     }
+
+    /**
+     * 检测上传的订单号
+     * */
+    @GetMapping("/checkOrderCode/{orderCode}")
+    public AjaxResult checkOrderCode(@PathVariable String orderCode) {
+        if (StringUtils.isBlank(orderCode)){
+            return AjaxResult.error("订单号不能为空");
+        }
+        return handwriteCollectionService.checkOrderCode(orderCode);
+    }
 }

+ 6 - 0
fs-service/src/main/java/com/fs/handwrite/service/IHandwriteCollectionService.java

@@ -1,5 +1,6 @@
 package com.fs.handwrite.service;
 
+import com.fs.common.core.domain.AjaxResult;
 import com.fs.handwrite.domain.HandwriteCollection;
 import java.util.List;
 
@@ -58,4 +59,9 @@ public interface IHandwriteCollectionService
      * @return 结果
      */
     public int deleteHandwriteCollectionById(Integer id);
+
+    /**
+     * 订单号校验
+     * */
+    public AjaxResult checkOrderCode(String orderNo);
 }

+ 35 - 1
fs-service/src/main/java/com/fs/handwrite/service/impl/HandwriteCollectionServiceImpl.java

@@ -1,9 +1,16 @@
 package com.fs.handwrite.service.impl;
 
+import com.fs.common.core.domain.AjaxResult;
+import com.fs.common.exception.CustomException;
 import com.fs.handwrite.domain.HandwriteCollection;
 import com.fs.handwrite.mapper.HandwriteCollectionMapper;
 import com.fs.handwrite.service.IHandwriteCollectionService;
+import com.fs.hisStore.domain.FsStoreOrderScrm;
+import com.fs.hisStore.mapper.FsStoreOrderScrmMapper;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.DuplicateKeyException;
 import org.springframework.stereotype.Service;
 import java.util.Date;
 import java.util.List;
@@ -14,12 +21,16 @@ import java.util.List;
  * @author fs
  * @date 2024-01-01
  */
+@Slf4j
 @Service
 public class HandwriteCollectionServiceImpl implements IHandwriteCollectionService
 {
     @Autowired
     private HandwriteCollectionMapper handwriteCollectionMapper;
 
+    @Autowired
+    private FsStoreOrderScrmMapper storeOrderScrmMapper;
+
     @Override
     public HandwriteCollection selectHandwriteCollectionById(Integer id)
     {
@@ -37,7 +48,11 @@ public class HandwriteCollectionServiceImpl implements IHandwriteCollectionServi
     {
         handwriteCollection.setCreateTime(new Date());
         handwriteCollection.setUpdateTime(new Date());
-        return handwriteCollectionMapper.insertHandwriteCollection(handwriteCollection);
+        try {
+            return handwriteCollectionMapper.insertHandwriteCollection(handwriteCollection);
+        } catch (DuplicateKeyException e) {
+            throw new CustomException("订单号已存在,请勿重复添加");
+        }
     }
 
     @Override
@@ -58,4 +73,23 @@ public class HandwriteCollectionServiceImpl implements IHandwriteCollectionServi
     {
         return handwriteCollectionMapper.deleteHandwriteCollectionById(id);
     }
+
+    @Override
+    public AjaxResult checkOrderCode(String orderCode) {
+        // 首先查询订单表是否存在该订单号
+        FsStoreOrderScrm fsStoreOrderScrm = storeOrderScrmMapper.selectFsStoreOrderByOrderCode(orderCode);
+        if (fsStoreOrderScrm == null) {
+            log.error("商城订单不存在!orderCode:{}", orderCode);
+            return AjaxResult.error("商城订单不存在!");
+        }
+        // 其次查询手写信息采集表中是否已存在此订单号
+        HandwriteCollection queryCondition = new HandwriteCollection();
+        queryCondition.setOrderCode(orderCode);
+        List<HandwriteCollection> handwriteCollections = handwriteCollectionMapper.selectHandwriteCollectionList(queryCondition);
+        if (CollectionUtils.isNotEmpty(handwriteCollections)) {
+            log.error("订单号已上传,请勿重复添加!orderCode:{}", orderCode);
+            return AjaxResult.error("订单号已上传,请勿重复添加!");
+        }
+        return AjaxResult.success();
+    }
 }