自动化立体仓库 - WMS系统
zhou zhou
2 天以前 4e32eae9008b56a346f52710d86241890a0ae1a7
src/main/java/com/zy/asrs/controller/CheckOrderController.java
@@ -1,5 +1,7 @@
package com.zy.asrs.controller;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
@@ -10,8 +12,11 @@
import com.zy.asrs.entity.*;
import com.zy.asrs.entity.param.CheckTaskListParam;
import com.zy.asrs.entity.param.OrderDomainParam;
import com.zy.asrs.entity.result.CheckOrderExportDTO;
import com.zy.asrs.enums.OrderTypeEnum;
import com.zy.asrs.service.*;
import com.core.annotations.ManagerAuth;
import com.zy.common.entity.NodeExcel;
import com.zy.common.model.DetlDto;
import com.zy.common.model.LocDto;
import com.zy.common.web.BaseController;
@@ -19,6 +24,8 @@
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.*;
@@ -129,10 +136,14 @@
            checkOrderDetl.setBatch(locDetl.getBatch());
            checkOrderDetl.setSpecs(locDetl.getSpecs());
            checkOrderDetl.setAnfme(new BigDecimal(locDetl.getAnfme().toString()));
            checkOrderDetl.setQty(BigDecimal.ZERO);
            checkOrderDetl.setDiffQty(BigDecimal.ZERO);
            checkOrderDetl.setWorkQty(BigDecimal.ZERO);
            checkOrderDetl.setStatus(1);
            checkOrderDetl.setZpallet(locDetl.getZpallet());
            checkOrderDetl.setCreateBy(getUserId());
            checkOrderDetl.setCreateTime(now);
            checkOrderDetl.setUpdateBy(getUserId());
            checkOrderDetl.setUpdateTime(now);
            if (!checkOrderDetlService.insert(checkOrderDetl)) {
                throw new CoolException("保存盘点单明细失败");
            }
@@ -175,10 +186,14 @@
            checkOrderDetl1.setBatch(checkOrderDetl.getBatch());
            checkOrderDetl1.setSpecs(checkOrderDetl.getSpecs());
            checkOrderDetl1.setAnfme(checkOrderDetl.getAnfme());
            checkOrderDetl1.setQty(checkOrderDetl.getQty());
            checkOrderDetl1.setDiffQty(checkOrderDetl.getDiffQty());
            checkOrderDetl1.setWorkQty(checkOrderDetl.getWorkQty());
            checkOrderDetl1.setStatus(checkOrderDetl.getStatus());
            checkOrderDetl1.setZpallet(checkOrderDetl.getZpallet());
            checkOrderDetl1.setCreateBy(getUserId());
            checkOrderDetl1.setCreateTime(checkOrderDetl.getCreateTime() == null?now:checkOrderDetl.getCreateTime());
            checkOrderDetl1.setUpdateBy(getUserId());
            checkOrderDetl1.setUpdateTime(now);
            if (!checkOrderDetlService.insert(checkOrderDetl1)) {
                throw new CoolException("保存盘点单明细失败");
            }
@@ -205,6 +220,26 @@
        convert(param, wrapper);
        allLike(CheckOrder.class, param.keySet(), wrapper, condition);
        if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));}
        wrapper.orderBy("create_time", false);
        wrapper.eq("doc_type", OrderTypeEnum.INVENTORY.type);
        return R.ok(checkOrderService.selectPage(new Page<>(curr, limit), wrapper));
    }
    @RequestMapping(value = "/adjustOrder/list/auth")
    @ManagerAuth
    public R adjustList(@RequestParam(defaultValue = "1")Integer curr,
                  @RequestParam(defaultValue = "10")Integer limit,
                  @RequestParam(required = false)String orderByField,
                  @RequestParam(required = false)String orderByType,
                  @RequestParam(required = false)String condition,
                  @RequestParam Map<String, Object> param){
        EntityWrapper<CheckOrder> wrapper = new EntityWrapper<>();
        excludeTrash(param);
        convert(param, wrapper);
        allLike(CheckOrder.class, param.keySet(), wrapper, condition);
        if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));}
        wrapper.orderBy("create_time", false);
        wrapper.eq("doc_type", OrderTypeEnum.ADJUSTMENT.type);
        return R.ok(checkOrderService.selectPage(new Page<>(curr, limit), wrapper));
    }
@@ -247,15 +282,38 @@
//        return R.ok();
//    }
    @RequestMapping(value = "/checkOrder/export/auth")
    @ManagerAuth
    public R export(@RequestBody JSONObject param){
        EntityWrapper<CheckOrder> wrapper = new EntityWrapper<>();
        List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class);
        Map<String, Object> map = excludeTrash(param.getJSONObject("checkOrder"));
        convert(map, wrapper);
        List<CheckOrder> list = checkOrderService.selectList(wrapper);
        return R.ok(exportSupport(list, fields));
    @PostMapping(value = "/checkOrder/export/auth")
    @ManagerAuth(memo = "盘点单导出")
    public void export(@RequestParam("orderId") Long orderId, HttpServletResponse response) throws IOException {
        CheckOrder checkOrder = checkOrderService.selectById(orderId);
        if (Cools.isEmpty(checkOrder)) {
            throw new CoolException("数据错误");
        }
        List<CheckOrderDetl> checkOrderDetls = checkOrderDetlService.selectList(new EntityWrapper<CheckOrderDetl>().eq("order_id", orderId));
        ArrayList<CheckOrderExportDTO> checkOrderExportDTOS = new ArrayList<>();
        for (CheckOrderDetl checkOrderDetl : checkOrderDetls) {
            CheckOrderExportDTO checkOrderExportDTO = new CheckOrderExportDTO();
            checkOrderExportDTO.sync(checkOrderDetl);
            checkOrderExportDTOS.add(checkOrderExportDTO);
        }
        String fileName = "盘点差异单_"+checkOrder.getOrderNo() + ".xlsx";
        // 设置响应头,指定文件名
        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
        response.setCharacterEncoding("utf-8");
        // 防止中文乱码
        fileName = java.net.URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "%20");
        response.setHeader("Content-Disposition", "attachment;filename*=" + fileName);
        EasyExcel.write(response.getOutputStream(), CheckOrderExportDTO.class)
                .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
                .sheet("sheet1")
                .doWrite(checkOrderExportDTOS);
    }
    @RequestMapping(value = "/checkOrderQuery/auth")