From affa4c62a4a2a033f31ef3ecc3b74edd8d1f1e20 Mon Sep 17 00:00:00 2001 From: mashuai Date: Sat, 25 May 2024 16:47:00 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=98=E7=82=B9=E5=85=A5=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sgzb/material/domain/MachIneDto.java | 12 ++++++ .../InventoryAndWarehousingServiceImpl.java | 39 +++++++++++++++++-- .../InventoryAndWarehousingMapper.xml | 36 +++++++++++++---- 3 files changed, 75 insertions(+), 12 deletions(-) diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MachIneDto.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MachIneDto.java index f186ca3b..211cd0ee 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MachIneDto.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MachIneDto.java @@ -31,6 +31,12 @@ public class MachIneDto { @ApiModelProperty(value = "主键id") private Integer id; + /** + * 主键id + */ + @ApiModelProperty(value = "主键id") + private Integer infoId; + /** 机具ID */ @ApiModelProperty(value = "机具ID") private Long maId; @@ -105,6 +111,12 @@ public class MachIneDto { @ApiModelProperty(value = "上方页面入库数量") private Double num; + /** + * 表单数量总和 + */ + @ApiModelProperty(value = "表单数量总和") + private Double totalNum; + /** * 检验人 */ diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/InventoryAndWarehousingServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/InventoryAndWarehousingServiceImpl.java index a1344df1..61642674 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/InventoryAndWarehousingServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/InventoryAndWarehousingServiceImpl.java @@ -11,6 +11,7 @@ import com.bonus.sgzb.material.mapper.InventoryAndWarehousingMapper; import com.bonus.sgzb.material.service.InventoryAndWarehousingService; import com.bonus.sgzb.material.vo.GlobalContants; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -18,6 +19,7 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport; import java.text.SimpleDateFormat; import java.util.*; +import java.util.stream.Collectors; /** * @author hay @@ -114,6 +116,16 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi */ private int insertMaMachineInfo(SavePutInfoDto dto, String code) { int res = 0; + if (dto.getNum() != null) { + MachIneDto machIneDto = dto.getMachIneDtoList().get(0); + machIneDto.setCode(code); + machIneDto.setPutInType(dto.getPutInType()); + machIneDto.setCreator(dto.getCreator()); + machIneDto.setNum(dto.getNum()); + machIneDto.setIsCode(dto.getIsCode()); + res += insertInfo(machIneDto); + machIneDto.setInfoId(machIneDto.getId()); + } for (int i = 0; i < dto.getMachIneDtoList().size(); i++) { MachIneDto machIneDto = dto.getMachIneDtoList().get(i); machIneDto.setCode(code); @@ -126,11 +138,18 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi machIneDto.setCheckMan(dto.getCheckMan()); machIneDto.setUnitId(dto.getUnitId()); machIneDto.setProId(dto.getProId()); + machIneDto.setInfoId(dto.getMachIneDtoList().get(0).getInfoId()); res += insertMachineInfo(machIneDto); } return res; } + //插入ma_type_put_in_storage_info表,返回主键id + private int insertInfo(MachIneDto machIneDto) { + return inventoryAndWarehousingMapper.saveInfo(machIneDto); + } + + /** * 方法抽取,保持到ma_machine、ma_machine_label和ma_label_bind * @param machIneDto @@ -150,11 +169,8 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi * @return */ private int insertTypePutInStorageInfo(MachIneDto machIneDto) { - //插入ma_type_put_in_storage_info表,返回主键id - int res = inventoryAndWarehousingMapper.saveInfo(machIneDto); //ma_type_put_in_storage_details表 - res += inventoryAndWarehousingMapper.saveDetails(machIneDto); - return res; + return inventoryAndWarehousingMapper.saveDetails(machIneDto); } @@ -176,6 +192,20 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi */ private int insertPutInfo(SavePutInfoDto dto, String code) { int res = 0; + Double total = dto.getMachIneDtoList().stream() + .map(MachIneDto::getPutInStoreNum) + .filter(num -> num != null) + .collect(Collectors.summingDouble(Double::doubleValue)); + if (CollectionUtils.isNotEmpty(dto.getMachIneDtoList())) { + MachIneDto machIneDto = dto.getMachIneDtoList().get(0); + machIneDto.setCode(code); + machIneDto.setPutInType(dto.getPutInType()); + machIneDto.setCreator(dto.getCreator()); + machIneDto.setIsCode(dto.getIsCode()); + machIneDto.setTotalNum(total); + res += insertInfo(machIneDto); + machIneDto.setInfoId(machIneDto.getId()); + } for (int i = 0; i < dto.getMachIneDtoList().size(); i++) { MachIneDto machIneDto = dto.getMachIneDtoList().get(i); machIneDto.setCreator(dto.getCreator()); @@ -184,6 +214,7 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi machIneDto.setUnitId(dto.getUnitId()); machIneDto.setProId(dto.getProId()); machIneDto.setCode(code); + machIneDto.setInfoId(dto.getMachIneDtoList().get(0).getInfoId()); res += insertTypePutInStorageInfo(machIneDto); //根据类型追加ma_type表里面的num res += updateMaTypeInfo(machIneDto.getTypeId(), machIneDto.getPutInStoreNum()); diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/InventoryAndWarehousingMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/InventoryAndWarehousingMapper.xml index de24b8d4..eee98fba 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/InventoryAndWarehousingMapper.xml +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/InventoryAndWarehousingMapper.xml @@ -4,9 +4,19 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - INSERT INTO ma_type_put_in_storage_details (NUM, + INSERT INTO ma_type_put_in_storage_details ( - + + + NUM, + + + + NUM, + + + + INFO, @@ -23,10 +33,20 @@ ) - VALUES (1, + VALUES ( + + + 1, + + + + #{putInStoreNum}, + + + - - #{id}, + + #{infoId}, #{typeId}, @@ -52,7 +72,7 @@ NUM, - + NUM, @@ -81,8 +101,8 @@ #{num}, - - #{putInStoreNum}, + + #{totalNum},