装备配置管理

This commit is contained in:
jiang 2025-08-12 18:52:34 +08:00
parent 3958bfad7d
commit bbdb2ee405
9 changed files with 640 additions and 156 deletions

View File

@ -3,19 +3,38 @@ package com.bonus.common.biz.domain;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
@Data
public class MaTypeProperty {
/** 类型ID */
private Long id;
/**
* 类型ID
*/
@ApiModelProperty(value = "类型ID")
private Long typeId;
/** 属性名称 */
/**
* 属性名称
*/
@ApiModelProperty(value = "属性名称")
private String propertyName;
/** 是否必填(0:否, 1:是) */
/**
* 是否必填(0:, 1:)
*/
@ApiModelProperty(value = "是否必填(0:否, 1:是)")
private String mustHave;
/**
* 属性值
*/
private String propertyValue;
/**
* 创建时间
*/
private Date createTime;
}

View File

@ -214,6 +214,16 @@ public class MaTypeController extends BaseController {
}
@ApiOperation(value = "根据左列表类型id查询右表格")
@GetMapping("/getList")
public AjaxResult getList(@RequestParam(required = false) String typeName, Integer level) {
List<MaType> listByMaType = iTypeService.getList(typeName,level);
Integer pageIndex = Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1);
Integer pageSize = Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10);
return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, listByMaType));
}
/**
* 根据左列表类型id查询右表格
*
@ -253,6 +263,17 @@ public class MaTypeController extends BaseController {
}
}
@PostMapping("/addProperties")
public AjaxResult addProperties(@RequestBody MaType maType) {
return iTypeService.addProperties(maType);
}
@PostMapping("/updateProperties")
public AjaxResult updateProperties(@RequestBody MaType maType) {
return iTypeService.updateProperties(maType);
}
@ApiOperation(value = "租赁价(批量)修改")
@PostMapping("/updateLeasePrice")
public AjaxResult updateLeasePrice(@RequestBody MaType maType) {
@ -263,9 +284,9 @@ public class MaTypeController extends BaseController {
return AjaxResult.error("请输入价格");
}
Integer i = iTypeService.updateLeasePrice(maType);
if (i > 0){
if (i > 0) {
return AjaxResult.success("修改成功");
}else {
} else {
return AjaxResult.error("修改失败");
}
}

View File

@ -71,7 +71,7 @@ public interface MaTypeMapper {
List<MaType> selectMaTypeTreeByLevel(String id);
List<MaType> selectMaTypeListByLevelNotFour(@Param("parentId") String parentId,@Param("keyword")String keyword);
List<MaType> selectMaTypeListByLevelNotFour(@Param("parentId") String parentId, @Param("keyword") String keyword);
List<MaType> getMaTypeSelect(String parentId);
@ -85,13 +85,15 @@ public interface MaTypeMapper {
List<MaTypeKeeper> selectMaTypeByUserId(Long userId);
List<Integer> selectParentId(@Param("typeId")Long typeId, @Param("level")Integer level);
List<Integer> selectParentId(@Param("typeId") Long typeId, @Param("level") Integer level);
Integer updateLeasePrice(@Param("typeIds")List<Integer> typeIds,@Param("leasePrice") BigDecimal leasePrice);
Integer updateLeasePrice(@Param("typeIds") List<Integer> typeIds, @Param("leasePrice") BigDecimal leasePrice);
List<MaTypeProperty> selectMaTypePropertyNames();
int deleteMaTypePropertyNames(@Param("typeId")Long typeId);
int deleteMaTypePropertyNames(@Param("typeId") Long typeId);
int insertMaTypePropertyNames(@Param("typeId")Long typeId, @Param("list") List<MaTypeProperty> properties);
int insertMaTypePropertyNames(@Param("typeId") Long typeId, @Param("list") List<MaTypeProperty> properties);
List<MaType> getList(@Param("typeName") String typeName, @Param("level") Integer level);
}

View File

@ -1,5 +1,6 @@
package com.bonus.material.ma.service;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.ma.vo.MaType;
import com.bonus.material.ma.vo.TreeSelect;
@ -69,4 +70,10 @@ public interface ITypeService {
Integer updateLeasePrice(MaType typeIds);
AjaxResult addProperties(MaType maType);
AjaxResult updateProperties(MaType maType);
List<MaType> getList(String typeName,Integer level);
}

View File

@ -3,6 +3,7 @@ package com.bonus.material.ma.service.impl;
import com.bonus.common.biz.domain.MaTypeProperty;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.core.utils.StringUtils;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.ma.mapper.MaTypeFileMapper;
import com.bonus.material.ma.mapper.MaTypeMapper;
import com.bonus.material.ma.service.ITypeService;
@ -14,6 +15,7 @@ import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* 工机具类型管理实现层
@ -213,13 +215,12 @@ public class MaTypeServiceImpl implements ITypeService {
public List<TreeSelect> getMaTypeList(String typeName, String parentId) {
List<MaType> maTypes = maTypeMapper.selectMaTypeTree(parentId);
//填充自定义属性
fillProperties(maTypes);
List<TreeSelect> treeSelectList = buildDeptTreeSelect(maTypes);
List<TreeSelect> treeSelectList = buildDeptTreeSelect(fillProperties(maTypes));
//如果没有查询到那么返回空
return treeSelectList;
}
private void fillProperties(List<MaType> maTypes) {
private List<MaType> fillProperties(List<MaType> maTypes) {
List<MaTypeProperty> maTypeProperties = maTypeMapper.selectMaTypePropertyNames();
Map<Long, List<MaTypeProperty>> maTypePropertiesMap = new HashMap<>();
if (!CollectionUtils.isEmpty(maTypeProperties)) {
@ -228,6 +229,7 @@ public class MaTypeServiceImpl implements ITypeService {
for (MaType maType : maTypes) {
maType.setMaTypeProperties(maTypePropertiesMap.get(maType.getTypeId()));
}
return maTypes;
}
@Override
@ -399,6 +401,152 @@ public class MaTypeServiceImpl implements ITypeService {
return maTypeMapper.updateLeasePrice(maType.getTypeIds(), maType.getLeasePrice());
}
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult addProperties(MaType maType) {
// 1. 参数校验
if (maType == null || StringUtils.isEmpty(maType.getTypeName())) {
return AjaxResult.error("参数不合法");
}
// 2. 检查同级节点是否有同名类型
if (hasDuplicateTypeName(maType)) {
return AjaxResult.error("未新增成功,请查看同一层级是否有重名的类型!");
}
try {
// 3. 设置类型基本信息
setupMaTypeBasicInfo(maType);
// 4. 插入类型记录
int insertCount = maTypeMapper.insertType(maType);
if (insertCount <= 0) {
return AjaxResult.error("新增类型失败");
}
// 5. 处理并插入属性
Long typeId = maType.getTypeId();
List<MaTypeProperty> properties = buildMaTypeProperties(typeId, maType.getFormFeature());
if (!properties.isEmpty()) {
int propertyInsertCount = maTypeMapper.insertMaTypePropertyNames(typeId, properties);
if (propertyInsertCount <= 0) {
throw new RuntimeException("新增属性失败");
}
}
return AjaxResult.success("新增成功");
} catch (Exception e) {
return AjaxResult.error("新增失败:" + e.getMessage());
}
}
@Override
public AjaxResult updateProperties(MaType maType) {
// 1. 参数校验
if (maType == null || StringUtils.isEmpty(maType.getTypeName())) {
return AjaxResult.error("参数不合法");
}
// 2. 检查同级节点是否有同名类型
if (hasDuplicateTypeName(maType)) {
return AjaxResult.error("未修改成功,请查看同一层级是否有重名的类型!");
}
try {
// 3. 设置类型基本信息
setupMaTypeBasicInfo(maType);
// 4. 插入类型记录
int insertCount = maTypeMapper.updateType(maType);
if (insertCount <= 0) {
return AjaxResult.error("修改类型失败");
}
// 5. 处理并插入属性
Long typeId = maType.getTypeId();
List<MaTypeProperty> properties = buildMaTypeProperties(typeId, maType.getFormFeature());
maTypeMapper.deleteMaTypePropertyNames(typeId);
if (!properties.isEmpty()) {
int propertyInsertCount = maTypeMapper.insertMaTypePropertyNames(typeId, properties);
if (propertyInsertCount <= 0) {
throw new RuntimeException("修改属性失败");
}
}
return AjaxResult.success("修改成功");
} catch (Exception e) {
return AjaxResult.error("修改失败:" + e.getMessage());
}
}
@Override
public List<MaType> getList(String typeName, Integer level) {
List<MaType> list = maTypeMapper.getList(typeName, level);
return fillProperties(list);
}
// 检查是否有重复类型名
private boolean hasDuplicateTypeName(MaType maType) {
Long parentId = maType.getParentId();
Long currentId = maType.getTypeId(); // 可能为null新增场景
String typeName = maType.getTypeName();
List<MaType> siblings = maTypeMapper.getListByParentId(parentId, null);
return siblings.stream()
// 过滤逻辑若currentId为null新增则不过滤任何节点若不为null编辑则排除自身
.filter(sibling -> currentId == null ? true : !sibling.getTypeId().equals(currentId))
// 判断是否存在同名节点
.anyMatch(sibling -> typeName.equals(sibling.getTypeName()));
}
// 设置类型基本信息
private void setupMaTypeBasicInfo(MaType maType) {
Long parentId = maType.getParentId();
MaType parent = parentId == 0 ? null : maTypeMapper.selectMaTypeByTypeId(parentId);
// 设置层级
String level = parent == null ? "0" : parent.getLevel();
maType.setLevel(String.valueOf(Integer.parseInt(level) + 1));
// 设置其他信息
maType.setCreateTime(DateUtils.getNowDate());
maType.setCompanyId(parentId == 0 ? "101" : parent.getCompanyId());
}
// 构建类型属性列表
private List<MaTypeProperty> buildMaTypeProperties(Long typeId, List<FormFeature> formFeatures) {
if (CollectionUtils.isEmpty(formFeatures)) {
return Collections.emptyList();
}
return formFeatures.stream()
.flatMap(formFeature -> {
String propertyName = formFeature.getFeatureName();
String mustHave = formFeature.isRequired() ? "1" : "0";
if ("input".equals(formFeature.getInputType())) {
return Stream.of(createMaTypeProperty(typeId, propertyName, formFeature.getValue(), mustHave));
} else if ("select".equals(formFeature.getInputType())) {
return formFeature.getOptions().stream()
.map(value -> createMaTypeProperty(typeId, propertyName, value, mustHave));
}
return Stream.empty();
})
.collect(Collectors.toList());
}
// 创建类型属性对象
private MaTypeProperty createMaTypeProperty(Long typeId, String propertyName, String propertyValue, String mustHave) {
MaTypeProperty property = new MaTypeProperty();
property.setTypeId(typeId);
property.setPropertyName(propertyName);
property.setPropertyValue(propertyValue);
property.setMustHave(mustHave);
return property;
}
/**
* @Author dingjie
* @Date 2023/12/14

View File

@ -0,0 +1,39 @@
package com.bonus.material.ma.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class FormFeature {
private Long id;
/**
* 特征名称
*/
private String featureName;
/**
* 输入类型select, input, checkbox等
*/
private String inputType;
/**
* 是否必填
*/
private boolean required;
/**
* 当前选中的值
*/
private String value;
/**
* 可选项列表适用于select等输入类型
*/
private List<String> options;
}

View File

@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
@ -17,7 +18,6 @@ import java.util.List;
*/
/**
*
* @author rsyao
* @date
*/
@ -26,54 +26,78 @@ public class MaType extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 类型ID */
/**
* 类型ID
*/
@ApiModelProperty(value = "类型ID")
private Long typeId;
/** 类型名称 */
/**
* 类型名称
*/
@ApiModelProperty(value = "类型名称")
@Excel(name = "名称")
private String typeName;
/** 类型ID */
/**
* 类型ID
*/
@ApiModelProperty(value = "类型ID,用作组织树筛选")
private Long id;
/** 类型名称 */
/**
* 类型名称
*/
@ApiModelProperty(value = "类型名称,用作组织树筛选")
private String label;
/** 上级ID */
/**
* 上级ID
*/
@ApiModelProperty(value = "上级ID")
private Long parentId;
/** 帐号状态0正常 1停用 */
/**
* 帐号状态0正常 1停用
*/
@ApiModelProperty(value = "帐号状态0正常 1停用")
private String status;
/** 实时库存 */
/**
* 实时库存
*/
@ApiModelProperty(value = "实时库存")
private Integer storageNum;
/** 计量单位id */
/**
* 计量单位id
*/
@ApiModelProperty(value = "计量单位id")
private String unitId;
/** 计量单位 */
/**
* 计量单位
*/
@ApiModelProperty(value = "计量单位")
@Excel(name = "计量单位")
private String unitName;
/** 管理方式 */
/**
* 管理方式
*/
@ApiModelProperty(value = "管理方式")
private String manageType;
/** 租赁单价 */
/**
* 租赁单价
*/
@ApiModelProperty(value = "租赁单价")
@Excel(name = "租赁价格")
private BigDecimal leasePrice;
/** 租赁单价 */
/**
* 租赁单价
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "租赁单价")
private Date effTime;
@ -82,125 +106,181 @@ public class MaType extends BaseEntity {
private BigDecimal rentPrice;
private BigDecimal finalPrice;
/** 原价 */
/**
* 原价
*/
@ApiModelProperty(value = "原价")
@Excel(name = "原值")
private BigDecimal buyPrice;
/** 丢失赔偿价 */
/**
* 丢失赔偿价
*/
@ApiModelProperty(value = "丢失|赔偿价")
@Excel(name = "丢失赔偿价")
private BigDecimal payPrice;
/** 层级 */
/**
* 层级
*/
@ApiModelProperty(value = "层级")
private String level;
/** 额定载荷 */
/**
* 额定载荷
*/
@ApiModelProperty(value = "额定载荷")
private String ratedLoad;
/** 试验载荷 */
/**
* 试验载荷
*/
@ApiModelProperty(value = "试验载荷")
private String testLoad;
/** 持荷时间 */
/**
* 持荷时间
*/
@ApiModelProperty(value = "持荷时间")
private String holdingTime;
/** 库存预警数量 */
/**
* 库存预警数量
*/
@ApiModelProperty(value = "库存预警数量")
private Integer warnNum;
/** 库存预警数量 */
/**
* 库存预警数量
*/
@ApiModelProperty(value = "是否计划管理0代表否 1代表是")
private String isPlan;
/** 库存预警数量 */
/**
* 库存预警数量
*/
@ApiModelProperty(value = "是否安措费机具0代表否1代表是")
private String isAncuo;
/** 删除标志0代表存在 2代表删除 */
/**
* 删除标志0代表存在 2代表删除
*/
@ApiModelProperty(value = "删除标志0代表存在 2代表删除")
private String delFlag;
/** 创建者 */
/**
* 创建者
*/
@ApiModelProperty(value = "创建者")
private String createBy;
/** 创建时间 */
/**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建时间")
private Date createTime;
/** 更新者 */
/**
* 更新者
*/
@ApiModelProperty(value = "更新者")
private String updateBy;
/** 更新时间 */
/**
* 更新时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "更新时间")
private Date updateTime;
/** 备注 */
/**
* 备注
*/
@ApiModelProperty(value = "备注")
@Excel(name = "备注信息")
private String remark;
/** 数据所属组织 */
/**
* 数据所属组织
*/
@ApiModelProperty(value = "数据所属组织")
private String companyId;
/** 图片名称 */
/**
* 图片名称
*/
@ApiModelProperty(value = "图片名称")
@Excel(name = "图片")
private String photoName;
/** 图片路径 */
/**
* 图片路径
*/
@ApiModelProperty(value = "图片路径")
private String photoUrl;
private String childPhoto;
/** 文档名称 */
/**
* 文档名称
*/
@ApiModelProperty(value = "文档名称")
@Excel(name = "文档资料")
private String documentName;
/** 文档路径 */
/**
* 文档路径
*/
@ApiModelProperty(value = "文档路径")
private String documentUrl;
/** 库管员id */
/**
* 库管员id
*/
@ApiModelProperty(value = "库管员id")
private Integer keeperUserId;
/** 库管员名称 */
/**
* 库管员名称
*/
@ApiModelProperty(value = "库管员名称")
@Excel(name = "库管员")
private String keeperUserName;
/** 库管员id */
/**
* 库管员id
*/
@ApiModelProperty(value = "维修员id")
private Integer repairUserId;
/** 维修员名称 */
/**
* 维修员名称
*/
@ApiModelProperty(value = "维修员名称")
private String repairUserName;
/** 资产属性id */
/**
* 资产属性id
*/
@ApiModelProperty(value = "资产属性id")
private long propId;
/** 资产属性名称 */
/**
* 资产属性名称
*/
@ApiModelProperty(value = "资产属性名称")
@Excel(name = "资产属性")
private String propName;
/** 资产属性名称 */
/**
* 资产属性名称
*/
@ApiModelProperty(value = "类型编码")
private String code;
/** 子节点 */
/**
* 子节点
*/
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<MaType> children = new ArrayList<>();
@ -211,8 +291,8 @@ public class MaType extends BaseEntity {
private String facModel;
/*
* 推送智慧工程定义的门类分类机具编码
* */
* 推送智慧工程定义的门类分类机具编码
* */
@ApiModelProperty(value = "推送智慧工程定义的门类分类机具编码")
private String intelligentCode;
@ -222,4 +302,12 @@ public class MaType extends BaseEntity {
private List<Integer> typeIds;
private List<MaTypeProperty> maTypeProperties;
private List<FormFeature> formFeature;
private String major;
private String mainProcedure;
private String subProcedure;
}

View File

@ -9,17 +9,20 @@ import java.util.stream.Collectors;
/**
* Treeselect树结构实体类
*
*
* @author ruoyi
*/
public class TreeSelect implements Serializable
{
public class TreeSelect implements Serializable {
private static final long serialVersionUID = 1L;
/** 节点ID */
/**
* 节点ID
*/
private Long id;
/** 节点名称 */
/**
* 节点名称
*/
private String label;
private Integer level;
@ -28,14 +31,18 @@ public class TreeSelect implements Serializable
private String companyId;
private String unitName;
private List<MaTypeProperty> maTypeProperties;
/** 子节点 */
/**
* 子节点
*/
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<TreeSelect> children;
public TreeSelect()
{
public TreeSelect() {
}
@ -47,13 +54,13 @@ public class TreeSelect implements Serializable
// this.children = maHouse.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
// }
public TreeSelect(MaType maType)
{
public TreeSelect(MaType maType) {
this.parentId = maType.getParentId();
this.level = Integer.valueOf(maType.getLevel());
this.id = maType.getTypeId();
this.label = maType.getTypeName();
this.companyId = maType.getCompanyId();
this.unitName = maType.getUnitName();
this.maTypeProperties = maType.getMaTypeProperties();
this.children = maType.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
}
@ -74,13 +81,11 @@ public class TreeSelect implements Serializable
}
public Long getId()
{
public Long getId() {
return id;
}
public void setId(Long id)
{
public void setId(Long id) {
this.id = id;
}
@ -92,13 +97,11 @@ public class TreeSelect implements Serializable
this.level = level;
}
public String getLabel()
{
public String getLabel() {
return label;
}
public void setLabel(String label)
{
public void setLabel(String label) {
this.label = label;
}
@ -110,6 +113,14 @@ public class TreeSelect implements Serializable
this.companyId = companyId;
}
public String getUnitName() {
return unitName;
}
public void setUnitName(String unitName) {
this.unitName = unitName;
}
public List<MaTypeProperty> getMaTypeProperties() {
return maTypeProperties;
}
@ -118,13 +129,11 @@ public class TreeSelect implements Serializable
this.maTypeProperties = maTypeProperties;
}
public List<TreeSelect> getChildren()
{
public List<TreeSelect> getChildren() {
return children;
}
public void setChildren(List<TreeSelect> children)
{
public void setChildren(List<TreeSelect> children) {
this.children = children;
}
}

View File

@ -4,46 +4,75 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bonus.material.ma.mapper.MaTypeMapper">
<resultMap type="com.bonus.material.ma.vo.MaType" id="MaTypeResult">
<result property="typeId" column="type_id" />
<result property="typeName" column="type_name" />
<result property="parentId" column="parent_id" />
<result property="storageNum" column="storage_num" />
<result property="companyId" column="company_id" />
<result property="code" column="code" />
<result property="unitId" column="unit_id" />
<result property="unitName" column="unit_name" />
<result property="manageType" column="manage_type" />
<result property="leasePrice" column="lease_price" />
<result property="effTime" column="eff_time" />
<result property="rentPrice" column="rent_price" />
<result property="buyPrice" column="buy_price" />
<result property="payPrice" column="pay_price" />
<result property="level" column="level" />
<result property="ratedLoad" column="rated_load" />
<result property="testLoad" column="test_load" />
<result property="holdingTime" column="holding_time" />
<result property="warnNum" column="warn_num" />
<result property="delFlag" column="del_flag" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="isPlan" column="is_plan" />
<result property="isAncuo" column="is_ancuo" />
<result property="remark" column="remark" />
<result property="childPhoto" column="childPhoto" />
<result property="intelligentCode" column="intelligent_code" />
<result property="maintenanceAlarmDay" column="maintenance_alarm_day" />
<result property="typeId" column="type_id"/>
<result property="typeName" column="type_name"/>
<result property="parentId" column="parent_id"/>
<result property="storageNum" column="storage_num"/>
<result property="companyId" column="company_id"/>
<result property="code" column="code"/>
<result property="unitId" column="unit_id"/>
<result property="unitName" column="unit_name"/>
<result property="manageType" column="manage_type"/>
<result property="leasePrice" column="lease_price"/>
<result property="effTime" column="eff_time"/>
<result property="rentPrice" column="rent_price"/>
<result property="buyPrice" column="buy_price"/>
<result property="payPrice" column="pay_price"/>
<result property="level" column="level"/>
<result property="ratedLoad" column="rated_load"/>
<result property="testLoad" column="test_load"/>
<result property="holdingTime" column="holding_time"/>
<result property="warnNum" column="warn_num"/>
<result property="delFlag" column="del_flag"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="isPlan" column="is_plan"/>
<result property="isAncuo" column="is_ancuo"/>
<result property="remark" column="remark"/>
<result property="childPhoto" column="childPhoto"/>
<result property="intelligentCode" column="intelligent_code"/>
<result property="maintenanceAlarmDay" column="maintenance_alarm_day"/>
</resultMap>
<sql id="selectMaTypeVo">
select type_id, type_name, parent_id, storage_num, company_id, code, unit_id, unit_name, manage_type,
lease_price, eff_time, rent_price, buy_price, pay_price, level, rated_load, test_load, holding_time,
warn_num, del_flag, create_by, create_time, update_by, update_time, is_plan, is_ancuo, remark,
intelligent_code, maintenance_alarm_day, fac_model, child_photo from ma_type
select type_id,
type_name,
parent_id,
storage_num,
company_id,
code,
unit_id,
unit_name,
manage_type,
lease_price,
eff_time,
rent_price,
buy_price,
pay_price,
level,
rated_load,
test_load,
holding_time,
warn_num,
del_flag,
create_by,
create_time,
update_by,
update_time,
is_plan,
is_ancuo,
remark,
intelligent_code,
maintenance_alarm_day,
fac_model,
child_photo
from ma_type
</sql>
<insert id="insertType" parameterType="com.bonus.material.ma.vo.MaType" useGeneratedKeys="true" keyProperty="typeId">
<insert id="insertType" parameterType="com.bonus.material.ma.vo.MaType" useGeneratedKeys="true"
keyProperty="typeId">
insert into ma_type
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="typeName != null and typeName != ''">type_name,</if>
@ -109,7 +138,8 @@
</trim>
</insert>
<insert id="insertTypeFile" parameterType="com.bonus.material.ma.vo.MaTypeFile" useGeneratedKeys="true" keyProperty="typeId">
<insert id="insertTypeFile" parameterType="com.bonus.material.ma.vo.MaTypeFile" useGeneratedKeys="true"
keyProperty="typeId">
insert into ma_type_file(
<if test="typeId != null and typeId != 0">type_id,</if>
<if test="maId != null and maId != ''">ma_id,</if>
@ -169,16 +199,24 @@
</update>
<delete id="deleteTypeById" parameterType="Long">
update ma_type set del_flag = '2' where type_id = #{typeId}
update ma_type
set del_flag = '2'
where type_id = #{typeId}
</delete>
<delete id="deleteTypeByTypeId">
delete from ma_type_repair where type_id = #{typeId}
delete
from ma_type_repair
where type_id = #{typeId}
</delete>
<delete id="deleteKeeperByTypeId">
delete from ma_type_keeper where type_id = #{typeId}
delete
from ma_type_keeper
where type_id = #{typeId}
</delete>
<delete id="deletePropSetByTypeId">
delete from ma_prop_set where type_id = #{typeId}
delete
from ma_prop_set
where type_id = #{typeId}
</delete>
<select id="selectMaTypeList" parameterType="String" resultMap="MaTypeResult">
@ -213,8 +251,11 @@
</select>
<select id="selectTypeById" resultType="java.lang.Integer">
select count(1) from ma_type
where del_flag = '0' and parent_id = #{typeId} limit 1
select count(1)
from ma_type
where del_flag = '0'
and parent_id = #{typeId}
limit 1
</select>
<select id="checkTypeNameUnique" resultType="com.bonus.material.ma.vo.MaType">
@ -287,13 +328,41 @@
</insert>
<select id="selectMaTypeByTypeId" resultMap="MaTypeResult">
select m.type_id, m.type_name, m.parent_id, m.storage_num, m.unit_id,m.unit_name, m.manage_type,
m.lease_price, m.eff_time, m.rent_price, m.buy_price, m.pay_price, m.level, m.rated_load, m.test_load,
m.holding_time, m.warn_num, mtf.file_name photoName, mtf.file_url photoUrl,
mtf2.file_name documentName, mtf2.file_url documentUrl, mtk.user_id keeperUserId,
su.nick_name keeperUserName, mtr.user_id repairUserId, su1.nick_name repairUserName,mpi.prop_id as propId, mpi.prop_name as propName,
m.del_flag, m.create_by, m.create_time,
m.remark, m.company_id,m.fac_model as facModel,m.intelligent_code, m.maintenance_alarm_day
select m.type_id,
m.type_name,
m.parent_id,
m.storage_num,
m.unit_id,
m.unit_name,
m.manage_type,
m.lease_price,
m.eff_time,
m.rent_price,
m.buy_price,
m.pay_price,
m.level,
m.rated_load,
m.test_load,
m.holding_time,
m.warn_num,
mtf.file_name photoName,
mtf.file_url photoUrl,
mtf2.file_name documentName,
mtf2.file_url documentUrl,
mtk.user_id keeperUserId,
su.nick_name keeperUserName,
mtr.user_id repairUserId,
su1.nick_name repairUserName,
mpi.prop_id as propId,
mpi.prop_name as propName,
m.del_flag,
m.create_by,
m.create_time,
m.remark,
m.company_id,
m.fac_model as facModel,
m.intelligent_code,
m.maintenance_alarm_day
from ma_type m
left join ma_prop_set mps on m.type_id = mps.type_id
left join ma_prop_info mpi on mps.prop_id = mpi.prop_id
@ -303,19 +372,28 @@
left join sys_user su on mtk.user_id = su.user_id
left join ma_type_repair mtr on m.type_id = mtr.type_id
left join sys_user su1 on mtr.user_id = su1.user_id
where m.type_id = #{typeId} and m.del_flag = '0'
where m.type_id = #{typeId}
and m.del_flag = '0'
</select>
<update id="updateKeeperByTypeId">
update ma_type_keeper set user_id = #{userId},update_time = now() where type_id = #{typeId}
update ma_type_keeper
set user_id = #{userId},
update_time = now()
where type_id = #{typeId}
</update>
<update id="updateRepairByTypeId">
update ma_type_repair set user_id = #{userId},update_time = now() where type_id = #{typeId}
update ma_type_repair
set user_id = #{userId},
update_time = now()
where type_id = #{typeId}
</update>
<update id="updatePropSetByTypeId">
update ma_prop_set set prop_id = #{propId} where type_id = #{typeId}
update ma_prop_set
set prop_id = #{propId}
where type_id = #{typeId}
</update>
<select id="selectTypeByTypeId" parameterType="long" resultMap="MaTypeResult">
@ -324,12 +402,31 @@
</select>
<select id="selectMaTypeTree" resultMap="MaTypeResult" parameterType="java.lang.String">
select m.type_id, m.type_name, m.parent_id, m.storage_num, m.unit_id, m.manage_type,
m.lease_price, m.eff_time, m.rent_price, m.buy_price, m.pay_price, m.level, m.rated_load, m.test_load,
m.holding_time, m.warn_num, m.del_flag, m.create_by, m.create_time,
m.remark, m.company_id, m.maintenance_alarm_day
select m.type_id,
m.type_name,
m.parent_id,
m.storage_num,
m.unit_id,
m.unit_name,
m.manage_type,
m.lease_price,
m.eff_time,
m.rent_price,
m.buy_price,
m.pay_price,
m.level,
m.rated_load,
m.test_load,
m.holding_time,
m.warn_num,
m.del_flag,
m.create_by,
m.create_time,
m.remark,
m.company_id,
m.maintenance_alarm_day
from ma_type m
where level != 4 and del_flag = '0'
where del_flag = '0'
</select>
<select id="getMaTypeSelect" resultType="com.bonus.material.ma.vo.MaType">
select m.type_id, m.type_name, m.parent_id, m.storage_num, m.unit_id, m.manage_type,
@ -425,17 +522,19 @@
</where>
</select>
<select id="selectMaTypeByUserId" resultType="com.bonus.material.ma.vo.MaTypeKeeper">
select * from ma_type_keeper where user_id = #{userId}
select *
from ma_type_keeper
where user_id = #{userId}
</select>
<select id="selectParentId" resultType="java.lang.Integer">
SELECT DISTINCT
mt2.type_id
mt2.type_id
FROM
ma_type mt
LEFT JOIN ma_type mt2 ON mt.parent_id = mt2.type_id
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id
ma_type mt
LEFT JOIN ma_type mt2 ON mt.parent_id = mt2.type_id
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id
WHERE 1=1
<if test="level == 1">
and mt4.type_id = #{typeId}
@ -453,7 +552,9 @@
</select>
<update id="updateTypeNum">
update ma_type set storage_num = IFNULL( storage_num, 0 ) + 1 where type_id = #{typeId}
update ma_type
set storage_num = IFNULL(storage_num, 0) + 1
where type_id = #{typeId}
</update>
<update id="updateLeasePrice">
update ma_type set lease_price = #{leasePrice} where type_id in
@ -464,28 +565,78 @@
</update>
<select id="selectMaTypePropertyNames" resultType="com.bonus.common.biz.domain.MaTypeProperty">
select type_id as typeId,
property_name as propertyName,
must_have as mustHave
select type_id as typeId,
property_name as propertyName,
property_value AS propertyValue,
must_have as mustHave
from ma_type_properties
order by must_have desc
</select>
<select id="getList" resultMap="MaTypeResult">
select m.type_id,
m.type_name,
m.parent_id,
m.storage_num,
m.unit_id,
m.unit_name,
m.manage_type,
m.lease_price,
m.eff_time,
m.rent_price,
m.buy_price,
m.pay_price,
m.level,
m.rated_load,
m.test_load,
m.holding_time,
m.warn_num,
m.del_flag,
m.create_by,
m.create_time,
m.remark,
m.company_id,
m.maintenance_alarm_day,
m3.type_name AS subProcedure,
m2.type_name AS mainProcedure,
m1.type_name AS major
FROM ma_type m
LEFT JOIN ma_type m3 ON m3.type_id = m.parent_id
LEFT JOIN ma_type m2 ON m2.type_id = m3.parent_id
LEFT JOIN ma_type m1 ON m1.type_id = m2.parent_id
WHERE m.LEVEL = '4'
and m.del_flag = 0
<if test="level == 1">
and m1.type_name = #{typeName}
</if>
<if test="level == 2">
and m2.type_name = #{typeName}
</if>
<if test="level == 3">
and m3.type_name = #{typeName}
</if>
<if test="level == 4">
and m.type_name = #{typeName}
</if>
</select>
<delete id="deleteMaTypePropertyNames">
delete from ma_type_properties where type_id = #{typeId}
delete
from ma_type_properties
where type_id = #{typeId}
</delete>
<insert id="insertMaTypePropertyNames">
insert into
ma_type_properties(type_id, property_name, must_have, create_time)
ma_type_properties(type_id, property_name,property_value, must_have, create_time)
values
<foreach collection="list" item="item" index="index" separator=",">
(
#{typeId},
#{item.propertyName},
#{item.mustHave},
now()
)
</foreach>
<foreach collection="list" item="item" index="index" separator=",">
(
#{typeId},
#{item.propertyName},
#{item.propertyValue},
#{item.mustHave},
now()
)
</foreach>
</insert>
</mapper>