Ver código fonte

问题修改

zhs 2 anos atrás
pai
commit
771d177f1f
26 arquivos alterados com 871 adições e 65 exclusões
  1. 33 3
      src/main/java/com/tld/controller/AskGoodsController.java
  2. 51 0
      src/main/java/com/tld/controller/WarehousingController.java
  3. 9 6
      src/main/java/com/tld/mapper/AskGoodsMapper.java
  4. 28 0
      src/main/java/com/tld/mapper/WarehousingMapper.java
  5. 24 0
      src/main/java/com/tld/model/AskGoods.java
  6. 4 0
      src/main/java/com/tld/model/Dictionary.java
  7. 8 0
      src/main/java/com/tld/model/MaterialClass.java
  8. 112 0
      src/main/java/com/tld/model/Notice.java
  9. 4 0
      src/main/java/com/tld/model/ReturRemoval.java
  10. 4 0
      src/main/java/com/tld/model/ReturnWarehousing.java
  11. 7 1
      src/main/java/com/tld/service/AskGoodsService.java
  12. 11 0
      src/main/java/com/tld/service/WarehousingService.java
  13. 64 3
      src/main/java/com/tld/service/impl/AskGoodsServiceImpl.java
  14. 1 1
      src/main/java/com/tld/service/impl/InviteServiceImpl.java
  15. 201 5
      src/main/java/com/tld/service/impl/WarehousingServiceImpl.java
  16. 95 19
      src/main/resources/mapper/AskGoodsMapper.xml
  17. 2 0
      src/main/resources/mapper/ContainerMapper.xml
  18. 2 2
      src/main/resources/mapper/DictionaryMapper.xml
  19. 33 24
      src/main/resources/mapper/InviteMapper.xml
  20. 6 0
      src/main/resources/mapper/MaterialClassMapper.xml
  21. 1 1
      src/main/resources/mapper/MenuMapper.xml
  22. 2 0
      src/main/resources/mapper/ReceiveGoodsMapper.xml
  23. 2 0
      src/main/resources/mapper/RoleMapper.xml
  24. 2 0
      src/main/resources/mapper/StorageLocationMapper.xml
  25. 2 0
      src/main/resources/mapper/UserMapper.xml
  26. 163 0
      src/main/resources/mapper/WarehousingMapper.xml

+ 33 - 3
src/main/java/com/tld/controller/AskGoodsController.java

@@ -1,6 +1,7 @@
 package com.tld.controller;
 
 import com.tld.model.AskGoods;
+import com.tld.model.ReceiveGoods;
 import com.tld.service.AskGoodsService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -101,8 +102,37 @@ public class AskGoodsController {
      * @param id 指定id
      * @return 返回结果
      */
-    @DeleteMapping("delAskGoodsVitrual")
-    public Map<String, Object> delAskGoodsVitrual(String id){
-        return askGoodsService.delAskGoodsVitrual(id);
+    @GetMapping("delAskGoodsVitrual")
+    public Map<String, Object> delAskGoodsVitrual(String id, String type){
+        return askGoodsService.delAskGoodsVitrual(id, type);
+    }
+
+    /**
+     * 查询半成品出库物料
+     * @param askGoods 参数
+     * @return 返回结果
+     */
+    @GetMapping("getGoodsHalf")
+    public Map<String, Object> getGoodsHalf(AskGoods askGoods){
+        return askGoodsService.getGoodsHalf(askGoods);
+    }
+
+    /**
+     * 半成品出库流水
+     * @param askGoods 参数
+     * @return 返回结果
+     */
+    @GetMapping("getRemovalHalfProduct")
+    public Map<String, Object> getRemovalHalfProduct(AskGoods askGoods){
+        return askGoodsService.getRemovalHalfProduct(askGoods);
+    }
+
+    /**
+     * 半成品出库流水 导出
+     * @param askGoods 参数
+     */
+    @GetMapping("getRemovalHalfProductExcel")
+    public void getRemovalHalfProductExcel(AskGoods askGoods, HttpServletResponse response){
+        askGoodsService.getRemovalHalfProductExcel(askGoods, response);
     }
 }

+ 51 - 0
src/main/java/com/tld/controller/WarehousingController.java

@@ -1,6 +1,7 @@
 package com.tld.controller;
 
 import com.tld.model.AskGoods;
+import com.tld.model.Notice;
 import com.tld.model.Storage;
 import com.tld.model.WarehousingVirtual;
 import com.tld.service.WarehousingService;
@@ -90,4 +91,54 @@ public class WarehousingController {
     public void userExport(Storage storage, HttpServletResponse response){
         warehousingService.export(storage, response);
     }
+
+    /**
+     * 查询报工单
+     * @param notice 参数
+     * @return 返回结果
+     */
+    @GetMapping("getNotice")
+    public Map<String, Object> getNotice(Notice notice){
+        return warehousingService.getNotice(notice);
+    }
+
+    /**
+     * 半成品材料入库
+     * @param notice 参数
+     * @return 返回结果
+     */
+    @PostMapping("addInventoryNotice")
+    public Map<String, Object> addInventoryNotice(Notice notice){
+        return warehousingService.addInventoryNotice(notice);
+    }
+
+    /**
+     * 半成品出库
+     * @param notice 参数
+     * @return 返回结果
+     */
+    @PostMapping("updateInventoryNotice")
+    public Map<String, Object> updateInventoryNotice(Notice notice){
+        return warehousingService.updateInventoryNotice(notice);
+    }
+
+    /**
+     * 查询半成品流水
+     * @param notice 参数
+     * @return 返回结果
+     */
+    @GetMapping("getProduct")
+    public Map<String, Object> getProduct(Notice notice){
+        return warehousingService.getProduct(notice);
+    }
+
+    /**
+     * 导出
+     * @param notice 参数
+     * @return 返回结果
+     */
+    @GetMapping("productExcel")
+    public void productExcel(Notice notice, HttpServletResponse response){
+        warehousingService.productExcel(notice, response);
+    }
 }

+ 9 - 6
src/main/java/com/tld/mapper/AskGoodsMapper.java

@@ -1,9 +1,6 @@
 package com.tld.mapper;
 
-import com.tld.model.AskGoods;
-import com.tld.model.Inventory;
-import com.tld.model.ReturRemoval;
-import com.tld.model.StorageLocation;
+import com.tld.model.*;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -69,7 +66,7 @@ public interface AskGoodsMapper {
 
     Map<String, Object> plugOutRemoval(String removalCode);
 
-    Map<String, Object> getRemovalz(String askGoodsId);
+    List<Map<String, Object>> getRemovalz(String askGoodsId);
 
     List<AskGoods> getRemoval(AskGoods askGoods);
 
@@ -77,9 +74,15 @@ public interface AskGoodsMapper {
 
     List<AskGoods> getAskGoodsVitrual(@Param("uniqueCode")String uniqueCode, @Param("type")String type);
 
-    void delAskGoodsVitrual(String id);
+    void delAskGoodsVitrual(@Param("id")String id, @Param("type")String type);
 
     void updateOutNum(@Param("num")String num, @Param("askGoodsId")String askGoodsId, @Param("materialId")String materialId);
 
     String getScanNum(AskGoods askGoods);
+
+    List<AskGoods> getGoodsHalf(AskGoods askGoods);
+
+    List<AskGoods> getRemovalHalfProduct(AskGoods askGoods);
+
+    List<Map<String, Object>> getRemovalHalfProductExcel(AskGoods askGoods);
 }

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

@@ -56,4 +56,32 @@ public interface WarehousingMapper {
     int getMateriaIsExist(String wllbCode);
 
     List<String> getInventoryProduc(@Param("wllbCode")String wllbCode, @Param("producDate")String producDate, @Param("storageLocationCode")String storageLocationCode);
+
+    List<Notice> getNotice(Notice notice);
+
+    Notice getNoticeId(Notice notice);
+
+    void addInventoryNotice(Notice notice);
+
+    int getInventoryNotice(Notice notice);
+
+    void updateInventoryNotice(Notice notice);
+
+    Inventory getHalfInventory(Notice notice);
+
+    void updateInventoryNoticeNum(Notice notice);
+
+    void delInventoryNotice(Notice notice);
+
+    void addProduct(WarehousingVirtual warehousingVirtual);
+
+    List<Notice> getProduct(Notice notice);
+
+    List<Map<String, Object>> productExcel(Notice notice);
+
+    AskGoods getAskGoodsHalf(Notice notice);
+
+    void updateAskGoodsHalf(@Param("id")String id, @Param("warehousingNum")String warehousingNum);
+
+    void addRemovalHalfProduct(AskGoods askGoods1);
 }

+ 24 - 0
src/main/java/com/tld/model/AskGoods.java

@@ -27,6 +27,14 @@ public class AskGoods implements Serializable {
      * 生产订单号
      */
     private String productionCode;
+    /**
+     * 库位名称
+     */
+    private String storageLocationName;
+    /**
+     * 用户名称
+     */
+    private String userName;
     /**
      * 物料id
      */
@@ -115,6 +123,10 @@ public class AskGoods implements Serializable {
      * 生成日期
      */
     private String scrq;
+    /**
+     * 供应商名称
+     */
+    private String supplierName;
     /**
      * 生产日期
      */
@@ -144,4 +156,16 @@ public class AskGoods implements Serializable {
      * 结束时间
      */
     private String endTime;
+    /**
+     * 工序
+     */
+    private String process;
+    /**
+     * 要货申请类型
+     */
+    private String askGoodsApplyType;
+    /**
+     * 物料类别
+     */
+    private String partType;
 }

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

@@ -67,6 +67,10 @@ public class Dictionary  implements Serializable {
      * 是否混合
      */
     private String isNotDisable;
+    /**
+     * 是否推荐库位
+     */
+    private String isRecommend;
     /**
      * 分数
      */

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

@@ -48,6 +48,14 @@ public class MaterialClass implements Serializable {
      * 是否混合
      */
     private String isNotDisable;
+    /**
+     * 是否推荐库位
+     */
+    private String isRecommend;
+    /**
+     * 物料类别
+     */
+    private String partType;
     /**
      * 页数
      */

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

@@ -0,0 +1,112 @@
+package com.tld.model;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * 报工单
+ */
+@Data
+@Accessors(chain = true)
+@SuppressWarnings("serial")
+public class Notice implements Serializable {
+    /**
+     * 主键
+     */
+    private String id;
+    /**
+     * 通知单id
+     */
+    private String noticeId;
+    /**
+     * 通知单code
+     */
+    private String noticeCode;
+    /**
+     * 公司编号
+     */
+    private String companyNumber;
+    /**
+     * 通知单时间
+     */
+    private String noticeTime;
+    /**
+     * 来源类型
+     */
+    private String sourceType;
+    /**
+     * 移动类型
+     */
+    private String moveType;
+    /**
+     * 分录号
+     */
+    private String entryNumber;
+    /**
+     * 生产单编号
+     */
+    private String productionCode;
+    /**
+     * 物料id
+     */
+    private String materialId;
+    /**
+     * wbs
+     */
+    private String wbs;
+    /**
+     * 计量单位
+     */
+    private String measurementId;
+    /**
+     * 数量
+     */
+    private String num;
+    /**
+     * 状态
+     */
+    private String type;
+    /**
+     * 入库数量
+     */
+    private String warehousingNum;
+    /**
+     * 页数
+     */
+    private int page;
+    /**
+     * 条数
+     */
+    private int limit;
+    /**
+     * 开始时间
+     */
+    private String startTime;
+    /**
+     * 结束时间
+     */
+    private String endTime;
+    /**
+     * 物料名称
+     */
+    private String materialName;
+    /**
+     * 物料类别
+     */
+    private String wllbClass;
+    /**
+     * 物料编号
+     */
+    private String materialCode;
+    /**
+     * 用户编号
+     */
+    private String userId;
+    /**
+     * 要货单id
+     */
+    private String askGoodsId;
+
+}

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

@@ -72,4 +72,8 @@ public class ReturRemoval implements Serializable {
      * 库存编号
      */
     private String storageLocationCode;
+    /**
+     * 用户编号
+     */
+    private String userId;
 }

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

@@ -84,4 +84,8 @@ public class ReturnWarehousing implements Serializable {
      * 库位编号
      */
     private String storageLocationCode;
+    /**
+     * 通知单id
+     */
+    private String noticeId;
 }

+ 7 - 1
src/main/java/com/tld/service/AskGoodsService.java

@@ -26,5 +26,11 @@ public interface AskGoodsService {
 
     Map<String, Object> getAskGoodsVitrual(String uniqueCode, String type);
 
-    Map<String, Object> delAskGoodsVitrual(String id);
+    Map<String, Object> delAskGoodsVitrual(String id, String type);
+
+    Map<String, Object> getGoodsHalf(AskGoods askGoods);
+
+    Map<String, Object> getRemovalHalfProduct(AskGoods askGoods);
+
+    void getRemovalHalfProductExcel(AskGoods askGoods, HttpServletResponse response);
 }

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

@@ -1,5 +1,6 @@
 package com.tld.service;
 
+import com.tld.model.Notice;
 import com.tld.model.Storage;
 import com.tld.model.WarehousingVirtual;
 
@@ -22,4 +23,14 @@ public interface WarehousingService {
     Map<String, Object> getWarehousingVirtual(String uniqueCode);
 
     void export(Storage storage, HttpServletResponse response);
+
+    Map<String, Object> getNotice(Notice notice);
+
+    Map<String, Object> addInventoryNotice(Notice notice);
+
+    Map<String, Object> updateInventoryNotice(Notice notice);
+
+    Map<String, Object> getProduct(Notice notice);
+
+    void productExcel(Notice notice, HttpServletResponse response);
 }

+ 64 - 3
src/main/java/com/tld/service/impl/AskGoodsServiceImpl.java

@@ -116,7 +116,7 @@ public class AskGoodsServiceImpl implements AskGoodsService {
         Map<String, Object> map = new HashMap<>();
         try{
             Map<String, Object> mapVal = askGoodsMapper.getScanIsNot(askGoods);
-            if((Integer.parseInt(mapVal.get("inventoryNum").toString()) - Integer.parseInt(mapVal.get("virtualNum").toString())) == 0){
+            if((Double.parseDouble(mapVal.get("inventoryNum").toString()) - Double.parseDouble(mapVal.get("virtualNum").toString())) == 0){
                 map.put("msg", "500");
                 map.put("errMsg", "已全部出库");
                 return map;
@@ -276,10 +276,10 @@ public class AskGoodsServiceImpl implements AskGoodsService {
     }
 
     @Override
-    public Map<String, Object> delAskGoodsVitrual(String id) {
+    public Map<String, Object> delAskGoodsVitrual(String id, String type) {
         Map<String, Object> map = new HashMap<>();
         try{
-            askGoodsMapper.delAskGoodsVitrual(id);
+            askGoodsMapper.delAskGoodsVitrual(id, type);
             map.put("msg", "200");
         }catch (Exception e){
             e.printStackTrace();
@@ -289,6 +289,67 @@ public class AskGoodsServiceImpl implements AskGoodsService {
         return map;
     }
 
+    @Override
+    public Map<String, Object> getGoodsHalf(AskGoods askGoods) {
+        Map<String, Object> map = new HashMap<>();
+        try{
+            //查询数据
+            PageHelper.startPage(askGoods.getPage(), askGoods.getLimit());
+            PageInfo<AskGoods> list = new PageInfo<>(askGoodsMapper.getGoodsHalf(askGoods));
+            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> getRemovalHalfProduct(AskGoods askGoods) {
+        Map<String, Object> map = new HashMap<>();
+        try{
+            //查询数据
+            PageHelper.startPage(askGoods.getPage(), askGoods.getLimit());
+            PageInfo<AskGoods> list = new PageInfo<>(askGoodsMapper.getRemovalHalfProduct(askGoods));
+            map.put("data", list);
+            map.put("msg", "200");
+        }catch (Exception e){
+            e.printStackTrace();
+            map.put("msg", "500");
+            map.put("errMsg", "失败");
+        }
+        return map;
+    }
+
+    @Override
+    public void getRemovalHalfProductExcel(AskGoods askGoods, HttpServletResponse response) {
+        try{
+            //导出数据汇总
+            List<List<Object>> sheetDataList = new ArrayList<>();
+            //表头数据
+            List<Object> head = Arrays.asList("物料名称", "出库数量", "用户名称", "出库时间", "要货单ID", "领用部门");
+            //查询数据
+            PageHelper.startPage(askGoods.getPage(), askGoods.getLimit());
+            PageInfo<Map<String, Object>> list = new PageInfo<>(askGoodsMapper.getRemovalHalfProductExcel(askGoods));
+            sheetDataList.add(head);
+            for(Map<String, Object> userMap : list.getList()){
+                List<Object> listSheet = new ArrayList<>();
+                for(String key: userMap.keySet()){
+                    listSheet.add(userMap.get(key));
+                }
+                sheetDataList.add(listSheet);
+            }
+            //当前时间
+            Date time = new Date();
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMddHHmmss");
+            ExcelUtils.export(response, "出库流水数据导出" + sdf.format(time), sheetDataList);
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+    }
+
     /**
      * 出库单生成
      * @return

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

@@ -78,7 +78,7 @@ public class InviteServiceImpl implements InviteService {
         Map<String, Object> map = new HashMap<>();
         try{
             Map<String, Object> mapVal = inviteMapper.getScanIsNot(askGoods);
-            if((Integer.parseInt(mapVal.get("inventoryNum").toString()) - Integer.parseInt(mapVal.get("virtualNum").toString())) == 0){
+            if((Double.parseDouble(mapVal.get("inventoryNum").toString()) - Double.parseDouble(mapVal.get("virtualNum").toString())) == 0){
                 map.put("msg", "500");
                 map.put("errMsg", "已全部出库");
                 return map;

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

@@ -6,6 +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;
@@ -15,6 +16,8 @@ import com.tld.service.WarehousingService;
 import com.tld.util.DateUtil;
 import com.tld.util.HttpClientUtil;
 import org.apache.http.ParseException;
+import org.redisson.api.RLock;
+import org.redisson.api.RedissonClient;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -35,9 +38,12 @@ public class WarehousingServiceImpl implements WarehousingService {
 
     @Autowired
     private ErrorMapper errorMapper;
+    //redis锁
+    @Autowired
+    private RedissonClient redissonClient;
 
-//    @Resource
-//    private HttpClientUtil httpClientUtil;
+    @Autowired
+    private AskGoodsMapper askGoodsMapper;
 
     @Override
     public Map<String, Object> getRecommend(String wllbCode, String suppId, String num, String unique, String producDate) {
@@ -239,7 +245,8 @@ public class WarehousingServiceImpl implements WarehousingService {
                 list.add(BillItems);
                 strJson.put("BillItems", list);
                 returnData.put("strJson", JSON.toJSONString(strJson));
-                System.out.println(returnData);
+
+
                 HttpClientUtil httpClientUtil1 = new HttpClientUtil();
                 Map<String, Object> result = httpClientUtil1.doPost("http://42.159.85.29:52480/cwbase/sg/V1/ERP/TELD/DEVTEST/API_WMS_PurInStock/CreatePurInStock", returnData);
                 if(Integer.parseInt(result.get("msg").toString()) != 200){
@@ -314,6 +321,182 @@ public class WarehousingServiceImpl implements WarehousingService {
         }
     }
 
+    @Override
+    public Map<String, Object> getNotice(Notice notice) {
+        Map<String, Object> map = new HashMap<>();
+        try{
+            PageHelper.startPage(notice.getPage(), notice.getLimit());
+            PageInfo<Notice> list = new PageInfo<>(warehousingMapper.getNotice(notice));
+            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> addInventoryNotice(Notice notice) {
+        Map<String, Object> map = new HashMap<>();
+        try{
+            Notice notice1 = warehousingMapper.getNoticeId(notice);
+            if(notice1.getType().equals("1")){
+                map.put("msg", "500");
+                map.put("errMsg", "此通知单已入库!");
+                return map;
+            }
+//            if(Double.parseDouble(notice1.getNum()) < Double.parseDouble(notice.getNum())){
+//                map.put("msg", "500");
+//                map.put("errMsg", "入库数量大于通知单数量!");
+//                return map;
+//            }
+            if(warehousingMapper.getInventoryNotice(notice) != 0){
+                warehousingMapper.updateInventoryNotice(notice);
+            } else {
+                warehousingMapper.addInventoryNotice(notice);
+            }
+            //入库流水
+            WarehousingVirtual warehousingVirtual = new WarehousingVirtual()
+                    .setWllbCode(notice1.getMaterialCode())
+                    .setUserId(notice.getUserId())
+                    .setStorageLocationCode("000000")
+                    .setProducDate(notice1.getNoticeTime())
+                    .setNum(notice.getNum());
+            warehousingMapper.addProduct(warehousingVirtual);//入库流水 半成品
+
+            //存入给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("data", storageCode);
+            map.put("msg", "200");
+        } catch (Exception e){
+            e.printStackTrace();
+            map.put("msg", "500");
+            map.put("errMsg", "服务器请求异常,请稍后再试");
+        }
+        return map;
+    }
+
+    @Override
+    public Map<String, Object> updateInventoryNotice(Notice notice) {
+        Map<String, Object> map = new HashMap<>();
+        //redis并发锁
+        RLock lock = redissonClient.getLock(notice.getMaterialId());
+        lock.lock();
+        try{
+            Inventory inventory = warehousingMapper.getHalfInventory(notice);//库存信息
+            AskGoods askGoods = warehousingMapper.getAskGoodsHalf(notice);//要货单信息
+            if(Double.parseDouble(askGoods.getNum()) < Double.parseDouble(notice.getWarehousingNum())){
+                map.put("msg", "500");
+                map.put("errMsg", "出库数量大于要货单数量");
+                return map;
+            }
+            if(inventory == null){
+                map.put("msg", "500");
+                map.put("errMsg", "没有查询到此半成品物料的库存");
+                return map;
+            }
+            if(Double.parseDouble(notice.getWarehousingNum()) > Double.parseDouble(inventory.getAmount())){
+                map.put("msg", "500");
+                map.put("errMsg", "库存不足");
+                return map;
+            }
+            if(Double.parseDouble(notice.getWarehousingNum()) == Double.parseDouble(inventory.getAmount())){
+                warehousingMapper.delInventoryNotice(notice);
+            } else {
+                warehousingMapper.updateInventoryNoticeNum(notice);
+            }
+            warehousingMapper.updateAskGoodsHalf(askGoods.getId(), notice.getWarehousingNum());//修改要货单出库数量
+            //新增半成品出库流水
+            AskGoods askGoods1 = new AskGoods()
+                    .setMaterialId(notice.getMaterialId())
+                    .setNum(notice.getWarehousingNum())
+                    .setUserId(notice.getUserId())
+                    .setAskGoodsId(askGoods.getAskGoodsId())
+                    .setDepartment(askGoods.getDepartment());//新增出库流水
+            warehousingMapper.addRemovalHalfProduct(askGoods1);
+            //新增返回gs信息
+            String removalCode = codeGenerateCk();
+            ReturRemoval returRemoval = new ReturRemoval()
+                    .setMaterialId(notice.getMaterialId())
+                    .setAskGoodsId(notice.getAskGoodsId())
+                    .setWbs(askGoods.getWbs())
+                    .setNum(notice.getWarehousingNum())
+                    .setEntryNumber(askGoods.getEntryNumber())
+                    .setAskId(askGoods.getId())
+                    .setStorageLocationCode(inventory.getStorageLocationCode())
+                    .setRemovalCode(removalCode)
+                    .setSourceType(askGoods.getSourceType())
+                    .setMoveType(askGoods.getMoveType());
+            askGoodsMapper.addReturnGsRemovalF(returRemoval);//新增返回gs数据父表信息
+            askGoodsMapper.addReturnGsRemoval(returRemoval);//新增返回gs数据子表信息
+            map.put("msg", "200");
+        } catch (Exception e){
+            e.printStackTrace();
+            map.put("msg", "500");
+            map.put("errMsg", "服务器请求异常,请稍后再试");
+        } finally {
+            //释放锁
+            lock.unlock();
+        }
+        return map;
+    }
+
+    @Override
+    public Map<String, Object> getProduct(Notice notice) {
+        Map<String, Object> map = new HashMap<>();
+        try{
+            PageHelper.startPage(notice.getPage(), notice.getLimit());
+            PageInfo<Notice> list = new PageInfo<>(warehousingMapper.getProduct(notice));
+            map.put("data", list);
+            map.put("msg", "200");
+        } catch (Exception e){
+            e.printStackTrace();
+            map.put("msg", "500");
+            map.put("errMsg", "服务器请求异常,请稍后再试");
+        }
+        return map;
+    }
+
+    @Override
+    public void productExcel(Notice notice, HttpServletResponse response) {
+        try{
+            //导出数据汇总
+            List<List<Object>> sheetDataList = new ArrayList<>();
+            //表头数据
+            List<Object> head = Arrays.asList("物料名称", "生产时间", "数量", "用户名称", "入库时间");
+            //查询数据
+            PageHelper.startPage(notice.getPage(), notice.getLimit());
+            PageInfo<Map<String, Object>> list = new PageInfo<>(warehousingMapper.productExcel(notice));
+            sheetDataList.add(head);
+            for(Map<String, Object> userMap : list.getList()){
+                List<Object> listSheet = new ArrayList<>();
+                for(String key: userMap.keySet()){
+                    listSheet.add(userMap.get(key));
+                }
+                sheetDataList.add(listSheet);
+            }
+            //当前时间
+            Date time = new Date();
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMddHHmmss");
+            ExcelUtils.export(response, "入库流水数据导出" + sdf.format(time), sheetDataList);
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+    }
+
     /**
      * 入库单生成
      * @return
@@ -330,7 +513,20 @@ public class WarehousingServiceImpl implements WarehousingService {
         return (stringBuilder.append(count + 1)).toString();
     }
 
-    public static void main(String[] args) {
-
+    /**
+     * 出库单id
+     * @return
+     */
+    public String codeGenerateCk(){
+        StringBuilder stringBuilder = new StringBuilder("CK");
+        Date date = new Date();
+        SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd");
+        stringBuilder.append(sdf.format(date));
+        int count = askGoodsMapper.getReturnRemovalCount();
+        for(int i = 0; i < 4 - (count + "").length(); i++){
+            stringBuilder.append("0");
+        }
+        return (stringBuilder.append(count + 1)).toString();
     }
+
 }

+ 95 - 19
src/main/resources/mapper/AskGoodsMapper.xml

@@ -28,9 +28,9 @@
         select count(*) from tld_ask_goods_f where ask_goods_id = #{askGoodsId} and ask_goods_code = #{askGoodsCode}
     </select>
     <!-- 新增要料申请单父级 -->
-    <insert id="addAskGoodsNumf">
-        insert into tld_ask_goods_f(ask_goods_id,ask_goods_code,company_number,sqrq,department,source_type,move_type)
-        values(#{askGoodsId},#{askGoodsCode},#{companyNumber},#{sqrq},#{department},#{sourceType},#{moveType})
+    <insert id="addAskGoodsf">
+        insert into tld_ask_goods_f(ask_goods_id,ask_goods_code,company_number,sqrq,department,source_type,move_type,ask_goods_apply_type)
+        values(#{askGoodsId},#{askGoodsCode},#{companyNumber},#{sqrq},#{department},#{sourceType},#{moveType},#{askGoodsApplyType})
     </insert>
     <!-- 查询生产领料单 -->
     <select id="getAskGoodsfList" resultType="com.tld.model.AskGoods">
@@ -40,7 +40,7 @@
                b.name as departmentName
         from tld_ask_goods_f a
         left join tld_department b on a.department = b.tld_id
-        order by sqrq desc
+        order by a.sqrq desc
     </select>
     <!-- 查询指定生产单的物料 -->
     <select id="getAskGoodsMaterial" resultType="com.tld.model.AskGoods">
@@ -55,7 +55,7 @@
             tld_ask_goods a
             left join tld_material b on a.material_id = b.tld_id
         WHERE
-            a.ask_goods_id = #{askGoodsId} and a.num <![CDATA[>]]> a.out_num
+            a.ask_goods_id = #{askGoodsId} and (a.num + 0) <![CDATA[>]]> (a.out_num + 0) and b.part_type != '半成品' and b.part_type != '产成品'
     </select>
     <!-- 物料库位选择 -->
     <select id="getMaterialCk" resultType="com.tld.model.Inventory">
@@ -89,6 +89,7 @@
     <!-- 查询指定库存内容 -->
     <select id="getInventory" resultType="com.tld.model.Inventory">
         select
+           id,
            storage_location_code,
            wllb_class,
            library_type,
@@ -105,7 +106,7 @@
            wllb_code,
            produc_date,
            scrq
-        from tld_inventory where supplier_id = #{supplierId} and serial = #{uniqueCode} and wllb_code = #{wllbCode} and produc_date = #{producDate}
+        from tld_inventory where supplier_id = #{supplierId} and serial = #{serial} and wllb_code = #{wllbCode} and produc_date = #{producDate}
     </select>
     <!-- 查询库存是否充足 -->
     <select id="getAsk" resultType="com.tld.model.AskGoods">
@@ -130,8 +131,8 @@
     <!-- 查询是否扫描 -->
     <select id="getScanIsNot" resultType="java.util.Map">
         select
-            (select amount from tld_inventory where supplier_id = #{supplierId} and serial = #{uniqueCode} and wllb_code = #{wllbCode} and produc_date = #{producDate}) as inventoryNum,
-            (select sum(num) from tld_ask_goods_vitrual where supplier_id = #{supplierId} and serial = #{uniqueCode} and wllb_code = #{wllbCode} and produc_date = #{producDate} and type = #{type}) as virtualNum
+            (select ifnull(amount,0) from tld_inventory where supplier_id = #{supplierId} and serial = #{serial} and wllb_code = #{wllbCode} and produc_date = #{producDate}) as inventoryNum,
+            (select ifnull(sum(num),0) from tld_ask_goods_vitrual where supplier_id = #{supplierId} and serial = #{serial} and wllb_code = #{wllbCode} and produc_date = #{producDate} and type = #{type}) as virtualNum
         from dual
     </select>
     <!-- 查询指定送货单信息 -->
@@ -149,15 +150,15 @@
         FROM
             tld_ask_goods a
             join tld_material b on a.material_id = b.tld_id
-        where a.ask_goods_id = #{askGoodsId} and b.code = #{materialCode}
+        where a.ask_goods_id = #{askGoodsId} and b.code = #{wllbCode}
     </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 = #{wllbCode} and ask_goods_id = #{askGoodsId} and type = #{type}
     </select>
     <!-- 查询此库存在虚拟表里占用的数量 -->
     <select id="getInventoryAlready" resultType="int">
-        select sum(num) from tld_ask_goods_vitrual where supplier_id = #{supplierId} and serial = #{uniqueCode} and wllb_code = #{wllbCode} and produc_date = #{producDate} and type = #{type}
+        select ifnull(sum(num), 0) from tld_ask_goods_vitrual where supplier_id = #{supplierId} and serial = #{serial} and wllb_code = #{wllbCode} and produc_date = #{producDate} and type = #{type}
     </select>
     <!-- 查询虚拟表指定pda跟状态的的数据 -->
     <select id="getVirtualUniqueCode" resultType="com.tld.model.AskGoods">
@@ -194,7 +195,7 @@
     <!-- 插入出库流水 -->
     <insert id="addRemoval">
         insert into tld_removal(wllb_code,supplier_id,serial,num,type,user_id,storage_location_code,scrq,process,ask_goods_id,produc_date,department)
-        values(#{materialCode},#{supplierId},#{serial},#{num},#{type},#{userId},#{storageLocationCode},now(),#{process},#{askGoodsId},#{producDate},#{department})
+        values(#{wllbCode},#{supplierId},#{serial},#{num},#{type},#{userId},#{storageLocationCode},now(),#{process},#{askGoodsId},#{producDate},#{department})
     </insert>
     <!-- 查询指定物料类型的id -->
     <select id="getMaterialId" resultType="String">
@@ -235,8 +236,8 @@
     </select>
     <!-- 新增返回gs数据父表信息 -->
     <insert id="addReturnGsRemovalF">
-        insert into tld_ask_goods_f(ask_goods_id,removal_code,source_type,move_type,scrq)
-        values(#{askGoodsId},#{removalCode},#{sourceType},#{movetype},now())
+        insert into tld_return_gs_removal(ask_goods_id,removal_code,source_type,move_type,scrq)
+        values(#{askGoodsId},#{removalCode},#{sourceType},#{moveType},now())
     </insert>
     <!-- 查询当天出库数量 -->
     <select id="getReturnRemovalCount" resultType="int">
@@ -273,14 +274,14 @@
             a.serial,
             a.type,
             c.user_name as userName,
-            e.name as departmentName,
+            a.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_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">
@@ -297,6 +298,7 @@
                 and a.type like CONCAT(CONCAT('%', #{type}), '%')
             </if>
         </trim>
+        order by a.id desc
     </select>
     <!-- 导出 -->
     <select id="export" resultType="java.util.LinkedHashMap">
@@ -306,14 +308,14 @@
             a.serial,
             a.type,
             c.user_name as userName,
-            e.name as departmentName,
+            a.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_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">
@@ -330,6 +332,7 @@
                 and a.type like CONCAT(CONCAT('%', #{type}), '%')
             </if>
         </trim>
+        order by a.id desc
     </select>
     <!-- 查询指定pda出库虚拟表 -->
     <select id="getAskGoodsVitrual" resultType="com.tld.model.AskGoods">
@@ -351,7 +354,7 @@
     </select>
     <!-- 删除指定虚拟表数据 -->
     <delete id="delAskGoodsVitrual">
-        delete from tld_ask_goods_vitrual where id = #{id}
+        delete from tld_ask_goods_vitrual where id = #{id} and type = #{type}
     </delete>
     <!-- 修改出库数量 -->
     <update id="updateOutNum">
@@ -364,4 +367,77 @@
         from tld_ask_goods_vitrual
         where unique_code = #{uniqueCode} and ask_goods_id = #{askGoodsId}
     </select>
+    <!-- 查询半成品出库数据 -->
+    <select id="getGoodsHalf" resultSets="com.tld.model.AskGoods">
+        SELECT
+            a.id,
+            a.material_id,
+            a.num,
+            b.name as materialName,
+            b.code as materialCode,
+            a.out_num,
+            a.ask_goods_id
+        FROM
+            tld_ask_goods a
+            join tld_material b on a.material_id = b.tld_id
+        WHERE
+            (a.num + 0) <![CDATA[>]]> (a.out_num + 0) and b.part_type = #{partType}
+        <if test="productionCode != null and productionCode != ''">
+            and a.production_code = #{productionCode}
+        </if>
+        <if test="askGoodsId != null and askGoodsId != ''">
+            and a.ask_goods_id = #{askGoodsId}
+        </if>
+    </select>
+    <!-- 查询半成品出库流水 -->
+    <select id="getRemovalHalfProduct" resultType="com.tld.model.AskGoods">
+        select
+            a.id,
+            a.material_id,
+            a.num,
+            a.user_id,
+            a.scrq,
+            a.ask_goods_id,
+            c.name as department,
+            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_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>
+        <if test="startTime != null and startTime != ''">
+            and a.scrq <![CDATA[>=]]> #{startTime}
+        </if>
+        <if test="endTime != null and endTime != ''">
+            and a.scrq <![CDATA[<=]]> #{endTime}
+        </if>
+        order by a.scrq desc
+    </select>
+    <!-- 查询半成品出库流水导出 -->
+    <select id="getRemovalHalfProductExcel" resultType="java.util.LinkedHashMap">
+        select
+            b.name as materialName,
+            a.num,
+            e.user_name as userName,
+            a.scrq,
+            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_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>
+        <if test="startTime != null and startTime != ''">
+            and a.scrq <![CDATA[>=]]> #{startTime}
+        </if>
+        <if test="endTime != null and endTime != ''">
+            and a.scrq <![CDATA[<=]]> #{endTime}
+        </if>
+        order by a.scrq desc
+    </select>
 </mapper>

+ 2 - 0
src/main/resources/mapper/ContainerMapper.xml

@@ -32,6 +32,7 @@
                 and a.container_name like CONCAT(CONCAT('%', #{containerName}), '%')
             </if>
         </trim>
+        order by a.id desc
     </select>
     <!-- 新增容器内容 -->
     <insert id="addContainer">
@@ -87,6 +88,7 @@
                 and a.container_name = #{containerName}
             </if>
         </trim>
+        order by a.id desc
     </select>
     <!-- 新增报废日志 -->
     <insert id="addScrap">

+ 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)
-        values(#{code},#{name},#{tldId},#{specificationAndModel},#{unitOfMeasurement})
+        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>
     <!-- 字典新增 -->
     <insert id="addDictionary">

+ 33 - 24
src/main/resources/mapper/InviteMapper.xml

@@ -34,7 +34,13 @@
     </insert>
     <!-- 查询生产领料单 -->
     <select id="getAskGoodsfList" resultType="com.tld.model.AskGoods">
-        select ask_goods_id,ask_goods_code,department from tld_invite_f order by sqrq desc
+        select
+            a.ask_goods_id,
+            a.ask_goods_code,
+            b.name as departmentName
+        from tld_invite_f a
+        left join tld_department b on a.department = b.tld_id
+        order by a.sqrq desc
     </select>
     <!-- 查询指定生产单的物料 -->
     <select id="getAskGoodsMaterial" resultType="com.tld.model.AskGoods">
@@ -48,28 +54,31 @@
             tld_invite a
             left join tld_material b on a.material_id = b.tld_id
         WHERE
-            a.ask_goods_id = #{askGoodsId} and a.num <![CDATA[>]]> a.out_num
+            a.ask_goods_id = #{askGoodsId} and (a.num + 0) <![CDATA[>]]> (a.out_num + 0)
     </select>
     <!-- 物料库位选择 -->
     <select id="getMaterialCk" 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
-        from tld_inventory where material_id = #{materialId} order by scrq
+            a.storage_location_code,
+            a.wllb_class,
+            a.library_type,
+            a.material_id,
+            a.amount,
+            a.total,
+            a.totime,
+            a.hold,
+            a.amount_lock,
+            a.account_sleeve,
+            a.wbs,
+            a.supplier_id,
+            a.serial,
+            a.wllb_code,
+            a.produc_date,
+            a.scrq,
+            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
     </select>
     <!-- 新增出库虚拟表 -->
     <insert id="addAskGoodsVitrual">
@@ -95,7 +104,7 @@
             wllb_code,
             produc_date,
             scrq
-        from tld_inventory where supplier_id = #{supplierId} getScanIsNot serial = #{uniqueCode} and wllb_code = #{wllbCode} and produc_date = #{producDate}
+        from tld_inventory where supplier_id = #{supplierId} and serial = #{serial} and wllb_code = #{wllbCode} and produc_date = #{producDate}
     </select>
     <!-- 查询库存是否充足 -->
     <select id="getAsk" resultType="com.tld.model.AskGoods">
@@ -120,8 +129,8 @@
     <!-- 查询是否扫描 -->
     <select id="getScanIsNot" resultType="java.util.Map">
         select
-            (select amount from tld_inventory where supplier_id = #{supplierId} and serial = #{uniqueCode} and wllb_code = #{wllbCode} and produc_date = #{producDate}) as inventoryNum,
-            (select sum(num) from tld_ask_goods_vitrual where supplier_id = #{supplierId} and serial = #{uniqueCode} and wllb_code = #{wllbCode} and produc_date = #{producDate} and type = #{type}) as virtualNum
+            (select ifnull(amount,0) from tld_inventory where supplier_id = #{supplierId} and serial = #{serial} and wllb_code = #{wllbCode} and produc_date = #{producDate}) as inventoryNum,
+            (select ifnull(sum(num),0) from tld_ask_goods_vitrual where supplier_id = #{supplierId} and serial = #{serial} and wllb_code = #{wllbCode} and produc_date = #{producDate} and type = #{type}) as virtualNum
         from dual
     </select>
     <!-- 查询指定送货单信息 -->
@@ -139,7 +148,7 @@
         FROM
             tld_invite a
             join tld_material b on a.material_id = b.tld_id
-        where a.ask_goods_id = #{askGoodsId} and b.code = #{materialCode}
+        where a.ask_goods_id = #{askGoodsId} and b.code = #{wllbCode}
     </select>
     <!-- 查询已扫描总数 -->
     <select id="getAskInfoNumVitrual" resultType="int">
@@ -147,7 +156,7 @@
     </select>
     <!-- 查询此库存在虚拟表里占用的数量 -->
     <select id="getInventoryAlready" resultType="int">
-        select sum(num) from tld_ask_goods_vitrual where supplier_id = #{supplierId} and serial = #{uniqueCode} and wllb_code = #{wllbCode} and produc_date = #{producDate} and type = #{type}
+        select ifnull(sum(num), 0) from tld_ask_goods_vitrual where supplier_id = #{supplierId} and serial = #{serial} and wllb_code = #{wllbCode} and produc_date = #{producDate} and type = #{type}
     </select>
     <!-- 查询虚拟表指定pda跟状态的的数据 -->
     <select id="getVirtualUniqueCode" resultType="com.tld.model.AskGoods">

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

@@ -62,6 +62,12 @@
                 <if test="isNotDisable != null and isNotDisable != ''">
                     is_not_disable = #{isNotDisable},
                 </if>
+                <if test="isRecommend != null and isRecommend != ''">
+                    is_recommend = #{isRecommend},
+                </if>
+                <if test="partType != null and partType != ''">
+                    part_type = #{partType},
+                </if>
             </trim>
         </set>
         where tld_id = #{id}

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

@@ -17,7 +17,7 @@
             </if>
             and type = "PC"
         </trim>
-        order by order_by
+        order by order_by desc
     </select>
     <!-- 查询列表 -->
     <select id="getPage" resultType="com.tld.model.Menu">

+ 2 - 0
src/main/resources/mapper/ReceiveGoodsMapper.xml

@@ -35,6 +35,7 @@
                 and a.order_code = #{orderCode}
             </if>
         </trim>
+    order by a.id desc
     </select>
     <!-- 查询超时采购单 -->
     <select id="getPastReceiveGoods" resultType="com.tld.model.ReceiveGoods">
@@ -56,6 +57,7 @@
         <if test="orderCode != null and orderCode != ''">
             and a.order_code = #{orderCode}
         </if>
+        order by a.id desc
     </select>
     <!-- 查询采购父表是否有次采购单的数据 -->
     <select id="getReceiveGoodsf" resultType="int">

+ 2 - 0
src/main/resources/mapper/RoleMapper.xml

@@ -56,6 +56,7 @@
                 and id = #{id}
             </if>
         </trim>
+        order by id desc
     </select>
     <!-- 删除角色信息 -->
     <delete id="delRole">
@@ -74,5 +75,6 @@
                 and role_name like CONCAT(CONCAT('%', #{roleName}), '%')
             </if>
         </trim>
+        order by id desc
     </select>
 </mapper>

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

@@ -38,6 +38,7 @@
                 and a.id = #{id}
             </if>
         </trim>
+        order by a.id desc
     </select>
     <!-- 新增库位信息 -->
     <insert id="addStorage">
@@ -103,6 +104,7 @@
                 and id = #{id}
             </if>
         </trim>
+        order by a.id desc
     </select>
     <!-- 查询编号是否存在 -->
     <select id="getStorageCount" resultType="int">

+ 2 - 0
src/main/resources/mapper/UserMapper.xml

@@ -54,6 +54,7 @@
                 and a.id = #{id}
             </if>
         </trim>
+        order by id desc
     </select>
     <!-- 新增用户 -->
     <insert id="addUser">
@@ -130,5 +131,6 @@
                 and a.user_name like CONCAT(CONCAT('%', #{userName}), '%')
             </if>
         </trim>
+        order by id desc
     </select>
 </mapper>

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

@@ -209,6 +209,7 @@
                 and a.scrq <![CDATA[<=]]> #{endTime}
             </if>
         </trim>
+        order by scrq desc
     </select>
     <!-- 查询虚拟入库 -->
     <select id="getWarehousingVirtual" resultType="com.tld.model.WarehousingVirtual">
@@ -260,6 +261,7 @@
                 and a.scrq <![CDATA[<=]]> #{endTime}
             </if>
         </trim>
+        order by a.scrq desc
     </select>
     <!-- 查询是否扫描 -->
     <select id="getScanIsNot" resultType="java.util.Map">
@@ -281,4 +283,165 @@
             JOIN tld_material b ON a.material_id = b.tld_id
         WHERE a.produc_date = #{producDate} AND b.code = #{wllbCode} and a.storage_location_code = #{storageLocationCode}
     </select>
+    <!-- 查询报工单 -->
+    <select id="getNotice" resultType="com.tld.model.Notice">
+        select
+            a.id,
+            a.notice_id,
+            a.entry_number,
+            a.production_code,
+            a.material_id,
+            a.wbs,
+            a.measurement_id,
+            a.num,
+            a.type,
+            a.warehousing_num,
+            a.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
+        <trim prefix="WHERE" prefixOverrides="and |or">
+            <if test="type != null and type != ''">
+                and a.type = #{type}
+            </if>
+            <if test="startTime != null and startTime != ''">
+                and b.notice_time <![CDATA[>=]]> #{startTime}
+            </if>
+            <if test="endTime != null and endTime != ''">
+                and b.notice_time <![CDATA[<=]]> #{endTime}
+            </if>
+        </trim>
+    </select>
+    <!-- 查询通知单是否入库 -->
+    <select id="getNoticeId" resultType="com.tld.model.Notice">
+        select
+            a.id,
+            a.notice_id,
+            a.entry_number,
+            a.production_code,
+            a.material_id,
+            a.wbs,
+            a.measurement_id,
+            a.num,
+            a.type,
+            a.warehousing_num,
+            b.wllb_class,
+            c.source_type,
+            c.move_type,
+            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}
+    </insert>
+    <!-- 查询库存里是否存在半成品虚拟库位 -->
+    <select id="getInventoryNotice" resultType="int">
+        select count(0) from tld_inventory where storage_location_code = '000000' 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>
+    <!-- 半成品出库库存查询 -->
+    <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>
+    <!-- 删除库存信息 -->
+    <delete id="delInventoryNotice">
+        delete from tld_inventory where storage_location_code = '000000' 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>
+    <!-- 新增半成品入库流水 -->
+    <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())
+    </insert>
+    <!-- 查询半成品入库流水-->
+    <select id="getProduct" resultType="com.tld.model.Notice">
+        select
+            a.wllb_code,
+            a.produc_date,
+            a.produc_batch,
+            a.capacity,
+            a.user_id,
+            a.storage_location_code,
+            a.scrq
+        from tld_half_product a
+        <trim prefix="WHERE" prefixOverrides="and |or">
+            <if test="wllbCode != null and wllbCode != ''">
+                and a.wllb_code = #{wllbCode}
+            </if>
+            <if test="startTime != null and startTime != ''">
+                and a.scrq <![CDATA[>=]]> #{startTime}
+            </if>
+            <if test="endTime != null and endTime != ''">
+                and a.scrq <![CDATA[<=]]> #{endTime}
+            </if>
+        </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
+        from tld_half_product a
+        right join tld_material b on a.wllb_code = b.tld_id
+        <trim prefix="WHERE" prefixOverrides="and |or">
+            <if test="wllbCode != null and wllbCode != ''">
+                and a.wllb_code = #{wllbCode}
+            </if>
+            <if test="startTime != null and startTime != ''">
+                and a.scrq <![CDATA[>=]]> #{startTime}
+            </if>
+            <if test="endTime != null and endTime != ''">
+                and a.scrq <![CDATA[<=]]> #{endTime}
+            </if>
+        </trim>
+        order by a.scrq desc
+    </select>
+    <!-- 查询要料单信息 -->
+    <select id="getAskGoodsHalf" resultType="com.tld.model.AskGoods">
+        select
+            a.id,
+            a.ask_goods_id,
+            a.material_id,
+            a.wbs,
+            a.measurement_id,
+            a.num,
+            a.out_num,
+            a.entry_number,
+            b.source_type,
+            b.move_type
+        from tld_ask_goods a
+        join tld_ask_goods_f b on a.ask_goods_id = b. ask_goods_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>
+    <!-- 新增半成品流水 -->
+    <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>
 </mapper>