From f175c44ba13355f9719e14f61feec49c0bb0c864 Mon Sep 17 00:00:00 2001 From: mashuai Date: Mon, 22 Apr 2024 11:28:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E5=A5=97=E6=8A=B1=E6=9D=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sgzb/material/config/ExceptionEnum.java | 4 +- .../sgzb/material/config/PageResultVo.java | 90 ++++++++ .../controller/MaWholeSetController.java | 99 +++++++++ .../bonus/sgzb/material/domain/MaWhole.java | 29 +++ .../sgzb/material/domain/MaWholeSetDto.java | 44 ++++ .../sgzb/material/domain/MaWholeTreeVo.java | 31 +++ .../bonus/sgzb/material/domain/MaWholeVo.java | 33 +++ .../sgzb/material/domain/TreeSelectId.java | 37 ++++ .../material/mapper/MaWholeSetMapper.java | 81 +++++++ .../material/service/MaWholeSetService.java | 59 +++++ .../service/impl/MaWholeSetServiceImpl.java | 204 ++++++++++++++++++ .../mapper/material/MaWholeSetMapper.xml | 170 +++++++++++++++ 12 files changed, 880 insertions(+), 1 deletion(-) create mode 100644 sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/config/PageResultVo.java create mode 100644 sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/MaWholeSetController.java create mode 100644 sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MaWhole.java create mode 100644 sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MaWholeSetDto.java create mode 100644 sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MaWholeTreeVo.java create mode 100644 sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MaWholeVo.java create mode 100644 sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/TreeSelectId.java create mode 100644 sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/MaWholeSetMapper.java create mode 100644 sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/MaWholeSetService.java create mode 100644 sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/MaWholeSetServiceImpl.java create mode 100644 sgzb-modules/sgzb-material/src/main/resources/mapper/material/MaWholeSetMapper.xml diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/config/ExceptionEnum.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/config/ExceptionEnum.java index 982afed1..61c96253 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/config/ExceptionEnum.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/config/ExceptionEnum.java @@ -12,7 +12,9 @@ import lombok.Getter; @AllArgsConstructor public enum ExceptionEnum { - SAVE_TO_DATABASE(500, "新增保存失败,请联系管理员!!!"); + SAVE_TO_DATABASE(500, "新增保存失败,请联系管理员!!!"), + DELETE_TO_DATABASE(500, "删除失败,请联系管理员!!!"), + UPDATE_TO_DATABASE(500, "修改失败,请联系管理员!!!"); private Integer code; diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/config/PageResultVo.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/config/PageResultVo.java new file mode 100644 index 00000000..e52ea614 --- /dev/null +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/config/PageResultVo.java @@ -0,0 +1,90 @@ +package com.bonus.sgzb.material.config; + +import java.io.Serializable; +import java.util.List; + +/** + * 分页查询返回vo + * @Author ma_sh + * @create 2024/4/16 16:43 + */ +public class PageResultVo implements Serializable { + private static final long serialVersionUID = -3915666721968467471L; + private int pageNum; + private int pageSize; + private long totalCount; + private int totalPageCount; + private List result; + + public PageResultVo() { + } + + public PageResultVo(List result, int totalCount) { + this.result = result; + this.totalCount = (long)totalCount; + } + + public PageResultVo(int pageNum, int pageSize, long totalCount, int totalPageCount, List result) { + this.pageNum = pageNum; + this.pageSize = pageSize; + this.totalCount = totalCount; + this.totalPageCount = totalPageCount; + this.result = result; + } + + public boolean getFirstPage() { + return this.getPageNum() == 1; + } + + public long getPrevPage() { + return (long)Math.max(1, this.getPageNum() - 1); + } + + public long getNextPage() { + return (long)(this.getPageNum() + 1); + } + + public boolean getLastPage() { + return this.getPageNum() >= this.getTotalPageCount(); + } + + public int getPageNum() { + return this.pageNum; + } + + public void setPageNum(int pageNum) { + this.pageNum = pageNum; + } + + public int getPageSize() { + return this.pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public long getTotalCount() { + return this.totalCount; + } + + public void setTotalCount(long totalCount) { + this.totalCount = totalCount; + } + + public int getTotalPageCount() { + return this.totalPageCount; + } + + public void setTotalPageCount(int totalPageCount) { + this.totalPageCount = totalPageCount; + } + + public List getResult() { + return this.result; + } + + public void setResult(List result) { + this.result = result; + } +} 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 new file mode 100644 index 00000000..963f7c73 --- /dev/null +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/MaWholeSetController.java @@ -0,0 +1,99 @@ +package com.bonus.sgzb.material.controller; + +import com.bonus.sgzb.common.core.web.controller.BaseController; +import com.bonus.sgzb.common.core.web.domain.AjaxResult; +import com.bonus.sgzb.common.core.web.page.TableDataInfo; +import com.bonus.sgzb.material.config.PageResultVo; +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 io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.List; + +/** + * @Author ma_sh + * @create 2024/4/15 17:14 + */ +@RestController +@RequestMapping("/maWhole") +@Slf4j +public class MaWholeSetController extends BaseController { + + @Resource + private MaWholeSetService maWholeSetService; + + /** + * 新增整套抱杆管理 + * @param dto + * @return + */ + @ApiOperation("新增整套抱杆管理") + @PostMapping("/addOrUpdate") + public AjaxResult addOrUpdate(@ApiParam(value = "添加信息", required = true) + @RequestBody MaWholeSetDto dto) { + if (dto.getId() != null) { + log.info("修改整套抱杆管理:{}", dto); + return maWholeSetService.update(dto); + } + log.info("新增整套抱杆管理:{}", dto); + return maWholeSetService.insert(dto); + } + + /** + * 查询整套抱杆管理 + * @param dto + * @return + */ + @ApiOperation("查询整套抱杆管理") + @PostMapping("/selectList") + public AjaxResult selectList(@ApiParam(value = "查询信息") @RequestBody MaWholeSetDto dto) { + log.info("查询整套抱杆管理:{}", dto); + PageResultVo result = maWholeSetService.selectList(dto); + return AjaxResult.success(result); + } + + /** + * 查询整套抱杆明细 + * @param dto + * @return + */ + @ApiOperation("查询整套抱杆明细") + @PostMapping("/selectListById") + public TableDataInfo selectListById(@ApiParam(value = "查询信息") @RequestBody MaWholeSetDto dto) { + log.info("查询整套抱杆明细:{}", dto); + startPage(); + List list = maWholeSetService.selectListById(dto); + return getDataTable(list); + } + + /** + * 修改时查询整套抱杆明细 + * @param dto + * @return + */ + @ApiOperation("修改时查询整套抱杆明细") + @PostMapping("/selectListTree") + public AjaxResult selectListTree(@ApiParam(value = "查询信息") @RequestBody MaWholeSetDto dto) { + log.info("修改时查询整套抱杆明细:{}", dto); + MaWholeTreeVo maWholeTreeVo = maWholeSetService.selectListTree(dto.getId()); + return AjaxResult.success(maWholeTreeVo); + } + + /** + * 根据id删除整套抱杆 + * @param dto + * @return + */ + @ApiOperation("根据id删除整套抱杆") + @PostMapping("/deleteById") + public AjaxResult deleteById(@ApiParam(value = "删除信息") @RequestBody MaWholeSetDto dto) { + log.info("根据id删除整套抱杆:{}", dto); + return maWholeSetService.deleteById(dto); + } +} 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 new file mode 100644 index 00000000..c88b336c --- /dev/null +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MaWhole.java @@ -0,0 +1,29 @@ +package com.bonus.sgzb.material.domain; + +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 整套抱杆表单集合实体类 + * @Author ma_sh + * @create 2024/4/15 17:09 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class MaWhole { + + /** 类型ID */ + @ApiModelProperty(value = "类型ID") + private Integer id; + + /** 父级ID */ + @ApiModelProperty(value = "父级ID") + private Integer parentId; + + /** 配套数量 */ + @ApiModelProperty(value = "配套数量") + private Integer totalNum; +} 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 new file mode 100644 index 00000000..495b0106 --- /dev/null +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MaWholeSetDto.java @@ -0,0 +1,44 @@ +package com.bonus.sgzb.material.domain; + +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 整套抱杆新增dto + * @Author ma_sh + * @create 2024/4/15 15:55 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class MaWholeSetDto { + + /** 主键id */ + @ApiModelProperty(value = "主键id") + private Integer id; + + /** 分页传参当前页 */ + @ApiModelProperty(value = "分页传参当前页") + private Integer pageNum; + + /** 每页条数 */ + @ApiModelProperty(value = "每页条数") + private Integer pageSize; + + /** 父级ID */ + @ApiModelProperty(value = "父级ID") + private Integer parentId; + + /** 关键字 */ + @ApiModelProperty(value = "关键字") + private String keyWord; + + /** 表单对象集合 */ + @ApiModelProperty(value = "表单对象集合") + private List wholeList; + +} diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MaWholeTreeVo.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MaWholeTreeVo.java new file mode 100644 index 00000000..731a8274 --- /dev/null +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MaWholeTreeVo.java @@ -0,0 +1,31 @@ +package com.bonus.sgzb.material.domain; + +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 编辑查询下拉树实体集合vo + * @Author ma_sh + * @create 2024/4/17 16:22 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class MaWholeTreeVo { + + /** 物资类似树id */ + @ApiModelProperty(value = "物资类似树id") + private TreeSelectId typeList; + + /** 配件树id */ + @ApiModelProperty(value = "配件树id") + private List list; + + /** 配件明细集合 */ + @ApiModelProperty(value = "配件明细集合") + private List voList; +} 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 new file mode 100644 index 00000000..4181daf5 --- /dev/null +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MaWholeVo.java @@ -0,0 +1,33 @@ +package com.bonus.sgzb.material.domain; + +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 整套抱杆最外层表单vo + * @Author ma_sh + * @create 2024/4/16 10:04 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class MaWholeVo { + + /** 主键ID */ + @ApiModelProperty(value = "主键ID") + private Integer id; + + /** 机具名称 */ + @ApiModelProperty(value = "机具名称") + private String typeName; + + /** 规格型号 */ + @ApiModelProperty(value = "规格型号") + private String typeModelName; + + /** 套装所需配件数量 */ + @ApiModelProperty(value = "套装所需配件数量") + private Integer totalNum; +} diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/TreeSelectId.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/TreeSelectId.java new file mode 100644 index 00000000..d485337c --- /dev/null +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/TreeSelectId.java @@ -0,0 +1,37 @@ +package com.bonus.sgzb.material.domain; + +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * Treeselect树结构id实体类 + * @author ma_sh + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class TreeSelectId implements Serializable +{ + private static final long serialVersionUID = 1L; + + /** 一级节点ID */ + @ApiModelProperty(value = "一级节点ID") + private Long firstId; + + /** 二级节点ID */ + @ApiModelProperty(value = "二级节点ID") + private Long secondId; + + /** 三级节点ID */ + @ApiModelProperty(value = "三级节点ID") + private Long threeId; + + /** 四级节点ID */ + @ApiModelProperty(value = "四级节点ID") + private Long fourId; + +} 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 new file mode 100644 index 00000000..ff532d9b --- /dev/null +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/MaWholeSetMapper.java @@ -0,0 +1,81 @@ +package com.bonus.sgzb.material.mapper; + +import com.bonus.sgzb.base.api.domain.MaType; +import com.bonus.sgzb.material.domain.MaWhole; +import com.bonus.sgzb.material.domain.MaWholeSetDto; +import com.bonus.sgzb.material.domain.MaWholeVo; +import com.bonus.sgzb.material.domain.TreeSelectId; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 整套抱杆mapper层 + * @Author ma_sh + * @create 2024/4/15 17:23 + */ +public interface MaWholeSetMapper { + + /** + * 新增ma_whole_set表 + * @param wholeList + * @return + */ + int insert(@Param("wholeList") List wholeList); + + /** + * 根据parentId查询,去重 + * @param parentId + * @return + */ + int selectByParentId(@Param("parentId") Integer parentId); + + /** + * 查询整套抱杆管理 + * @param dto + * @return + */ + List selectList(MaWholeSetDto dto); + + /** + * 查询整套抱杆明细 + * @param dto + * @return + */ + List selectListById(MaWholeSetDto dto); + + /** + * 根据id删除 + * @param id + * @return + */ + int deleteById(@Param("id") Integer id); + + /** + * 根据id去ma_whole_set表中查询typeid + * @param id + * @return + */ + List selectTypeId(@Param("id") Integer id); + + /** + * 先根据id去查询物质类型树 + * @param id + * @return + */ + TreeSelectId selectTypeTree(@Param("id") Integer id); + + /** + * 根据id查询 + * @param id + * @return + */ + List select(@Param("id") Integer id); + + /** + * 根据typeId查询对应树id + * @param typeId + * @return + */ + List selectId(@Param("typeId") List 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 new file mode 100644 index 00000000..e511c21d --- /dev/null +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/MaWholeSetService.java @@ -0,0 +1,59 @@ +package com.bonus.sgzb.material.service; + +import com.bonus.sgzb.common.core.web.domain.AjaxResult; +import com.bonus.sgzb.material.config.PageResultVo; +import com.bonus.sgzb.material.domain.MaWholeSetDto; +import com.bonus.sgzb.material.domain.MaWholeTreeVo; +import com.bonus.sgzb.material.domain.MaWholeVo; + +import java.util.List; + +/** + * 整套抱杆服务层 + * @Author ma_sh + * @create 2024/4/15 17:17 + */ +public interface MaWholeSetService { + + /** + * 新增整套抱杆管理 + * @param dto + * @return + */ + AjaxResult insert(MaWholeSetDto dto); + + /** + * 查询整套抱杆管理 + * @param dto + * @return + */ + PageResultVo selectList(MaWholeSetDto dto); + + /** + * 查询整套抱杆明细 + * @param dto + * @return + */ + List selectListById(MaWholeSetDto dto); + + /** + * 根据id删除 + * @param dto + * @return + */ + AjaxResult deleteById(MaWholeSetDto dto); + + /** + * 修改整套抱杆管理 + * @param dto + * @return + */ + AjaxResult update(MaWholeSetDto dto); + + /** + * 修改时查询整套抱杆明细 + * @param id + * @return + */ + MaWholeTreeVo selectListTree(Integer id); +} 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 new file mode 100644 index 00000000..af24e77f --- /dev/null +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/MaWholeSetServiceImpl.java @@ -0,0 +1,204 @@ +package com.bonus.sgzb.material.service.impl; + +import com.bonus.sgzb.common.core.web.domain.AjaxResult; +import com.bonus.sgzb.material.config.ExceptionEnum; +import com.bonus.sgzb.material.config.PageResultVo; +import com.bonus.sgzb.material.domain.*; +import com.bonus.sgzb.material.mapper.MaWholeSetMapper; +import com.bonus.sgzb.material.service.MaWholeSetService; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.List; + +/** + * 整套抱杆操作实现层 + * @Author ma_sh + * @create 2024/4/15 17:17 + */ +@Service +@Slf4j +public class MaWholeSetServiceImpl implements MaWholeSetService { + + @Resource + private MaWholeSetMapper mapper; + + /** + * 新增整套抱杆管理 + * @param dto + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + public AjaxResult insert(MaWholeSetDto dto) { + if (dto == null) { + return AjaxResult.error("参数不能为空!!!"); + } + if (dto.getParentId() == null) { + return AjaxResult.error("父级id不能为空"); + } + int count = selectByParentId(dto.getParentId()); + if (count != 0) { + return AjaxResult.error("该物品类型已经绑定相关配件,无法再次绑定,请重新选择!!!"); + } + if (CollectionUtils.isNotEmpty(dto.getWholeList())) { + for (MaWhole maWhole : dto.getWholeList()) { + maWhole.setParentId(dto.getParentId()); + } + } + int res = 0; + try { + res = insertMaWholeSet(dto.getWholeList()); + 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()); + } + 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; + } + + /** + * 查询整套抱杆明细 + * @param dto + * @return + */ + @Override + public List selectListById(MaWholeSetDto dto) { + return mapper.selectListById(dto); + } + + /** + * 根据id删除 + * @param dto + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + public AjaxResult deleteById(MaWholeSetDto dto) { + if (dto.getId() == null) { + return AjaxResult.error("删除标识id为空,无法进行删除"); + } + int res = 0; + try { + res = deleteMaWhole(dto.getId()); + if (res == 0) { + throw new RuntimeException("删除失败"); + } + } catch (Exception e) { + log.error("删除异常:{}",e.getMessage()); + return AjaxResult.error(ExceptionEnum.DELETE_TO_DATABASE.getCode(), ExceptionEnum.DELETE_TO_DATABASE.getMsg()); + } + return AjaxResult.success("删除成功", res); + } + + /** + * 根据id删除整套配件信息 + * @param id + * @return + */ + private int deleteMaWhole(Integer id) { + return mapper.deleteById(id); + } + + /** + * 修改整套抱杆管理 + * @param dto + * @return + */ + @Override + @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()) { + 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()); + if (res == 0) { + log.error("insertMaWholeSet方法插入异常"); + throw new RuntimeException("insertMaWholeSet方法插入异常"); + } + } catch (Exception e) { + e.printStackTrace(); + return AjaxResult.error(ExceptionEnum.UPDATE_TO_DATABASE.getCode(), ExceptionEnum.UPDATE_TO_DATABASE.getMsg()); + } + return AjaxResult.success("修改成功", res); + } + + /** + * 修改时查询整套抱杆明细 + * @param id + * @return + */ + @Override + public MaWholeTreeVo selectListTree(Integer id) { + //根据id去ma_whole_set表中查询typeId + List typeId = mapper.selectTypeId(id); + //先根据id去查询物质类型树树级id + TreeSelectId selectId = mapper.selectTypeTree(id); + //根据typeId查询对应树id + List ids = mapper.selectId(typeId); + List voList = mapper.select(id); + MaWholeTreeVo treeVo = new MaWholeTreeVo(); + treeVo.setTypeList(selectId); + treeVo.setList(ids); + treeVo.setVoList(voList); + return treeVo; + } + + /** + * 方法提取,新增ma_whole_set表 + * @param wholeList + * @return + */ + private int insertMaWholeSet(List wholeList) { return mapper.insert(wholeList); } + + /** + * 根据parentId查询,去重 + * @param parentId + * @return + */ + private int selectByParentId(Integer parentId) { + return mapper.selectByParentId(parentId); + } +} 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 new file mode 100644 index 00000000..d73f50d1 --- /dev/null +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/MaWholeSetMapper.xml @@ -0,0 +1,170 @@ + + + + + insert into plan_need_info + + unit_id, + create_by, + remark, + company_id, + create_time + + + #{unitId}, + #{createBy}, + #{remark}, + #{companyId}, + now() + + + + + insert into plan_borrow_info + + need_unit_id, + borrow_unit_id, + create_by, + remark, + create_time + + + #{needUnitId}, + #{borrowUnitId}, + #{createBy}, + #{remark}, + now() + + + + + + insert into ma_whole_set + + type_id, + parent_id, + part_num, + status + + + #{item.id}, + #{item.parentId}, + #{item.totalNum}, + 1 + + + + + delete from ma_whole_set + where parent_id = #{id} + + + + + + + + + + + + \ No newline at end of file