From b8c1da262aa8576932427b0a5b461da759730be3 Mon Sep 17 00:00:00 2001
From: 王佳豪 <g675230687@126.com>
Date: 星期六, 19 六月 2021 14:09:17 +0800
Subject: [PATCH] 1.平仓调整库存与erp进行通讯 2.修改库存数量进行优化
---
src/main/java/com/zy/asrs/controller/LocNormalController.java | 152 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 148 insertions(+), 4 deletions(-)
diff --git a/src/main/java/com/zy/asrs/controller/LocNormalController.java b/src/main/java/com/zy/asrs/controller/LocNormalController.java
index 275454e..58da3c8 100644
--- a/src/main/java/com/zy/asrs/controller/LocNormalController.java
+++ b/src/main/java/com/zy/asrs/controller/LocNormalController.java
@@ -10,9 +10,14 @@
import com.core.common.Cools;
import com.core.common.DateUtils;
import com.core.common.R;
+import com.sun.org.apache.bcel.internal.generic.NEW;
import com.zy.asrs.entity.LocNormal;
+import com.zy.asrs.entity.LocNormalReport;
import com.zy.asrs.entity.param.LocNormalParam;
+import com.zy.asrs.service.LocNormalReportService;
import com.zy.asrs.service.LocNormalService;
+import com.zy.common.service.erp.ErpService;
+import com.zy.common.service.erp.ErpSqlServer;
import com.zy.common.utils.excel.locNomal.LocNormalExcel;
import com.zy.common.utils.excel.locNomal.LocNormalExcelListener;
import com.zy.common.utils.excel.matcode.MatCodeExcel;
@@ -27,6 +32,10 @@
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
+import java.math.BigDecimal;
+import java.text.MessageFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -37,6 +46,10 @@
public class LocNormalController extends BaseController {
@Autowired
private LocNormalService locNormalService;
+ @Autowired
+ private LocNormalReportService locNormalReportService;
+ @Autowired
+ private ErpSqlServer erpSqlServer;
@RequestMapping(value = "/locNomal/list/auth")
@ManagerAuth
@@ -53,7 +66,9 @@
if (!Cools.isEmpty(orderByField)) {
wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));
}
- wrapper.eq("state", "1").or().eq("state", "2");
+ if (Cools.isEmpty(param.get("state"))) {
+ wrapper.in("state", "1,2");
+ }
return R.ok(locNormalService.selectPage(new Page<>(curr, limit), wrapper));
}
@@ -99,7 +114,19 @@
public void updateLocNormal(LocNormal param) {
Long modiUser = getUserId();
Date modiTime = new Date();
- locNormalService.updateLocNormal(param.getMatnr(), param.getAnfme(), modiUser, modiTime);
+ // 璋冩暣搴撳瓨锛屼慨鏀癸紝StockCheckRecord鎻掑叆鐩樼泩銆佺洏浜忔暟鎹�
+ LocNormal locNormalOld = locNormalService.selectOne(new EntityWrapper<LocNormal>().eq("matnr", param.getMatnr()).and().eq("warehouse", param.getWarehouse()).and().eq("supplier", param.getSupplier()));
+ BigDecimal erpCount = new BigDecimal(0);
+ if (param.getAnfme() == new BigDecimal(0)) {
+ erpCount = new BigDecimal(0).subtract(new BigDecimal(String.valueOf(locNormalOld.getAnfme())));
+ } else {
+ erpCount = param.getAnfme().subtract(new BigDecimal(String.valueOf(locNormalOld.getAnfme())));
+ }
+ // 璋冩暣搴撳瓨锛屾柊澧烇紝StockCheckRecord鎻掑叆鐩樼泩鏁版嵁
+ String ErpSql = "insert into StockCheckRecord(Fnumber, CheckQty, Fflag_rw, Fflag_finish) values (''{0}'', {1,number,#}, 0, 0)";
+ ErpSql = MessageFormat.format(ErpSql, param.getMatnr(), erpCount);
+ erpSqlServer.update(ErpSql);
+ locNormalService.updateLocNormal(param.getMatnr(), param.getAnfme(), modiUser, modiTime, param.getId());
}
@RequestMapping(value = "/locNormal/outLoc/auth")
@@ -107,7 +134,7 @@
public void outLocNormal(LocNormal param) {
Long modiUser = getUserId();
Date modiTime = new Date();
- locNormalService.outLocNormal(param.getMatnr(), modiUser, modiTime);
+ locNormalService.outLocNormal(param.getMatnr(), modiUser, modiTime, param.getId());
}
@RequestMapping(value = "/locNormal/removeLoc/auth")
@@ -115,7 +142,7 @@
public void removeLoc(LocNormal param) {
Long modiUser = getUserId();
Date modiTime = new Date();
- locNormalService.removeLocNormal(param.getMatnr(), modiUser, modiTime);
+ locNormalService.removeLocNormal(param.getMatnr(), modiUser, modiTime, param.getId());
}
/* 瀵煎叆 */
@@ -126,6 +153,36 @@
LocNormalExcelListener listener = new LocNormalExcelListener(getUserId());
EasyExcel.read(file.getInputStream(), LocNormalExcel.class, listener).sheet().doRead();
return R.ok("鎴愬姛瀵煎叆" + listener.getTotal() + "鏉$墿鏂欎俊鎭�");
+ }
+
+ /* 骞充粨鍏ュ簱 鎴愬搧 */
+ @RequestMapping(value = "/locNormal/in")
+ @ManagerAuth(memo = "骞充粨鍏ュ簱")
+ @Transactional
+ public R locNormalIn(@RequestBody LocNormalParam param) {
+ Long userId = getUserId();
+ Date timeNow = new Date();
+ for (Integer i = 0; i < param.getNormalList().size(); i++) {
+ param.getNormalList().get(i).setAppeUser(userId);
+ param.getNormalList().get(i).setAppeTime(timeNow);
+ }
+ locNormalService.locNormalIn(param.getNormalList());
+ return R.ok();
+ }
+
+ /* 骞充粨鍏ュ簱-鍘熸潗鏂� */
+ @RequestMapping(value = "/locNormal/in/source")
+ @ManagerAuth(memo = "骞充粨鍏ュ簱-鍘熸潗鏂�")
+ @Transactional
+ public R locNormalInSource(@RequestBody LocNormalParam param) {
+ Long userId = getUserId();
+ Date timeNow = new Date();
+ for (Integer i = 0; i < param.getNormalList().size(); i++) {
+ param.getNormalList().get(i).setAppeUser(userId);
+ param.getNormalList().get(i).setAppeTime(timeNow);
+ }
+ locNormalService.locNormalInSource(param.getNormalList());
+ return R.ok();
}
/* pda鍏ュ簱 */
@@ -142,4 +199,91 @@
locNormalService.pdaLocNormalIn(param.getNormalList());
return R.ok();
}
+
+ /* pda鍑哄簱鏌ヨ */
+ @RequestMapping(value = "/locNormal/pda/out/query")
+ @ManagerAuth(memo = "pda鍑哄簱鏌ヨ")
+ @Transactional
+ public R locNormalPdaOutQuery(String matnr, String warehouse, String billNo) {
+ List<LocNormal> list = new ArrayList<>();
+ list = locNormalService.pdaLocNormalQuery(matnr, warehouse, billNo);
+ return R.ok(list);
+ }
+
+ @RequestMapping(value = "/locNormal/pda/out")
+ @ManagerAuth(memo = "pda鍑哄簱")
+ @Transactional
+ public R locNormalPdaOut(@RequestBody LocNormalParam param) {
+ Long userId = getUserId();
+ Date timeNow = new Date();
+ List<LocNormal> list = param.getNormalList();
+ for (Integer i = 0; i < list.size(); i++) {
+ list.get(i).setModiUser(userId);
+ list.get(i).setModiTime(timeNow);
+ }
+ locNormalService.pdaLocNormalOut(list);
+ return R.ok();
+ }
+
+ @RequestMapping(value = "/locNormal/pda/warehouseQuery")
+ @ManagerAuth(memo = "pda鏍规嵁搴撳尯鏌ヨ鐗╂枡娓呭崟")
+ @Transactional
+ public R locNormalPdaWarehouseQuery(String warehouse, String matnr) {
+ List<LocNormal> list = locNormalService.pdaLocNormalWarehouseQuery(warehouse, matnr);
+ return R.ok(list);
+ }
+
+ @RequestMapping(value = "/locNormal/pda/move")
+ @ManagerAuth(memo = "pda绉诲簱")
+ @Transactional
+ public R LocNormalPdaMove(@RequestBody LocNormalParam param) {
+ Long userId = getUserId();
+ Date timeNow = new Date();
+ List<LocNormal> list = param.getNormalList();
+ for (Integer i = 0; i < list.size(); i++) {
+ list.get(i).setModiUser(userId);
+ list.get(i).setModiTime(timeNow);
+ }
+ locNormalService.pdaLocNormalMove(list);
+ return R.ok();
+ }
+
+ @RequestMapping(value = "/locNomal/getInListByDay")
+ @ManagerAuth(memo = "骞充粨鏃ュ嚭鍏ュ簱鏌ヨ")
+ public R getInListByDay(@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) {
+ excludeTrash(param);
+ EntityWrapper<LocNormalReport> wrapper = new EntityWrapper<>();
+ List<String> orderList = new ArrayList<>();
+ orderList.add("time");
+ wrapper.eq("state", param.get("state").toString()).orderDesc(orderList);
+ String timeRange = "";
+ String time1 = "";
+ String time2 = "";
+ if (!Cools.isEmpty(param.get("query_date"))) {
+ timeRange = param.get("query_date").toString();
+ time1 = timeRange.substring(0, 19);
+ time2 = timeRange.substring(21, timeRange.length());
+ }
+ param.remove("query_date");
+ convert(param, wrapper);
+ if (time1 != "" && time2 != "") {
+ SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ Date dateTime1 = new Date();
+ Date dateTime2 = new Date();
+ try {
+ dateTime1 = formatter.parse(time1);
+ dateTime2 = formatter.parse(time2);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ wrapper.ge("time", dateTime1).and().le("time", dateTime2);
+ }
+ allLike(LocNormalReport.class, param.keySet(), wrapper, condition);
+ return R.ok(locNormalReportService.selectPage(new Page<>(curr, limit), wrapper));
+ }
}
--
Gitblit v1.9.1