盘点入库

This commit is contained in:
mashuai 2024-05-25 16:47:00 +08:00
parent 390d87b67c
commit affa4c62a4
3 changed files with 75 additions and 12 deletions

View File

@ -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;
/**
* 检验人
*/

View File

@ -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_machinema_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());

View File

@ -4,9 +4,19 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bonus.sgzb.material.mapper.InventoryAndWarehousingMapper">
<insert id="saveDetails" useGeneratedKeys="true" keyProperty="id">
INSERT INTO ma_type_put_in_storage_details (NUM,
INSERT INTO ma_type_put_in_storage_details (
<trim prefix="" suffixOverrides=",">
<if test="id != null and id != ''">
<choose>
<when test="isCode and num != null and num != 0">
NUM,
</when>
<otherwise>
<if test="putInStoreNum != null and putInStoreNum != 0">
NUM,
</if>
</otherwise>
</choose>
<if test="infoId != null and infoId != ''">
INFO,
</if>
<if test="typeId != null and typeId != ''">
@ -23,10 +33,20 @@
</if>
</trim>
)
VALUES (1,
VALUES (
<choose>
<when test="isCode and num != null and num != 0">
1,
</when>
<otherwise>
<if test="putInStoreNum != null and putInStoreNum != 0">
#{putInStoreNum},
</if>
</otherwise>
</choose>
<trim prefix="" suffixOverrides=",">
<if test="id != null and id != ''">
#{id},
<if test="infoId != null and infoId != ''">
#{infoId},
</if>
<if test="typeId != null and typeId != ''">
#{typeId},
@ -52,7 +72,7 @@
NUM,
</when>
<otherwise>
<if test="putInStoreNum != null and putInStoreNum != 0">
<if test="totalNum != null and totalNum != 0">
NUM,
</if>
</otherwise>
@ -81,8 +101,8 @@
#{num},
</when>
<otherwise>
<if test="putInStoreNum != null and putInStoreNum != 0">
#{putInStoreNum},
<if test="totalNum != null and totalNum != 0">
#{totalNum},
</if>
</otherwise>
</choose>