Kaynağa Gözat

问题修改

zhs 2 yıl önce
ebeveyn
işleme
4d9218650f

+ 1 - 1
src/main/java/com/tld/mapper/WarehousingMapper.java

@@ -103,7 +103,7 @@ public interface WarehousingMapper {
 
     Map<String, Object> getScanIsNotProduct(Notice notice);
 
-    String getStorageLocationCode(@Param("attribute")String attribute, @Param("symbol")String symbol, @Param("producBatch")String producBatch, @Param("materialId")String materialId);
+    String getStorageLocationCode(@Param("attribute")String attribute, @Param("symbol")String symbol, @Param("producBatch")String producBatch, @Param("materialId")String materialId, @Param("companyNumber")String companyNumber);
 
     int getCountStorage(@Param("attribute")String attribute, @Param("storageLocationCode")String storageLocationCode, @Param("symbol")String symbol, @Param("producBatch")String producBatch, @Param("materialId")String materialId);
 

+ 27 - 15
src/main/java/com/tld/service/impl/DeliveryServiceImpl.java

@@ -3,6 +3,7 @@ package com.tld.service.impl;
 import com.tld.mapper.AskGoodsMapper;
 import com.tld.mapper.DeliveryMapper;
 import com.tld.mapper.DictionaryMapper;
+import com.tld.mapper.WarehousingMapper;
 import com.tld.model.*;
 import com.tld.service.DeliveryService;
 import org.redisson.api.RLock;
@@ -28,6 +29,9 @@ public class DeliveryServiceImpl implements DeliveryService {
     //删除日志表
     @Autowired
     private DictionaryMapper dictionaryMapper;
+    //入库
+    @Autowired
+    private WarehousingMapper warehousingMapper;
 
     @Override
     public Map<String, Object> getDelivery(Delivery delivery) {
@@ -126,6 +130,8 @@ public class DeliveryServiceImpl implements DeliveryService {
         try{
             String removalCode = codeGenerateCk();
             for(AskGoods askGoods : askGoodsMapper.getAskGoodsVitrual(uniqueCode, type)){
+                askGoods.setStorageCode(removalCode);
+                askGoods.setCompanyNumber(askGoods.getAccountSleeve());
                 Inventory inventory = deliveryMapper.getInventoryHalf(askGoods);
                 //如果出库库存等于虚拟表库存则删除此库存
                 if(Integer.parseInt(askGoods.getNum()) == Integer.parseInt(inventory.getAmount())){
@@ -134,25 +140,31 @@ public class DeliveryServiceImpl implements DeliveryService {
                     inventory.setAmount(askGoods.getNum());
                     askGoodsMapper.updateInventory(inventory);
                 }
-                String materialId = askGoodsMapper.getMaterialId(askGoods.getWllbCode());//查询物料id
-                deliveryMapper.updateDelivery(materialId, askGoods.getNum(), deliveryId); //修改销售单出库数量
+                //判断物料是否录入
+                MaterialClass materialClass = warehousingMapper.getMateriaIsExist(askGoods.getWllbCode());
+                deliveryMapper.updateDelivery(materialClass.getTldId(), askGoods.getNum(), deliveryId); //修改销售单出库数量
                 //查询销售单部分信息
-                Delivery delivery = new Delivery().setDeliveryId(deliveryId).setMaterialId(materialId);
+                Delivery delivery = new Delivery().setDeliveryId(deliveryId).setMaterialId(materialClass.getTldId());
                 List<Delivery> list = deliveryMapper.getDelivery(delivery);
-                //产成品销售流水
-                Delivery delivery1 = new Delivery()
-                        .setMaterialCode(askGoods.getWllbCode()) //物料code
-                        .setOutNum(askGoods.getNum()) //出库数量
-                        .setUserId(askGoods.getUserId()) //用户id
-                        .setDeliveryId(deliveryId) //销售单id
-                        .setCompanyNumber(list.get(0).getCompanyNumber()) //公司编号
-                        .setCustomerCode(list.get(0).getCustomerCode())//客户编号
-                        .setStorageCode(removalCode) //出库流水
-                        .setWbs(list.get(0).getWbs());// wbs
-                deliveryMapper.addRemovalHalf(delivery1); //流水录入
+                if(materialClass.getPartType().equals("产成品")){
+                    //产成品销售流水
+                    Delivery delivery1 = new Delivery()
+                            .setMaterialCode(askGoods.getWllbCode()) //物料code
+                            .setOutNum(askGoods.getNum()) //出库数量
+                            .setUserId(askGoods.getUserId()) //用户id
+                            .setDeliveryId(deliveryId) //销售单id
+                            .setCompanyNumber(list.get(0).getCompanyNumber()) //公司编号
+                            .setCustomerCode(list.get(0).getCustomerCode())//客户编号
+                            .setStorageCode(removalCode) //出库流水
+                            .setWbs(list.get(0).getWbs());// wbs
+                    deliveryMapper.addRemovalHalf(delivery1); //流水录入
+                } else if(materialClass.getPartType().equals("原材料")){
+                    askGoods.setType("销售出库");
+                    askGoodsMapper.addRemoval(askGoods);//插入出库流水
+                }
                 askGoodsMapper.deleteVirtual(askGoods.getId());//删除已出虚拟表库存
                 ReturRemoval returRemoval = new ReturRemoval()
-                        .setMaterialId(materialId)
+                        .setMaterialId(materialClass.getTldId())
                         .setDocumentId(deliveryId)
                         .setWbs(list.get(0).getWbs())
                         .setNum(askGoods.getNum())

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

@@ -566,7 +566,7 @@ public class WarehousingServiceImpl implements WarehousingService {
                 return map;
             }
             Notice notice1 = warehousingMapper.getNoticeId(new Notice().setNoticeId(notice.getNoticeId()).setMaterialId(notice.getMaterialId()));
-            Double contrast = Double.parseDouble(notice1.getWarehousingNum()) + Double.parseDouble(notice.getNum());
+            Double contrast = Double.parseDouble(notice1.getWarehousingNum()) + Double.parseDouble(notice.getWarehousingNum());
             if(Double.doubleToLongBits(contrast) > Double.doubleToLongBits(Double.parseDouble(notice1.getNum()))){
                 map.put("msg", "500");
                 map.put("errMsg", "扫描数量超出报工单数量");
@@ -583,7 +583,7 @@ public class WarehousingServiceImpl implements WarehousingService {
                         if(symbol[i].equals("=")){
                             producBatch = notice.getProducBatch();
                         }
-                        String storageLocationCode = warehousingMapper.getStorageLocationCode(notice.getAttribute(), symbol[i], producBatch, material.getTldId()); //查询昨天没满的库位
+                        String storageLocationCode = warehousingMapper.getStorageLocationCode(notice.getAttribute(), symbol[i], producBatch, material.getTldId(), notice.getCompanyNumber()); //查询昨天没满的库位
                         if(!storageLocationCode.equals("0")) {
                             int countStorage = warehousingMapper.getCountStorage(notice.getAttribute(), storageLocationCode, symbol[i], producBatch, material.getTldId());
                             if (countStorage < num) {

+ 13 - 4
src/main/resources/mapper/DeliveryMapper.xml

@@ -58,8 +58,8 @@
         FROM tld_inventory a
         LEFT JOIN tld_storage_location b on a.storage_location_code = b.storage_location_code
         WHERE #{storageLocationCode} LIKE CONCAT( '%', CONCAT( a.storage_location_code, ',' ), '%' )
-          AND a.material_id = #{delivery.materialId} AND a.hold = '0' AND a.wbs = #{delivery.wbs} and a.account_sleeve = #{item.companyNumber}
-        <if test="delivery.attribute != null and delivery.attribute != ''">
+          AND a.material_id = #{delivery.materialId} AND a.hold = '0' AND a.wbs = #{delivery.wbs} and a.account_sleeve = #{delivery.companyNumber}
+        <if test="delivery.attribute != null">
             and a.attribute = #{delivery.attribute}
         </if>
         ORDER BY
@@ -85,7 +85,16 @@
             b.storage_location_name as storageLocationName
         FROM tld_inventory a
         JOIN tld_material b on a.material_id = b.tld_id
-        WHERE a.attribute = #{attribute} and a.produc_batch = #{producDate} and a.serial = #{serial} and b.code = #{wllbCode} and a.account_sleeve = #{companyNumber} and wbs = #{wbs}
+        WHERE b.code = #{wllbCode} and a.account_sleeve = #{companyNumber} and a.wbs = #{wbs}
+        <if test="attribute != null and attribute != ''">
+            and a.attribute = #{attribute}
+        </if>
+        <if test="producDate != null and producDate != ''">
+            and a.produc_batch = #{producDate}
+        </if>
+        <if test="serial != null and serial != ''">
+            and a.serial = #{serial}
+        </if>
     </select>
     <!-- 查询指定库存被占用数量 -->
     <select id="getVitrual" resultType="int">
@@ -161,7 +170,7 @@
     <select id="getScanIsNot" resultType="java.util.Map">
         select
             (select ifnull(amount,0) from tld_inventory where id = #{id}) as amount,
-            (select ifnull(sum(num),0) from tld_ask_goods_vitrual where wbs = #{wbs} and wllb_code = #{wllbCode} and storage_location_code = #{storageLocationCode} and produc_date = #{producDate}) as vitrualNum
+            (select ifnull(sum(num),0) from tld_ask_goods_vitrual where wbs = #{wbs} and wllb_code = #{wllbCode} and storage_location_code = #{storageLocationCode} and produc_date = #{producDate} and account_sleeve = #{companyNumber}) as vitrualNum
         from dual
     </select>
     <!-- 查询销售交货单原始数据 -->

+ 1 - 1
src/main/resources/mapper/WarehousingMapper.xml

@@ -918,7 +918,7 @@
     <select id="getStorageLocationCode" resultType="String">
         SELECT ifnull(max(storage_location_code), "0")
         FROM tld_inventory
-        WHERE attribute = #{attribute} and DATE_FORMAT(scrq,'%Y-%m-%d') <![CDATA[${symbol}]]> CURDATE() and material_id = #{materialId}
+        WHERE attribute = #{attribute} and DATE_FORMAT(scrq,'%Y-%m-%d') <![CDATA[${symbol}]]> CURDATE() and material_id = #{materialId} and account_sleeve = #{companyNumber}
         <if test="producBatch != null">
             and produc_batch = #{producBatch}
         </if>