diff --git a/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/TreeNode.java b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/TreeNode.java index 6f6e0170..1bf8218a 100644 --- a/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/TreeNode.java +++ b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/TreeNode.java @@ -40,8 +40,13 @@ public class TreeNode { @ApiModelProperty(value = "实时库存") private Long storageNum; + private Long num; + private String remark; + @ApiModelProperty(value = "类型") + private String manageType; + @JsonInclude(JsonInclude.Include.NON_EMPTY) private List children = new ArrayList<>(); } diff --git a/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/lease/LeaseApplyInfo.java b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/lease/LeaseApplyInfo.java index 56bb4bd2..77991d14 100644 --- a/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/lease/LeaseApplyInfo.java +++ b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/lease/LeaseApplyInfo.java @@ -347,5 +347,9 @@ public class LeaseApplyInfo extends BaseEntity{ */ private List projectIdList; + private Long parentId; + @ApiModelProperty(value = "创建时间") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private String leaseTime; } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/controller/SelectController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/controller/SelectController.java index 45f6de00..ada88817 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/controller/SelectController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/controller/SelectController.java @@ -151,6 +151,13 @@ public class SelectController { return service.getDeviceTypeTree(dto); } + @ApiOperation(value = "设备类型树") + @PostMapping("getDeviceTypeTreeTwo") + public AjaxResult getDeviceTypeTreeTwo(@RequestBody SelectDto dto){ + return service.getDeviceTypeTreeTwo(dto); + } + + @ApiOperation(value = "退料设备类型树") @PostMapping("getBackDeviceTypeTree") public AjaxResult getBackDeviceTypeTree(@RequestBody SelectDto dto){ diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/mapper/SelectMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/mapper/SelectMapper.java index 852ffde7..748d9e8c 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/mapper/SelectMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/mapper/SelectMapper.java @@ -299,4 +299,6 @@ public interface SelectMapper { * @return */ List getBzUseTypeTreeL4(BackApplyInfo bean); + + List getDeviceTypeTreeTwo(SelectDto dto); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/service/SelectService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/service/SelectService.java index 0153ca24..acd8f3ed 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/service/SelectService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/service/SelectService.java @@ -103,6 +103,8 @@ public interface SelectService { */ AjaxResult getDeviceTypeTree(SelectDto dto); + AjaxResult getDeviceTypeTreeTwo(SelectDto dto); + AjaxResult getBackDeviceTypeTree(SelectDto dto); /** diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/service/impl/SelectServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/service/impl/SelectServiceImpl.java index 53486a8a..f69f555f 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/service/impl/SelectServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/service/impl/SelectServiceImpl.java @@ -433,6 +433,24 @@ public class SelectServiceImpl implements SelectService { return AjaxResult.success(groupList); } + @Override + public AjaxResult getDeviceTypeTreeTwo(SelectDto dto) { + List groupList = new ArrayList<>(); + List list = new ArrayList<>(); + try { + list = mapper.getDeviceTypeTreeTwo(dto); + if (CollectionUtils.isNotEmpty(list)) { + // 创建树形结构(数据集合作为参数) + TreeBuild treeBuild = new TreeBuild(list); + // 原查询结果转换树形结构 + groupList = treeBuild.buildTree(); + } + } catch (Exception e) { + log.error("单位树/归属部门/所属上级-查询失败", e); + } + return AjaxResult.success(groupList); + } + @Override public AjaxResult getBackDeviceTypeTree(SelectDto dto) { List groupList = new ArrayList<>(); diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/WarehousingController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/WarehousingController.java new file mode 100644 index 00000000..2a614664 --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/WarehousingController.java @@ -0,0 +1,79 @@ +package com.bonus.material.ma.controller; + +import com.bonus.common.core.web.controller.BaseController; +import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.common.core.web.page.TableDataInfo; +import com.bonus.material.common.annotation.PreventRepeatSubmit; +import com.bonus.material.ma.domain.PutInStorageBean; +import com.bonus.material.ma.domain.SavePutInfoDto; +import com.bonus.material.ma.domain.SupplierInfo; +import com.bonus.material.ma.service.WarehousingService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.java.Log; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** +* @description 入库盘点 +*/ +@Api(tags = " 入库盘点") +@RestController +@RequestMapping("/warehousing") +@Slf4j +public class WarehousingController extends BaseController { + @Autowired + private WarehousingService warehousingService; + + /** + * 查询入库盘点列表 + */ + @ApiOperation(value = "获取入库盘点列表") + @GetMapping("/getList") + public TableDataInfo getList(PutInStorageBean bean) { + startPage(); + List list = warehousingService.getList(bean); + return getDataTable(list); + } + + /** + * 查询供应商管理列表 + */ + @ApiOperation(value = "查询供应商管理列表") + @GetMapping("/supplierInfoList") + public TableDataInfo supplierInfoList(SupplierInfo maSupplierInfo) + { + List list = warehousingService.selectMaSupplierInfoList(maSupplierInfo); + return getDataTable(list); + } + + /** + * 新增入库盘点 + * @param dto + * @return + */ + @ApiOperation(value = "新增入库盘点") + @PreventRepeatSubmit + @PostMapping("/addList") + public AjaxResult savePutInfo(@RequestBody SavePutInfoDto dto) { + return warehousingService.savePutInfo(dto); + } + + + /** + * 根据入库单号查看详情 + * @param bean + * @return + */ + @ApiOperation(value = "根据入库单号查看详情") + @GetMapping("/getDetail") + public TableDataInfo getDetail(PutInStorageBean bean) { + startPage(); + List list = warehousingService.getDetails(bean); + return getDataTable(list); + } + +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/MachIneDto.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/MachIneDto.java new file mode 100644 index 00000000..27a82ccd --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/MachIneDto.java @@ -0,0 +1,158 @@ +package com.bonus.material.ma.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.springframework.format.annotation.DateTimeFormat; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 表单类型表单集合 + * @Author ma_sh + * @create 2024/3/28 17:53 + */ +@Data +@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 + */ + @ApiModelProperty(value = "主键id") + private Integer infoId; + + /** 设备编号 */ + @ApiModelProperty(value = "设备编号") + private String maCode; + + /** 二维码 */ + @ApiModelProperty(value = "二维码") + private String qrCode; + + + /** + * 类型id + */ + @ApiModelProperty(value = "类型id") + private String typeId; + + /** + * 主信息 + */ + @ApiModelProperty(value = "主信息") + private Integer info; + + /** 出厂编码 */ + @ApiModelProperty(value = "出厂编码") + private String outFacCode; + + /** 生产厂家 */ + @ApiModelProperty(value = "生产厂家") + private String maVender; + + /** 本次检修日期 */ + @ApiModelProperty(value = "本次检修日期") + @DateTimeFormat(pattern = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date thisCheckTime; + + /** 下次检修日期 */ + @ApiModelProperty(value = "下次检修日期") + @DateTimeFormat(pattern = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date nextCheckTime; + + /** 单价 */ + @ApiModelProperty(value = "单价") + private BigDecimal buyPrice; + + /** 编码 */ + @ApiModelProperty(value = "编码") + private String code; + + /** + * 创建者 + */ + @ApiModelProperty(value = "创建者") + private Long creator; + + /** + * 入库形式 + */ + @ApiModelProperty(value = "入库形式") + private String putInType; + + /** + * 备注 + */ + @ApiModelProperty(value = "备注") + private String remarks; + + /** + * 单位名称 + */ + @ApiModelProperty(value = "单位名称") + private String unitId; + + /** + * 工程名称 + */ + @ApiModelProperty(value = "工程名称") + private String proId; + + /** + * 表单备注 + */ + @ApiModelProperty(value = "表单备注") + private String remark; + + /** + * 数量 + */ + @ApiModelProperty(value = "上方页面入库数量") + private Integer num; + + /** + * 数量 + */ + @ApiModelProperty(value = "数量") + private Integer totalNum; + + /** + * 检验人 + */ + @ApiModelProperty(value = "检验人") + private String checkMan; + + /** + * 入库数量 + */ + @ApiModelProperty(value = "表单集合入库数量") + private Integer putInStoreNum; + +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/Machine.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/Machine.java index 26f37947..88ca091d 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/Machine.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/Machine.java @@ -329,4 +329,6 @@ public class Machine extends BaseEntity { private int devType; private String type; + + private Integer manageType; } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/PutInStorageBean.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/PutInStorageBean.java new file mode 100644 index 00000000..ef15dd91 --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/PutInStorageBean.java @@ -0,0 +1,101 @@ +package com.bonus.material.ma.domain; + +import com.bonus.common.core.web.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** +* @description 入库盘点 +*/ +@Data +public class PutInStorageBean extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** id */ + @ApiModelProperty(value = "id") + private Integer id; + + /** 入库形式 */ + @ApiModelProperty(value = "入库形式") + private String putInType; + + /** 关键字 */ + @ApiModelProperty(value = "关键字") + private String keyWord; + + /** 入库数量 */ + @ApiModelProperty(value = "入库数量") + private BigDecimal num; + + /** 创建者 */ + @ApiModelProperty(value = "创建者") + private Integer creator; + + /** 入库人 */ + @ApiModelProperty(value = "入库人") + private String modelName; + + /** 盘点入库单号 */ + @ApiModelProperty(value = "盘点入库单号") + private String kindName; + + /** 设备编号 */ + @ApiModelProperty(value = "设备编号") + private String maCode; + + /** 单位ID */ + @ApiModelProperty(value = "单位ID") + private String unitId; + + /** 单位名称 */ + @ApiModelProperty(value = "单位名称") + private String unitName; + + /** 工程ID */ + @ApiModelProperty(value = "工程ID") + private String projectId; + + /** 工程名称 */ + @ApiModelProperty(value = "工程名称") + private String projectName; + + /** 创建日期 */ + @ApiModelProperty(value = "创建日期") + private String createDate; + + /** 备注 */ + @ApiModelProperty(value = "备注") + private String remark; + + + /** 主信息 */ + @ApiModelProperty(value = "主信息") + private Integer info; + + /** 库房 */ + @ApiModelProperty(value = "库房") + private Integer ram; + + /** 设备工器具类型 */ + @ApiModelProperty(value = "设备工器具类型") + private Integer type; + + /** 设备工器具类型名称 */ + @ApiModelProperty(value = "设备工器具类型名称") + private String typeName; + + /** 规格型号 */ + @ApiModelProperty(value = "规格型号") + private String typeModelName; + + /** 设备主键 */ + @ApiModelProperty(value = "设备主键") + private Integer machine; + + + private String code; + + private Integer infoId; +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/SavePutInfoDto.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/SavePutInfoDto.java new file mode 100644 index 00000000..d5e59844 --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/SavePutInfoDto.java @@ -0,0 +1,124 @@ +package com.bonus.material.ma.domain; + +import com.bonus.common.core.web.domain.BaseEntity; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 新增盘点入库接口实体类dto + * @Author ma_sh + * @create 2024/3/28 14:22 + */ +@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 Integer 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 proId; + + /** + * 创建者 + */ + @ApiModelProperty(value = "创建者") + private Long creator; + + /** + * 创建时间 + */ + @ApiModelProperty(value = "创建时间") + private String createDate; + + /** + * 备注 + */ + @ApiModelProperty(value = "备注") + private String remarks; + + /** + * 检验人 + */ + @ApiModelProperty(value = "检验人") + private String checkMan; + + /** + * 表单类型表单集合 + */ + private List machIneDtoList; + +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/vo/ExceptionEnum.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/vo/ExceptionEnum.java new file mode 100644 index 00000000..fa67acd6 --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/vo/ExceptionEnum.java @@ -0,0 +1,39 @@ +package com.bonus.material.ma.domain.vo; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * 返回异常枚举类 + * @Author ma_sh + * @create 2024/3/29 14:43 + */ +@Getter +@AllArgsConstructor +public enum ExceptionEnum { + + PARAM_NULL(1001, "参数为空"), + IOT_CODE_DUPLICATE(1002, "设备编号重复"), + IOT_TO_DELETE(1003, "该iot设备绑定相关类型设备,无法删除"), + SUCCESS(200, "操作成功"), + SAVE_TO_DATABASE(500, "新增保存失败,请联系管理员!!!"), + DELETE_TO_DATABASE(500, "删除失败,请联系管理员!!!"), + BIND_TO_DATABASE(500, "绑定失败,请联系管理员!!!"), + UN_BIND_TO_DATABASE(500, "解绑失败,请联系管理员!!!"), + UPDATE_TO_DATABASE(500, "修改失败,请联系管理员!!!"), + + RETURN_DATA_IS_EMPTY(501, "返回数据为空!!"), + IOT_ENCODING_ERROR(502, "输入的IOT编码有误,请输入正确的编码!!!"); + + private Integer code; + + private String msg; + + public Integer getCode() { + return code; + } + + public String getMsg() { + return msg; + } +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/vo/FieldGenerator.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/vo/FieldGenerator.java new file mode 100644 index 00000000..9d7958aa --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/vo/FieldGenerator.java @@ -0,0 +1,23 @@ +package com.bonus.material.ma.domain.vo; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.UUID; + +/** + * 后端生产随机编码通用方法(格式:今日年月日日期-随机4位编码 20240328-0001) + * @Author ma_sh + * @create 2024/3/28 17:42 + */ +public class FieldGenerator { + + public static String generateField() { + LocalDate today = LocalDate.now(); + String currentDate = today.format(DateTimeFormatter.ofPattern("yyyyMMdd")); + // 生成UUID并取后4位,转换为纯数字类型 + String uuid = UUID.randomUUID().toString().replaceAll("-", ""); + String uuidLast4Digits = uuid.substring(uuid.length() - 7); + int uuidLast4DigitsNumeric = Integer.parseInt(uuidLast4Digits, 16); + return currentDate + "-" + String.format("%07d", uuidLast4DigitsNumeric % 10000); + } +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/vo/GlobalContants.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/vo/GlobalContants.java new file mode 100644 index 00000000..d9040ae8 --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/vo/GlobalContants.java @@ -0,0 +1,15 @@ +package com.bonus.material.ma.domain.vo; + +/** + * @Author:梁超 + * @date:2024/1/30 - 14:09 + */ +public class GlobalContants { + public static final int NUM1 = 9; + public static final int NUM2 = 100; + public static final int NUM3 = 99; + public static final int NUM4 = 1000; + + public static final int NUM5 = 68; + public static final int NUM6 = 24; +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/MachineMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/MachineMapper.java index 318cc80e..ff358075 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/MachineMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/MachineMapper.java @@ -204,4 +204,12 @@ public interface MachineMapper List getElectronicLabelByWsMaInfo(Machine machine); List getHisByCodeNewByWsMaInfo(Machine machine); + + LeaseApplyInfo getLeaseParentId(Machine machine); + + LeaseApplyInfo getLeaseUnitAndProject(LeaseApplyInfo leaseInfo); + + LeaseApplyInfo getBackParentId(Machine machine); + + LeaseApplyInfo getBackUnitAndProject(LeaseApplyInfo leaseInfoBack); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/WarehousingMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/WarehousingMapper.java new file mode 100644 index 00000000..4f7c0bc0 --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/WarehousingMapper.java @@ -0,0 +1,71 @@ +package com.bonus.material.ma.mapper; + + +import com.bonus.material.ma.domain.MachIneDto; +import com.bonus.material.ma.domain.PutInStorageBean; +import com.bonus.material.ma.domain.SupplierInfo; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.Date; +import java.util.List; + +/** +* @description 入库盘点 +* @author hay +* @date 2024/3/27 13:33 +*/ +@Mapper +public interface WarehousingMapper { + + /** + * 查询入库盘点列表 + * @param bean + * @return 结果 + */ + List getList(PutInStorageBean bean); + + + List selectMaSupplierInfoList(SupplierInfo maSupplierInfo); + + + int selectByMaCode(String maCode); + + /** + * 插入ma_type_put_in_storage_info表 + * @param machIneDto + * @return + */ + int saveInfo(MachIneDto machIneDto); + + /** + * 新增ma_machine表 + * @param machIneDto + * @return + */ + int insertMachine(MachIneDto machIneDto); + + /** + * 新增ma_type_put_in_storage_details表 + * @param machIneDto + * @return + */ + Integer saveDetails(MachIneDto machIneDto); + + /** + * 查询 + * @param nowDate + * @return + */ + int selectTaskNumByMonth(@Param("date") Date nowDate); + + /** + * 更新matype表中num数量 + * @param typeId + * @param num + * @return + */ + int updateMaType(@Param("typeId") String typeId, @Param("num") Integer num); + + List getDetails(PutInStorageBean bean); +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/WarehousingService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/WarehousingService.java new file mode 100644 index 00000000..f3585a00 --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/WarehousingService.java @@ -0,0 +1,43 @@ +package com.bonus.material.ma.service; + + + + +import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.material.ma.domain.PutInStorageBean; +import com.bonus.material.ma.domain.SavePutInfoDto; +import com.bonus.material.ma.domain.SupplierInfo; + +import java.util.List; + +/** +* @description 入库盘点 +* @author hay +* @date 2024/3/27 13:31 +*/ +public interface WarehousingService { + + /** + * 查询入库盘点列表 + * @param bean + * @return 结果 + */ + List getList(PutInStorageBean bean); + + List selectMaSupplierInfoList(SupplierInfo maSupplierInfo); + + /** + * 新增入库盘点 + * @param dto + * @return + */ + AjaxResult savePutInfo(SavePutInfoDto dto); + + + /** + * 根据入库单号查看详情 + * @param bean + * @return + */ + List getDetails(PutInStorageBean bean); +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/MachineServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/MachineServiceImpl.java index 0f05747b..51c51c47 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/MachineServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/MachineServiceImpl.java @@ -338,8 +338,36 @@ public class MachineServiceImpl implements IMachineService Machine checkNum = machineMapper.getCheckNumByQrcode(machine); //报废时间 Machine scrapTime = machineMapper.getScrapTimeByQrcode(machine); - //3根据机具id查询领退工程 - Machine leaseInfo = machineMapper.getLeaseInfoByQrcode(machine); +// //3根据机具id查询领退工程 +// Machine leaseInfo = machineMapper.getLeaseInfoByQrcode(machine); + + // 根据maid查询领料任务 + LeaseApplyInfo leaseInfo = machineMapper.getLeaseParentId(machine); + if (leaseInfo.getParentId() == null){ + baseInfo.setLeaseTime(null); + baseInfo.setLeaseUnit(null); + baseInfo.setLeaseProject(null); + }else{ + LeaseApplyInfo leaseDetail = machineMapper.getLeaseUnitAndProject(leaseInfo); + baseInfo.setLeaseTime(String.valueOf(leaseDetail.getLeaseTime())); + baseInfo.setLeaseUnit(leaseDetail.getUnitName()); + baseInfo.setLeaseProject(leaseDetail.getProjectName()); + } + + // 根据maid查询退料任务 + LeaseApplyInfo leaseInfoBack = machineMapper.getBackParentId(machine); + if (leaseInfoBack.getParentId() == null){ + baseInfo.setBackTime(null); + baseInfo.setBackUnit(null); + baseInfo.setBackProject(null); + }else{ + LeaseApplyInfo leaseDetailBack = machineMapper.getBackUnitAndProject(leaseInfoBack); + baseInfo.setBackTime(String.valueOf(leaseDetailBack.getLeaseTime())); + baseInfo.setBackUnit(leaseDetailBack.getUnitName()); + baseInfo.setBackProject(leaseDetailBack.getProjectName()); + } + + if (inTime != null){ Integer taskId = inTime.getTaskId(); if(taskId != null){ @@ -368,14 +396,6 @@ public class MachineServiceImpl implements IMachineService baseInfo.setScrapTime("暂无"); } - if(leaseInfo != null){ - baseInfo.setLeaseTime(leaseInfo.getLeaseTime()); - baseInfo.setLeaseUnit(leaseInfo.getLeaseUnit()); - baseInfo.setLeaseProject(leaseInfo.getLeaseProject()); - baseInfo.setBackTime(leaseInfo.getBackTime()); - baseInfo.setBackUnit(leaseInfo.getBackUnit()); - baseInfo.setBackProject(leaseInfo.getBackProject()); - } return success(baseInfo); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/WarehousingServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/WarehousingServiceImpl.java new file mode 100644 index 00000000..4afde39d --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/WarehousingServiceImpl.java @@ -0,0 +1,284 @@ +package com.bonus.material.ma.service.impl; + + +import com.bonus.common.core.exception.ServiceException; +import com.bonus.common.core.utils.DateUtils; +import com.bonus.common.core.utils.StringUtils; +import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.common.security.utils.SecurityUtils; +import com.bonus.material.ma.domain.MachIneDto; +import com.bonus.material.ma.domain.PutInStorageBean; +import com.bonus.material.ma.domain.SavePutInfoDto; +import com.bonus.material.ma.domain.SupplierInfo; +import com.bonus.material.ma.domain.vo.ExceptionEnum; +import com.bonus.material.ma.domain.vo.FieldGenerator; +import com.bonus.material.ma.domain.vo.GlobalContants; +import com.bonus.material.ma.mapper.WarehousingMapper; +import com.bonus.material.ma.service.WarehousingService; +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; +import org.springframework.transaction.interceptor.TransactionAspectSupport; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author hay + * @description 入库盘点 + * @date 2024/3/27 13:32 + */ +@Service +@Slf4j +public class WarehousingServiceImpl implements WarehousingService { + + @Autowired + private WarehousingMapper warehousingMapper; + +// @Autowired +// private PurchaseInputMapper purchaseInputMapper; + + /** + * 查询入库盘点列表 + * @param bean + * @return + */ + @Override + public List getList(PutInStorageBean bean) { + return warehousingMapper.getList(bean); + } + + @Override + public List selectMaSupplierInfoList(SupplierInfo maSupplierInfo) + { + return warehousingMapper.selectMaSupplierInfoList(maSupplierInfo); + } + + /** + * 生成code编码 + * @return + */ + public String genderBackCode() { + log.info("enter method genderBackCode"); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); + Date nowDate = DateUtils.getNowDate(); + String format = dateFormat.format(nowDate); + int taskNum = warehousingMapper.selectTaskNumByMonth(nowDate) + 1; + String code = ""; + if (taskNum > GlobalContants.NUM1 && taskNum < GlobalContants.NUM2) { + code = "PD" + format + "-00" + taskNum; + } else if (taskNum > GlobalContants.NUM3 && taskNum < GlobalContants.NUM4) { + code = "PD" + format + "-0" + taskNum; + } else { + code = "PD" + format + "-000" + taskNum; + } + log.info("end method genderBackCode" + code); + return code; + } + + /** + * 新增入库盘点 + * @param dto + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + public AjaxResult savePutInfo(SavePutInfoDto dto) { + log.info("新增入库盘点入参dto:{}", dto); + Long userId = SecurityUtils.getLoginUser().getUserid(); + dto.setCreator(userId); + String code = genderBackCode(); + List machIneDtoList = dto.getMachIneDtoList(); + //判断提交表单中是否存在相同编码 + for (int i = 0; i < machIneDtoList.size() - 1; i++) { + for (int j = i + 1; j < machIneDtoList.size(); j++) { + if (StringUtils.isNotEmpty(machIneDtoList.get(i).getMaCode()) && StringUtils.isNotEmpty(machIneDtoList.get(j).getMaCode()) + && machIneDtoList.get(i).getMaCode().equals(machIneDtoList.get(j).getMaCode())) { + throw new ServiceException("列表中包含以下相同的设备编码,请修改后重新提交:" + machIneDtoList.get(i).getMaCode()); + } + } + } + //判断提交中设备编码是否与库中相同 + if (CollectionUtils.isNotEmpty(machIneDtoList)) { + for (MachIneDto machIneDto : machIneDtoList) { + if (StringUtils.isNotBlank(machIneDto.getMaCode())) { + int count = selectByMaCode(machIneDto.getMaCode()); + if (count != 0) { + throw new ServiceException("以下设备编码与库中数据存在重复,请修改后重新提交:" + machIneDto.getMaCode()); + } + } + } + } + int res; + try { + //1. 判断是数量还是编号入库,保存到不同表 + //1.1 如果是编号入库 + if (dto.getIsCode()) { + res = insertMaMachineInfo(dto, code); + if (res == 0) { + 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, code); + if (res == 0) { + log.error("insertPutInfo方法插入异常"); + throw new RuntimeException("insertPutInfo方法插入异常"); + } + } + + } catch (Exception e) { + log.error("保存入库盘点异常:{}",e.getMessage()); + // 添加事务回滚逻辑,保证入库全部成功或者全部失败 + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return AjaxResult.error(ExceptionEnum.SAVE_TO_DATABASE.getCode(), ExceptionEnum.SAVE_TO_DATABASE.getMsg()); + } + return AjaxResult.success(res); + } + + /** + * 根据设备编码code查重 + * @param maCode + * @return + */ + private int selectByMaCode(String maCode) { + return warehousingMapper.selectByMaCode(maCode); + } + + /** + * 编号新增,插入ma_machine、ma_machine_label和ma_label_bind + * @param dto + * @param code + * @return + */ + 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()); + machIneDto.setTypeId(dto.getTypeId()); + machIneDto.setUnitId(dto.getUnitId()); + machIneDto.setProId(dto.getProId()); + machIneDto.setRemarks(dto.getRemarks()); + 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); + machIneDto.setIsCode(dto.getIsCode()); + machIneDto.setTypeId(dto.getTypeId()); + machIneDto.setCreator(dto.getCreator()); + machIneDto.setPutInType(dto.getPutInType()); + machIneDto.setNum(dto.getNum()); + machIneDto.setCheckMan(dto.getCheckMan()); + machIneDto.setInfoId(dto.getMachIneDtoList().get(0).getInfoId()); + res += insertMachineInfo(machIneDto); + } + return res; + } + + /** + * 插入ma_type_put_in_storage_info表,返回主键id + * @param machIneDto + * @return + */ + private int insertInfo(MachIneDto machIneDto) { + return warehousingMapper.saveInfo(machIneDto); + } + + /** + * 方法抽取,保持到ma_machine、ma_machine_label和ma_label_bind + * @param machIneDto + * @return + */ + private int insertMachineInfo(MachIneDto machIneDto) { + int res = warehousingMapper.insertMachine(machIneDto); + + res += insertTypePutInStorageInfo(machIneDto); + return res; + } + + /** + * 方法抽取 + * @param machIneDto + * @return + */ + private int insertTypePutInStorageInfo(MachIneDto machIneDto) { + //ma_type_put_in_storage_details表 + return warehousingMapper.saveDetails(machIneDto); + } + + /** + * 方法抽取,追加ma_type表里面的num + * @param typeId + * @param num + * @return + */ + private int updateMaTypeInfo(String typeId, Integer num) { + return warehousingMapper.updateMaType(typeId, num); + } + + /** + * 插入表方法 + * @param dto + * @return + */ + private int insertPutInfo(SavePutInfoDto dto, String code) { + int res = 0; + Integer total = dto.getMachIneDtoList().stream() + .map(MachIneDto::getPutInStoreNum) + .filter(num -> num != null) + .collect(Collectors.summingInt(Integer::intValue)); + 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); + machIneDto.setRemarks(dto.getRemarks()); + 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()); + machIneDto.setPutInType(dto.getPutInType()); + machIneDto.setRemarks(dto.getRemarks()); + machIneDto.setCode(code); + machIneDto.setInfoId(dto.getMachIneDtoList().get(0).getInfoId()); + res += insertTypePutInStorageInfo(machIneDto); + //根据类型追加ma_type表里面的num + res += updateMaTypeInfo(machIneDto.getTypeId(), machIneDto.getPutInStoreNum()); + } + return res; + } + + + /** + * 根据入库单号查看详情 + * @param bean + * @return + */ + @Override + public List getDetails(PutInStorageBean bean) { + return warehousingMapper.getDetails(bean); + } +} diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/common/SelectMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/common/SelectMapper.xml index bdbd6c88..324d33fa 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/common/SelectMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/common/SelectMapper.xml @@ -903,4 +903,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" GROUP BY mt.type_id + diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/MachineMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/MachineMapper.xml index 20ac6078..f6680048 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/MachineMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/MachineMapper.xml @@ -807,6 +807,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" mm.check_man as checkMan, mm.this_check_time as thisCheckTime, mm.next_check_time as nextCheckTime, + mt.manage_type as manageType, mm.in_out_num as inOutNum, mt.jiju_type as jiJuType, mt.is_check as isCheck, @@ -838,6 +839,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" wmi.check_man as checkMan, wmi.this_check_time as thisCheckTime, wmi.next_check_time as nextCheckTime, + 1 as manageType, '' as inOutNum, '1' as jiJuType, '' as isCheck, @@ -900,4 +902,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and wmi.id = #{maId} LIMIT 100 + + + + diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/WarehousingMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/WarehousingMapper.xml new file mode 100644 index 00000000..a7451a2d --- /dev/null +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/WarehousingMapper.xml @@ -0,0 +1,221 @@ + + + + + + + + + + + INSERT INTO ma_type_put_in_storage_info + + put_in_type, + + + num, + + + + num, + + + + type_id, + creator, + code, + remarks, + create_time + + VALUES + + #{putInType}, + + + #{num}, + + + + #{totalNum}, + + + + #{typeId}, + #{creator}, + #{code}, + #{remarks}, + sysdate() + + + + + INSERT INTO ma_type_put_in_storage_details ( + + + + num, + + + + num, + + + + + info_id, + + + type_id, + + + ma_id, + + + remarks, + + + ma_code, + + + ) + VALUES ( + + + 1, + + + + #{putInStoreNum}, + + + + + + #{infoId}, + + + #{typeId}, + + + #{maId}, + + + #{remark}, + + + #{maCode}, + + + ) + + + + insert into ma_machine ( + type_id, + ma_code, + ma_status, + buy_price, + ma_vender, + check_man, + out_fac_code, + this_check_time, + next_check_time, + create_time + )values( + #{typeId}, + #{maCode}, + 1, + #{buyPrice}, + #{maVender}, + #{checkMan}, + #{outFacCode}, + #{thisCheckTime}, + #{nextCheckTime}, + sysdate() + ) + + + + UPDATE ma_type + SET storage_num = IFNULL(storage_num, 0) + #{num}, + update_time = now() + + and type_id = #{typeId} + + + + + \ No newline at end of file