白坯检验后台报表调整

master
FCD 1 week ago
parent 1eb50923d1
commit a35a2f6547

@ -17,6 +17,7 @@ import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.bean.BeanUtils;
import com.op.common.core.utils.poi.ExcelMapUtil;
import com.op.common.core.utils.poi.ExcelReportMapUtil;
import com.op.common.core.web.domain.AjaxResult;
import com.op.quality.domain.*;
import com.op.system.api.domain.mes.ProLineDTO;
import com.op.system.api.domain.quality.ChartDTO;
@ -960,8 +961,8 @@ public class QcStaticTableController extends BaseController {
@Log(title = "白坯缺陷排列报表--数表", businessType = BusinessType.QUERY)
@GetMapping("/getMonthOfDataDefect")
public List<Map<String, String>> getMonthOfDataDefect(QcStaticTable qcStaticTable) {
return qcStaticTableService.getMonthOfDataDefect(qcStaticTable);
public AjaxResult getMonthOfDataDefect(QcStaticTable qcStaticTable) {
return AjaxResult.success(qcStaticTableService.getMonthOfDataDefectV2(qcStaticTable));
}
@Log(title = "白坯缺陷排列报表导出", businessType = BusinessType.EXPORT)
@PostMapping("/getMonthOfDataDefectExport")
@ -1005,12 +1006,12 @@ public class QcStaticTableController extends BaseController {
@Log(title = "白坯不良项目报表--数表", businessType = BusinessType.QUERY)
@GetMapping("/getDefectItemData")
public List<Map<String, String>> getDefectItemData(QcStaticTable qcStaticTable) {
return qcStaticTableService.getDefectItemData(qcStaticTable);
return qcStaticTableService.getDefectItemDataV2(qcStaticTable);
}
@Log(title = "白坯不良项目报表--图表", businessType = BusinessType.QUERY)
@GetMapping("/getDefectItemLine")
public QcStaticTable getDefectItemLine(QcStaticTable qcStaticTable) {
return qcStaticTableService.getDefectItemLine(qcStaticTable);
public AjaxResult getDefectItemLine(QcStaticTable qcStaticTable) {
return AjaxResult.success(qcStaticTableService.getDefectItemLineV2(qcStaticTable));
}
@Log(title = "白坯不良项目报表导出", businessType = BusinessType.EXPORT)
@PostMapping("/getDefectItemDataExport")
@ -1048,12 +1049,12 @@ public class QcStaticTableController extends BaseController {
@Log(title = "白坯性能--数表", businessType = BusinessType.QUERY)
@GetMapping("/getDefectItemDataPC")
public List<Map<String, String>> getDefectItemDataPC(QcStaticTable qcStaticTable) {
return qcStaticTableService.getDefectItemDataPC(qcStaticTable);
return qcStaticTableService.getDefectItemDataPCV2(qcStaticTable);
}
@Log(title = "白坯性能--图表", businessType = BusinessType.QUERY)
@GetMapping("/getDefectItemLinePC")
public QcStaticTable getDefectItemLinePC(QcStaticTable qcStaticTable) {
return qcStaticTableService.getDefectItemLinePC(qcStaticTable);
public Map<String,Object> getDefectItemLinePC(QcStaticTable qcStaticTable) {
return qcStaticTableService.getDefectItemLinePCV2(qcStaticTable);
}
@Log(title = "白坯性能报表导出", businessType = BusinessType.EXPORT)
@PostMapping("/getDefectItemDataPCExport")

@ -2,6 +2,8 @@ package com.op.quality.domain;
import com.op.common.core.web.domain.BaseEntity;
import java.util.List;
/**
* remark
*
@ -28,12 +30,12 @@ public class QcCheckBp extends BaseEntity {
/**
*
* **/
private Integer checkNum;
private Integer checkNum = 0;
/**
*
* **/
private Integer badNum;
private Integer badNum = 0;
/**
*
@ -61,6 +63,15 @@ public class QcCheckBp extends BaseEntity {
* **/
private String createUserName;
/**
*
* **/
private String incomeBatchNo;
/**
*
* **/
private List<QcCheckBpDefect> defectList;
public String getMaterialCode() {
@ -142,4 +153,20 @@ public class QcCheckBp extends BaseEntity {
public void setCreateUserName(String createUserName) {
this.createUserName = createUserName;
}
public String getIncomeBatchNo() {
return incomeBatchNo;
}
public void setIncomeBatchNo(String incomeBatchNo) {
this.incomeBatchNo = incomeBatchNo;
}
public List<QcCheckBpDefect> getDefectList() {
return defectList;
}
public void setDefectList(List<QcCheckBpDefect> defectList) {
this.defectList = defectList;
}
}

@ -0,0 +1,50 @@
package com.op.quality.domain;
/**
* remark
*
* @author 019117
* @date
*/
public class QcCheckBpDefect {
private Integer badNum = 0;
private String badItem;
private String defectCode;
private String defectSubclass;
public Integer getBadNum() {
return badNum;
}
public void setBadNum(Integer badNum) {
this.badNum = badNum;
}
public String getBadItem() {
return badItem;
}
public void setBadItem(String badItem) {
this.badItem = badItem;
}
public String getDefectCode() {
return defectCode;
}
public void setDefectCode(String defectCode) {
this.defectCode = defectCode;
}
public String getDefectSubclass() {
return defectSubclass;
}
public void setDefectSubclass(String defectSubclass) {
this.defectSubclass = defectSubclass;
}
}

@ -1,6 +1,7 @@
package com.op.quality.mapper;
import com.op.quality.domain.QcCheckBp;
import com.op.quality.domain.QcCheckTaskDefect;
import com.op.quality.domain.QcCheckTaskIncome;
import org.apache.ibatis.annotations.Mapper;
@ -20,6 +21,8 @@ public interface QcCheckBpMapper {
void insertCheckBpResult( QcCheckTaskIncome task );
void batchInsertCheckBpDefects( List<QcCheckTaskDefect> list );
}

@ -159,4 +159,10 @@ public interface QcStaticTableMapper {
List<String> getCpDefectTypes(QcStaticTable qcStaticTable);
String getGroupIdByOrderNo(String orderNo);
List<QcCheckTaskDefect> getBPDefectList(QcStaticTable qcStaticTable);
List<QcCheckTaskDefect> getBPDefectMothMapV2(QcStaticTable qcStaticTable);
List<QcCheckTaskDefect> getBPDefectMothPCMapV2(QcStaticTable qcStaticTable);
}

@ -97,4 +97,17 @@ public interface IQcStaticTableService {
List<String> getCpDateTitle(QcStaticTable qcStaticTable);
List<Map<String, String>> getCpDefectDate(QcStaticTable qcStaticTable);
List<Map<String,String>> getMonthOfDataDefectV2(QcStaticTable qcStaticTable);
Map<String,Object> getDefectItemLineV2(QcStaticTable qcStaticTable);
Map<String,Object> getDefectItemLinePCV2(QcStaticTable qcStaticTable);
List<Map<String, String>> getDefectItemDataPCV2(QcStaticTable qcStaticTable);
List<Map<String, String>> getDefectItemDataV2(QcStaticTable qcStaticTable);
}

@ -3,19 +3,17 @@ package com.op.quality.service.impl;
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.quality.domain.QcCheckBp;
import com.op.quality.domain.QcCheckTaskIncome;
import com.op.quality.domain.QcCheckTaskProduce;
import com.op.quality.domain.*;
import com.op.quality.mapper.QcCheckBpMapper;
import com.op.quality.mapper.QcCheckTaskIncomeMapper;
import com.op.quality.mapper.QcCheckTaskProduceMapper;
import com.op.quality.service.IQcCheckBpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -67,7 +65,29 @@ public class QcCheckBpServiceImpl implements IQcCheckBpService {
task.setOrderType("bp");
task.setRemark(params.getRemark());
task.setRemarkCode(params.getBadItem());
task.setIncomeBatchNo(params.getIncomeBatchNo());
qcCheckBpMapper.insertCheckBpResult(task);
List<QcCheckTaskDefect> defectList = new ArrayList<>();
for (QcCheckBpDefect item : params.getDefectList()) {
QcCheckTaskDefect defect = new QcCheckTaskDefect();
defect.setRecordId(IdUtils.fastSimpleUUID());
defect.setDefectCode(item.getDefectCode());
defect.setDefectSubclass(item.getDefectSubclass());
defect.setCreateBy(params.getCreateBy());
defect.setFactoryCode("ds_"+params.getFactoryCode());
defect.setBelongTo(task.getRecordId());
defect.setOkQuality(new BigDecimal(params.getCheckNum()));
defect.setNoOkQuality(new BigDecimal(item.getBadNum()));
defect.setClassId(item.getBadItem());
defectList.add(defect);
}
if (!CollectionUtils.isEmpty(defectList)) {
qcCheckBpMapper.batchInsertCheckBpDefects(defectList);
}
}

@ -1769,6 +1769,70 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
return dtos;
}
@Override
@DS("#header.poolName")
public List<Map<String,String>> getMonthOfDataDefectV2(QcStaticTable qcStaticTable) {
List<String> bpDefects = qcStaticTableMapper.getBpDefects(qcStaticTable);
List<QcCheckTaskDefect> list = qcStaticTableMapper.getBPDefectList(qcStaticTable);
List<Map<String,String>> result = new ArrayList<>();
for (String defect : bpDefects){
Map<String,String> map = new HashMap<>();
map.put("defect",defect);
int count = 0;
for (QcCheckTaskDefect data : list){
if (defect.equals(data.getDefectSubclass())){
map.put(data.getAttr1(),data.getAttr2());
if (StringUtils.isNotBlank(data.getAttr2())){
count = count + Integer.parseInt(data.getAttr2());
}
}
}
map.put("count", Integer.toString(count));
result.add(map);
}
int count1 = 0;
int count2 = 0;
Map<String,String> map1 = new HashMap<>();
map1.put("defect","合计");
Map<String,String> map2 = new HashMap<>();
map2.put("defect","抽样数");
for (QcCheckTaskDefect data : list){
if ("合计".equals(data.getDefectSubclass())){
map1.put(data.getAttr1(),data.getAttr2());
map2.put(data.getAttr1(),data.getAttr3());
if (StringUtils.isNotBlank(data.getAttr2())){
count1 = count1 + Integer.parseInt(data.getAttr2());
}
if (StringUtils.isNotBlank(data.getAttr3())){
count2 = count2 + Integer.parseInt(data.getAttr3().replace(".00",""));
}
}
}
map1.put("count", Integer.toString(count1));
map2.put("count", Integer.toString(count2));
result.add(map1);
result.add(map2);
return result;
}
@Override
@DS("#header.poolName")
public List<Map<String, String>> getDefectItemDataV2(QcStaticTable qcStaticTable) {
List<Map<String, String>> dtos = new ArrayList<>();
//获取不良种类
List<String> bpDefects = qcStaticTableMapper.getBpDefects(qcStaticTable);
List<QcCheckTaskDefect> monthList = qcStaticTableMapper.getBPDefectMothMapV2(qcStaticTable);
qcStaticTable.setYearMonth(null);
List<QcCheckTaskDefect> totalList = qcStaticTableMapper.getBPDefectMothMapV2(qcStaticTable);
dtos.add(computerBpDefectsRate(monthList,"num","不良数", bpDefects));
dtos.add(computerBpDefectsRate(monthList,"rate","不良比例", bpDefects));
dtos.add(computerBpDefectsRate(totalList,"rate","累计不良比例", bpDefects));
return dtos;
}
@Override
@DS("#header.poolName")
public List<String> getDefectItemTitle(QcStaticTable qcStaticTable) {
@ -1888,6 +1952,80 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
return dto;
}
@Override
@DS("#header.poolName")
public Map<String,Object> getDefectItemLineV2(QcStaticTable qcStaticTable) {
Map<String,Object> result = new HashMap<>();
//获取不良种类
List<String> bpDefects = qcStaticTableMapper.getBpDefects(qcStaticTable);
result.put("xData",bpDefects);
//当前查询月份的不良率
List<QcCheckTaskDefect> monthList = qcStaticTableMapper.getBPDefectMothMapV2(qcStaticTable);
//计算总不良率
//不良数
BigDecimal noOkQty = new BigDecimal(0);
//样品数
BigDecimal sampleQty = new BigDecimal(0);
for (QcCheckTaskDefect item : monthList){
if (StringUtils.isNotBlank(item.getAttr2())){
noOkQty = noOkQty.add(new BigDecimal(item.getAttr2()));
}
if (StringUtils.isNotBlank(item.getAttr3())){
sampleQty = sampleQty.add(new BigDecimal(item.getAttr3()));
}
}
//不良率
BigDecimal noOkRate = new BigDecimal(0);
if (sampleQty.compareTo(BigDecimal.ZERO) > 0){
noOkRate = noOkQty.divide(sampleQty,4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
}
//合格率
BigDecimal okRate = new BigDecimal(100).subtract(noOkRate);
result.put("noOkQty",noOkQty);
result.put("sampleQty",sampleQty);
result.put("noOkRate",noOkRate);
result.put("okRate",okRate);
List<String> yDataLeft = new ArrayList<>();
for (String defect : bpDefects) {
boolean flag = true;
for (QcCheckTaskDefect item : monthList){
if (defect.equals(item.getDefectSubclass())){
yDataLeft.add(item.getAttr1());
flag = false;
break;
}
}
if (flag){
yDataLeft.add("0");
}
}
result.put("yDataLeft",yDataLeft);
//累计不良率
qcStaticTable.setYearMonth(null);
List<QcCheckTaskDefect> totalList = qcStaticTableMapper.getBPDefectMothMapV2(qcStaticTable);
List<String> yDataRight = new ArrayList<>();
for (String defect : bpDefects) {
boolean flag = true;
for (QcCheckTaskDefect item : totalList){
if (defect.equals(item.getDefectSubclass())){
yDataRight.add(item.getAttr1());
flag = false;
break;
}
}
if (flag){
yDataRight.add("0");
}
}
result.put("yDataRight",yDataRight);
return result;
}
@Override
@DS("#header.poolName")
public List<Map<String, String>> getDefectItemDataPC(QcStaticTable qcStaticTable) {
@ -1933,6 +2071,55 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
return dtos;
}
@Override
@DS("#header.poolName")
public List<Map<String, String>> getDefectItemDataPCV2(QcStaticTable qcStaticTable) {
List<Map<String, String>> dtos = new ArrayList<>();
//获取不良种类
List<String> bpDefects = qcStaticTableMapper.getBpDefects(qcStaticTable);
List<QcCheckTaskDefect> monthList = qcStaticTableMapper.getBPDefectMothPCMapV2(qcStaticTable);
qcStaticTable.setYearMonth(null);
List<QcCheckTaskDefect> totalList = qcStaticTableMapper.getBPDefectMothPCMapV2(qcStaticTable);
dtos.add(computerBpDefectsRate(monthList,"num","不良数", bpDefects));
dtos.add(computerBpDefectsRate(monthList,"rate","不良比例", bpDefects));
dtos.add(computerBpDefectsRate(totalList,"rate","累计不良比例", bpDefects));
return dtos;
}
//计算
private Map<String,String> computerBpDefectsRate(List<QcCheckTaskDefect> list, String type, String title, List<String> bpDefects ){
Map<String,String> result= new HashMap<>();
result.put("dataType",title);
int i = 0;
for (String defect : bpDefects) {
for (QcCheckTaskDefect item : list){
if (defect.equals(item.getDefectSubclass())){
if (StringUtils.isNotBlank(item.getAttr1())){
if ("rate".equals(type)){
result.put("item"+i, item.getAttr1());
}else {
if (StringUtils.isNotBlank(item.getAttr2())){
result.put("item"+i,new BigDecimal(item.getAttr1()).divide(new BigDecimal(item.getAttr2()),2,RoundingMode.HALF_UP).toString());
}else {
result.put("item"+i,"100");
}
}
}else {
result.put("item"+i,"0");
}
break;
}
}
i++;
}
return result;
}
@Override
@DS("#header.poolName")
public QcStaticTable getDefectItemLinePC(QcStaticTable qcStaticTable) {
@ -2001,6 +2188,81 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
return dto;
}
@Override
@DS("#header.poolName")
public Map<String,Object> getDefectItemLinePCV2(QcStaticTable qcStaticTable) {
Map<String,Object> result = new HashMap<>();
//获取不良种类
List<String> bpDefects = qcStaticTableMapper.getBpDefects(qcStaticTable);
result.put("xData",bpDefects);
//当前查询月份的不良率
List<QcCheckTaskDefect> monthList = qcStaticTableMapper.getBPDefectMothPCMapV2(qcStaticTable);
//计算总不良率
//不良数
BigDecimal noOkQty = new BigDecimal(0);
//样品数
BigDecimal sampleQty = new BigDecimal(0);
for (QcCheckTaskDefect item : monthList){
if (StringUtils.isNotBlank(item.getAttr2())){
noOkQty = noOkQty.add(new BigDecimal(item.getAttr2()));
}
if (StringUtils.isNotBlank(item.getAttr3())){
sampleQty = sampleQty.add(new BigDecimal(item.getAttr3()));
}
}
//不良率
BigDecimal noOkRate = new BigDecimal(0);
if (sampleQty.compareTo(BigDecimal.ZERO) > 0){
noOkRate = noOkQty.divide(sampleQty,4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
}
//合格率
BigDecimal okRate = new BigDecimal(100).subtract(noOkRate);
result.put("noOkQty",noOkQty);
result.put("sampleQty",sampleQty);
result.put("noOkRate",noOkRate);
result.put("okRate",okRate);
List<String> yDataLeft = new ArrayList<>();
for (String defect : bpDefects) {
boolean flag = true;
for (QcCheckTaskDefect item : monthList){
if (defect.equals(item.getDefectSubclass())){
yDataLeft.add(item.getAttr1());
flag = false;
break;
}
}
if (flag){
yDataLeft.add("0");
}
}
result.put("yDataLeft",yDataLeft);
//累计不良率
qcStaticTable.setYearMonth(null);
List<QcCheckTaskDefect> totalList = qcStaticTableMapper.getBPDefectMothPCMapV2(qcStaticTable);
List<String> yDataRight = new ArrayList<>();
for (String defect : bpDefects) {
boolean flag = true;
for (QcCheckTaskDefect item : totalList){
if (defect.equals(item.getDefectSubclass())){
yDataRight.add(item.getAttr1());
flag = false;
break;
}
}
if (flag){
yDataRight.add("0");
}
}
result.put("yDataRight",yDataRight);
return result;
}
@Override
@DS("#header.poolName")
public List<String> getCpDateTitle(QcStaticTable qcStaticTable) {

@ -99,4 +99,17 @@
</trim>
</insert>
<insert id="batchInsertCheckBpDefects">
insert into qc_check_task_defect(
record_id, defect_code, defect_subclass, create_by, create_time,
factory_code, belong_to, ok_quality, noOk_quality, class_id
) values
<foreach item="item" index="index" collection="list" separator=",">
(
#{item.recordId}, #{item.defectCode}, #{item.defectSubclass}, #{item.createBy}, GETDATE(),
#{item.factoryCode}, #{item.belongTo}, #{item.okQuality}, #{item.noOkQuality},#{item.classId}
)
</foreach>
</insert>
</mapper>

@ -359,7 +359,12 @@
select qct.record_id, qct.check_no, qct.income_batch_no,
qct.order_no, qct.material_code, qct.material_name, qct.quality, qct.unit,
qct.supplier_code, qct.supplier_name, qct.income_time, qct.check_loc, qct.check_status,
qct.check_time, qct.check_result, qct.check_type,'首件检验' check_name,
qct.check_time, qct.check_result, qct.check_type,
CASE
WHEN 'checkTypeSC' = #{checkType} THEN '首件检验'
WHEN 'checkTypeCPPC' = #{checkType} THEN '批次成品检验'
ELSE ''
END check_name,
CONVERT(varchar(10),qct.create_time, 120) createTimeStr,
qct.confirm,qct.confirm_man_name,qct.check_man_code ,qct.check_man_name
from qc_check_task qct
@ -386,44 +391,8 @@
<if test="incomeTimeEnd != null ">and #{incomeTimeEnd} > CONVERT(varchar(30),qct.income_time, 120)</if>
<if test="checkTimeStart != null ">and CONVERT(varchar(30),qct.create_time, 120) >= #{checkTimeStart}</if>
<if test="checkTimeEnd != null ">and #{checkTimeEnd} > CONVERT(varchar(30),qct.create_time, 120)</if>
and qct.check_type = 'checkTypeSC' and qct.del_flag = '0'
and qct.check_type in ('checkTypeSC','checkTypeCPPC') and qct.del_flag = '0'
</where>
union ALL
select
'','','',
qct.order_no, qct.material_code, qct.material_name, qct.quality, qct.unit,
qct.supplier_code, qct.supplier_name,CONVERT(varchar(10), qct.income_time, 120) income_time,'','',
null,'', qct.check_type,'巡检检验' check_name,CONVERT(varchar(10),qct.create_time, 120) createTimeStr,
qct.confirm,qct.confirm_man_name,'',''
from qc_check_task qct
<where>
<if test="checkNo != null and checkNo != ''">and qct.check_no = #{checkNo}</if>
<if test="incomeBatchNo != null and incomeBatchNo != ''">and qct.income_batch_no = #{incomeBatchNo}</if>
<if test="orderNo != null and orderNo != ''">and qct.order_no = #{orderNo}</if>
<if test="materialCode != null and materialCode != ''">and qct.material_code = #{materialCode}</if>
<if test="materialName != null and materialName != ''">and qct.material_name like concat('%',
#{materialName}, '%')
</if>
<if test="supplierCode != null and supplierCode != ''">and qct.supplier_code = #{supplierCode}</if>
<if test="supplierName != null and supplierName != ''">and qct.supplier_name like concat('%',
#{supplierName}, '%')
</if>
<if test="checkLoc != null and checkLoc != ''">and qct.check_loc = #{checkLoc}</if>
<if test="checkStatus != null and checkStatus != ''">and qct.check_status = #{checkStatus}</if>
<if test="checkManCode != null and checkManCode != ''">and qct.check_man_code = #{checkManCode}</if>
<if test="checkManName != null and checkManName != ''">and qct.check_man_name like concat('%',
#{checkManName}, '%')
</if>
<if test="checkResult != null and checkResult != ''">and qct.check_result = #{checkResult}</if>
<if test="incomeTimeStart != null ">and CONVERT(varchar(30),qct.income_time, 120) >= #{incomeTimeStart}</if>
<if test="incomeTimeEnd != null ">and #{incomeTimeEnd} > CONVERT(varchar(30),qct.income_time, 120)</if>
<if test="checkTimeStart != null ">and CONVERT(varchar(30),qct.create_time, 120) >= #{checkTimeStart}</if>
<if test="checkTimeEnd != null ">and #{checkTimeEnd} > CONVERT(varchar(30),qct.create_time, 120)</if>
and qct.check_type = 'checkTypeSCXJ' and qct.del_flag = '0'
</where>
GROUP BY qct.order_no, qct.material_code, qct.material_name, qct.quality, qct.unit,
qct.supplier_code, qct.supplier_name,CONVERT(varchar(10), qct.income_time, 120), qct.check_type,CONVERT(varchar(10),qct.create_time, 120),
qct.confirm,qct.confirm_man_name
) t
left join pro_order_workorder pow on pow.workorder_code = t.order_no
where pow.del_flag = '0'

@ -1412,4 +1412,79 @@
where pow.workorder_code = #{orderNo}
</select>
<select id="getBPDefectList" resultType="com.op.quality.domain.QcCheckTaskDefect">
SELECT
tc.class_name defectSubclass,
FORMAT ( qct.create_time, 'yyyy-MM-dd' ) attr1,
SUM(td.noOk_quality) attr2,
SUM(qct.sample_quality) attr3
FROM qc_check_task qct
LEFT JOIN qc_check_task_defect td ON qct.record_id = td.belong_to
LEFT JOIN qc_defect_type_class tc ON td.class_id = tc.id
WHERE qct.del_flag = '0'
AND tc.class_name IS NOT NULL
AND FORMAT ( qct.create_time, 'yyyy-MM' ) = #{yearMonth}
AND qct.order_type = 'bp'
GROUP BY tc.class_name, FORMAT ( qct.create_time, 'yyyy-MM-dd' )
UNION ALL
SELECT
'合计' defectSubclass,
FORMAT ( qct.create_time, 'yyyy-MM-dd' ) attr1,
SUM ( td.noOk_quality ) attr2,
SUM ( qct.sample_quality ) attr3
FROM qc_check_task qct
LEFT JOIN qc_check_task_defect td ON qct.record_id = td.belong_to
LEFT JOIN qc_defect_type_class tc ON td.class_id = tc.id
WHERE qct.del_flag = '0'
AND tc.class_name IS NOT NULL
AND FORMAT ( qct.create_time, 'yyyy-MM' ) = #{yearMonth}
AND qct.order_type = 'bp'
GROUP BY FORMAT ( qct.create_time, 'yyyy-MM-dd' )
</select>
<select id="getBPDefectMothMapV2" resultType="com.op.quality.domain.QcCheckTaskDefect">
SELECT
tc.class_name defectSubclass,
SUM ( td.noOk_quality ) / SUM ( qct.sample_quality ) * 100 attr1,
SUM ( td.noOk_quality ) attr2,
SUM ( qct.sample_quality ) attr3
FROM qc_check_task qct
LEFT JOIN qc_check_task_defect td ON qct.record_id = td.belong_to
LEFT JOIN qc_defect_type_class tc ON td.class_id = tc.id
WHERE qct.del_flag = '0'
AND tc.class_name IS NOT NULL
AND qct.order_type = 'bp'
<if test="yearMonth !=null and yearMonth != ''">
AND FORMAT ( qct.create_time, 'yyyy-MM' ) = #{yearMonth}
</if>
GROUP BY tc.class_name
</select>
<select id="getBPDefectMothPCMapV2" resultType="com.op.quality.domain.QcCheckTaskDefect">
SELECT
t.defectSubclass,
SUM ( t.attr2 ) attr2,
SUM ( t.attr3 ) attr3
FROM
(
SELECT
tc.class_name defectSubclass,
SUM (CASE WHEN qct.check_status = 'N' THEN 1 ELSE 0 END) attr2,
COUNT ( 0 ) attr3,
qct.income_batch_no
FROM qc_check_task qct
LEFT JOIN qc_check_task_defect td ON qct.record_id = td.belong_to
LEFT JOIN qc_defect_type_class tc ON td.class_id = tc.id
WHERE qct.del_flag = '0'
AND tc.class_name IS NOT NULL
AND qct.order_type = 'bp'
<if test="yearMonth !=null and yearMonth != ''">
AND FORMAT ( qct.create_time, 'yyyy-MM' ) = #{yearMonth}
</if>
GROUP BY tc.class_name, qct.income_batch_no
) t
GROUP BY
t.defectSubclass
</select>
</mapper>

Loading…
Cancel
Save