This commit is contained in:
zhouzy062 2024-04-02 13:36:51 +08:00
commit 8f541d2e3d
5 changed files with 205 additions and 79 deletions

View File

@ -1,5 +1,6 @@
package com.bonus.sgzb.material.domain; package com.bonus.sgzb.material.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
@ -7,6 +8,7 @@ import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
/** /**
* 表单类型表单集合
* @Author ma_sh * @Author ma_sh
* @create 2024/3/28 17:53 * @create 2024/3/28 17:53
*/ */
@ -14,26 +16,41 @@ import lombok.NoArgsConstructor;
@Builder @Builder
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@ApiModel("表单类型表单集合")
public class MachIneDto { public class MachIneDto {
/**
* 判断为数量还是编号true为编号
*/
@ApiModelProperty(value = "判断为数量还是编号true为编号")
private Boolean isCode;
/** /**
* 主键id * 主键id
*/ */
@ApiModelProperty(value = "主键id")
private Integer id; private Integer id;
/** 机具ID */ /** 机具ID */
@ApiModelProperty(value = "机具ID") @ApiModelProperty(value = "机具ID")
private Long maId; private Long maId;
/**
* 类型id
*/
private String typeId;
/** 设备编号 */ /** 设备编号 */
@ApiModelProperty(value = "设备编号") @ApiModelProperty(value = "设备编号")
private String maCode; private String maCode;
/**
* 类型id
*/
@ApiModelProperty(value = "类型id")
private String typeId;
/**
* 主信息
*/
@ApiModelProperty(value = "主信息")
private Integer info;
/** 出厂编码 */ /** 出厂编码 */
@ApiModelProperty(value = "出厂编码") @ApiModelProperty(value = "出厂编码")
private String outFacCode; private String outFacCode;
@ -75,4 +92,28 @@ public class MachIneDto {
*/ */
@ApiModelProperty(value = "备注") @ApiModelProperty(value = "备注")
private String remarks; private String remarks;
/**
* 表单备注
*/
@ApiModelProperty(value = "表单备注")
private String remark;
/**
* 数量
*/
@ApiModelProperty(value = "数量")
private Double num;
/**
* 检验人
*/
@ApiModelProperty(value = "检验人")
private String checkMan;
/**
* 入库数量
*/
@ApiModelProperty(value = "入库数量")
private Double putInStoreNum;
} }

View File

@ -1,6 +1,8 @@
package com.bonus.sgzb.material.domain; package com.bonus.sgzb.material.domain;
import com.bonus.sgzb.common.core.web.domain.BaseEntity; import com.bonus.sgzb.common.core.web.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
@ -15,85 +17,107 @@ import java.util.List;
@Data @Data
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@ApiModel("新增盘点入库接口实体类dto")
public class SavePutInfoDto extends BaseEntity { public class SavePutInfoDto extends BaseEntity {
/** /**
* 判断为数量还是编号true为编号 * 判断为数量还是编号true为编号
*/ */
@ApiModelProperty(value = "判断为数量还是编号true为编号")
private Boolean isCode; private Boolean isCode;
/** /**
* 主键id * 主键id
*/ */
@ApiModelProperty(value = "主键id")
private Integer id; private Integer id;
/** /**
* 类型id * 类型id
*/ */
@ApiModelProperty(value = "类型id")
private String typeId; private String typeId;
/** /**
* 主信息 * 主信息
*/ */
@ApiModelProperty(value = "主信息")
private Integer info; private Integer info;
/** /**
* 数量 * 数量
*/ */
@ApiModelProperty(value = "数量")
private Double num; private Double num;
/** /**
* 库房 * 库房
*/ */
@ApiModelProperty(value = "库房")
private Integer ram; private Integer ram;
/** /**
* 设备工器具类型 * 设备工器具类型
*/ */
@ApiModelProperty(value = "设备工器具类型")
private Integer type; private Integer type;
/** /**
* 设备主键 * 设备主键
*/ */
@ApiModelProperty(value = "设备主键")
private Integer machine; private Integer machine;
/** /**
* 入库形式 * 入库形式
*/ */
@ApiModelProperty(value = "入库形式")
private String putInType; private String putInType;
/** /**
* 盘点入库单号 * 盘点入库单号
*/ */
@ApiModelProperty(value = "盘点入库单号")
private String code; private String code;
/** /**
* 单位名称 * 单位名称
*/ */
@ApiModelProperty(value = "单位名称")
private String unitId; private String unitId;
/** /**
* 工程名称 * 工程名称
*/ */
@ApiModelProperty(value = "工程名称")
private String projectId; private String projectId;
/** /**
* 创建者 * 创建者
*/ */
@ApiModelProperty(value = "创建者")
private String creator; private String creator;
/** /**
* 创建时间 * 创建时间
*/ */
@ApiModelProperty(value = "创建时间")
private String createDate; private String createDate;
/** /**
* 备注 * 备注
*/ */
@ApiModelProperty(value = "备注")
private String remarks; private String remarks;
/** /**
* 表单类型集合 * 检验人
*/
@ApiModelProperty(value = "检验人")
private String checkMan;
/**
* 表单类型表单集合
*/ */
private List<MachIneDto> machIneDtoList; private List<MachIneDto> machIneDtoList;

View File

@ -47,7 +47,7 @@ public interface InventoryAndWarehousingMapper {
* @param * @param
* @return * @return
*/ */
int insertMachine(MachIneDto machIneDtoy); int insertMachine(MachIneDto machIneDto);
int insertMachineLabel(MachIneDto machIneDto); int insertMachineLabel(MachIneDto machIneDto);
@ -58,5 +58,7 @@ public interface InventoryAndWarehousingMapper {
* @param code * @param code
* @return * @return
*/ */
int selectById(String code); int selectByCode(String code);
int selectById(Integer id);
} }

View File

@ -47,20 +47,23 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public AjaxResult savePutInfo(SavePutInfoDto dto) { public AjaxResult savePutInfo(SavePutInfoDto dto) {
log.info("新增入库盘点入参dto{}", dto);
Long userId = SecurityUtils.getLoginUser().getUserid(); Long userId = SecurityUtils.getLoginUser().getUserid();
dto.setCreator(userId.toString()); dto.setCreator(userId.toString());
List<String> codeList = new ArrayList<>(); List<String> codeList = new ArrayList<>();
if (dto.getNum() != null) {
while (codeList.size() < dto.getNum()) { while (codeList.size() < dto.getNum()) {
String code = FieldGenerator.generateField(); String code = FieldGenerator.generateField();
int count = selectById(code); int count = selectByCode(code);
if (count == 0) { if (count == 0) {
codeList.add(code); codeList.add(code);
} }
} }
}
int res = 0; int res = 0;
try { try {
//1. 判断是数量还是编号保存到不同表 //1. 判断是数量还是编号入库保存到不同表
//1.1 如果是编号 //1.1 如果是编号入库
if (dto.getIsCode()) { if (dto.getIsCode()) {
/*插入ma_machinema_machine_label和ma_label_bind以及 /*插入ma_machinema_machine_label和ma_label_bind以及
ma_type_put_in_storage_info表和ma_type_put_in_storage_details表*/ ma_type_put_in_storage_info表和ma_type_put_in_storage_details表*/
@ -69,20 +72,20 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi
log.error("insertMaMachineInfo方法插入异常"); log.error("insertMaMachineInfo方法插入异常");
throw new RuntimeException("insertMaMachineInfo方法插入异常"); throw new RuntimeException("insertMaMachineInfo方法插入异常");
} }
} else {
//2.插入ma_type_put_in_storage_info表和ma_type_put_in_storage_details表
res = insertPutInfo(dto, codeList);
if (res == 0) {
log.error("insertPutInfo方法插入异常");
throw new RuntimeException("insertPutInfo方法插入异常");
}
}
//去修改ma_type里面的库存num根据前端传的数量追加 //去修改ma_type里面的库存num根据前端传的数量追加
res = updateMaTypeInfo(dto.getTypeId(), dto.getNum()); res = updateMaTypeInfo(dto.getTypeId(), dto.getNum());
if (res == 0) { if (res == 0) {
log.error("updateMaTypeInfo方法修改异常"); log.error("updateMaTypeInfo方法修改异常");
throw new RuntimeException("updateMaTypeInfo方法修改异常"); throw new RuntimeException("updateMaTypeInfo方法修改异常");
} }
} else {
//2.插入ma_type_put_in_storage_info表和ma_type_put_in_storage_details表
res = insertPutInfo(dto);
if (res == 0) {
log.error("insertPutInfo方法插入异常");
throw new RuntimeException("insertPutInfo方法插入异常");
}
}
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage()); log.error(e.getMessage());
// 添加事务回滚逻辑 // 添加事务回滚逻辑
@ -99,8 +102,8 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi
* @param code * @param code
* @return * @return
*/ */
private int selectById(String code) { private int selectByCode(String code) {
return inventoryAndWarehousingMapper.selectById(code); return inventoryAndWarehousingMapper.selectByCode(code);
} }
/** /**
@ -115,10 +118,13 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi
MachIneDto machIneDto = dto.getMachIneDtoList().get(i); MachIneDto machIneDto = dto.getMachIneDtoList().get(i);
String code = codeList.get(i); String code = codeList.get(i);
machIneDto.setCode(code); machIneDto.setCode(code);
machIneDto.setIsCode(dto.getIsCode());
machIneDto.setTypeId(dto.getTypeId()); machIneDto.setTypeId(dto.getTypeId());
machIneDto.setCreator(dto.getCreator()); machIneDto.setCreator(dto.getCreator());
machIneDto.setRemarks(dto.getRemarks()); machIneDto.setRemarks(dto.getRemarks());
machIneDto.setPutInType(dto.getPutInType()); machIneDto.setPutInType(dto.getPutInType());
machIneDto.setNum(dto.getNum());
machIneDto.setCheckMan(dto.getCheckMan());
num = inventoryAndWarehousingMapper.insertMachine(machIneDto); num = inventoryAndWarehousingMapper.insertMachine(machIneDto);
if (num == 0) { if (num == 0) {
throw new RuntimeException("新增到ma_machine表失败"); throw new RuntimeException("新增到ma_machine表失败");
@ -131,16 +137,27 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi
if (num == 0) { if (num == 0) {
throw new RuntimeException("新增到ma_label_bind表失败"); throw new RuntimeException("新增到ma_label_bind表失败");
} }
//ma_type_put_in_storage_details表,返回主键id num = getAnInt(machIneDto);
num = inventoryAndWarehousingMapper.saveDetails(machIneDto);
if (num == 0) {
throw new RuntimeException("新增到ma_type_put_in_storage_details表失败");
} }
//插入ma_type_put_in_storage_info表 return num;
}
/**
* 方法抽取
* @param machIneDto
* @return
*/
private int getAnInt(MachIneDto machIneDto) {
int num;
//插入ma_type_put_in_storage_info表,返回主键id
num = inventoryAndWarehousingMapper.saveInfo(machIneDto); num = inventoryAndWarehousingMapper.saveInfo(machIneDto);
if (num == 0) { if (num == 0) {
throw new RuntimeException("新增到ma_type_put_in_storage_info表失败"); throw new RuntimeException("新增到ma_type_put_in_storage_info表失败");
} }
//ma_type_put_in_storage_details表
num = inventoryAndWarehousingMapper.saveDetails(machIneDto);
if (num == 0) {
throw new RuntimeException("新增到ma_type_put_in_storage_details表失败");
} }
return num; return num;
} }
@ -148,7 +165,6 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi
/** /**
* 方法抽取追加ma_type表里面的num * 方法抽取追加ma_type表里面的num
*
* @param typeId * @param typeId
* @param num * @param num
* @return * @return
@ -163,26 +179,16 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi
* @param dto * @param dto
* @return * @return
*/ */
private int insertPutInfo(SavePutInfoDto dto, List<String> codeList) { private int insertPutInfo(SavePutInfoDto dto) {
int num = 0; int num = 0;
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);
String code = codeList.get(i);
machIneDto.setCode(code);
machIneDto.setTypeId(dto.getTypeId());
machIneDto.setCreator(dto.getCreator()); machIneDto.setCreator(dto.getCreator());
machIneDto.setRemarks(dto.getRemarks());
machIneDto.setPutInType(dto.getPutInType()); machIneDto.setPutInType(dto.getPutInType());
//ma_type_put_in_storage_details表,返回主键id machIneDto.setRemarks(dto.getRemarks());
num = inventoryAndWarehousingMapper.saveDetails(machIneDto); getAnInt(machIneDto);
if (num == 0) { //根据类型追加ma_type表里面的num
throw new RuntimeException("新增到ma_type_put_in_storage_details表失败"); num = updateMaTypeInfo(machIneDto.getTypeId(), machIneDto.getPutInStoreNum());
}
//插入ma_type_put_in_storage_info表
num = inventoryAndWarehousingMapper.saveInfo(machIneDto);
if (num == 0) {
throw new RuntimeException("新增到ma_type_put_in_storage_info表失败");
}
} }
return num; return num;
} }

View File

@ -1,11 +1,17 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper <!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"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 (NUM,
<trim prefix="" suffixOverrides=","> <trim prefix="" suffixOverrides=",">
<if test="id != null and id != ''">
INFO,
</if>
<if test="typeId != null and typeId != ''">
TYPE,
</if>
<if test="maId != null and maId != ''"> <if test="maId != null and maId != ''">
MACHINE, MACHINE,
</if> </if>
@ -19,6 +25,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
) )
VALUES (1, VALUES (1,
<trim prefix="" suffixOverrides=","> <trim prefix="" suffixOverrides=",">
<if test="id != null and id != ''">
#{id},
</if>
<if test="typeId != null and typeId != ''">
#{typeId},
</if>
<if test="maId != null and maId != ''"> <if test="maId != null and maId != ''">
#{maId}, #{maId},
</if> </if>
@ -31,24 +43,58 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim> </trim>
) )
</insert> </insert>
<insert id="saveInfo"> <insert id="saveInfo" useGeneratedKeys="true" keyProperty="id">
INSERT INTO ma_type_put_in_storage_info INSERT INTO ma_type_put_in_storage_info
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null and id != 0">ID,</if>
<if test="putInType != null and putInType != ''">PUT_IN_TYPE,</if> <if test="putInType != null and putInType != ''">PUT_IN_TYPE,</if>
<choose>
<when test="isCode and num != null and num != 0">
NUM, NUM,
</when>
<otherwise>
<if test="putInStoreNum != null and putInStoreNum != 0">
NUM,
</if>
</otherwise>
</choose>
<if test="creator != null and creator != ''">CREATOR,</if> <if test="creator != null and creator != ''">CREATOR,</if>
CREATE_DATE, CREATE_DATE,
<if test="remarks != null and remarks != ''">REMARKS</if> <choose>
<when test="isCode and remarks != null and remarks != ''">
REMARKS
</when>
<otherwise>
<if test="remark != null and remark != ''">
REMARKS
</if>
</otherwise>
</choose>
</trim> </trim>
VALUES VALUES
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null and id != 0">#{id},</if>
<if test="putInType != null and putInType != ''">#{putInType},</if> <if test="putInType != null and putInType != ''">#{putInType},</if>
1, <choose>
<when test="isCode and num != null and num != 0">
#{num},
</when>
<otherwise>
<if test="putInStoreNum != null and putInStoreNum != 0">
#{putInStoreNum},
</if>
</otherwise>
</choose>
<if test="creator != null and creator != ''">#{creator},</if> <if test="creator != null and creator != ''">#{creator},</if>
sysdate(), sysdate(),
<if test="remarks != null and remarks != ''">#{remarks}</if> <choose>
<when test="isCode and remarks != null and remarks != ''">
#{remarks}
</when>
<otherwise>
<if test="remark != null and remark != ''">
#{remark}
</if>
</otherwise>
</choose>
</trim> </trim>
</insert> </insert>
<insert id="insertMachine" useGeneratedKeys="true" keyProperty="maId"> <insert id="insertMachine" useGeneratedKeys="true" keyProperty="maId">
@ -59,6 +105,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="code != null and code != ''">qr_code,</if> <if test="code != null and code != ''">qr_code,</if>
<if test="buyPrice != null and buyPrice != ''">buy_price,</if> <if test="buyPrice != null and buyPrice != ''">buy_price,</if>
<if test="maVender != null and maVender != ''">ma_vender,</if> <if test="maVender != null and maVender != ''">ma_vender,</if>
<if test="checkMan != null and checkMan != ''">check_man,</if>
<if test="outFacCode != null and outFacCode != ''">out_fac_code,</if> <if test="outFacCode != null and outFacCode != ''">out_fac_code,</if>
<if test="thisCheckTime != null and thisCheckTime != ''">this_check_time,</if> <if test="thisCheckTime != null and thisCheckTime != ''">this_check_time,</if>
<if test="nextCheckTime != null and nextCheckTime != ''">next_check_time,</if> <if test="nextCheckTime != null and nextCheckTime != ''">next_check_time,</if>
@ -70,6 +117,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="code != null and code != ''">#{code},</if> <if test="code != null and code != ''">#{code},</if>
<if test="buyPrice != null and buyPrice != ''">#{buyPrice},</if> <if test="buyPrice != null and buyPrice != ''">#{buyPrice},</if>
<if test="maVender != null and maVender != ''">#{maVender},</if> <if test="maVender != null and maVender != ''">#{maVender},</if>
<if test="checkMan != null and checkMan != ''">#{checkMan},</if>
<if test="outFacCode != null and outFacCode != ''">#{outFacCode},</if> <if test="outFacCode != null and outFacCode != ''">#{outFacCode},</if>
<if test="thisCheckTime != null and thisCheckTime != ''">#{thisCheckTime},</if> <if test="thisCheckTime != null and thisCheckTime != ''">#{thisCheckTime},</if>
<if test="nextCheckTime != null and nextCheckTime != ''">#{nextCheckTime},</if> <if test="nextCheckTime != null and nextCheckTime != ''">#{nextCheckTime},</if>
@ -116,35 +164,40 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</insert> </insert>
<update id="updateMaType"> <update id="updateMaType">
UPDATE ma_type UPDATE ma_type
SET num = num + #{num} SET num = num + #{num},
update_time = now()
<where> <where>
<if test="typeId != null "> and type_id = #{typeId}</if> <if test="typeId != null ">and type_id = #{typeId}</if>
</where> </where>
</update> </update>
<select id="getList" resultType="com.bonus.sgzb.material.domain.PutInStorageBean"> <select id="getList" resultType="com.bonus.sgzb.material.domain.PutInStorageBean">
SELECT SELECT pisi.PUT_IN_TYPE as putInType,
pisi.PUT_IN_TYPE as putInType,
lot.lot_name as projectName, lot.lot_name as projectName,
bui.unit_name as unitName, bui.unit_name as unitName,
pisi.`CODE` as code, pisi.`CODE` as code,
mt2.type_name as typeName, mt2.type_name as typeName,
su.user_name as userName, su.user_name as userName,
pisi.CREATE_DATE as createDate pisi.CREATE_DATE as createDate
FROM FROM ma_type_put_in_storage_info pisi
ma_type_put_in_storage_info pisi LEFT JOIN ma_type_put_in_storage_details pisd on pisi.id = pisd.INFO
LEFT JOIN ma_type_put_in_storage_details pisd on pisi.id=pisd.INFO LEFT JOIN bm_project_lot lot on lot.lot_id = pisi.PROJECT_ID
LEFT JOIN bm_project_lot lot on lot.lot_id=pisi.PROJECT_ID LEFT JOIN bm_unit_info bui on bui.unit_id = pisi.UNIT_ID
LEFT JOIN bm_unit_info bui on bui.unit_id=pisi.UNIT_ID LEFT JOIN ma_type mt on mt.type_id = pisd.TYPE
LEFT JOIN ma_type mt on mt.type_id=pisd.TYPE LEFT JOIN ma_type mt2 on mt2.type_id = mt.parent_id
LEFT JOIN ma_type mt2 on mt2.type_id=mt.parent_id LEFT JOIN sys_user su on su.user_id = pisi.CREATOR
LEFT JOIN sys_user su on su.user_id=pisi.CREATOR
</select> </select>
<select id="selectById" resultType="java.lang.Integer"> <select id="selectByCode" resultType="java.lang.Integer">
select count(*) select count(*)
from ma_machine from ma_machine
<where> <where>
<if test="code != null "> and qr_code = #{code}</if> <if test="code != null ">and qr_code = #{code}</if>
</where>
</select>
<select id="selectById" resultType="java.lang.Integer">
select info from ma_type_put_in_storage_details
<where>
<if test="id != null">and ID = #{id}</if>
</where> </where>
</select> </select>
</mapper> </mapper>