From e9748109d43a3a528667a88edf7da0d7a2f82495 Mon Sep 17 00:00:00 2001
From: zhaowenxuan <chacca165@163.com>
Date: 星期三, 16 十月 2024 15:31:41 +0800
Subject: [PATCH] 增加客户以及客户采样查询接口

---
 ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjSamplingController.java |  119 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 110 insertions(+), 9 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 cad1f50..7172769 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
@@ -9,28 +9,27 @@
 import javax.servlet.http.HttpServletResponse;
 import javax.swing.plaf.basic.BasicScrollPaneUI;
 
+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.framework.config.MatchUtils;
-import com.ltkj.hosp.domain.TbTransition;
-import com.ltkj.hosp.domain.TjCustomer;
-import com.ltkj.hosp.domain.TjProject;
-import com.ltkj.hosp.service.ITjCustomerService;
-import com.ltkj.hosp.service.ITjProjectService;
-import com.ltkj.hosp.service.TjAsyncService;
+import com.ltkj.hosp.domain.*;
+import com.ltkj.hosp.service.*;
+import com.ltkj.web.controller.lis.LisApiMethod;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import org.aspectj.weaver.AjAttribute;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
 import org.springframework.web.bind.annotation.*;
 import com.ltkj.common.annotation.Log;
 import com.ltkj.common.core.controller.BaseController;
 import com.ltkj.common.core.domain.AjaxResult;
 import com.ltkj.common.enums.BusinessType;
-import com.ltkj.hosp.domain.TjSampling;
-import com.ltkj.hosp.service.ITjSamplingService;
 import com.ltkj.common.utils.poi.ExcelUtil;
 import com.ltkj.common.core.page.TableDataInfo;
 
@@ -54,6 +53,12 @@
     private TjAsyncService asyncService;
     @Resource
     private RedisCache redisCache;
+    @Autowired
+    private ITjOrderService orderService;
+    @Autowired
+    private ITbTransitionService tbTransitionService;
+    @Autowired
+    private LisApiMethod lisApiMethod;
 
     /**
      * 鏌ヨ浣撴閲囨牱绠$悊鍒楄〃
@@ -178,6 +183,84 @@
     }
 
     /**
+     * 鑾峰彇閲囨牱瀹㈡埛鍒楄〃
+     * @param isSignFor
+     * @param tjNum
+     * @param name
+     * @param pageNum
+     * @param pageSize
+     * @param beginTime
+     * @param endTime
+     * @return
+     */
+    @GetMapping("/getCusList")
+    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){
+        Page<TjSampling> samplingPage = new Page<>(pageNum, pageSize);
+        LambdaQueryWrapper<TjSampling> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(TjSampling::getIsSignFor,isSignFor);
+        if (null != tjNum && StrUtil.isNotBlank(tjNum))
+            wrapper.eq(TjSampling::getTjNum,tjNum);
+        if (null != name && StrUtil.isNotBlank(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);
+//        wrapper.last("LIMIT " + (pageNum - 1) * pageSize + "," + pageSize);
+        Page<TjSampling> page = tjSamplingService.page(samplingPage, wrapper);
+        List<TjSampling> list = page.getRecords();
+        ArrayList<TjCustomer> tjCustomers = new ArrayList<>();
+        for (TjSampling tjSampling : list) {
+            TjCustomer customer = customerService.getById(tjSampling.getCusId());
+            customer.setCusName(MatchUtils.hideCusName(customer.getCusName()));
+            customer.setCusPhone(MatchUtils.hidePhoneNum(customer.getCusPhone()));
+            customer.setCusIdcard(MatchUtils.hideIdCardNum(customer.getCusIdcard()));
+            customer.setTjNumber(tjSampling.getTjNum());
+            customer.setApplicationTime(tjSampling.getApplicationTime());
+            tjCustomers.add(customer);
+        }
+        HashMap<String, Object> hashMap = new HashMap<>();
+        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){
+        if (cusId == null || StrUtil.isBlank(cusId))
+            return AjaxResult.error("鍙傛暟閿欒");
+        LambdaQueryWrapper<TjSampling> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(TjSampling::getCusId,cusId);
+        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);
+            }
+        }
+        return AjaxResult.success(projectList);
+    }
+
+    @PostMapping("/mergeCaiYang")
+    public AjaxResult mergeCaiYang(@RequestBody List<String> ids){
+        return AjaxResult.success();
+    }
+
+    /**
      * 瀵煎嚭浣撴閲囨牱绠$悊鍒楄〃
      */
     //@PreAuthorize("@ss.hasPermi('sampling:sampling:export')")
@@ -239,13 +322,17 @@
      */
     @PostMapping("/confirmSampling")
     @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());
@@ -254,6 +341,7 @@
                 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());
@@ -266,8 +354,21 @@
                     }
                 }
             }
-            tjSamplingService.updateById(sampling);
+            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("鎿嶄綔鎴愬姛");
     }
 }

--
Gitblit v1.8.0