From d00be6eb896fbbb283a8a3ec8eece3796ed1ed9a Mon Sep 17 00:00:00 2001
From: zjh <1084500556@qq.com>
Date: 星期四, 17 十月 2024 14:35:13 +0800
Subject: [PATCH] zjh20241017

---
 ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjSamplingController.java |  131 ++++++++++++++++++++++++++++++++-----------
 1 files changed, 96 insertions(+), 35 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..b8d687d 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,26 @@
 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 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.web.controller.lis.LisApiMethod;
+import com.sun.xml.internal.bind.v2.TODO;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 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;
@@ -41,7 +46,7 @@
  */
 @RestController
 @RequestMapping("/sampling/sampling")
-@Api(tags = "浣撴閲囨牱绠$悊")
+@Api(tags = "PC绔� 浣撴閲囨牱绠$悊")
 public class TjSamplingController extends BaseController {
     @Resource
     private ITjSamplingService tjSamplingService;
@@ -59,6 +64,8 @@
     private ITbTransitionService tbTransitionService;
     @Autowired
     private LisApiMethod lisApiMethod;
+    @Autowired
+    private IdUtils idUtils;
 
     /**
      * 鏌ヨ浣撴閲囨牱绠$悊鍒楄〃
@@ -184,6 +191,7 @@
 
     /**
      * 鑾峰彇閲囨牱瀹㈡埛鍒楄〃
+     *
      * @param isSignFor
      * @param tjNum
      * @param name
@@ -194,20 +202,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);
@@ -225,40 +234,105 @@
             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) {
         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.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) {
+//            sampling.setCusName(MatchUtils.hideCusName(sampling.getCusName()));
+            sampling.setCusName(sampling.getCusName());
+        }
+        return AjaxResult.success(list);
     }
 
     @PostMapping("/mergeCaiYang")
-    public AjaxResult mergeCaiYang(@RequestBody List<String> ids){
-        return AjaxResult.success();
+    @ApiOperation(value = "閲囨牱鐧昏鍚堝苟椤圭洰鎺ュ彛")
+    @Transactional
+    public AjaxResult mergeCaiYang(@RequestBody List<String> ids) {
+        if (null != ids && !ids.isEmpty()) {
+            if(ids.size()==1)return AjaxResult.error("璇烽�夋嫨鑷冲皯涓ゆ潯椤圭洰杩涜鍚堝苟!");
+            int i = tjSamplingService.panduanshifoukeyihebing(ids);
+            if (i > 1) {
+                return AjaxResult.error("鏍囨湰绫诲瀷涓嶄竴鑷�,涓嶅彲鍚堝苟");
+            }
+            int pdsfczhbxm = tjSamplingService.pdsfczhbxm(ids);
+            if (pdsfczhbxm == ids.size()) return AjaxResult.error("澶氫釜鍚堝苟椤圭洰涓嶅彲鍐嶇户缁悎骞�!");
+            if (pdsfczhbxm > 1) return AjaxResult.error("鏈�澶氬厑璁搁�夋嫨涓�涓悎骞惰繃鐨勯」鐩�!");
+            if (pdsfczhbxm == 0) {
+                TjSampling tjSampling = tjSamplingService.getById(ids.get(0));
+                Map<String, Object> map = tjSamplingService.hebingCaiYangInFo(ids);
+                TjSampling sampling = new TjSampling();
+                String proId = map.get("proId").toString();
+                String proName = map.get("proName").toString();
+                BeanUtil.copyProperties(tjSampling, sampling, new String[]{"id"});
+                sampling.setProId(proId);
+                sampling.setProName(proName);
+                sampling.setIsMerge(1);
+                sampling.setJyxh(idUtils.generateLisID());
+                if (tjSamplingService.save(sampling)) {
+                    if (tjSamplingService.updateHeBingXm(ids, sampling.getId())) {
+                        return AjaxResult.success("鍚堝苟椤圭洰鎴愬姛!");
+                    }
+                }
+                return AjaxResult.error("鎿嶄綔澶辫触!");
+            } else {
+                TjSampling tjSampling = tjSamplingService.getTjSamplingByHb(ids);
+                List<TjSampling> samplingList = tjSamplingService.getTjSamplingListByHb(ids);
+                if (null != tjSampling && null != samplingList && !samplingList.isEmpty()) {
+                    List<String> stringList = samplingList.stream().map(TjSampling::getId).collect(Collectors.toList());
+                    Map<String, Object> map = tjSamplingService.hebingCaiYangInFo(stringList);
+                    String proId = map.get("proId").toString();
+                    String proName = map.get("proName").toString();
+                    tjSampling.setProId(proId);
+                    tjSampling.setProName(proName);
+                    if (tjSamplingService.updateById(tjSampling)) {
+                        if (tjSamplingService.updateHeBingXm(stringList, tjSampling.getParentId())) {
+                            return AjaxResult.success("鍚堝苟椤圭洰鎴愬姛!");
+                        }
+                    }
+                }
+                return AjaxResult.error("鎿嶄綔澶辫触!");
+            }
+        }
+        return AjaxResult.error("璇烽�夋嫨浣犺鍚堝苟鐨勯」鐩�!!!");
     }
+
+
+    @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("璇烽�夋嫨浣犺鎾ら攢鐨勯」鐩�!!!");
+    }
+
 
     /**
      * 瀵煎嚭浣撴閲囨牱绠$悊鍒楄〃
@@ -327,12 +401,9 @@
         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());
@@ -341,7 +412,6 @@
                 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());
@@ -357,15 +427,6 @@
             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){
-
             }
         }
 

--
Gitblit v1.8.0