From f65bcbe907738bbdf352d5d97ff4ecf2022cb86a Mon Sep 17 00:00:00 2001
From: x_z <zrhdyxa@163.com>
Date: Fri, 21 Apr 2023 11:02:12 +0800
Subject: [PATCH] =?UTF-8?q?1.=E4=BF=AE=E5=A4=8D=E7=AC=AC=E4=B8=89=E6=96=B9?=
 =?UTF-8?q?=E4=BA=A7=E5=93=81=E4=BF=A1=E6=81=AF=E6=9F=A5=E8=AF=A2=E6=8A=A5?=
 =?UTF-8?q?=E9=94=99=E9=97=AE=E9=A2=98=EF=BC=8C=E4=BC=98=E5=8C=96=E6=9F=A5?=
 =?UTF-8?q?=E8=AF=A2=E8=AF=AD=E5=8F=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../thrsys/ThrProductsController.java         | 74 ++++---------------
 .../thrsys/impl/ThrProductsServiceImpl.java   |  7 +-
 .../mybatis/mapper/thrsys/ThrProductsDao.xml  |  4 +-
 3 files changed, 19 insertions(+), 66 deletions(-)

diff --git a/src/main/java/com/glxp/api/controller/thrsys/ThrProductsController.java b/src/main/java/com/glxp/api/controller/thrsys/ThrProductsController.java
index a8156c86..2e745c61 100644
--- a/src/main/java/com/glxp/api/controller/thrsys/ThrProductsController.java
+++ b/src/main/java/com/glxp/api/controller/thrsys/ThrProductsController.java
@@ -1,8 +1,6 @@
 package com.glxp.api.controller.thrsys;
 
 
-import cn.hutool.core.util.StrUtil;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.github.pagehelper.PageInfo;
 import com.glxp.api.annotation.AuthRuleAnnotation;
 import com.glxp.api.annotation.Log;
@@ -10,13 +8,10 @@ import com.glxp.api.common.enums.ResultEnum;
 import com.glxp.api.common.res.BaseResponse;
 import com.glxp.api.common.util.ResultVOUtils;
 import com.glxp.api.constant.BusinessType;
-import com.glxp.api.entity.auth.AuthAdmin;
 import com.glxp.api.entity.thrsys.ThrProductsEntity;
-import com.glxp.api.entity.thrsys.ThrSystemDetailEntity;
 import com.glxp.api.http.ErpBasicClient;
 import com.glxp.api.req.system.DeleteRequest;
 import com.glxp.api.req.thrsys.FilterThrProductsRequest;
-import com.glxp.api.req.thrsys.ThrProductsRequest;
 import com.glxp.api.res.PageSimpleResponse;
 import com.glxp.api.res.thrsys.ThrProductsResponse;
 import com.glxp.api.service.auth.CustomerService;
@@ -24,7 +19,10 @@ import com.glxp.api.service.thrsys.ThrProductsService;
 import com.glxp.api.service.thrsys.ThrSystemDetailService;
 import org.springframework.beans.BeanUtils;
 import org.springframework.validation.BindingResult;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
 import java.util.Date;
@@ -63,54 +61,13 @@ public class ThrProductsController {
             return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
         }
 
-        ThrSystemDetailEntity thrSystemDetailEntity = thrSystemDetailService.selectByKey("piQueryUrl", filterThrProductsRequest.getThirdSys());
-        if (thrSystemDetailEntity == null || thrSystemDetailEntity.getValue() == null) {
-            return ResultVOUtils.error(500, "ERP产品信息接口地址未定义");
-        }
-
-        if (thrSystemDetailEntity.getEnabled()) {
-            if (thrSystemDetailEntity.getFromType() == 0 || (filterThrProductsRequest.getIsDownThrSys() != null && filterThrProductsRequest.getIsDownThrSys())) {
-                BaseResponse<PageSimpleResponse<ThrProductsResponse>> udiDlDeviceResponse = erpBasicClient.getErpProducts(filterThrProductsRequest);
-                if (udiDlDeviceResponse.getCode() == 20000) {
-                    List<ThrProductsResponse> invmandocResponses = udiDlDeviceResponse.getData().getList();
-                    //todo  耗材字典未确认数据库
-//                    if (invmandocResponses != null) {
-//                        for (ThrProductsResponse invmandocResponse : invmandocResponses) {
-//                            UdiRelevanceEntity udiRelevanceEntity = udiRelevanceService.selectByThirdId(invmandocResponse.getCode(), filterErpGoodsRequest.getThirdSys());
-//                            invmandocResponse.setThirdSys(thrProductsRequest.getThirdSys());
-//                            if (udiRelevanceEntity != null) {
-//                                invmandocResponse.setChecked(true);
-//                            } else {
-//                                invmandocResponse.setChecked(false);
-//                            }
-//                        }
-//                    }
-
-                }
-                return udiDlDeviceResponse;
-            } else {
-
-                List<ThrProductsResponse> thrCorpEntities = thrProductsService.filterJoinThrProducts(filterThrProductsRequest);
-                //todo  耗材字典未确认数据库
-//                for (ThrProductsEntity thrProductsEntity : thrCorpEntities) {
-//                    UdiRelevanceEntity udiRelevanceEntity = udiRelevanceService.selectByThirdId(thrProductsEntity.getCode(), thrProductsEntity.getThirdSysFk());
-//                    if (udiRelevanceEntity != null) {
-//                        thrProductsEntity.setChecked(true);
-//                    } else {
-//                        thrProductsEntity.setChecked(false);
-//                    }
-//                }
-                PageInfo<ThrProductsResponse> pageInfo;
-                pageInfo = new PageInfo<>(thrCorpEntities);
-                PageSimpleResponse<ThrProductsResponse> pageSimpleResponse = new PageSimpleResponse<>();
-                pageSimpleResponse.setTotal(pageInfo.getTotal());
-                pageSimpleResponse.setList(thrCorpEntities);
-                return ResultVOUtils.success(pageSimpleResponse);
-            }
-
-        } else {
-            return ResultVOUtils.error(500, "第三方系统产品信息接口服务未启用");
-        }
+        List<ThrProductsResponse> thrCorpEntities = thrProductsService.filterJoinThrProducts(filterThrProductsRequest);
+        PageInfo<ThrProductsResponse> pageInfo;
+        pageInfo = new PageInfo<>(thrCorpEntities);
+        PageSimpleResponse<ThrProductsResponse> pageSimpleResponse = new PageSimpleResponse<>();
+        pageSimpleResponse.setTotal(pageInfo.getTotal());
+        pageSimpleResponse.setList(thrCorpEntities);
+        return ResultVOUtils.success(pageSimpleResponse);
     }
 
     @PostMapping("/udiwms/thrsys/delThrProducts")
@@ -169,15 +126,14 @@ public class ThrProductsController {
     @AuthRuleAnnotation("")
     @PostMapping("/udiwms/udiinfo/erp/products/saveProduct")
     @Log(title = "第三方产品信息", businessType = BusinessType.INSERT)
-    public BaseResponse saveProduct(@RequestBody ThrProductsEntity thrProductsEntity,FilterThrProductsRequest filterThrProductsRequest) {
-
+    public BaseResponse saveProduct(@RequestBody ThrProductsEntity thrProductsEntity, FilterThrProductsRequest filterThrProductsRequest) {
 
 
         if (null == thrProductsEntity)
             return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
-        BeanUtils.copyProperties(thrProductsEntity,filterThrProductsRequest);
+        BeanUtils.copyProperties(thrProductsEntity, filterThrProductsRequest);
         List<ThrProductsEntity> thrProductsEntities = thrProductsService.filterThrProducts1(filterThrProductsRequest);
-        if(thrProductsEntities.size()==0){
+        if (thrProductsEntities.size() == 0) {
             thrProductsEntity.setUpdateUser(String.valueOf(customerService.getUserId()));
             thrProductsEntity.setCreateUser(String.valueOf(customerService.getUserId()));
             thrProductsEntity.setUpdateTime(new Date());
@@ -185,7 +141,7 @@ public class ThrProductsController {
             thrProductsService.insertThrProducts(thrProductsEntity);
             return ResultVOUtils.success();
         }
-        return ResultVOUtils.error(999,"数据已存在!");
+        return ResultVOUtils.error(999, "数据已存在!");
 
 
 //        //新增主系统产品信息直接加到耗材字典里
diff --git a/src/main/java/com/glxp/api/service/thrsys/impl/ThrProductsServiceImpl.java b/src/main/java/com/glxp/api/service/thrsys/impl/ThrProductsServiceImpl.java
index 96d086ce..63abfd96 100644
--- a/src/main/java/com/glxp/api/service/thrsys/impl/ThrProductsServiceImpl.java
+++ b/src/main/java/com/glxp/api/service/thrsys/impl/ThrProductsServiceImpl.java
@@ -2,16 +2,14 @@ package com.glxp.api.service.thrsys.impl;
 
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.StrUtil;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.github.pagehelper.PageHelper;
-import com.glxp.api.entity.thrsys.ThrProductsEntity;
 import com.glxp.api.dao.thrsys.ThrProductsDao;
+import com.glxp.api.entity.thrsys.ThrProductsEntity;
 import com.glxp.api.req.thrsys.FilterThrProductsRequest;
 import com.glxp.api.res.thrsys.ThrProductsAddDiResponse;
 import com.glxp.api.res.thrsys.ThrProductsResponse;
 import com.glxp.api.service.thrsys.ThrProductsAddDiService;
 import com.glxp.api.service.thrsys.ThrProductsService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -83,8 +81,7 @@ public class ThrProductsServiceImpl implements ThrProductsService {
             int offset = (filterThrProductsRequest.getPage() - 1) * filterThrProductsRequest.getLimit();
             PageHelper.offsetPage(offset, filterThrProductsRequest.getLimit());
         }
-        List<ThrProductsResponse> data = thrProductsDao.filterJoinThrProducts(filterThrProductsRequest);
-        return data;
+        return thrProductsDao.filterJoinThrProducts(filterThrProductsRequest);
     }
 
     @Override
diff --git a/src/main/resources/mybatis/mapper/thrsys/ThrProductsDao.xml b/src/main/resources/mybatis/mapper/thrsys/ThrProductsDao.xml
index 2734c22e..94c426c5 100644
--- a/src/main/resources/mybatis/mapper/thrsys/ThrProductsDao.xml
+++ b/src/main/resources/mybatis/mapper/thrsys/ThrProductsDao.xml
@@ -101,9 +101,9 @@
 
     <select id="filterJoinThrProducts" parameterType="com.glxp.api.req.thrsys.FilterThrProductsRequest"
             resultType="com.glxp.api.res.thrsys.ThrProductsResponse">
-        SELECT thr_products.*, thr_system.thirdName thirdSysName
+        SELECT thr_products.*,
+               (select thirdName from thr_system t where t.thirdId = thr_products.thirdSysFk) thirdSysName
         FROM thr_products
-                 LEFT JOIN thr_system on thr_products.thirdSysFk = thr_system.thirdId
         <where>
             <if test="name != '' and name != null">
                 AND name LIKE concat('%', #{name}, '%')