From 88fc713144a877a4257b4173fbfadafd926c94de Mon Sep 17 00:00:00 2001
From: skyouc <creaycat@gmail.com>
Date: 星期五, 09 一月 2026 20:35:19 +0800
Subject: [PATCH] 出库再入库
---
src/main/java/com/zy/asrs/controller/OrderController.java | 85 ++++++++++++++++++++++++++++++++++++++----
1 files changed, 77 insertions(+), 8 deletions(-)
diff --git a/src/main/java/com/zy/asrs/controller/OrderController.java b/src/main/java/com/zy/asrs/controller/OrderController.java
index 6c9d546..cdc148d 100644
--- a/src/main/java/com/zy/asrs/controller/OrderController.java
+++ b/src/main/java/com/zy/asrs/controller/OrderController.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.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
@@ -12,14 +14,23 @@
import com.zy.asrs.entity.result.WrkTraceVo;
import com.zy.asrs.service.*;
+import com.zy.asrs.utils.MatExcelListener;
+import com.zy.asrs.utils.OrderExcelListener;
+import com.zy.common.entity.MatExcel;
+import com.zy.common.entity.OrderExcel;
import com.zy.common.model.DetlDto;
import com.zy.common.web.BaseController;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import java.io.IOException;
+import java.net.URLEncoder;
import java.util.*;
+
+import javax.servlet.http.HttpServletResponse;
@RestController
public class OrderController extends BaseController {
@@ -98,14 +109,22 @@
@ManagerAuth(memo = "鎵嬪姩娣诲姞璁㈠崟")
@Transactional
public R formAdd(@RequestBody OrderDomainParam param){
+ int status = 0;
if(Cools.isEmpty(param.getOrderNo())){
String prefix = "";
DocType docType = docTypeService.selectById(param.getDocType());
if(!Cools.isEmpty(docType)){
prefix = docType.getPakin() == 1 ? "RK" : "CK";
+ status = (prefix.equals("RK") ? 1 : (prefix.equals("CK") ? 2 : 0));
}
param.setOrderNo(prefix + snowflakeIdWorker.nextId());
+ } else {
+ DocType docType = docTypeService.selectById(param.getDocType());
+ if(!Cools.isEmpty(docType)){
+ status = (docType.getPakin() == 1 ? 1 : 2 );
+ }
}
+
Order order = orderService.selectByNo(param.getOrderNo());
if (order != null) {
return R.error("鍗曟嵁缂栧彿宸插瓨鍦�");
@@ -145,16 +164,20 @@
now, // 娣诲姞鏃堕棿
getUserId(), // 淇敼浜哄憳
now, // 淇敼鏃堕棿
- null // 澶囨敞
+ null, // 澶囨敞
+ status
);
if (!orderService.insert(order)) {
throw new CoolException("淇濆瓨璁㈠崟涓绘。澶辫触");
}
List<DetlDto> list = new ArrayList<>();
for (OrderDetl orderDetl : param.getOrderDetlList()) {
- DetlDto dto = new DetlDto(orderDetl.getMatnr(), orderDetl.getBatch());
+ DetlDto dto = new DetlDto(orderDetl.getMatnr(), orderDetl.getBatch(), orderDetl.getBrand(),
+ orderDetl.getStandby1(),orderDetl.getStandby2(),orderDetl.getStandby3(),
+ orderDetl.getBoxType1(),orderDetl.getBoxType2(),orderDetl.getBoxType3());
if (DetlDto.has(list, dto)) {
- OrderDetl item = orderDetlService.selectItem(order.getId(), orderDetl.getMatnr(), orderDetl.getBatch());
+ OrderDetl item = orderDetlService.selectItem(order.getId(), orderDetl.getMatnr(), orderDetl.getBatch(),orderDetl.getBrand(),orderDetl.getStandby1(),orderDetl.getStandby2(),orderDetl.getStandby3(),
+ orderDetl.getBoxType1(),orderDetl.getBoxType2(),orderDetl.getBoxType3());
item.setAnfme(item.getAnfme() + orderDetl.getAnfme());
if (!orderDetlService.updateById(item)) {
throw new CoolException("淇濆瓨璁㈠崟鏄庣粏妗eけ璐�");
@@ -169,6 +192,7 @@
orderDetl.setUpdateTime(now);
orderDetl.setStatus(1);
orderDetl.setQty(0.0D);
+ orderDetl.setPakinPakoutStatus(status);
if (!orderDetlService.insert(orderDetl)) {
throw new CoolException("淇濆瓨璁㈠崟鏄庣粏妗eけ璐�");
}
@@ -205,9 +229,13 @@
// 2.閲嶇粍鏁版嵁
List<DetlDto> list = new ArrayList<>();
for (OrderDetl orderDetl : param.getOrderDetlList()) {
- DetlDto dto = new DetlDto(orderDetl.getMatnr(), orderDetl.getBatch());
+ DetlDto dto = new DetlDto(orderDetl.getMatnr(), orderDetl.getBatch(),orderDetl.getBrand(),
+ orderDetl.getStandby1(),orderDetl.getStandby2(),orderDetl.getStandby3(),
+ orderDetl.getBoxType1(),orderDetl.getBoxType2(),orderDetl.getBoxType3());
if (DetlDto.has(list, dto)) {
- OrderDetl item = orderDetlService.selectItem(order.getId(), orderDetl.getMatnr(), orderDetl.getBatch());
+ OrderDetl item = orderDetlService.selectItem(order.getId(), orderDetl.getMatnr(), orderDetl.getBatch(),orderDetl.getBrand(),
+ orderDetl.getStandby1(),orderDetl.getStandby2(),orderDetl.getStandby3(),
+ orderDetl.getBoxType1(),orderDetl.getBoxType2(),orderDetl.getBoxType3());
item.setAnfme(item.getAnfme() + orderDetl.getAnfme());
if (!orderDetlService.updateById(item)) {
throw new CoolException("淇濆瓨璁㈠崟鏄庣粏妗eけ璐�");
@@ -242,10 +270,12 @@
double totalQty = 0;
double wrkQty = 0;
double lackQty = 0;
+ double endQty = 0;
for (OrderDetl orderDetl : orderDetls) {
totalQty = totalQty + orderDetl.getAnfme();
- wrkQty = wrkQty + orderDetl.getQty();
- double issued = Optional.of(orderDetl.getAnfme() - orderDetl.getQty()).orElse(0.0D);
+ wrkQty = wrkQty + orderDetl.getWorkQty();
+ endQty = endQty + orderDetl.getQty();
+ double issued = Optional.of(orderDetl.getAnfme() - orderDetl.getWorkQty()).orElse(0.0D);
if (issued > 0.0) {
List<LocDetl> locDetls = locDetlService.queryStock(orderDetl.getMatnr(), orderDetl.getBatch(), orderDetl.getOrigin(), null);
for (LocDetl locDetl : locDetls) {
@@ -267,6 +297,9 @@
WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", wrkDetl.getWrkNo()).eq("io_time", wrkDetl.getIoTime()));
if (wrkMast == null) {
WrkMastLog wrkMastLog = wrkMastLogService.selectOne(new EntityWrapper<WrkMastLog>().eq("wrk_no", wrkDetl.getWrkNo()).eq("io_time", wrkDetl.getIoTime()));
+ if (wrkMastLog.getIoType()==103){
+ wrkMastLog = wrkMastLogService.selectOne(new EntityWrapper<WrkMastLog>().eq("wrk_no", wrkDetl.getWrkNo()).eq("io_time", wrkDetl.getIoTime()).eq("io_type",53));
+ }
if (wrkMastLog != null) {
wrkMast = new WrkMast();
BeanUtils.copyProperties(wrkMastLog, wrkMast);
@@ -293,8 +326,9 @@
.add("list", wrkTraceVos)
.add("orderNo", order.getOrderNo())
.add("totalQty", totalQty)
- .add("wrkQty", wrkQty)
+ .add("wrkQty", wrkQty+endQty)
.add("lackQty", lackQty)
+ .add("endQty",endQty)
);
}
@@ -334,6 +368,41 @@
}
}
+ /**
+ * excel瀵煎叆妯℃澘涓嬭浇
+ */
+ @RequestMapping(value = "/orders/excel/import/mould")
+ public void matExcelImportMould(HttpServletResponse response) throws IOException {
+ List<OrderExcel> excels = new ArrayList<>();
+ response.setContentType("application/vnd.ms-excel");
+ response.setCharacterEncoding("utf-8");
+ String fileName = URLEncoder.encode("鍗曟嵁Excel瀵煎叆妯℃澘", "UTF-8");
+ response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
+ EasyExcel.write(response.getOutputStream(), OrderExcel.class)
+ .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
+ .sheet("sheet1")
+ .doWrite(excels);
+ }
+
+
+
+ /**
+ * 鍗曟嵁瀵煎叆
+ * @author Ryan
+ * @date 2026/1/8 17:17
+ * @param file
+ * @return com.core.common.R
+ */
+ @PostMapping(value = "/orders/excel/import/auth")
+ @ManagerAuth(memo = "鍗曟嵁瀵煎叆")
+ @Transactional
+ public R matExcelImport(MultipartFile file) throws IOException {
+ OrderExcelListener listener = new OrderExcelListener(getUserId());
+ EasyExcel.read(file.getInputStream(), OrderExcel.class, listener).sheet().doRead();
+ return R.ok("鎴愬姛鍚屾" + listener.getTotal() + "鏉″晢鍝佹暟鎹�");
+ }
+
+
@RequestMapping(value = "/order/update/auth")
@ManagerAuth
public R update(Order order){
--
Gitblit v1.9.1