From 8aa35d3ccfbb28895ff8fcda1631cefb266c0599 Mon Sep 17 00:00:00 2001 From: "liang.chao" <1360241448@qq.com> Date: Tue, 25 Jun 2024 17:46:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E9=97=AE=E9=A2=98=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/MaWholeSetController.java | 22 ++-- .../bonus/sgzb/material/domain/MaWhole.java | 16 ++- .../sgzb/material/domain/MaWholeSetDto.java | 15 ++- .../bonus/sgzb/material/domain/MaWholeVo.java | 27 ++++- .../material/mapper/MaWholeSetMapper.java | 8 +- .../material/service/MaWholeSetService.java | 2 +- .../service/impl/MaWholeSetServiceImpl.java | 114 ++++++++++-------- .../mapper/material/MaWholeSetMapper.xml | 66 ++++------ 8 files changed, 158 insertions(+), 112 deletions(-) diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/MaWholeSetController.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/MaWholeSetController.java index 963f7c73..067f7035 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/MaWholeSetController.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/MaWholeSetController.java @@ -8,6 +8,8 @@ import com.bonus.sgzb.material.domain.MaWholeSetDto; import com.bonus.sgzb.material.domain.MaWholeTreeVo; import com.bonus.sgzb.material.domain.MaWholeVo; import com.bonus.sgzb.material.service.MaWholeSetService; +import com.bonus.sgzb.material.vo.ScrapApplyDetailsVO; +import com.github.pagehelper.PageHelper; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import lombok.extern.slf4j.Slf4j; @@ -35,8 +37,7 @@ public class MaWholeSetController extends BaseController { */ @ApiOperation("新增整套抱杆管理") @PostMapping("/addOrUpdate") - public AjaxResult addOrUpdate(@ApiParam(value = "添加信息", required = true) - @RequestBody MaWholeSetDto dto) { + public AjaxResult addOrUpdate(@ApiParam(value = "添加信息", required = true) @RequestBody MaWholeSetDto dto) { if (dto.getId() != null) { log.info("修改整套抱杆管理:{}", dto); return maWholeSetService.update(dto); @@ -51,11 +52,11 @@ public class MaWholeSetController extends BaseController { * @return */ @ApiOperation("查询整套抱杆管理") - @PostMapping("/selectList") - public AjaxResult selectList(@ApiParam(value = "查询信息") @RequestBody MaWholeSetDto dto) { - log.info("查询整套抱杆管理:{}", dto); - PageResultVo result = maWholeSetService.selectList(dto); - return AjaxResult.success(result); + @GetMapping("/selectList") + public TableDataInfo selectList(MaWholeSetDto dto) { + PageHelper.startPage(dto.getPageNum() == 0 ? 1 : dto.getPageNum(), dto.getPageSize()); + List maWholeVos = maWholeSetService.selectList(dto); + return getDataTable(maWholeVos); } /** @@ -64,12 +65,11 @@ public class MaWholeSetController extends BaseController { * @return */ @ApiOperation("查询整套抱杆明细") - @PostMapping("/selectListById") - public TableDataInfo selectListById(@ApiParam(value = "查询信息") @RequestBody MaWholeSetDto dto) { - log.info("查询整套抱杆明细:{}", dto); + @GetMapping("/selectListById") + public AjaxResult selectListById(MaWholeSetDto dto) { startPage(); List list = maWholeSetService.selectListById(dto); - return getDataTable(list); + return AjaxResult.success(getDataTable(list)); } /** diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MaWhole.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MaWhole.java index 27397add..1bcd1de0 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MaWhole.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MaWhole.java @@ -24,16 +24,30 @@ public class MaWhole { private Integer id; /** 父级ID */ - @ApiModelProperty(value = "父级ID") + @ApiModelProperty(value = "父级类型ID") private Integer parentId; + /** 父级ID */ + @ApiModelProperty(value = "类型ID") + private Integer typeId; + @ApiModelProperty(value = "数量") + private Integer deviceNum; /** 配套数量 */ @ApiModelProperty(value = "配套数量") private Integer totalNum; + /** 设备id */ + @ApiModelProperty(value = "设备id") + private Integer deviceTypeId; + /** 设备类型 */ + @ApiModelProperty(value = "设备类型(1主体设备 2配套设备)") + private Integer ascriptionType; /** 配套名称 */ @ApiModelProperty(value = "配套名称") private String wholeTypeName; + /** 配套名称 */ + @ApiModelProperty(value = "所属公司") + private String companyId; /** 创建时间 */ @ApiModelProperty(value = "创建时间") diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MaWholeSetDto.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MaWholeSetDto.java index 495b0106..ecb64f1c 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MaWholeSetDto.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MaWholeSetDto.java @@ -36,9 +36,22 @@ public class MaWholeSetDto { /** 关键字 */ @ApiModelProperty(value = "关键字") private String keyWord; + /** 配套名称 */ + @ApiModelProperty(value = "配套名称") + private String wholeTypeName; + /** 关键字 */ + @ApiModelProperty(value = "所属公司") + private String companyId; + /** 关键字 */ + @ApiModelProperty(value = "创建人") + private Integer createBy; + @ApiModelProperty(value = "开始时间") + private String startTime; + @ApiModelProperty(value = "结束时间") + private String endTime; /** 表单对象集合 */ @ApiModelProperty(value = "表单对象集合") - private List wholeList; + private List deviceInfo; } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MaWholeVo.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MaWholeVo.java index 260c4ba5..c61a2829 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MaWholeVo.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MaWholeVo.java @@ -1,10 +1,13 @@ package com.bonus.sgzb.material.domain; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import java.util.Date; + /** * 整套抱杆最外层表单vo * @Author ma_sh @@ -18,10 +21,25 @@ public class MaWholeVo { /** 主键ID */ @ApiModelProperty(value = "主键ID") private Integer id; + /** 主键ID */ + @ApiModelProperty(value = "设备类型(1:主体设备 2:配套设备)") + private Integer ascriptionType; + /** 设备id */ + @ApiModelProperty(value = "设备id") + private Integer deviceTypeId; + /** 设备id */ + @ApiModelProperty(value = "设备数量") + private Integer deviceNum; /** 机具名称 */ @ApiModelProperty(value = "机具名称") private String typeName; + /** 机具名称 */ + @ApiModelProperty(value = "配套设备类型") + private String deviceAscription; + /** 机具名称 */ + @ApiModelProperty(value = "机具名称") + private String deviceType; /** 规格型号 */ @ApiModelProperty(value = "规格型号") @@ -30,8 +48,15 @@ public class MaWholeVo { /** 配套名称 */ @ApiModelProperty(value = "配套名称") private String wholeTypeName; + /** 创建人 */ + @ApiModelProperty(value = "创建人") + private String nickName; + /** 创建日期 */ + @ApiModelProperty(value = "创建日期") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; /** 套装所需配件数量 */ - @ApiModelProperty(value = "套装所需配件数量") + @ApiModelProperty(value = "套装所需配件种类数量") private Integer totalNum; } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/MaWholeSetMapper.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/MaWholeSetMapper.java index ff532d9b..9bda1734 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/MaWholeSetMapper.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/MaWholeSetMapper.java @@ -25,10 +25,10 @@ public interface MaWholeSetMapper { /** * 根据parentId查询,去重 - * @param parentId + * @param wholeTypeName * @return */ - int selectByParentId(@Param("parentId") Integer parentId); + int selectByParentId(String wholeTypeName); /** * 查询整套抱杆管理 @@ -46,10 +46,10 @@ public interface MaWholeSetMapper { /** * 根据id删除 - * @param id + * @param * @return */ - int deleteById(@Param("id") Integer id); + int deleteById(MaWholeSetDto dto); /** * 根据id去ma_whole_set表中查询typeid diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/MaWholeSetService.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/MaWholeSetService.java index e511c21d..390eb7bc 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/MaWholeSetService.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/MaWholeSetService.java @@ -27,7 +27,7 @@ public interface MaWholeSetService { * @param dto * @return */ - PageResultVo selectList(MaWholeSetDto dto); + List selectList(MaWholeSetDto dto); /** * 查询整套抱杆明细 diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/MaWholeSetServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/MaWholeSetServiceImpl.java index af24e77f..641db2be 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/MaWholeSetServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/MaWholeSetServiceImpl.java @@ -18,6 +18,7 @@ import java.util.List; /** * 整套抱杆操作实现层 + * * @Author ma_sh * @create 2024/4/15 17:17 */ @@ -30,6 +31,7 @@ public class MaWholeSetServiceImpl implements MaWholeSetService { /** * 新增整套抱杆管理 + * * @param dto * @return */ @@ -39,54 +41,51 @@ public class MaWholeSetServiceImpl implements MaWholeSetService { if (dto == null) { return AjaxResult.error("参数不能为空!!!"); } - if (dto.getParentId() == null) { - return AjaxResult.error("父级id不能为空"); + + if (selectByParentId(dto.getWholeTypeName()) > 0) { + return AjaxResult.error("成套名称已存在"); } - int count = selectByParentId(dto.getParentId()); - if (count != 0) { - return AjaxResult.error("该物品类型已经绑定相关配件,无法再次绑定,请重新选择!!!"); - } - if (CollectionUtils.isNotEmpty(dto.getWholeList())) { - for (MaWhole maWhole : dto.getWholeList()) { + + if (CollectionUtils.isNotEmpty(dto.getDeviceInfo())) { + for (MaWhole maWhole : dto.getDeviceInfo()) { + maWhole.setCreateBy(dto.getCreateBy()); + maWhole.setCompanyId(dto.getCompanyId()); + maWhole.setTypeId(maWhole.getDeviceTypeId()); + maWhole.setTotalNum(maWhole.getDeviceNum()); + maWhole.setWholeTypeName(dto.getWholeTypeName()); maWhole.setParentId(dto.getParentId()); } - } - int res = 0; - try { - res = insertMaWholeSet(dto.getWholeList()); - if (res == 0) { - log.error("insertMaWholeSet方法插入异常"); - throw new RuntimeException("insertMaWholeSet方法插入异常"); + int res = 0; + try { + res = insertMaWholeSet(dto.getDeviceInfo()); + if (res == 0) { + log.error("insertMaWholeSet方法插入异常"); + throw new RuntimeException("insertMaWholeSet方法插入异常"); + } + } catch (Exception e) { + log.error("新增计划管理异常:{}", e.getMessage()); + return AjaxResult.error(ExceptionEnum.SAVE_TO_DATABASE.getCode(), ExceptionEnum.SAVE_TO_DATABASE.getMsg()); } - } catch (Exception e) { - log.error("新增计划管理异常:{}",e.getMessage()); - return AjaxResult.error(ExceptionEnum.SAVE_TO_DATABASE.getCode(), ExceptionEnum.SAVE_TO_DATABASE.getMsg()); + return AjaxResult.success("新增成功", res); + } else { + return AjaxResult.error("请选择主/配套设备"); } - return AjaxResult.success("新增成功", res); } /** * 查询整套抱杆管理 + * * @param dto * @return */ @Override - public PageResultVo selectList(MaWholeSetDto dto) { - List list = mapper.selectList(dto); - PageHelper.startPage(dto.getPageNum() == 0 ? 1 : dto.getPageNum(), dto.getPageSize()); - PageResultVo pageResult = new PageResultVo(); - // 分页信息 - PageInfo pageInfo = new PageInfo<>(list); - pageResult.setTotalCount(pageInfo.getTotal()); - pageResult.setTotalPageCount(pageInfo.getPages()); - pageResult.setResult(list); - pageResult.setPageNum(dto.getPageNum()); - pageResult.setPageSize(dto.getPageSize()); - return pageResult; + public List selectList(MaWholeSetDto dto) { + return mapper.selectList(dto); } /** * 查询整套抱杆明细 + * * @param dto * @return */ @@ -97,23 +96,24 @@ public class MaWholeSetServiceImpl implements MaWholeSetService { /** * 根据id删除 + * * @param dto * @return */ @Override @Transactional(rollbackFor = Exception.class) public AjaxResult deleteById(MaWholeSetDto dto) { - if (dto.getId() == null) { + if (dto == null) { return AjaxResult.error("删除标识id为空,无法进行删除"); } int res = 0; try { - res = deleteMaWhole(dto.getId()); + res = deleteMaWhole(dto); if (res == 0) { throw new RuntimeException("删除失败"); } } catch (Exception e) { - log.error("删除异常:{}",e.getMessage()); + log.error("删除异常:{}", e.getMessage()); return AjaxResult.error(ExceptionEnum.DELETE_TO_DATABASE.getCode(), ExceptionEnum.DELETE_TO_DATABASE.getMsg()); } return AjaxResult.success("删除成功", res); @@ -121,15 +121,17 @@ public class MaWholeSetServiceImpl implements MaWholeSetService { /** * 根据id删除整套配件信息 - * @param id + * + * @param * @return */ - private int deleteMaWhole(Integer id) { - return mapper.deleteById(id); + private int deleteMaWhole(MaWholeSetDto dto) { + return mapper.deleteById(dto); } /** * 修改整套抱杆管理 + * * @param dto * @return */ @@ -137,27 +139,28 @@ public class MaWholeSetServiceImpl implements MaWholeSetService { @Transactional(rollbackFor = Exception.class) public AjaxResult update(MaWholeSetDto dto) { log.info("修改整套抱杆管理传参:{}", dto); - int count = selectByParentId(dto.getParentId()); - if (!dto.getId().equals(dto.getParentId()) && count != 0) { - return AjaxResult.error("该物品类型已经配套相关配件,无法再次绑定,请重新提交修改!!!"); - } - if (CollectionUtils.isNotEmpty(dto.getWholeList())) { - for (MaWhole maWhole : dto.getWholeList()) { + if (CollectionUtils.isNotEmpty(dto.getDeviceInfo())) { + for (MaWhole maWhole : dto.getDeviceInfo()) { + maWhole.setCreateBy(dto.getCreateBy()); + maWhole.setCompanyId(dto.getCompanyId()); + maWhole.setTypeId(maWhole.getDeviceTypeId()); + maWhole.setTotalNum(maWhole.getDeviceNum()); + maWhole.setWholeTypeName(dto.getWholeTypeName()); maWhole.setParentId(dto.getParentId()); } } int res = 0; try { - res = deleteMaWhole(dto.getId()); - if (res == 0) { - log.error("deleteById方法删除异常"); - throw new RuntimeException("deleteById方法删除异常"); - } - res = insertMaWholeSet(dto.getWholeList()); + deleteMaWhole(dto); + res = insertMaWholeSet(dto.getDeviceInfo()); if (res == 0) { log.error("insertMaWholeSet方法插入异常"); throw new RuntimeException("insertMaWholeSet方法插入异常"); } + /* int count = selectByParentId(dto.getWholeTypeName()); + if (count > 1) { + throw new RuntimeException("配套名称已重复,请重新输入"); + }*/ } catch (Exception e) { e.printStackTrace(); return AjaxResult.error(ExceptionEnum.UPDATE_TO_DATABASE.getCode(), ExceptionEnum.UPDATE_TO_DATABASE.getMsg()); @@ -167,6 +170,7 @@ public class MaWholeSetServiceImpl implements MaWholeSetService { /** * 修改时查询整套抱杆明细 + * * @param id * @return */ @@ -188,17 +192,21 @@ public class MaWholeSetServiceImpl implements MaWholeSetService { /** * 方法提取,新增ma_whole_set表 + * * @param wholeList * @return */ - private int insertMaWholeSet(List wholeList) { return mapper.insert(wholeList); } + private int insertMaWholeSet(List wholeList) { + return mapper.insert(wholeList); + } /** * 根据parentId查询,去重 - * @param parentId + * + * @param wholeTypeName * @return */ - private int selectByParentId(Integer parentId) { - return mapper.selectByParentId(parentId); + private int selectByParentId(String wholeTypeName) { + return mapper.selectByParentId(wholeTypeName); } } diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/MaWholeSetMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/MaWholeSetMapper.xml index 01f9b7ca..4cfc0869 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/MaWholeSetMapper.xml +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/MaWholeSetMapper.xml @@ -41,44 +41,30 @@ - insert into ma_whole_set - - type_id, - parent_id, - part_num, - whole_type_name, - create_by, - create_time, - status - - - #{item.id}, - #{item.parentId}, - #{item.totalNum}, - #{item.wholeTypeName}, - #{item.createBy}, - #{item.createTime}, - 1 - + insert into ma_whole_set (type_id,parent_id,part_num,whole_type_name,create_by,ascription_type,create_time,status,company_id) + values(#{item.typeId},#{item.parentId},#{item.totalNum},#{item.wholeTypeName},#{item.createBy},#{item.ascriptionType}, now(),1,#{item.companyId}) - + delete from ma_whole_set - where parent_id = #{id} + where parent_id = #{id} and whole_type_name = #{wholeTypeName}