zhs преди 2 години
родител
ревизия
b8eca96706

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

@@ -40,4 +40,6 @@ public interface WarehouseTransferMapper {
     WarehouseTransfer getAsknInfo(AskGoods askGoods);
 
     List<Inventory> getMaterialWarehouseTransfer(AskGoods askGoods);
+
+    Inventory getInventoryVitrual(AskGoods askGoods);
 }

+ 4 - 0
src/main/java/com/tld/model/WarehouseTransfer.java

@@ -122,4 +122,8 @@ public class WarehouseTransfer {
      * 供货仓库状态
      */
     private String suppType;
+    /**
+     * 是否推荐库位 产成品用
+     */
+    private String isRecommend;
 }

+ 6 - 0
src/main/java/com/tld/service/impl/AskGoodsServiceImpl.java

@@ -163,6 +163,9 @@ public class AskGoodsServiceImpl implements AskGoodsService {
     @Transactional(rollbackFor = Exception.class)
     public Map<String, Object> addAskGoodsVitrual(AskGoods askGoods) {
         Map<String, Object> map = new HashMap<>();
+        //redis并发锁
+        RLock lock = redissonClient.getLock(askGoods.getUniqueCode());
+        lock.lock();
         try{
             Map<String, Object> mapVal = askGoodsMapper.getScanIsNot(askGoods);
             if((Double.parseDouble(mapVal.get("inventoryNum").toString()) - Double.parseDouble(mapVal.get("virtualNum").toString())) == 0){
@@ -189,6 +192,9 @@ public class AskGoodsServiceImpl implements AskGoodsService {
             e.printStackTrace();
             map.put("msg", "500");
             map.put("errMsg", "失败");
+        } finally {
+            //释放锁
+            lock.unlock();
         }
         return map;
     }

+ 28 - 8
src/main/java/com/tld/service/impl/WarehouseTransferServiceImpl.java

@@ -83,12 +83,17 @@ public class WarehouseTransferServiceImpl implements WarehouseTransferService {
                 MaterialClass material = warehousingMapper.getMaterial(new Notice().setMaterialCode(askGoods.getWllbCode()));
                 Inventory inventory = new Inventory();
                 askGoods.setCompanyNumber(askGoods.getAccountSleeve());
+                askGoods.setMaterialId(material.getTldId());
                 if(material.getPartType().equals("原材料")) {
                     inventory = askGoodsMapper.getInventory(askGoods);
                 } else if(material.getPartType().equals("产成品")) {
                     inventory = deliveryMapper.getInventoryHalf(askGoods);
                 } else if(material.getPartType().equals("半成品")) {
-                    inventory = askGoodsMapper.getInventoryInfo(askGoods).get(0);
+                    if(askGoodsMapper.getInventoryInfo(askGoods).size() != 0){
+                        inventory = askGoodsMapper.getInventoryInfo(askGoods).get(0);
+                    } else {
+                        inventory = null;
+                    }
                 }
                 if(inventory == null){
                     map.put("msg", "500");
@@ -127,11 +132,21 @@ public class WarehouseTransferServiceImpl implements WarehouseTransferService {
                 askGoodsMapper.deleteVirtual(askGoods.getId());//删除已出虚拟表库存
                 warehouseTransferMapper.updateOutNum(askGoods.getNum(), askGoodsId, materialId);//修改出库数量
                 if(askGoods.getStorageLocationCodeRk().indexOf("XNKW") != -1){
-                    Inventory inventory1 = new Inventory()
-                            .setNum(askGoods.getNum())
-                            .setMaterialId(materialId)
-                            .setStorageLocationCode(askGoods.getStorageLocationCodeRk());
-                    warehousingMapper.updateVitrualNum(inventory1);
+                    Inventory inventory2 = warehouseTransferMapper.getInventoryVitrual(askGoods);
+                    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);//库存
+                    }
                 }
                 WarehouseTransfer warehouseTransfer1 = new WarehouseTransfer()
                         .setWarehouseTransferId(warehouseTransfer.getWarehouseTransferId()) //移库单id
@@ -221,7 +236,6 @@ public class WarehouseTransferServiceImpl implements WarehouseTransferService {
                 } else if(material.getPartType().equals("半成品")){
                     inventory = askGoodsMapper.getInventoryInfo(askGoods).get(0);
                 }
-
                 //如果出库库存等于虚拟表库存则删除此库存
                 if(Integer.parseInt(askGoods.getNum()) == Integer.parseInt(inventory.getAmount())){
                     askGoodsMapper.deleteInventory(inventory);
@@ -231,7 +245,6 @@ public class WarehouseTransferServiceImpl implements WarehouseTransferService {
                 }
                 askGoodsMapper.addRemoval(askGoods);//插入出库流水
 
-
                 WarehouseTransfer warehouseTransfer1 = new WarehouseTransfer()
                         .setWarehouseTransferId(warehouseTransfer.getWarehouseTransferId()) //移库单id
                         .setEntryNumber(warehouseTransfer.getEntryNumber())//分录号
@@ -298,6 +311,13 @@ public class WarehouseTransferServiceImpl implements WarehouseTransferService {
     public Map<String, Object> addAskGoodsVitrual(AskGoods askGoods) {
         Map<String, Object> map = new HashMap<>();
         try{
+            askGoods.setAccountSleeve(askGoods.getCompanyNumber());
+            List<Inventory> inventory = askGoodsMapper.getInventoryInfo(askGoods);
+            if(inventory.size() == 0){
+                map.put("msg", "500");
+                map.put("errMsg", "库存数量不足");
+                return map;
+            }
             askGoodsMapper.addAskGoodsVitrual(askGoods);
             map.put("msg", "200");
         }catch (Exception e){

+ 3 - 3
src/main/resources/mapper/AskGoodsMapper.xml

@@ -147,7 +147,7 @@
             wllb_code,
             produc_date,
             scrq
-        from tld_inventory where supplier_id = #{supplierId} and wllb_code = #{wllbCode} and produc_date = #{producDate} and account_sleeve = #{companyNumber} and wbs = #{wbs}
+        from tld_inventory where storage_location_code = #{storageLocationCode} and wllb_code = #{wllbCode} and account_sleeve = #{companyNumber} and wbs = #{wbs}
     </select>
     <!-- 查询库存是否充足 -->
     <select id="getAsk" resultType="com.tld.model.AskGoods">
@@ -627,8 +627,8 @@
         <if test="attribute != '' and attribute != null">
             and attribute = #{attribute}
         </if>
-        <if test="producBatch != '' and producBatch != null">
-            and produc_batch = #{producBatch}
+        <if test="producDate != '' and producDate != null">
+            and produc_batch = #{producDate}
         </if>
         <if test="supplierId != '' and supplierId != null">
             and supplier_id = #{supplierId}

+ 29 - 0
src/main/resources/mapper/WarehouseTransferMapper.xml

@@ -22,6 +22,7 @@
             c.name as materialName,
             c.code as materialCode,
             c.part_type as partType,
+            c.is_recommend as isRecommend,
             f.name as askGoodsWarehouseaName,
             e.name as supplyWarehouseName,
             ifnull(f.warehouse_type, 10) as askType,
@@ -196,4 +197,32 @@
         </if>
         order by a.produc_date
     </select>
+    <!-- 查询是否存在虚拟库存 -->
+    <select id="getInventoryVitrual" resultType="com.tld.model.Inventory">
+        select
+            id,
+            storage_location_code,
+            wllb_class,
+            library_type,
+            material_id,
+            amount,
+            total,
+            totime,
+            hold,
+            amount_lock,
+            account_sleeve,
+            wbs,
+            supplier_id,
+            serial,
+            wllb_code,
+            produc_date,
+            scrq
+        from tld_inventory where storage_location_code = #{storageLocationCodeRk} and material_id = #{materialId}
+        <if test="accountSleeve != null and accountSleeve != ''">
+            and account_sleeve = #{accountSleeve}
+        </if>
+        <if test="wbs != null and wbs != ''">
+            and wbs = #{wbs}
+        </if>
+    </select>
 </mapper>