From ac225bd66eb7c21b5af1d8533dc59376ea53da6c Mon Sep 17 00:00:00 2001
From: 廖井涛 <2265517004@qq.com>
Date: 星期五, 12 十二月 2025 12:29:42 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10105/r/ERP_override
---
north-glass-erp/src/main/java/com/example/erp/service/mm/MaterialInventoryService.java | 475 ++++++++++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 406 insertions(+), 69 deletions(-)
diff --git a/north-glass-erp/src/main/java/com/example/erp/service/mm/MaterialInventoryService.java b/north-glass-erp/src/main/java/com/example/erp/service/mm/MaterialInventoryService.java
index bc82806..67265c9 100644
--- a/north-glass-erp/src/main/java/com/example/erp/service/mm/MaterialInventoryService.java
+++ b/north-glass-erp/src/main/java/com/example/erp/service/mm/MaterialInventoryService.java
@@ -1,22 +1,14 @@
package com.example.erp.service.mm;
import cn.hutool.core.util.StrUtil;
-import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.dynamic.datasource.annotation.DS;
-import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
-import com.example.erp.common.Constants;
-import com.example.erp.dto.mm.FinishedOperateLogDTO;
+import com.example.erp.dto.mm.MaterialLogDTO;
import com.example.erp.entity.mm.*;
import com.example.erp.entity.pp.*;
-import com.example.erp.entity.sd.Delivery;
-import com.example.erp.entity.sd.DeliveryDetail;
-import com.example.erp.entity.sd.OrderDetail;
-import com.example.erp.entity.sd.OrderProcessDetail;
import com.example.erp.entity.userInfo.Log;
import com.example.erp.entity.userInfo.SysError;
-import com.example.erp.exception.ServiceException;
import com.example.erp.mapper.mm.BasicWarehouseTypeMapper;
import com.example.erp.mapper.mm.MaterialInventoryMapper;
import com.example.erp.mapper.mm.MaterialLogMapper;
@@ -28,7 +20,6 @@
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
-import java.time.LocalDateTime;
import java.util.List;
import java.util.ArrayList;
@@ -36,6 +27,9 @@
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.*;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
@Service
@@ -93,6 +87,7 @@
//鍒犻櫎鏉愭枡鍑哄簱鏄庣粏鐨勬暟鎹�
materialInventoryMapper.deleteMaterialOutboundDetail(materialOutboundId);
materialInventoryMapper.updateMaterialOutbound(materialOutbound, materialOutboundId);
+ materialInventoryMapper.deleteMaterialLog(materialOutboundId);
oddNumber = materialOutboundId;
log.setFunction("saveMaterialOutbound淇敼:"+oddNumber);
} else {
@@ -114,13 +109,16 @@
materialInventoryMapper.insertMaterialOutboundDetail(materialOutboundDetail, oddNumber, materialOutboundDetailMaximum + 1);
//淇敼鐗╂枡搴撳瓨琛ㄥ嚭搴撴暟閲�
materialInventoryMapper.updateMaterialInventoryAvailableOut(materialOutboundDetail.getId(), materialOutboundDetail.getOutboundQuantity());
- if(materialOutboundDetail.getUseId()!=null){
- //淇敼浼樺寲宸ョ▼琛ㄥ嚭搴撴暟閲�
- materialInventoryMapper.updateMaterialInventoryAvailableOptOut(materialOutboundDetail.getUseId(), materialOutboundDetail.getOutboundQuantity());
- }/*else{
+ String projectNo="";
+ if(materialOutboundDetail.getUseId()!=null){
+ projectNo = materialInventoryMapper.selectProjectNo(materialOutboundDetail.getUseId());
+ //淇敼浼樺寲宸ョ▼琛ㄥ嚭搴撴暟閲�
+ materialInventoryMapper.updateMaterialInventoryAvailableOptOut(materialOutboundDetail.getUseId(), materialOutboundDetail.getOutboundQuantity());
+
+ }/*else{
//淇敼鐗╂枡搴撳瓨琛ㄥ嚭搴撴暟閲�
materialInventoryMapper.updateMaterialInventoryAvailableOut(materialOutboundDetail.getId(), materialOutboundDetail.getOutboundQuantity());
- }*/
+ }*/
String json="";
MaterialStore materialStore=materialStoreMapper.getSelectMaterialStoreById(Long.valueOf(materialOutboundDetail.getMaterialCode()));
json=materialStore.getJson().substring(1, materialStore.getJson().length() - 1);
@@ -140,6 +138,7 @@
materialLog.setInventoryId(materialOutboundDetail.getId());
materialLog.setInventoryArea(materialInventory.getInventoryArea());
materialLog.setRemarks(materialOutboundDetail.getRemarks());
+ materialLog.setProjectNo(projectNo);
materialLog.setOperator(object.get("userName").toString());
materialLog.setOperateTime(LocalDate.now());
materialLogMapper.insert(materialLog);
@@ -163,7 +162,7 @@
sysError.setError(e+Arrays.toString(e.getStackTrace()));
sysError.setFunc("saveMaterialOutbound");
sysErrorService.insert(sysError);
- saveState = "false1";
+ saveState = "false";
}
return saveState;
@@ -194,23 +193,26 @@
MaterialInventory materialInventory = JSONObject.parseObject(JSONObject.toJSONString(object.get("title")), MaterialInventory.class);
-
+ if(materialInventory.getProducer()==null){
+ materialInventory.setProducer("");
+ }
//鏌ヨ鐗╂枡鏄惁瀛樺湪
- Integer MaterialInventoryCount=0;
+ List<MaterialInventory> MaterialInventoryCount;
if (materialInventory.getDateOfManufacture()!=null){
- MaterialInventoryCount = materialInventoryMapper.getMaterialInventoryCount(materialCode,materialInventory.getDateOfManufacture());
+ MaterialInventoryCount = materialInventoryMapper.getMaterialInventoryCount(materialCode,materialInventory.getDateOfManufacture(),materialInventory.getProducer());
}else{
- MaterialInventoryCount = materialInventoryMapper.getMaterialInventoryCountNull(materialCode);
+ MaterialInventoryCount = materialInventoryMapper.getMaterialInventoryCountNull(materialCode,materialInventory.getProducer());
}
- if(MaterialInventoryCount==1){
+ if(MaterialInventoryCount.size()==1){
+ materialInventory.setId(MaterialInventoryCount.get(0).getId());
if (materialInventory.getDateOfManufacture()!=null){
materialInventoryMapper.updateMaterialInventory(materialCode,singlePieceArea,totalArea,materialInventory);
}else{
materialInventoryMapper.updateMaterialInventoryNull(materialCode,singlePieceArea,totalArea,materialInventory);
}
log.setFunction("saveMaterialInventory淇敼");
- }else if(MaterialInventoryCount==0) {
+ }else if(MaterialInventoryCount.isEmpty()) {
materialInventoryMapper.insertMaterialInventory(materialCode,singlePieceArea,totalArea,materialInventory);
log.setFunction("saveMaterialInventory鏂板");
}else {
@@ -221,6 +223,9 @@
MaterialStore materialStore=materialStoreMapper.getSelectMaterialStoreById(materialCode);
json=materialStore.getJson().substring(1, materialStore.getJson().length() - 1);
MaterialLog materialLog=new MaterialLog();
+ if(materialInventory.getDateOfManufacture()!=null){
+ materialLog.setOperationOrderNumber(materialInventory.getDateOfManufacture().toString());
+ }
materialLog.setOperateType("鐗╂枡鏂板");
materialLog.setMaterialCode(materialCode);
materialLog.setMaterialName(convertString(json,"\"name\""));
@@ -338,7 +343,10 @@
for (MaterialOutboundDetail materialOutboundDetail : materialOutboundDetailLists) {
//杩樺師鐗╂枡搴撳瓨鏁�
materialInventoryMapper.updateMaterialInventoryAvailableInt(materialOutboundDetail.getInventoryId(), materialOutboundDetail.getOutboundQuantity());
-
+ if(materialOutboundDetail.getUseId()!=null){
+ //杩樺師浼樺寲宸ョ▼搴撳瓨鏁�
+ materialInventoryMapper.updateMaterialInventoryAvailableOptInt(materialOutboundDetail.getUseId(), materialOutboundDetail.getOutboundQuantity());
+ }
}
}
@@ -482,10 +490,12 @@
List<MaterialOutboundDetail> materialOutboundDetailList = materialInventoryMapper.getIsNotMaterialOutboundDetail(materialOutboundId);
if (!materialOutboundDetailList.isEmpty()) {
for (MaterialOutboundDetail materialOutboundDetail : materialOutboundDetailList) {
-
+ if(materialOutboundDetail.getUseId()!=null){
//淇敼鐗╂枡搴撳瓨鏁伴噺
+ materialInventoryMapper.updateMaterialInventoryInventoryPlanQuantityOut(materialOutboundDetail.getInventoryId(), materialOutboundDetail.getOutboundQuantity());
+ }else{
materialInventoryMapper.updateMaterialInventoryInventoryOut(materialOutboundDetail.getInventoryId(), materialOutboundDetail.getOutboundQuantity());
-
+ }
}
}
@@ -494,9 +504,13 @@
List<MaterialOutboundDetail> materialOutboundDetailList = materialInventoryMapper.getIsNotMaterialOutboundDetail(materialOutboundId);
if (!materialOutboundDetailList.isEmpty()) {
for (MaterialOutboundDetail materialOutboundDetail : materialOutboundDetailList) {
-
+ if(materialOutboundDetail.getUseId()!=null){
//淇敼鐗╂枡搴撳瓨鏁伴噺
+ materialInventoryMapper.updateMaterialInventoryInventoryPlanQuantityInt(materialOutboundDetail.getInventoryId(), materialOutboundDetail.getOutboundQuantity());
+ }else{
materialInventoryMapper.updateMaterialInventoryInventoryInt(materialOutboundDetail.getInventoryId(), materialOutboundDetail.getOutboundQuantity());
+ }
+
}
@@ -583,16 +597,19 @@
totalArea= Double.parseDouble(decimalFormat.format(singlePieceArea * returningWarehouseDetail.getReturnQuantity()));
+ if(returningWarehouseDetail.getProducer()==null){
+ returningWarehouseDetail.setProducer("");
+ }
//鏌ヨ鐗╂枡鏄惁瀛樺湪
- Integer MaterialInventoryCount=0;
+ List<MaterialInventory> MaterialInventoryCount;
if (returningWarehouseDetail.getDateOfManufacture()!=null){
- MaterialInventoryCount = materialInventoryMapper.getMaterialInventoryCount(returningWarehouseDetail.getId(),returningWarehouseDetail.getDateOfManufacture());
+ MaterialInventoryCount = materialInventoryMapper.getMaterialInventoryCount(returningWarehouseDetail.getId(),returningWarehouseDetail.getDateOfManufacture(),returningWarehouseDetail.getProducer());
}else{
- MaterialInventoryCount = materialInventoryMapper.getMaterialInventoryCountNull(returningWarehouseDetail.getId());
+ MaterialInventoryCount = materialInventoryMapper.getMaterialInventoryCountNull(returningWarehouseDetail.getId(),returningWarehouseDetail.getProducer());
}
- if(MaterialInventoryCount>0){
+ if(!MaterialInventoryCount.isEmpty()){
if (returningWarehouseDetail.getDateOfManufacture()!=null){
materialInventoryMapper.updateMaterialInventoryReturning(returningWarehouseDetail.getId(),singlePieceArea,totalArea,returningWarehouseDetail);
}else{
@@ -606,9 +623,9 @@
//鑾峰彇搴撳瓨缂栧彿娣诲姞鍒拌繑搴撴槑缁嗚〃
List<MaterialInventory> MaterialInventoryId;
if (returningWarehouseDetail.getDateOfManufacture()!=null){
- MaterialInventoryId = materialInventoryMapper.getMaterialInventoryCountId(returningWarehouseDetail.getId(),returningWarehouseDetail.getDateOfManufacture());
+ MaterialInventoryId = materialInventoryMapper.getMaterialInventoryCountId(returningWarehouseDetail.getId(),returningWarehouseDetail.getDateOfManufacture(),returningWarehouseDetail.getProducer());
}else{
- MaterialInventoryId = materialInventoryMapper.getMaterialInventoryCountNullId(returningWarehouseDetail.getId());
+ MaterialInventoryId = materialInventoryMapper.getMaterialInventoryCountNullId(returningWarehouseDetail.getId(),returningWarehouseDetail.getProducer());
}
materialInventoryMapper.updateReturningWarehouseDetail(oddNumber, returningWarehouseDetailMaximum + 1,MaterialInventoryId.get(0).getId());
@@ -852,8 +869,15 @@
return map;
}
- public List<MaterialLog> exportMaterialLogReport(List<LocalDate> dates, String type) {
- return materialInventoryMapper.exportMaterialLogReport(dates,type);
+ public List<MaterialLogDTO> exportMaterialLogReport(List<LocalDate> dates, String type) {
+ if(type.equals("鐗╂枡鍑哄簱")){
+ return materialInventoryMapper.exportMaterialLogReport(dates,type);
+ }else if(type.equals("浼樺寲鍑哄簱")){
+ return materialInventoryMapper.exportMaterialLogOptimizeOutboundReport(dates,type);
+ }else{
+ return materialInventoryMapper.exportMaterialLogReports(dates,type);
+ }
+
}
@@ -947,49 +971,362 @@
@Transactional(rollbackFor = Exception.class)
public boolean mesMaterialOutbound(Map<String, Object> reportingWorkMap) {
- //鎺ユ敹瑙f瀽涓婚檮琛ㄤ俊鎭�
- JSONObject reportingWorkJson = new JSONObject(reportingWorkMap);
- String projectNo=reportingWorkJson.get("projectNo").toString();
- Double width= Double.valueOf(reportingWorkJson.get("width").toString());
- Double height= Double.valueOf(reportingWorkJson.get("height").toString());
- Integer quantity= Integer.valueOf(reportingWorkJson.get("quantity").toString());
+ boolean saveState=true;
+ Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint();
+ try {
+ //鎺ユ敹瑙f瀽涓婚檮琛ㄤ俊鎭�
+ JSONObject reportingWorkJson = new JSONObject(reportingWorkMap);
+ String projectNo=reportingWorkJson.get("projectNo").toString();
+ Double width= Double.valueOf(reportingWorkJson.get("width").toString());
+ Double height= Double.valueOf(reportingWorkJson.get("height").toString());
+ Integer quantity= Integer.valueOf(reportingWorkJson.get("quantity").toString());
- List<MaterialOutbound> materialOutboundList=materialInventoryMapper.getSelectMaterialOutboundProjectNo(projectNo);
- OptimizeUse optimizeUses=materialInventoryMapper.getSelectOptimizeUses(projectNo,width,height);
- List<MaterialOutboundDetail> materialOutboundDetailList=materialInventoryMapper.getSelectMaterialOutboundOptimizeUses(optimizeUses.getId());
- List<MaterialOutboundDetail> materialOutboundDetailList1=materialInventoryMapper.getSelectMaterialOutboundOptimizeUses(null);
- MaterialInventory materialInventory=materialInventoryMapper.getMaterialInventoryById(Long.valueOf(optimizeUses.getRawStockCode()));
- if(materialOutboundList.size()==1){
- if(materialOutboundDetailList.size()==1){
- materialInventoryMapper.updateMaterialOutboundOptimizeUses(optimizeUses.getId());
+ List<MaterialOutbound> materialOutboundList=materialInventoryMapper.getSelectMaterialOutboundProjectNo(projectNo);
+ OptimizeUse optimizeUses=materialInventoryMapper.getSelectOptimizeUses(projectNo,width,height);
+
+ if(optimizeUses.getNotUseCount()>0){
+ MaterialInventory materialInventory=materialInventoryMapper.getMaterialInventoryById(Long.valueOf(optimizeUses.getRawStockCode()));
+ if(materialOutboundList.size()==1){
+ List<MaterialOutboundDetail> materialOutboundDetailList=materialInventoryMapper.getSelectMaterialOutboundOptimizeUses(materialOutboundList.get(0).getMaterialOutboundId(),optimizeUses.getId());
+ List<MaterialOutboundDetail> materialOutboundDetailList1=materialInventoryMapper.getSelectMaterialOutboundOptimizeUses(materialOutboundList.get(0).getMaterialOutboundId(),null);
+ if(materialOutboundDetailList.size()==1){
+ materialInventoryMapper.updateMaterialOutboundOptimizeUses(optimizeUses.getId(),quantity);
+ }else{
+ materialInventoryMapper.insertMaterialOutboundDetailOptimizeUses(materialOutboundList.get(0).getMaterialOutboundId(),
+ materialOutboundDetailList1.size()+1,Long.valueOf(optimizeUses.getRawStockCode()),materialInventory.getMaterialCode(),materialInventory.getInventoryArea(),
+ optimizeUses.getId(),quantity,materialInventory.getSinglePieceArea(),materialInventory.getDateOfManufacture());
+ }
+ }else if(materialOutboundList.isEmpty()){
+ String oddNumber = orderNumberSetting("鍑哄簱");
+ materialInventoryMapper.insertMaterialOutboundOptimizeUses(oddNumber,projectNo,reportingWorkJson.get("userName").toString());
+ materialInventoryMapper.insertMaterialOutboundDetailOptimizeUses(oddNumber, 1,Long.valueOf(optimizeUses.getRawStockCode()),materialInventory.getMaterialCode(),materialInventory.getInventoryArea(),
+ optimizeUses.getId(),quantity,materialInventory.getSinglePieceArea(),materialInventory.getDateOfManufacture());
+ }else{
+ return false;
+ }
materialInventoryMapper.updateMaterialInventoryAvailableInventoryOutMes(Long.valueOf(optimizeUses.getRawStockCode()),quantity);
+ materialInventoryMapper.updateOptimizeUsesMes(optimizeUses.getId(),quantity);
}else{
- materialInventoryMapper.insertMaterialOutboundDetailOptimizeUses(materialOutboundList.get(0).getMaterialOutboundId(),
- materialOutboundDetailList1.size()+1,Long.valueOf(optimizeUses.getRawStockCode()),materialInventory.getMaterialCode(),materialInventory.getInventoryArea(),
- optimizeUses.getId(),quantity,materialInventory.getSinglePieceArea(),materialInventory.getDateOfManufacture());
- materialInventoryMapper.updateMaterialInventoryAvailableInventoryOutMes(Long.valueOf(optimizeUses.getRawStockCode()),quantity);
+ return false;
}
- }else if(materialOutboundList.isEmpty()){
- String oddNumber = orderNumberSetting("鍑哄簱");
- materialInventoryMapper.insertMaterialOutboundOptimizeUses(oddNumber,projectNo,reportingWorkJson.get("userName").toString());
- materialInventoryMapper.insertMaterialOutboundDetailOptimizeUses(oddNumber, materialOutboundDetailList1.size()+1,Long.valueOf(optimizeUses.getRawStockCode()),materialInventory.getMaterialCode(),materialInventory.getInventoryArea(),
- optimizeUses.getId(),quantity,materialInventory.getSinglePieceArea(),materialInventory.getDateOfManufacture());
- materialInventoryMapper.updateMaterialInventoryAvailableInventoryOutMes(Long.valueOf(optimizeUses.getRawStockCode()),quantity);
- }else{
- return false;
- }
- //淇濆瓨鏃ュ織
- Log log = new Log();
- log.setContent(reportingWorkMap.toString());
- log.setFunction("mesMaterialOutbound鎶ュ伐鏂板");
- log.setOperatorId((String) reportingWorkJson.get("userId"));
- log.setOperator((String) reportingWorkJson.get("userName"));
- logService.saveLog(log);
- return true;
+ //淇濆瓨鏃ュ織
+ Log log = new Log();
+ log.setContent(reportingWorkMap.toString());
+ log.setFunction("mesMaterialOutbound鎶ュ伐鏂板");
+ log.setOperatorId((String) reportingWorkJson.get("userId"));
+ log.setOperator((String) reportingWorkJson.get("userName"));
+ logService.saveLog(log);
+ } catch (Exception e) {
+ TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint);
+ //灏嗗紓甯镐紶鍏ユ暟鎹簱
+ SysError sysError = new SysError();
+ sysError.setError(e+Arrays.toString(e.getStackTrace()));
+ sysError.setFunc("mesMaterialOutbound鎶ュ伐鏂板");
+ sysErrorService.insert(sysError);
+ saveState = false;
+
+ }
+ return saveState;
}
+ public String cancelMaterialAdditionRecord(Map<String,Object> object) {
+ String saveState = "true";
+ //璁剧疆鍥炴粴鐐�
+ Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint();
+ try {
+ Log log = new Log();
+ log.setOperatorId(object.get("userId").toString());
+ log.setOperator(object.get("userName").toString());
+ log.setFunction("cancelMaterialAdditionRecord鐗╂枡鏂板鎾ら攢");
+ log.setContent(object.toString());
+ //鑾峰彇瀵硅薄闆嗗悎寰幆杩涜鏂板淇敼
+ List<MaterialLog> materialLoglist = JSONArray.parseArray(JSONObject.toJSONString(object.get("materialAdd")), MaterialLog.class);
+ if (!materialLoglist.isEmpty()){
+ for (MaterialLog materialLog : materialLoglist) {
+
+ if(materialLog.getProducer()==null){
+ materialLog.setProducer("");
+ }
+ //鏌ヨ鐗╂枡鏄惁瀛樺湪
+ List<MaterialInventory> MaterialInventoryList;
+ if (materialLog.getOperationOrderNumber()!=null){
+ MaterialInventoryList = materialInventoryMapper.getMaterialInventoryCount(materialLog.getMaterialCode(), LocalDate.parse(materialLog.getOperationOrderNumber()),materialLog.getProducer());
+ }else{
+ MaterialInventoryList = materialInventoryMapper.getMaterialInventoryCountNull(materialLog.getMaterialCode(),materialLog.getProducer());
+ }
+
+ if(MaterialInventoryList.size()==1){
+ if(MaterialInventoryList.get(0).getAvailableQuantity()>=materialLog.getQuantity()){
+ if (materialLog.getOperationOrderNumber()!=null){
+ materialInventoryMapper.updateMaterialInventoryOut(materialLog.getMaterialCode(),materialLog.getQuantity(),
+ materialLog.getOperationOrderNumber(),materialLog.getProducer());
+ }else{
+ materialInventoryMapper.updateMaterialInventoryNullOut(materialLog.getMaterialCode(),materialLog.getQuantity(),
+ materialLog.getProducer());
+ }
+ materialInventoryMapper.deleteMaterialLogById(materialLog.getId());
+ }else{
+ return "false1";
+ }
+
+ }else{
+ return "false2";
+ }
+ }
+
+ }
+ logService.saveLog(log);
+
+ } catch (Exception e) {
+ TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint);
+ //灏嗗紓甯镐紶鍏ユ暟鎹簱
+ SysError sysError = new SysError();
+ sysError.setError(e+Arrays.toString(e.getStackTrace()));
+ sysError.setFunc("cancelFinishedGoodsInventoryStorage");
+ sysErrorService.insert(sysError);
+ saveState = "false";
+
+ }
+ return saveState;
+
+ }
+
+
+ public Map<String, Object> getOptimizeOutboundReport(String type, Integer pageNum, Integer pageSize, List<String> selectDate, MaterialLog materialLog) {
+ Integer offset = (pageNum-1)*pageSize;
+ String endDate = LocalDate.now().toString();
+ String startDate = LocalDate.now().minusDays(15).toString();
+ if(selectDate !=null && selectDate.size()==2){
+ if(!selectDate.get(0).isEmpty()){
+ startDate = selectDate.get(0);
+ }
+ if(!selectDate.get(1).isEmpty()){
+ endDate = selectDate.get(1);
+ }
+ }
+
+ Map<String, Object> map = new HashMap<>();
+ map.put("data", materialInventoryMapper.getOptimizeOutboundReport(offset, pageSize,startDate, endDate, materialLog,type));
+ map.put("total", materialInventoryMapper.getOptimizeOutboundReportTotal(offset, pageSize,startDate, endDate, materialLog,type));
+ List<String> list = new ArrayList<>();
+ list.add(startDate);
+ list.add(endDate);
+ map.put("selectDate",list);
+ return map;
+ }
+
+ public List<Map<String,Object>> mesOriginalSelect() {
+ return materialInventoryMapper.getSelectMaterialInventoryMes();
+ }
+
+ public String saveToExamineMaterialOutbound(Map<String,Object> object) {
+ String saveState = "true";
+ //璁剧疆鍥炴粴鐐�
+ Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint();
+ String materialOutboundId = "";
+ String oddNumber;
+ if (object.get("materialOutboundId") != null) {
+ materialOutboundId = object.get("materialOutboundId").toString();
+ }
+ Log log = new Log();
+ log.setOperatorId(object.get("userId").toString());
+ log.setOperator(object.get("userName").toString());
+ log.setContent(object.toString());
+ try {
+ MaterialOutbound materialOutbound = JSONObject.parseObject(JSONObject.toJSONString(object.get("title")), MaterialOutbound.class);
+ List<MaterialOutboundDetail> materialOutboundDetailList = JSONArray.parseArray(JSONObject.toJSONString(object.get("materialOutboundDetail")), MaterialOutboundDetail.class);
+ //鏌ヨ鍑哄簱鍗曟槸鍚﹀瓨鍦�
+ Integer MaterialOutboundConut = materialInventoryMapper.getMaterialOutboundCount(materialOutboundId);
+ if (MaterialOutboundConut != 0) {
+
+ List<MaterialOutboundDetail> materialOutboundDetailLists = materialInventoryMapper.getIsNotMaterialOutboundDetail(materialOutboundId);
+ if (!materialOutboundDetailLists.isEmpty()) {
+ for (MaterialOutboundDetail materialOutboundDetail : materialOutboundDetailLists) {
+ //杩樺師鐗╂枡搴撳瓨鏁�
+ materialInventoryMapper.updateMaterialInventoryAvailableInt(materialOutboundDetail.getInventoryId(), materialOutboundDetail.getOutboundQuantity());
+ if(materialOutboundDetail.getUseId()!=null){
+ //杩樺師浼樺寲宸ョ▼搴撳瓨鏁�
+ materialInventoryMapper.updateMaterialInventoryAvailableOptInt(materialOutboundDetail.getUseId(), materialOutboundDetail.getOutboundQuantity());
+ }/*else{
+ //杩樺師鐗╂枡搴撳瓨鏁�
+ materialInventoryMapper.updateMaterialInventoryAvailableInt(materialOutboundDetail.getId(), materialOutboundDetail.getOutboundQuantity());
+ }*/
+
+ }
+ }
+ //鍒犻櫎鏉愭枡鍑哄簱鏄庣粏鐨勬暟鎹�
+ materialInventoryMapper.deleteMaterialOutboundDetail(materialOutboundId);
+ materialInventoryMapper.updateMaterialOutbound(materialOutbound, materialOutboundId);
+ materialInventoryMapper.deleteMaterialLog(materialOutboundId);
+ oddNumber = materialOutboundId;
+ log.setFunction("saveMaterialOutbound淇敼:"+oddNumber);
+ } else {
+ //鑾峰彇鍗曞彿
+ oddNumber = orderNumberSetting("鍑哄簱");
+ //鏂板鏉愭枡鍑哄簱琛ㄦ暟鎹�
+ materialInventoryMapper.insertMaterialOutbound(materialOutbound, oddNumber);
+ log.setFunction("saveMaterialOutbound鏂板:"+oddNumber);
+ }
+ //鑾峰彇瀵硅薄闆嗗悎寰幆杩涜鏂板淇敼
+
+ if (!materialOutboundDetailList.isEmpty()) {
+ for (MaterialOutboundDetail materialOutboundDetail : materialOutboundDetailList) {
+ MaterialInventory materialInventory = materialInventoryMapper.getMaterialInventoryById(materialOutboundDetail.getId());
+ if(materialInventory.getAvailableQuantity()>=materialOutboundDetail.getOutboundQuantity()){
+ Integer materialOutboundDetailMaximum = materialInventoryMapper.getMaterialOutboundDetailMaximum(oddNumber);
+ //鏂板鏉愭枡鍑哄簱鏄庣粏鏁版嵁
+ materialInventoryMapper.insertMaterialOutboundDetail(materialOutboundDetail, oddNumber, materialOutboundDetailMaximum + 1);
+ //淇敼鐗╂枡搴撳瓨琛ㄥ嚭搴撴暟閲�
+ materialInventoryMapper.updateMaterialInventoryAvailableOut(materialOutboundDetail.getId(), materialOutboundDetail.getOutboundQuantity());
+
+ String projectNo="";
+ if(materialOutboundDetail.getUseId()!=null){
+ projectNo = materialInventoryMapper.selectProjectNo(materialOutboundDetail.getUseId());
+ //淇敼浼樺寲宸ョ▼琛ㄥ嚭搴撴暟閲�
+ materialInventoryMapper.updateMaterialInventoryAvailableOptOut(materialOutboundDetail.getUseId(), materialOutboundDetail.getOutboundQuantity());
+
+ }/*else{
+ //淇敼鐗╂枡搴撳瓨琛ㄥ嚭搴撴暟閲�
+ materialInventoryMapper.updateMaterialInventoryAvailableOut(materialOutboundDetail.getId(), materialOutboundDetail.getOutboundQuantity());
+ }*/
+
+ if(materialOutboundDetail.getUseId()!=null){
+ //淇敼鐗╂枡搴撳瓨鏁伴噺
+ materialInventoryMapper.updateMaterialInventoryInventoryPlanQuantityOut(materialOutboundDetail.getId(), materialOutboundDetail.getOutboundQuantity());
+ }else{
+ materialInventoryMapper.updateMaterialInventoryInventoryOut(materialOutboundDetail.getId(), materialOutboundDetail.getOutboundQuantity());
+ }
+
+ materialInventoryMapper.updateMaterialOutboundToExamine(oddNumber,1,object.get("userName").toString());
+ String json="";
+ MaterialStore materialStore=materialStoreMapper.getSelectMaterialStoreById(Long.valueOf(materialOutboundDetail.getMaterialCode()));
+ json=materialStore.getJson().substring(1, materialStore.getJson().length() - 1);
+ MaterialLog materialLog=new MaterialLog();
+ materialLog.setOperationOrderNumber(oddNumber);
+ materialLog.setOperationNumber(materialOutboundDetailMaximum + 1);
+ materialLog.setOperateType("鐗╂枡鍑哄簱");
+ materialLog.setMaterialCode(Long.valueOf(materialOutboundDetail.getMaterialCode()));
+ materialLog.setMaterialName(convertString(json,"\"name\""));
+ materialLog.setProducer(materialInventory.getProducer());
+ materialLog.setUnit(convertString(json,"\"unit\""));
+ materialLog.setWidth(convertDouble(json,"\"width\""));
+ materialLog.setHeight(convertDouble(json,"\"height\""));
+ materialLog.setThickness(convertDouble(json,"\"thickness\""));
+ materialLog.setQuantity(materialOutboundDetail.getOutboundQuantity());
+ materialLog.setSinglePieceArea(materialOutboundDetail.getSinglePieceArea());
+ materialLog.setInventoryId(materialOutboundDetail.getId());
+ materialLog.setInventoryArea(materialInventory.getInventoryArea());
+ materialLog.setRemarks(materialOutboundDetail.getRemarks());
+ materialLog.setProjectNo(projectNo);
+ materialLog.setOperator(object.get("userName").toString());
+ materialLog.setOperateTime(LocalDate.now());
+ materialLogMapper.insert(materialLog);
+ }else{
+ TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint);
+ return "false1";
+ }
+ }
+
+ }
+ logService.saveLog(log);
+
+ } catch (Exception e) {
+ TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint);
+ //灏嗗紓甯镐紶鍏ユ暟鎹簱
+ SysError sysError = new SysError();
+ sysError.setError(e+Arrays.toString(e.getStackTrace()));
+ sysError.setFunc("saveMaterialOutbound");
+ sysErrorService.insert(sysError);
+ saveState = "false";
+
+ }
+ return saveState;
+
+ }
+
+
+ public String updateMaterialInventory(Map<String,Object> object) {
+ String saveState = "true";
+ //璁剧疆鍥炴粴鐐�
+ Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint();
+ try {
+
+ long materialInventoryId = 0L;
+ if (object.get("materialInventoryId") != null) {
+ materialInventoryId = Long.parseLong(object.get("materialInventoryId").toString());
+ }
+ Log log = new Log();
+ log.setOperatorId(object.get("userId").toString());
+ log.setOperator(object.get("userName").toString());
+ log.setContent(object.toString());
+ log.setFunction("updateMaterialInventory鐗╂枡搴撳瓨淇敼");
+ MaterialInventory materialInventory = JSONObject.parseObject(JSONObject.toJSONString(object.get("title")), MaterialInventory.class);
+
+ if(materialInventory.getProducer()==null){
+ materialInventory.setProducer("");
+ }
+ //鏌ヨ鐗╂枡鏄惁瀛樺湪
+ List<MaterialInventory> MaterialInventoryCount;
+ if (materialInventory.getDateOfManufacture()!=null){
+ MaterialInventoryCount = materialInventoryMapper.getMaterialInventoryCount1(materialInventory.getMaterialCode(),materialInventory.getDateOfManufacture(),materialInventory.getProducer(),materialInventory.getId());
+ }else{
+ MaterialInventoryCount = materialInventoryMapper.getMaterialInventoryCountNull1(materialInventory.getMaterialCode(),materialInventory.getProducer(),materialInventory.getId());
+ }
+
+ if(MaterialInventoryCount.size()==1){
+ materialInventoryMapper.updateMaterialInventoryOne(MaterialInventoryCount.get(0).getId(),materialInventory);
+ List<Long> id=new ArrayList<>();
+ id.add(materialInventoryId);
+ materialInventoryMapper.deleteMaterialInventory(id);
+ }else{
+ materialInventoryMapper.updateMaterialInventoryAll(materialInventoryId,materialInventory);
+ }
+
+
+
+ logService.saveLog(log);
+ } catch (Exception e) {
+ TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint);
+ //灏嗗紓甯镐紶鍏ユ暟鎹簱
+ SysError sysError = new SysError();
+ sysError.setError(e+Arrays.toString(e.getStackTrace()));
+ sysError.setFunc("saveMaterialInventory");
+ sysErrorService.insert(sysError);
+ saveState = "false";
+
+ }
+ return saveState;
+
+ }
+
+ public Object appGetStockList() {
+ //ExecutorService executor = Executors.newFixedThreadPool(2);
+ List<MaterialInventory> materialInventoryList = materialInventoryMapper.selectGetStockList();
+ //executor.shutdown();
+
+ Map<String, Object> totalSum = new HashMap<>();
+
+ Integer inventoryQuantity = 0;
+ Integer availableQuantity = 0;
+ Double totalArea = 0.00;
+ for (MaterialInventory materialInventory : materialInventoryList) {
+ inventoryQuantity += materialInventory.getInventoryQuantity();
+ availableQuantity += materialInventory.getAvailableQuantity();
+ totalArea += materialInventory.getTotalArea();
+ }
+ DecimalFormat df = new DecimalFormat("#.00");
+ totalSum.put("inventoryQuantity",inventoryQuantity);
+ totalSum.put("availableQuantity",availableQuantity);
+ totalSum.put("totalArea", df.format(totalArea));
+
+
+ Map<String, Object> map = new HashMap<>();
+ map.put("glassStock", materialInventoryList);
+ map.put("totalSum", totalSum);
+ return map;
+ }
}
--
Gitblit v1.8.0