物料检验项目维护

highway
shaoyong 1 year ago
parent c1fac1f909
commit 3c40a7df23

@ -99,7 +99,17 @@ public class QcMaterialGroupController extends BaseController {
@RequiresPermissions("quality:materialGroup:remove")
@Log(title = "物料组", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable String[] ids) {
return toAjax(qcMaterialGroupService.deleteQcMaterialGroupByIds(ids));
public AjaxResult remove(@PathVariable String id) {
QcMaterialGroup parent = new QcMaterialGroup();
parent.setId(id);
List<QcMaterialGroup> children = qcMaterialGroupService.getMaterialChildrenList(parent);
boolean hasRule = qcMaterialGroupService.validationData(id);
if (!children.isEmpty()) {
return AjaxResult.error("此节点下含有子节点,请先删除子节点");
}else if (hasRule){
return AjaxResult.error("此节点含有检验规则,请先删除检验规则");
} else {
return toAjax(qcMaterialGroupService.deleteQcMaterialGroupById(id));
}
}
}

@ -2,6 +2,8 @@ package com.op.quality.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.op.quality.domain.QcMaterialGroup;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@ -91,7 +93,14 @@ public class QcMaterialGroupDetailController extends BaseController {
@RequiresPermissions("quality:materialGroupDetail:remove")
@Log(title = "物料组成员", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable String[] ids) {
return toAjax(qcMaterialGroupDetailService.deleteQcMaterialGroupDetailByIds(ids));
public AjaxResult remove(@PathVariable String id) {
QcMaterialGroupDetail groupDetail = qcMaterialGroupDetailService.selectQcMaterialGroupDetailById(id);
boolean hasRule = qcMaterialGroupDetailService.validationData(groupDetail.getMaterialCode());
if (hasRule) {
return AjaxResult.error("此节点含有检验规则,请先删除检验规则");
}else {
return toAjax(qcMaterialGroupDetailService.deleteQcMaterialGroupDetailById(id));
}
}
}

@ -21,6 +21,11 @@ public class QcCheckTypeProject extends BaseEntity {
/** 检验项目id */
@Excel(name = "检验项目id")
private String projectId;
/** 检验规则名称 */
@Excel(name = "检验规则名称")
private String ruleName;
/** 规则方式*/
private String propertyCode;
/** 检验节点id */
@Excel(name = "检验节点id")
@ -175,11 +180,28 @@ public class QcCheckTypeProject extends BaseEntity {
return materialCode;
}
public String getRuleName() {
return ruleName;
}
public void setRuleName(String ruleName) {
this.ruleName = ruleName;
}
public String getPropertyCode() {
return propertyCode;
}
public void setPropertyCode(String propertyCode) {
this.propertyCode = propertyCode;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("projectId", getProjectId())
.append("ruleName", getRuleName())
.append("typeId", getTypeId())
.append("standardValue", getStandardValue())
.append("upperDiff", getUpperDiff())

@ -62,4 +62,6 @@ public interface QcMaterialGroupDetailMapper {
public int deleteQcMaterialGroupDetailByIds(String[] ids);
public QcMaterialGroupDetail getGroupByMaterial(String materialCode);
public List<QcMaterialGroupDetail> validationData(String materialCode);
}

@ -62,4 +62,6 @@ public interface QcMaterialGroupMapper {
public int deleteQcMaterialGroupByIds(String[] ids);
public List<QcMaterialGroup> getMaterialChildrenList(QcMaterialGroup qcMaterialGroup);
public List<QcMaterialGroup> validationData(String id);
}

@ -57,4 +57,6 @@ public interface IQcMaterialGroupDetailService {
* @return
*/
public int deleteQcMaterialGroupDetailById(String id);
public boolean validationData(String id);
}

@ -67,4 +67,6 @@ public interface IQcMaterialGroupService {
* @return
*/
public int deleteQcMaterialGroupById(String id);
public boolean validationData(String id);
}

@ -4,11 +4,18 @@ import java.util.List;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.uuid.IdUtils;
import com.op.common.security.utils.SecurityUtils;
import org.apache.catalina.security.SecurityUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.op.quality.mapper.QcCheckTypeProjectMapper;
import com.op.quality.domain.QcCheckTypeProject;
import com.op.quality.service.IQcCheckTypeProjectService;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
/**
* Service
@ -54,7 +61,12 @@ public class QcCheckTypeProjectServiceImpl implements IQcCheckTypeProjectService
@Override
@DS("#header.poolName")
public int insertQcCheckTypeProject(QcCheckTypeProject qcCheckTypeProject) {
qcCheckTypeProject.setId(IdUtils.fastSimpleUUID());
qcCheckTypeProject.setCreateBy(SecurityUtils.getUsername());
qcCheckTypeProject.setCreateTime(DateUtils.getNowDate());
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String key = "#header.poolName";
qcCheckTypeProject.setFactoryCode(request.getHeader(key.substring(8)).replace("ds_",""));
return qcCheckTypeProjectMapper.insertQcCheckTypeProject(qcCheckTypeProject);
}
@ -67,6 +79,7 @@ public class QcCheckTypeProjectServiceImpl implements IQcCheckTypeProjectService
@Override
@DS("#header.poolName")
public int updateQcCheckTypeProject(QcCheckTypeProject qcCheckTypeProject) {
qcCheckTypeProject.setUpdateBy(SecurityUtils.getUsername());
qcCheckTypeProject.setUpdateTime(DateUtils.getNowDate());
return qcCheckTypeProjectMapper.updateQcCheckTypeProject(qcCheckTypeProject);
}

@ -105,4 +105,9 @@ public class QcMaterialGroupDetailServiceImpl implements IQcMaterialGroupDetailS
public int deleteQcMaterialGroupDetailById(String id) {
return qcMaterialGroupDetailMapper.deleteQcMaterialGroupDetailById(id);
}
@Override
public boolean validationData(String materialCode) {
return qcMaterialGroupDetailMapper.validationData(materialCode).size() > 0;
}
}

@ -173,6 +173,11 @@ public class QcMaterialGroupServiceImpl implements IQcMaterialGroupService {
return qcMaterialGroupMapper.deleteQcMaterialGroupById(id);
}
@Override
public boolean validationData(String id) {
return qcMaterialGroupMapper.validationData(id).size() > 0;
}
private boolean hasChild(List<QcMaterialGroup> list, QcMaterialGroup t) {
return getChildList(list, t).size() > 0 ? true : false;
}

@ -22,32 +22,77 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="delFlag" column="del_flag" />
<result property="groupId" column="group_id" />
<result property="materialCode" column="material_code" />
<result property="sampleNum" column="sample_num" />
</resultMap>
<sql id="selectQcCheckTypeProjectVo">
select id, project_id, type_id, standard_value, upper_diff, down_diff, sample, status, attr1, create_by, create_time, update_by, update_time, factory_code, del_flag, group_id, material_code from qc_check_type_project
select id, project_id, type_id, standard_value, upper_diff, down_diff, sample, status, attr1, create_by, create_time, update_by, update_time, factory_code, del_flag, group_id, material_code, sample_num from qc_check_type_project
</sql>
<select id="selectQcCheckTypeProjectList" parameterType="QcCheckTypeProject" resultMap="QcCheckTypeProjectResult">
<include refid="selectQcCheckTypeProjectVo"/>
SELECT
ctp.id,
ctp.project_id,
cp.rule_name ruleName,
cp.property_code propertyCode,
ctp.type_id,
ctp.standard_value,
ctp.upper_diff,
ctp.down_diff,
ctp.sample,
ctp.status,
ctp.create_by,
ctp.create_time,
ctp.update_by,
ctp.update_time,
ctp.factory_code,
ctp.del_flag,
ctp.group_id,
ctp.material_code,
ctp.sample_num
FROM qc_check_type_project ctp
LEFT JOIN qc_check_project cp ON ctp.project_id = cp.id AND cp.del_flag = '0'
<where>
<if test="projectId != null and projectId != ''"> and project_id = #{projectId}</if>
<if test="typeId != null and typeId != ''"> and type_id = #{typeId}</if>
<if test="standardValue != null "> and standard_value = #{standardValue}</if>
<if test="upperDiff != null "> and upper_diff = #{upperDiff}</if>
<if test="downDiff != null "> and down_diff = #{downDiff}</if>
<if test="sample != null "> and sample = #{sample}</if>
AND ctp.del_flag = '0'
<if test="projectId != null and projectId != ''"> and ctp.project_id = #{projectId}</if>
<if test="typeId != null and typeId != ''"> and ctp.type_id = #{typeId}</if>
<if test="standardValue != null "> and ctp.standard_value = #{standardValue}</if>
<if test="upperDiff != null "> and ctp.upper_diff = #{upperDiff}</if>
<if test="downDiff != null "> and ctp.down_diff = #{downDiff}</if>
<if test="sample != null "> and ctp.sample = #{sample}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
<if test="attr1 != null and attr1 != ''"> and attr1 = #{attr1}</if>
<if test="factoryCode != null and factoryCode != ''"> and factory_code = #{factoryCode}</if>
<if test="groupId != null and groupId != ''"> and group_id = #{groupId}</if>
<if test="materialCode != null and materialCode != ''"> and material_code = #{materialCode}</if>
<if test="sampleNum != null and sampleNum != ''"> and sample_num = #{sampleNum}</if>
</where>
</select>
<select id="selectQcCheckTypeProjectById" parameterType="String" resultMap="QcCheckTypeProjectResult">
<include refid="selectQcCheckTypeProjectVo"/>
where id = #{id}
SELECT
ctp.id,
ctp.project_id,
cp.rule_name ruleName,
cp.property_code propertyCode,
ctp.type_id,
ctp.standard_value,
ctp.upper_diff,
ctp.down_diff,
ctp.sample,
ctp.status,
ctp.create_by,
ctp.create_time,
ctp.update_by,
ctp.update_time,
ctp.factory_code,
ctp.del_flag,
ctp.group_id,
ctp.material_code,
ctp.sample_num
FROM qc_check_type_project ctp
LEFT JOIN qc_check_project cp ON ctp.project_id = cp.id AND cp.del_flag = '0'
WHERE ctp.del_flag ='0' AND ctp.id = #{id}
</select>
<select id="getTPByTypeMaterial" resultType="com.op.quality.domain.QcCheckTaskDetail">
select qctp.project_id projectId,
@ -110,6 +155,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="delFlag != null">del_flag,</if>
<if test="groupId != null">group_id,</if>
<if test="materialCode != null">material_code,</if>
<if test="sampleNum != null">sample_num</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
@ -129,6 +175,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="delFlag != null">#{delFlag},</if>
<if test="groupId != null">#{groupId},</if>
<if test="materialCode != null">#{materialCode},</if>
<if test="sampleNum != null">#{sampleNum}</if>
</trim>
</insert>
@ -151,6 +198,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="groupId != null">group_id = #{groupId},</if>
<if test="materialCode != null">material_code = #{materialCode},</if>
<if test="sampleNum != null">sample_num = #{sampleNum}</if>
</trim>
where id = #{id}
</update>

@ -102,4 +102,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id}
</foreach>
</delete>
<select id="validationData" parameterType="String">
select
id,
create_by,
create_time
from qc_check_type_project
where material_code = #{materialCode}
</select>
</mapper>

@ -107,4 +107,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id}
</foreach>
</delete>
<select id="validationData" parameterType="String">
select
id,
create_by,
create_time
from qc_check_type_project
where group_id = #{id}
</select>
</mapper>
Loading…
Cancel
Save