实现添加缺陷记录后刷新检验单的CR、MAJ、MIN数量
This commit is contained in:
parent
0782327369
commit
381d900e9e
@ -6,8 +6,11 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import com.ktg.common.utils.StringUtils;
|
import com.ktg.common.utils.StringUtils;
|
||||||
import com.ktg.mes.qc.domain.ValidList;
|
import com.ktg.mes.qc.domain.ValidList;
|
||||||
|
import com.ktg.mes.qc.service.IQcIqcLineService;
|
||||||
|
import com.ktg.mes.qc.service.IQcIqcService;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
@ -39,6 +42,12 @@ public class QcIqcDefectController extends BaseController
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IQcIqcDefectService qcIqcDefectService;
|
private IQcIqcDefectService qcIqcDefectService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IQcIqcLineService qcIqcLineService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IQcIqcService qcIqcService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询来料检验单缺陷记录列表
|
* 查询来料检验单缺陷记录列表
|
||||||
*/
|
*/
|
||||||
@ -91,8 +100,11 @@ public class QcIqcDefectController extends BaseController
|
|||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('mes:qc:iqcdefect:edit')")
|
@PreAuthorize("@ss.hasPermi('mes:qc:iqcdefect:edit')")
|
||||||
@Log(title = "来料检验单缺陷记录", businessType = BusinessType.UPDATE)
|
@Log(title = "来料检验单缺陷记录", businessType = BusinessType.UPDATE)
|
||||||
|
@Transactional
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult updateList(@Validated @RequestBody ValidList<QcIqcDefect> defects){
|
public AjaxResult updateList(@Validated @RequestBody ValidList<QcIqcDefect> defects){
|
||||||
|
Long iqcId = -1L;
|
||||||
|
Long lineId = -1L;
|
||||||
if(CollUtil.isNotEmpty(defects)){
|
if(CollUtil.isNotEmpty(defects)){
|
||||||
for (QcIqcDefect defect: defects
|
for (QcIqcDefect defect: defects
|
||||||
) {
|
) {
|
||||||
@ -101,9 +113,14 @@ public class QcIqcDefectController extends BaseController
|
|||||||
}else {
|
}else {
|
||||||
qcIqcDefectService.insertQcIqcDefect(defect);
|
qcIqcDefectService.insertQcIqcDefect(defect);
|
||||||
}
|
}
|
||||||
|
iqcId = defect.getIqcId();
|
||||||
|
lineId = defect.getLineId();
|
||||||
}
|
}
|
||||||
|
//更新行上的cr,maj,min数量
|
||||||
|
qcIqcLineService.updateCrMajMinQuantity(iqcId,lineId);
|
||||||
|
//更新头上的cr,maj,min数量和比例
|
||||||
|
qcIqcService.updateCrMajMinQuaAndRate(iqcId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,6 +133,19 @@ public class QcIqcDefectController extends BaseController
|
|||||||
@DeleteMapping("/{recordIds}")
|
@DeleteMapping("/{recordIds}")
|
||||||
public AjaxResult remove(@PathVariable Long[] recordIds)
|
public AjaxResult remove(@PathVariable Long[] recordIds)
|
||||||
{
|
{
|
||||||
|
Long iqcId =-1L;
|
||||||
|
Long lineId =-1L;
|
||||||
|
if(recordIds!=null && recordIds.length>0){
|
||||||
|
QcIqcDefect defect = qcIqcDefectService.selectQcIqcDefectByRecordId(recordIds[0]);
|
||||||
|
iqcId = defect.getIqcId();
|
||||||
|
lineId = defect.getLineId();
|
||||||
|
|
||||||
|
//更新行上的cr,maj,min数量
|
||||||
|
qcIqcLineService.updateCrMajMinQuantity(iqcId,lineId);
|
||||||
|
//更新头上的cr,maj,min数量和比例
|
||||||
|
qcIqcService.updateCrMajMinQuaAndRate(iqcId);
|
||||||
|
}
|
||||||
|
|
||||||
return toAjax(qcIqcDefectService.deleteQcIqcDefectByRecordIds(recordIds));
|
return toAjax(qcIqcDefectService.deleteQcIqcDefectByRecordIds(recordIds));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,9 @@ public interface QcIqcLineMapper
|
|||||||
*/
|
*/
|
||||||
public int updateQcIqcLine(QcIqcLine qcIqcLine);
|
public int updateQcIqcLine(QcIqcLine qcIqcLine);
|
||||||
|
|
||||||
|
|
||||||
|
public int updateCrMajMinQuantity(QcIqcLine qcIqcLine);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除来料检验单行
|
* 删除来料检验单行
|
||||||
*
|
*
|
||||||
|
@ -45,6 +45,8 @@ public interface QcIqcMapper
|
|||||||
*/
|
*/
|
||||||
public int updateQcIqc(QcIqc qcIqc);
|
public int updateQcIqc(QcIqc qcIqc);
|
||||||
|
|
||||||
|
public int updateCrMajMinQuaAndRate(Long iqcId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除来料检验单
|
* 删除来料检验单
|
||||||
*
|
*
|
||||||
|
@ -43,6 +43,15 @@ public interface IQcIqcLineService
|
|||||||
*/
|
*/
|
||||||
public int updateQcIqcLine(QcIqcLine qcIqcLine);
|
public int updateQcIqcLine(QcIqcLine qcIqcLine);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算并更新当前行的Cr,Maj,Min的总数量
|
||||||
|
* @param iqcId
|
||||||
|
* @param lineId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int updateCrMajMinQuantity(Long iqcId,Long lineId);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除来料检验单行
|
* 批量删除来料检验单行
|
||||||
*
|
*
|
||||||
|
@ -50,6 +50,8 @@ public interface IQcIqcService
|
|||||||
*/
|
*/
|
||||||
public int updateQcIqc(QcIqc qcIqc);
|
public int updateQcIqc(QcIqc qcIqc);
|
||||||
|
|
||||||
|
public int updateCrMajMinQuaAndRate(Long iqcId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除来料检验单
|
* 批量删除来料检验单
|
||||||
*
|
*
|
||||||
|
@ -70,6 +70,14 @@ public class QcIqcLineServiceImpl implements IQcIqcLineService
|
|||||||
return qcIqcLineMapper.updateQcIqcLine(qcIqcLine);
|
return qcIqcLineMapper.updateQcIqcLine(qcIqcLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int updateCrMajMinQuantity(Long iqcId,Long lineId) {
|
||||||
|
QcIqcLine qcIqcLine = new QcIqcLine();
|
||||||
|
qcIqcLine.setIqcId(iqcId);
|
||||||
|
qcIqcLine.setLineId(lineId);
|
||||||
|
return qcIqcLineMapper.updateCrMajMinQuantity(qcIqcLine);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除来料检验单行
|
* 批量删除来料检验单行
|
||||||
*
|
*
|
||||||
|
@ -83,6 +83,11 @@ public class QcIqcServiceImpl implements IQcIqcService
|
|||||||
return qcIqcMapper.updateQcIqc(qcIqc);
|
return qcIqcMapper.updateQcIqc(qcIqc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int updateCrMajMinQuaAndRate(Long iqcId) {
|
||||||
|
return qcIqcMapper.updateCrMajMinQuaAndRate(iqcId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除来料检验单
|
* 批量删除来料检验单
|
||||||
*
|
*
|
||||||
|
@ -114,6 +114,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
|
||||||
|
<update id="updateCrMajMinQuantity" parameterType="QcIqcLine">
|
||||||
|
UPDATE qc_iqc_line a
|
||||||
|
INNER JOIN (
|
||||||
|
SELECT SUM(CASE WHEN defect_level = 'CR' THEN defect_quantity ELSE 0 END ) AS cr_quantity,
|
||||||
|
SUM(CASE WHEN defect_level = 'MAJ' THEN defect_quantity ELSE 0 END) AS maj_quantity,
|
||||||
|
SUM(CASE WHEN defect_level = 'MIN' THEN defect_quantity ELSE 0 END) AS min_quantity,
|
||||||
|
qid.`iqc_id`,
|
||||||
|
qid.`line_id`
|
||||||
|
FROM qc_iqc_defect qid
|
||||||
|
WHERE qid.iqc_id = #{iqcId}
|
||||||
|
AND qid.line_id = #{lineId}
|
||||||
|
GROUP BY qid.iqc_id,qid.line_id
|
||||||
|
)b
|
||||||
|
ON a.iqc_id = b.iqc_id AND a.line_id = b.line_id
|
||||||
|
SET a.cr_quantity=b.cr_quantity,a.maj_quantity=b.maj_quantity,a.min_quantity=b.min_quantity
|
||||||
|
WHERE a.iqc_id = #{iqcId}
|
||||||
|
AND a.line_id = #{lineId}
|
||||||
|
</update>
|
||||||
|
|
||||||
<update id="updateQcIqcLine" parameterType="QcIqcLine">
|
<update id="updateQcIqcLine" parameterType="QcIqcLine">
|
||||||
update qc_iqc_line
|
update qc_iqc_line
|
||||||
<trim prefix="SET" suffixOverrides=",">
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
@ -180,6 +180,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateCrMajMinQuaAndRate" parameterType="Long">
|
||||||
|
UPDATE qc_iqc a
|
||||||
|
INNER JOIN (
|
||||||
|
|
||||||
|
SELECT SUM(CASE WHEN defect_level = 'CR' THEN defect_quantity ELSE 0 END ) AS cr_quantity,
|
||||||
|
SUM(CASE WHEN defect_level = 'MAJ' THEN defect_quantity ELSE 0 END) AS maj_quantity,
|
||||||
|
SUM(CASE WHEN defect_level = 'MIN' THEN defect_quantity ELSE 0 END) AS min_quantity,
|
||||||
|
qid.`iqc_id`
|
||||||
|
FROM qc_iqc_defect qid
|
||||||
|
WHERE qid.iqc_id = #{iqc_id}
|
||||||
|
GROUP BY qid.iqc_id
|
||||||
|
) b
|
||||||
|
ON a.`iqc_id` = b.iqc_id
|
||||||
|
SET a.cr_quantity=b.cr_quantity,a.maj_quantity=b.maj_quantity,a.min_quantity=b.min_quantity,
|
||||||
|
a.`cr_rate`= ROUND(b.cr_quantity/a.`quantity_check`*100,2),
|
||||||
|
a.`maj_rate`= ROUND(b.maj_quantity/a.`quantity_check`*100,2),
|
||||||
|
a.`min_rate`= ROUND(b.min_quantity/a.`quantity_check`*100,2)
|
||||||
|
WHERE a.iqc_id = #{iqc_id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
|
||||||
<update id="updateQcIqc" parameterType="QcIqc">
|
<update id="updateQcIqc" parameterType="QcIqc">
|
||||||
update qc_iqc
|
update qc_iqc
|
||||||
<trim prefix="SET" suffixOverrides=",">
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
Loading…
Reference in New Issue
Block a user