瀏覽代碼

问题修改

zhs 2 年之前
父節點
當前提交
fbaced24ef

+ 24 - 4
src/main/java/com/tld/controller/WarehousingController.java

@@ -70,8 +70,8 @@ public class WarehousingController {
      * @return 返回结果
      */
     @GetMapping("warehousing")
-    public Map<String, Object> warehousing(String uniqueCode){
-        return warehousingService.warehousing(uniqueCode);
+    public Map<String, Object> warehousing(String uniqueCode, String type){
+        return warehousingService.warehousing(uniqueCode, type);
     }
 
     /**
@@ -108,7 +108,7 @@ public class WarehousingController {
      * @return 返回结果
      */
     @PostMapping("addInventoryNotice")
-    public Map<String, Object> addInventoryNotice(Notice notice){
+    public Map<String, Object> addInventoryNotice(@RequestBody Notice notice){
         return warehousingService.addInventoryNotice(notice);
     }
 
@@ -118,7 +118,7 @@ public class WarehousingController {
      * @return 返回结果
      */
     @PostMapping("updateInventoryNotice")
-    public Map<String, Object> updateInventoryNotice(Notice notice){
+    public Map<String, Object> updateInventoryNotice(@RequestBody Notice notice){
         return warehousingService.updateInventoryNotice(notice);
     }
 
@@ -141,4 +141,24 @@ public class WarehousingController {
     public void productExcel(Notice notice, HttpServletResponse response){
         warehousingService.productExcel(notice, response);
     }
+
+    /**
+     * 产成品入库
+     * @return 参数
+     */
+    @GetMapping("getProductWarehousing")
+    public Map<String, Object> getProductWarehousing(Notice notice){
+        return warehousingService.getProductWarehousing(notice);
+    }
+
+    /**
+     * 推荐库位之后产成品入库
+     * @return 参数
+     */
+    @GetMapping("getProductWarehousingRecommend")
+    public Map<String, Object> getProductWarehousingRecommend(String uniqueCode, String type, String noticeId){
+        return warehousingService.getProductWarehousingRecommend(uniqueCode, type, noticeId);
+    }
+
+
 }

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

@@ -51,4 +51,6 @@ public interface InviteMapper {
     AskGoods getAskDetailedF(String askGoodsId);
 
     int getReturnRemovalCount();
+
+    String getScanNum(AskGoods askGoods1);
 }

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

@@ -25,7 +25,7 @@ public interface WarehousingMapper {
 
     void delWarehousingVirtual(WarehousingVirtual warehousingVirtual);
 
-    List<WarehousingVirtual> getVirtual(String uniqueCode);
+    List<WarehousingVirtual> getVirtual(@Param("uniqueCode")String uniqueCode, @Param("type")String type);
 
     List<ReceiveGoods> getReceiveGoods(WarehousingVirtual warehousingVirtual);
 
@@ -84,4 +84,12 @@ public interface WarehousingMapper {
     void updateAskGoodsHalf(@Param("id")String id, @Param("warehousingNum")String warehousingNum);
 
     void addRemovalHalfProduct(AskGoods askGoods1);
+
+    MaterialClass getMaterial(Notice notice);
+
+    Inventory getInventoryInfo(StorageLocation storageLocation1);
+
+    void addHalf(WarehousingVirtual warehousingVirtual);
+
+    List<WarehousingVirtual> getVirtualNotice(@Param("uniqueCode")String uniqueCode, @Param("type")String type, @Param("noticeId")String noticeId);
 }

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

@@ -71,6 +71,10 @@ public class Dictionary  implements Serializable {
      * 是否推荐库位
      */
     private String isRecommend;
+    /**
+     * 物料类别
+     */
+    private String partType;
     /**
      * 分数
      */

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

@@ -84,4 +84,12 @@ public class Inventory implements Serializable {
      * 物料id
      */
     private String materialId;
+    /**
+     * 生成批次
+     */
+    private String producBatch;
+    /**
+     * 属性
+     */
+    private String attribute;
 }

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

@@ -24,6 +24,10 @@ public class MaterialClass implements Serializable {
      * 物料编号
      */
     private String wllbCode;
+    /**
+     * 物料类型
+     */
+    private String wllbClass;
     /**
      * 物料
      */

+ 36 - 0
src/main/java/com/tld/model/Notice.java

@@ -108,5 +108,41 @@ public class Notice implements Serializable {
      * 要货单id
      */
     private String askGoodsId;
+    /**
+     *物料code
+     */
+    private String wllbCode;
+    /**
+     * 连翻号
+     */
+    private String serial;
+    /**
+     * 批次
+     */
+    private String producBatch;
+    /**
+     * 属性
+     */
+    private String attribute;
+    /**
+     * 库位编号
+     */
+    private String storageLocationCode;
+    /**
+     * 序列号
+     */
+    private String seq;
+    /**
+     * 用户名称
+     */
+    private String userName;
+    /**
+     * 入库时间
+     */
+    private String scrq;
+    /**
+     *
+     */
+    private String uniqueCode;
 
 }

+ 5 - 1
src/main/java/com/tld/model/StorageLocation.java

@@ -45,9 +45,13 @@ public class StorageLocation implements Serializable {
      */
     private String storageLocationCapacity;
     /**
-     * 是否禁用
+     * 是否混合
      */
     private String isNotDisable;
+    /**
+     * 是否产成品库位
+     */
+    private String isProduct;
     /**
      * 创建时间
      */

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

@@ -128,4 +128,12 @@ public class WarehousingVirtual implements Serializable {
      * 姓名
      */
     private String userName;
+    /**
+     * 属性
+     */
+    private String attribute;
+    /**
+     * 半成品产成品入库通知单
+     */
+    private String noticeId;
 }

+ 5 - 1
src/main/java/com/tld/service/WarehousingService.java

@@ -14,7 +14,7 @@ public interface WarehousingService {
 
     Map<String, Object> delWarehousingVirtual(WarehousingVirtual warehousingVirtual);
 
-    Map<String, Object> warehousing(String uniqueCode);
+    Map<String, Object> warehousing(String uniqueCode, String type);
 
     void plugOutWarehousing(String orderNumber);
 
@@ -33,4 +33,8 @@ public interface WarehousingService {
     Map<String, Object> getProduct(Notice notice);
 
     void productExcel(Notice notice, HttpServletResponse response);
+
+    Map<String, Object> getProductWarehousing(Notice notice);
+
+    Map<String, Object> getProductWarehousingRecommend(String uniqueCode, String type, String noticeId);
 }

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

@@ -7,10 +7,8 @@ import com.github.pagehelper.PageInfo;
 import com.tld.excel.ExcelUtils;
 import com.tld.mapper.AskGoodsMapper;
 import com.tld.mapper.ErrorMapper;
-import com.tld.model.AskGoods;
+import com.tld.model.*;
 import com.tld.model.Error;
-import com.tld.model.Inventory;
-import com.tld.model.ReturRemoval;
 import com.tld.service.AskGoodsService;
 import com.tld.util.DateUtil;
 import com.tld.util.HttpClientUtil;
@@ -134,7 +132,7 @@ public class AskGoodsServiceImpl implements AskGoodsService {
             for(Inventory inventory : askGoodsMapper.getMaterialCk(askGoods)){
                 AskGoods askGoods1 = askGoodsMapper.getAsk(inventory);
                 if(askGoods1 != null){
-                    if(Integer.parseInt(askGoods1.getNum()) != Integer.parseInt(inventory.getAmount())){
+                    if(Double.parseDouble(askGoods1.getNum()) != Double.parseDouble(inventory.getAmount())){
                         list.add(inventory);
                     }
                 } else {

+ 12 - 1
src/main/java/com/tld/service/impl/InviteServiceImpl.java

@@ -42,6 +42,13 @@ public class InviteServiceImpl implements InviteService {
         Map<String, Object> map = new HashMap<>();
         try{
             List<AskGoods> list = inviteMapper.getAskGoodsMaterial(askGoods);
+            List<String> scanNum = new LinkedList<>();
+            for(AskGoods askGoods1 : list){
+                askGoods1.setUniqueCode(askGoods.getUniqueCode());
+                askGoods1.setAskGoodsId(askGoods.getAskGoodsId());
+                scanNum.add(inviteMapper.getScanNum(askGoods1));//扫描总数
+            }
+            map.put("scanNum", scanNum);
             map.put("data", list);
             map.put("msg", "200");
         }catch (Exception e){
@@ -59,7 +66,11 @@ public class InviteServiceImpl implements InviteService {
             List<Inventory> list = new LinkedList<>();
             for(Inventory inventory : inviteMapper.getMaterialCk(askGoods)){
                 AskGoods askGoods1 = inviteMapper.getAsk(inventory);
-                if(Integer.parseInt(askGoods1.getNum()) != Integer.parseInt(inventory.getAmount())){
+                if(askGoods1 != null){
+                    if(Double.parseDouble(askGoods1.getNum()) != Double.parseDouble(inventory.getAmount())){
+                        list.add(inventory);
+                    }
+                } else {
                     list.add(inventory);
                 }
             }

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

@@ -6,10 +6,7 @@ import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.mysql.cj.xdevapi.JsonString;
 import com.tld.excel.ExcelUtils;
-import com.tld.mapper.AskGoodsMapper;
-import com.tld.mapper.ErrorMapper;
-import com.tld.mapper.UserMapper;
-import com.tld.mapper.WarehousingMapper;
+import com.tld.mapper.*;
 import com.tld.model.*;
 import com.tld.model.Error;
 import com.tld.service.WarehousingService;
@@ -29,21 +26,24 @@ import java.util.*;
 
 @Service
 public class WarehousingServiceImpl implements WarehousingService {
-
+    //入库
     @Autowired
     private WarehousingMapper warehousingMapper;
-
+    //用户
     @Autowired
     private UserMapper userMapper;
-
+    //错误日志表
     @Autowired
     private ErrorMapper errorMapper;
     //redis锁
     @Autowired
     private RedissonClient redissonClient;
-
+    //出库
     @Autowired
     private AskGoodsMapper askGoodsMapper;
+    //库存
+    @Autowired
+    private StorageLocationMapper storageLocationMapper;
 
     @Override
     public Map<String, Object> getRecommend(String wllbCode, String suppId, String num, String unique, String producDate) {
@@ -137,13 +137,13 @@ public class WarehousingServiceImpl implements WarehousingService {
     }
 
     @Override
-    public Map<String, Object> warehousing(String uniqueCode) {
+    public Map<String, Object> warehousing(String uniqueCode, String type) {
         Map<String, Object> map = new HashMap<>();
         try{
             //入库信息
             List<WarehousingVirtual> list = new LinkedList<>();
             //查询入库所需要的信息
-            for(WarehousingVirtual warehousingVirtual : warehousingMapper.getVirtual(uniqueCode)){
+            for(WarehousingVirtual warehousingVirtual : warehousingMapper.getVirtual(uniqueCode, type)){
                 //查询采购单信息
                 List<ReceiveGoods> receiveGoods = warehousingMapper.getReceiveGoods(warehousingVirtual);
                 if(receiveGoods.size() != 0) {
@@ -167,7 +167,7 @@ public class WarehousingServiceImpl implements WarehousingService {
             //返回采购单id
             StringBuilder stringBuilder = new StringBuilder();
             //入质检入库数量
-            for(WarehousingVirtual warehousingVirtual1 : warehousingMapper.getVirtual(uniqueCode)) {
+            for(WarehousingVirtual warehousingVirtual1 : warehousingMapper.getVirtual(uniqueCode, type)) {
                 //查询采购单信息
                 List<ReceiveGoods> receiveGoods = warehousingMapper.getReceiveGoods(warehousingVirtual1);
                 for(ReceiveGoods receiveGoods1 : receiveGoods) {
@@ -178,7 +178,7 @@ public class WarehousingServiceImpl implements WarehousingService {
                     int surplusNum = Integer.parseInt(receiveGoods1.getQualifiedNum()) - Integer.parseInt(receiveGoods1.getWarehousingNum());
                     //剩余入库数量
                     int numInto = Integer.parseInt(warehousingVirtual1.getNum()) - surplusNum;
-                    if(numInto < 0){
+                    if(numInto < 0) {
                         receiveGoods1.setWarehousingNum(warehousingVirtual1.getNum());
                         warehousingMapper.updateReceiveGood(receiveGoods1);
                     } else {
@@ -352,6 +352,7 @@ public class WarehousingServiceImpl implements WarehousingService {
 //                map.put("errMsg", "入库数量大于通知单数量!");
 //                return map;
 //            }
+            notice.setStorageLocationCode("000000");
             if(warehousingMapper.getInventoryNotice(notice) != 0){
                 warehousingMapper.updateInventoryNotice(notice);
             } else {
@@ -363,7 +364,7 @@ public class WarehousingServiceImpl implements WarehousingService {
                     .setUserId(notice.getUserId())
                     .setStorageLocationCode("000000")
                     .setProducDate(notice1.getNoticeTime())
-                    .setNum(notice.getNum());
+                    .setNum(notice.getWarehousingNum());
             warehousingMapper.addProduct(warehousingVirtual);//入库流水 半成品
 
             //存入给gs的返回数据
@@ -396,8 +397,14 @@ public class WarehousingServiceImpl implements WarehousingService {
         RLock lock = redissonClient.getLock(notice.getMaterialId());
         lock.lock();
         try{
+            notice.setStorageLocationCode("000000");
             Inventory inventory = warehousingMapper.getHalfInventory(notice);//库存信息
             AskGoods askGoods = warehousingMapper.getAskGoodsHalf(notice);//要货单信息
+            if(askGoods.getType().equals("1")){
+                map.put("msg", "500");
+                map.put("errMsg", "订单已出库");
+                return map;
+            }
             if(Double.parseDouble(askGoods.getNum()) < Double.parseDouble(notice.getWarehousingNum())){
                 map.put("msg", "500");
                 map.put("errMsg", "出库数量大于要货单数量");
@@ -421,7 +428,7 @@ public class WarehousingServiceImpl implements WarehousingService {
             warehousingMapper.updateAskGoodsHalf(askGoods.getId(), notice.getWarehousingNum());//修改要货单出库数量
             //新增半成品出库流水
             AskGoods askGoods1 = new AskGoods()
-                    .setMaterialId(notice.getMaterialId())
+                    .setWllbCode(notice.getWllbCode())
                     .setNum(notice.getWarehousingNum())
                     .setUserId(notice.getUserId())
                     .setAskGoodsId(askGoods.getAskGoodsId())
@@ -497,6 +504,148 @@ public class WarehousingServiceImpl implements WarehousingService {
         }
     }
 
+    @Override
+    public Map<String, Object> getProductWarehousing(Notice notice) {
+        Map<String, Object> map = new HashMap<>();
+        try{
+            MaterialClass material = warehousingMapper.getMaterial(notice);
+            if(material == null) {
+                map.put("msg", "500");
+                map.put("errMsg", "物料信息未录入,请联系管理员");
+                return map;
+            }
+            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");
+                    //查询产成品库位
+                    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(storageLocation1.getStorageLocationCapacity()) - 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);
+                            }
+                        }
+                    }
+                    List<StorageLocation> list = warehousingMapper.recommend(stringBuffer.toString());
+                    map.put("data", list);
+                    map.put("listString", listMap);//返回库位剩余数量
+                } else {
+                    notice.setStorageLocationCode("111111");
+                    if(warehousingMapper.getInventoryNotice(notice) != 0){
+                        warehousingMapper.updateInventoryNotice(notice);
+                    } else {
+                        warehousingMapper.addInventoryNotice(notice);
+                    }
+                    //入库流水
+                    WarehousingVirtual warehousingVirtual = new WarehousingVirtual()
+                            .setWllbCode(material.getWllbCode())
+                            .setUserId(notice.getUserId())
+                            .setStorageLocationCode(notice.getStorageLocationCode())
+                            .setProducDate(notice.getProducBatch())
+                            .setNum(notice.getWarehousingNum())
+                            .setSerial(notice.getSerial())
+                            .setSeq(notice.getSeq())
+                            .setAttribute(notice.getAttribute());
+                    warehousingMapper.addHalf(warehousingVirtual);//入库流水 产成品
+                    Notice notice1 = warehousingMapper.getNoticeId(notice);
+                    //存入给gs的返回数据
+                    String storageCode = codeGenerateRk();
+                    ReturnWarehousing returnWarehousing = new ReturnWarehousing()
+                            .setStorageCode(storageCode)//入库编号
+                            .setSourceType(notice1.getSourceType())//来源类型
+                            .setMoveType(notice1.getMoveType())//移动类型
+                            .setOrderNumber(notice1.getNoticeId())//通知单id
+                            .setWbs(notice1.getWbs())//wbs
+                            .setEntryNumber(notice1.getEntryNumber())//gs分录号
+                            .setMaterialId(notice1.getMaterialId())//物料id
+                            .setId(notice1.getId())//分录单id
+                            .setWarehousingNum(notice.getWarehousingNum());//入库数量
+                    warehousingMapper.addReturnWarehousing(returnWarehousing);
+                    map.put("msg", "200");
+                    map.put("data", notice1.getNoticeId() + ",");
+                }
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            map.put("msg", "500");
+            map.put("errMsg", "服务器请求异常,请稍后再试");
+        }
+        return map;
+    }
+
+    @Override
+    public Map<String, Object> getProductWarehousingRecommend(String uniqueCode, String type, String noticeId) {
+        Map<String, Object> map = new HashMap<>();
+        try{
+            //返回采购单id
+            StringBuilder stringBuilder = new StringBuilder();
+            //查询入库所需要的信息
+            for(WarehousingVirtual warehousingVirtual : warehousingMapper.getVirtualNotice(uniqueCode, type, noticeId)) {
+                //查询物料信息
+                Notice notice = new Notice().setWllbCode(warehousingVirtual.getWllbCode());
+                MaterialClass material = warehousingMapper.getMaterial(notice);
+                Notice notice1 = warehousingMapper.getNoticeId(new Notice().setNoticeId(noticeId).setMaterialId(material.getTldId()));
+                Notice notice2 = new Notice()
+                        .setMaterialId(material.getTldId())
+                        .setStorageLocationCode(warehousingVirtual.getStorageLocationCode())
+                        .setNoticeId(noticeId)
+                        .setWarehousingNum(warehousingVirtual.getNum())
+                        .setAttribute(warehousingVirtual.getAttribute())
+                        .setProducBatch(warehousingVirtual.getProducDate())
+                        .setWllbClass(material.getWllbClass())
+                        .setWbs(notice1.getWbs())
+                        .setCompanyNumber(notice1.getCompanyNumber());
+                warehousingMapper.addInventoryNotice(notice2);
+                //入库流水
+                WarehousingVirtual warehousingVirtual1 = new WarehousingVirtual()
+                        .setWllbCode(material.getWllbCode())
+                        .setUserId(warehousingVirtual.getUserId())
+                        .setStorageLocationCode(warehousingVirtual.getStorageLocationCode())
+                        .setProducDate(warehousingVirtual.getProducDate())
+                        .setNum(warehousingVirtual.getNum())
+                        .setSerial(warehousingVirtual.getSerial())
+                        .setSeq(warehousingVirtual.getSeq())
+                        .setAttribute(warehousingVirtual.getAttribute());
+                warehousingMapper.addHalf(warehousingVirtual1);//入库流水 产成品
+                //存入给gs的返回数据
+                String storageCode = codeGenerateRk();
+                ReturnWarehousing returnWarehousing = new ReturnWarehousing()
+                        .setStorageCode(storageCode)//入库编号
+                        .setSourceType(notice1.getSourceType())//来源类型
+                        .setMoveType(notice1.getMoveType())//移动类型
+                        .setOrderNumber(notice1.getNoticeId())//通知单id
+                        .setWbs(notice1.getWbs())//wbs
+                        .setEntryNumber(notice1.getEntryNumber())//gs分录号
+                        .setMaterialId(notice1.getMaterialId())//物料id
+                        .setId(notice1.getId())//分录单id
+                        .setWarehousingNum(warehousingVirtual.getNum());//入库数量
+                warehousingMapper.addReturnWarehousing(returnWarehousing);
+                if (!stringBuilder.toString().contains(notice1.getNoticeId() + ",")) {
+                    stringBuilder.append(notice1.getNoticeId() + ",");
+                }
+            }
+            map.put("msg", "200");
+            map.put("data", stringBuilder.toString());
+        }catch (Exception e){
+            e.printStackTrace();
+            map.put("msg", "500");
+            map.put("errMsg", "服务器请求异常,请稍后再试");
+        }
+        return map;
+    }
+
     /**
      * 入库单生成
      * @return

+ 6 - 0
src/main/resources/banner.txt

@@ -0,0 +1,6 @@
+______________________.____     ________   
+\__    ___/\_   _____/|    |    \______ \  
+  |    |    |    __)_ |    |     |    |  \ 
+  |    |    |        \|    |___  |    `   \
+  |____|   /_______  /|_______ \/_______  /
+                   \/         \/        \/

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

@@ -79,7 +79,7 @@
             b.storage_location_name as storageLocationName
         from tld_inventory a
         left join tld_storage_location b on a.storage_location_code = b.storage_location_code
-        where a.material_id = #{materialId} order by a.scrq
+        where a.material_id = #{materialId} order by a.produc_date
     </select>
     <!-- 新增出库虚拟表 -->
     <insert id="addAskGoodsVitrual">
@@ -111,18 +111,7 @@
     <!-- 查询库存是否充足 -->
     <select id="getAsk" resultType="com.tld.model.AskGoods">
         SELECT
-            a.id,
-            a.unique_code,
-            a.supplier_id,
-            a.serial,
-            a.wllb_code,
-            a.produc_date,
-            a.ask_goods_id,
-            a.type,
-            a.storage_location_code,
-            a.num,
-            a.user_id,
-            a.department
+            ifnull(sum(a.num),0) as num
         FROM
             tld_ask_goods_vitrual a
             join tld_material b on a.wllb_code = b.code and b.tld_id = #{materialId}
@@ -368,18 +357,23 @@
         where unique_code = #{uniqueCode} and ask_goods_id = #{askGoodsId}
     </select>
     <!-- 查询半成品出库数据 -->
-    <select id="getGoodsHalf" resultSets="com.tld.model.AskGoods">
+    <select id="getGoodsHalf" resultType="com.tld.model.AskGoods">
         SELECT
             a.id,
             a.material_id,
             a.num,
+            a.production_code,
             b.name as materialName,
             b.code as materialCode,
             a.out_num,
-            a.ask_goods_id
+            a.ask_goods_id,
+            e.name as department,
+            a.type
         FROM
             tld_ask_goods a
             join tld_material b on a.material_id = b.tld_id
+            join tld_ask_goods_f c on a.ask_goods_id = c.ask_goods_id
+            left join tld_department e on c.department = e.tld_id
         WHERE
             (a.num + 0) <![CDATA[>]]> (a.out_num + 0) and b.part_type = #{partType}
         <if test="productionCode != null and productionCode != ''">
@@ -388,12 +382,18 @@
         <if test="askGoodsId != null and askGoodsId != ''">
             and a.ask_goods_id = #{askGoodsId}
         </if>
+        <if test="id != null and id != ''">
+            and a.id = #{id}
+        </if>
+        <if test="type != null and type != ''">
+            and a.type = #{type}
+        </if>
     </select>
     <!-- 查询半成品出库流水 -->
     <select id="getRemovalHalfProduct" resultType="com.tld.model.AskGoods">
         select
             a.id,
-            a.material_id,
+            a.wllb_code,
             a.num,
             a.user_id,
             a.scrq,
@@ -402,11 +402,11 @@
             b.name as materialName,
             e.user_name as userName
         from tld_removal_half_product a
-        left join tld_material b on a.material_id = b.tld_id
+        left join tld_material b on a.wllb_code = b.code
         left join tld_department c on a.department = c.tld_id
         left join tld_user e on a.user_id = e.id
-        <if test="materialId != null and materialId != ''">
-            and a.material_id = #{materialId}
+        <if test="wllbCode != null and wllbCode != ''">
+            and a.wllb_code = #{wllbCode}
         </if>
         <if test="startTime != null and startTime != ''">
             and a.scrq <![CDATA[>=]]> #{startTime}
@@ -426,11 +426,11 @@
             a.ask_goods_id,
             c.name as department
         from tld_removal_half_product a
-        left join tld_material b on a.material_id = b.tld_id
+        left join tld_material b on a.wllb_code = b.code
         left join tld_department c on a.department = c.tld_id
         left join tld_user e on a.user_id = e.id
-        <if test="materialId != null and materialId != ''">
-            and a.material_id = #{materialId}
+        <if test="wllbCode != null and wllbCode != ''">
+            and a.wllb_code = #{wllbCode}
         </if>
         <if test="startTime != null and startTime != ''">
             and a.scrq <![CDATA[>=]]> #{startTime}

+ 11 - 15
src/main/resources/mapper/InviteMapper.xml

@@ -49,12 +49,19 @@
             a.material_id,
             a.num,
             b.name as materialName,
-            b.code as materialCode
+            b.code as materialCode,
+            a.out_num
         FROM
             tld_invite a
             left join tld_material b on a.material_id = b.tld_id
         WHERE
-            a.ask_goods_id = #{askGoodsId} and (a.num + 0) <![CDATA[>]]> (a.out_num + 0)
+            a.ask_goods_id = #{askGoodsId} and (a.num + 0) <![CDATA[>]]> (a.out_num + 0) and b.part_type != '半成品' and b.part_type != '产成品'
+    </select>
+    <!-- 查询指定pda 指定物料扫描总数 -->
+    <select id="getScanNum" resultType="String">
+        select if(AVG(num) is null, 0, num)
+        from tld_ask_goods_vitrual
+        where unique_code = #{uniqueCode} and ask_goods_id = #{askGoodsId}
     </select>
     <!-- 物料库位选择 -->
     <select id="getMaterialCk" resultType="com.tld.model.Inventory">
@@ -109,18 +116,7 @@
     <!-- 查询库存是否充足 -->
     <select id="getAsk" resultType="com.tld.model.AskGoods">
         SELECT
-            a.id,
-            a.unique_code,
-            a.supplier_id,
-            a.serial,
-            a.wllb_code,
-            a.produc_date,
-            a.ask_goods_id,
-            a.type,
-            a.storage_location_code,
-            a.num,
-            a.user_id,
-            a.department
+            ifnull(sum(a.num),0) as num
         FROM
             tld_ask_goods_vitrual a
             join tld_material b on a.wllb_code = b.code and b.tld_id = #{materialId}
@@ -152,7 +148,7 @@
     </select>
     <!-- 查询已扫描总数 -->
     <select id="getAskInfoNumVitrual" resultType="int">
-        select sum(num) from tld_ask_goods_vitrual where wllb_code = #{materialCode} and ask_goods_id = #{askGoodsId} and type = #{type}
+        select ifnull(sum(num), 0) from tld_ask_goods_vitrual where wllb_code = #{materialCode} and ask_goods_id = #{askGoodsId} and type = #{type}
     </select>
     <!-- 查询此库存在虚拟表里占用的数量 -->
     <select id="getInventoryAlready" resultType="int">

+ 9 - 2
src/main/resources/mapper/StorageLocationMapper.xml

@@ -17,6 +17,7 @@
             a.is_not_disable,
             a.storage_location_capacity,
             a.create_time,
+            a.is_product,
             b.name as materialName
         from
         tld_storage_location a
@@ -37,13 +38,16 @@
             <if test="id != null and id != ''">
                 and a.id = #{id}
             </if>
+            <if test="isProduct != null and isProduct != ''">
+                and is_product = #{isProduct}
+            </if>
         </trim>
         order by a.id desc
     </select>
     <!-- 新增库位信息 -->
     <insert id="addStorage">
-        insert into tld_storage_location(storage_location_code,storage_location_name,warehouse_where,storage_location_type,is_not_disable,storage_location_capacity,create_time)
-        values(#{storageLocationCode},#{storageLocationName},#{warehouseWhere},#{storageLocationType},#{isNotDisable},#{storageLocationCapacity},DATE_FORMAT(NOW(), '%Y-%m-%d'))
+        insert into tld_storage_location(storage_location_code,storage_location_name,warehouse_where,storage_location_type,is_not_disable,storage_location_capacity,create_time,is_product)
+        values(#{storageLocationCode},#{storageLocationName},#{warehouseWhere},#{storageLocationType},#{isNotDisable},#{storageLocationCapacity},DATE_FORMAT(NOW(), '%Y-%m-%d'),#{isProduct})
     </insert>
     <!-- 删除库位信息 -->
     <delete id="delStorage">
@@ -72,6 +76,9 @@
                 <if test="isNotDisable != null and isNotDisable != ''">
                     is_not_disable = #{isNotDisable},
                 </if>
+                <if test="isProduct != null and isProduct != ''">
+                    is_product = #{isProduct},
+                </if>
             </trim>
         </set>
             where id = #{id}

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

@@ -131,6 +131,6 @@
                 and a.user_name like CONCAT(CONCAT('%', #{userName}), '%')
             </if>
         </trim>
-        order by id desc
+        order by a.id desc
     </select>
 </mapper>

+ 120 - 34
src/main/resources/mapper/WarehousingMapper.xml

@@ -27,8 +27,8 @@
     </select>
     <!-- 新增库位信息虚拟表 -->
     <insert id="addWarehousingVirtual">
-        insert into tld_warehousing_virtual(unique_code,num,storage_location_code,wllb_code,supp_id,serial,type,produc_date,capacity,seq,user_id,storage_location_name)
-        values(#{uniqueCode},#{num},#{storageLocationCode},#{wllbCode},#{suppId},#{serial},#{type},#{producDate},#{capacity},#{seq},#{userId},#{storageLocationName})
+        insert into tld_warehousing_virtual(unique_code,num,storage_location_code,wllb_code,supp_id,serial,type,produc_date,capacity,seq,user_id,storage_location_name,attribute,notice_id)
+        values(#{uniqueCode},#{num},#{storageLocationCode},#{wllbCode},#{suppId},#{serial},#{type},#{producDate},#{capacity},#{seq},#{userId},#{storageLocationName},#{attribute},#{noticeId})
     </insert>
     <!-- 查询总数量 -->
     <select id="getScanNum" resultType="java.util.Map">
@@ -93,11 +93,12 @@
             a.capacity,
             a.seq,
             a.user_id,
+            a.attribute,
             a.storage_location_name,
             b.user_name
         from tld_warehousing_virtual a
         left join tld_user b on a.user_id = b.id
-        where a.unique_code = #{uniqueCode}
+        where a.unique_code = #{uniqueCode} and a.type = #{type}
     </select>
     <!-- 查询采购单信息 -->
     <select id="getReceiveGoods" resultType="com.tld.model.ReceiveGoods">
@@ -152,10 +153,10 @@
     </insert>
     <!-- 插入库存 -->
     <insert id="addInventory">
-        insert into tld_inventory(storage_location_code,wllb_class,material_id,amount,totime,hold,amount_lock,account_sleeve,wbs,supplier_id,serial,wllb_code,produc_date,scrq)
+        insert into tld_inventory(storage_location_code,wllb_class,material_id,amount,totime,hold,amount_lock,account_sleeve,wbs,supplier_id,serial,wllb_code,produc_date,scrq,produc_batch)
         values
         <foreach collection="list" index="index" item="item" separator=",">
-            (#{item.storageLocationCode},#{item.wllbClass},#{item.materialId},#{item.num},now(),'0','0',#{item.accountSleeve},#{item.wbs},#{item.suppId},#{item.serial},#{item.wllbCode},#{item.producDate}, now())
+            (#{item.storageLocationCode},#{item.wllbClass},#{item.materialId},#{item.num},now(),'0','0',#{item.accountSleeve},#{item.wbs},#{item.suppId},#{item.serial},#{item.wllbCode},#{item.producDate}, now(),#{item.producDate}, '0')
         </foreach>
     </insert>
     <!-- 删除临时表数据 -->
@@ -296,16 +297,19 @@
             a.num,
             a.type,
             a.warehousing_num,
-            a.company_number,
+            b.company_number,
             c.name as materialName,
             c.wllb_class as wllbClass
         from tld_notice a
         join tld_notice_f b on a.notice_id = b.notice_id
-        left join tld_material c on a.material_id = c.tld_id
+        join tld_material c on a.material_id = c.tld_id
         <trim prefix="WHERE" prefixOverrides="and |or">
             <if test="type != null and type != ''">
                 and a.type = #{type}
             </if>
+            <if test="materialCode != null and materialCode != ''">
+                and c.code = #{materialCode}
+            </if>
             <if test="startTime != null and startTime != ''">
                 and b.notice_time <![CDATA[>=]]> #{startTime}
             </if>
@@ -330,57 +334,62 @@
             b.wllb_class,
             c.source_type,
             c.move_type,
-            b.code as materialCode
+            b.code as materialCode,
             c.notice_time as noticeTime
         from tld_notice a
         join tld_notice_f c on a.notice_id = c.notice_id
         left join tld_material b on a.material_id = b.tld_id
         where a.notice_id = #{noticeId} and a.material_id = #{materialId}
     </select>
-    <!-- 半成品跟部分产成品入虚拟库存 -->
+    <!-- 半成品跟部分产成品入库存 -->
     <insert id="addInventoryNotice">
         insert into
-            tld_inventory(storage_location_code,material_id,amount,hold,amount_lock,account_sleeve,wbs,produc_date,scrq,wllb_class)
-            value('000000',#{materialId},#{warehousingNum},'0','0',#{companyNumber},#{wbs},now(),now(),#{wllbClass});
-        update tld_notice set warehousing_num = warehousing_num + #{num},type = '1' where notice_id = #{noticeId} and material_id = #{materialId}
+            tld_inventory(storage_location_code,material_id,amount,hold,amount_lock,account_sleeve,wbs,produc_date,scrq,wllb_class,produc_batch,attribute)
+            value(#{storageLocationCode},#{materialId},#{warehousingNum},'0','0',#{companyNumber},#{wbs},now(),now(),#{wllbClass},#{producBatch},#{attribute});
+        update tld_notice set warehousing_num = #{warehousingNum},type = '1' where notice_id = #{noticeId} and material_id = #{materialId}
     </insert>
     <!-- 查询库存里是否存在半成品虚拟库位 -->
     <select id="getInventoryNotice" resultType="int">
-        select count(0) from tld_inventory where storage_location_code = '000000' and material_id = #{materialId}
+        select count(0) from tld_inventory where storage_location_code = #{storageLocationCode} and material_id = #{materialId}
     </select>
-    <!-- 增加半成品虚拟库位数量 -->
+    <!-- 增加半成品/产成品虚拟库位数量 -->
     <update id="updateInventoryNotice">
-        update tld_inventory set amount = amount + #{warehousingNum} where storage_location_code = '000000';
-        update tld_notice set warehousing_num = warehousing_num + #{warehousingNum},type = '1' where notice_id = #{noticeId} and material_id = #{materialId}
+        update tld_inventory set amount = amount + #{warehousingNum} where storage_location_code = #{storageLocationCode};
+        update tld_notice set warehousing_num = #{warehousingNum},type = '1' where notice_id = #{noticeId} and material_id = #{materialId}
     </update>
     <!-- 半成品出库库存查询 -->
-    <select id="getHalfInventory" resultType="com.tld.model.Notice">
-        select storage_location_code,wllb_class,material_id,amount from tld_inventory where storage_location_code = '000000' and material_id = #{materialId}
+    <select id="getHalfInventory" resultType="com.tld.model.Inventory">
+        select storage_location_code,wllb_class,material_id,amount from tld_inventory where storage_location_code = #{storageLocationCode} and material_id = #{materialId}
     </select>
     <!-- 删除库存信息 -->
     <delete id="delInventoryNotice">
-        delete from tld_inventory where storage_location_code = '000000' and material_id = #{materialId}
+        delete from tld_inventory where storage_location_code = #{storageLocationCode} and material_id = #{materialId}
     </delete>
     <!-- 删减库存 -->
     <update id="updateInventoryNoticeNum">
-        update tld_inventory set amount = amount - #{num} where storage_location_code = '000000' and material_id = #{materialId}
+        update tld_inventory set amount = amount - #{warehousingNum} where storage_location_code = #{storageLocationCode} and material_id = #{materialId}
     </update>
     <!-- 新增半成品入库流水 -->
     <insert id="addProduct">
         insert into tld_half_product(wllb_code,produc_date,produc_batch,capacity,user_id,storage_location_code,scrq)
-        value(#{wllbCode},#{producDate},#{producBatch},#{producBatch},#{num},#{userId},#{storageLocationCode},now())
+        value(#{wllbCode},#{producDate},#{producDate},#{num},#{userId},#{storageLocationCode},now())
     </insert>
     <!-- 查询半成品入库流水-->
     <select id="getProduct" resultType="com.tld.model.Notice">
         select
+            a.id,
             a.wllb_code,
             a.produc_date,
             a.produc_batch,
-            a.capacity,
+            a.capacity as warehousingNum,
             a.user_id,
+            c.user_name,
             a.storage_location_code,
-            a.scrq
+            a.scrq,
+            b.name as materialName
         from tld_half_product a
+        left join tld_material b on a.wllb_code = b.code
+        left join tld_user c on a.user_id = c.id
         <trim prefix="WHERE" prefixOverrides="and |or">
             <if test="wllbCode != null and wllbCode != ''">
                 and a.wllb_code = #{wllbCode}
@@ -394,17 +403,17 @@
         </trim>
         order by a.scrq desc
     </select>
-
     <!-- 查询半成品入库流水-->
     <select id="productExcel" resultType="java.util.LinkedHashMap">
         select
-        b.name,
-        a.produc_date,
-        a.capacity,
-        a.user_id,
-        a.scrq
+            b.name,
+            a.produc_date,
+            a.capacity,
+            c.user_name,
+            a.scrq
         from tld_half_product a
-        right join tld_material b on a.wllb_code = b.tld_id
+        left join tld_material b on a.wllb_code = b.code
+        left join tld_user c on a.user_id = c.id
         <trim prefix="WHERE" prefixOverrides="and |or">
             <if test="wllbCode != null and wllbCode != ''">
                 and a.wllb_code = #{wllbCode}
@@ -430,18 +439,95 @@
             a.out_num,
             a.entry_number,
             b.source_type,
-            b.move_type
+            b.move_type,
+            c.code as wllbCode,
+            a.type,
+            b.department
         from tld_ask_goods a
         join tld_ask_goods_f b on a.ask_goods_id = b. ask_goods_id
+        left join tld_material c on a.material_id = c.tld_id
         where a.ask_goods_id = #{askGoodsId} and a.material_id = #{materialId}
     </select>
     <!-- 修改要货单出库数量 -->
     <update id="updateAskGoodsHalf">
-        update tld_ask_goods set out_num = out_num + #{warehousingNum} where id = #{id}
+        update tld_ask_goods set out_num = out_num + #{warehousingNum},type = '1' where id = #{id}
     </update>
     <!-- 新增半成品流水 -->
     <insert id="addRemovalHalfProduct">
-        insert into tld_removal_half_product(material_id,num,user_id,scrq,ask_goods_id,department)
-        value(#{materialId},#{num},#{userId},now(),#{askGoodsId},#{department})
+        insert into tld_removal_half_product(wllb_code,num,user_id,scrq,ask_goods_id,department)
+        value(#{wllbCode},#{num},#{userId},now(),#{askGoodsId},#{department})
     </insert>
+    <!-- 查询指定物料内容 -->
+    <select id="getMaterial" resultType="com.tld.model.MaterialClass">
+        select
+            code as wllbCode,
+            name as wllbName,
+            tld_id,
+            specification_and_model,
+            unit_of_measurement,
+            size,
+            wllb_class,
+            is_not_disable,
+            is_recommend,
+            part_type
+        from tld_material where tld_id = #{materialId}
+        <trim prefix="WHERE" prefixOverrides="and |or">
+            <if test="materialId != null and materialId != ''">
+                and tld_id = #{materialId}
+            </if>
+            <if test="materialCode != null and materialCode != ''">
+                and wllb_code = #{materialCode}
+            </if>
+        </trim>
+    </select>
+    <!-- 查询库存信息 -->
+    <select id="getInventoryInfo" resultType="com.tld.model.Inventory">
+        select
+            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,
+            produc_batch,
+            attribute
+        from tld_inventory where storage_location_code = #{storageLocationCode}
+    </select>
+    <!-- 产成品入库 -->
+    <insert id="addHalf">
+        insert into tld_half(wllb_code,produc_date,produc_batch,capacity,user_id,storage_location_code,scrq,serial,seq,attribute)
+        value(#{wllbCode},#{producDate},#{producDate},#{num},#{userId},#{storageLocationCode},now(),#{scrq},#{serial},#{seq},#{attribute})
+    </insert>
+    <!-- 查询虚拟表数据进行入库 -->
+    <select id="getVirtual" resultType="com.tld.model.WarehousingVirtual">
+        select
+            a.id,
+            a.unique_code,
+            a.num,
+            a.storage_location_code,
+            a.wllb_code,
+            a.supp_id,
+            a.serial,
+            a.type,
+            a.produc_date,
+            a.capacity,
+            a.seq,
+            a.user_id,
+            a.attribute,
+            a.storage_location_name,
+            b.user_name
+        from tld_warehousing_virtual a
+        left join tld_user b on a.user_id = b.id
+        where a.unique_code = #{uniqueCode} and a.type = #{type} and a.notice_id = #{noticeId}
+    </select>
 </mapper>