自动化立体仓库 - WMS系统
zjj
2023-09-06 914a092bc4c21d69641f94b68fecf61b25ddaca1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package com.zy.asrs.service.impl;
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.zy.asrs.entity.ManLocDetl;
import com.zy.asrs.entity.Order;
import com.zy.asrs.entity.OrderDetl;
import com.zy.asrs.mapper.PakoutMapper;
import com.zy.asrs.entity.Pakout;
import com.zy.asrs.service.*;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.List;
 
@Service("pakoutService")
public class PakoutServiceImpl extends ServiceImpl<PakoutMapper, Pakout> implements PakoutService {
    @Autowired
    private OrderService orderService;
 
    @Autowired
    private OrderDetlService orderDetlService;
 
    @Autowired
    private ManLocDetlService manLocDetlService;
 
    @Override
    public void deletePakout(String docNum) {
        Order order = orderService.selectByNo(docNum);
        List<OrderDetl> orderDetls = orderDetlService.selectList(new EntityWrapper<OrderDetl>().eq("order_no", docNum));
 
        for (OrderDetl orderDetl: orderDetls){
            if (orderDetl.getQty() > 0.0){
                throw new RuntimeException("拣货单已有出库任务,不可删除!");
            }
            orderDetl.setWorkQty(0.0D);
        }
 
       if (!orderDetlService.updateBatchById(orderDetls)){
           throw new RuntimeException("订单明细批量更新失败");
       }
       order.setSettle(1L);
       if (!orderService.updateById(order)){
           throw new RuntimeException("订单明细批量更新失败");
       }
 
        List<Pakout> pakouts = selectList(new EntityWrapper<Pakout>().eq("doc_num", docNum));
       for (Pakout pakout: pakouts){
           ManLocDetl manLocDetl = manLocDetlService.selectOne(new EntityWrapper<ManLocDetl>()
                   .eq("loc_no", pakout.getLocNo())
                   .eq("matnr", pakout.getMatnr()));
           manLocDetl.setStatus(1);
           if (!manLocDetlService.update(manLocDetl,new EntityWrapper<ManLocDetl>()
                   .eq("loc_no", pakout.getLocNo())
                   .eq("matnr", pakout.getMatnr()))){
               throw new RuntimeException("库存状态更新失败");
           }
       }
 
        if (!delete(new EntityWrapper<Pakout>().eq("doc_num",docNum))){
          throw new RuntimeException("拣货单删除失败");
      }
 
 
    }
}