设备台账

This commit is contained in:
JinLu.Yin 2022-05-08 22:54:55 +08:00
parent 7a67a2bf69
commit ddcef9c8a2
7 changed files with 733 additions and 6 deletions

View File

@ -0,0 +1,104 @@
package com.ktg.mes.dv.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.DvMachinery;
import com.ktg.mes.dv.service.IDvMachineryService;
import com.ktg.common.utils.poi.ExcelUtil;
import com.ktg.common.core.page.TableDataInfo;
/**
* 设备Controller
*
* @author yinjinlu
* @date 2022-05-08
*/
@RestController
@RequestMapping("/mes/dv/machinery")
public class DvMachineryController extends BaseController
{
@Autowired
private IDvMachineryService dvMachineryService;
/**
* 查询设备列表
*/
@PreAuthorize("@ss.hasPermi('mes:dv:machinery:list')")
@GetMapping("/list")
public TableDataInfo list(DvMachinery dvMachinery)
{
startPage();
List<DvMachinery> list = dvMachineryService.selectDvMachineryList(dvMachinery);
return getDataTable(list);
}
/**
* 导出设备列表
*/
@PreAuthorize("@ss.hasPermi('mes:dv:machinery:export')")
@Log(title = "设备", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DvMachinery dvMachinery)
{
List<DvMachinery> list = dvMachineryService.selectDvMachineryList(dvMachinery);
ExcelUtil<DvMachinery> util = new ExcelUtil<DvMachinery>(DvMachinery.class);
util.exportExcel(response, list, "设备数据");
}
/**
* 获取设备详细信息
*/
@PreAuthorize("@ss.hasPermi('mes:dv:machinery:query')")
@GetMapping(value = "/{machineryId}")
public AjaxResult getInfo(@PathVariable("machineryId") Long machineryId)
{
return AjaxResult.success(dvMachineryService.selectDvMachineryByMachineryId(machineryId));
}
/**
* 新增设备
*/
@PreAuthorize("@ss.hasPermi('mes:dv:machinery:add')")
@Log(title = "设备", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DvMachinery dvMachinery)
{
return toAjax(dvMachineryService.insertDvMachinery(dvMachinery));
}
/**
* 修改设备
*/
@PreAuthorize("@ss.hasPermi('mes:dv:machinery:edit')")
@Log(title = "设备", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DvMachinery dvMachinery)
{
return toAjax(dvMachineryService.updateDvMachinery(dvMachinery));
}
/**
* 删除设备
*/
@PreAuthorize("@ss.hasPermi('mes:dv:machinery:remove')")
@Log(title = "设备", businessType = BusinessType.DELETE)
@DeleteMapping("/{machineryIds}")
public AjaxResult remove(@PathVariable Long[] machineryIds)
{
return toAjax(dvMachineryService.deleteDvMachineryByMachineryIds(machineryIds));
}
}

View File

@ -0,0 +1,248 @@
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.BaseEntity;
/**
* 设备对象 dv_machinery
*
* @author yinjinlu
* @date 2022-05-08
*/
public class DvMachinery extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 设备类型ID */
private Long machineryId;
/** 设备类型编码 */
@Excel(name = "设备类型编码")
private String machineryCode;
/** 设备类型名称 */
@Excel(name = "设备类型名称")
private String machineryName;
/** 品牌 */
@Excel(name = "品牌")
private String machineryBrand;
/** 规格型号 */
@Excel(name = "规格型号")
private String machinerySpec;
/** 设备类型ID */
@Excel(name = "设备类型ID")
private Long machineryTypeId;
/** 设备类型编码 */
@Excel(name = "设备类型编码")
private String machineryTypeCode;
/** 设备类型名称 */
@Excel(name = "设备类型名称")
private String machineryTypeName;
/** 所属车间ID */
@Excel(name = "所属车间ID")
private Long workshopId;
/** 所属车间编码 */
@Excel(name = "所属车间编码")
private String workshopCode;
/** 所属车间名称 */
@Excel(name = "所属车间名称")
private String workshopName;
/** 设备状态 */
@Excel(name = "设备状态")
private String status;
/** 预留字段1 */
private String attr1;
/** 预留字段2 */
private String attr2;
/** 预留字段3 */
private Long attr3;
/** 预留字段4 */
private Long attr4;
public void setMachineryId(Long machineryId)
{
this.machineryId = machineryId;
}
public Long getMachineryId()
{
return machineryId;
}
public void setMachineryCode(String machineryCode)
{
this.machineryCode = machineryCode;
}
public String getMachineryCode()
{
return machineryCode;
}
public void setMachineryName(String machineryName)
{
this.machineryName = machineryName;
}
public String getMachineryName()
{
return machineryName;
}
public void setMachineryBrand(String machineryBrand)
{
this.machineryBrand = machineryBrand;
}
public String getMachineryBrand()
{
return machineryBrand;
}
public void setMachinerySpec(String machinerySpec)
{
this.machinerySpec = machinerySpec;
}
public String getMachinerySpec()
{
return machinerySpec;
}
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 setWorkshopId(Long workshopId)
{
this.workshopId = workshopId;
}
public Long getWorkshopId()
{
return workshopId;
}
public void setWorkshopCode(String workshopCode)
{
this.workshopCode = workshopCode;
}
public String getWorkshopCode()
{
return workshopCode;
}
public void setWorkshopName(String workshopName)
{
this.workshopName = workshopName;
}
public String getWorkshopName()
{
return workshopName;
}
public void setStatus(String status)
{
this.status = status;
}
public String getStatus()
{
return status;
}
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("machineryId", getMachineryId())
.append("machineryCode", getMachineryCode())
.append("machineryName", getMachineryName())
.append("machineryBrand", getMachineryBrand())
.append("machinerySpec", getMachinerySpec())
.append("machineryTypeId", getMachineryTypeId())
.append("machineryTypeCode", getMachineryTypeCode())
.append("machineryTypeName", getMachineryTypeName())
.append("workshopId", getWorkshopId())
.append("workshopCode", getWorkshopCode())
.append("workshopName", getWorkshopName())
.append("status", getStatus())
.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.DvMachinery;
/**
* 设备Mapper接口
*
* @author yinjinlu
* @date 2022-05-08
*/
public interface DvMachineryMapper
{
/**
* 查询设备
*
* @param machineryId 设备主键
* @return 设备
*/
public DvMachinery selectDvMachineryByMachineryId(Long machineryId);
/**
* 查询设备列表
*
* @param dvMachinery 设备
* @return 设备集合
*/
public List<DvMachinery> selectDvMachineryList(DvMachinery dvMachinery);
/**
* 新增设备
*
* @param dvMachinery 设备
* @return 结果
*/
public int insertDvMachinery(DvMachinery dvMachinery);
/**
* 修改设备
*
* @param dvMachinery 设备
* @return 结果
*/
public int updateDvMachinery(DvMachinery dvMachinery);
/**
* 删除设备
*
* @param machineryId 设备主键
* @return 结果
*/
public int deleteDvMachineryByMachineryId(Long machineryId);
/**
* 批量删除设备
*
* @param machineryIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteDvMachineryByMachineryIds(Long[] machineryIds);
}

View File

@ -0,0 +1,61 @@
package com.ktg.mes.dv.service;
import java.util.List;
import com.ktg.mes.dv.domain.DvMachinery;
/**
* 设备Service接口
*
* @author yinjinlu
* @date 2022-05-08
*/
public interface IDvMachineryService
{
/**
* 查询设备
*
* @param machineryId 设备主键
* @return 设备
*/
public DvMachinery selectDvMachineryByMachineryId(Long machineryId);
/**
* 查询设备列表
*
* @param dvMachinery 设备
* @return 设备集合
*/
public List<DvMachinery> selectDvMachineryList(DvMachinery dvMachinery);
/**
* 新增设备
*
* @param dvMachinery 设备
* @return 结果
*/
public int insertDvMachinery(DvMachinery dvMachinery);
/**
* 修改设备
*
* @param dvMachinery 设备
* @return 结果
*/
public int updateDvMachinery(DvMachinery dvMachinery);
/**
* 批量删除设备
*
* @param machineryIds 需要删除的设备主键集合
* @return 结果
*/
public int deleteDvMachineryByMachineryIds(Long[] machineryIds);
/**
* 删除设备信息
*
* @param machineryId 设备主键
* @return 结果
*/
public int deleteDvMachineryByMachineryId(Long machineryId);
}

View File

@ -0,0 +1,96 @@
package com.ktg.mes.dv.service.impl;
import java.util.List;
import com.ktg.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ktg.mes.dv.mapper.DvMachineryMapper;
import com.ktg.mes.dv.domain.DvMachinery;
import com.ktg.mes.dv.service.IDvMachineryService;
/**
* 设备Service业务层处理
*
* @author yinjinlu
* @date 2022-05-08
*/
@Service
public class DvMachineryServiceImpl implements IDvMachineryService
{
@Autowired
private DvMachineryMapper dvMachineryMapper;
/**
* 查询设备
*
* @param machineryId 设备主键
* @return 设备
*/
@Override
public DvMachinery selectDvMachineryByMachineryId(Long machineryId)
{
return dvMachineryMapper.selectDvMachineryByMachineryId(machineryId);
}
/**
* 查询设备列表
*
* @param dvMachinery 设备
* @return 设备
*/
@Override
public List<DvMachinery> selectDvMachineryList(DvMachinery dvMachinery)
{
return dvMachineryMapper.selectDvMachineryList(dvMachinery);
}
/**
* 新增设备
*
* @param dvMachinery 设备
* @return 结果
*/
@Override
public int insertDvMachinery(DvMachinery dvMachinery)
{
dvMachinery.setCreateTime(DateUtils.getNowDate());
return dvMachineryMapper.insertDvMachinery(dvMachinery);
}
/**
* 修改设备
*
* @param dvMachinery 设备
* @return 结果
*/
@Override
public int updateDvMachinery(DvMachinery dvMachinery)
{
dvMachinery.setUpdateTime(DateUtils.getNowDate());
return dvMachineryMapper.updateDvMachinery(dvMachinery);
}
/**
* 批量删除设备
*
* @param machineryIds 需要删除的设备主键
* @return 结果
*/
@Override
public int deleteDvMachineryByMachineryIds(Long[] machineryIds)
{
return dvMachineryMapper.deleteDvMachineryByMachineryIds(machineryIds);
}
/**
* 删除设备信息
*
* @param machineryId 设备主键
* @return 结果
*/
@Override
public int deleteDvMachineryByMachineryId(Long machineryId)
{
return dvMachineryMapper.deleteDvMachineryByMachineryId(machineryId);
}
}

View File

@ -39,7 +39,7 @@ public class MdWorkshopController extends BaseController
/**
* 查询车间列表
*/
@PreAuthorize("@ss.hasPermi('md:workshop:list')")
@PreAuthorize("@ss.hasPermi('mes:md:workshop:list')")
@GetMapping("/list")
public TableDataInfo list(MdWorkshop mdWorkshop)
{
@ -48,10 +48,23 @@ public class MdWorkshopController extends BaseController
return getDataTable(list);
}
/**
* 获取所有可用车间
* @return
*/
@PreAuthorize("@ss.hasPermi('mes:md:workshop:list')")
@GetMapping("/listAll")
public AjaxResult listAll(){
MdWorkshop mdWorkshop = new MdWorkshop();
mdWorkshop.setEnableFlag("Y");
List<MdWorkshop> list = mdWorkshopService.selectMdWorkshopList(mdWorkshop);
return AjaxResult.success(list);
}
/**
* 导出车间列表
*/
@PreAuthorize("@ss.hasPermi('md:workshop:export')")
@PreAuthorize("@ss.hasPermi('mes:md:workshop:export')")
@Log(title = "车间", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, MdWorkshop mdWorkshop)
@ -64,7 +77,7 @@ public class MdWorkshopController extends BaseController
/**
* 获取车间详细信息
*/
@PreAuthorize("@ss.hasPermi('md:workshop:query')")
@PreAuthorize("@ss.hasPermi('mes:md:workshop:query')")
@GetMapping(value = "/{workshopId}")
public AjaxResult getInfo(@PathVariable("workshopId") Long workshopId)
{
@ -74,7 +87,7 @@ public class MdWorkshopController extends BaseController
/**
* 新增车间
*/
@PreAuthorize("@ss.hasPermi('md:workshop:add')")
@PreAuthorize("@ss.hasPermi('mes:md:workshop:add')")
@Log(title = "车间", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody MdWorkshop mdWorkshop)
@ -91,7 +104,7 @@ public class MdWorkshopController extends BaseController
/**
* 修改车间
*/
@PreAuthorize("@ss.hasPermi('md:workshop:edit')")
@PreAuthorize("@ss.hasPermi('mes:md:workshop:edit')")
@Log(title = "车间", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody MdWorkshop mdWorkshop)
@ -108,7 +121,7 @@ public class MdWorkshopController extends BaseController
/**
* 删除车间
*/
@PreAuthorize("@ss.hasPermi('md:workshop:remove')")
@PreAuthorize("@ss.hasPermi('mes:md:workshop:remove')")
@Log(title = "车间", businessType = BusinessType.DELETE)
@DeleteMapping("/{workshopIds}")
public AjaxResult remove(@PathVariable Long[] workshopIds)

View File

@ -0,0 +1,144 @@
<?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.DvMachineryMapper">
<resultMap type="DvMachinery" id="DvMachineryResult">
<result property="machineryId" column="machinery_id" />
<result property="machineryCode" column="machinery_code" />
<result property="machineryName" column="machinery_name" />
<result property="machineryBrand" column="machinery_brand" />
<result property="machinerySpec" column="machinery_spec" />
<result property="machineryTypeId" column="machinery_type_id" />
<result property="machineryTypeCode" column="machinery_type_code" />
<result property="machineryTypeName" column="machinery_type_name" />
<result property="workshopId" column="workshop_id" />
<result property="workshopCode" column="workshop_code" />
<result property="workshopName" column="workshop_name" />
<result property="status" column="status" />
<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="selectDvMachineryVo">
select machinery_id, machinery_code, machinery_name, machinery_brand, machinery_spec, machinery_type_id, machinery_type_code, machinery_type_name, workshop_id, workshop_code, workshop_name, status, remark, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time from dv_machinery
</sql>
<select id="selectDvMachineryList" parameterType="DvMachinery" resultMap="DvMachineryResult">
<include refid="selectDvMachineryVo"/>
<where>
<if test="machineryCode != null and machineryCode != ''"> and machinery_code = #{machineryCode}</if>
<if test="machineryName != null and machineryName != ''"> and machinery_name like concat('%', #{machineryName}, '%')</if>
<if test="machineryBrand != null and machineryBrand != ''"> and machinery_brand = #{machineryBrand}</if>
<if test="machinerySpec != null and machinerySpec != ''"> and machinery_spec = #{machinerySpec}</if>
<if test="machineryTypeId != null ">
AND (machinery_type_id = #{machineryTypeId} OR machinery_type_id in (select machinery_type_id from dv_machinery_type where find_in_set(#{machineryTypeId},ancestors)))
</if>
<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="workshopId != null "> and workshop_id = #{workshopId}</if>
<if test="workshopCode != null and workshopCode != ''"> and workshop_code = #{workshopCode}</if>
<if test="workshopName != null and workshopName != ''"> and workshop_name like concat('%', #{workshopName}, '%')</if>
<if test="status != null and status != ''"> and status = #{status}</if>
</where>
</select>
<select id="selectDvMachineryByMachineryId" parameterType="Long" resultMap="DvMachineryResult">
<include refid="selectDvMachineryVo"/>
where machinery_id = #{machineryId}
</select>
<insert id="insertDvMachinery" parameterType="DvMachinery" useGeneratedKeys="true" keyProperty="machineryId">
insert into dv_machinery
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="machineryCode != null and machineryCode != ''">machinery_code,</if>
<if test="machineryName != null and machineryName != ''">machinery_name,</if>
<if test="machineryBrand != null">machinery_brand,</if>
<if test="machinerySpec != null">machinery_spec,</if>
<if test="machineryTypeId != null">machinery_type_id,</if>
<if test="machineryTypeCode != null">machinery_type_code,</if>
<if test="machineryTypeName != null">machinery_type_name,</if>
<if test="workshopId != null">workshop_id,</if>
<if test="workshopCode != null">workshop_code,</if>
<if test="workshopName != null">workshop_name,</if>
<if test="status != null and status != ''">status,</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="machineryCode != null and machineryCode != ''">#{machineryCode},</if>
<if test="machineryName != null and machineryName != ''">#{machineryName},</if>
<if test="machineryBrand != null">#{machineryBrand},</if>
<if test="machinerySpec != null">#{machinerySpec},</if>
<if test="machineryTypeId != null">#{machineryTypeId},</if>
<if test="machineryTypeCode != null">#{machineryTypeCode},</if>
<if test="machineryTypeName != null">#{machineryTypeName},</if>
<if test="workshopId != null">#{workshopId},</if>
<if test="workshopCode != null">#{workshopCode},</if>
<if test="workshopName != null">#{workshopName},</if>
<if test="status != null and status != ''">#{status},</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="updateDvMachinery" parameterType="DvMachinery">
update dv_machinery
<trim prefix="SET" suffixOverrides=",">
<if test="machineryCode != null and machineryCode != ''">machinery_code = #{machineryCode},</if>
<if test="machineryName != null and machineryName != ''">machinery_name = #{machineryName},</if>
<if test="machineryBrand != null">machinery_brand = #{machineryBrand},</if>
<if test="machinerySpec != null">machinery_spec = #{machinerySpec},</if>
<if test="machineryTypeId != null">machinery_type_id = #{machineryTypeId},</if>
<if test="machineryTypeCode != null">machinery_type_code = #{machineryTypeCode},</if>
<if test="machineryTypeName != null">machinery_type_name = #{machineryTypeName},</if>
<if test="workshopId != null">workshop_id = #{workshopId},</if>
<if test="workshopCode != null">workshop_code = #{workshopCode},</if>
<if test="workshopName != null">workshop_name = #{workshopName},</if>
<if test="status != null and status != ''">status = #{status},</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_id = #{machineryId}
</update>
<delete id="deleteDvMachineryByMachineryId" parameterType="Long">
delete from dv_machinery where machinery_id = #{machineryId}
</delete>
<delete id="deleteDvMachineryByMachineryIds" parameterType="String">
delete from dv_machinery where machinery_id in
<foreach item="machineryId" collection="array" open="(" separator="," close=")">
#{machineryId}
</foreach>
</delete>
</mapper>