Browse Source

问题修改

zhs 2 years ago
parent
commit
a6ffbf8e28

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

@@ -29,6 +29,16 @@ public class DeliveryController {
         return deliveryService.getDelivery(delivery);
     }
 
+    /**
+     * 推荐属性列表
+     * @param delivery 参数
+     * @return 返回结果
+     */
+    @GetMapping("getAttribute")
+    public Map<String, Object> getAttribute(Delivery delivery){
+        return deliveryService.getAttribute(delivery);
+    }
+
     /**
      * 推荐库位
      * @param delivery 参数

+ 44 - 0
src/main/java/com/tld/controller/QueryListController.java

@@ -0,0 +1,44 @@
+package com.tld.controller;
+
+import com.tld.model.Inventory;
+import com.tld.service.QueryListService;
+import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Map;
+
+/**
+ * 查询列表
+ */
+@RestController
+@RequestMapping("queryList")
+@RequiredArgsConstructor
+public class QueryListController {
+
+    private final QueryListService queryListService;
+
+    /**
+     * 呆滞品查询
+     * @param inventory 参数
+     * @return 返回结果
+     */
+    @GetMapping("dullGoods")
+    public Map<String, Object> dullGoods(Inventory inventory){
+        return queryListService.dullGoods(inventory);
+    }
+
+    /**
+     * 物料储量预警查询
+     * @param wllbCode 物料编号
+     * @param page 页数
+     * @param limit 条数
+     * @return 返回结果
+     */
+    @GetMapping("reserveWarning")
+    public Map<String, Object> reserveWarning(String wllbCode, int page, int limit){
+        return queryListService.reserveWarning(wllbCode, page, limit);
+    }
+}
+

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

@@ -91,5 +91,5 @@ public interface AskGoodsMapper {
 
     List<Map<String, Object>> getRemovalHalfExcel(AskGoods askGoods);
 
-    Inventory getInventoryInfo(AskGoods askGoods);
+    List<Inventory> getInventoryInfo(AskGoods askGoods);
 }

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

@@ -25,4 +25,8 @@ public interface DeliveryMapper {
     void addRemovalHalf(Delivery delivery1);
 
     Delivery getDeliveryF(String deliveryId);
+
+    List<Inventory> getAttribute(String storageLocationCode, Delivery delivery);
+
+    int getSumAmount(Inventory inventory);
 }

+ 16 - 0
src/main/java/com/tld/mapper/QueryListMapper.java

@@ -0,0 +1,16 @@
+package com.tld.mapper;
+
+import com.tld.model.Inventory;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+import java.util.Map;
+
+@Mapper
+public interface QueryListMapper {
+    List<Map<String, Object>> dullGoods(Inventory inventory);
+
+    Map<String, Object> reserveWarning(Map<String, Object> map);
+
+    List<Map<String, Object>> getMaterial(String wllbCode);
+}

+ 4 - 0
src/main/java/com/tld/mapper/WarehousingMapper.java

@@ -102,4 +102,8 @@ public interface WarehousingMapper {
     void updateNotice(Notice notice2);
 
     Map<String, Object> getScanIsNotProduct(Notice notice);
+
+    String getStorageLocationCode(@Param("attribute")String attribute, @Param("symbol")String symbol);
+
+    int getCountStorage(@Param("attribute")String attribute, @Param("storageLocationCode")String storageLocationCode, @Param("symbol")String symbol);
 }

+ 8 - 0
src/main/java/com/tld/model/Inventory.java

@@ -96,4 +96,12 @@ public class Inventory implements Serializable {
      * 出货仓库
      */
     private String warehouseWhere;
+    /**
+     * 页数
+     */
+    private int page;
+    /**
+     * 条数
+     */
+    private int limit;
 }

+ 8 - 0
src/main/java/com/tld/model/MaterialClass.java

@@ -60,6 +60,14 @@ public class MaterialClass implements Serializable {
      * 物料类别
      */
     private String partType;
+    /**
+     * 最少数量
+     */
+    private String minNum;
+    /**
+     * 最高数量
+     */
+    private String maxNum;
     /**
      * 页数
      */

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

@@ -10,4 +10,6 @@ public interface DeliveryService {
     Map<String, Object> getRecommend(Delivery delivery);
 
     Map<String, Object> OutOfLibrary(String uniqueCode, String type, String deliveryId);
+
+    Map<String, Object> getAttribute(Delivery delivery);
 }

+ 11 - 0
src/main/java/com/tld/service/QueryListService.java

@@ -0,0 +1,11 @@
+package com.tld.service;
+
+import com.tld.model.Inventory;
+
+import java.util.Map;
+
+public interface QueryListService {
+    Map<String, Object> dullGoods(Inventory inventory);
+
+    Map<String, Object> reserveWarning(String wllbCode, int page, int limit);
+}

+ 11 - 10
src/main/java/com/tld/service/impl/AskGoodsServiceImpl.java

@@ -507,23 +507,23 @@ public class AskGoodsServiceImpl implements AskGoodsService {
                 askGoods.setStorageLocationCode("111111");
             }
             //查询库存
-            Inventory inventory = askGoodsMapper.getInventoryInfo(askGoods);
-            if(inventory == null){
+            List<Inventory> inventory = askGoodsMapper.getInventoryInfo(askGoods);
+            if(inventory.size() == 0){
                 map.put("msg", "500");
                 map.put("errMsg", "未查询到该库位的库存");
                 return map;
             }
-            if(Integer.parseInt(inventory.getAmount()) < Integer.parseInt(askGoods.getNum())){
+            if(Integer.parseInt(inventory.get(0).getAmount()) < Integer.parseInt(askGoods.getNum())){
                 map.put("msg", "500");
                 map.put("errMsg", "库存数量不足");
                 return map;
             }
             //如果出库库存等于虚拟表库存则删除此库存
-            if(Integer.parseInt(askGoods.getNum()) == Integer.parseInt(inventory.getAmount())){
-                askGoodsMapper.deleteInventory(inventory);
+            if(Integer.parseInt(askGoods.getNum()) == Integer.parseInt(inventory.get(0).getAmount())){
+                askGoodsMapper.deleteInventory(inventory.get(0));
             } else {
-                inventory.setAmount(askGoods.getNum());
-                askGoodsMapper.updateInventory(inventory);
+                inventory.get(0).setAmount(askGoods.getNum());
+                askGoodsMapper.updateInventory(inventory.get(0));
             }
             if(material.getPartType().equals("半成品")){
                 //新增半成品出库流水
@@ -545,9 +545,10 @@ public class AskGoodsServiceImpl implements AskGoodsService {
                         .setCustomerCode(""); //客户编号
                 deliveryMapper.addRemovalHalf(delivery1); //流水录入
             } else {
-                askGoods.setSupplierId(inventory.getSupplierId());
+                askGoods.setSupplierId(inventory.get(0).getSupplierId());
                 askGoods.setType("其他出库");
-                askGoods.setProducDate(inventory.getProducDate());
+                askGoods.setProducDate(inventory.get(0).getProducDate());
+                askGoods.setSerial(inventory.get(0).getSerial());
                 askGoodsMapper.addRemoval(askGoods);//插入出库流水
             }
             //新增返回gs信息
@@ -556,7 +557,7 @@ public class AskGoodsServiceImpl implements AskGoodsService {
                     .setMaterialId(material.getTldId())
                     .setWbs(askGoods.getWbs())
                     .setNum(askGoods.getNum())
-                    .setStorageLocationCode(inventory.getStorageLocationCode())
+                    .setStorageLocationCode(inventory.get(0).getStorageLocationCode())
                     .setRemovalCode(removalCode)
                     .setSourceType("0")
                     .setMoveType("209")

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

@@ -133,6 +133,33 @@ public class DeliveryServiceImpl implements DeliveryService {
         return map;
     }
 
+    @Override
+    public Map<String, Object> getAttribute(Delivery delivery) {
+        Map<String, Object> map = new HashMap<>();
+        try{
+            //查询所有产成品库位
+            String storageLocationCode = deliveryMapper.getStorageLocationCodeList();
+            List<Inventory> list = new LinkedList<>();
+            Map<String, Object> occupyMap = new HashMap<>();
+            for(Inventory inventory : deliveryMapper.getAttribute(storageLocationCode, delivery)){
+                int amount = deliveryMapper.getSumAmount(inventory);
+                int occupy = deliveryMapper.getVitrual(inventory);
+                int num = Integer.parseInt(inventory.getAmount()) - occupy;
+                if(amount > (occupy + Integer.parseInt(delivery.getOutNum()))){
+                    list.add(inventory);
+                    occupyMap.put(inventory.getStorageLocationCode(), num);
+                }
+            }
+            map.put("data", list);
+            map.put("msg", "200");
+        }catch (Exception e){
+            map.put("msg", "500");
+            map.put("errMsg", "服务器请求异常,请稍后再试");
+            e.printStackTrace();
+        }
+        return map;
+    }
+
     /**
      * 出库单生成
      * @return

+ 0 - 1
src/main/java/com/tld/service/impl/DictionaryServiceImpl.java

@@ -24,7 +24,6 @@ public class DictionaryServiceImpl implements DictionaryService {
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Map<String, Object> addDictionary(List<Dictionary> dictionarys) {
-
         Map<String, Object> map = new HashMap<>();
         try{
             for(Dictionary dictionary : dictionarys) {

+ 58 - 0
src/main/java/com/tld/service/impl/QueryListServiceImpl.java

@@ -0,0 +1,58 @@
+package com.tld.service.impl;
+
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.tld.mapper.QueryListMapper;
+import com.tld.model.Inventory;
+import com.tld.model.Notice;
+import com.tld.service.QueryListService;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+@Service
+@RequiredArgsConstructor
+public class QueryListServiceImpl implements QueryListService {
+
+    private final QueryListMapper queryListMapper;
+
+    @Override
+    public Map<String, Object> dullGoods(Inventory inventory) {
+        Map<String, Object> map = new HashMap<>();
+        try{
+            PageHelper.startPage(inventory.getPage(), inventory.getLimit());
+            PageInfo<Map<String, Object>> list = new PageInfo<>(queryListMapper.dullGoods(inventory));
+            map.put("data", list);
+            map.put("msg", "200");
+        } catch (Exception e){
+            e.printStackTrace();
+            map.put("msg", "500");
+            map.put("errMsg", "服务器请求异常,请稍后再试");
+        }
+        return map;
+    }
+
+    @Override
+    public Map<String, Object> reserveWarning(String wllbCode, int page, int limit) {
+        Map<String, Object> map = new HashMap<>();
+        try{
+            List<Map<String, Object>> mapList = new LinkedList<>();
+            PageHelper.startPage(page, limit);
+            PageInfo<Map<String, Object>> list = new PageInfo<>(queryListMapper.getMaterial(wllbCode));
+            for(Map<String, Object> data : list.getList()){
+                mapList.add(queryListMapper.reserveWarning(data));
+            }
+            map.put("data", mapList);
+            map.put("msg", "200");
+        } catch (Exception e){
+            e.printStackTrace();
+            map.put("msg", "500");
+            map.put("errMsg", "服务器请求异常,请稍后再试");
+        }
+        return map;
+    }
+}

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

@@ -544,31 +544,34 @@ public class WarehousingServiceImpl implements WarehousingService {
             }
             notice.setWllbClass(material.getWllbClass());
             StringBuffer stringBuffer = new StringBuffer();//库位编号
-            Map<String, Object> listMap = new HashMap<>();
             if(material.getPartType().equals("产成品")){
                 if(material.getIsRecommend().equals("1")){
                     StorageLocation storageLocation = new StorageLocation().setIsProduct("1");
+                    String[] symbol = {"<", "="};
+                    for(int i = 0; i < symbol.length; i++){
+                        String storageLocationCode = warehousingMapper.getStorageLocationCode(notice.getAttribute(), symbol[i]); //查询昨天没满的库位
+                        if(!storageLocationCode.equals("0")){
+                            int countStorage = warehousingMapper.getCountStorage(notice.getAttribute(), storageLocationCode, symbol[i]);
+                            if(countStorage < 7) {
+                                stringBuffer.append(storageLocationCode + ",");
+                                List<StorageLocation> list = warehousingMapper.recommend(stringBuffer.toString());
+                                map.put("data", list);
+                                map.put("msg", "210");
+                                return map;
+                            }
+                        }
+                    }
                     //查询产成品库位
                     List<StorageLocation> storageLocations = storageLocationMapper.getStorage(storageLocation);
                     for(StorageLocation storageLocation1 : storageLocations){
                         Inventory inventory = warehousingMapper.getInventoryInfo(storageLocation1);//查询库存信息
                         if(inventory == null){
                             stringBuffer.append(storageLocation1.getStorageLocationCode() + ",");
-                            continue;
-                        }
-                        //判断剩余容量大于入库数量
-                        int num = (int) (Double.parseDouble(material.getSize()) - Double.parseDouble(inventory.getAmount()));
-                        if(Integer.parseInt(notice.getWarehousingNum()) < num){
-                            //同一属性 同一批次推荐
-                            if(inventory.getAttribute().equals(notice.getAttribute()) && inventory.getProducBatch().equals(notice.getProducBatch())){
-                                stringBuffer.append(storageLocation1.getStorageLocationCode() + ",");
-                                listMap.put(storageLocation1.getStorageLocationCode(), num);
-                            }
+                            break;
                         }
                     }
                     List<StorageLocation> list = warehousingMapper.recommend(stringBuffer.toString());
                     map.put("data", list);
-                    map.put("listString", listMap);//返回库位剩余数量
                     map.put("msg", "210");
                 } else {
                     notice.setStorageLocationCode("111111");

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

@@ -266,14 +266,14 @@
             a.serial,
             a.type,
             c.user_name as userName,
-            a.department,
+            e.name as department,
             g.storage_location_name as storageLocationName,
             a.scrq,
             a.num
         from tld_removal a
         left join tld_material b on a.wllb_code = b.code
         left join tld_user c on a.user_id = c.id
+        left join tld_department e on a.department = e.tld_id
         left join tld_storage_location g on a.storage_location_code = g.storage_location_code
         left join tld_customer h on a.supplier_id = h.code
         <trim prefix="WHERE" prefixOverrides="and |or">
@@ -300,14 +300,14 @@
             a.serial,
             a.type,
             c.user_name as userName,
-            a.department,
+            e.name as department,
             g.storage_location_name as storageLocationName,
             a.scrq,
             a.num
         from tld_removal a
         left join tld_material b on a.wllb_code = b.code
         left join tld_user c on a.user_id = c.id
+        left join tld_department e on a.department = e.tld_id
         left join tld_storage_location g on a.storage_location_code = g.storage_location_code
         left join tld_customer h on a.supplier_id = h.code
         <trim prefix="WHERE" prefixOverrides="and |or">
@@ -502,6 +502,7 @@
     <!-- 查询指定物料的库存 -->
     <select id="getInventoryInfo" resultType="com.tld.model.Inventory">
         select
+            id,
             storage_location_code,
             wllb_class,
             library_type,
@@ -520,6 +521,12 @@
             scrq,
             produc_batch,
             attribute
-        from tld_inventory where storage_location_code = #{storageLocationCode} and material_id = #{materialId} and wbs = #{wbs}
+        from tld_inventory where storage_location_code = #{storageLocationCode} and material_id = #{materialId} and amount <![CDATA[>=]]> #{num}
+        <if test="wbs != '' and wbs != null">
+            and wbs = #{wbs}
+        </if>
+        <if test="wbs = ''">
+            and wbs is null
+        </if>
     </select>
 </mapper>

+ 15 - 0
src/main/resources/mapper/DeliveryMapper.xml

@@ -115,4 +115,19 @@
             move_type
         from tld_delivery_f where delivery_id = #{deliveryId}
     </select>
+    <!-- 查询产成品属性 -->
+    <select id="getAttribute" resultType="com.tld.model.Inventory">
+        SELECT
+            DISTINCT attribute,
+            storage_location_code,
+            wllb_code,
+            produc_batch
+        FROM tld_inventory
+        WHERE CONCAT(#{storageLocationCode},'111111,') LIKE CONCAT( '%', CONCAT( storage_location_code, ',' ), '%' )
+          AND material_id = #{delivery.materialId} AND hold = '0'
+    </select>
+    <!-- 查询库存 -->
+    <select id="getSumAmount" resultType="int">
+        select sum(amount) from tld_inventory where storage_location_code = #{storageLocationCode}
+    </select>
 </mapper>

+ 2 - 2
src/main/resources/mapper/DictionaryMapper.xml

@@ -8,8 +8,8 @@
     </select>
     <!-- 物料字典新增 -->
     <insert id="addMaterial">
-        insert into tld_material(code,name,tld_id,specification_and_model,unit_of_measurement,size,is_not_disable,is_recommend)
-        values(#{code},#{name},#{tldId},#{specificationAndModel},#{unitOfMeasurement},'0','0','0')
+        insert into tld_material(code,name,tld_id,specification_and_model,unit_of_measurement,size,is_not_disable,is_recommend,min_num,max_num)
+        values(#{code},#{name},#{tldId},#{specificationAndModel},#{unitOfMeasurement},'0','0','0',"0","0")
     </insert>
     <!-- 字典新增 -->
     <insert id="addDictionary">

+ 6 - 0
src/main/resources/mapper/MaterialClassMapper.xml

@@ -69,6 +69,12 @@
                 <if test="partType != null and partType != ''">
                     part_type = #{partType},
                 </if>
+                <if test="minNum != null and minNum != ''">
+                    min_num = #{minNum},
+                </if>
+                <if test="maxNum != null and maxNum != ''">
+                    max_num = #{maxNum},
+                </if>
             </trim>
         </set>
         where tld_id = #{id}

+ 49 - 0
src/main/resources/mapper/QueryListMappeer.xml

@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.tld.mapper.QueryListMapper">
+    <!-- 呆滞品查询 -->
+   <select id="dullGoods" resultType="java.util.Map">
+       SELECT
+           a.material_id as materialId,
+           a.amount as amount,
+           a.scrq as scrq,
+           a.storage_location_code as storageLocationCode,
+           b.name as materialName
+       FROM tld_inventory a
+       JOIN tld_material b on a.material_id = b.tld_id
+       WHERE datediff(a.scrq, now()) <![CDATA[>]]> 90
+        <if test="storageLocationCode != null and storageLocationCode != ''">
+            and a.storage_location_code = #{storageLocationCode}
+        </if>
+        <if test="wllbCode != null and wllbCode != ''">
+           and b.coed = #{wllbCode}
+        </if>
+   </select>
+    <!-- 查询所有物料 -->
+    <select id="getMaterial" resultType="java.util.Map">
+        select
+            tld_id as tldId,
+            min_num as minNum,
+            max_num as maxNum,
+            name as name
+        from tld_material
+        <trim prefix="WHERE" prefixOverrides="and |or">
+            <if test="wllbCode != null and wllbCode != ''">
+                and code = #{wllbCode}
+            </if>
+        </trim>
+    </select>
+    <!-- 物料储量预警查询 -->
+    <select id="reserveWarning" resultType="java.util.Map" parameterType="java.util.Map">
+        SELECT
+            ifnull(sum( a.amount ), 0) as amount,
+            ${tldId} as materialId,
+            ${name} AS materialName,
+            ${minNum} as minNum,
+            ${maxNum} as maxNum
+        FROM tld_inventory a
+        LEFT JOIN tld_material b ON a.material_id = b.tld_id
+        WHERE material_id = #{tldId}
+    </select>
+</mapper>

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

@@ -131,7 +131,7 @@
             (#{item.supplierId},#{item.orderCode},#{item.materialId},#{item.purchaseNum},#{item.arrivalNum},#{item.arrivalTime},'0')
         </foreach>
     </insert>
-
+    <!-- 修改采购到料状态 -->
     <update id="updatePurchaseType">
         update tld_purchase set type = '1' where order_code = #{orderCode}
     </update>

+ 16 - 0
src/main/resources/mapper/WarehousingMapper.xml

@@ -627,4 +627,20 @@
             (select count(*) from tld_warehousing_virtual where attribute = #{attribute} and serial = #{serial} and wllb_code = #{materialCode} and produc_date = #{producBatch}) as virtualCount
         from dual
     </select>
+    <!-- 查询昨天没满的库位 -->
+    <select id="getStorageLocationCode" resultType="String">
+        SELECT
+            ifnull(storage_location_code, "0")
+        FROM tld_inventory
+        WHERE attribute = #{attribute} and scrq <![CDATA[${symbol}]]> CURDATE()
+        ORDER BY scrq desc LIMIT 1
+    </select>
+    <select id="getCountStorage" resultType="int">
+        SELECT
+            count(*)
+        FROM
+            tld_inventory
+        where attribute = #{attribute} and storage_location_code = #{storageLocationCode} and scrq <![CDATA[${symbol}]]> CURDATE()
+        ORDER BY scrq desc LIMIT 1
+    </select>
 </mapper>