From a053608b784552dbfc5612f16ce389b809524824 Mon Sep 17 00:00:00 2001 From: mashuai Date: Tue, 2 Apr 2024 13:19:59 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=98=E7=82=B9=E5=85=A5=E5=BA=93-=E6=95=B0?= =?UTF-8?q?=E9=87=8F=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 | 51 +++++++- .../sgzb/material/domain/SavePutInfoDto.java | 26 +++- .../mapper/InventoryAndWarehousingMapper.java | 6 +- .../InventoryAndWarehousingServiceImpl.java | 90 +++++++------- .../InventoryAndWarehousingMapper.xml | 111 +++++++++++++----- 5 files changed, 205 insertions(+), 79 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 77da40fc..2ab9cc25 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 @@ -1,5 +1,6 @@ package com.bonus.sgzb.material.domain; +import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.AllArgsConstructor; import lombok.Builder; @@ -7,6 +8,7 @@ import lombok.Data; import lombok.NoArgsConstructor; /** + * 表单类型表单集合 * @Author ma_sh * @create 2024/3/28 17:53 */ @@ -14,26 +16,41 @@ import lombok.NoArgsConstructor; @Builder @AllArgsConstructor @NoArgsConstructor +@ApiModel("表单类型表单集合") public class MachIneDto { + /** + * 判断为数量还是编号,true为编号 + */ + @ApiModelProperty(value = "判断为数量还是编号,true为编号") + private Boolean isCode; + /** * 主键id */ + @ApiModelProperty(value = "主键id") private Integer id; /** 机具ID */ @ApiModelProperty(value = "机具ID") private Long maId; - /** - * 类型id - */ - private String typeId; - /** 设备编号 */ @ApiModelProperty(value = "设备编号") private String maCode; + /** + * 类型id + */ + @ApiModelProperty(value = "类型id") + private String typeId; + + /** + * 主信息 + */ + @ApiModelProperty(value = "主信息") + private Integer info; + /** 出厂编码 */ @ApiModelProperty(value = "出厂编码") private String outFacCode; @@ -75,4 +92,28 @@ public class MachIneDto { */ @ApiModelProperty(value = "备注") private String remarks; + + /** + * 表单备注 + */ + @ApiModelProperty(value = "表单备注") + private String remark; + + /** + * 数量 + */ + @ApiModelProperty(value = "数量") + private Double num; + + /** + * 检验人 + */ + @ApiModelProperty(value = "检验人") + private String checkMan; + + /** + * 入库数量 + */ + @ApiModelProperty(value = "入库数量") + private Double putInStoreNum; } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/SavePutInfoDto.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/SavePutInfoDto.java index 76e1021c..cd46450d 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/SavePutInfoDto.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/SavePutInfoDto.java @@ -1,6 +1,8 @@ package com.bonus.sgzb.material.domain; import com.bonus.sgzb.common.core.web.domain.BaseEntity; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -15,85 +17,107 @@ import java.util.List; @Data @AllArgsConstructor @NoArgsConstructor +@ApiModel("新增盘点入库接口实体类dto") public class SavePutInfoDto extends BaseEntity { /** * 判断为数量还是编号,true为编号 */ + @ApiModelProperty(value = "判断为数量还是编号,true为编号") private Boolean isCode; /** * 主键id */ + @ApiModelProperty(value = "主键id") private Integer id; /** * 类型id */ + @ApiModelProperty(value = "类型id") private String typeId; /** * 主信息 */ + @ApiModelProperty(value = "主信息") private Integer info; /** * 数量 */ + @ApiModelProperty(value = "数量") private Double num; /** * 库房 */ + @ApiModelProperty(value = "库房") private Integer ram; /** * 设备工器具类型 */ + @ApiModelProperty(value = "设备工器具类型") private Integer type; /** * 设备主键 */ + @ApiModelProperty(value = "设备主键") private Integer machine; /** * 入库形式 */ + @ApiModelProperty(value = "入库形式") private String putInType; /** * 盘点入库单号 */ + @ApiModelProperty(value = "盘点入库单号") private String code; /** * 单位名称 */ + @ApiModelProperty(value = "单位名称") private String unitId; /** * 工程名称 */ + @ApiModelProperty(value = "工程名称") private String projectId; /** * 创建者 */ + @ApiModelProperty(value = "创建者") private String creator; /** * 创建时间 */ + @ApiModelProperty(value = "创建时间") private String createDate; /** * 备注 */ + @ApiModelProperty(value = "备注") private String remarks; /** - * 表单类型集合 + * 检验人 + */ + @ApiModelProperty(value = "检验人") + private String checkMan; + + /** + * 表单类型表单集合 */ private List machIneDtoList; diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/InventoryAndWarehousingMapper.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/InventoryAndWarehousingMapper.java index c176453d..d43bb2db 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/InventoryAndWarehousingMapper.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/InventoryAndWarehousingMapper.java @@ -47,7 +47,7 @@ public interface InventoryAndWarehousingMapper { * @param * @return */ - int insertMachine(MachIneDto machIneDtoy); + int insertMachine(MachIneDto machIneDto); int insertMachineLabel(MachIneDto machIneDto); @@ -58,5 +58,7 @@ public interface InventoryAndWarehousingMapper { * @param code * @return */ - int selectById(String code); + int selectByCode(String code); + + int selectById(Integer id); } 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 1d490fdd..88a0a445 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 @@ -47,20 +47,23 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi @Override @Transactional(rollbackFor = Exception.class) public AjaxResult savePutInfo(SavePutInfoDto dto) { + log.info("新增入库盘点入参dto:{}", dto); Long userId = SecurityUtils.getLoginUser().getUserid(); dto.setCreator(userId.toString()); List codeList = new ArrayList<>(); - while (codeList.size() < dto.getNum()) { - String code = FieldGenerator.generateField(); - int count = selectById(code); - if (count == 0) { - codeList.add(code); + if (dto.getNum() != null) { + while (codeList.size() < dto.getNum()) { + String code = FieldGenerator.generateField(); + int count = selectByCode(code); + if (count == 0) { + codeList.add(code); + } } } int res = 0; try { - //1. 判断是数量还是编号,保存到不同表 - //1.1 如果是编号 + //1. 判断是数量还是编号入库,保存到不同表 + //1.1 如果是编号入库 if (dto.getIsCode()) { /*插入ma_machine、ma_machine_label和ma_label_bind以及 ma_type_put_in_storage_info表和ma_type_put_in_storage_details表*/ @@ -69,20 +72,20 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi log.error("insertMaMachineInfo方法插入异常"); throw new RuntimeException("insertMaMachineInfo方法插入异常"); } + //去修改ma_type里面的库存num,根据前端传的数量追加 + res = updateMaTypeInfo(dto.getTypeId(), dto.getNum()); + if (res == 0) { + log.error("updateMaTypeInfo方法修改异常"); + throw new RuntimeException("updateMaTypeInfo方法修改异常"); + } } else { //2.插入ma_type_put_in_storage_info表和ma_type_put_in_storage_details表 - res = insertPutInfo(dto, codeList); + res = insertPutInfo(dto); if (res == 0) { log.error("insertPutInfo方法插入异常"); throw new RuntimeException("insertPutInfo方法插入异常"); } } - //去修改ma_type里面的库存num,根据前端传的数量追加 - res = updateMaTypeInfo(dto.getTypeId(), dto.getNum()); - if (res == 0) { - log.error("updateMaTypeInfo方法修改异常"); - throw new RuntimeException("updateMaTypeInfo方法修改异常"); - } } catch (Exception e) { log.error(e.getMessage()); // 添加事务回滚逻辑 @@ -99,8 +102,8 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi * @param code * @return */ - private int selectById(String code) { - return inventoryAndWarehousingMapper.selectById(code); + private int selectByCode(String code) { + return inventoryAndWarehousingMapper.selectByCode(code); } /** @@ -115,10 +118,13 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi MachIneDto machIneDto = dto.getMachIneDtoList().get(i); String code = codeList.get(i); machIneDto.setCode(code); + machIneDto.setIsCode(dto.getIsCode()); machIneDto.setTypeId(dto.getTypeId()); machIneDto.setCreator(dto.getCreator()); machIneDto.setRemarks(dto.getRemarks()); machIneDto.setPutInType(dto.getPutInType()); + machIneDto.setNum(dto.getNum()); + machIneDto.setCheckMan(dto.getCheckMan()); num = inventoryAndWarehousingMapper.insertMachine(machIneDto); if (num == 0) { throw new RuntimeException("新增到ma_machine表失败"); @@ -131,16 +137,27 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi if (num == 0) { throw new RuntimeException("新增到ma_label_bind表失败"); } - //ma_type_put_in_storage_details表,返回主键id - num = inventoryAndWarehousingMapper.saveDetails(machIneDto); - if (num == 0) { - throw new RuntimeException("新增到ma_type_put_in_storage_details表失败"); - } - //插入ma_type_put_in_storage_info表 - num = inventoryAndWarehousingMapper.saveInfo(machIneDto); - if (num == 0) { - throw new RuntimeException("新增到ma_type_put_in_storage_info表失败"); - } + num = getAnInt(machIneDto); + } + return num; + } + + /** + * 方法抽取 + * @param machIneDto + * @return + */ + private int getAnInt(MachIneDto machIneDto) { + int num; + //插入ma_type_put_in_storage_info表,返回主键id + num = inventoryAndWarehousingMapper.saveInfo(machIneDto); + if (num == 0) { + 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; } @@ -148,7 +165,6 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi /** * 方法抽取,追加ma_type表里面的num - * * @param typeId * @param num * @return @@ -163,26 +179,16 @@ public class InventoryAndWarehousingServiceImpl implements InventoryAndWarehousi * @param dto * @return */ - private int insertPutInfo(SavePutInfoDto dto, List codeList) { + private int insertPutInfo(SavePutInfoDto dto) { int num = 0; for (int i = 0; i < dto.getMachIneDtoList().size(); i++) { MachIneDto machIneDto = dto.getMachIneDtoList().get(i); - String code = codeList.get(i); - machIneDto.setCode(code); - machIneDto.setTypeId(dto.getTypeId()); machIneDto.setCreator(dto.getCreator()); - machIneDto.setRemarks(dto.getRemarks()); machIneDto.setPutInType(dto.getPutInType()); - //ma_type_put_in_storage_details表,返回主键id - num = inventoryAndWarehousingMapper.saveDetails(machIneDto); - if (num == 0) { - throw new RuntimeException("新增到ma_type_put_in_storage_details表失败"); - } - //插入ma_type_put_in_storage_info表 - num = inventoryAndWarehousingMapper.saveInfo(machIneDto); - if (num == 0) { - throw new RuntimeException("新增到ma_type_put_in_storage_info表失败"); - } + machIneDto.setRemarks(dto.getRemarks()); + getAnInt(machIneDto); + //根据类型追加ma_type表里面的num + num = updateMaTypeInfo(machIneDto.getTypeId(), machIneDto.getPutInStoreNum()); } return num; } 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 3097e42e..d6177f87 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 @@ -1,11 +1,17 @@ + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> INSERT INTO ma_type_put_in_storage_details (NUM, + + INFO, + + + TYPE, + MACHINE, @@ -19,6 +25,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ) VALUES (1, + + #{id}, + + + #{typeId}, + #{maId}, @@ -31,24 +43,58 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ) - + INSERT INTO ma_type_put_in_storage_info - ID, PUT_IN_TYPE, - NUM, + + + NUM, + + + + NUM, + + + CREATOR, CREATE_DATE, - REMARKS + + + REMARKS + + + + REMARKS + + + VALUES - #{id}, #{putInType}, - 1, + + + #{num}, + + + + #{putInStoreNum}, + + + #{creator}, sysdate(), - #{remarks} + + + #{remarks} + + + + #{remark} + + + @@ -59,6 +105,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" qr_code, buy_price, ma_vender, + check_man, out_fac_code, this_check_time, next_check_time, @@ -70,6 +117,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{code}, #{buyPrice}, #{maVender}, + #{checkMan}, #{outFacCode}, #{thisCheckTime}, #{nextCheckTime}, @@ -116,35 +164,40 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" UPDATE ma_type - SET num = num + #{num} + SET num = num + #{num}, + update_time = now() - and type_id = #{typeId} + and type_id = #{typeId} - select count(*) from ma_machine - and qr_code = #{code} + and qr_code = #{code} + + + \ No newline at end of file