质量检验-检验项

This commit is contained in:
JinLu.Yin 2022-05-17 21:40:54 +08:00
parent 0c0f91bcfa
commit 6c8a0a6e8e
6 changed files with 647 additions and 0 deletions

View File

@ -0,0 +1,118 @@
package com.ktg.mes.qc.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.ktg.common.constant.UserConstants;
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.QcIndex;
import com.ktg.mes.qc.service.IQcIndexService;
import com.ktg.common.utils.poi.ExcelUtil;
import com.ktg.common.core.page.TableDataInfo;
/**
* 检测项Controller
*
* @author yinjinlu
* @date 2022-05-17
*/
@RestController
@RequestMapping("/mes/qc/qcindex")
public class QcIndexController extends BaseController
{
@Autowired
private IQcIndexService qcIndexService;
/**
* 查询检测项列表
*/
@PreAuthorize("@ss.hasPermi('mes:qc:qcindex:list')")
@GetMapping("/list")
public TableDataInfo list(QcIndex qcIndex)
{
startPage();
List<QcIndex> list = qcIndexService.selectQcIndexList(qcIndex);
return getDataTable(list);
}
/**
* 导出检测项列表
*/
@PreAuthorize("@ss.hasPermi('mes:qc:qcindex:export')")
@Log(title = "检测项", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, QcIndex qcIndex)
{
List<QcIndex> list = qcIndexService.selectQcIndexList(qcIndex);
ExcelUtil<QcIndex> util = new ExcelUtil<QcIndex>(QcIndex.class);
util.exportExcel(response, list, "检测项数据");
}
/**
* 获取检测项详细信息
*/
@PreAuthorize("@ss.hasPermi('mes:qc:qcindex:query')")
@GetMapping(value = "/{indexId}")
public AjaxResult getInfo(@PathVariable("indexId") Long indexId)
{
return AjaxResult.success(qcIndexService.selectQcIndexByIndexId(indexId));
}
/**
* 新增检测项
*/
@PreAuthorize("@ss.hasPermi('mes:qc:qcindex:add')")
@Log(title = "检测项", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody QcIndex qcIndex)
{
if(UserConstants.NOT_UNIQUE.equals(qcIndexService.checkIndexCodeUnique(qcIndex))){
return AjaxResult.error("检测项编号已存在!");
}
if(UserConstants.NOT_UNIQUE.equals(qcIndexService.checkIndexNameUnique(qcIndex))){
return AjaxResult.error("检测项名称已存在!");
}
return toAjax(qcIndexService.insertQcIndex(qcIndex));
}
/**
* 修改检测项
*/
@PreAuthorize("@ss.hasPermi('mes:qc:qcindex:edit')")
@Log(title = "检测项", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody QcIndex qcIndex)
{
if(UserConstants.NOT_UNIQUE.equals(qcIndexService.checkIndexCodeUnique(qcIndex))){
return AjaxResult.error("检测项编号已存在!");
}
if(UserConstants.NOT_UNIQUE.equals(qcIndexService.checkIndexNameUnique(qcIndex))){
return AjaxResult.error("检测项名称已存在!");
}
return toAjax(qcIndexService.updateQcIndex(qcIndex));
}
/**
* 删除检测项
*/
@PreAuthorize("@ss.hasPermi('mes:qc:qcindex:remove')")
@Log(title = "检测项", businessType = BusinessType.DELETE)
@DeleteMapping("/{indexIds}")
public AjaxResult remove(@PathVariable Long[] indexIds)
{
return toAjax(qcIndexService.deleteQcIndexByIndexIds(indexIds));
}
}

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_index
*
* @author yinjinlu
* @date 2022-05-17
*/
public class QcIndex extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 检测项ID */
private Long indexId;
/** 检测项编码 */
@Excel(name = "检测项编码")
private String indexCode;
/** 检测项名称 */
@Excel(name = "检测项名称")
private String indexName;
/** 检测项类型 */
@Excel(name = "检测项类型")
private String indexType;
/** 检测工具 */
@Excel(name = "检测工具")
private String qcTool;
/** 预留字段1 */
private String attr1;
/** 预留字段2 */
private String attr2;
/** 预留字段3 */
private Long attr3;
/** 预留字段4 */
private Long attr4;
public void setIndexId(Long indexId)
{
this.indexId = indexId;
}
public Long getIndexId()
{
return indexId;
}
public void setIndexCode(String indexCode)
{
this.indexCode = indexCode;
}
public String getIndexCode()
{
return indexCode;
}
public void setIndexName(String indexName)
{
this.indexName = indexName;
}
public String getIndexName()
{
return indexName;
}
public void setIndexType(String indexType)
{
this.indexType = indexType;
}
public String getIndexType()
{
return indexType;
}
public void setQcTool(String qcTool)
{
this.qcTool = qcTool;
}
public String getQcTool()
{
return qcTool;
}
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("indexId", getIndexId())
.append("indexCode", getIndexCode())
.append("indexName", getIndexName())
.append("indexType", getIndexType())
.append("qcTool", getQcTool())
.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,66 @@
package com.ktg.mes.qc.mapper;
import java.util.List;
import com.ktg.mes.qc.domain.QcIndex;
/**
* 检测项Mapper接口
*
* @author yinjinlu
* @date 2022-05-17
*/
public interface QcIndexMapper
{
/**
* 查询检测项
*
* @param indexId 检测项主键
* @return 检测项
*/
public QcIndex selectQcIndexByIndexId(Long indexId);
/**
* 查询检测项列表
*
* @param qcIndex 检测项
* @return 检测项集合
*/
public List<QcIndex> selectQcIndexList(QcIndex qcIndex);
public QcIndex checkIndexCodeUnique(QcIndex qcIndex);
public QcIndex checkIndexNameUnique(QcIndex qcIndex);
/**
* 新增检测项
*
* @param qcIndex 检测项
* @return 结果
*/
public int insertQcIndex(QcIndex qcIndex);
/**
* 修改检测项
*
* @param qcIndex 检测项
* @return 结果
*/
public int updateQcIndex(QcIndex qcIndex);
/**
* 删除检测项
*
* @param indexId 检测项主键
* @return 结果
*/
public int deleteQcIndexByIndexId(Long indexId);
/**
* 批量删除检测项
*
* @param indexIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteQcIndexByIndexIds(Long[] indexIds);
}

View File

@ -0,0 +1,77 @@
package com.ktg.mes.qc.service;
import java.util.List;
import com.ktg.mes.qc.domain.QcIndex;
/**
* 检测项Service接口
*
* @author yinjinlu
* @date 2022-05-17
*/
public interface IQcIndexService
{
/**
* 查询检测项
*
* @param indexId 检测项主键
* @return 检测项
*/
public QcIndex selectQcIndexByIndexId(Long indexId);
/**
* 查询检测项列表
*
* @param qcIndex 检测项
* @return 检测项集合
*/
public List<QcIndex> selectQcIndexList(QcIndex qcIndex);
/**
* 检测项编号是否唯一
* @param qcIndex
* @return
*/
public String checkIndexCodeUnique(QcIndex qcIndex);
/**
* 检测项名称是否唯一
* @param qcIndex
* @return
*/
public String checkIndexNameUnique(QcIndex qcIndex);
/**
* 新增检测项
*
* @param qcIndex 检测项
* @return 结果
*/
public int insertQcIndex(QcIndex qcIndex);
/**
* 修改检测项
*
* @param qcIndex 检测项
* @return 结果
*/
public int updateQcIndex(QcIndex qcIndex);
/**
* 批量删除检测项
*
* @param indexIds 需要删除的检测项主键集合
* @return 结果
*/
public int deleteQcIndexByIndexIds(Long[] indexIds);
/**
* 删除检测项信息
*
* @param indexId 检测项主键
* @return 结果
*/
public int deleteQcIndexByIndexId(Long indexId);
}

View File

@ -0,0 +1,119 @@
package com.ktg.mes.qc.service.impl;
import java.util.List;
import com.ktg.common.constant.UserConstants;
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.qc.mapper.QcIndexMapper;
import com.ktg.mes.qc.domain.QcIndex;
import com.ktg.mes.qc.service.IQcIndexService;
/**
* 检测项Service业务层处理
*
* @author yinjinlu
* @date 2022-05-17
*/
@Service
public class QcIndexServiceImpl implements IQcIndexService
{
@Autowired
private QcIndexMapper qcIndexMapper;
/**
* 查询检测项
*
* @param indexId 检测项主键
* @return 检测项
*/
@Override
public QcIndex selectQcIndexByIndexId(Long indexId)
{
return qcIndexMapper.selectQcIndexByIndexId(indexId);
}
/**
* 查询检测项列表
*
* @param qcIndex 检测项
* @return 检测项
*/
@Override
public List<QcIndex> selectQcIndexList(QcIndex qcIndex)
{
return qcIndexMapper.selectQcIndexList(qcIndex);
}
@Override
public String checkIndexCodeUnique(QcIndex qcIndex) {
QcIndex index = qcIndexMapper.checkIndexCodeUnique(qcIndex);
Long indexId = qcIndex.getIndexId()==null?-1L:qcIndex.getIndexId();
if(StringUtils.isNotNull(index) &&index.getIndexId().longValue() != indexId.longValue()){
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
}
@Override
public String checkIndexNameUnique(QcIndex qcIndex) {
QcIndex index = qcIndexMapper.checkIndexNameUnique(qcIndex);
Long indexId = qcIndex.getIndexId()==null?-1L:qcIndex.getIndexId();
if(StringUtils.isNotNull(index) &&index.getIndexId().longValue() != indexId.longValue()){
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
}
/**
* 新增检测项
*
* @param qcIndex 检测项
* @return 结果
*/
@Override
public int insertQcIndex(QcIndex qcIndex)
{
qcIndex.setCreateTime(DateUtils.getNowDate());
return qcIndexMapper.insertQcIndex(qcIndex);
}
/**
* 修改检测项
*
* @param qcIndex 检测项
* @return 结果
*/
@Override
public int updateQcIndex(QcIndex qcIndex)
{
qcIndex.setUpdateTime(DateUtils.getNowDate());
return qcIndexMapper.updateQcIndex(qcIndex);
}
/**
* 批量删除检测项
*
* @param indexIds 需要删除的检测项主键
* @return 结果
*/
@Override
public int deleteQcIndexByIndexIds(Long[] indexIds)
{
return qcIndexMapper.deleteQcIndexByIndexIds(indexIds);
}
/**
* 删除检测项信息
*
* @param indexId 检测项主键
* @return 结果
*/
@Override
public int deleteQcIndexByIndexId(Long indexId)
{
return qcIndexMapper.deleteQcIndexByIndexId(indexId);
}
}

View File

@ -0,0 +1,117 @@
<?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.QcIndexMapper">
<resultMap type="QcIndex" id="QcIndexResult">
<result property="indexId" column="index_id" />
<result property="indexCode" column="index_code" />
<result property="indexName" column="index_name" />
<result property="indexType" column="index_type" />
<result property="qcTool" column="qc_tool" />
<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="selectQcIndexVo">
select index_id, index_code, index_name, index_type, qc_tool, remark, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time from qc_index
</sql>
<select id="selectQcIndexList" parameterType="QcIndex" resultMap="QcIndexResult">
<include refid="selectQcIndexVo"/>
<where>
<if test="indexCode != null and indexCode != ''"> and index_code = #{indexCode}</if>
<if test="indexName != null and indexName != ''"> and index_name like concat('%', #{indexName}, '%')</if>
<if test="indexType != null and indexType != ''"> and index_type = #{indexType}</if>
<if test="qcTool != null and qcTool != ''"> and qc_tool = #{qcTool}</if>
</where>
</select>
<select id="selectQcIndexByIndexId" parameterType="Long" resultMap="QcIndexResult">
<include refid="selectQcIndexVo"/>
where index_id = #{indexId}
</select>
<select id="checkIndexCodeUnique" parameterType="QcIndex" resultMap="QcIndexResult">
<include refid="selectQcIndexVo"/>
where index_code = #{indexCode}
</select>
<select id="checkIndexNameUnique" parameterType="QcIndex" resultMap="QcIndexResult">
<include refid="selectQcIndexVo"/>
where index_name = #{indexName}
</select>
<insert id="insertQcIndex" parameterType="QcIndex" useGeneratedKeys="true" keyProperty="indexId">
insert into qc_index
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="indexCode != null and indexCode != ''">index_code,</if>
<if test="indexName != null and indexName != ''">index_name,</if>
<if test="indexType != null and indexType != ''">index_type,</if>
<if test="qcTool != null">qc_tool,</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="indexCode != null and indexCode != ''">#{indexCode},</if>
<if test="indexName != null and indexName != ''">#{indexName},</if>
<if test="indexType != null and indexType != ''">#{indexType},</if>
<if test="qcTool != null">#{qcTool},</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="updateQcIndex" parameterType="QcIndex">
update qc_index
<trim prefix="SET" suffixOverrides=",">
<if test="indexCode != null and indexCode != ''">index_code = #{indexCode},</if>
<if test="indexName != null and indexName != ''">index_name = #{indexName},</if>
<if test="indexType != null and indexType != ''">index_type = #{indexType},</if>
<if test="qcTool != null">qc_tool = #{qcTool},</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 index_id = #{indexId}
</update>
<delete id="deleteQcIndexByIndexId" parameterType="Long">
delete from qc_index where index_id = #{indexId}
</delete>
<delete id="deleteQcIndexByIndexIds" parameterType="String">
delete from qc_index where index_id in
<foreach item="indexId" collection="array" open="(" separator="," close=")">
#{indexId}
</foreach>
</delete>
</mapper>