设备类型设置

This commit is contained in:
JinLu.Yin 2022-05-08 19:56:09 +08:00
parent d743bd649c
commit 4fcabb2de3
6 changed files with 598 additions and 0 deletions

View File

@ -0,0 +1,108 @@
package com.ktg.mes.dv.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.ktg.common.constant.UserConstants;
import com.ktg.system.strategy.AutoCodeUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ktg.common.annotation.Log;
import com.ktg.common.core.controller.BaseController;
import com.ktg.common.core.domain.AjaxResult;
import com.ktg.common.enums.BusinessType;
import com.ktg.mes.dv.domain.DvMachineryType;
import com.ktg.mes.dv.service.IDvMachineryTypeService;
import com.ktg.common.utils.poi.ExcelUtil;
/**
* 设备类型Controller
*
* @author yinjinlu
* @date 2022-05-08
*/
@RestController
@RequestMapping("/mes/dv/machinerytype")
public class DvMachineryTypeController extends BaseController
{
@Autowired
private IDvMachineryTypeService dvMachineryTypeService;
@Autowired
private AutoCodeUtil autoCodeUtil;
/**
* 查询设备类型列表
*/
@PreAuthorize("@ss.hasPermi('mes:dv:machinerytype:list')")
@GetMapping("/list")
public AjaxResult list(DvMachineryType dvMachineryType)
{
List<DvMachineryType> list = dvMachineryTypeService.selectDvMachineryTypeList(dvMachineryType);
return AjaxResult.success(list);
}
/**
* 导出设备类型列表
*/
@PreAuthorize("@ss.hasPermi('mes:dv:machinerytype:export')")
@Log(title = "设备类型", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DvMachineryType dvMachineryType)
{
List<DvMachineryType> list = dvMachineryTypeService.selectDvMachineryTypeList(dvMachineryType);
ExcelUtil<DvMachineryType> util = new ExcelUtil<DvMachineryType>(DvMachineryType.class);
util.exportExcel(response, list, "设备类型数据");
}
/**
* 获取设备类型详细信息
*/
@PreAuthorize("@ss.hasPermi('mes:dv:machinerytype:query')")
@GetMapping(value = "/{machineryTypeId}")
public AjaxResult getInfo(@PathVariable("machineryTypeId") Long machineryTypeId)
{
return AjaxResult.success(dvMachineryTypeService.selectDvMachineryTypeByMachineryTypeId(machineryTypeId));
}
/**
* 新增设备类型
*/
@PreAuthorize("@ss.hasPermi('mes:dv:machinerytype:add')")
@Log(title = "设备类型", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DvMachineryType dvMachineryType)
{
dvMachineryType.setMachineryTypeCode(autoCodeUtil.genSerialCode(UserConstants.MACHINERY_TYPE_CODE,null));
return toAjax(dvMachineryTypeService.insertDvMachineryType(dvMachineryType));
}
/**
* 修改设备类型
*/
@PreAuthorize("@ss.hasPermi('mes:dv:machinerytype:edit')")
@Log(title = "设备类型", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DvMachineryType dvMachineryType)
{
return toAjax(dvMachineryTypeService.updateDvMachineryType(dvMachineryType));
}
/**
* 删除设备类型
*/
@PreAuthorize("@ss.hasPermi('mes:dv:machinerytype:remove')")
@Log(title = "设备类型", businessType = BusinessType.DELETE)
@DeleteMapping("/{machineryTypeIds}")
public AjaxResult remove(@PathVariable Long[] machineryTypeIds)
{
return toAjax(dvMachineryTypeService.deleteDvMachineryTypeByMachineryTypeIds(machineryTypeIds));
}
}

View File

@ -0,0 +1,151 @@
package com.ktg.mes.dv.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ktg.common.annotation.Excel;
import com.ktg.common.core.domain.TreeEntity;
/**
* 设备类型对象 dv_machinery_type
*
* @author yinjinlu
* @date 2022-05-08
*/
public class DvMachineryType extends TreeEntity
{
private static final long serialVersionUID = 1L;
/** 设备类型ID */
private Long machineryTypeId;
/** 设备类型编码 */
@Excel(name = "设备类型编码")
private String machineryTypeCode;
/** 设备类型名称 */
@Excel(name = "设备类型名称")
private String machineryTypeName;
/** 父类型ID */
@Excel(name = "父类型ID")
private Long parentTypeId;
/** 是否启用 */
@Excel(name = "是否启用")
private String enableFlag;
/** 预留字段1 */
private String attr1;
/** 预留字段2 */
private String attr2;
/** 预留字段3 */
private Long attr3;
/** 预留字段4 */
private Long attr4;
public void setMachineryTypeId(Long machineryTypeId)
{
this.machineryTypeId = machineryTypeId;
}
public Long getMachineryTypeId()
{
return machineryTypeId;
}
public void setMachineryTypeCode(String machineryTypeCode)
{
this.machineryTypeCode = machineryTypeCode;
}
public String getMachineryTypeCode()
{
return machineryTypeCode;
}
public void setMachineryTypeName(String machineryTypeName)
{
this.machineryTypeName = machineryTypeName;
}
public String getMachineryTypeName()
{
return machineryTypeName;
}
public void setParentTypeId(Long parentTypeId)
{
this.parentTypeId = parentTypeId;
}
public Long getParentTypeId()
{
return parentTypeId;
}
public void setEnableFlag(String enableFlag)
{
this.enableFlag = enableFlag;
}
public String getEnableFlag()
{
return enableFlag;
}
public void setAttr1(String attr1)
{
this.attr1 = attr1;
}
public String getAttr1()
{
return attr1;
}
public void setAttr2(String attr2)
{
this.attr2 = attr2;
}
public String getAttr2()
{
return attr2;
}
public void setAttr3(Long attr3)
{
this.attr3 = attr3;
}
public Long getAttr3()
{
return attr3;
}
public void setAttr4(Long attr4)
{
this.attr4 = attr4;
}
public Long getAttr4()
{
return attr4;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("machineryTypeId", getMachineryTypeId())
.append("machineryTypeCode", getMachineryTypeCode())
.append("machineryTypeName", getMachineryTypeName())
.append("parentTypeId", getParentTypeId())
.append("ancestors", getAncestors())
.append("enableFlag", getEnableFlag())
.append("remark", getRemark())
.append("attr1", getAttr1())
.append("attr2", getAttr2())
.append("attr3", getAttr3())
.append("attr4", getAttr4())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}

View File

@ -0,0 +1,61 @@
package com.ktg.mes.dv.mapper;
import java.util.List;
import com.ktg.mes.dv.domain.DvMachineryType;
/**
* 设备类型Mapper接口
*
* @author yinjinlu
* @date 2022-05-08
*/
public interface DvMachineryTypeMapper
{
/**
* 查询设备类型
*
* @param machineryTypeId 设备类型主键
* @return 设备类型
*/
public DvMachineryType selectDvMachineryTypeByMachineryTypeId(Long machineryTypeId);
/**
* 查询设备类型列表
*
* @param dvMachineryType 设备类型
* @return 设备类型集合
*/
public List<DvMachineryType> selectDvMachineryTypeList(DvMachineryType dvMachineryType);
/**
* 新增设备类型
*
* @param dvMachineryType 设备类型
* @return 结果
*/
public int insertDvMachineryType(DvMachineryType dvMachineryType);
/**
* 修改设备类型
*
* @param dvMachineryType 设备类型
* @return 结果
*/
public int updateDvMachineryType(DvMachineryType dvMachineryType);
/**
* 删除设备类型
*
* @param machineryTypeId 设备类型主键
* @return 结果
*/
public int deleteDvMachineryTypeByMachineryTypeId(Long machineryTypeId);
/**
* 批量删除设备类型
*
* @param machineryTypeIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteDvMachineryTypeByMachineryTypeIds(Long[] machineryTypeIds);
}

View File

@ -0,0 +1,61 @@
package com.ktg.mes.dv.service;
import java.util.List;
import com.ktg.mes.dv.domain.DvMachineryType;
/**
* 设备类型Service接口
*
* @author yinjinlu
* @date 2022-05-08
*/
public interface IDvMachineryTypeService
{
/**
* 查询设备类型
*
* @param machineryTypeId 设备类型主键
* @return 设备类型
*/
public DvMachineryType selectDvMachineryTypeByMachineryTypeId(Long machineryTypeId);
/**
* 查询设备类型列表
*
* @param dvMachineryType 设备类型
* @return 设备类型集合
*/
public List<DvMachineryType> selectDvMachineryTypeList(DvMachineryType dvMachineryType);
/**
* 新增设备类型
*
* @param dvMachineryType 设备类型
* @return 结果
*/
public int insertDvMachineryType(DvMachineryType dvMachineryType);
/**
* 修改设备类型
*
* @param dvMachineryType 设备类型
* @return 结果
*/
public int updateDvMachineryType(DvMachineryType dvMachineryType);
/**
* 批量删除设备类型
*
* @param machineryTypeIds 需要删除的设备类型主键集合
* @return 结果
*/
public int deleteDvMachineryTypeByMachineryTypeIds(Long[] machineryTypeIds);
/**
* 删除设备类型信息
*
* @param machineryTypeId 设备类型主键
* @return 结果
*/
public int deleteDvMachineryTypeByMachineryTypeId(Long machineryTypeId);
}

View File

@ -0,0 +1,105 @@
package com.ktg.mes.dv.service.impl;
import java.util.List;
import com.ktg.common.core.domain.entity.ItemType;
import com.ktg.common.utils.DateUtils;
import com.ktg.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ktg.mes.dv.mapper.DvMachineryTypeMapper;
import com.ktg.mes.dv.domain.DvMachineryType;
import com.ktg.mes.dv.service.IDvMachineryTypeService;
/**
* 设备类型Service业务层处理
*
* @author yinjinlu
* @date 2022-05-08
*/
@Service
public class DvMachineryTypeServiceImpl implements IDvMachineryTypeService
{
@Autowired
private DvMachineryTypeMapper dvMachineryTypeMapper;
/**
* 查询设备类型
*
* @param machineryTypeId 设备类型主键
* @return 设备类型
*/
@Override
public DvMachineryType selectDvMachineryTypeByMachineryTypeId(Long machineryTypeId)
{
return dvMachineryTypeMapper.selectDvMachineryTypeByMachineryTypeId(machineryTypeId);
}
/**
* 查询设备类型列表
*
* @param dvMachineryType 设备类型
* @return 设备类型
*/
@Override
public List<DvMachineryType> selectDvMachineryTypeList(DvMachineryType dvMachineryType)
{
return dvMachineryTypeMapper.selectDvMachineryTypeList(dvMachineryType);
}
/**
* 新增设备类型
*
* @param dvMachineryType 设备类型
* @return 结果
*/
@Override
public int insertDvMachineryType(DvMachineryType dvMachineryType)
{
if(dvMachineryType.getParentTypeId()!= null){
DvMachineryType parent = dvMachineryTypeMapper.selectDvMachineryTypeByMachineryTypeId(dvMachineryType.getParentTypeId());
if(StringUtils.isNotNull(parent)){
dvMachineryType.setAncestors(parent.getAncestors()+","+parent.getMachineryTypeId());
}
}
dvMachineryType.setCreateTime(DateUtils.getNowDate());
return dvMachineryTypeMapper.insertDvMachineryType(dvMachineryType);
}
/**
* 修改设备类型
*
* @param dvMachineryType 设备类型
* @return 结果
*/
@Override
public int updateDvMachineryType(DvMachineryType dvMachineryType)
{
dvMachineryType.setUpdateTime(DateUtils.getNowDate());
return dvMachineryTypeMapper.updateDvMachineryType(dvMachineryType);
}
/**
* 批量删除设备类型
*
* @param machineryTypeIds 需要删除的设备类型主键
* @return 结果
*/
@Override
public int deleteDvMachineryTypeByMachineryTypeIds(Long[] machineryTypeIds)
{
return dvMachineryTypeMapper.deleteDvMachineryTypeByMachineryTypeIds(machineryTypeIds);
}
/**
* 删除设备类型信息
*
* @param machineryTypeId 设备类型主键
* @return 结果
*/
@Override
public int deleteDvMachineryTypeByMachineryTypeId(Long machineryTypeId)
{
return dvMachineryTypeMapper.deleteDvMachineryTypeByMachineryTypeId(machineryTypeId);
}
}

View File

@ -0,0 +1,112 @@
<?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.ktg.mes.dv.mapper.DvMachineryTypeMapper">
<resultMap type="DvMachineryType" id="DvMachineryTypeResult">
<result property="machineryTypeId" column="machinery_type_id" />
<result property="machineryTypeCode" column="machinery_type_code" />
<result property="machineryTypeName" column="machinery_type_name" />
<result property="parentTypeId" column="parent_type_id" />
<result property="ancestors" column="ancestors" />
<result property="enableFlag" column="enable_flag" />
<result property="remark" column="remark" />
<result property="attr1" column="attr1" />
<result property="attr2" column="attr2" />
<result property="attr3" column="attr3" />
<result property="attr4" column="attr4" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectDvMachineryTypeVo">
select machinery_type_id, machinery_type_code, machinery_type_name, parent_type_id, ancestors, enable_flag, remark, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time from dv_machinery_type
</sql>
<select id="selectDvMachineryTypeList" parameterType="DvMachineryType" resultMap="DvMachineryTypeResult">
<include refid="selectDvMachineryTypeVo"/>
<where>
<if test="machineryTypeCode != null and machineryTypeCode != ''"> and machinery_type_code = #{machineryTypeCode}</if>
<if test="machineryTypeName != null and machineryTypeName != ''"> and machinery_type_name like concat('%', #{machineryTypeName}, '%')</if>
<if test="parentTypeId != null "> and parent_type_id = #{parentTypeId}</if>
<if test="ancestors != null and ancestors != ''"> and ancestors = #{ancestors}</if>
<if test="enableFlag != null and enableFlag != ''"> and enable_flag = #{enableFlag}</if>
</where>
</select>
<select id="selectDvMachineryTypeByMachineryTypeId" parameterType="Long" resultMap="DvMachineryTypeResult">
<include refid="selectDvMachineryTypeVo"/>
where machinery_type_id = #{machineryTypeId}
</select>
<insert id="insertDvMachineryType" parameterType="DvMachineryType" useGeneratedKeys="true" keyProperty="machineryTypeId">
insert into dv_machinery_type
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="machineryTypeCode != null and machineryTypeCode != ''">machinery_type_code,</if>
<if test="machineryTypeName != null and machineryTypeName != ''">machinery_type_name,</if>
<if test="parentTypeId != null">parent_type_id,</if>
<if test="ancestors != null and ancestors != ''">ancestors,</if>
<if test="enableFlag != null and enableFlag != ''">enable_flag,</if>
<if test="remark != null">remark,</if>
<if test="attr1 != null">attr1,</if>
<if test="attr2 != null">attr2,</if>
<if test="attr3 != null">attr3,</if>
<if test="attr4 != null">attr4,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="machineryTypeCode != null and machineryTypeCode != ''">#{machineryTypeCode},</if>
<if test="machineryTypeName != null and machineryTypeName != ''">#{machineryTypeName},</if>
<if test="parentTypeId != null">#{parentTypeId},</if>
<if test="ancestors != null and ancestors != ''">#{ancestors},</if>
<if test="enableFlag != null and enableFlag != ''">#{enableFlag},</if>
<if test="remark != null">#{remark},</if>
<if test="attr1 != null">#{attr1},</if>
<if test="attr2 != null">#{attr2},</if>
<if test="attr3 != null">#{attr3},</if>
<if test="attr4 != null">#{attr4},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateDvMachineryType" parameterType="DvMachineryType">
update dv_machinery_type
<trim prefix="SET" suffixOverrides=",">
<if test="machineryTypeCode != null and machineryTypeCode != ''">machinery_type_code = #{machineryTypeCode},</if>
<if test="machineryTypeName != null and machineryTypeName != ''">machinery_type_name = #{machineryTypeName},</if>
<if test="parentTypeId != null">parent_type_id = #{parentTypeId},</if>
<if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if>
<if test="enableFlag != null and enableFlag != ''">enable_flag = #{enableFlag},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="attr1 != null">attr1 = #{attr1},</if>
<if test="attr2 != null">attr2 = #{attr2},</if>
<if test="attr3 != null">attr3 = #{attr3},</if>
<if test="attr4 != null">attr4 = #{attr4},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where machinery_type_id = #{machineryTypeId}
</update>
<delete id="deleteDvMachineryTypeByMachineryTypeId" parameterType="Long">
delete from dv_machinery_type where machinery_type_id = #{machineryTypeId}
</delete>
<delete id="deleteDvMachineryTypeByMachineryTypeIds" parameterType="String">
delete from dv_machinery_type where machinery_type_id in
<foreach item="machineryTypeId" collection="array" open="(" separator="," close=")">
#{machineryTypeId}
</foreach>
</delete>
</mapper>