标准配置,领用申请
This commit is contained in:
parent
d5ed07d4d0
commit
0bf50f54cd
|
|
@ -42,6 +42,12 @@ public class SelectController {
|
||||||
return service.getMaTypeData(dto);
|
return service.getMaTypeData(dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "标准配置下拉选")
|
||||||
|
@PostMapping("getConfigList")
|
||||||
|
public AjaxResult getConfigList(@RequestBody BmUnit bmUnit) {
|
||||||
|
return service.getConfigList(bmUnit);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 机具类型下拉选
|
* 机具类型下拉选
|
||||||
* @param dto
|
* @param dto
|
||||||
|
|
|
||||||
|
|
@ -165,4 +165,11 @@ public interface SelectMapper {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<SelectVo> getMaType(SelectDto dto);
|
List<SelectVo> getMaType(SelectDto dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取标准配置下拉选
|
||||||
|
* @param bmUnit
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<ProjectTreeNode> getConfigList(BmUnit bmUnit);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -199,4 +199,11 @@ public interface SelectService {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
AjaxResult getMaType(SelectDto dto);
|
AjaxResult getMaType(SelectDto dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标准配置下拉选
|
||||||
|
* @param bmUnit
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
AjaxResult getConfigList(BmUnit bmUnit);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,24 @@ public class SelectServiceImpl implements SelectService {
|
||||||
return AjaxResult.success(list);
|
return AjaxResult.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AjaxResult getConfigList(BmUnit bmUnit) {
|
||||||
|
List<ProjectTreeNode> groupList = new ArrayList<>();
|
||||||
|
List<ProjectTreeNode> list;
|
||||||
|
try {
|
||||||
|
list = mapper.getConfigList(bmUnit);
|
||||||
|
if (CollectionUtils.isNotEmpty(list)) {
|
||||||
|
// 创建树形结构(数据集合作为参数)
|
||||||
|
ProjectTreeBuild treeBuild = new ProjectTreeBuild(list);
|
||||||
|
// 原查询结果转换树形结构
|
||||||
|
groupList = treeBuild.buildTree();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("标准配置-查询失败", e);
|
||||||
|
}
|
||||||
|
return AjaxResult.success(groupList);
|
||||||
|
}
|
||||||
|
|
||||||
// @Override
|
// @Override
|
||||||
// public AjaxResult getDictByPidCbx(SelectDto dto) {
|
// public AjaxResult getDictByPidCbx(SelectDto dto) {
|
||||||
// List<SelectVo> list = new ArrayList<>();
|
// List<SelectVo> list = new ArrayList<>();
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,120 @@
|
||||||
|
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.log.annotation.SysLog;
|
||||||
|
import com.bonus.common.log.enums.OperaType;
|
||||||
|
import com.bonus.common.security.annotation.RequiresPermissions;
|
||||||
|
import com.bonus.material.common.annotation.PreventRepeatSubmit;
|
||||||
|
import com.bonus.material.ma.domain.StandardConfigBean;
|
||||||
|
import com.bonus.material.ma.domain.Type;
|
||||||
|
import com.bonus.material.ma.domain.vo.StandardConfigDetailsVo;
|
||||||
|
import com.bonus.material.ma.service.StandardConfigManageService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 机械设备标准配置管理Controller
|
||||||
|
*
|
||||||
|
* @author hay
|
||||||
|
*/
|
||||||
|
@Api(tags = "机械设备标准配置管理接口")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/standardConfig")
|
||||||
|
public class StandardConfigManageController extends BaseController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private StandardConfigManageService service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标准配置下拉树
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "标准配置下拉树")
|
||||||
|
@GetMapping("/getConfigTreeSelect")
|
||||||
|
public AjaxResult getMaTypeTreeSelect(@RequestParam(required = false, defaultValue = "", value = "configName") String configName,
|
||||||
|
@RequestParam(required = false, defaultValue = "", value = "parentId") String parentId) {
|
||||||
|
return service.getConfigTreeSelect(configName, parentId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据左配置id查询右表格
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "根据左配置id查询右表格")
|
||||||
|
@GetMapping("/getListByConfigId")
|
||||||
|
public AjaxResult getListByConfigId(StandardConfigDetailsVo bean) {
|
||||||
|
return service.getListByConfigId(bean);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增标准配置
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "新增标准配置")
|
||||||
|
@SysLog(title = "机械设备标准配置管理", businessType = OperaType.INSERT, module = "机械设备标准配置管理->新增标准配置")
|
||||||
|
@PostMapping(value = "/add")
|
||||||
|
public AjaxResult add(@RequestBody StandardConfigBean bean) {
|
||||||
|
return toAjax(service.insertConfig(bean));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改标准配置
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "修改标准配置")
|
||||||
|
@SysLog(title = "机械设备标准配置管理", businessType = OperaType.UPDATE, module = "机械设备标准配置管理->修改标准配置")
|
||||||
|
@PostMapping(value = "/edit")
|
||||||
|
public AjaxResult edit(@RequestBody StandardConfigBean bean) {
|
||||||
|
return toAjax(service.updateConfig(bean));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除标准配置
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "删除标准配置")
|
||||||
|
@SysLog(title = "机械设备标准配置管理", businessType = OperaType.DELETE, module = "机械设备标准配置管理->删除标准配置")
|
||||||
|
@PostMapping("/del")
|
||||||
|
public AjaxResult remove(@RequestBody StandardConfigBean bean) {
|
||||||
|
return service.deleteConfigByConfigId(bean);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增标准配置明细
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "新增标准配置明细")
|
||||||
|
@SysLog(title = "机械设备标准配置管理", businessType = OperaType.INSERT, module = "机械设备标准配置管理->新增标准配置明细")
|
||||||
|
@PostMapping(value = "/addConfigDetails")
|
||||||
|
public AjaxResult addConfigDetails(@RequestBody StandardConfigDetailsVo bean) {
|
||||||
|
int result = service.addConfigDetails(bean);
|
||||||
|
if (result == 0){
|
||||||
|
return AjaxResult.error("操作失败!");
|
||||||
|
} else if (result == -2){
|
||||||
|
return AjaxResult.error("该类型下已存在该配置!");
|
||||||
|
} else if (result >0){
|
||||||
|
return AjaxResult.success();
|
||||||
|
} else {
|
||||||
|
return AjaxResult.error("操作失败!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改标准配置明细
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "修改标准配置明细")
|
||||||
|
@SysLog(title = "机械设备标准配置管理", businessType = OperaType.UPDATE, module = "机械设备标准配置管理->修改标准配置明细")
|
||||||
|
@PostMapping(value = "/editConfigDetails")
|
||||||
|
public AjaxResult editConfigDetails(@RequestBody StandardConfigDetailsVo bean) {
|
||||||
|
return toAjax(service.updateConfigDetails(bean));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除标准配置明细
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "删除标准配置明细")
|
||||||
|
@SysLog(title = "机械设备标准配置管理", businessType = OperaType.DELETE, module = "机械设备标准配置管理->删除标准配置明细")
|
||||||
|
@PostMapping("/delConfigDetails")
|
||||||
|
public AjaxResult delConfigDetails(@RequestBody StandardConfigDetailsVo bean) {
|
||||||
|
return service.delConfigDetails(bean);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
package com.bonus.material.ma.domain;
|
||||||
|
|
||||||
|
import com.bonus.common.core.annotation.Excel;
|
||||||
|
import com.bonus.common.core.web.domain.BaseEntity;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物资类型对象 ma_type
|
||||||
|
* @author syruan
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@Data
|
||||||
|
@ToString
|
||||||
|
public class StandardConfigBean extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 配置id */
|
||||||
|
@ApiModelProperty(value = "配置id")
|
||||||
|
private Long Id;
|
||||||
|
|
||||||
|
/** 配置id */
|
||||||
|
@ApiModelProperty(value = "配置id")
|
||||||
|
private Long configId;
|
||||||
|
|
||||||
|
/** 配置名称 */
|
||||||
|
@ApiModelProperty(value = "配置名称")
|
||||||
|
private String configName;
|
||||||
|
|
||||||
|
|
||||||
|
/** 上级ID */
|
||||||
|
@ApiModelProperty(value = "上级ID")
|
||||||
|
private Long parentId;
|
||||||
|
|
||||||
|
|
||||||
|
/** 层级 */
|
||||||
|
@ApiModelProperty(value = "层级")
|
||||||
|
private String level;
|
||||||
|
|
||||||
|
|
||||||
|
/** 删除标志(0代表存在 2代表删除) */
|
||||||
|
private String delFlag;
|
||||||
|
|
||||||
|
|
||||||
|
private String keyword;
|
||||||
|
|
||||||
|
/** 子节点 */
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||||
|
private List<StandardConfigBean> children = new ArrayList<>();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,81 @@
|
||||||
|
package com.bonus.material.ma.domain.vo;
|
||||||
|
|
||||||
|
import com.bonus.common.core.annotation.Excel;
|
||||||
|
import com.bonus.material.ma.domain.Type;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 机械设备标准配置详情
|
||||||
|
* @author hay
|
||||||
|
* @date 2025/2/14 14:02
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class StandardConfigDetailsVo extends Type {
|
||||||
|
|
||||||
|
/** 配置ID */
|
||||||
|
@ApiModelProperty(value = "配置ID")
|
||||||
|
private Long configId;
|
||||||
|
|
||||||
|
/** 配置详情ID */
|
||||||
|
@ApiModelProperty(value = "配置详情ID")
|
||||||
|
private Long detailsId;
|
||||||
|
|
||||||
|
/** 仓库Id */
|
||||||
|
@ApiModelProperty(value = "仓库Id")
|
||||||
|
private Long houseId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "仓库名称")
|
||||||
|
private String houseName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "施工类型")
|
||||||
|
private String constructionType;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "物资类型")
|
||||||
|
private String materialType;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "物资名称")
|
||||||
|
private String typeName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "规格ID")
|
||||||
|
private Long typeId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "规格型号")
|
||||||
|
private String typeModelName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "计量单位")
|
||||||
|
private String unit;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "数量")
|
||||||
|
private BigDecimal num;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "创建者")
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "创建时间")
|
||||||
|
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "更新者")
|
||||||
|
private String updateBy;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "更新时间 ")
|
||||||
|
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "关键字")
|
||||||
|
private String keyWord;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,109 @@
|
||||||
|
package com.bonus.material.ma.mapper;
|
||||||
|
|
||||||
|
import com.bonus.common.biz.domain.lease.LeaseOutDetails;
|
||||||
|
import com.bonus.material.ma.domain.MaTypeHistory;
|
||||||
|
import com.bonus.material.ma.domain.StandardConfigBean;
|
||||||
|
import com.bonus.material.ma.domain.Type;
|
||||||
|
import com.bonus.material.ma.domain.vo.MaTypeConfigVo;
|
||||||
|
import com.bonus.material.ma.domain.vo.MaTypeSelectVo;
|
||||||
|
import com.bonus.material.ma.domain.vo.MaTypeVo;
|
||||||
|
import com.bonus.material.ma.domain.vo.StandardConfigDetailsVo;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 机械设备标准配置管理Mapper接口
|
||||||
|
* @author hay
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface StandardConfigManageMapper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询机械设备标准配置管理树
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<StandardConfigBean> selectStandardConfigTree();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据level层级和typeID 查询父级ID
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<Integer> selectParentId(StandardConfigDetailsVo bean);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据父级ID 查询子级
|
||||||
|
* @param configId
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<StandardConfigDetailsVo> getListByParentId(@Param("configId") Long configId,@Param("bean") StandardConfigDetailsVo bean);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据配置id 查询配置详情
|
||||||
|
* @param configName
|
||||||
|
* @param parentId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
StandardConfigBean queryByNameAndParentId(@Param("configName") String configName, @Param("parentId") Long parentId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增配置
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int insertConfig(StandardConfigBean bean);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改配置
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int updateConfig(StandardConfigBean bean);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据配置id 查询配置详情
|
||||||
|
* @param configId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<StandardConfigDetailsVo> selectByConfigId(Long configId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据配置id 删除配置
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int deleteConfigByConfigId(StandardConfigBean bean);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据configId和typeId 查询是否存在数据
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int getCountById(StandardConfigDetailsVo bean);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增配置详情
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int addConfigDetails(StandardConfigDetailsVo bean);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改配置详情
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int updateConfigDetails(StandardConfigDetailsVo bean);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除配置详情
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int delConfigDetails(StandardConfigDetailsVo bean);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,77 @@
|
||||||
|
package com.bonus.material.ma.service;
|
||||||
|
|
||||||
|
import com.bonus.common.biz.domain.TreeSelect;
|
||||||
|
import com.bonus.common.core.web.domain.AjaxResult;
|
||||||
|
import com.bonus.material.ma.domain.MaTypeHistory;
|
||||||
|
import com.bonus.material.ma.domain.StandardConfigBean;
|
||||||
|
import com.bonus.material.ma.domain.Type;
|
||||||
|
import com.bonus.material.ma.domain.vo.MaTypeConfigVo;
|
||||||
|
import com.bonus.material.ma.domain.vo.MaTypeSelectVo;
|
||||||
|
import com.bonus.material.ma.domain.vo.MaTypeVo;
|
||||||
|
import com.bonus.material.ma.domain.vo.StandardConfigDetailsVo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 机械设备标准配置管理Service接口
|
||||||
|
* @author hay
|
||||||
|
*/
|
||||||
|
public interface StandardConfigManageService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询机械设备标准配置管理树结构信息
|
||||||
|
* @param configName
|
||||||
|
* @param parentId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
AjaxResult getConfigTreeSelect(String configName, String parentId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据左配置id查询右表格
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
AjaxResult getListByConfigId(StandardConfigDetailsVo bean);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增机械设备标准配置管理
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int insertConfig(StandardConfigBean bean);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改机械设备标准配置管理
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int updateConfig(StandardConfigBean bean);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除机械设备标准配置管理
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
AjaxResult deleteConfigByConfigId(StandardConfigBean bean);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增机械设备标准配置管理明细
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int addConfigDetails(StandardConfigDetailsVo bean);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改机械设备标准配置管理明细
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int updateConfigDetails(StandardConfigDetailsVo bean);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除机械设备标准配置管理明细
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
AjaxResult delConfigDetails(StandardConfigDetailsVo bean);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,241 @@
|
||||||
|
package com.bonus.material.ma.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.convert.Convert;
|
||||||
|
import com.bonus.common.biz.config.ListPagingUtil;
|
||||||
|
import com.bonus.common.biz.domain.TreeSelect;
|
||||||
|
import com.bonus.common.biz.enums.HttpCodeEnum;
|
||||||
|
import com.bonus.common.core.utils.DateUtils;
|
||||||
|
import com.bonus.common.core.utils.ServletUtils;
|
||||||
|
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.StandardConfigBean;
|
||||||
|
import com.bonus.material.ma.domain.Type;
|
||||||
|
import com.bonus.material.ma.domain.vo.MaTypeVo;
|
||||||
|
import com.bonus.material.ma.domain.vo.StandardConfigDetailsVo;
|
||||||
|
import com.bonus.material.ma.mapper.StandardConfigManageMapper;
|
||||||
|
import com.bonus.material.ma.mapper.TypeMapper;
|
||||||
|
import com.bonus.material.ma.service.StandardConfigManageService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 机械设备标准配置管理Service业务层实现
|
||||||
|
*
|
||||||
|
* @author hay
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class StandardConfigManageServiceImpl implements StandardConfigManageService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private StandardConfigManageMapper mapper;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AjaxResult getConfigTreeSelect(String configName, String parentId) {
|
||||||
|
// 定义最终接口返回集合
|
||||||
|
List<TreeSelect> treeSelectResultList = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
// 1.顶级节点及子节点数据全部查询完毕
|
||||||
|
treeSelectResultList = this.getConfigTree(configName, parentId);
|
||||||
|
return AjaxResult.success(treeSelectResultList);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return AjaxResult.success(treeSelectResultList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AjaxResult getListByConfigId(StandardConfigDetailsVo bean) {
|
||||||
|
List<StandardConfigDetailsVo> list = new ArrayList<>();
|
||||||
|
Integer pageIndex = Convert.toInt(ServletUtils.getParameter("pageNum"), 1);
|
||||||
|
Integer pageSize = Convert.toInt(ServletUtils.getParameter("pageSize"), 10);
|
||||||
|
try {
|
||||||
|
//根据level层级和配置id 查询父级ID
|
||||||
|
List<Integer> parentIds = mapper.selectParentId(bean);
|
||||||
|
if (CollectionUtils.isEmpty(parentIds)) {
|
||||||
|
return AjaxResult.success(new ArrayList<>());
|
||||||
|
}
|
||||||
|
for (Integer parentId : parentIds) {
|
||||||
|
list.addAll(mapper.getListByParentId(parentId.longValue(), bean));
|
||||||
|
}
|
||||||
|
return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, list));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, new ArrayList<>()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insertConfig(StandardConfigBean bean) {
|
||||||
|
//根据类型名称判断,去重
|
||||||
|
StandardConfigBean bean1 = mapper.queryByNameAndParentId(bean.getConfigName(), bean.getParentId());
|
||||||
|
if (bean1 != null) {
|
||||||
|
throw new RuntimeException("同级下类型配置存在重复!");
|
||||||
|
}
|
||||||
|
bean.setLevel(String.valueOf(2));
|
||||||
|
bean.setCreateTime(DateUtils.getNowDate());
|
||||||
|
bean.setCreateBy(SecurityUtils.getUserId().toString());
|
||||||
|
int count = mapper.insertConfig(bean);
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int updateConfig(StandardConfigBean bean) {
|
||||||
|
//根据类型名称判断,去重
|
||||||
|
StandardConfigBean bean1 = mapper.queryByNameAndParentId(bean.getConfigName(), bean.getParentId());
|
||||||
|
if (bean1 != null && !bean1.getConfigId().equals(bean1.getConfigId())) {
|
||||||
|
throw new RuntimeException("同级下类型配置存在重复!");
|
||||||
|
}
|
||||||
|
bean.setUpdateTime(DateUtils.getNowDate());
|
||||||
|
bean.setUpdateBy(SecurityUtils.getUserId().toString());
|
||||||
|
int updateResult = mapper.updateConfig(bean);
|
||||||
|
return updateResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AjaxResult deleteConfigByConfigId(StandardConfigBean bean) {
|
||||||
|
if (StringUtils.isNull(bean.getConfigId())){
|
||||||
|
return AjaxResult.error("删除失败,缺少参数");
|
||||||
|
}
|
||||||
|
//根据configId查询删除类型下属是否有关联,有关联无法删除
|
||||||
|
List<StandardConfigDetailsVo> list = mapper.selectByConfigId(bean.getConfigId());
|
||||||
|
if (list!=null && list.size()>0) {
|
||||||
|
return AjaxResult.error("该类型下有子类型,无法删除");
|
||||||
|
}
|
||||||
|
bean.setUpdateTime(DateUtils.getNowDate());
|
||||||
|
bean.setUpdateBy(SecurityUtils.getUserId().toString());
|
||||||
|
int result = mapper.deleteConfigByConfigId(bean);
|
||||||
|
if (result > 0) {
|
||||||
|
return AjaxResult.success(HttpCodeEnum.SUCCESS.getMsg(), result);
|
||||||
|
}
|
||||||
|
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int addConfigDetails(StandardConfigDetailsVo bean) {
|
||||||
|
try {
|
||||||
|
//根据configId和typeId 查询是否存在数据
|
||||||
|
int count = mapper.getCountById(bean);
|
||||||
|
if (count > 0) {
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
bean.setCreateTime(DateUtils.getNowDate());
|
||||||
|
bean.setCreateBy(SecurityUtils.getUserId().toString());
|
||||||
|
int result = mapper.addConfigDetails(bean);
|
||||||
|
return result;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int updateConfigDetails(StandardConfigDetailsVo bean) {
|
||||||
|
try {
|
||||||
|
bean.setUpdateTime(DateUtils.getNowDate());
|
||||||
|
bean.setUpdateBy(SecurityUtils.getUserId().toString());
|
||||||
|
int result = mapper.updateConfigDetails(bean);
|
||||||
|
return result;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AjaxResult delConfigDetails(StandardConfigDetailsVo bean) {
|
||||||
|
try {
|
||||||
|
if (StringUtils.isNull(bean.getDetailsId())){
|
||||||
|
return AjaxResult.error("删除失败,缺少参数");
|
||||||
|
}
|
||||||
|
int result = mapper.delConfigDetails(bean);
|
||||||
|
return AjaxResult.success(result);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TreeSelect> getConfigTree(String typeName, String parentId) {
|
||||||
|
List<StandardConfigBean> standardConfigs = mapper.selectStandardConfigTree();
|
||||||
|
List<StandardConfigBean> builtConfigList = buildConfigTree(standardConfigs);
|
||||||
|
|
||||||
|
// 查询顶级节点的仓库配置信息
|
||||||
|
|
||||||
|
// 如果没有查询到那么返回空
|
||||||
|
return builtConfigList.stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.map(this::convertToTreeSelect)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<StandardConfigBean> buildConfigTree(List<StandardConfigBean> configList) {
|
||||||
|
List<StandardConfigBean> returnList = new ArrayList<StandardConfigBean>();
|
||||||
|
List<Long> tempList = configList.stream().map(StandardConfigBean::getId).collect(Collectors.toList());
|
||||||
|
for (StandardConfigBean maType : configList) {
|
||||||
|
// 如果是顶级节点, 遍历该父节点的所有子节点
|
||||||
|
if (!tempList.contains(maType.getParentId())) {
|
||||||
|
recursionFn(configList, maType);
|
||||||
|
returnList.add(maType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (returnList.isEmpty()) {
|
||||||
|
returnList = configList;
|
||||||
|
}
|
||||||
|
return returnList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 递归列表
|
||||||
|
*/
|
||||||
|
private void recursionFn(List<StandardConfigBean> list, StandardConfigBean t) {
|
||||||
|
// 得到子节点列表
|
||||||
|
List<StandardConfigBean> childList = getChildList(list, t);
|
||||||
|
t.setChildren(childList);
|
||||||
|
for (StandardConfigBean tChild : childList) {
|
||||||
|
if (hasChild(list, tChild)) {
|
||||||
|
recursionFn(list, tChild);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 得到子节点列表
|
||||||
|
*/
|
||||||
|
private List<StandardConfigBean> getChildList(List<StandardConfigBean> list, StandardConfigBean t) {
|
||||||
|
List<StandardConfigBean> tlist = new ArrayList<>();
|
||||||
|
for (StandardConfigBean n : list) {
|
||||||
|
if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getId().longValue()) {
|
||||||
|
tlist.add(n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tlist;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是否有子节点
|
||||||
|
*/
|
||||||
|
private boolean hasChild(List<StandardConfigBean> list, StandardConfigBean t) {
|
||||||
|
return !getChildList(list, t).isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过构造函数将 Type对象 转换为 TreeSelect -- 并递归处理子节点
|
||||||
|
*
|
||||||
|
* @param type 要进行转换的object对象
|
||||||
|
*/
|
||||||
|
private TreeSelect convertToTreeSelect(StandardConfigBean type) {
|
||||||
|
List<TreeSelect> children = type.getChildren().stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.map(this::convertToTreeSelect)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
return new TreeSelect(type.getId(), type.getConfigName(), null, Integer.valueOf(type.getLevel()), type.getParentId(), children);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -388,4 +388,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
and parent_id = #{typeId}
|
and parent_id = #{typeId}
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getConfigList" resultType="com.bonus.common.biz.domain.ProjectTreeNode">
|
||||||
|
SELECT id,
|
||||||
|
`name`,
|
||||||
|
parent_id AS parentId,
|
||||||
|
`level`
|
||||||
|
FROM bm_standard_config
|
||||||
|
WHERE del_flag = 0
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,198 @@
|
||||||
|
<?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.material.ma.mapper.StandardConfigManageMapper">
|
||||||
|
<insert id="insertConfig">
|
||||||
|
insert into bm_standard_config(
|
||||||
|
`name`,
|
||||||
|
parent_id,
|
||||||
|
level,
|
||||||
|
create_by,
|
||||||
|
create_time,
|
||||||
|
update_by,
|
||||||
|
update_time
|
||||||
|
)
|
||||||
|
values(
|
||||||
|
#{configName},
|
||||||
|
#{parentId},
|
||||||
|
#{level},
|
||||||
|
#{createBy},
|
||||||
|
#{createTime},
|
||||||
|
#{createBy},
|
||||||
|
#{createTime}
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
|
<insert id="addConfigDetails">
|
||||||
|
insert into bm_standard_config_details(
|
||||||
|
config_id,
|
||||||
|
type_id,
|
||||||
|
create_by,
|
||||||
|
create_time,
|
||||||
|
update_by,
|
||||||
|
update_time
|
||||||
|
)
|
||||||
|
values(
|
||||||
|
#{configId},
|
||||||
|
#{typeId},
|
||||||
|
#{createBy},
|
||||||
|
#{createTime},
|
||||||
|
#{createBy},
|
||||||
|
#{createTime}
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
|
<update id="updateConfig">
|
||||||
|
update bm_standard_config
|
||||||
|
set
|
||||||
|
<if test="configName != null and configName != ''">
|
||||||
|
`name` = #{configName},
|
||||||
|
</if>
|
||||||
|
<if test="parentId != null and parentId != ''">
|
||||||
|
parent_id = #{parentId},
|
||||||
|
</if>
|
||||||
|
<if test="level != null and level != ''">
|
||||||
|
level = #{level},
|
||||||
|
</if>
|
||||||
|
update_by = #{updateBy},
|
||||||
|
update_time = #{updateTime}
|
||||||
|
where id = #{configId}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<update id="deleteConfigByConfigId">
|
||||||
|
update bm_standard_config
|
||||||
|
set
|
||||||
|
del_flag = 2,
|
||||||
|
update_by = #{updateBy},
|
||||||
|
update_time = #{updateTime}
|
||||||
|
where id = #{configId}
|
||||||
|
</update>
|
||||||
|
<update id="updateConfigDetails">
|
||||||
|
update bm_standard_config_details
|
||||||
|
set
|
||||||
|
<if test="num != null">
|
||||||
|
num = #{num},
|
||||||
|
</if>
|
||||||
|
<if test="remark != null and remark != ''">
|
||||||
|
remark = #{remark},
|
||||||
|
</if>
|
||||||
|
update_by = #{updateBy},
|
||||||
|
update_time = #{updateTime}
|
||||||
|
where id = #{detailsId}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<update id="delConfigDetails">
|
||||||
|
update bm_standard_config_details
|
||||||
|
set
|
||||||
|
del_flag = 2,
|
||||||
|
update_by = #{updateBy},
|
||||||
|
update_time = #{updateTime}
|
||||||
|
where id = #{detailsId}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<select id="selectStandardConfigTree" resultType="com.bonus.material.ma.domain.StandardConfigBean">
|
||||||
|
SELECT
|
||||||
|
bsc1.id,
|
||||||
|
bsc1.`name` as configName,
|
||||||
|
bsc1.parent_id as parentId,
|
||||||
|
bsc1.level
|
||||||
|
FROM
|
||||||
|
bm_standard_config bsc1
|
||||||
|
WHERE
|
||||||
|
bsc1.del_flag = 0
|
||||||
|
</select>
|
||||||
|
<select id="selectParentId" resultType="java.lang.Integer">
|
||||||
|
SELECT DISTINCT
|
||||||
|
bsc1.id
|
||||||
|
FROM
|
||||||
|
bm_standard_config bsc1
|
||||||
|
LEFT JOIN bm_standard_config bsc2 ON bsc1.parent_id = bsc2.id
|
||||||
|
WHERE
|
||||||
|
bsc1.id IS NOT NULL
|
||||||
|
and bsc2.id IS NOT NULL
|
||||||
|
<if test="level == 1">
|
||||||
|
and bsc2.id=#{configId}
|
||||||
|
</if>
|
||||||
|
<if test="level == 2">
|
||||||
|
and bsc1.id=#{configId}
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
<select id="getListByParentId" resultType="com.bonus.material.ma.domain.vo.StandardConfigDetailsVo">
|
||||||
|
SELECT
|
||||||
|
bscd.id as detailsId,
|
||||||
|
a.houseName,
|
||||||
|
a.constructionType,
|
||||||
|
a.materialType,
|
||||||
|
a.typeName,
|
||||||
|
a.typeModelName,
|
||||||
|
a.unit,
|
||||||
|
bscd.num,
|
||||||
|
bscd.remark
|
||||||
|
FROM
|
||||||
|
bm_standard_config_details bscd
|
||||||
|
LEFT JOIN
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
mt.type_id AS typeId,
|
||||||
|
whi.house_name as houseName,
|
||||||
|
mt4.type_name AS constructionType,
|
||||||
|
mt3.type_name AS materialType,
|
||||||
|
mt2.type_name AS typeName,
|
||||||
|
mt.type_name AS typeModelName,
|
||||||
|
mt.unit_name AS unit
|
||||||
|
FROM
|
||||||
|
ma_type mt
|
||||||
|
LEFT JOIN
|
||||||
|
ma_type mt2 ON mt2.type_id = mt.parent_id
|
||||||
|
LEFT JOIN
|
||||||
|
ma_type mt3 ON mt3.type_id = mt2.parent_id
|
||||||
|
LEFT JOIN
|
||||||
|
ma_type mt4 ON mt4.type_id = mt3.parent_id
|
||||||
|
LEFT JOIN wh_house_set whs on whs.type_id=mt4.type_id and whs.del_flag=0
|
||||||
|
LEFT JOIN wh_house_info whi on whi.house_id=whs.house_id and whi.del_flag=0
|
||||||
|
WHERE
|
||||||
|
mt.`level` = 4
|
||||||
|
AND mt.del_flag = '0'
|
||||||
|
) a ON a.typeId = bscd.type_id
|
||||||
|
WHERE
|
||||||
|
bscd.config_id = #{configId}
|
||||||
|
AND bscd.del_flag = 0
|
||||||
|
<if test="bean.keyWord != null and bean.keyWord !=''">
|
||||||
|
AND (a.houseName like concat('%',#{bean.keyWord},'%')
|
||||||
|
or a.constructionType like concat('%',#{bean.keyWord},'%')
|
||||||
|
or a.materialType like concat('%',#{bean.keyWord},'%')
|
||||||
|
or a.typeName like concat('%',#{bean.keyWord},'%')
|
||||||
|
or a.typeModelName like concat('%',#{bean.keyWord},'%')
|
||||||
|
or bscd.remark like concat('%',#{bean.keyWord},'%')
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="queryByNameAndParentId" resultType="com.bonus.material.ma.domain.StandardConfigBean">
|
||||||
|
SELECT id AS configId,
|
||||||
|
parent_id AS parentId,
|
||||||
|
`name` AS configName,
|
||||||
|
`level`
|
||||||
|
FROM bm_standard_config
|
||||||
|
WHERE `name` = #{configName}
|
||||||
|
AND parent_id = #{parentId}
|
||||||
|
AND del_flag = '0'
|
||||||
|
</select>
|
||||||
|
<select id="selectByConfigId" resultType="com.bonus.material.ma.domain.vo.StandardConfigDetailsVo">
|
||||||
|
SELECT
|
||||||
|
config_id AS configId
|
||||||
|
FROM
|
||||||
|
bm_standard_config_details bscd
|
||||||
|
WHERE
|
||||||
|
del_flag = 0
|
||||||
|
AND config_id = #{configId}
|
||||||
|
</select>
|
||||||
|
<select id="getCountById" resultType="java.lang.Integer">
|
||||||
|
SELECT count(1) AS count
|
||||||
|
FROM
|
||||||
|
bm_standard_config_details bscd
|
||||||
|
WHERE
|
||||||
|
del_flag = 0
|
||||||
|
AND config_id = #{configId}
|
||||||
|
AND type_id = #{typeId}
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
Loading…
Reference in New Issue