From b6ea206938c4f7a318486e6e3a0fff9924a0fbcf Mon Sep 17 00:00:00 2001
From: chenlu <1320612696@qq.com>
Date: 星期四, 01 八月 2024 17:35:08 +0800
Subject: [PATCH] Merge branch 'master' of http://bore.pub:10439/r/ERP_override

---
 north-glass-erp/src/main/java/com/example/erp/service/mm/MaterialStoreService.java |   34 ++++++++++++++++++++++++++++++++--
 1 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/north-glass-erp/src/main/java/com/example/erp/service/mm/MaterialStoreService.java b/north-glass-erp/src/main/java/com/example/erp/service/mm/MaterialStoreService.java
index eb878ef..b9b3b4e 100644
--- a/north-glass-erp/src/main/java/com/example/erp/service/mm/MaterialStoreService.java
+++ b/north-glass-erp/src/main/java/com/example/erp/service/mm/MaterialStoreService.java
@@ -4,6 +4,7 @@
 import com.example.erp.entity.mm.MaterialStore;
 import com.example.erp.entity.userInfo.SysError;
 import com.example.erp.mapper.mm.BasicWarehouseTypeMapper;
+import com.example.erp.mapper.mm.MaterialInventoryMapper;
 import com.example.erp.mapper.mm.MaterialStoreMapper;
 import com.example.erp.service.userInfo.SysErrorService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -11,6 +12,7 @@
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
+import java.text.DecimalFormat;
 import java.util.*;
 
 @Service
@@ -20,15 +22,23 @@
     @Autowired
     MaterialStoreMapper materialStoreMapper;
     @Autowired
+    MaterialInventoryMapper materialInventoryMapper;
+    @Autowired
     BasicWarehouseTypeMapper basicWarehouseTypeMapper;
     @Autowired
     SysErrorService sysErrorService;
 
     public Boolean saveMaterialStore(Map<String,Object> object) {
         boolean saveState = true;
+        //璁剧疆鍥炴粴鐐�
+        Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint();
+        try {
             String id = "";
             String type = "";
             String json = "";
+            double width = 0.0;
+            double height = 0.0;
+            double singlePieceArea=0.0;
             if (object.get("id") != null) {
                 id = object.get("id").toString();
             }
@@ -38,12 +48,32 @@
             if (object.get("json") != null) {
                 json = object.get("json").toString();
             }
+            if (object.get("width") != null) {
+                width = Double.parseDouble(object.get("width").toString());
+            }
+            if (object.get("height") != null) {
+                height = Double.parseDouble(object.get("height").toString());
+            }
+            DecimalFormat decimalFormat = new DecimalFormat("#0.00");
+            singlePieceArea= Double.parseDouble(decimalFormat.format(width * height / 100000));
             if(Long.parseLong(id)>0){
                 materialStoreMapper.updateMaterialStore(type,json, Long.valueOf(id));
+                if (Objects.equals(type, "鍘熺墖")){
+                    materialInventoryMapper.updateMaterialInventoryArea(Long.valueOf(id),singlePieceArea);
+                }
             }else{
                 materialStoreMapper.insertMaterialStore(type,json);
             }
+        } catch (Exception e) {
+            TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint);
+            //灏嗗紓甯镐紶鍏ユ暟鎹簱
+            SysError sysError = new SysError();
+            sysError.setError(e+Arrays.toString(e.getStackTrace()));
+            sysError.setFunc("saveMaterialStore");
+            sysErrorService.insert(sysError);
+            saveState = false;
 
+        }
         return saveState;
 
     }
@@ -76,8 +106,8 @@
             TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint);
             //灏嗗紓甯镐紶鍏ユ暟鎹簱
             SysError sysError = new SysError();
-            sysError.setError(e.toString());
-            sysError.setFunc("saveOrder");
+            sysError.setError(e+Arrays.toString(e.getStackTrace()));
+            sysError.setFunc("deleteMaterialStore");
             sysErrorService.insert(sysError);
             saveState = false;
 

--
Gitblit v1.8.0