From 38ac9f6394d730fa17cc0e52e8fb85c10bf01cfc Mon Sep 17 00:00:00 2001
From: pengcheng <1432755665@qq.com>
Date: Fri, 27 Sep 2019 16:26:36 +0800
Subject: [PATCH] sql修改

---
 src/main/java/com/huaheng/pc/config/shipmentPreference/service/ShipmentPreferenceServiceImpl.java | 13 +++++++++++++
 src/main/java/com/huaheng/pc/inventory/inventoryDetail/service/InventoryDetailService.java        |  3 ++-
 src/main/java/com/huaheng/pc/inventory/inventoryDetail/service/InventoryDetailServiceImpl.java    | 26 ++++++++++++++------------
 src/main/java/com/huaheng/pc/shipment/shippingCombination/service/ShippingCombinationService.java | 38 ++++++++++++++++++++------------------
 4 files changed, 49 insertions(+), 31 deletions(-)

diff --git a/src/main/java/com/huaheng/pc/config/shipmentPreference/service/ShipmentPreferenceServiceImpl.java b/src/main/java/com/huaheng/pc/config/shipmentPreference/service/ShipmentPreferenceServiceImpl.java
index e53547a..2071bff 100644
--- a/src/main/java/com/huaheng/pc/config/shipmentPreference/service/ShipmentPreferenceServiceImpl.java
+++ b/src/main/java/com/huaheng/pc/config/shipmentPreference/service/ShipmentPreferenceServiceImpl.java
@@ -7,6 +7,8 @@ import com.huaheng.common.exception.service.ServiceException;
 import com.huaheng.common.support.Convert;
 import com.huaheng.common.utils.StringUtils;
 import com.huaheng.common.utils.security.ShiroUtils;
+import com.huaheng.pc.config.configValue.domain.ConfigValue;
+import com.huaheng.pc.config.configValue.service.ConfigValueService;
 import com.huaheng.pc.config.shipmentPreference.domain.ShipmentPreference;
 import com.huaheng.pc.config.shipmentPreference.mapper.ShipmentPreferenceMapper;
 import com.huaheng.pc.config.statusFlow.domain.StatusFlowDetail;
@@ -32,6 +34,8 @@ public class ShipmentPreferenceServiceImpl extends ServiceImpl<ShipmentPreferenc
     private StatusFlowDetailService statusFlowDetailService;
     @Autowired
     private ShipmentHeaderService shipmentHeaderService;
+    @Autowired
+    private ConfigValueService configValueService;
 
 
     /**
@@ -46,6 +50,15 @@ public class ShipmentPreferenceServiceImpl extends ServiceImpl<ShipmentPreferenc
      */
     @Override
     public List<ShipmentHeader> checkShipmentProcess(String ids, Integer code) {
+
+        LambdaQueryWrapper<ConfigValue> configValueLambdaQueryWrapper=Wrappers.lambdaQuery();
+        configValueLambdaQueryWrapper.eq(ConfigValue::getModuleType,"shipment")
+                .eq(ConfigValue::getWarehouseCode,ShiroUtils.getWarehouseCode());
+        ConfigValue configValue=configValueService.getOne(configValueLambdaQueryWrapper);
+        if(configValue==null){
+            throw new ServiceException("仓库的出库配置不存在");
+        }
+
         //查找出库首选项
         ShipmentPreference shipmentPreference = shipmentPreferenceService.list().get(0);
         if(shipmentPreference == null){
diff --git a/src/main/java/com/huaheng/pc/inventory/inventoryDetail/service/InventoryDetailService.java b/src/main/java/com/huaheng/pc/inventory/inventoryDetail/service/InventoryDetailService.java
index a8c9a78..77adfb0 100644
--- a/src/main/java/com/huaheng/pc/inventory/inventoryDetail/service/InventoryDetailService.java
+++ b/src/main/java/com/huaheng/pc/inventory/inventoryDetail/service/InventoryDetailService.java
@@ -2,6 +2,7 @@ package com.huaheng.pc.inventory.inventoryDetail.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.huaheng.framework.web.domain.AjaxResult;
+import com.huaheng.pc.config.shipmentPreference.domain.ShipmentPreference;
 import com.huaheng.pc.inventory.inventoryDetail.domain.InventoryDetail;
 import com.huaheng.pc.shipment.shipmentDetail.domain.ShipmentDetail;
 
@@ -14,7 +15,7 @@ public interface InventoryDetailService extends IService<InventoryDetail> {
 
     void detailcreateCheckOutTask (Integer id);
 
-    List<InventoryDetail> selectBysql(String sql, ShipmentDetail shipmentDetail,String sqll);
+    List<InventoryDetail> selectBysql(String sql, ShipmentDetail shipmentDetail, String sqll, ShipmentPreference shipmentPreference);
 
 
     AjaxResult detailCheckTask (Integer[] ids) throws InvocationTargetException, IllegalAccessException;
diff --git a/src/main/java/com/huaheng/pc/inventory/inventoryDetail/service/InventoryDetailServiceImpl.java b/src/main/java/com/huaheng/pc/inventory/inventoryDetail/service/InventoryDetailServiceImpl.java
index 65504f1..1a4b5ad 100644
--- a/src/main/java/com/huaheng/pc/inventory/inventoryDetail/service/InventoryDetailServiceImpl.java
+++ b/src/main/java/com/huaheng/pc/inventory/inventoryDetail/service/InventoryDetailServiceImpl.java
@@ -12,6 +12,7 @@ import com.huaheng.pc.check.checkHeader.domain.CheckHeader;
 import com.huaheng.pc.check.checkHeader.service.CheckHeaderService;
 import com.huaheng.pc.config.location.domain.Location;
 import com.huaheng.pc.config.location.service.LocationService;
+import com.huaheng.pc.config.shipmentPreference.domain.ShipmentPreference;
 import com.huaheng.pc.inventory.inventoryDetail.domain.InventoryDetail;
 import com.huaheng.pc.inventory.inventoryHeader.service.InventoryHeaderService;
 import com.huaheng.pc.receipt.receiptDetail.domain.ReceiptDetail;
@@ -128,18 +129,19 @@ public class InventoryDetailServiceImpl extends ServiceImpl<InventoryDetailMappe
     }
 
     @Override
-    public List<InventoryDetail> selectBysql(String sql, ShipmentDetail shipmentDetail,String sqll) {
-        if(StringUtils.isEmpty(sqll)) {
-            sql = sql + " \n" + "and warehouseCode='" + shipmentDetail.getWarehouseCode() + "' \n" +
-                    "and companyCode='" + shipmentDetail.getCompanyCode() + "' \n" +
-                    "and materialCode='" + shipmentDetail.getMaterialCode() + "' \n" +
-                    "and inventorySts='" + shipmentDetail.getInventorySts() + "'";
-        }else {
-            sql = sql + " \n" + "and warehouseCode='" + shipmentDetail.getWarehouseCode() + "' \n" +
-                    "and companyCode='" + shipmentDetail.getCompanyCode() + "' \n" +
-                    "and materialCode='" + shipmentDetail.getMaterialCode() + "' \n" +
-                    "and inventorySts='" + shipmentDetail.getInventorySts() + "'"+ " \n" +sqll;
-        }
+    public List<InventoryDetail> selectBysql(String sql, ShipmentDetail shipmentDetail, String sqll, ShipmentPreference shipmentPreference) {
+       if(shipmentPreference.getAllowQcCheckResult() == true) {
+           sql = sql + " \n" + "and warehouseCode='" + shipmentDetail.getWarehouseCode() + "' \n" +
+                   "and companyCode='" + shipmentDetail.getCompanyCode() + "' \n" +
+                   "and materialCode='" + shipmentDetail.getMaterialCode() + "' \n" +
+                   "and inventorySts='" + shipmentDetail.getInventorySts() + "'\n"+
+                   "and inventorySts='" + shipmentDetail.getInventorySts() + "'\n"+ sqll;
+       }else {
+           sql = sql + " \n" + "and warehouseCode='" + shipmentDetail.getWarehouseCode() + "' \n" +
+                   "and companyCode='" + shipmentDetail.getCompanyCode() + "' \n" +
+                   "and materialCode='" + shipmentDetail.getMaterialCode() + "' \n" +
+                   "and qcCheck=1\n"+ sqll;
+       }
         return inventoryDetailMapper.selectBysql(sql);
     }
 
diff --git a/src/main/java/com/huaheng/pc/shipment/shippingCombination/service/ShippingCombinationService.java b/src/main/java/com/huaheng/pc/shipment/shippingCombination/service/ShippingCombinationService.java
index a603558..e01c992 100644
--- a/src/main/java/com/huaheng/pc/shipment/shippingCombination/service/ShippingCombinationService.java
+++ b/src/main/java/com/huaheng/pc/shipment/shippingCombination/service/ShippingCombinationService.java
@@ -46,6 +46,23 @@ public class ShippingCombinationService {
 
     //根据分配规则查找库存
     public List<InventoryDetail> getInventorys(ShipmentDetail shipmentDetail) {
+        LambdaQueryWrapper<ConfigValue> configValueLambdaQueryWrapper=Wrappers.lambdaQuery();
+        configValueLambdaQueryWrapper.eq(ConfigValue::getModuleType,"shipment")
+                .eq(ConfigValue::getWarehouseCode,shipmentDetail.getWarehouseCode());
+        ConfigValue configValue=configValueService.getOne(configValueLambdaQueryWrapper);
+        if(configValue==null){
+            throw new ServiceException("仓库的出库配置不存在");
+        }
+
+        //查找出库首选项
+        LambdaQueryWrapper<ShipmentPreference> slam=Wrappers.lambdaQuery();
+        slam.eq(ShipmentPreference::getCode,configValue.getIdentifier())
+                .eq(ShipmentPreference::getWarehouseCode,configValue.getWarehouseCode());
+        ShipmentPreference shipmentPreference=shipmentPreferenceService.getOne(slam);
+        if(shipmentPreference==null){
+            throw new ServiceException("仓库的出库配置中出库首选项不存在");
+        }
+
         List<InventoryDetail> list=new ArrayList<>();
         FilterConfigDetail filterConfigDetail=new FilterConfigDetail();
         LambdaQueryWrapper<FilterConfigDetail> filterConfigDetailLambdaQueryWrapper= Wrappers.lambdaQuery();
@@ -61,7 +78,7 @@ public class ShippingCombinationService {
 
             //根据sql查库存
             try {
-                list = inventoryDetailService.selectBysql(filterConfigDetail.getStatement(),shipmentDetail,filterConfigDetail.getSqll());
+                list = inventoryDetailService.selectBysql(filterConfigDetail.getStatement(),shipmentDetail,filterConfigDetail.getSqll(),shipmentPreference);
             }catch (Exception e){
                 throw new ServiceException("sql错误");
             }
@@ -81,27 +98,12 @@ public class ShippingCombinationService {
             }
 
             //根据sql查库存
-            list=inventoryDetailService.selectBysql(filterConfigDetail.getStatement(),shipmentDetail,filterConfigDetail.getSqll());
+            list=inventoryDetailService.selectBysql(filterConfigDetail.getStatement(),shipmentDetail,filterConfigDetail.getSqll(),shipmentPreference);
             return list;
         }
 
         //都没有时,默认仓库的分配规则
-        LambdaQueryWrapper<ConfigValue> configValueLambdaQueryWrapper=Wrappers.lambdaQuery();
-        configValueLambdaQueryWrapper.eq(ConfigValue::getModuleType,"shipment")
-                .eq(ConfigValue::getWarehouseCode,shipmentDetail.getWarehouseCode());
-        ConfigValue configValue=configValueService.getOne(configValueLambdaQueryWrapper);
-        if(configValue==null){
-            throw new ServiceException("仓库的出库配置不存在");
-        }
 
-        //查找出库首选项
-        LambdaQueryWrapper<ShipmentPreference> slam=Wrappers.lambdaQuery();
-        slam.eq(ShipmentPreference::getCode,configValue.getIdentifier())
-                .eq(ShipmentPreference::getWarehouseCode,configValue.getWarehouseCode());
-        ShipmentPreference shipmentPreference=shipmentPreferenceService.getOne(slam);
-        if(shipmentPreference==null){
-            throw new ServiceException("仓库的出库配置中出库首选项不存在");
-        }
         //查找分配规则
         filterConfigDetailLambdaQueryWrapper.eq(FilterConfigDetail::getCode,shipmentPreference.getAllocationRule());
         filterConfigDetail=filterConfigDetailService.getOne(filterConfigDetailLambdaQueryWrapper);
@@ -110,7 +112,7 @@ public class ShippingCombinationService {
         }
 
         //根据sql查库存
-        list=inventoryDetailService.selectBysql(filterConfigDetail.getStatement(),shipmentDetail,filterConfigDetail.getSqll());
+        list=inventoryDetailService.selectBysql(filterConfigDetail.getStatement(),shipmentDetail,filterConfigDetail.getSqll(),shipmentPreference);
         return list;
     }
 
--
libgit2 0.22.2