zhs %!s(int64=2) %!d(string=hai) anos
pai
achega
ebdae34c52

+ 8 - 0
src/main/java/com/tld/mapper/DeliveryMapper.java

@@ -51,4 +51,12 @@ public interface DeliveryMapper {
     void addRemovalHalfProduct(Delivery delivery1);
 
     Inventory getTemporarily(AskGoods askGoods);
+
+    Delivery getDeliveryInfo(AskGoods askGoods);
+
+    Inventory getInventoryVal(String id);
+
+    String getScanNumDelivery(AskGoods askGoods);
+
+    String getAllScanNumDelivery(AskGoods askGoods);
 }

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

@@ -267,6 +267,21 @@ public class DeliveryServiceImpl implements DeliveryService {
                 map.put("errMsg", "已全部出库");
                 return map;
             }
+            //判断物料是否录入
+            MaterialClass materialClass = warehousingMapper.getMateriaIsExist(askGoods.getWllbCode());
+            if(!materialClass.getPartType().equals("产成品")){
+                Delivery delivery = deliveryMapper.getDeliveryInfo(askGoods); //需求数量、已出数量
+                String scanNum = deliveryMapper.getScanNumDelivery(askGoods); //单据扫描数量
+                Inventory inventory = deliveryMapper.getInventoryVal(askGoods.getId());//库存数量
+                String allScanNum = deliveryMapper.getAllScanNumDelivery(askGoods); //虚拟表此物料占用数量
+                //剩余出库数量
+                Double num = Double.parseDouble(delivery.getGsDeliveryNum()) - Double.parseDouble(delivery.getOutNum()) - Double.parseDouble(scanNum);
+                if(Double.doubleToLongBits(Double.parseDouble(inventory.getAmount()) - Double.parseDouble(allScanNum) - num) >= 0){
+                    askGoods.setNum(num.toString());
+                } else {
+                    askGoods.setNum((Double.parseDouble(inventory.getAmount()) - Double.parseDouble(allScanNum)) + "");
+                }
+            }
             askGoodsMapper.addAskGoodsVitrual(askGoods);
             map.put("msg", "200");
         }catch (Exception e){

+ 6 - 1
src/main/resources/mapper/AskGoodsMapper.xml

@@ -78,6 +78,7 @@
                IFNULL(a.out_num, 0) AS out_num,
                e.NAME               AS materialName,
                e.CODE               AS materialCode,
+               e.part_type as partType,
                b.ask_goods_code,
                b.company_number,
                b.sqrq,
@@ -94,7 +95,7 @@
         JOIN tld_material e ON a.material_id = e.tld_id
         WHERE (a.num + 0) <![CDATA[>]]> (
             IFNULL(a.out_num, 0) + 0)
-          and e.part_type != '半成品' and e.part_type != '产成品' and b.sqrq <![CDATA[<]]> "2023-05-06"
+          and e.part_type != '半成品' and e.part_type != '产成品'
     </select>
     <!-- 物料库位选择 -->
     <select id="getMaterialCk" resultType="com.tld.model.Inventory">
@@ -252,6 +253,8 @@
         from tld_ask_goods_vitrual
         where wllb_code = #{wllbCode}
           and ask_goods_id = #{askGoodsId}
+          and account_sleeve = #{accountSleeve}
+          and wbs = #{wbs}
           and type = #{type}
     </select>
     <!-- 查询此库存在虚拟表里占用的数量 -->
@@ -262,6 +265,8 @@
           and serial = #{serial}
           and wllb_code = #{wllbCode}
           and produc_date = #{producDate}
+          and account_sleeve = #{accountSleeve}
+          and wbs = #{wbs}
           and type = #{type}
     </select>
     <!-- 查询虚拟表指定pda跟状态的的数据 -->

+ 26 - 1
src/main/resources/mapper/DeliveryMapper.xml

@@ -217,7 +217,10 @@
             (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}
               <if test="serial != null and serial !=''">
                   and serial = #{serial}
-              </if>) as vitrualNum
+              </if>
+            <if test="attribute != null and attribute !=''">
+                and attribute = #{attribute}
+            </if>) as vitrualNum
         from dual
     </select>
     <!-- 查询销售交货单原始数据 -->
@@ -290,4 +293,26 @@
         insert into tld_removal_half_product(wllb_code,num,user_id,scrq,ask_goods_id,storage_code,wbs,company_number,transmission_type)
             value(#{materialCode},#{outNum},#{userId},now(),#{deliveryId},#{storageCode},#{wbs},#{companyNumber},0)
     </insert>
+    <!-- 查询销售订单 -->
+    <select id="getDeliveryInfo" resultType="com.tld.model.Delivery">
+        select out_num,gs_delivery_num from tld_delivery where delivery_id = #{askGoodsId} and entry_number = #{entryNumber}
+    </select>
+    <!-- 查询指定库存 -->
+    <select id="getInventoryVal" resultType="com.tld.model.Inventory">
+        select amount from tld_inventory where id = #{id}
+    </select>
+    <!-- 查询指定销售单扫描数量 -->
+    <select id="getScanNumDelivery" resultType="String">
+        select ifnull(sum(num), 0) as num from tld_ask_goods_vitrual where ask_goods_id = #{askGoodsId} and entry_number = #{entryNumber}
+    </select>
+    <!-- 虚拟表此物料占用数量 -->
+    <select id="getAllScanNumDelivery" resultType="String">
+        select ifnull(sum(num), 0) as num from tld_ask_goods_vitrual where wllb_code = #{wllbCode} and account_sleeve = #{accountSleeve} and wbs = #{wbs}
+        <if test="producDate != null and producDate != ''">
+            and produc_date = #{producDate}
+        </if>
+        <if test="serial != null and serial != ''">
+            and serial = #{serial}
+        </if>
+    </select>
 </mapper>