定量值分析报表

master
zhaoxiaolin 1 year ago
parent 9c0c534f81
commit 6f08b87290

@ -265,7 +265,7 @@ public class QcCheckTaskIncomeController extends BaseController {
public AjaxResult commitCheckResult(@RequestBody QcCheckTaskIncome qcCheckTaskIncome) {
qcCheckTaskIncome.setUpdateBy(SecurityUtils.getUsername());
qcCheckTaskIncome.setUpdateTime(DateUtils.getNowDate());
return toAjax(qcCheckTaskIncomeService.commitCheckResult(qcCheckTaskIncome));
return toAjax(qcCheckTaskIncomeService.commitCheckResults(qcCheckTaskIncome));
}
/**不良类型**/

@ -313,4 +313,13 @@ public class QcStaticTableController extends BaseController {
util.exportExcel(response, list, "质检不良统计");
}
/**定量值分析--表头--产品名称**/
@GetMapping("/getDLTableAvgInfo")
public QcStaticTable getDLTableAvgInfo(QcStaticTable qcStaticTable) {
return qcStaticTableService.getDLTableAvgInfo(qcStaticTable);
}
@GetMapping("/getDLDetailList")
public List<QcStaticTable> getDLDetailList(QcStaticTable qcStaticTable) {
return qcStaticTableService.getDLDetailList(qcStaticTable);
}
}

@ -8,6 +8,7 @@ import com.op.system.api.domain.quality.ChartSeriesDTO;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
/**
@ -99,6 +100,42 @@ public class QcStaticTable extends BaseEntity {
private String startDateStr;
private String endDateStr;
private String checkType;
private List<String> titleCol1;
private List<String> titleCol2;
private List<HashMap> dxData;
private List<HashMap> details;
public List<HashMap> getDetails() {
return details;
}
public void setDetails(List<HashMap> details) {
this.details = details;
}
public List<String> getTitleCol1() {
return titleCol1;
}
public void setTitleCol1(List<String> titleCol1) {
this.titleCol1 = titleCol1;
}
public List<String> getTitleCol2() {
return titleCol2;
}
public void setTitleCol2(List<String> titleCol2) {
this.titleCol2 = titleCol2;
}
public List<HashMap> getDxData() {
return dxData;
}
public void setDxData(List<HashMap> dxData) {
this.dxData = dxData;
}
public String getCheckType() {
return checkType;

@ -64,4 +64,6 @@ public interface QcStaticTableMapper {
List<QcStaticTable> getWorkcenter();
@MapKey("recordId")
Map<String, QcStaticTable> picsMap(QcStaticTable qcStaticTable);
List<QcStaticTable> getDLTableTitle(QcStaticTable qcStaticTable);
}

@ -43,4 +43,8 @@ public interface IQcStaticTableService {
List<QcCheckType> getCheckTypeList(String typeCode);
List<QcStaticTable> getSupplierList(String typeCode);
QcStaticTable getDLTableAvgInfo(QcStaticTable qcStaticTable);
List<QcStaticTable> getDLDetailList(QcStaticTable qcStaticTable);
}

@ -471,6 +471,71 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
return dtos;
}
@Override
@DS("#header.poolName")
public QcStaticTable getDLTableAvgInfo(QcStaticTable qcStaticTable) {
QcStaticTable dto = new QcStaticTable();
//第一列日期
List<String> days = this.getDays(qcStaticTable.getYmArrayStart(),
qcStaticTable.getYmArrayEnd(),"ymd");
qcStaticTable.setDataType("ymd");
List<QcStaticTable> titleList = qcStaticTableMapper.getDLTableTitle(qcStaticTable);
Map<String, QcStaticTable> titleMap = titleList.stream().collect(Collectors.toMap(QcStaticTable::getYearMonth, (a) -> a));
//表头:第一行
List<String> colName1 = titleList.stream().map(QcStaticTable::getMaterialName).distinct().collect(Collectors.toList());
List<String> colCode1 = titleList.stream().map(QcStaticTable::getMaterialCode).distinct().collect(Collectors.toList());
dto.setTitleCol1(colName1);
//表头:第二行
List<String> colName2 = titleList.stream().map(QcStaticTable::getRuleName).distinct().collect(Collectors.toList());
List<String> colCode2 = titleList.stream().map(QcStaticTable::getProjectNo).distinct().collect(Collectors.toList());
dto.setTitleCol2(colName2);
//均值列表
List<HashMap> dxData = new ArrayList<>();
for(String day:days){
HashMap result = new HashMap();
List<HashMap> detailsData = new ArrayList<>();
HashMap detailResult = new HashMap();
result.put("ymdms",day+"均值");
int i=0,j=0;
for(int m=0;m<colCode1.size();m++){
for(int n=0;n<colCode2.size();n++){
String key = colCode1.get(m)+"-"+colCode2.get(n)+"-"+day;
QcStaticTable avgdto = titleMap.get(key);
if(avgdto!=null){
String avgArrayStr = avgdto.getQuality().replace("[","")
.replace("]","")
.replace("\"","");
List<String> avgArray = Arrays.asList(avgArrayStr.split(","));
BigDecimal addVal = new BigDecimal("0.00");
for(String avgVal:avgArray){
addVal = addVal.add(new BigDecimal(avgVal));
}
BigDecimal avg = addVal.divide(new BigDecimal(avgArray.size()),2,BigDecimal.ROUND_HALF_UP);
result.put("mcode"+m+"Pcode"+n,avg);
detailResult.put("mcode"+m+"Pcode"+n+"Detail",avgArrayStr.replace(",","\n"));
}else{
result.put("mcode"+m+"Pcode"+n,"0.00");
detailResult.put("mcode"+m+"Pcode"+n+"Detail","");
}
}
}
detailsData.add(detailResult);
result.put("details",detailsData);
dxData.add(result);
}
dto.setDxData(dxData);
return dto;
}
@Override
@DS("#header.poolName")
public List<QcStaticTable> getDLDetailList(QcStaticTable qcStaticTable) {
return null;
}
private List<String> getHourProductionTitle(QcStaticTable qcStaticTable) {
// 返回的日期集合
@ -501,6 +566,50 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
return dayHours;
}
public List<String> getDays(String startMonth,String endMonth,String type){
// 返回的日期集合
List<String> days = new ArrayList<String>();
DateFormat dateFormat = null;
try {
Calendar tempStart = null;
Calendar tempEnd = null;
if("ymd".equals(type)){
dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date start = dateFormat.parse(startMonth);//开始
Date end = dateFormat.parse(endMonth);//结束
tempStart = Calendar.getInstance();
tempStart.setTime(start);
tempEnd = Calendar.getInstance();
tempEnd.setTime(end);
tempEnd.add(Calendar.DAY_OF_MONTH, 1);
}else{
dateFormat = new SimpleDateFormat("yyyy-MM");
Date start = dateFormat.parse(startMonth);//开始
Date end = dateFormat.parse(endMonth);//结束
tempStart = Calendar.getInstance();
tempStart.setTime(start);
tempEnd = Calendar.getInstance();
tempEnd.setTime(end);
tempEnd.add(Calendar.MONTH, 1);
}
while (tempStart.before(tempEnd)) {
days.add(dateFormat.format(tempStart.getTime()));
if("ymd".equals(type)) {
tempStart.add(Calendar.DAY_OF_MONTH, 1);
}else{
tempStart.add(Calendar.MONTH, 1);
}
}
} catch (ParseException e) {
e.printStackTrace();
}
return days;
}
}

@ -275,7 +275,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where order_no = #{orderNo}
</update>
<update id="updateWorkOrderBatchStatus">
update pro_order_workorder_batch set qc_status = #{status} where batch_code = #{incomeBatchNo}
update pro_order_workorder_batch set qc_status = #{status} where batch_code = #{incomeBatchNo} and check_type = #{checkType}
</update>
<update id="updatePutStatus">
update wms_product_put set check_status = #{status} where batch_number = #{incomeBatchNo}

@ -82,23 +82,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="getProduceChartDataYM" resultType="com.op.quality.domain.QcStaticTable">
select
concat(qct.material_code,CONVERT(varchar(7),qct.income_time, 120)) materailDate,
<if test='dataType=="ymd" '>
concat(qct.material_code,CONVERT(varchar(10),qct.income_time, 120)) materailDate,
</if>
<if test='dataType=="ym" '>
concat(qct.material_code,CONVERT(varchar(7),qct.income_time, 120)) materailDate,
</if>
qct.material_code materialCode,
qct.material_name materialName,
sum(qct.sample_quality) sampleQuality,
sum(qct.aNoOkquality) aNoOkquality,
sum(qct.bNoOkquality) bNoOkquality,
sum(qct.cNoOkquality) cNoOkquality,
CONVERT(varchar(7),qct.income_time, 120) incomeTime
CONVERT(varchar(7),qct.income_time, 120)
from qc_check_task qct
where qct.del_flag = '0' and qct.type_code = 'produce'
<if test="materialCode != null "> and qct.material_code in (${materialCode})</if>
<if test="workCenter != null "> and qct.supplier_code = #{workCenter}</if>
<if test="ymArrayStart != null "> and CONVERT(varchar(10),qct.income_time, 120) >= #{ymArrayStart}</if>
<if test="ymArrayEnd != null "> and #{ymArrayEnd}>= CONVERT(varchar(10),qct.income_time, 120)</if>
<if test='ymArrayStart != null and dataType=="ym" '> and CONVERT(varchar(7),qct.income_time, 120) >= #{ymArrayStart}</if>
<if test='ymArrayEnd != null and dataType=="ym"'> and #{ymArrayEnd}>= CONVERT(varchar(7),qct.income_time, 120)</if>
<if test='ymArrayStart != null and dataType=="ymd" '> and CONVERT(varchar(10),qct.income_time, 120) >= #{ymArrayStart}</if>
<if test='ymArrayEnd != null and dataType=="ymd"'> and #{ymArrayEnd}>= CONVERT(varchar(10),qct.income_time, 120)</if>
group by qct.material_code ,
qct.material_name ,
CONVERT(varchar(7),qct.income_time, 120)
qct.material_name
<if test='dataType=="ymd" '>
,CONVERT(varchar(10),qct.income_time, 120)
</if>
<if test='dataType=="ym" '>
,CONVERT(varchar(7),qct.income_time, 120)
</if>
</select>
<select id="getWorkcenterList" resultType="com.op.system.api.domain.quality.FactoryDto">
select factory_name factoryName,
@ -255,4 +267,40 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
) t
GROUP by t.source_id
</select>
<select id="getDLTableTitle" resultType="com.op.quality.domain.QcStaticTable">
SELECT
concat(q.material_code,'-',q.project_no,'-',CONVERT(varchar(10),q.ymdms, 120)) yearMonth,
material_code materialCode,
material_name materialName,
ymdms,rule_name ruleName,
project_no projectNo,
STUFF(
(SELECT ',' + t.actual_value
FROM (select
qct.material_code,qct.material_name,
CONVERT(varchar(10),qct.income_time, 120) ymdms,
qctd.rule_name, qctd.project_no,qctd.actual_value
from qc_check_task qct
left join qc_check_task_detail qctd on qct.record_id = qctd.belong_to
where qct.check_type = 'checkTypeLL' and qctd.property_code = '1' and qct.check_time is not null
<if test="ymArrayStart != null "> and CONVERT(varchar(10),qct.income_time, 120) >= CONVERT(varchar(10),#{ymArrayStart}, 120)</if>
<if test="ymArrayEnd != null "> and CONVERT(varchar(10),#{ymArrayEnd}, 120)>=CONVERT(varchar(10),qct.income_time, 120)</if>
) t
WHERE t.material_code = q.material_code and t.project_no = q.project_no and t.ymdms=q.ymdms
FOR xml path('')
),1,1,''
) quality
FROM (
select
qct.material_code,qct.material_name,
CONVERT(varchar(10),qct.income_time, 120) ymdms,
qctd.rule_name,qctd.project_no,qctd.actual_value
from qc_check_task qct
left join qc_check_task_detail qctd on qct.record_id = qctd.belong_to
where qct.check_type = 'checkTypeLL' and qctd.property_code = '1' and qct.check_time is not null
<if test="ymArrayStart != null "> and CONVERT(varchar(10),qct.income_time, 120) >= CONVERT(varchar(10),#{ymArrayStart}, 120)</if>
<if test="ymArrayEnd != null "> and CONVERT(varchar(10),#{ymArrayEnd}, 120)>=CONVERT(varchar(10),qct.income_time, 120)</if>
) q
GROUP BY q.material_code,q.material_name, q.ymdms,q.rule_name,q.project_no
</select>
</mapper>

Loading…
Cancel
Save