常见缺陷

This commit is contained in:
JinLu.Yin 2022-05-19 14:43:04 +08:00
parent 8288d2f136
commit ea41209da4
7 changed files with 587 additions and 0 deletions

View File

@ -83,6 +83,7 @@ public class UserConstants
public static final String ITEM_CODE ="ITEM_CODE";
public static final String MACHINERY_TYPE_CODE="MACHINERY_TYPE_CODE";
public static final String TASK_CODE="TASK_CODE";
public static final String DEFECT_CODE = "DEFECT_CODE";
/**

View File

@ -0,0 +1,111 @@
package com.ktg.mes.qc.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.qc.domain.QcDefect;
import com.ktg.mes.qc.service.IQcDefectService;
import com.ktg.common.utils.poi.ExcelUtil;
import com.ktg.common.core.page.TableDataInfo;
/**
* 常见缺陷Controller
*
* @author yinjinlu
* @date 2022-05-19
*/
@RestController
@RequestMapping("/mes/qc/qcdefect")
public class QcDefectController extends BaseController
{
@Autowired
private IQcDefectService qcDefectService;
@Autowired
private AutoCodeUtil autoCodeUtil;
/**
* 查询常见缺陷列表
*/
@PreAuthorize("@ss.hasPermi('mes:qc:qcdefect:list')")
@GetMapping("/list")
public TableDataInfo list(QcDefect qcDefect)
{
startPage();
List<QcDefect> list = qcDefectService.selectQcDefectList(qcDefect);
return getDataTable(list);
}
/**
* 导出常见缺陷列表
*/
@PreAuthorize("@ss.hasPermi('mes:qc:qcdefect:export')")
@Log(title = "常见缺陷", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, QcDefect qcDefect)
{
List<QcDefect> list = qcDefectService.selectQcDefectList(qcDefect);
ExcelUtil<QcDefect> util = new ExcelUtil<QcDefect>(QcDefect.class);
util.exportExcel(response, list, "常见缺陷数据");
}
/**
* 获取常见缺陷详细信息
*/
@PreAuthorize("@ss.hasPermi('mes:qc:qcdefect:query')")
@GetMapping(value = "/{defectId}")
public AjaxResult getInfo(@PathVariable("defectId") Long defectId)
{
return AjaxResult.success(qcDefectService.selectQcDefectByDefectId(defectId));
}
/**
* 新增常见缺陷
*/
@PreAuthorize("@ss.hasPermi('mes:qc:qcdefect:add')")
@Log(title = "常见缺陷", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody QcDefect qcDefect)
{
qcDefect.setDefectCode(autoCodeUtil.genSerialCode(UserConstants.DEFECT_CODE,null));
return toAjax(qcDefectService.insertQcDefect(qcDefect));
}
/**
* 修改常见缺陷
*/
@PreAuthorize("@ss.hasPermi('mes:qc:qcdefect:edit')")
@Log(title = "常见缺陷", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody QcDefect qcDefect)
{
return toAjax(qcDefectService.updateQcDefect(qcDefect));
}
/**
* 删除常见缺陷
*/
@PreAuthorize("@ss.hasPermi('mes:qc:qcdefect:remove')")
@Log(title = "常见缺陷", businessType = BusinessType.DELETE)
@DeleteMapping("/{defectIds}")
public AjaxResult remove(@PathVariable Long[] defectIds)
{
return toAjax(qcDefectService.deleteQcDefectByDefectIds(defectIds));
}
}

View File

@ -0,0 +1,150 @@
package com.ktg.mes.qc.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;
/**
* 常见缺陷对象 qc_defect
*
* @author yinjinlu
* @date 2022-05-19
*/
public class QcDefect extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 缺陷ID */
private Long defectId;
/** 缺陷编码 */
@Excel(name = "缺陷编码")
private String defectCode;
/** 缺陷描述 */
@Excel(name = "缺陷描述")
private String defectName;
/** 检测项类型 */
@Excel(name = "检测项类型")
private String indexType;
/** 缺陷等级 */
@Excel(name = "缺陷等级")
private String defectLevel;
/** 预留字段1 */
private String attr1;
/** 预留字段2 */
private String attr2;
/** 预留字段3 */
private Long attr3;
/** 预留字段4 */
private Long attr4;
public void setDefectId(Long defectId)
{
this.defectId = defectId;
}
public Long getDefectId()
{
return defectId;
}
public void setDefectCode(String defectCode)
{
this.defectCode = defectCode;
}
public String getDefectCode()
{
return defectCode;
}
public void setDefectName(String defectName)
{
this.defectName = defectName;
}
public String getDefectName()
{
return defectName;
}
public void setIndexType(String indexType)
{
this.indexType = indexType;
}
public String getIndexType()
{
return indexType;
}
public void setDefectLevel(String defectLevel)
{
this.defectLevel = defectLevel;
}
public String getDefectLevel()
{
return defectLevel;
}
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("defectId", getDefectId())
.append("defectCode", getDefectCode())
.append("defectName", getDefectName())
.append("indexType", getIndexType())
.append("defectLevel", getDefectLevel())
.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.qc.mapper;
import java.util.List;
import com.ktg.mes.qc.domain.QcDefect;
/**
* 常见缺陷Mapper接口
*
* @author yinjinlu
* @date 2022-05-19
*/
public interface QcDefectMapper
{
/**
* 查询常见缺陷
*
* @param defectId 常见缺陷主键
* @return 常见缺陷
*/
public QcDefect selectQcDefectByDefectId(Long defectId);
/**
* 查询常见缺陷列表
*
* @param qcDefect 常见缺陷
* @return 常见缺陷集合
*/
public List<QcDefect> selectQcDefectList(QcDefect qcDefect);
/**
* 新增常见缺陷
*
* @param qcDefect 常见缺陷
* @return 结果
*/
public int insertQcDefect(QcDefect qcDefect);
/**
* 修改常见缺陷
*
* @param qcDefect 常见缺陷
* @return 结果
*/
public int updateQcDefect(QcDefect qcDefect);
/**
* 删除常见缺陷
*
* @param defectId 常见缺陷主键
* @return 结果
*/
public int deleteQcDefectByDefectId(Long defectId);
/**
* 批量删除常见缺陷
*
* @param defectIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteQcDefectByDefectIds(Long[] defectIds);
}

View File

@ -0,0 +1,61 @@
package com.ktg.mes.qc.service;
import java.util.List;
import com.ktg.mes.qc.domain.QcDefect;
/**
* 常见缺陷Service接口
*
* @author yinjinlu
* @date 2022-05-19
*/
public interface IQcDefectService
{
/**
* 查询常见缺陷
*
* @param defectId 常见缺陷主键
* @return 常见缺陷
*/
public QcDefect selectQcDefectByDefectId(Long defectId);
/**
* 查询常见缺陷列表
*
* @param qcDefect 常见缺陷
* @return 常见缺陷集合
*/
public List<QcDefect> selectQcDefectList(QcDefect qcDefect);
/**
* 新增常见缺陷
*
* @param qcDefect 常见缺陷
* @return 结果
*/
public int insertQcDefect(QcDefect qcDefect);
/**
* 修改常见缺陷
*
* @param qcDefect 常见缺陷
* @return 结果
*/
public int updateQcDefect(QcDefect qcDefect);
/**
* 批量删除常见缺陷
*
* @param defectIds 需要删除的常见缺陷主键集合
* @return 结果
*/
public int deleteQcDefectByDefectIds(Long[] defectIds);
/**
* 删除常见缺陷信息
*
* @param defectId 常见缺陷主键
* @return 结果
*/
public int deleteQcDefectByDefectId(Long defectId);
}

View File

@ -0,0 +1,96 @@
package com.ktg.mes.qc.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.qc.mapper.QcDefectMapper;
import com.ktg.mes.qc.domain.QcDefect;
import com.ktg.mes.qc.service.IQcDefectService;
/**
* 常见缺陷Service业务层处理
*
* @author yinjinlu
* @date 2022-05-19
*/
@Service
public class QcDefectServiceImpl implements IQcDefectService
{
@Autowired
private QcDefectMapper qcDefectMapper;
/**
* 查询常见缺陷
*
* @param defectId 常见缺陷主键
* @return 常见缺陷
*/
@Override
public QcDefect selectQcDefectByDefectId(Long defectId)
{
return qcDefectMapper.selectQcDefectByDefectId(defectId);
}
/**
* 查询常见缺陷列表
*
* @param qcDefect 常见缺陷
* @return 常见缺陷
*/
@Override
public List<QcDefect> selectQcDefectList(QcDefect qcDefect)
{
return qcDefectMapper.selectQcDefectList(qcDefect);
}
/**
* 新增常见缺陷
*
* @param qcDefect 常见缺陷
* @return 结果
*/
@Override
public int insertQcDefect(QcDefect qcDefect)
{
qcDefect.setCreateTime(DateUtils.getNowDate());
return qcDefectMapper.insertQcDefect(qcDefect);
}
/**
* 修改常见缺陷
*
* @param qcDefect 常见缺陷
* @return 结果
*/
@Override
public int updateQcDefect(QcDefect qcDefect)
{
qcDefect.setUpdateTime(DateUtils.getNowDate());
return qcDefectMapper.updateQcDefect(qcDefect);
}
/**
* 批量删除常见缺陷
*
* @param defectIds 需要删除的常见缺陷主键
* @return 结果
*/
@Override
public int deleteQcDefectByDefectIds(Long[] defectIds)
{
return qcDefectMapper.deleteQcDefectByDefectIds(defectIds);
}
/**
* 删除常见缺陷信息
*
* @param defectId 常见缺陷主键
* @return 结果
*/
@Override
public int deleteQcDefectByDefectId(Long defectId)
{
return qcDefectMapper.deleteQcDefectByDefectId(defectId);
}
}

View File

@ -0,0 +1,107 @@
<?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.qc.mapper.QcDefectMapper">
<resultMap type="QcDefect" id="QcDefectResult">
<result property="defectId" column="defect_id" />
<result property="defectCode" column="defect_code" />
<result property="defectName" column="defect_name" />
<result property="indexType" column="index_type" />
<result property="defectLevel" column="defect_level" />
<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="selectQcDefectVo">
select defect_id, defect_code, defect_name, index_type, defect_level, remark, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time from qc_defect
</sql>
<select id="selectQcDefectList" parameterType="QcDefect" resultMap="QcDefectResult">
<include refid="selectQcDefectVo"/>
<where>
<if test="defectCode != null and defectCode != ''"> and defect_code = #{defectCode}</if>
<if test="defectName != null and defectName != ''"> and defect_name like concat('%', #{defectName}, '%')</if>
<if test="indexType != null and indexType != ''"> and index_type = #{indexType}</if>
<if test="defectLevel != null and defectLevel != ''"> and defect_level = #{defectLevel}</if>
</where>
</select>
<select id="selectQcDefectByDefectId" parameterType="Long" resultMap="QcDefectResult">
<include refid="selectQcDefectVo"/>
where defect_id = #{defectId}
</select>
<insert id="insertQcDefect" parameterType="QcDefect" useGeneratedKeys="true" keyProperty="defectId">
insert into qc_defect
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="defectCode != null and defectCode != ''">defect_code,</if>
<if test="defectName != null and defectName != ''">defect_name,</if>
<if test="indexType != null and indexType != ''">index_type,</if>
<if test="defectLevel != null and defectLevel != ''">defect_level,</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="defectCode != null and defectCode != ''">#{defectCode},</if>
<if test="defectName != null and defectName != ''">#{defectName},</if>
<if test="indexType != null and indexType != ''">#{indexType},</if>
<if test="defectLevel != null and defectLevel != ''">#{defectLevel},</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="updateQcDefect" parameterType="QcDefect">
update qc_defect
<trim prefix="SET" suffixOverrides=",">
<if test="defectCode != null and defectCode != ''">defect_code = #{defectCode},</if>
<if test="defectName != null and defectName != ''">defect_name = #{defectName},</if>
<if test="indexType != null and indexType != ''">index_type = #{indexType},</if>
<if test="defectLevel != null and defectLevel != ''">defect_level = #{defectLevel},</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 defect_id = #{defectId}
</update>
<delete id="deleteQcDefectByDefectId" parameterType="Long">
delete from qc_defect where defect_id = #{defectId}
</delete>
<delete id="deleteQcDefectByDefectIds" parameterType="String">
delete from qc_defect where defect_id in
<foreach item="defectId" collection="array" open="(" separator="," close=")">
#{defectId}
</foreach>
</delete>
</mapper>