From 3af811456bf5045b79eaad7bb22b6b813c50d9d0 Mon Sep 17 00:00:00 2001
From: zjh <1084500556@qq.com>
Date: 星期二, 05 十一月 2024 08:40:49 +0800
Subject: [PATCH] zjh20241105

---
 ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjSamplingController.java |  132 +++++++++++++++++++++-----------------------
 1 files changed, 63 insertions(+), 69 deletions(-)

diff --git a/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjSamplingController.java b/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjSamplingController.java
index 7172769..70336a9 100644
--- a/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjSamplingController.java
+++ b/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjSamplingController.java
@@ -6,21 +6,28 @@
 import java.util.Map;
 import java.util.stream.Collectors;
 import javax.annotation.Resource;
+import javax.servlet.ServletSecurityElement;
 import javax.servlet.http.HttpServletResponse;
 import javax.swing.plaf.basic.BasicScrollPaneUI;
 
+import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.StrUtil;
+import cn.hutool.extra.pinyin.PinyinUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ltkj.common.core.redis.RedisCache;
+import com.ltkj.common.utils.IdUtils;
 import com.ltkj.framework.config.MatchUtils;
 import com.ltkj.hosp.domain.*;
 import com.ltkj.hosp.service.*;
+import com.ltkj.system.service.ISysConfigService;
 import com.ltkj.web.controller.lis.LisApiMethod;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
+import lombok.extern.slf4j.Slf4j;
 import org.aspectj.weaver.AjAttribute;
+import org.springframework.beans.BeanUtils;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
@@ -39,9 +46,10 @@
  * @author ltkj_璧典匠璞�&鏉庢牸
  * @date 2023-04-11
  */
+@Slf4j
 @RestController
 @RequestMapping("/sampling/sampling")
-@Api(tags = "浣撴閲囨牱绠$悊")
+@Api(tags = "PC绔� 浣撴閲囨牱绠$悊")
 public class TjSamplingController extends BaseController {
     @Resource
     private ITjSamplingService tjSamplingService;
@@ -59,6 +67,10 @@
     private ITbTransitionService tbTransitionService;
     @Autowired
     private LisApiMethod lisApiMethod;
+    @Autowired
+    private ISysConfigService configService;
+    @Autowired
+    private SamplingServiceApi samplingService;
 
     /**
      * 鏌ヨ浣撴閲囨牱绠$悊鍒楄〃
@@ -184,6 +196,7 @@
 
     /**
      * 鑾峰彇閲囨牱瀹㈡埛鍒楄〃
+     *
      * @param isSignFor
      * @param tjNum
      * @param name
@@ -194,20 +207,21 @@
      * @return
      */
     @GetMapping("/getCusList")
+    @ApiOperation(value = "鑾峰彇閲囨牱瀹㈡埛鍒楄〃")
     public AjaxResult getCusList(@RequestParam(defaultValue = "1") @ApiParam(value = "0鏄�1鍚�") Integer isSignFor,
                                  @RequestParam(required = false) @ApiParam(value = "浣撴鍙�") String tjNum,
                                  @RequestParam(required = false) @ApiParam(value = "瀹㈡埛濮撳悕") String name,
                                  @ApiParam(value = "椤电爜鏁�(榛樿1)") @RequestParam(defaultValue = "1") Integer pageNum,
                                  @ApiParam(value = "鏄剧ず鏉℃暟(榛樿10)") @RequestParam(defaultValue = "10") Integer pageSize,
                                  @ApiParam(value = "寮�濮嬫椂闂�") @RequestParam(required = false) String beginTime,
-                                 @ApiParam(value = "缁撴潫鏃堕棿") @RequestParam(required = false) String endTime){
+                                 @ApiParam(value = "缁撴潫鏃堕棿") @RequestParam(required = false) String endTime) {
         Page<TjSampling> samplingPage = new Page<>(pageNum, pageSize);
         LambdaQueryWrapper<TjSampling> wrapper = new LambdaQueryWrapper<>();
-        wrapper.eq(TjSampling::getIsSignFor,isSignFor);
+        wrapper.eq(TjSampling::getIsSignFor, isSignFor);
         if (null != tjNum && StrUtil.isNotBlank(tjNum))
-            wrapper.eq(TjSampling::getTjNum,tjNum);
+            wrapper.eq(TjSampling::getTjNum, tjNum);
         if (null != name && StrUtil.isNotBlank(name))
-            wrapper.eq(TjSampling::getCusName,name);
+            wrapper.eq(TjSampling::getCusName, name);
         if (null != beginTime && null != endTime && StrUtil.isNotBlank(beginTime) && StrUtil.isNotBlank(endTime))
             wrapper.between(TjSampling::getApplicationTime, beginTime, endTime);
         wrapper.groupBy(TjSampling::getCusId);
@@ -217,7 +231,7 @@
         ArrayList<TjCustomer> tjCustomers = new ArrayList<>();
         for (TjSampling tjSampling : list) {
             TjCustomer customer = customerService.getById(tjSampling.getCusId());
-            customer.setCusName(MatchUtils.hideCusName(customer.getCusName()));
+            customer.setCusName(customer.getCusName());
             customer.setCusPhone(MatchUtils.hidePhoneNum(customer.getCusPhone()));
             customer.setCusIdcard(MatchUtils.hideIdCardNum(customer.getCusIdcard()));
             customer.setTjNumber(tjSampling.getTjNum());
@@ -225,40 +239,63 @@
             tjCustomers.add(customer);
         }
         HashMap<String, Object> hashMap = new HashMap<>();
-        hashMap.put("list",tjCustomers);
-        hashMap.put("total",page.getTotal());
+        hashMap.put("list", tjCustomers);
+        hashMap.put("total", page.getTotal());
         return AjaxResult.success(hashMap);
     }
 
     /**
      * 鏍规嵁瀹㈡埛鑾峰彇閲囨牱鍒楄〃
+     *
      * @param cusId
      * @return
      */
     @GetMapping("/getCusCyList")
-    public AjaxResult getCusCyList(@RequestParam @ApiParam(value = "瀹㈡埛id") String cusId){
+    @ApiOperation(value = "鏍规嵁瀹㈡埛鑾峰彇閲囨牱鍒楄〃")
+    public AjaxResult getCusCyList(@RequestParam @ApiParam(value = "瀹㈡埛id") String cusId,
+                                   @RequestParam(defaultValue = "1") @ApiParam(value = "0鏄�1鍚�") Integer isSignFor) {
         if (cusId == null || StrUtil.isBlank(cusId))
-            return AjaxResult.error("鍙傛暟閿欒");
+            return AjaxResult.error("鍙傛暟閿欒,鏈紶鍙傛暟");
         LambdaQueryWrapper<TjSampling> wrapper = new LambdaQueryWrapper<>();
-        wrapper.eq(TjSampling::getCusId,cusId);
+        wrapper.eq(TjSampling::getCusId, cusId);
+        wrapper.eq(TjSampling::getIsSignFor,isSignFor);
+        wrapper.and(i -> i.isNull(TjSampling::getParentId).or().eq(TjSampling::getIsMerge,1));
+        wrapper.orderByDesc(TjSampling::getIsMerge);
         List<TjSampling> list = tjSamplingService.list(wrapper);
-        if (list.isEmpty())
-            return AjaxResult.error("鍙傛暟閿欒");
-        List<TjSampling> projectList = new ArrayList<>();
-        for (TjSampling sampling : list) {
-            sampling.setCusName(MatchUtils.hideCusName(sampling.getCusName()));
-            TjProject project = projectService.getById(sampling.getProId());
-            if (null != project && project.getProParentId() == 0) {
-                projectList.add(sampling);
-            }
+        if (list.isEmpty()){
+            logger.info("cusId鍙傛暟浼犵殑鏄�:"+cusId);
+            return AjaxResult.error("鍙傛暟閿欒,鏈煡璇㈠埌鏁版嵁");
         }
-        return AjaxResult.success(projectList);
+        for (TjSampling sampling : list) {
+            TjCustomer customer = customerService.getById(sampling.getCusId());
+            TjOrder order = orderService.getOrderByTjNum(sampling.getTjNum());
+            if(null !=order)sampling.setCardId(order.getCardId());
+            sampling.setCustomer(customer);
+        }
+        return AjaxResult.success(list);
     }
 
     @PostMapping("/mergeCaiYang")
-    public AjaxResult mergeCaiYang(@RequestBody List<String> ids){
-        return AjaxResult.success();
+    @ApiOperation(value = "閲囨牱鐧昏鍚堝苟椤圭洰鎺ュ彛")
+    public AjaxResult mergeCaiYang(@RequestBody List<String> ids) {
+        return tjSamplingService.mergeCaiYangTran(ids);
     }
+
+
+    @PostMapping("/chexiaoCaiYang")
+    @ApiOperation(value = "鎾ら攢閲囨牱鐧昏鍚堝苟椤圭洰鎺ュ彛")
+    @Transactional
+    public AjaxResult chexiaoCaiYang(@RequestBody List<String> ids) {
+        if (null != ids && !ids.isEmpty()) {
+            int pdsfczhbxm = tjSamplingService.pdsfczhbxm(ids);
+            if (pdsfczhbxm != ids.size()) return AjaxResult.error("瀛樺湪鏈悎骞剁殑椤圭洰涓嶅彲鎾ら攢!!!");
+            tjSamplingService.deletedTjSamplingListByHb(ids);
+            tjSamplingService.updateHeBingXm(ids);
+            return AjaxResult.success("鎾ら攢鎴愬姛!!!");
+        }
+        return AjaxResult.error("璇烽�夋嫨浣犺鎾ら攢鐨勯」鐩�!!!");
+    }
+
 
     /**
      * 瀵煎嚭浣撴閲囨牱绠$悊鍒楄〃
@@ -324,51 +361,8 @@
     @ApiOperation(value = "纭閲囨牱鎺ュ彛")
     @Transactional
     public AjaxResult confirmSampling(@RequestBody List<String> ids) {
-        if (null == ids || ids.size() == 0) {
-            return AjaxResult.error("璇烽�夋嫨瑕佺‘璁ら」");
-        }
-        String tjNumber = "";
-        ArrayList<TjProject> projects = new ArrayList<>();
-        for (String id : ids) {
-            TjSampling sampling = tjSamplingService.getById(id);
-            if (null != sampling) {
-                tjNumber = sampling.getTjNum();
-                sampling.setIsSignFor("0");
-                LambdaQueryWrapper<TjProject> wq = new LambdaQueryWrapper<>();
-                wq.eq(TjProject::getProParentId, sampling.getProId());
-                List<TjProject> projectList = projectService.list(wq);
-                List<String> collect = new ArrayList<>();
-                for (TjProject project : projectList) {
-                    Long proId = project.getProId();
-                    collect.add(String.valueOf(proId));
-                    projects.add(project);
-                }
-                LambdaQueryWrapper<TjSampling> wq1 = new LambdaQueryWrapper<>();
-                wq1.eq(TjSampling::getTjNum, sampling.getTjNum());
-                wq1.in(TjSampling::getProId, collect);
-                List<TjSampling> samplingList = tjSamplingService.list(wq1);
-                if (null != samplingList && samplingList.size() > 0) {
-                    for (TjSampling tjSampling : samplingList) {
-                        tjSampling.setIsSignFor("0");
-                        tjSamplingService.updateById(tjSampling);
-                    }
-                }
-            }
-            if (!tjSamplingService.updateById(sampling)) {
-                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-                return AjaxResult.error("鎿嶄綔澶辫触,璇烽噸璇�");
-            }
-        }
-        if (StrUtil.isNotBlank(tjNumber)){
-            TjOrder order = orderService.getOrderByTjNum(tjNumber);
-            TjCustomer customer = customerService.getById(order.getUserId());
-            List<TbTransition> detailList = tbTransitionService.getTbTransitionListByCusId(String.valueOf(customer.getCusId()),order.getCardId());
-            Boolean save = lisApiMethod.save(order, customer, projects, detailList);
-            if (!save){
-
-            }
-        }
-
-        return AjaxResult.success("鎿嶄綔鎴愬姛");
+        String config = configService.selectConfigByKey("sfkqdyhis");
+        String mergeRequest = configService.selectConfigByKey("use_lis_pacs_is_auto_merge_request");
+        return samplingService.confirm(ids,config,mergeRequest);
     }
 }

--
Gitblit v1.8.0