chenlu
2024-06-07 2f640b1038fa331954f78ed1f4317212cf5bb34d
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
@@ -19,6 +21,8 @@
public class MaterialStoreService {
    @Autowired
    MaterialStoreMapper materialStoreMapper;
    @Autowired
    MaterialInventoryMapper materialInventoryMapper;
    @Autowired
    BasicWarehouseTypeMapper basicWarehouseTypeMapper;
    @Autowired
@@ -29,6 +33,9 @@
            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,8 +45,19 @@
            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);
            }