整套抱杆
This commit is contained in:
parent
6e1c80d8b0
commit
f175c44ba1
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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<T> implements Serializable {
|
||||
private static final long serialVersionUID = -3915666721968467471L;
|
||||
private int pageNum;
|
||||
private int pageSize;
|
||||
private long totalCount;
|
||||
private int totalPageCount;
|
||||
private List<T> result;
|
||||
|
||||
public PageResultVo() {
|
||||
}
|
||||
|
||||
public PageResultVo(List<T> result, int totalCount) {
|
||||
this.result = result;
|
||||
this.totalCount = (long)totalCount;
|
||||
}
|
||||
|
||||
public PageResultVo(int pageNum, int pageSize, long totalCount, int totalPageCount, List<T> 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<T> getResult() {
|
||||
return this.result;
|
||||
}
|
||||
|
||||
public void setResult(List<T> result) {
|
||||
this.result = result;
|
||||
}
|
||||
}
|
||||
|
|
@ -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<MaWholeVo> 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<MaWholeVo> 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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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<MaWhole> wholeList;
|
||||
|
||||
}
|
||||
|
|
@ -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<TreeSelectId> list;
|
||||
|
||||
/** 配件明细集合 */
|
||||
@ApiModelProperty(value = "配件明细集合")
|
||||
private List<MaWholeVo> voList;
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
|
@ -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<MaWhole> wholeList);
|
||||
|
||||
/**
|
||||
* 根据parentId查询,去重
|
||||
* @param parentId
|
||||
* @return
|
||||
*/
|
||||
int selectByParentId(@Param("parentId") Integer parentId);
|
||||
|
||||
/**
|
||||
* 查询整套抱杆管理
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
List<MaWholeVo> selectList(MaWholeSetDto dto);
|
||||
|
||||
/**
|
||||
* 查询整套抱杆明细
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
List<MaWholeVo> selectListById(MaWholeSetDto dto);
|
||||
|
||||
/**
|
||||
* 根据id删除
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
int deleteById(@Param("id") Integer id);
|
||||
|
||||
/**
|
||||
* 根据id去ma_whole_set表中查询typeid
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
List<Integer> selectTypeId(@Param("id") Integer id);
|
||||
|
||||
/**
|
||||
* 先根据id去查询物质类型树
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
TreeSelectId selectTypeTree(@Param("id") Integer id);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
List<MaWholeVo> select(@Param("id") Integer id);
|
||||
|
||||
/**
|
||||
* 根据typeId查询对应树id
|
||||
* @param typeId
|
||||
* @return
|
||||
*/
|
||||
List<TreeSelectId> selectId(@Param("typeId") List<Integer> typeId);
|
||||
}
|
||||
|
|
@ -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<MaWholeVo> selectList(MaWholeSetDto dto);
|
||||
|
||||
/**
|
||||
* 查询整套抱杆明细
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
List<MaWholeVo> 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);
|
||||
}
|
||||
|
|
@ -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<MaWholeVo> selectList(MaWholeSetDto dto) {
|
||||
List<MaWholeVo> list = mapper.selectList(dto);
|
||||
PageHelper.startPage(dto.getPageNum() == 0 ? 1 : dto.getPageNum(), dto.getPageSize());
|
||||
PageResultVo pageResult = new PageResultVo();
|
||||
// 分页信息
|
||||
PageInfo<MaWholeVo> 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<MaWholeVo> 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<Integer> typeId = mapper.selectTypeId(id);
|
||||
//先根据id去查询物质类型树树级id
|
||||
TreeSelectId selectId = mapper.selectTypeTree(id);
|
||||
//根据typeId查询对应树id
|
||||
List<TreeSelectId> ids = mapper.selectId(typeId);
|
||||
List<MaWholeVo> 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<MaWhole> wholeList) { return mapper.insert(wholeList); }
|
||||
|
||||
/**
|
||||
* 根据parentId查询,去重
|
||||
* @param parentId
|
||||
* @return
|
||||
*/
|
||||
private int selectByParentId(Integer parentId) {
|
||||
return mapper.selectByParentId(parentId);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,170 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bonus.sgzb.material.mapper.MaWholeSetMapper">
|
||||
<insert id="insertPlanNeedInfo" useGeneratedKeys="true" keyProperty="planId">
|
||||
insert into plan_need_info
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="unitId != null">unit_id,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="companyId != null">company_id,</if>
|
||||
create_time
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="unitId != null">#{unitId},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="companyId != null">#{companyId},</if>
|
||||
now()
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<insert id="insertPlanBorrow" useGeneratedKeys="true" keyProperty="borrowId">
|
||||
insert into plan_borrow_info
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="needUnitId != null">need_unit_id,</if>
|
||||
<if test="borrowUnitId != null">borrow_unit_id,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
create_time
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="needUnitId != null">#{needUnitId},</if>
|
||||
<if test="borrowUnitId != null">#{borrowUnitId},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
now()
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<insert id="insert">
|
||||
<foreach item="item" index="index" collection="wholeList" separator=";">
|
||||
insert into ma_whole_set
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="item.id != null">type_id,</if>
|
||||
<if test="item.parentId != null">parent_id,</if>
|
||||
<if test="item.totalNum != null">part_num,</if>
|
||||
status
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="item.id != null">#{item.id},</if>
|
||||
<if test="item.parentId != null">#{item.parentId},</if>
|
||||
<if test="item.totalNum != null">#{item.totalNum},</if>
|
||||
1
|
||||
</trim>
|
||||
</foreach>
|
||||
</insert>
|
||||
<delete id="deleteById" parameterType="java.lang.Integer">
|
||||
delete from ma_whole_set
|
||||
where parent_id = #{id}
|
||||
</delete>
|
||||
|
||||
<select id="selectByParentId" resultType="java.lang.Integer">
|
||||
select COUNT(*) from ma_whole_set
|
||||
where parent_id = #{parentId}
|
||||
</select>
|
||||
<select id="selectList" resultType="com.bonus.sgzb.material.domain.MaWholeVo">
|
||||
SELECT
|
||||
mws.parent_id AS id,
|
||||
mt2.type_name AS typeName,
|
||||
mt.type_name AS typeModelName,
|
||||
SUM(mws.part_num) AS totalNum
|
||||
FROM ma_whole_set mws
|
||||
JOIN ma_type mt ON mws.parent_id = mt.type_id
|
||||
JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
|
||||
JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
|
||||
JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
|
||||
<if test="keyWord != null and keyWord != ''">
|
||||
and (
|
||||
mt2.type_name like concat('%', #{keyWord}, '%') or
|
||||
mt.type_name like concat('%', #{keyWord}, '%')
|
||||
)
|
||||
</if>
|
||||
GROUP BY mws.parent_id
|
||||
</select>
|
||||
<select id="selectListById" resultType="com.bonus.sgzb.material.domain.MaWholeVo">
|
||||
SELECT
|
||||
mws.parent_id AS id,
|
||||
mt2.type_name AS typeName,
|
||||
mt.type_name AS typeModelName,
|
||||
mws.part_num AS totalNum
|
||||
FROM
|
||||
ma_whole_set mws
|
||||
JOIN ma_type mt ON mws.type_id = mt.type_id
|
||||
JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
|
||||
JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
|
||||
JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
|
||||
WHERE
|
||||
<if test="id != null and id != ''">
|
||||
mws.parent_id = #{id}
|
||||
</if>
|
||||
<if test="keyWord != null and keyWord != ''">
|
||||
and (
|
||||
mt2.type_name like concat('%', #{keyWord}, '%') or
|
||||
mt.type_name like concat('%', #{keyWord}, '%')
|
||||
)
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectTypeTree" resultType="com.bonus.sgzb.material.domain.TreeSelectId">
|
||||
SELECT
|
||||
mt4.type_id AS firstId,
|
||||
mt3.type_id AS secondId,
|
||||
mt2.type_id AS threeId,
|
||||
mt.type_id AS fourId
|
||||
FROM
|
||||
ma_type mt
|
||||
JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
|
||||
JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
|
||||
JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
|
||||
WHERE
|
||||
mt.`status` = '0'
|
||||
AND mt.del_flag = '0'
|
||||
<if test="id != null and id !=''">
|
||||
AND mt.type_id = #{id}
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectTypeId" resultType="java.lang.Integer">
|
||||
select type_id from ma_whole_set
|
||||
where parent_id = #{id}
|
||||
</select>
|
||||
<select id="select" resultType="com.bonus.sgzb.material.domain.MaWholeVo">
|
||||
SELECT
|
||||
mt.type_id AS id,
|
||||
mt2.type_name AS typeName,
|
||||
mt.type_name AS typeModelName,
|
||||
mws.part_num AS totalNum
|
||||
FROM
|
||||
ma_whole_set mws
|
||||
JOIN ma_type mt ON mws.type_id = mt.type_id
|
||||
JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
|
||||
JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
|
||||
JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
|
||||
WHERE
|
||||
<if test="id != null and id != ''">
|
||||
mws.parent_id = #{id}
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectId" resultType="com.bonus.sgzb.material.domain.TreeSelectId">
|
||||
SELECT
|
||||
mt4.type_id AS firstId,
|
||||
mt3.type_id AS secondId,
|
||||
mt2.type_id AS threeId,
|
||||
mt.type_id AS fourId
|
||||
FROM
|
||||
ma_type mt
|
||||
JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
|
||||
JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
|
||||
JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
|
||||
WHERE
|
||||
mt.`status` = '0'
|
||||
AND mt.del_flag = '0'
|
||||
AND mt.type_id in
|
||||
<foreach item="item" collection="typeId" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue