From 4e32eae9008b56a346f52710d86241890a0ae1a7 Mon Sep 17 00:00:00 2001
From: zhou zhou <3272660260@qq.com>
Date: 星期四, 27 十一月 2025 19:59:00 +0800
Subject: [PATCH] #库存调整
---
src/main/java/com/zy/asrs/controller/CheckOrderController.java | 80 ++++++++++++++++++++++++++++++++++-----
1 files changed, 69 insertions(+), 11 deletions(-)
diff --git a/src/main/java/com/zy/asrs/controller/CheckOrderController.java b/src/main/java/com/zy/asrs/controller/CheckOrderController.java
index 8194bf9..4b88046 100644
--- a/src/main/java/com/zy/asrs/controller/CheckOrderController.java
+++ b/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")
--
Gitblit v1.9.1