From d3f11759e6b32d7e9e63e0f7b0cc4b6874aea020 Mon Sep 17 00:00:00 2001
From: whycq <10027870+whycq@user.noreply.gitee.com>
Date: 星期一, 28 八月 2023 11:14:42 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/bfasrs6' into bfasrs6
---
src/main/java/com/zy/asrs/controller/OrderController.java | 161 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 160 insertions(+), 1 deletions(-)
diff --git a/src/main/java/com/zy/asrs/controller/OrderController.java b/src/main/java/com/zy/asrs/controller/OrderController.java
index de1f495..1cf392f 100644
--- a/src/main/java/com/zy/asrs/controller/OrderController.java
+++ b/src/main/java/com/zy/asrs/controller/OrderController.java
@@ -1,5 +1,6 @@
package com.zy.asrs.controller;
+import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
@@ -12,14 +13,26 @@
import com.zy.asrs.entity.result.WrkTraceVo;
import com.zy.asrs.service.*;
import com.zy.common.model.DetlDto;
+import com.zy.common.model.OrderDto;
import com.zy.common.web.BaseController;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.DataFormatter;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
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.io.InputStream;
import java.util.*;
+@Slf4j
@RestController
public class OrderController extends BaseController {
@@ -39,6 +52,8 @@
private WrkMastLogService wrkMastLogService;
@Autowired
private LocDetlService locDetlService;
+ @Autowired
+ private MatService matService;
@RequestMapping(value = "/order/nav/list/auth")
@ManagerAuth
@@ -88,7 +103,9 @@
@RequestMapping(value = "/order/detl/all/auth")
@ManagerAuth
public R head(@RequestParam Long orderId){
- return R.ok().add(orderDetlService.selectList(new EntityWrapper<OrderDetl>().eq("order_id", orderId)));
+ List<OrderDetl> orderDetls = orderDetlService.selectList(new EntityWrapper<OrderDetl>().eq("order_id", orderId));
+ orderDetls.removeIf(next -> next.getQty() > 0);
+ return R.ok().add(orderDetls);
}
@RequestMapping(value = "/order/form/add/auth")
@@ -254,6 +271,15 @@
List<WrkTraceVo> wrkTraceVos = new ArrayList<>();
List<WrkDetl> wrkDetls = wrkDetlService.selectAndLogByOrderNoGroupByMatnrOfSum(order.getOrderNo());
for (WrkDetl wrkDetl : wrkDetls) {
+ if (isJSON(wrkDetl.getOrderNo())) {
+ List<OrderDto> orderDtoList = JSON.parseArray(wrkDetl.getOrderNo(), OrderDto.class);
+ for (OrderDto one : orderDtoList) {
+ if (one.getOrderNo().equals(order.getOrderNo())) {
+ wrkDetl.setAnfme(one.getAnfme());
+ break;
+ }
+ }
+ }
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()));
@@ -391,4 +417,137 @@
return R.ok();
}
+ /*************************************** 鏁版嵁鐩稿叧 ***********************************************/
+
+ /**
+ * excel瀵煎叆
+ */
+ @PostMapping(value = "/order/excel/import/auth")
+ @ManagerAuth(memo = "閿�鍞崟Excel瀵煎叆")
+ @Transactional
+ public R cstmrExcelImport(MultipartFile file) throws IOException {
+ InputStream inStream = file.getInputStream();
+ String fileMime = file.getContentType();
+ int excelVersion = 2007;
+ if ("application/vnd.ms-excel".equals(fileMime)) {
+ excelVersion = 2003;
+ }
+ Workbook book = null;
+ try {
+ if (excelVersion == 2003) {
+ book = new HSSFWorkbook(inStream);
+ }
+ else { // 褰� excel 鏄� 2007 鏃�
+ book = new XSSFWorkbook(inStream);
+ }
+ } catch (Exception e) {
+ log.error("fail", e);
+ return R.error("瀵煎叆鏂囦欢鏍煎紡閿欒锛岃浣跨敤xls鍚庣紑鐨勬枃浠讹紒");
+ }
+
+ Sheet sheet = book.getSheetAt(0);
+ int totalRows = sheet.getLastRowNum() + 1; // 鎬�
+ Long userId = getUserId();
+ Date now = new Date();
+ DataFormatter dataFormatter = new DataFormatter();
+ for (int i = 1; i < totalRows; i++) {
+ Row row = sheet.getRow(i);
+ // 璁㈠崟缂栧彿
+ String uuid = dataFormatter.formatCellValue(row.getCell(0));
+ // 鍟嗗搧鍚嶇О
+ String maktx = dataFormatter.formatCellValue(row.getCell(1));
+ // 鍟嗗搧缂栫爜
+ String matnr = dataFormatter.formatCellValue(row.getCell(2));
+ // 鏁伴噺
+ Double anfme = Double.parseDouble(dataFormatter.formatCellValue(row.getCell(3)));
+ // 涓嬪崟鏃堕棿
+ String timeStr = dataFormatter.formatCellValue(row.getCell(4));
+
+ // 鍗曟嵁绫诲瀷
+ Long orderType = Long.parseLong(dataFormatter.formatCellValue(row.getCell(5)));
+ Date time = null;
+ try {
+ time = DateUtils.convert(timeStr, DateUtils.yyyyMMddHHmmss_F);
+ } catch (Exception e) {
+ throw new CoolException("绗�" + i + "琛屼笅鐨勯偅鏃堕棿瑙f瀽澶辫触锛岃閲嶆柊瀵煎叆锛�");
+ }
+ // 鍟嗗搧绯诲垪
+ String tagName = dataFormatter.formatCellValue(row.getCell(5));
+ // 瑙勬牸
+ String specs = dataFormatter.formatCellValue(row.getCell(6));
+
+ Mat mat = matService.selectByMatnr(matnr);
+ if (null == mat) {
+ throw new CoolException(matnr + "鍟嗗搧缂栫爜鐨勫晢鍝佷笉瀛樺湪锛岃閲嶆柊瀵煎叆锛�");
+ }
+
+ Order order = orderService.selectByNo(uuid);
+ if (null == order) {
+ order = new Order(
+ String.valueOf(snowflakeIdWorker.nextId()), // 缂栧彿[闈炵┖]
+ uuid, // 璁㈠崟缂栧彿
+ timeStr, // 鍗曟嵁鏃ユ湡
+ orderType, // 鍗曟嵁绫诲瀷
+ null, // 椤圭洰缂栧彿
+ null, //
+ null, // 璋冩嫧椤圭洰缂栧彿
+ null, // 鍒濆绁ㄦ嵁鍙�
+ null, // 绁ㄦ嵁鍙�
+ null, // 瀹㈡埛缂栧彿
+ null, // 瀹㈡埛
+ null, // 鑱旂郴鏂瑰紡
+ null, // 鎿嶄綔浜哄憳
+ null, // 鍚堣閲戦
+ null, // 浼樻儬鐜�
+ null, // 浼樻儬閲戦
+ null, // 閿�鍞垨閲囪喘璐圭敤鍚堣
+ null, // 瀹炰粯閲戦
+ null, // 浠樻绫诲瀷
+ null, // 涓氬姟鍛�
+ null, // 缁撶畻澶╂暟
+ null, // 閭垂鏀粯绫诲瀷
+ null, // 閭垂
+ null, // 浠樻鏃堕棿
+ null, // 鍙戣揣鏃堕棿
+ null, // 鐗╂祦鍚嶇О
+ null, // 鐗╂祦鍗曞彿
+ 1L, // 璁㈠崟鐘舵��
+ 1, // 鐘舵��
+ userId, // 娣诲姞浜哄憳
+ now, // 娣诲姞鏃堕棿
+ userId, // 淇敼浜哄憳
+ now, // 淇敼鏃堕棿
+ null // 澶囨敞
+ );
+ if (!orderService.insert(order)) {
+ throw new CoolException("鐢熸垚鍗曟嵁涓绘。澶辫触锛岃閲嶆柊瀵煎叆锛�");
+ }
+ }
+
+ OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), matnr, null);
+ if (orderDetl == null) {
+ orderDetl = new OrderDetl();
+ orderDetl.sync(mat);
+ orderDetl.setBatch(null);
+ orderDetl.setAnfme(anfme);
+ orderDetl.setOrderId(order.getId());
+ orderDetl.setOrderNo(order.getOrderNo());
+ orderDetl.setCreateBy(userId);
+ orderDetl.setCreateTime(now);
+ orderDetl.setUpdateBy(userId);
+ orderDetl.setUpdateTime(now);
+ orderDetl.setStatus(1);
+ orderDetl.setQty(0.0D);
+ if (!orderDetlService.insert(orderDetl)) {
+ throw new CoolException("鐢熸垚鍗曟嵁鏄庣粏澶辫触锛岃閲嶆柊瀵煎叆锛�");
+ }
+ } else {
+ if(!orderDetlService.increaseAnfme(order.getId(), matnr, null, anfme)) {
+ throw new CoolException("鐢熸垚鍗曟嵁鏄庣粏澶辫触锛岃閲嶆柊瀵煎叆锛�");
+ }
+ }
+ }
+ return R.ok("瀵煎叆鎴愬姛");
+ }
+
}
--
Gitblit v1.9.1