自动化立体仓库 - WMS系统
1
ZY
2024-09-25 a378c8fbae0c40ae2b5387ba4ff052af27107aaf
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package com.zy.asrs.controller;
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.core.annotations.ManagerAuth;
import com.core.common.Cools;
import com.core.common.DateUtils;
import com.core.common.R;
import com.zy.asrs.entity.ManPakOut;
import com.zy.asrs.entity.PlaQty;
import com.zy.asrs.service.ManPakOutService;
import com.zy.asrs.service.PlaQtyService;
import com.zy.asrs.service.PlaService;
import com.zy.common.web.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.*;
import java.util.stream.Collectors;
 
@RestController
public class PlaQtyController extends BaseController {
 
    @Autowired
    private PlaService plaService;
    @Autowired
    private PlaQtyService plaQtyService;
    @Autowired
    private ManPakOutService manPakOutService;
 
    @RequestMapping(value = "/plaQty/list/auth")
    @ManagerAuth
    public R list(@RequestParam(defaultValue = "1")Integer curr,
                  @RequestParam(defaultValue = "10")Integer limit,
                  @RequestParam(required = false)String condition,
                  @RequestParam Map<String, Object> param){
        excludeTrash(param);
        EntityWrapper<PlaQty> wrapper = new EntityWrapper<>();
        convert(param, wrapper);
        allLike(PlaQty.class, param.keySet(), wrapper, condition);
        return R.ok(plaQtyService.selectPage(new Page<>(curr, limit), wrapper));
    }
 
    @RequestMapping(value = "/plaQty/orderDetail/auth")
    @ManagerAuth
    public R getOrderDetail(String orderNo) {
 
        List<PlaQty> plaQties = plaQtyService.selectList(new EntityWrapper<PlaQty>().eq("order_no", orderNo).eq(false,"returned",1));
 
        plaQties = plaQties.stream().filter(plaQty -> {
            ManPakOut manPakOut = manPakOutService.selectOne(new EntityWrapper<ManPakOut>().eq("node_id", plaQty.getId()));
            if (Cools.isEmpty(manPakOut)) {
                return false;
            }
            if (Cools.isEmpty(manPakOut.getStatus()) || manPakOut.getStatus() != 1) {
                return false;
            }
            if(plaQty.getReturned() > 0){
                return false;
            }
 
            return true;
        }).collect(Collectors.toList());
 
 
        return R.ok(plaQties);
    }
 
    @RequestMapping(value = "/plaQty/delivery/auth")
    @ManagerAuth
    public R delivery() {
        return R.ok(plaQtyService.getDeliveryDate());
    }
 
    @RequestMapping(value = "/orderNoQuery/auth")
    @ManagerAuth
    public R query(String condition) {
//        EntityWrapper<PlaQty> wrapper = new EntityWrapper<>();
//        wrapper.setSqlSelect("order_no");
//        wrapper.like("order_no", Cools.isEmpty(condition) ? "0" : condition);
//        wrapper.groupBy("order_no");
//        Page<PlaQty> plaQtyPage = plaQtyService.selectPage(new Page<>(1, 20), wrapper);
        List<String> list = plaQtyService.selectOrderNo(Cools.isEmpty(condition) ? "0" : condition);
        List<Map<String, Object>> result = new ArrayList<>();
        for (String orderNo : list){
            Map<String, Object> map = new HashMap<>();
            PlaQty plaQty = plaQtyService.selectOne(new EntityWrapper<PlaQty>().eq("order_no", orderNo));
            map.put("id", plaQty.getId());
            map.put("value", orderNo);
            map.put("customer", plaQty.getCustomer());
            map.put("type","returned");
            result.add(map);
        }
        return R.ok(result);
    }
 
    private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){
        for (Map.Entry<String, Object> entry : map.entrySet()){
            String val = String.valueOf(entry.getValue());
            if (val.contains(RANGE_TIME_LINK)){
                String[] dates = val.split(RANGE_TIME_LINK);
                wrapper.ge(entry.getKey(), DateUtils.convert(dates[0]));
                wrapper.le(entry.getKey(), DateUtils.convert(dates[1]));
            } else {
                wrapper.eq(entry.getKey(), val);
            }
        }
    }
 
}