自动化立体仓库 - WMS系统
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
package com.zy.asrs.controller;
 
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.plugins.Page;
import com.core.annotations.ManagerAuth;
import com.core.common.R;
import com.zy.asrs.entity.OrderDetlPakoutLog;
import com.zy.asrs.entity.OrderPakoutLog;
import com.zy.asrs.service.OrderDetlPakoutLogService;
import com.zy.asrs.service.OrderPakoutLogService;
import com.zy.common.web.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.List;
import java.util.Map;
 
@RestController
@RequestMapping("order/pakout/history")
public class OrderPakoutLogController extends BaseController {
 
    @Autowired
    private OrderPakoutLogService orderPakoutLogService;
    @Autowired
    private OrderDetlPakoutLogService orderDetlPakoutLogService;
 
    @RequestMapping(value = "/order/list/auth")
    @ManagerAuth(memo = "出库单据历史档查询")
    public R list(@RequestParam(defaultValue = "1") Integer curr,
                  @RequestParam(defaultValue = "10") Integer limit,
                  @RequestParam Map<String, Object> param) {
        excludeTrash(param);
        normalizeRange(param, "create_time", "createTimeStart", "createTimeEnd");
        normalizeRange(param, "update_time", "updateTimeStart", "updateTimeEnd");
        return R.ok(orderPakoutLogService.selectHistoryPage(toSimplePage(curr, limit, param)));
    }
 
    @RequestMapping(value = "/orderDetl/list/auth")
    @ManagerAuth(memo = "出库单据历史明细查询")
    public R detlList(@RequestParam(defaultValue = "1") Integer curr,
                      @RequestParam(defaultValue = "10") Integer limit,
                      @RequestParam Map<String, Object> param) {
        excludeTrash(param);
        return R.ok(orderDetlPakoutLogService.selectHistoryPage(toSimplePage(curr, limit, param)));
    }
 
    @RequestMapping(value = "/order/export/auth")
    @ManagerAuth(memo = "出库单据历史档导出")
    public R export(@RequestBody JSONObject param) {
        List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class);
        Map<String, Object> map = excludeTrash(param.getJSONObject("orderPakoutLog"));
        normalizeRange(map, "create_time", "createTimeStart", "createTimeEnd");
        normalizeRange(map, "update_time", "updateTimeStart", "updateTimeEnd");
        List<OrderPakoutLog> list = orderPakoutLogService.selectHistoryAll(map);
        return R.ok(exportSupport(list, fields));
    }
 
    private void normalizeRange(Map<String, Object> param, String sourceKey, String startKey, String endKey) {
        Object rangeObj = param.remove(sourceKey);
        if (rangeObj == null) {
            return;
        }
        String range = String.valueOf(rangeObj);
        if (!range.contains(RANGE_TIME_LINK)) {
            param.put(sourceKey, range);
            return;
        }
        String[] dates = range.split(RANGE_TIME_LINK);
        if (dates.length > 0) {
            param.put(startKey, dates[0]);
        }
        if (dates.length > 1) {
            param.put(endKey, dates[1]);
        }
    }
 
    private <T> Page<T> toSimplePage(Integer pageNumber, Integer pageSize, Map<String, Object> map) {
        Page<T> page = new Page<>(pageNumber, pageSize);
        map.put("pageNumber", pageNumber);
        map.put("pageSize", pageSize);
        page.setCondition(map);
        return page;
    }
}