自动化立体仓库 - WMS系统
ZY
2025-02-07 49e1cab7fb101c81ebdcc74f945c15947802a154
src/main/java/com/zy/asrs/controller/OrderLogController.java
@@ -1,5 +1,6 @@
package com.zy.asrs.controller;
import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
@@ -8,13 +9,17 @@
import com.core.common.*;
import com.zy.asrs.entity.*;
import com.zy.asrs.entity.result.WrkTraceVo;
import com.zy.asrs.excel.CloseOrderReadListener;
import com.zy.asrs.excel.ExcelOrder;
import com.zy.asrs.service.*;
import com.zy.common.web.BaseController;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.*;
@Slf4j
@@ -39,10 +44,12 @@
    private LocDetlService locDetlService;
    @Autowired
    private MatService matService;
    @Autowired
    private OrderService orderService;
    @RequestMapping(value = "/orderLog/nav/list/auth")
    @ManagerAuth
    public R navList(@RequestParam(required = false) String orderNo){
    public R navList(@RequestParam(required = false) String orderNo) {
        EntityWrapper<OrderLog> wrapper = new EntityWrapper<>();
        if (!Cools.isEmpty(orderNo)) {
            wrapper.like("order_no", orderNo);
@@ -70,15 +77,17 @@
    @RequestMapping(value = "/orderLog/head/page/auth")
    @ManagerAuth
    public R head(@RequestParam(defaultValue = "1")Integer curr,
                  @RequestParam(defaultValue = "10")Integer limit,
                  @RequestParam(required = false)String orderByField,
                  @RequestParam(required = false)String orderByType,
                  @RequestParam Map<String, Object> param){
    public R head(@RequestParam(defaultValue = "1") Integer curr,
                  @RequestParam(defaultValue = "10") Integer limit,
                  @RequestParam(required = false) String orderByField,
                  @RequestParam(required = false) String orderByType,
                  @RequestParam Map<String, Object> param) {
        EntityWrapper<OrderLog> wrapper = new EntityWrapper<>();
        excludeTrash(param);
        convert(param, wrapper);
        if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} else {
        if (!Cools.isEmpty(orderByField)) {
            wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));
        } else {
            wrapper.orderBy("settle").orderBy("create_time", false);
        }
        wrapper.eq("status", 1);
@@ -87,12 +96,9 @@
    @RequestMapping(value = "/orderLog/detl/all/auth")
    @ManagerAuth
    public R head(@RequestParam Long orderId){
    public R head(@RequestParam Long orderId) {
        return R.ok().add(orderDetlLogService.selectList(new EntityWrapper<OrderDetlLog>().eq("order_id", orderId)));
    }
    @PostMapping(value = "/orderLog/wrk/trace/auth")
@@ -174,22 +180,24 @@
    @RequestMapping(value = "/orderLog/list/auth")
    @ManagerAuth
    public R list(@RequestParam(defaultValue = "1")Integer curr,
                  @RequestParam(defaultValue = "10")Integer limit,
                  @RequestParam(required = false)String orderByField,
                  @RequestParam(required = false)String orderByType,
                  @RequestParam Map<String, Object> param){
    public R list(@RequestParam(defaultValue = "1") Integer curr,
                  @RequestParam(defaultValue = "10") Integer limit,
                  @RequestParam(required = false) String orderByField,
                  @RequestParam(required = false) String orderByType,
                  @RequestParam Map<String, Object> param) {
        EntityWrapper<OrderLog> wrapper = new EntityWrapper<>();
        excludeTrash(param);
        convert(param, wrapper);
        if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));}
        if (!Cools.isEmpty(orderByField)) {
            wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));
        }
        return R.ok(orderLogService.selectPage(new Page<>(curr, limit), wrapper));
    }
    private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){
        for (Map.Entry<String, Object> entry : map.entrySet()){
    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)){
            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]));
@@ -202,7 +210,7 @@
    @RequestMapping(value = "/orderLog/export/auth")
    @ManagerAuth
    public R export(@RequestBody JSONObject param){
    public R export(@RequestBody JSONObject param) {
        EntityWrapper<OrderLog> wrapper = new EntityWrapper<>();
        List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class);
        Map<String, Object> map = excludeTrash(param.getJSONObject("order"));
@@ -218,7 +226,7 @@
        wrapper.like("id", condition);
        Page<OrderLog> page = orderLogService.selectPage(new Page<>(0, 10), wrapper);
        List<Map<String, Object>> result = new ArrayList<>();
        for (OrderLog order : page.getRecords()){
        for (OrderLog order : page.getRecords()) {
            Map<String, Object> map = new HashMap<>();
            map.put("id", order.getId());
            map.put("value", order.getOrderNo());
@@ -231,10 +239,21 @@
    @ManagerAuth
    public R query(@RequestBody JSONObject param) {
        Wrapper<OrderLog> wrapper = new EntityWrapper<OrderLog>().eq(humpToLine(String.valueOf(param.get("key"))), param.get("val"));
        if (null != orderLogService.selectOne(wrapper)){
        if (null != orderLogService.selectOne(wrapper)) {
            return R.parse(BaseRes.REPEAT).add(getComment(Order.class, String.valueOf(param.get("key"))));
        }
        return R.ok();
    }
    /**
     * 文件上传,关闭单据
     */
    @PostMapping("/order/close")
    @ResponseBody
    @ManagerAuth
    public R upload(MultipartFile file) throws IOException {
        EasyExcel.read(file.getInputStream(), ExcelOrder.class, new CloseOrderReadListener(orderService)).sheet().doRead();
        return R.ok();
    }
}