盘点入库
This commit is contained in:
parent
2d37e70125
commit
c45eb9c65b
|
|
@ -31,6 +31,12 @@ public class MachIneDto {
|
||||||
@ApiModelProperty(value = "主键id")
|
@ApiModelProperty(value = "主键id")
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键id
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "主键id")
|
||||||
|
private Integer infoId;
|
||||||
|
|
||||||
/** 机具ID */
|
/** 机具ID */
|
||||||
@ApiModelProperty(value = "机具ID")
|
@ApiModelProperty(value = "机具ID")
|
||||||
private Long maId;
|
private Long maId;
|
||||||
|
|
@ -117,6 +123,12 @@ public class MachIneDto {
|
||||||
@ApiModelProperty(value = "表单集合入库数量")
|
@ApiModelProperty(value = "表单集合入库数量")
|
||||||
private Double putInStoreNum;
|
private Double putInStoreNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表单数量总和
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "表单数量总和")
|
||||||
|
private Double totalNum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 单位名称
|
* 单位名称
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import com.bonus.sgzb.material.mapper.InventoryAndWarehousingMapper;
|
||||||
import com.bonus.sgzb.material.service.InventoryAndWarehousingService;
|
import com.bonus.sgzb.material.service.InventoryAndWarehousingService;
|
||||||
import com.bonus.sgzb.material.vo.GlobalContants;
|
import com.bonus.sgzb.material.vo.GlobalContants;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
@ -18,6 +19,7 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author hay
|
* @author hay
|
||||||
|
|
@ -114,6 +116,16 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi
|
||||||
*/
|
*/
|
||||||
private int insertMaMachineInfo(SavePutInfoDto dto, String code) {
|
private int insertMaMachineInfo(SavePutInfoDto dto, String code) {
|
||||||
int res = 0;
|
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++) {
|
for (int i = 0; i < dto.getMachIneDtoList().size(); i++) {
|
||||||
MachIneDto machIneDto = dto.getMachIneDtoList().get(i);
|
MachIneDto machIneDto = dto.getMachIneDtoList().get(i);
|
||||||
machIneDto.setCode(code);
|
machIneDto.setCode(code);
|
||||||
|
|
@ -126,11 +138,17 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi
|
||||||
machIneDto.setCheckMan(dto.getCheckMan());
|
machIneDto.setCheckMan(dto.getCheckMan());
|
||||||
machIneDto.setUnitId(dto.getUnitId());
|
machIneDto.setUnitId(dto.getUnitId());
|
||||||
machIneDto.setProId(dto.getProId());
|
machIneDto.setProId(dto.getProId());
|
||||||
|
machIneDto.setInfoId(dto.getMachIneDtoList().get(0).getInfoId());
|
||||||
res += insertMachineInfo(machIneDto);
|
res += insertMachineInfo(machIneDto);
|
||||||
}
|
}
|
||||||
return res;
|
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
|
* 方法抽取,保持到ma_machine、ma_machine_label和ma_label_bind
|
||||||
* @param machIneDto
|
* @param machIneDto
|
||||||
|
|
@ -150,11 +168,8 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private int insertTypePutInStorageInfo(MachIneDto machIneDto) {
|
private int insertTypePutInStorageInfo(MachIneDto machIneDto) {
|
||||||
//插入ma_type_put_in_storage_info表,返回主键id
|
|
||||||
int res = inventoryAndWarehousingMapper.saveInfo(machIneDto);
|
|
||||||
//ma_type_put_in_storage_details表
|
//ma_type_put_in_storage_details表
|
||||||
res += inventoryAndWarehousingMapper.saveDetails(machIneDto);
|
return inventoryAndWarehousingMapper.saveDetails(machIneDto);
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -176,6 +191,20 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi
|
||||||
*/
|
*/
|
||||||
private int insertPutInfo(SavePutInfoDto dto, String code) {
|
private int insertPutInfo(SavePutInfoDto dto, String code) {
|
||||||
int res = 0;
|
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++) {
|
for (int i = 0; i < dto.getMachIneDtoList().size(); i++) {
|
||||||
MachIneDto machIneDto = dto.getMachIneDtoList().get(i);
|
MachIneDto machIneDto = dto.getMachIneDtoList().get(i);
|
||||||
machIneDto.setCreator(dto.getCreator());
|
machIneDto.setCreator(dto.getCreator());
|
||||||
|
|
@ -184,6 +213,7 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi
|
||||||
machIneDto.setUnitId(dto.getUnitId());
|
machIneDto.setUnitId(dto.getUnitId());
|
||||||
machIneDto.setProId(dto.getProId());
|
machIneDto.setProId(dto.getProId());
|
||||||
machIneDto.setCode(code);
|
machIneDto.setCode(code);
|
||||||
|
machIneDto.setInfoId(dto.getMachIneDtoList().get(0).getInfoId());
|
||||||
res += insertTypePutInStorageInfo(machIneDto);
|
res += insertTypePutInStorageInfo(machIneDto);
|
||||||
//根据类型追加ma_type表里面的num
|
//根据类型追加ma_type表里面的num
|
||||||
res += updateMaTypeInfo(machIneDto.getTypeId(), machIneDto.getPutInStoreNum());
|
res += updateMaTypeInfo(machIneDto.getTypeId(), machIneDto.getPutInStoreNum());
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,19 @@
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.bonus.sgzb.material.mapper.InventoryAndWarehousingMapper">
|
<mapper namespace="com.bonus.sgzb.material.mapper.InventoryAndWarehousingMapper">
|
||||||
<insert id="saveDetails" useGeneratedKeys="true" keyProperty="id">
|
<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=",">
|
<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,
|
INFO,
|
||||||
</if>
|
</if>
|
||||||
<if test="typeId != null and typeId != ''">
|
<if test="typeId != null and typeId != ''">
|
||||||
|
|
@ -23,10 +33,20 @@
|
||||||
</if>
|
</if>
|
||||||
</trim>
|
</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=",">
|
<trim prefix="" suffixOverrides=",">
|
||||||
<if test="id != null and id != ''">
|
<if test="infoId != null and infoId != ''">
|
||||||
#{id},
|
#{infoId},
|
||||||
</if>
|
</if>
|
||||||
<if test="typeId != null and typeId != ''">
|
<if test="typeId != null and typeId != ''">
|
||||||
#{typeId},
|
#{typeId},
|
||||||
|
|
@ -52,7 +72,7 @@
|
||||||
NUM,
|
NUM,
|
||||||
</when>
|
</when>
|
||||||
<otherwise>
|
<otherwise>
|
||||||
<if test="putInStoreNum != null and putInStoreNum != 0">
|
<if test="totalNum != null and totalNum != 0">
|
||||||
NUM,
|
NUM,
|
||||||
</if>
|
</if>
|
||||||
</otherwise>
|
</otherwise>
|
||||||
|
|
@ -81,8 +101,8 @@
|
||||||
#{num},
|
#{num},
|
||||||
</when>
|
</when>
|
||||||
<otherwise>
|
<otherwise>
|
||||||
<if test="putInStoreNum != null and putInStoreNum != 0">
|
<if test="totalNum != null and totalNum != 0">
|
||||||
#{putInStoreNum},
|
#{totalNum},
|
||||||
</if>
|
</if>
|
||||||
</otherwise>
|
</otherwise>
|
||||||
</choose>
|
</choose>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue