Browse Source

问题修改

zhs 2 years ago
parent
commit
bb08182799

+ 1 - 1
src/main/java/com/tld/config/MyRedissonConfig.java

@@ -24,4 +24,4 @@ public class MyRedissonConfig {
         RedissonClient  redissonClient = Redisson.create(config);
         return redissonClient;
     }
-}
+}

+ 3 - 3
src/main/java/com/tld/config/SaticScheduleTask.java

@@ -42,15 +42,15 @@ public class SaticScheduleTask {
     /**
      * 批量回调 生产领料
      */
-    @Scheduled(cron = "0 */30 * * * ?")
-    public void callback(){
+    @Scheduled(cron = "0 */60 * * * ?")
+    public void callback() {
         askGoodsService.getCallback();
     }
 
     /**
      * 批量回调 入库回传
      */
-    @Scheduled(cron = "0 */30 * * * ?")
+    @Scheduled(cron = "0 */10 * * * ?")
     public void callPlugOutWarehousing(){
         askGoodsService.getCallPlugOutWarehousing();
     }

+ 10 - 0
src/main/java/com/tld/controller/AskGoodsController.java

@@ -67,6 +67,16 @@ public class AskGoodsController {
         return askGoodsService.addAskGoodsVitrual(askGoods);
     }
 
+    /**
+     * 跨越退料
+     * @param askGoods
+     * @return
+     */
+    @PostMapping("addAskGoodsVitrualMinus")
+    public Map<String, Object> addAskGoodsVitrualMinus(@RequestBody AskGoods askGoods){
+        return askGoodsService.addAskGoodsVitrualMinus(askGoods);
+    }
+
     /**
      * 移库入虚拟库
      * @param askGoods 參數

+ 17 - 0
src/main/java/com/tld/controller/WarehousingController.java

@@ -33,6 +33,23 @@ public class WarehousingController {
         return warehousingService.getRecommend(wllbCode, suppId, num, unique, producDate, warehouseWhere, wbs, accountSleeve);
     }
 
+    /**
+     * 要货单退库推荐库位
+     * @param wllbCode
+     * @param suppId
+     * @param num
+     * @param unique
+     * @param producDate
+     * @param warehouseWhere
+     * @param wbs
+     * @param accountSleeve
+     * @return
+     */
+    @GetMapping("getRecommendMinus")
+    public Map<String, Object> getRecommendMinus(String wllbCode, String suppId, String num, String unique, String producDate, String warehouseWhere, String wbs, String accountSleeve){
+        return warehousingService.getRecommendMinus(wllbCode, suppId, num, unique, producDate, warehouseWhere, wbs, accountSleeve);
+    }
+
     /**
      * 库位推荐虚拟表入库
      * @param warehousingVirtual 参数

+ 2 - 0
src/main/java/com/tld/mapper/AskGoodsMapper.java

@@ -249,4 +249,6 @@ public interface AskGoodsMapper {
     List<Map<String, Object>> getCallPlugOutWarehousing();
 
     String getUserName(@Param("userName") String userName);
+
+    void addInventory(Inventory inventory);
 }

+ 3 - 0
src/main/java/com/tld/service/AskGoodsService.java

@@ -104,8 +104,11 @@ public interface AskGoodsService {
     void mergeGs();
 
     void jsonErrorParking();
+
     void getCallback();
 
+    Map<String, Object> addAskGoodsVitrualMinus(AskGoods askGoods);
+
     void errorParkingReturn();
 
     void getCallPlugOutWarehousing();

+ 2 - 0
src/main/java/com/tld/service/WarehousingService.java

@@ -60,4 +60,6 @@ public interface WarehousingService {
     Map<String, Object> addDisposeNotice(Notice notice);
 
     void exportNotice(Notice notice, HttpServletResponse response);
+
+    Map<String, Object> getRecommendMinus(String wllbCode, String suppId, String num, String unique, String producDate, String warehouseWhere, String wbs, String accountSleeve);
 }

+ 54 - 8
src/main/java/com/tld/service/impl/AskGoodsServiceImpl.java

@@ -212,8 +212,8 @@ public class AskGoodsServiceImpl implements AskGoodsService {
             AskGoods askGoods1 = askGoodsMapper.getAsknInfo(askGoods); //要货单数量
             int alreadyNum =  askGoodsMapper.getAskInfoNumVitrual(askGoods);//已扫描总数
             int inventoryAlready =  askGoodsMapper.getInventoryAlready(askGoods);//库存已扫描数量
-            Double inventorySurplus = (Double.parseDouble(inventory.getAmount()) - Double.parseDouble(inventory.getAmountLock())) - inventoryAlready; //库存剩余数量
-            Double surplusNum = Double.parseDouble(askGoods1.getNum()) - Double.parseDouble(askGoods1.getOutNum()) - alreadyNum; //剩余要扫描数量
+            Double inventorySurplus = DateUtil.formatDouble1((Double.parseDouble(inventory.getAmount()) - Double.parseDouble(inventory.getAmountLock())) - inventoryAlready); //库存剩余数量
+            Double surplusNum = DateUtil.formatDouble1(Double.parseDouble(askGoods1.getNum()) - Double.parseDouble(askGoods1.getOutNum()) - alreadyNum); //剩余要扫描数量
 
             if(Double.doubleToLongBits(surplusNum) >= Double.doubleToLongBits(inventorySurplus)){
                 askGoods.setNum(String.valueOf(inventorySurplus));
@@ -237,6 +237,20 @@ public class AskGoodsServiceImpl implements AskGoodsService {
         return map;
     }
 
+    @Override
+    public Map<String, Object> addAskGoodsVitrualMinus(AskGoods askGoods) {
+        Map<String, Object> map = new HashMap<>();
+        try{
+            askGoodsMapper.addAskGoodsVitrual(askGoods);
+            map.put("msg", "200");
+        }catch (Exception e){
+            e.printStackTrace();
+            map.put("msg", "500");
+            map.put("errMsg", "失败");
+        }
+        return map;
+    }
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Map<String, Object> OutOfLibrary(String uniqueCode, String type, String askGoodsId, String name) {
@@ -251,11 +265,36 @@ public class AskGoodsServiceImpl implements AskGoodsService {
             for(AskGoods askGoods : list){
                 askGoods.setStorageCode(removalCode);
                 askGoods.setCompanyNumber(askGoods.getAccountSleeve());
+                String materialId = askGoodsMapper.getMaterialId(askGoods.getWllbCode());//查询物料id
                 Inventory inventory = askGoodsMapper.getInventory(askGoods);//查询库存数量
                 if(inventory == null){
 //                    throw new Exception("库存不存在");
 //                    System.out.println("库存不存在");
-                    continue;
+                    //查询物料信息
+                    MaterialClass material = warehousingMapper.getMaterial(new Notice().setMaterialCode(askGoods.getWllbCode()));
+
+                    inventory = new Inventory()
+                    .setStorageLocationCode(askGoods.getStorageLocationCode())
+                    .setAmount("0")
+                    .setWllbClass(material.getWllbClass())
+                    .setMaterialId(material.getTldId())
+                    .setWllbCode(material.getWllbCode())
+                    .setAccountSleeve(askGoods.getAccountSleeve())
+                    .setWbs(askGoods.getWbs())
+                    .setProducDate(askGoods.getProducDate())
+                    .setProducBatch("19700101")
+                    .setSupplierId(askGoods.getSupplierId())
+                    .setSerial(askGoods.getSerial());
+                    if(material.getPartType().equals("半成品") || material.getPartType().equals("产成品")) {
+                        inventory.setSupplierId("EC13437");
+                        if(askGoods.getAccountSleeve().equals("8130")){
+                            inventory.setSerial("000000");
+                        } else if(askGoods.getAccountSleeve().equals("8400")){
+                            inventory.setSerial("100000");
+                        }
+                    }
+                    askGoodsMapper.addInventory(inventory);
+                    inventory.setId(inventory.getId());
                 }
                 //如果出库库存等于虚拟表库存则删除此库存
                 if(Double.doubleToLongBits(Double.parseDouble(askGoods.getNum())) == Double.doubleToLongBits(Double.parseDouble(inventory.getAmount()))){
@@ -264,7 +303,6 @@ public class AskGoodsServiceImpl implements AskGoodsService {
                     inventory.setAmount(askGoods.getNum());
                     askGoodsMapper.updateInventory(inventory);
                 }
-                String materialId = askGoodsMapper.getMaterialId(askGoods.getWllbCode());//查询物料id
                 AskGoods askGoods1 = askGoodsMapper.getAskDetailed(askGoodsId, materialId, askGoods.getEntryNumber());//查询要料申请单内容
                 ReturRemoval returRemoval = new ReturRemoval()
                         .setMaterialId(materialId)
@@ -287,7 +325,8 @@ public class AskGoodsServiceImpl implements AskGoodsService {
                         .setRemovalCode(removalCode)
                         .setSourceType(askGoods3.getSourceType())
                         .setMoveType(askGoods3.getMoveType())
-                        .setName(name);
+                        .setName(name)
+                        .setRequestTypeName(askGoods3.getRequestTypeName());
                 askGoodsMapper.addReturnGsRemovalF(returRemoval1);//新增返回gs数据父表信息
                 map.put("data", askGoods3.getAskGoodsId());
 //            } else {
@@ -321,6 +360,12 @@ public class AskGoodsServiceImpl implements AskGoodsService {
                 List<Map<String, Object>> mapList = askGoodsMapper.plugOutRemoval(removalCode);
                 if(mapList.size() >0 ) {
                     JSONObject strJson = new JSONObject();
+                    int isRed = 0;
+                    if(mapList.get(0).get("requestTypeName").toString().equals("跨越退料")){
+                        isRed = 2;
+                    } else {
+                        isRed = 0;
+                    }
                     //父表
                     strJson.put("GIReqBillID", mapList.get(0).get("askGoodsId").toString());//要货单id
                     strJson.put("WMSID", mapList.get(0).get("id").toString());//出库单id
@@ -329,7 +374,7 @@ public class AskGoodsServiceImpl implements AskGoodsService {
                     strJson.put("SourceBillDate",DateUtil.dateConversion(mapList.get(0).get("scrq").toString()));//业务日期
                     strJson.put("SourceType", mapList.get(0).get("sourceType").toString());//来源类型 8
                     strJson.put("MoveType", mapList.get(0).get("moveType").toString());//移动类型
-                    strJson.put("IsRed", 0);//是否红单1
+                    strJson.put("IsRed", isRed);//是否红单1  2
                     if (realName == null || realName == ""){
                         realName = "李兆峰" ;
                     }
@@ -798,10 +843,9 @@ public class AskGoodsServiceImpl implements AskGoodsService {
                     JSONObject returnData = new JSONObject();
                     List<JSONObject> retunList = new LinkedList<>();
                     JSONObject ReqOutStocks = new JSONObject();
-                    JSONObject BillItems = new JSONObject();
                     List<JSONObject> list2 = new LinkedList<>();
                     for (Map<String, Object> map : askGoodsMapper.getRemovalz(mapList.get(0).get("askGoodsId").toString(), warehouseWhere)) {
-
+                        JSONObject BillItems = new JSONObject();
                         BillItems.put("WMSItemID", map.get("id"));//分录ID
                         BillItems.put("BOLID", map.get("askGoodsId"));//要货申请单ID
                         BillItems.put("BOLItemID", map.get("entryNumber"));//要货申请明细ID
@@ -1981,6 +2025,8 @@ public class AskGoodsServiceImpl implements AskGoodsService {
         }
     }
 
+
+
     @Override
     public void test() {
         AskGoods askGoods = new AskGoods();

+ 3 - 2
src/main/java/com/tld/service/impl/DeliveryServiceImpl.java

@@ -8,6 +8,7 @@ import com.tld.mapper.DictionaryMapper;
 import com.tld.mapper.WarehousingMapper;
 import com.tld.model.*;
 import com.tld.service.DeliveryService;
+import com.tld.util.DateUtil;
 import org.redisson.api.RLock;
 import org.redisson.api.RedissonClient;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -318,13 +319,13 @@ public class DeliveryServiceImpl implements DeliveryService {
                 Inventory inventory = deliveryMapper.getInventoryVal(askGoods.getId());//库存数量
                 String allScanNum = deliveryMapper.getAllScanNumDelivery(askGoods); //虚拟表此物料占用数量
                 //剩余出库数量
-                Double num = Double.parseDouble(delivery.getGsDeliveryNum()) - Double.parseDouble(delivery.getOutNum()) - Double.parseDouble(scanNum);
+                Double num = DateUtil.formatDouble1(Double.parseDouble(delivery.getGsDeliveryNum()) - Double.parseDouble(delivery.getOutNum()) - Double.parseDouble(scanNum));
                 if(Double.doubleToLongBits(Double.parseDouble(askGoods.getNum())) > Double.doubleToLongBits(num)){
                     map.put("msg", "500");
                     map.put("errMsg", "出库数量大于剩余需求数量,请修改!");
                     return map;
                 }
-                if(Double.doubleToLongBits(Double.parseDouble(inventory.getAmount()) - Double.parseDouble(allScanNum) - num) >= 0){
+                if(Double.doubleToLongBits(DateUtil.formatDouble1(Double.parseDouble(inventory.getAmount()) - Double.parseDouble(allScanNum) - num)) >= 0){
                     askGoods.setNum(num.toString());
                 } else {
                     askGoods.setNum((Double.parseDouble(inventory.getAmount()) - Double.parseDouble(allScanNum)) + "");

+ 38 - 9
src/main/java/com/tld/service/impl/InviteServiceImpl.java

@@ -1,11 +1,11 @@
 package com.tld.service.impl;
 
 import com.alibaba.fastjson.JSON;
-import com.tld.mapper.DictionaryMapper;
-import com.tld.mapper.InviteMapper;
-import com.tld.mapper.QueryListMapper;
+import com.tld.mapper.*;
 import com.tld.model.*;
 import com.tld.service.InviteService;
+import com.tld.service.WarehousingService;
+import com.tld.util.DateUtil;
 import org.redisson.api.RLock;
 import org.redisson.api.RedissonClient;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -28,6 +28,12 @@ public class InviteServiceImpl implements InviteService {
     private DictionaryMapper dictionaryMapper;
     @Autowired
     private QueryListMapper queryListMapper;
+    //入库
+    @Autowired
+    private WarehousingMapper warehousingMapper;
+
+    @Autowired
+    private AskGoodsMapper askGoodsMapper;
 
     @Override
     public Map<String, Object> getAskGoodsfList(AskGoods askGoods) {
@@ -118,9 +124,9 @@ public class InviteServiceImpl implements InviteService {
             Inventory inventory = inviteMapper.getInventory(askGoods); //库存数量
             AskGoods askGoods1 = inviteMapper.getAsknInfo(askGoods); //要货单数量
             int alreadyNum =  inviteMapper.getAskInfoNumVitrual(askGoods);//已扫描总数
-            int inventoryAlready =  inviteMapper.getInventoryAlready(askGoods);//库存已扫描数量
-            Double inventorySurplus = (Double.parseDouble(inventory.getAmount()) - Double.parseDouble(inventory.getAmountLock())) - inventoryAlready; //库存剩余数量
-            Double surplusNum = Double.parseDouble(askGoods1.getNum()) - Double.parseDouble(askGoods1.getOutNum()) - alreadyNum; //剩余要扫描数量
+            int inventoryAlready = inviteMapper.getInventoryAlready(askGoods);//库存已扫描数量
+            Double inventorySurplus = DateUtil.formatDouble1((Double.parseDouble(inventory.getAmount()) - Double.parseDouble(inventory.getAmountLock())) - inventoryAlready); //库存剩余数量
+            Double surplusNum = DateUtil.formatDouble1(Double.parseDouble(askGoods1.getNum()) - Double.parseDouble(askGoods1.getOutNum()) - alreadyNum); //剩余要扫描数量
 
             if(Double.doubleToLongBits(surplusNum) >= Double.doubleToLongBits(inventorySurplus)){
                 askGoods.setNum(String.valueOf(inventorySurplus));
@@ -153,8 +159,30 @@ public class InviteServiceImpl implements InviteService {
                 askGoods.setCompanyNumber(askGoods.getAccountSleeve());
                 Inventory inventory = inviteMapper.getInventory(askGoods);
                 if(inventory == null){
-//                    throw new Exception("库存不存在");
-                    continue;
+                    MaterialClass material = warehousingMapper.getMaterial(new Notice().setMaterialCode(askGoods.getWllbCode()));
+
+                    inventory = new Inventory()
+                            .setStorageLocationCode(askGoods.getStorageLocationCode())
+                            .setAmount("0")
+                            .setWllbClass(material.getWllbClass())
+                            .setMaterialId(material.getTldId())
+                            .setAccountSleeve(askGoods.getAccountSleeve())
+                            .setWbs(askGoods.getWbs())
+                            .setWllbCode(material.getWllbCode())
+                            .setProducDate(askGoods.getProducDate())
+                            .setProducBatch("19700101")
+                            .setSupplierId(askGoods.getSupplierId())
+                            .setSerial(askGoods.getSerial());
+                    if(material.getPartType().equals("半成品") || material.getPartType().equals("产成品")){
+                        inventory.setSupplierId("EC13437");
+                        if(askGoods.getAccountSleeve().equals("8130")){
+                            inventory.setSerial("000000");
+                        } else if(askGoods.getAccountSleeve().equals("8400")){
+                            inventory.setSerial("100000");
+                        }
+                    }
+                    askGoodsMapper.addInventory(inventory);
+                    inventory.setId(inventory.getId());
                 }
                 //如果出库库存等于虚拟表库存则删除此库存
                 if( Double.doubleToLongBits(Double.parseDouble(askGoods.getNum()))  == Double.doubleToLongBits(Double.parseDouble(inventory.getAmount())) ){
@@ -185,7 +213,8 @@ public class InviteServiceImpl implements InviteService {
                     .setDocumentId(askGoods3.getAskGoodsId())
                     .setRemovalCode(removalCode)
                     .setSourceType(askGoods3.getSourceType())
-                    .setMoveType(askGoods3.getMoveType());
+                    .setMoveType(askGoods3.getMoveType())
+                    .setRequestTypeName(askGoods3.getRequestTypeName());
             inviteMapper.addReturnGsRemovalF(returRemoval1);//新增返回gs数据父表信息
             map.put("data", askGoods3.getAskGoodsId());
             map.put("msg", "200");

+ 42 - 38
src/main/java/com/tld/service/impl/WarehouseTransferServiceImpl.java

@@ -144,29 +144,31 @@ public class WarehouseTransferServiceImpl implements WarehouseTransferService {
                 }
                 warehouseTransferMapper.updateOutNum(askGoods.getNum(), askGoodsId, materialId, typeVal, askGoods.getEntryNumber());//修改出库数量
                 if(askGoods.getStorageLocationCodeRk().indexOf("XNKW") != -1){
-                    Inventory inventory2 = warehouseTransferMapper.getInventoryVitrual(askGoods);
-                    String code = warehouseTransferMapper.getWarehouseTransferCodeType(warehouseTransfer.getAskGoodsWarehouseId());
-                    if(material.getPartType().equals("产成品") && code.equals("2")){
-                        //入库信息
-                        List<WarehousingVirtual> warehousingVal = new LinkedList<>();
-                        WarehousingVirtual warehousingVirtual = warehousing.get(warehousing.size() - 1);
-                        warehousingVirtual.setSuppId("");
-                        warehousingVal.add(warehousingVirtual);
-                        warehousingMapper.addInventory(warehousingVal);//库存
-                    } else {
-                        if(inventory2 != null ){
-                            Inventory inventory1 = new Inventory()
-                                    .setNum(askGoods.getNum())
-                                    .setMaterialId(materialId)
-                                    .setStorageLocationCode(askGoods.getStorageLocationCodeRk());
-                            warehousingMapper.updateVitrualNum(inventory1);
-                        } else {
+                    if(!warehouseType.equals("10")) {
+                        Inventory inventory2 = warehouseTransferMapper.getInventoryVitrual(askGoods);
+                        String code = warehouseTransferMapper.getWarehouseTransferCodeType(warehouseTransfer.getAskGoodsWarehouseId());
+                        if(material.getPartType().equals("产成品") && code.equals("2")){
                             //入库信息
                             List<WarehousingVirtual> warehousingVal = new LinkedList<>();
                             WarehousingVirtual warehousingVirtual = warehousing.get(warehousing.size() - 1);
-                            warehousingVirtual.setSuppId("").setSerial("");
+                            warehousingVirtual.setSuppId("");
                             warehousingVal.add(warehousingVirtual);
                             warehousingMapper.addInventory(warehousingVal);//库存
+                        } else {
+                            if(inventory2 != null ){
+                                Inventory inventory1 = new Inventory()
+                                        .setNum(askGoods.getNum())
+                                        .setMaterialId(materialId)
+                                        .setStorageLocationCode(askGoods.getStorageLocationCodeRk());
+                                warehousingMapper.updateVitrualNum(inventory1);
+                            } else {
+                                //入库信息
+                                List<WarehousingVirtual> warehousingVal = new LinkedList<>();
+                                WarehousingVirtual warehousingVirtual = warehousing.get(warehousing.size() - 1);
+                                warehousingVirtual.setSuppId("").setSerial("");
+                                warehousingVal.add(warehousingVirtual);
+                                warehousingMapper.addInventory(warehousingVal);//库存
+                            }
                         }
                     }
                 }
@@ -275,6 +277,8 @@ public class WarehouseTransferServiceImpl implements WarehouseTransferService {
                         inventory = deliveryMapper.getInventoryHalf(askGoods);
                     } else if(material.getPartType().equals("半成品")){
                         inventory = askGoodsMapper.getInventoryWarehousing(askGoods);
+                    } else if(material.getPartType().equals("低值易耗品")){
+                        inventory = askGoodsMapper.getInventoryWarehousing(askGoods);
                     }
                     //如果出库库存等于虚拟表库存则删除此库存
                     if(Double.doubleToLongBits(Double.parseDouble(askGoods.getNum())) == Double.doubleToLongBits(Double.parseDouble(inventory.getAmount()))){
@@ -293,33 +297,33 @@ public class WarehouseTransferServiceImpl implements WarehouseTransferService {
                         .setWbs(warehouseTransfer.getWbs())//wbs
                         .setOutNum(warehousingVirtual.getNum()); //出库数量
                 warehouseTransferMapper.addReturnGsWarehouseTransfer(warehouseTransfer1);//新增返回gs数据子表信息
-                //新入库逻辑
-                if(material.getPartType().equals("半成品") || material.getPartType().equals("低值易耗品")) {
-                    Notice notice1 = new Notice()
-                            .setMaterialId(warehouseTransfer.getMaterialId())
-                            .setCompanyNumber(warehousingVirtual.getAccountSleeve())
-                            .setStorageLocationCode(warehousingVirtual.getStorageLocationCode())
-                            .setWbs(warehouseTransfer.getWbs())
-                            .setWarehousingNum(warehousingVirtual.getNum())
-                            .setProducBatch(warehousingVirtual.getProducDate())
-                            .setWllbCode(material.getWllbCode())
-                            .setWllbClass(material.getWllbClass());
-                    if(material.getPartType().equals("低值易耗品")){
-                        notice1.setSupplierId("EC13437");
+                if(!warehouseType.equals("10")) {
+                    //新入库逻辑
+                    if(material.getPartType().equals("半成品") || material.getPartType().equals("低值易耗品")) {
+                        Notice notice1 = new Notice()
+                                .setMaterialId(warehouseTransfer.getMaterialId())
+                                .setCompanyNumber(warehousingVirtual.getAccountSleeve())
+                                .setStorageLocationCode(warehousingVirtual.getStorageLocationCode())
+                                .setWbs(warehouseTransfer.getWbs())
+                                .setWarehousingNum(warehousingVirtual.getNum())
+                                .setProducBatch(warehousingVirtual.getProducDate())
+                                .setWllbCode(material.getWllbCode())
+                                .setWllbClass(material.getWllbClass())
+                                .setSupplierId("EC13437");
                         if(warehousingVirtual.getAccountSleeve().equals("8130")){
                             notice1.setSerial("000000");
                         } else if(warehousingVirtual.getAccountSleeve().equals("8400")){
                             notice1.setSerial("100000");
                         }
-                    }
-                    if (warehousingMapper.getInventoryNotice(notice1) != 0) {
-                        warehousingMapper.updateInventoryNotice(notice1);
+                        if (warehousingMapper.getInventoryNotice(notice1) != 0) {
+                            warehousingMapper.updateInventoryNotice(notice1);
+                        } else {
+                            warehousingMapper.addInventoryNotice(notice1);
+                        }
                     } else {
-                        warehousingMapper.addInventoryNotice(notice1);
+                        warehousingMapper.addInventory(list1);//库存
+                        list1.clear();
                     }
-                } else {
-                    warehousingMapper.addInventory(list1);//库存
-                    list1.clear();
                 }
             }
             //入库

+ 89 - 5
src/main/java/com/tld/service/impl/WarehousingServiceImpl.java

@@ -237,15 +237,13 @@ public class WarehousingServiceImpl implements WarehousingService {
                             .setWarehousingNum(warehousingVirtual.getNum())
                             .setProducBatch(warehousingVirtual.getProducDate())
                             .setWllbCode(material.getWllbCode())
-                            .setWllbClass(material.getWllbClass());
-                    if(material.getPartType().equals("低值易耗品")){
-                        notice.setSupplierId("EC13437");
+                            .setWllbClass(material.getWllbClass())
+                            .setSupplierId("EC13437");
                         if(warehousingVirtual.getAccountSleeve().equals("8130")){
                             notice.setSerial("000000");
                         } else if(warehousingVirtual.getAccountSleeve().equals("8400")){
                             notice.setSerial("100000");
                         }
-                    }
                     if (warehousingMapper.getInventoryNotice(notice) != 0) {
                         warehousingMapper.updateInventoryNotice(notice);
                     } else {
@@ -456,6 +454,85 @@ public class WarehousingServiceImpl implements WarehousingService {
         }
     }
 
+    @Override
+    public Map<String, Object> getRecommendMinus(String wllbCode, String suppId, String num, String unique, String producDate, String warehouseWhere, String wbs, String accountSleeve) {
+        Map<String, Object> map = new HashMap<>();
+        try {
+            //判断物料是否录入
+            MaterialClass materialClass = warehousingMapper.getMateriaIsExist(wllbCode);
+            if (materialClass == null) {
+                map.put("msg", "500");
+                map.put("errMsg", "物料信息未录入,请联系管理员");
+                return map;
+            }
+            if(materialClass.getPartType().equals("半成品")) {
+                List<StorageLocation> listTwo = warehousingMapper.getRecommendTwo("1");
+                map.put("data", listTwo);
+                map.put("listString", new HashMap<>());//返回库位剩余数量
+                map.put("msg", "200");
+                return map;
+            }
+            if (materialClass.getPartType().equals("产成品")) {
+                List<StorageLocation> listTwo = warehousingMapper.getRecommendTwo("2");
+                map.put("data", listTwo);
+                map.put("listString", new HashMap<>());//返回库位剩余数量
+                map.put("msg", "200");
+                return map;
+            }
+            //判断如果是混合则走单独逻辑
+            String isNotSisable = warehousingMapper.getIsNotSisable(wllbCode);
+            if (isNotSisable.equals("1")) {
+                List<StorageLocation> list1 = warehousingMapper.getIsNotSisableLocation("1");
+                map.put("data", list1);
+                map.put("msg", "200");
+                return map;
+            }
+            List<MaterialClass> listMaterialClass = warehousingMapper.getMaterialClass(wllbCode);
+            if (listMaterialClass.size() == 0) {
+                listMaterialClass = warehousingMapper.getMaterialClassType(wllbCode);
+            }
+            if (listMaterialClass.size() == 0) {
+                map.put("msg", "500");
+                map.put("errMsg", "该物料未绑定库位");
+                return map;
+            }
+            StringBuffer stringBuffer = new StringBuffer();
+            Map<String, Object> listMap = new HashMap<>();
+            for (int i = 0; i < listMaterialClass.size(); i++) {
+                Map<String, Object> map1 = warehousingMapper.getScanNum(listMaterialClass.get(i).getStorageLocationCode(), num);
+                if ( Double.doubleToLongBits(Double.parseDouble(String.valueOf(map1.get("scanNum")))) <= Double.doubleToLongBits(Double.parseDouble(String.valueOf(materialClass.getSize()))) ) {
+                    //查询库存是否同物料同批次存在
+                    List<Map<String, Object>> countProduc = warehousingMapper.getInventoryProduc(listMaterialClass.get(i).getWllbCode(), producDate, listMaterialClass.get(i).getStorageLocationCode(), wbs, accountSleeve);
+                    if (countProduc.size() == 0) {
+                        stringBuffer.append(listMaterialClass.get(i).getStorageLocationCode() + ",");
+                        int surplusNum = (int) (Double.parseDouble(String.valueOf(materialClass.getSize())) - Double.parseDouble(String.valueOf(map1.get("scanNum"))) + Double.parseDouble(num));
+                        listMap.put(listMaterialClass.get(i).getStorageLocationCode(), surplusNum);
+                    } else {
+                        Date date = new Date();
+                        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
+                        if (String.valueOf(countProduc.get(0).get("producDate")).equals(sdf.format(date)) &&
+                                String.valueOf(countProduc.get(0).get("wbs")).equals(wbs) &&
+                                String.valueOf(countProduc.get(0).get("accountSleeve")).equals(accountSleeve) &&
+                                String.valueOf(countProduc.get(0).get("wllbCode")).equals(wllbCode)) {
+                            stringBuffer.append(listMaterialClass.get(i).getStorageLocationCode() + ",");
+                            int surplusNum = (int) (Double.parseDouble(String.valueOf(materialClass.getSize())) - Double.parseDouble(String.valueOf(map1.get("scanNum"))) + Double.parseDouble(num));
+                            listMap.put(listMaterialClass.get(i).getStorageLocationCode(), surplusNum);
+                        }
+                    }
+                }
+            }
+            List<StorageLocation> list = warehousingMapper.recommend(stringBuffer.toString());
+            map.put("data", list);
+            map.put("listString", listMap);//返回库位剩余数量
+            map.put("msg", "200");
+        } catch (Exception e) {
+            e.printStackTrace();
+            map.put("msg", "500");
+            map.put("errMsg", "服务器请求异常,请稍后再试");
+        }
+        return map;
+    }
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Map<String, Object> addInventoryNotice(Notice notice) {
@@ -472,6 +549,12 @@ public class WarehousingServiceImpl implements WarehousingService {
 //                map.put("errMsg", "入库数量大于通知单数量!");
 //                return map;
 //            }
+            notice.setSupplierId("EC13437");
+            if(notice.getCompanyNumber().equals("8130")){
+                notice.setSerial("000000");
+            } else {
+                notice.setSerial("100000");
+            }
             if (warehousingMapper.getInventoryNotice(notice) != 0) {
                 warehousingMapper.updateInventoryNotice(notice);
             } else {
@@ -582,7 +665,8 @@ public class WarehousingServiceImpl implements WarehousingService {
                     .setStorageLocationCode(inventory.getStorageLocationCode())
                     .setRemovalCode(removalCode)
                     .setSourceType(askGoods.getSourceType())
-                    .setMoveType(askGoods.getMoveType());
+                    .setMoveType(askGoods.getMoveType())
+                    .setName(notice.getRealName());
             askGoodsMapper.addReturnGsRemovalF(returRemoval);//新增返回gs数据父表信息
             askGoodsMapper.addReturnGsRemoval(returRemoval);//新增返回gs数据子表信息
             map.put("data", notice.getAskGoodsId());

+ 4 - 0
src/main/java/com/tld/util/DateUtil.java

@@ -17,4 +17,8 @@ public class DateUtil {
         }
         return dateFormat1.format(date);
     }
+
+    public static double formatDouble1(double d) {
+        return (double)Math.round(d * 1000) / 1000;
+    }
 }

+ 17 - 7
src/main/resources/mapper/AskGoodsMapper.xml

@@ -98,8 +98,8 @@
         LEFT JOIN tld_department c ON b.department = c.code
         JOIN tld_material e ON a.material_id = e.tld_id
         LEFT JOIN tld_wbs f ON a.wbs = f.tld_id
-        WHERE (a.num + 0) <![CDATA[>]]> (
-            IFNULL(a.out_num, 0) + 0)
+        WHERE ((a.num + 0) <![CDATA[>]]> (
+            IFNULL(a.out_num, 0) + 0) or ((a.num like '-%') and ((a.num + 0) != (a.out_num + 0))))
           and e.part_type != '半成品' and e.part_type != '产成品'
           and a.ask_goods_id = #{askGoodsId} and e.code in (select material_id from tld_user_material where user_id = #{userId})
     </select>
@@ -334,7 +334,7 @@
     <!-- 修改库存数量 -->
     <update id="updateInventory">
         UPDATE tld_inventory
-        SET amount = amount - #{amount}
+        SET amount = convert(amount - #{amount}, decimal(12,3))
         WHERE id = #{id}
     </update>
     <!-- 删除虚拟表出库记录 -->
@@ -390,14 +390,15 @@
                sqrq,
                department,
                source_type,
-               move_type
+               move_type,
+               request_type_name
         from tld_ask_goods_f
         where ask_goods_id = #{askGoodsId}
     </select>
     <!-- 新增返回gs数据父表信息 -->
     <insert id="addReturnGsRemovalF">
-        insert into tld_return_gs_removal(document_id, removal_code, source_type, move_type, scrq, delivery_type, name)
-        values (#{documentId}, #{removalCode}, #{sourceType}, #{moveType}, now(), #{deliveryType}, #{name})
+        insert into tld_return_gs_removal(document_id, removal_code, source_type, move_type, scrq, delivery_type, name, request_type_name)
+        values (#{documentId}, #{removalCode}, #{sourceType}, #{moveType}, now(), #{deliveryType}, #{name}, #{requestTypeName})
     </insert>
     <!-- 添加 tld_access 记录-->
     <insert id="addAccess">
@@ -437,6 +438,14 @@
             (#{item.materialCode})
         </foreach>
     </insert>
+    <!-- 退库新增库存 -->
+    <insert id="addInventory">
+        <selectKey resultType="java.lang.String" order="AFTER" keyProperty="id">
+            select LAST_INSERT_ID()
+        </selectKey>
+        insert into tld_inventory(storage_location_code,wllb_class,material_id,amount,totime,hold,amount_lock,total,account_sleeve,wbs,supplier_id,serial,wllb_code,produc_date,scrq,produc_batch,attribute)
+        value(#{storageLocationCode},#{wllbClass},#{materialId},#{amount},now(),'0','0','0',#{accountSleeve},#{wbs},#{supplierId},#{serial},#{wllbCode},#{producDate},now(),#{producBatch}, ' ')
+    </insert>
     <!-- 查询当天出库数量 -->
     <select id="getReturnRemovalCount" resultType="int">
         select count(*)
@@ -450,7 +459,8 @@
                removal_code as removalCode,
                source_type  as sourceType,
                move_type    as moveType,
-               scrq
+               scrq,
+               request_type_name as requestTypeName
         from tld_return_gs_removal
         where document_id = #{removalCode}
     </select>

+ 8 - 5
src/main/resources/mapper/InviteMapper.xml

@@ -83,7 +83,9 @@
             JOIN tld_material e ON a.material_id = e.tld_id
             LEFT JOIN tld_wbs f ON a.wbs = f.tld_id
         WHERE
-            ( a.num + 0 ) <![CDATA[>]]> (IFNULL( a.out_num, 0 ) + 0) and e.part_type != '半成品' and e.part_type != '产成品'
+            ((a.num + 0) <![CDATA[>]]> (
+                IFNULL(a.out_num, 0) + 0) or ((a.num like '-%') and ((a.num + 0) != (a.out_num + 0))))
+            and e.part_type != '半成品' and e.part_type != '产成品'
             and a.ask_goods_id = #{askGoodsId} and e.code in (select material_id from tld_user_material where user_id = #{userId})
     </select>
     <!-- 查询指定pda 指定物料扫描总数 -->
@@ -238,7 +240,7 @@
     <!-- 修改库存数量 -->
     <update id="updateInventory">
         UPDATE tld_inventory
-        SET amount = amount - ${amount}
+        SET amount = convert(amount - #{amount}, decimal(12,3))
         WHERE
             id = #{id}
     </update>
@@ -294,13 +296,14 @@
             sqrq,
             department,
             source_type,
-            move_type
+            move_type,
+            request_type_name
         from tld_invite_f where ask_goods_id = #{askGoodsId}
     </select>
     <!-- 新增返回gs数据父表信息 -->
     <insert id="addReturnGsRemovalF">
-        insert into tld_return_gs_removal(document_id,removal_code,source_type,move_type,scrq,delivery_type)
-        values(#{documentId},#{removalCode},#{sourceType},#{moveType},now(),#{deliveryType})
+        insert into tld_return_gs_removal(document_id,removal_code,source_type,move_type,scrq,delivery_type, request_type_name)
+        values(#{documentId},#{removalCode},#{sourceType},#{moveType},now(),#{deliveryType},#{requestTypeName})
     </insert>
     <!-- 半成品/产成品入库通知 -->
     <insert id="addNotice">

+ 19 - 14
src/main/resources/mapper/QueryListMappeer.xml

@@ -167,6 +167,7 @@
             a.amount AS sum,
             a.serial,
             a.produc_batch as producBatch,
+            a.produc_date as producDate,
             a.supplier_id as supplierId,
             b.storage_location_name as storageLocationName ,
             b.warehouse_where as warehouseWhere,
@@ -1342,8 +1343,8 @@
             tld_ask_goods a
             JOIN tld_material b on a.material_id = b.tld_id
         WHERE
-            ( a.out_num + 0 ) <![CDATA[<]]> (
-            a.num + 0) and b.code in (select material_id from tld_user_material where user_id = #{userId})
+            ((a.num + 0) <![CDATA[>]]> (IFNULL(a.out_num, 0) + 0) or ((a.num like '-%') and ((a.num + 0) != (a.out_num + 0))))
+            and b.code in (select material_id from tld_user_material where user_id = #{userId})
             and b.part_type != '半成品' and b.part_type != '产成品'
     </select>
     <!-- 查询非生产领料任务数量 -->
@@ -1354,8 +1355,8 @@
             tld_invite a
             JOIN tld_material b on a.material_id = b.tld_id
         WHERE
-            ( a.out_num + 0 ) <![CDATA[<]]> (
-            a.num + 0) and b.code in (select material_id from tld_user_material where user_id = #{userId})
+            ((a.num + 0) <![CDATA[>]]> (
+                IFNULL(a.out_num, 0) + 0) or ((a.num like '-%') and ((a.num + 0) != (a.out_num + 0)))) and b.code in (select material_id from tld_user_material where user_id = #{userId})
           and b.part_type != '半成品' and b.part_type != '产成品'
     </select>
     <!-- 查询半成品入库任务数量 -->
@@ -1527,8 +1528,8 @@
         join tld_ask_goods_f b on a.ask_goods_id = b.ask_goods_id
         join tld_material e on a.material_id = e.tld_id
         where e.code in ( SELECT material_id FROM tld_user_material WHERE user_id = #{userId} )
-          and (a.num + 0) <![CDATA[>]]> (
-            IFNULL(a.out_num, 0) + 0) and e.part_type != '半成品' and e.part_type != '产成品'
+          and ((a.num + 0) <![CDATA[>]]> (
+                IFNULL(a.out_num, 0) + 0) or ((a.num like '-%') and ((a.num + 0) != (a.out_num + 0)))) and e.part_type != '半成品' and e.part_type != '产成品'
         group by b.sqrq
         order by b.sqrq desc
     </select>
@@ -1540,8 +1541,9 @@
         join tld_invite_f b on a.ask_goods_id = b.ask_goods_id
         join tld_material e on a.material_id = e.tld_id
         where e.code in ( SELECT material_id FROM tld_user_material WHERE user_id = #{userId} )
-          and (a.num + 0) <![CDATA[>]]> (
-            IFNULL(a.out_num, 0) + 0) and e.part_type != '半成品' and e.part_type != '产成品'
+          and ((a.num + 0) <![CDATA[>]]> (
+            IFNULL(a.out_num, 0) + 0) or ((a.num like '-%') and ((a.num + 0) != (a.out_num + 0))))
+        and e.part_type != '半成品' and e.part_type != '产成品'
         group by b.sqrq
         order by b.sqrq desc
     </select>
@@ -1555,8 +1557,8 @@
         join tld_department c on b.department = c.code
         join tld_material e on a.material_id = e.tld_id
         where e.code IN ( SELECT material_id FROM tld_user_material WHERE user_id = #{userId} )
-          and (a.num + 0) <![CDATA[>]]> (
-            IFNULL(a.out_num, 0) + 0) and e.part_type != '半成品' and e.part_type != '产成品'
+          and ((a.num + 0) <![CDATA[>]]> (
+            IFNULL(a.out_num, 0) + 0) or ((a.num like '-%') and ((a.num + 0) != (a.out_num + 0)))) and e.part_type != '半成品' and e.part_type != '产成品'
           and b.sqrq = #{sqrq}
         group by c.name,c.code
     </select>
@@ -1570,8 +1572,9 @@
         join tld_department c on b.department = c.code
         join tld_material e on a.material_id = e.tld_id
         where e.code IN ( SELECT material_id FROM tld_user_material WHERE user_id = #{userId} )
-          and (a.num + 0) <![CDATA[>]]> (
-            IFNULL(a.out_num, 0) + 0) and e.part_type != '半成品' and e.part_type != '产成品'
+          and ((a.num + 0) <![CDATA[>]]> (
+            IFNULL(a.out_num, 0) + 0) or ((a.num like '-%') and ((a.num + 0) != (a.out_num + 0))))
+        and e.part_type != '半成品' and e.part_type != '产成品'
           and b.sqrq = #{sqrq}
         group by c.name,c.code
     </select>
@@ -1584,7 +1587,8 @@
         WHERE
             b.sqrq = #{sqrq} AND b.department = #{department}
           AND e.code IN ( SELECT material_id FROM tld_user_material WHERE user_id = #{userId} )
-          AND e.part_type != '半成品' AND e.part_type != '产成品' AND (a.num + 0) <![CDATA[>]]> (IFNULL(a.out_num, 0) + 0)
+          AND e.part_type != '半成品' AND e.part_type != '产成品' AND ((a.num + 0) <![CDATA[>]]> (
+                IFNULL(a.out_num, 0) + 0) or ((a.num like '-%') and ((a.num + 0) != (a.out_num + 0))))
     </select>
     <!-- 查询指定参数的要货单 -->
     <select id="getInviteInfo" resultType="com.tld.model.AskGoods">
@@ -1595,7 +1599,8 @@
         WHERE
             b.sqrq = #{sqrq} AND b.department = #{department}
           AND e.code IN ( SELECT material_id FROM tld_user_material WHERE user_id = #{userId} )
-          AND e.part_type != '半成品' AND e.part_type != '产成品' AND (a.num + 0) <![CDATA[>]]> (IFNULL(a.out_num, 0) + 0)
+          AND e.part_type != '半成品' AND e.part_type != '产成品' AND ((a.num + 0) <![CDATA[>]]> (
+                IFNULL(a.out_num, 0) + 0) or ((a.num like '-%') and ((a.num + 0) != (a.out_num + 0))))
     </select>
     <!--查询错误日志添加到Excel表-->
     <select id="getErrorList" resultType="com.tld.model.Error">