zhs před 2 roky
rodič
revize
145ceeeade

+ 21 - 0
src/main/java/com/tld/controller/AskGoodsController.java

@@ -135,4 +135,25 @@ public class AskGoodsController {
     public void getRemovalHalfProductExcel(AskGoods askGoods, HttpServletResponse response){
         askGoodsService.getRemovalHalfProductExcel(askGoods, response);
     }
+
+    /**
+     * 产成品出库流水
+     * @param askGoods 参数
+     * @return 返回结果
+     */
+    @GetMapping("getRemovalHalf")
+    public Map<String, Object> getRemovalHalf(AskGoods askGoods){
+        return askGoodsService.getRemovalHalf(askGoods);
+    }
+
+    /**
+     * 产成品出库流水导出
+     * @param askGoods 参数
+     * @param response 参数
+     * @return 返回结果
+     */
+    @GetMapping("getRemovalHalfExcel")
+    public void getRemovalHalfExcel(AskGoods askGoods, HttpServletResponse response){
+        askGoodsService.getRemovalHalfExcel(askGoods, response);
+    }
 }

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

@@ -0,0 +1,53 @@
+package com.tld.controller;
+
+import com.tld.model.Delivery;
+import com.tld.service.DeliveryService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Map;
+
+/**
+ * 交货单操作
+ */
+@RestController
+@RequestMapping("delivery")
+public class DeliveryController {
+
+    @Autowired
+    private DeliveryService deliveryService;
+
+    /**
+     * 查询销售交货单
+     * @param delivery 参数
+     * @return 返回结果
+     */
+    @GetMapping("getDelivery")
+    public Map<String, Object> getDelivery(Delivery delivery){
+        return deliveryService.getDelivery(delivery);
+    }
+
+    /**
+     * 推荐库位
+     * @param delivery 参数
+     * @return 返回结果
+     */
+    @GetMapping("getRecommend")
+    public Map<String, Object> getRecommend(Delivery delivery){
+        return deliveryService.getRecommend(delivery);
+    }
+
+    /**
+     * 出库
+     * @param uniqueCode PDA唯一表示
+     * @param type 出库类型
+     * @param deliveryId 销售单id
+     * @return 返回结果
+     */
+    @GetMapping("OutOfLibrary")
+    public Map<String, Object> OutOfLibrary(String uniqueCode, String type, String deliveryId){
+        return deliveryService.OutOfLibrary(uniqueCode, type, deliveryId);
+    }
+}

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

@@ -86,4 +86,8 @@ public interface AskGoodsMapper {
     List<AskGoods> getRemovalHalfProduct(AskGoods askGoods);
 
     List<Map<String, Object>> getRemovalHalfProductExcel(AskGoods askGoods);
+
+    List<AskGoods> getRemovalHalf(AskGoods askGoods);
+
+    List<Map<String, Object>> getRemovalHalfExcel(AskGoods askGoods);
 }

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

@@ -0,0 +1,28 @@
+package com.tld.mapper;
+
+import com.tld.model.AskGoods;
+import com.tld.model.Delivery;
+import com.tld.model.Inventory;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+@Mapper
+public interface DeliveryMapper {
+    List<Delivery> getDelivery(Delivery delivery);
+
+    String getStorageLocationCodeList();
+
+    List<Inventory> getInventory(@Param("storageLocationCode")String storageLocationCode, @Param("delivery")Delivery delivery);
+
+    Inventory getInventoryHalf(AskGoods askGoods);
+
+    int getVitrual(Inventory inventory);
+
+    void updateDelivery(@Param("materialId")String materialId, @Param("num")String num, @Param("deliveryId")String deliveryId);
+
+    void addRemovalHalf(Delivery delivery1);
+
+    Delivery getDeliveryF(String deliveryId);
+}

+ 1 - 0
src/main/java/com/tld/mapper/DictionaryMapper.java

@@ -1,5 +1,6 @@
 package com.tld.mapper;
 
+import com.tld.model.Delivery;
 import com.tld.model.Dictionary;
 import org.apache.ibatis.annotations.Mapper;
 

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

@@ -168,4 +168,16 @@ public class AskGoods implements Serializable {
      * 物料类别
      */
     private String partType;
+    /**
+     * 属性
+     */
+    private String attribute;
+    /**
+     * 销售单id
+     */
+    private String deliveryId;
+    /**
+     * 客户名称
+     */
+    private String customerName;
 }

+ 90 - 0
src/main/java/com/tld/model/Delivery.java

@@ -0,0 +1,90 @@
+package com.tld.model;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * 交货单
+ */
+@Data
+@Accessors(chain = true)
+public class Delivery implements Serializable {
+    /**
+     * id主键
+     */
+    private String id;
+    /**
+     * 交货单id
+     */
+    private String deliveryId;
+    /**
+     * 交货单编号
+     */
+    private String deliveryCode;
+    /**
+     * 公司编号
+     */
+    private String companyNumber;
+    /**
+     * 客户编号
+     */
+    private String customerCode;
+    /**
+     * 单据日期
+     */
+    private String billsTime;
+    /**
+     * 交货类型
+     */
+    private String deliveryType;
+    /**
+     * 来源类型
+     */
+    private String sourceType;
+    /**
+     * 移动类型
+     */
+    private String moveType;
+    /**
+     * gs分录号
+     */
+    private String entryNumber;
+    /**
+     * 物料id
+     */
+    private String materialId;
+    /**
+     * 物料名称
+     */
+    private String materialName;
+    /**
+     * 物料code
+     */
+    private String materialCode;
+    /**
+     * wbs
+     */
+    private String wbs;
+    /**
+     * 计量单位
+     */
+    private String measurementId;
+    /**
+     * 交货数量
+     */
+    private String gsDeliveryNum;
+    /**
+     * gs取消交货数量
+     */
+    private String gsCancelNum;
+    /**
+     * 出库数量
+     */
+    private String outNum;
+    /**
+     * 用户id
+     */
+    private String userId;
+}

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

@@ -144,5 +144,9 @@ public class Notice implements Serializable {
      *
      */
     private String uniqueCode;
+    /**
+     * 物料类别
+     */
+    private String partType;
 
 }

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

@@ -32,6 +32,10 @@ public class ReturRemoval implements Serializable {
      * 移动类型
      */
     private String moveType;
+    /**
+     * 交货类型
+     */
+    private String deliveryType;
     /**
      * 分录单id
      */
@@ -76,4 +80,12 @@ public class ReturRemoval implements Serializable {
      * 用户编号
      */
     private String userId;
+    /**
+     * 单据id
+     */
+    private String documentId;
+    /**
+     * 分录单id
+     */
+    private String documentPointsId;
 }

+ 4 - 0
src/main/java/com/tld/service/AskGoodsService.java

@@ -34,4 +34,8 @@ public interface AskGoodsService {
     Map<String, Object> getRemovalHalfProduct(AskGoods askGoods);
 
     void getRemovalHalfProductExcel(AskGoods askGoods, HttpServletResponse response);
+
+    Map<String, Object> getRemovalHalf(AskGoods askGoods);
+
+    void getRemovalHalfExcel(AskGoods askGoods, HttpServletResponse response);
 }

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

@@ -0,0 +1,13 @@
+package com.tld.service;
+
+import com.tld.model.Delivery;
+
+import java.util.Map;
+
+public interface DeliveryService {
+    Map<String, Object> getDelivery(Delivery delivery);
+
+    Map<String, Object> getRecommend(Delivery delivery);
+
+    Map<String, Object> OutOfLibrary(String uniqueCode, String type, String deliveryId);
+}

+ 52 - 5
src/main/java/com/tld/service/impl/AskGoodsServiceImpl.java

@@ -150,6 +150,7 @@ public class AskGoodsServiceImpl implements AskGoodsService {
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public Map<String, Object> addAskGoodsVitrual(AskGoods askGoods) {
         Map<String, Object> map = new HashMap<>();
         try{
@@ -163,7 +164,7 @@ public class AskGoodsServiceImpl implements AskGoodsService {
             AskGoods askGoods1 = askGoodsMapper.getAsknInfo(askGoods); //要货单数量
             int alreadyNum =  askGoodsMapper.getAskInfoNumVitrual(askGoods);//已扫描总数
             int inventoryAlready =  askGoodsMapper.getInventoryAlready(askGoods);//库存已扫描数量
-            int inventorySurplus = Integer.parseInt(inventory.getAmount()) - inventoryAlready; //库存剩余数量
+            int inventorySurplus = (Integer.parseInt(inventory.getAmount()) - Integer.parseInt(inventory.getAmountLock())) - inventoryAlready; //库存剩余数量
             int surplusNum = Integer.parseInt(askGoods1.getNum()) - alreadyNum; //剩余要扫描数量
 
             if(surplusNum >= inventorySurplus){
@@ -183,6 +184,7 @@ public class AskGoodsServiceImpl implements AskGoodsService {
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public Map<String, Object> OutOfLibrary(String uniqueCode, String type, String askGoodsId) {
         Map<String, Object> map = new HashMap<>();
         //redis并发锁
@@ -203,11 +205,11 @@ public class AskGoodsServiceImpl implements AskGoodsService {
                 AskGoods askGoods1 = askGoodsMapper.getAskDetailed(askGoodsId, materialId);//查询要料申请单内容
                 ReturRemoval returRemoval = new ReturRemoval()
                         .setMaterialId(materialId)
-                        .setAskGoodsId(askGoodsId)
+                        .setDocumentId(askGoodsId)
                         .setWbs(askGoods1.getWbs())
                         .setNum(askGoods.getNum())
                         .setEntryNumber(askGoods1.getEntryNumber())
-                        .setAskId(askGoods1.getId())
+                        .setDocumentPointsId(askGoods1.getId())
                         .setStorageLocationCode(askGoods.getStorageLocationCode());
                 askGoodsMapper.addRemoval(askGoods);//插入出库流水
                 askGoodsMapper.deleteVirtual(askGoods.getId());//删除已出虚拟表库存
@@ -218,7 +220,7 @@ public class AskGoodsServiceImpl implements AskGoodsService {
             AskGoods askGoods3 = askGoodsMapper.getAskDetailedF(askGoodsId);
             String removalCode = codeGenerateCk();
             ReturRemoval returRemoval1 = new ReturRemoval()
-                    .setAskGoodsId(askGoods3.getAskGoodsId())
+                    .setDocumentId(askGoods3.getAskGoodsId())
                     .setRemovalCode(removalCode)
                     .setSourceType(askGoods3.getSourceType())
                     .setMoveType(askGoods3.getMoveType());
@@ -357,6 +359,7 @@ public class AskGoodsServiceImpl implements AskGoodsService {
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public Map<String, Object> delAskGoodsVitrual(String id, String type) {
         Map<String, Object> map = new HashMap<>();
         try{
@@ -425,7 +428,51 @@ public class AskGoodsServiceImpl implements AskGoodsService {
             //当前时间
             Date time = new Date();
             SimpleDateFormat sdf = new SimpleDateFormat("yyyyMddHHmmss");
-            ExcelUtils.export(response, "出库流水数据导出" + sdf.format(time), sheetDataList);
+            ExcelUtils.export(response, "半成品出库流水数据导出" + sdf.format(time), sheetDataList);
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+    }
+
+    @Override
+    public Map<String, Object> getRemovalHalf(AskGoods askGoods) {
+        Map<String, Object> map = new HashMap<>();
+        try{
+            //查询数据
+            PageHelper.startPage(askGoods.getPage(), askGoods.getLimit());
+            PageInfo<AskGoods> list = new PageInfo<>(askGoodsMapper.getRemovalHalf(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 getRemovalHalfExcel(AskGoods askGoods, HttpServletResponse response) {
+        try{
+            //导出数据汇总
+            List<List<Object>> sheetDataList = new ArrayList<>();
+            //表头数据
+            List<Object> head = Arrays.asList("物料名称", "出库数量", "用户名称", "出库时间", "公司编号", "客户编号");
+            //查询数据
+            PageHelper.startPage(askGoods.getPage(), askGoods.getLimit());
+            PageInfo<Map<String, Object>> list = new PageInfo<>(askGoodsMapper.getRemovalHalfExcel(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();
         }

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

@@ -173,6 +173,7 @@ public class ContainerServiceImpl implements ContainerService {
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public Map<String, Object> delCon(String id) {
         Map<String, Object> map = new HashMap<>();
         try{

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

@@ -0,0 +1,151 @@
+package com.tld.service.impl;
+
+import com.tld.mapper.AskGoodsMapper;
+import com.tld.mapper.DeliveryMapper;
+import com.tld.model.AskGoods;
+import com.tld.model.Delivery;
+import com.tld.model.Inventory;
+import com.tld.model.ReturRemoval;
+import com.tld.service.DeliveryService;
+import org.redisson.api.RLock;
+import org.redisson.api.RedissonClient;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+@Service
+public class DeliveryServiceImpl implements DeliveryService {
+
+    @Autowired
+    private DeliveryMapper deliveryMapper;
+
+    @Autowired
+    private AskGoodsMapper askGoodsMapper;
+    //redis锁
+    @Autowired
+    private RedissonClient redissonClient;
+
+    @Override
+    public Map<String, Object> getDelivery(Delivery delivery) {
+        Map<String, Object> map = new HashMap<>();
+        try{
+            List<Delivery> list = deliveryMapper.getDelivery(delivery);
+            map.put("data", list);
+            map.put("msg", "200");
+        }catch (Exception e){
+            map.put("msg", "500");
+            map.put("errMsg", "服务器请求异常,请稍后再试");
+            e.printStackTrace();
+        }
+        return map;
+    }
+
+    @Override
+    public Map<String, Object> getRecommend(Delivery delivery) {
+        Map<String, Object> map = new HashMap<>();
+        try{
+            //查询所有产成品库位
+            String storageLocationCode = deliveryMapper.getStorageLocationCodeList();
+            List<Inventory> list = new LinkedList<>();
+            Map<String, Object> occupyMap = new HashMap<>();
+            for(Inventory inventory : deliveryMapper.getInventory(storageLocationCode, delivery)){
+                int occupy = deliveryMapper.getVitrual(inventory);
+                if(Integer.parseInt(inventory.getAmount()) > occupy){
+                    list.add(inventory);
+                    int num = Integer.parseInt(inventory.getAmount()) - occupy;
+                    occupyMap.put(inventory.getStorageLocationCode(), num);
+                }
+            }
+            map.put("data", list);
+            map.put("occupyMap", occupyMap);
+            map.put("msg", "200");
+        }catch (Exception e){
+            map.put("msg", "500");
+            map.put("errMsg", "服务器请求异常,请稍后再试");
+            e.printStackTrace();
+        }
+        return map;
+    }
+
+    @Override
+    public Map<String, Object> OutOfLibrary(String uniqueCode, String type, String deliveryId) {
+        Map<String, Object> map = new HashMap<>();
+        //redis并发锁
+        RLock lock = redissonClient.getLock(uniqueCode);
+        lock.lock();
+        try{
+            for(AskGoods askGoods : askGoodsMapper.getAskGoodsVitrual(uniqueCode, type)){
+                Inventory inventory = deliveryMapper.getInventoryHalf(askGoods);
+                //如果出库库存等于虚拟表库存则删除此库存
+                if(Integer.parseInt(askGoods.getNum()) == Integer.parseInt(inventory.getAmount())){
+                    askGoodsMapper.deleteInventory(inventory);
+                } else {
+                    inventory.setAmount(askGoods.getNum());
+                    askGoodsMapper.updateInventory(inventory);
+                }
+                String materialId = askGoodsMapper.getMaterialId(askGoods.getWllbCode());//查询物料id
+                deliveryMapper.updateDelivery(materialId, askGoods.getNum(), deliveryId); //修改销售单出库数量
+                //查询销售单部分信息
+                Delivery delivery = new Delivery().setDeliveryId(deliveryId).setMaterialId(materialId);
+                List<Delivery> list = deliveryMapper.getDelivery(delivery);
+                //产成品销售流水
+                Delivery delivery1 = new Delivery()
+                        .setMaterialCode(askGoods.getWllbCode()) //物料code
+                        .setOutNum(askGoods.getNum()) //出库数量
+                        .setUserId(askGoods.getUserId()) //用户id
+                        .setDeliveryId(deliveryId) //销售单id
+                        .setCompanyNumber(list.get(0).getCompanyNumber()) //公司编号
+                        .setCustomerCode(list.get(0).getCustomerCode()); //客户编号
+                deliveryMapper.addRemovalHalf(delivery1); //流水录入
+                askGoodsMapper.deleteVirtual(askGoods.getId());//删除已出虚拟表库存
+                ReturRemoval returRemoval = new ReturRemoval()
+                        .setMaterialId(materialId)
+                        .setDocumentId(deliveryId)
+                        .setWbs(list.get(0).getWbs())
+                        .setNum(askGoods.getNum())
+                        .setEntryNumber(list.get(0).getEntryNumber())
+                        .setDocumentPointsId(list.get(0).getId())
+                        .setStorageLocationCode(askGoods.getStorageLocationCode());
+                askGoodsMapper.addReturnGsRemoval(returRemoval);//新增返回gs数据子表信息
+            }
+            //新增销售单出库父表信息
+            String removalCode = codeGenerateCk();
+            Delivery delivery = deliveryMapper.getDeliveryF(deliveryId);
+            ReturRemoval returRemoval1 = new ReturRemoval()
+                    .setDocumentId(delivery.getDeliveryId())
+                    .setRemovalCode(removalCode)
+                    .setSourceType(delivery.getSourceType())
+                    .setMoveType(delivery.getMoveType())
+                    .setDeliveryType(delivery.getDeliveryType());
+            askGoodsMapper.addReturnGsRemovalF(returRemoval1);//新增返回gs数据父表信息
+            map.put("data", removalCode);
+            map.put("msg", "200");
+        }catch (Exception e){
+            map.put("msg", "500");
+            map.put("errMsg", "服务器请求异常,请稍后再试");
+            e.printStackTrace();
+        } finally {
+            //释放锁
+            lock.unlock();
+        }
+        return map;
+    }
+
+    /**
+     * 出库单生成
+     * @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();
+    }
+}

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

@@ -9,6 +9,7 @@ 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;
 
 import java.text.SimpleDateFormat;
 import java.util.*;
@@ -85,6 +86,7 @@ public class InviteServiceImpl implements InviteService {
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public Map<String, Object> addAskGoodsVitrual(AskGoods askGoods) {
         Map<String, Object> map = new HashMap<>();
         try{
@@ -98,7 +100,7 @@ public class InviteServiceImpl implements InviteService {
             AskGoods askGoods1 = inviteMapper.getAsknInfo(askGoods); //要货单数量
             int alreadyNum =  inviteMapper.getAskInfoNumVitrual(askGoods);//已扫描总数
             int inventoryAlready =  inviteMapper.getInventoryAlready(askGoods);//库存已扫描数量
-            int inventorySurplus = Integer.parseInt(inventory.getAmount()) - inventoryAlready; //库存剩余数量
+            int inventorySurplus = (Integer.parseInt(inventory.getAmount()) - Integer.parseInt(inventory.getAmountLock())) - inventoryAlready; //库存剩余数量
             int surplusNum = Integer.parseInt(askGoods1.getNum()) - alreadyNum; //剩余要扫描数量
 
             if(surplusNum >= inventorySurplus){
@@ -118,6 +120,7 @@ public class InviteServiceImpl implements InviteService {
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public Map<String, Object> OutOfLibrary(String uniqueCode, String type, String askGoodsId) {
         Map<String, Object> map = new HashMap<>();
         //redis并发锁
@@ -138,11 +141,11 @@ public class InviteServiceImpl implements InviteService {
                 AskGoods askGoods1 = inviteMapper.getAskDetailed(askGoodsId, materialId);//查询要料申请单内容
                 ReturRemoval returRemoval = new ReturRemoval()
                         .setMaterialId(materialId)
-                        .setAskGoodsId(askGoodsId)
+                        .setDocumentId(askGoodsId)
                         .setWbs(askGoods1.getWbs())
                         .setNum(askGoods.getNum())
                         .setEntryNumber(askGoods1.getEntryNumber())
-                        .setAskId(askGoods1.getId())
+                        .setDocumentPointsId(askGoods1.getId())
                         .setStorageLocationCode(askGoods.getStorageLocationCode());
                 inviteMapper.addRemoval(askGoods);//插入出库流水
                 inviteMapper.deleteVirtual(askGoods.getId());//删除已出虚拟表库存
@@ -152,7 +155,7 @@ public class InviteServiceImpl implements InviteService {
             AskGoods askGoods3 = inviteMapper.getAskDetailedF(askGoodsId);
             String removalCode = codeGenerateCk();
             ReturRemoval returRemoval1 = new ReturRemoval()
-                    .setAskGoodsId(askGoods3.getAskGoodsId())
+                    .setDocumentId(askGoods3.getAskGoodsId())
                     .setRemovalCode(removalCode)
                     .setSourceType(askGoods3.getSourceType())
                     .setMoveType(askGoods3.getMoveType());

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

@@ -137,6 +137,7 @@ public class WarehousingServiceImpl implements WarehousingService {
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public Map<String, Object> warehousing(String uniqueCode, String type) {
         Map<String, Object> map = new HashMap<>();
         try{
@@ -338,6 +339,7 @@ public class WarehousingServiceImpl implements WarehousingService {
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public Map<String, Object> addInventoryNotice(Notice notice) {
         Map<String, Object> map = new HashMap<>();
         try{
@@ -391,6 +393,7 @@ public class WarehousingServiceImpl implements WarehousingService {
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public Map<String, Object> updateInventoryNotice(Notice notice) {
         Map<String, Object> map = new HashMap<>();
         //redis并发锁
@@ -635,6 +638,7 @@ public class WarehousingServiceImpl implements WarehousingService {
                 if (!stringBuilder.toString().contains(notice1.getNoticeId() + ",")) {
                     stringBuilder.append(notice1.getNoticeId() + ",");
                 }
+                warehousingMapper.delVirtual(uniqueCode);//删除临时表数据
             }
             map.put("msg", "200");
             map.put("data", stringBuilder.toString());

+ 64 - 11
src/main/resources/mapper/AskGoodsMapper.xml

@@ -64,7 +64,7 @@
             a.wllb_class,
             a.library_type,
             a.material_id,
-            a.amount,
+            (a.amount - ifnull(a.amount_lock, 0)) as amount,
             a.total,
             a.totime,
             a.hold,
@@ -79,12 +79,12 @@
             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.produc_date
+        where a.material_id = #{materialId} and a.hold = '0' order by a.produc_date
     </select>
     <!-- 新增出库虚拟表 -->
     <insert id="addAskGoodsVitrual">
-        insert into tld_ask_goods_vitrual(unique_code,supplier_id,serial,wllb_code,produc_date,ask_goods_id,type,storage_location_code,num,user_id,department)
-        values(#{uniqueCode},#{supplierId},#{serial},#{wllbCode},#{producDate},#{askGoodsId},#{type},#{storageLocationCode},#{num},#{userId},#{department})
+        insert into tld_ask_goods_vitrual(unique_code,supplier_id,serial,wllb_code,produc_date,ask_goods_id,type,storage_location_code,num,user_id,department,attribute)
+        values(#{uniqueCode},#{supplierId},#{serial},#{wllbCode},#{producDate},#{askGoodsId},#{type},#{storageLocationCode},#{num},#{userId},#{department},#{attribute})
     </insert>
     <!-- 查询指定库存内容 -->
     <select id="getInventory" resultType="com.tld.model.Inventory">
@@ -207,8 +207,8 @@
     </select>
     <!-- 新增返回gs数据字表信息 -->
     <insert id="addReturnGsRemoval">
-        insert into tld_return_gs_removal_z(material_id,wbs,num,entry_number,ask_goods_id,ask_id,storage_location_code)
-        values(#{materialId},#{wbs},#{num},#{entryNumber},#{askGoodsId},#{askId},#{storageLocationCode})
+        insert into tld_return_gs_removal_z(material_id,wbs,num,entry_number,document_id,ask_id,storage_location_code)
+        values(#{materialId},#{wbs},#{num},#{entryNumber},#{documentId},#{documentPointsId},#{storageLocationCode})
     </insert>
     <!-- 查询要货单父级信息 -->
     <select id="getAskDetailedF" resultType="com.tld.model.AskGoods">
@@ -225,8 +225,8 @@
     </select>
     <!-- 新增返回gs数据父表信息 -->
     <insert id="addReturnGsRemovalF">
-        insert into tld_return_gs_removal(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,delivery_type)
+        values(#{documentId},#{removalCode},#{sourceType},#{moveType},now(),#{deliveryType})
     </insert>
     <!-- 查询当天出库数量 -->
     <select id="getReturnRemovalCount" resultType="int">
@@ -236,7 +236,7 @@
     <select id="plugOutRemoval" resultType="java.util.Map">
         select
             id,
-            ask_goods_id as askGoodsId,
+            document_id as askGoodsId,
             removal_code as removalCode,
             source_type as sourceType,
             move_type as moveType
@@ -249,8 +249,8 @@
             wbs,
             num,
             entry_number as entryNumber,
-            ask_goods_id as askGoodsId,
-            ask_id as askId
+            document_id as askGoodsId,
+            document_points_id as askId
         from tld_return_gs_removal_z where ask_goods_id = #{askGoodsId}
     </select>
     <!-- 查询出库流水 -->
@@ -440,4 +440,57 @@
         </if>
         order by a.scrq desc
     </select>
+    <!-- 产成品出库流水 -->
+    <select id="getRemovalHalf" resultType="com.tld.model.AskGoods">
+        select
+            a.id,
+            a.wllb_code,
+            a.num,
+            a.user_id,
+            a.scrq,
+            a.delivery_id,
+            a.company_number,
+            a.customer_code,
+            b.name as materialName,
+            c.user_name as userName,
+            e.name as customerName
+        from tld_removal_half 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_customer e on a.customer_code = e.code
+        <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>
+        order by a.scrq desc
+    </select>
+    <!-- 产成品导出出库流水 -->
+    <select id="getRemovalHalfExcel" resultType="java.util.LinkedHashMap">
+        select
+            b.name as materialName,
+            a.num,
+            c.user_name as userName
+            a.scrq,
+            a.company_number,
+            e.name
+        from tld_removal_half 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_customer e on a.customer_code = e.code
+        <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>
+        order by a.scrq desc
+    </select>
 </mapper>

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

@@ -0,0 +1,118 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.tld.mapper.DeliveryMapper">
+    <!-- 查询销售交货单 -->
+    <select id="getDelivery" resultType="com.tld.model.Delivery">
+        select
+            a.id,
+            a.delivery_id,
+            a.entry_number,
+            a.material_id,
+            a.wbs,
+            a.measurement_id,
+            a.gs_delivery_num,
+            a.gs_cancel_num,
+            a.out_num,
+            b.company_number,
+            b.bills_time,
+            b.delivery_type,
+            b.source_type,
+            b.move_type,
+            c.name as materialName,
+            c.code as materialCode
+        from tld_delivery a
+        join tld_delivery_f b on a.delivery_id = b.delivery_id
+        left join tld_material c on a.material_id = c.tld_id
+        where (a.gs_delivery_num - a.gs_cancel_num) != a.out_num
+        <if test="deliveryId != null and deliveryId != ''">
+            and a.delivery_id = #{deliveryId}
+        </if>
+        <if test="materialId != null and materialId != ''">
+            and a.material_id = #{materialId}
+        </if>
+    </select>
+    <!-- 查询所有产成品库位 -->
+    <select id="getStorageLocationCodeList" resultType="String">
+        select
+               CONCAT(GROUP_CONCAT(storage_location_code SEPARATOR ","),',')
+        from tld_storage_location where is_product = '1'
+    </select>
+    <!-- 查询指定库位跟物料的库存 -->
+    <select id="getInventory" resultType="com.tld.model.Inventory">
+        SELECT
+            a.id,
+            a.storage_location_code,
+            a.wllb_class,
+            a.library_type,
+            a.material_id,
+            (a.amount - ifnull(a.amount_lock, 0)) as amount,
+            a.wbs,
+            a.serial,
+            a.wllb_code,
+            a.produc_date,
+            a.scrq,
+            a.produc_batch,
+            a.attribute,
+            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 CONCAT(#{storageLocationCode},'111111,') LIKE CONCAT( '%', CONCAT( a.storage_location_code, ',' ), '%' )
+          AND a.material_id = #{delivery.materialId} AND a.hold = '0'
+        ORDER BY
+            a.produc_batch
+    </select>
+    <!-- 查询指定库存内容 -->
+    <select id="getInventoryHalf" resultType="com.tld.model.AskGoods">
+        SELECT
+            a.id,
+            a.storage_location_code,
+            a.wllb_class,
+            a.library_type,
+            a.material_id,
+            a.amount,
+            a.amount_lock,
+            a.wbs,
+            a.serial,
+            a.wllb_code,
+            a.produc_date,
+            a.scrq,
+            a.produc_batch,
+            a.attribute,
+            b.storage_location_name as storageLocationName
+        FROM tld_inventory a
+        JOIN tld_material b on a.material_id = b.tld_id
+        WHERE a.attribute = #{attribute} and a.produc_batch = #{producDate} and a.serial = #{serial} and b.code = #{wllbCode}
+    </select>
+    <!-- 查询指定库存被占用数量 -->
+    <select id="getVitrual" resultType="int">
+        select
+               ifnull(sum(a.num), 0)
+        from tld_ask_goods_vitrual a
+        join tld_material b on a.wllb_code = b.code
+        where a.storage_location_code = #{storageLocationCode} and b.code = #{wllbCode} and a.attribute = #{attribute} and a.produc_date = #{producBatch}
+    </select>
+    <!-- 修改销售单出库数量 -->
+    <update id="updateDelivery">
+        update tld_delivery set out_num = #{num} where delivery_id = #{deliveryId} and material_id = #{materialId}
+    </update>
+    <!-- 产成品出库流水 -->
+    <insert id="addRemovalHalf">
+        insert into tld_removal_half(wllb_code,num,user_id,scrq,delivery_id,company_number,customer_code)
+        value(#{materialCode},#{outNum},#{userId},now(),#{deliveryId},#{companyNumber},#{customerCode})
+    </insert>
+    <!-- 查询销售单父级信息 -->
+    <select id="getDeliveryF" resultType="com.tld.model.Delivery">
+        select
+            id,
+            delivery_id,
+            delivery_code,
+            company_number,
+            customer_code,
+            bills_time,
+            delivery_type,
+            source_type,
+            move_type
+        from tld_delivery_f where delivery_id = #{deliveryId}
+    </select>
+</mapper>

+ 4 - 4
src/main/resources/mapper/InviteMapper.xml

@@ -70,7 +70,7 @@
             a.wllb_class,
             a.library_type,
             a.material_id,
-            a.amount,
+            (a.amount - ifnull(a.amount_lock, 0)) as amount,
             a.total,
             a.totime,
             a.hold,
@@ -241,7 +241,7 @@
     <select id="plugOutRemoval" resultType="java.util.Map">
         select
             id,
-            ask_goods_id as askGoodsId,
+            document_id as askGoodsId,
             removal_code as removalCode,
             source_type as sourceType,
             move_type as moveType
@@ -254,8 +254,8 @@
             wbs,
             num,
             entry_number as entryNumber,
-            ask_goods_id as askGoodsId,
-            ask_id as askId
+            document_id as askGoodsId,
+            document_points_id as askId
         from tld_return_gs_removal_z where ask_goods_id = #{askGoodsId}
     </select>
     <!-- 查询出库流水 -->

+ 5 - 2
src/main/resources/mapper/WarehousingMapper.xml

@@ -282,7 +282,7 @@
         FROM
             tld_inventory a
             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}
+        WHERE a.produc_date = #{producDate} AND b.code = #{wllbCode} and a.storage_location_code = #{storageLocationCode} and hold = '0'
     </select>
     <!-- 查询报工单 -->
     <select id="getNotice" resultType="com.tld.model.Notice">
@@ -316,6 +316,9 @@
             <if test="endTime != null and endTime != ''">
                 and b.notice_time <![CDATA[<=]]> #{endTime}
             </if>
+            <if test="partType != null and partType != ''">
+                and c.part_type = #{partType}
+            </if>
         </trim>
     </select>
     <!-- 查询通知单是否入库 -->
@@ -470,7 +473,7 @@
             is_not_disable,
             is_recommend,
             part_type
-        from tld_material where tld_id = #{materialId}
+        from tld_material
         <trim prefix="WHERE" prefixOverrides="and |or">
             <if test="materialId != null and materialId != ''">
                 and tld_id = #{materialId}