黑蚊香质检分类汇总

master
zhaoxiaolin 3 months ago
parent b8a43de01a
commit 6051fa40b8

@ -1093,4 +1093,9 @@ public class QcStaticTableController extends BaseController {
public List<String> getCpDateTitle(QcStaticTable qcStaticTable) {
return qcStaticTableService.getCpDateTitle(qcStaticTable);
}
@Log(title = "黑蚊香成品分类汇总--数据", businessType = BusinessType.QUERY)
@GetMapping("/getCpDefectDate")
public List<Map<String, String>> getCpDefectDate(QcStaticTable qcStaticTable) {
return qcStaticTableService.getCpDefectDate(qcStaticTable);
}
}

@ -146,4 +146,15 @@ public interface QcStaticTableMapper {
QcStaticTable getBPHzInfoPC(QcStaticTable qcStaticTable);
@MapKey("ymdms")
Map<String, QcStaticTable> getBPDefectMothPCMap(QcStaticTable qcStaticTable);
List<String> getCpDefects(QcStaticTable qcStaticTable);
@MapKey("ymdms")
Map<String, QcStaticTable> getCpDefectMap(QcStaticTable qcStaticTable);
@MapKey("ymdms")
Map<String, QcStaticTable> getCpDefectTypeMap(QcStaticTable qcStaticTable);
@MapKey("ymdms")
Map<String, QcStaticTable> getCpDefectPCMap(QcStaticTable qcStaticTable);
@MapKey("ymdms")
Map<String, QcStaticTable> getCpSampMap(QcStaticTable qcStaticTable);
List<String> getCpDefectTypes(QcStaticTable qcStaticTable);
}

@ -95,4 +95,6 @@ public interface IQcStaticTableService {
QcStaticTable getDefectItemLinePC(QcStaticTable qcStaticTable);
List<String> getCpDateTitle(QcStaticTable qcStaticTable);
List<Map<String, String>> getCpDefectDate(QcStaticTable qcStaticTable);
}

@ -1989,14 +1989,13 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
}
@Override
@DS("#header.poolName")
public List<String> getCpDateTitle(QcStaticTable qcStaticTable) {
//获取不良种类
List<String> titles = new ArrayList<>();//qcStaticTableMapper.getCpDefects(qcStaticTable);
List<String> titles = qcStaticTableMapper.getCpDefects(qcStaticTable);
titles.add("抽样总数");
titles.add("A类");
titles.add("B类");
titles.add("C类");
List<String> abctitles = qcStaticTableMapper.getCpDefectTypes(qcStaticTable);
titles.addAll(abctitles);
titles.add("不良总数");
titles.add("不良率");
titles.add("抽检批数");
@ -2005,6 +2004,87 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
return titles;
}
@Override
@DS("#header.poolName")
public List<Map<String, String>> getCpDefectDate(QcStaticTable qcStaticTable) {
List<Map<String, String>> dtos = new ArrayList<>();
//获取不良项目
List<String> bpDefects = qcStaticTableMapper.getCpDefects(qcStaticTable);
//获取不良类别
List<String> abctitles = qcStaticTableMapper.getCpDefectTypes(qcStaticTable);
//获取时间
List<String> days = getDaysOfMonth(Integer.parseInt(qcStaticTable.getYearMonth().split("-")[0]),
Integer.parseInt(qcStaticTable.getYearMonth().split("-")[1]));
//不良项目map
Map<String,QcStaticTable> defectMaps = qcStaticTableMapper.getCpDefectMap(qcStaticTable);
//抽样分类map
Map<String,QcStaticTable> abcMaps = qcStaticTableMapper.getCpDefectTypeMap(qcStaticTable);
//批次map
Map<String,QcStaticTable> pcMaps = qcStaticTableMapper.getCpDefectPCMap(qcStaticTable);
//抽样总数map
Map<String,QcStaticTable> sampMaps = qcStaticTableMapper.getCpSampMap(qcStaticTable);
Map<String,String> dto1= null;
for(String ymd:days){
dto1= new HashMap<>();
dto1.put("dataType",ymd);
for(int i=0;i<bpDefects.size();i++){
String defectName = bpDefects.get(i)+ymd;
QcStaticTable defectMap = defectMaps.get(defectName);
if(defectMap!=null){
dto1.put("dataTitle"+i,defectMap.getNoOkQty().replace(".00",""));
}
}
//抽样总数
String sampKey = ymd;
QcStaticTable sampMap = sampMaps.get(sampKey);
if(sampMap!=null){
dto1.put("dataTitle"+bpDefects.size(),sampMap.getSampleQty().replace(".00",""));
}
//ABC类
BigDecimal noOkQty = BigDecimal.ZERO;
for(int i=0;i<abctitles.size();i++){
String defectName = abctitles.get(i)+ymd;
QcStaticTable abcMap = abcMaps.get(defectName);
if(abcMap!=null){
dto1.put("dataTitle"+(bpDefects.size()+1+i),abcMap.getNoOkQty().replace(".00",""));
noOkQty = noOkQty.add(new BigDecimal(abcMap.getNoOkQty()));
}
}
//不良总数
dto1.put("dataTitle"+(abctitles.size()+bpDefects.size()+1),noOkQty.toString());
//不良率
BigDecimal nookRate = BigDecimal.ZERO;
if(sampMap!=null && new BigDecimal(sampMap.getSampleQty()).compareTo(BigDecimal.ZERO)!=0){
nookRate = noOkQty
.multiply(new BigDecimal("100"))
.divide(new BigDecimal(sampMap.getSampleQty()),2,BigDecimal.ROUND_HALF_UP);
}
dto1.put("dataTitle"+(abctitles.size()+bpDefects.size()+2),nookRate+"%");
//抽检批数//不合格批数//不合格批次率
QcStaticTable pcMap = pcMaps.get(sampKey);
BigDecimal nookPcRate = BigDecimal.ZERO;
if(pcMap!=null){
dto1.put("dataTitle"+(abctitles.size()+bpDefects.size()+3),pcMap.getSampleQty().replace(".00",""));
dto1.put("dataTitle"+(abctitles.size()+bpDefects.size()+4),pcMap.getNoOkQty().replace(".00",""));
if(pcMap!=null && new BigDecimal(pcMap.getSampleQty()).compareTo(BigDecimal.ZERO)!=0){
nookPcRate = new BigDecimal(pcMap.getNoOkQty())
.multiply(new BigDecimal("100"))
.divide(new BigDecimal(pcMap.getSampleQty()),2,BigDecimal.ROUND_HALF_UP);
dto1.put("dataTitle"+(abctitles.size()+bpDefects.size()+5),nookPcRate+"%");
}
}else{
dto1.put("dataTitle"+(abctitles.size()+bpDefects.size()+3),"0");
dto1.put("dataTitle"+(abctitles.size()+bpDefects.size()+4),"0");
dto1.put("dataTitle"+(abctitles.size()+bpDefects.size()+5),"0%");
}
dtos.add(dto1);
}
return dtos;
}
protected Map<String,String> getHJRow(List<Map<String, String>> dtos,int days){
Map<String,String> dto2 = new HashMap<>();
dto2.put("dataType","合计");

@ -433,10 +433,10 @@
and qct.order_no = #{orderNo}
</if>
<if test="materialCode != null ">
and qct.material_code = #{materialCode}
and (qct.material_code like concat('%',#{materialCode},'%') or qct.material_name like concat('%',#{materialCode},'%'))
</if>
<if test="supplierCode != null ">
and qct.supplier_code = #{supplierCode}
and (qct.supplier_code like concat('%',#{supplierCode},'%') or qct.supplier_name like concat('%',#{materialCode},'%'))
</if>
) t
@ -468,10 +468,10 @@
and qct.order_no = #{orderNo}
</if>
<if test="materialCode != null ">
and qct.material_code = #{materialCode}
and (qct.material_code like concat('%',#{materialCode},'%') or qct.material_name like concat('%',#{materialCode},'%'))
</if>
<if test="supplierCode != null ">
and qct.supplier_code = #{supplierCode}
and (qct.supplier_code like concat('%',#{supplierCode},'%') or qct.supplier_name like concat('%',#{materialCode},'%'))
</if>
) q
GROUP BY q.material_code, q.ymdms,q.rule_name,q.project_no
@ -1327,4 +1327,77 @@
and bp.product_group_name ='白坯' and bp.del_flag = '0' and bp.product_desc_zh like '%白坯%'
) t
</select>
<select id="getCpDefects" resultType="java.lang.String">
select qdtc.class_name
from qc_defect_type qdt
left join qc_defect_type_class qdtc on qdtc.defect_id = qdt.defect_id
where qdt.defect_type = #{checkType} and qdt.del_flag = '0' and qdtc.del_flag = '0'
order by qdtc.sort
</select>
<select id="getCpDefectTypes" resultType="java.lang.String">
select qdt.defect_subclass
from qc_defect_type qdt
where qdt.defect_type = #{checkType} and qdt.del_flag = '0'
order by qdt.defect_subclass
</select>
<select id="getCpDefectMap" resultType="com.op.quality.domain.QcStaticTable">
select t.ymdms,sum(t.noOk_quality) noOkQty
from (
select
concat(qdtc.class_name,CONVERT(varchar(10),qct.create_time, 120)) ymdms,
qctd.defect_code,
qctd.defect_subclass,
qctd.class_id,
qdtc.class_name,
qctd.noOk_quality
from qc_check_task qct
left join qc_check_task_defect qctd on qct.record_id = qctd.belong_to
left join qc_defect_type_class qdtc on qdtc.id = qctd.class_id
where qct.del_flag = '0' and qdtc.class_name is not null --and qct.check_type ='checkTypeSC'
and CONVERT(varchar(7),qct.create_time, 120) = #{yearMonth}
) t group by t.ymdms
</select>
<select id="getCpDefectTypeMap" resultType="com.op.quality.domain.QcStaticTable">
select t.ymdms,sum(t.noOk_quality) noOkQty
from (
select
concat(qctd.defect_subclass,CONVERT(varchar(10),qct.create_time, 120)) ymdms,
qctd.defect_code,
qctd.defect_subclass,
qctd.class_id,
qdtc.class_name,
qctd.noOk_quality
from qc_check_task qct
left join qc_check_task_defect qctd on qct.record_id = qctd.belong_to
left join qc_defect_type_class qdtc on qdtc.id = qctd.class_id
where qct.del_flag = '0' and qdtc.class_name is not null --and qct.check_type ='checkTypeSC'
and CONVERT(varchar(7),qct.create_time, 120) = #{yearMonth}
) t group by t.ymdms
</select>
<select id="getCpDefectPCMap" resultType="com.op.quality.domain.QcStaticTable">
select t.ymdms,
SUM(CASE WHEN t.check_result = 'N' THEN 1 ELSE 0 END) noOkQty,
count(0) sampleQty
from (
select
CONVERT(varchar(10),qct.create_time, 120) ymdms,
check_result
from qc_check_task qct
where qct.del_flag = '0' --and qct.check_type ='checkTypeSC'
and CONVERT(varchar(7),qct.create_time, 120) = #{yearMonth}
) t group by t.ymdms
</select>
<select id="getCpSampMap" resultType="com.op.quality.domain.QcStaticTable">
select t.ymdms,
sum(t.sample_quality) sampleQty
from (
select
CONVERT(varchar(10),qct.create_time, 120) ymdms,
sample_quality
from qc_check_task qct
where qct.del_flag = '0' --and qct.check_type ='checkTypeSC'
and CONVERT(varchar(7),qct.create_time, 120) = #{yearMonth}
) t group by t.ymdms
</select>
</mapper>

Loading…
Cancel
Save