过程检验单编号唯一性检查

This commit is contained in:
JinLu.Yin 2022-08-29 20:39:08 +08:00
parent e0a6b9cd79
commit 2d48e5c7ea
5 changed files with 41 additions and 0 deletions

View File

@ -2,6 +2,8 @@ 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;
@ -77,6 +79,10 @@ public class QcIpqcController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody QcIpqc qcIpqc)
{
if(UserConstants.NOT_UNIQUE.equals(qcIpqcService.checkIpqcCodeUnique(qcIpqc))){
return AjaxResult.error("检测单编码已存在!");
}
return toAjax(qcIpqcService.insertQcIpqc(qcIpqc));
}
@ -88,6 +94,9 @@ public class QcIpqcController extends BaseController
@PutMapping
public AjaxResult edit(@RequestBody QcIpqc qcIpqc)
{
if(UserConstants.NOT_UNIQUE.equals(qcIpqcService.checkIpqcCodeUnique(qcIpqc))){
return AjaxResult.error("检测单编码已存在!");
}
return toAjax(qcIpqcService.updateQcIpqc(qcIpqc));
}

View File

@ -27,6 +27,13 @@ public interface QcIpqcMapper
*/
public List<QcIpqc> selectQcIpqcList(QcIpqc qcIpqc);
/**
* 验证检测编码是否唯一
* @param qcIpqc
* @return
*/
public QcIpqc checkIpqcCodeUnique(QcIpqc qcIpqc);
/**
* 新增过程检验单
*

View File

@ -27,6 +27,14 @@ public interface IQcIpqcService
*/
public List<QcIpqc> selectQcIpqcList(QcIpqc qcIpqc);
/**
* 检查检测编码是否唯一
* @param qcIpqc
* @return
*/
public String checkIpqcCodeUnique(QcIpqc qcIpqc);
/**
* 新增过程检验单
*

View File

@ -1,7 +1,10 @@
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.QcIpqcMapper;
@ -44,6 +47,16 @@ public class QcIpqcServiceImpl implements IQcIpqcService
return qcIpqcMapper.selectQcIpqcList(qcIpqc);
}
@Override
public String checkIpqcCodeUnique(QcIpqc qcIpqc) {
QcIpqc ipqc = qcIpqcMapper.checkIpqcCodeUnique(qcIpqc);
Long ipqcId = qcIpqc.getIpqcId()==null?-1:qcIpqc.getIpqcId();
if(StringUtils.isNotNull(ipqc) && ipqc.getIpqcId().longValue() != ipqcId.longValue()){
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
}
/**
* 新增过程检验单
*

View File

@ -99,6 +99,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectQcIpqcVo"/>
where ipqc_id = #{ipqcId}
</select>
<select id="checkIpqcCodeUnique" parameterType="QcIpqc" resultMap="QcIpqcResult">
select * from qc_ipqc where ipqc_code = #{ipqcCode}
</select>
<insert id="insertQcIpqc" parameterType="QcIpqc" useGeneratedKeys="true" keyProperty="ipqcId">
insert into qc_ipqc