|
|
|
@ -1,15 +1,21 @@
|
|
|
|
|
package com.aucma.report.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.ArrayIter;
|
|
|
|
|
import com.aucma.common.core.domain.R;
|
|
|
|
|
import com.aucma.common.utils.DateUtils;
|
|
|
|
|
import com.aucma.report.domain.*;
|
|
|
|
|
import com.aucma.report.mapper.GeneralReportMapper;
|
|
|
|
|
import com.aucma.report.service.IQualityReportService;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.io.Serializable;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* PDA管理Service业务层处理
|
|
|
|
@ -24,19 +30,21 @@ public class QualityReportServiceImpl implements IQualityReportService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 质量缺陷统计分析
|
|
|
|
|
*
|
|
|
|
|
* @param hashMap
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<QualityDefectsStatisticalAnalysis> qualityDefectsStatisticalAnalysisList(Map hashMap) {
|
|
|
|
|
if (hashMap.containsKey("stationCodeList")){
|
|
|
|
|
hashMap.put("stationCodeList",String.valueOf(hashMap.get("stationCodeList")).split(","));
|
|
|
|
|
if (hashMap.containsKey("stationCodeList")) {
|
|
|
|
|
hashMap.put("stationCodeList", String.valueOf(hashMap.get("stationCodeList")).split(","));
|
|
|
|
|
}
|
|
|
|
|
return reportMapper.qualityDefectsStatisticalAnalysisList(hashMap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 少错件报表
|
|
|
|
|
*
|
|
|
|
|
* @param hashMap
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
@ -47,6 +55,7 @@ public class QualityReportServiceImpl implements IQualityReportService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 质量问题前80报表
|
|
|
|
|
*
|
|
|
|
|
* @param hashMap
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
@ -58,6 +67,7 @@ public class QualityReportServiceImpl implements IQualityReportService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 产品追溯报表
|
|
|
|
|
*
|
|
|
|
|
* @param hashMap
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
@ -68,6 +78,7 @@ public class QualityReportServiceImpl implements IQualityReportService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 测温记录报表
|
|
|
|
|
*
|
|
|
|
|
* @param hashMap
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
@ -78,6 +89,7 @@ public class QualityReportServiceImpl implements IQualityReportService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 灌注记录报表
|
|
|
|
|
*
|
|
|
|
|
* @param hashMap
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
@ -88,6 +100,7 @@ public class QualityReportServiceImpl implements IQualityReportService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 质量缺陷统计分析明细
|
|
|
|
|
*
|
|
|
|
|
* @param hashMap
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
@ -98,6 +111,7 @@ public class QualityReportServiceImpl implements IQualityReportService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 产品追溯明细
|
|
|
|
|
*
|
|
|
|
|
* @param hashMap
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
@ -108,6 +122,7 @@ public class QualityReportServiceImpl implements IQualityReportService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 质量缺陷统计分析明细导出
|
|
|
|
|
*
|
|
|
|
|
* @param hashMap
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
@ -116,7 +131,7 @@ public class QualityReportServiceImpl implements IQualityReportService {
|
|
|
|
|
ArrayList<QualityDefectsDetail> defectsDetailArrayList = new ArrayList<>();
|
|
|
|
|
List<QualityDefectsStatisticalAnalysis> analysisList = this.qualityDefectsStatisticalAnalysisList(hashMap);
|
|
|
|
|
for (QualityDefectsStatisticalAnalysis item : analysisList) {
|
|
|
|
|
hashMap.put("stationCode",item.getSTATION_CODE());
|
|
|
|
|
hashMap.put("stationCode", item.getSTATION_CODE());
|
|
|
|
|
List<HashMap<String, Object>> hashMaps = this.qualityDefectsDetailList(hashMap);
|
|
|
|
|
for (HashMap<String, Object> map : hashMaps) {
|
|
|
|
|
QualityDefectsDetail defectsDetail = new QualityDefectsDetail();
|
|
|
|
@ -139,34 +154,167 @@ public class QualityReportServiceImpl implements IQualityReportService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 质量返修率报表
|
|
|
|
|
*
|
|
|
|
|
* @param hashMap
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<RepairRateReport> repairRateReportList(Map hashMap) {
|
|
|
|
|
if (hashMap.containsKey("stationCodeList")){
|
|
|
|
|
if (hashMap.containsKey("stationCodeList")) {
|
|
|
|
|
String[] stationCodeLists = String.valueOf(hashMap.get("stationCodeList")).split(",");
|
|
|
|
|
hashMap.put("stationCodeList", stationCodeLists);
|
|
|
|
|
for (String station : stationCodeLists) {
|
|
|
|
|
if (station.equals("2001") || station.equals("2006")|| station.equals("2007")){
|
|
|
|
|
if (station.equals("2001") || station.equals("2006") || station.equals("2007")) {
|
|
|
|
|
hashMap.put("leakFlag", "1");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
} else {
|
|
|
|
|
String[] stationCodeLists = {"null"};
|
|
|
|
|
hashMap.put("stationCodeList", stationCodeLists);
|
|
|
|
|
}
|
|
|
|
|
return reportMapper.repairRateReportList(hashMap);
|
|
|
|
|
|
|
|
|
|
//日
|
|
|
|
|
if (hashMap.get("month").equals("1")){
|
|
|
|
|
List<RepairRateReport> repairRateReports = reportMapper.repairRateReportList(hashMap);
|
|
|
|
|
return repairRateReports;
|
|
|
|
|
}
|
|
|
|
|
//周
|
|
|
|
|
else if (hashMap.get("month").equals("2")){
|
|
|
|
|
|
|
|
|
|
//将时间扩充到开始时间的周一和结束时间的周末
|
|
|
|
|
String beginTime = getFirstDayOfWeek(String.valueOf(hashMap.get("beginBeginTime")));
|
|
|
|
|
String endTime = getLastDayOfWeek(String.valueOf(hashMap.get("endBeginTime")));
|
|
|
|
|
hashMap.put("year",endTime.substring(0,4));
|
|
|
|
|
hashMap.put("beginBeginTime",beginTime);
|
|
|
|
|
hashMap.put("endBeginTime",endTime);
|
|
|
|
|
List<RepairRateReport> repairRateReports = reportMapper.repairRateReportListWeek(hashMap);
|
|
|
|
|
List<RepairRateReport> collect = repairRateReports.stream().collect(Collectors.collectingAndThen(
|
|
|
|
|
Collectors.toCollection(()->new TreeSet<>(Comparator.comparing(RepairRateReport::getCOLUMN_A))),ArrayList::new
|
|
|
|
|
));
|
|
|
|
|
List<RepairRateReport> repairRateReportsSumWeek = new ArrayList<>();
|
|
|
|
|
for (int i = 0; i < collect.size(); i++){
|
|
|
|
|
|
|
|
|
|
for (int j=0;j<repairRateReports.size();j++){
|
|
|
|
|
if (collect.get(i).getCOLUMN_A()==repairRateReports.get(i).getCOLUMN_A()&&
|
|
|
|
|
collect.get(i).getINSPECTOR_TIME() != repairRateReports.get(i).getINSPECTOR_TIME()
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
collect.get(i).setQUALITY_SUM(repairRateReports.get(i).getQUALITY_SUM()+ repairRateReports.get(i).getQUALITY_SUM());
|
|
|
|
|
collect.get(i).setOFF_LINE_NUM(repairRateReports.get(i).getOFF_LINE_NUM()+ repairRateReports.get(i).getOFF_LINE_NUM());
|
|
|
|
|
collect.get(i).setREPAIR_RATE(repairRateReports.get(i).getREPAIR_RATE()+ repairRateReports.get(i).getREPAIR_RATE());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return collect;
|
|
|
|
|
}
|
|
|
|
|
//月
|
|
|
|
|
//todo 逻辑 数据库会根据每天、不合格数量、所有数量、合格率分组 拿回来根据周/月进行循环累加,然后返回给前端
|
|
|
|
|
else if (hashMap.get("month").equals("3")){
|
|
|
|
|
List<RepairRateReport> repairRateReports = new ArrayList<>();
|
|
|
|
|
//将时间扩充到开始时间的月初和结束时间的月末
|
|
|
|
|
String beginTime = String.valueOf(hashMap.get("beginBeginTime")).substring(0, 7) + "01";
|
|
|
|
|
String endTime = String.valueOf(hashMap.get("endBeginTime")).substring(0, 7) + "31";
|
|
|
|
|
hashMap.put("beginBeginTime",beginTime);
|
|
|
|
|
hashMap.put("endBeginTime",endTime);
|
|
|
|
|
if (beginTime.substring(0,4).equals(endTime.substring(0,4))){
|
|
|
|
|
hashMap.put("year",endTime.substring(0,4));
|
|
|
|
|
repairRateReports = reportMapper.repairRateReportListMONTH(hashMap);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
hashMap.put("year",beginTime.substring(0,4));
|
|
|
|
|
List<RepairRateReport> repairRateReports1 = reportMapper.repairRateReportListMONTH(hashMap);
|
|
|
|
|
hashMap.put("year",endTime.substring(0,4));
|
|
|
|
|
List<RepairRateReport> repairRateReports2 = reportMapper.repairRateReportListMONTH(hashMap);
|
|
|
|
|
repairRateReports.addAll(repairRateReports1);
|
|
|
|
|
repairRateReports.addAll(repairRateReports2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<RepairRateReport> collect = repairRateReports.stream().collect(Collectors.collectingAndThen(
|
|
|
|
|
Collectors.toCollection(()->new TreeSet<>(Comparator.comparing(RepairRateReport::getCOLUMN_A))),ArrayList::new
|
|
|
|
|
));
|
|
|
|
|
List<RepairRateReport> repairRateReportsSumWeek = new ArrayList<>();
|
|
|
|
|
for (int i = 0; i < collect.size(); i++){
|
|
|
|
|
|
|
|
|
|
for (int j=0;j<repairRateReports.size();j++){
|
|
|
|
|
if (collect.get(i).getCOLUMN_A()==repairRateReports.get(i).getCOLUMN_A()&&
|
|
|
|
|
collect.get(i).getINSPECTOR_TIME() != repairRateReports.get(i).getINSPECTOR_TIME()
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
collect.get(i).setQUALITY_SUM(repairRateReports.get(i).getQUALITY_SUM()+ repairRateReports.get(i).getQUALITY_SUM());
|
|
|
|
|
collect.get(i).setOFF_LINE_NUM(repairRateReports.get(i).getOFF_LINE_NUM()+ repairRateReports.get(i).getOFF_LINE_NUM());
|
|
|
|
|
collect.get(i).setREPAIR_RATE(repairRateReports.get(i).getREPAIR_RATE()+ repairRateReports.get(i).getREPAIR_RATE());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return collect;
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
return reportMapper.repairRateReportList(hashMap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取指定日期所在周的周一
|
|
|
|
|
*
|
|
|
|
|
* @param date 日期
|
|
|
|
|
*/
|
|
|
|
|
public String getFirstDayOfWeek(String date) {
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
Date parse = null;
|
|
|
|
|
try {
|
|
|
|
|
parse = sdf.parse(date);
|
|
|
|
|
} catch (ParseException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
Calendar c = Calendar.getInstance();
|
|
|
|
|
c.setTime(parse);
|
|
|
|
|
if (c.get(Calendar.DAY_OF_WEEK) == 1) {
|
|
|
|
|
c.add(Calendar.DAY_OF_MONTH, -1);
|
|
|
|
|
}
|
|
|
|
|
c.add(Calendar.DATE, c.getFirstDayOfWeek() - c.get(Calendar.DAY_OF_WEEK) + 1);
|
|
|
|
|
|
|
|
|
|
String format = sdf.format(c.getTime());
|
|
|
|
|
return format;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据时间获取周日
|
|
|
|
|
* */
|
|
|
|
|
public String getLastDayOfWeek(String date){
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
Date parse = null;
|
|
|
|
|
try {
|
|
|
|
|
parse = sdf.parse(date);
|
|
|
|
|
} catch (ParseException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Calendar c = Calendar.getInstance();
|
|
|
|
|
c.setTime(parse);
|
|
|
|
|
// 如果是周日直接返回
|
|
|
|
|
if (c.get(Calendar.DAY_OF_WEEK) == 1) {
|
|
|
|
|
return sdf.format(parse);
|
|
|
|
|
}
|
|
|
|
|
//System.out.println(c.get(Calendar.DAY_OF_WEEK));
|
|
|
|
|
c.add(Calendar.DATE, 7 - c.get(Calendar.DAY_OF_WEEK) + 1);
|
|
|
|
|
String format = sdf.format(c.getTime());
|
|
|
|
|
return format;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 降级品占比报表
|
|
|
|
|
*
|
|
|
|
|
* @param hashMap
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<DowngradeProportionReport> downgradeProportionReportList(Map hashMap) {
|
|
|
|
|
if (!hashMap.containsKey("dateType")){
|
|
|
|
|
if (!hashMap.containsKey("dateType")) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
hashMap.put("timeSub", Integer.parseInt(String.valueOf(hashMap.get("dateType"))));
|
|
|
|
@ -175,12 +323,13 @@ public class QualityReportServiceImpl implements IQualityReportService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 年度不良率同比报表
|
|
|
|
|
*
|
|
|
|
|
* @param hashMap
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<AdverseRecordYearOnYearReport> adverseRecordYearOnYearList(Map hashMap) {
|
|
|
|
|
if (!hashMap.containsKey("year")){
|
|
|
|
|
if (!hashMap.containsKey("year")) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return reportMapper.adverseRecordYearOnYearList(hashMap);
|
|
|
|
@ -188,6 +337,7 @@ public class QualityReportServiceImpl implements IQualityReportService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 高故障率TOP20报表
|
|
|
|
|
*
|
|
|
|
|
* @param hashMap
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
@ -198,12 +348,57 @@ public class QualityReportServiceImpl implements IQualityReportService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 焊漏率报表
|
|
|
|
|
*
|
|
|
|
|
* @param hashMap
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<WeldLeakRateReport> weldLeakRateList(Map hashMap) {
|
|
|
|
|
if (hashMap.get("month").toString().equals("0")) {
|
|
|
|
|
return reportMapper.weldLeakRateList(hashMap);
|
|
|
|
|
}else if (hashMap.get("month").toString().equals("1")) {
|
|
|
|
|
List<WeldLeakRateReport> weldLeakRateReports = reportMapper.weldLeakRateListMonth(hashMap);
|
|
|
|
|
return weldLeakRateReports;
|
|
|
|
|
}
|
|
|
|
|
String month = hashMap.get("month").toString();
|
|
|
|
|
|
|
|
|
|
return reportMapper.weldLeakRateList(hashMap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//根据年份获取月份日期
|
|
|
|
|
public String[] getMonthBeginTime(String year) {
|
|
|
|
|
String[] array = new String[12];
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
|
|
cal.set(Calendar.YEAR, Integer.parseInt(year));
|
|
|
|
|
cal.set(Calendar.MONTH,0);
|
|
|
|
|
cal.set(Calendar.DATE,1);
|
|
|
|
|
cal.set(Calendar.HOUR,0);
|
|
|
|
|
cal.set(Calendar.MINUTE,0);
|
|
|
|
|
cal.set(Calendar.SECOND,0);
|
|
|
|
|
for (int i = 0; i < 12; i++) {
|
|
|
|
|
array[i] = sdf.format(cal.getTime());
|
|
|
|
|
cal.add(Calendar.MONTH, 1);
|
|
|
|
|
}
|
|
|
|
|
return array;
|
|
|
|
|
}
|
|
|
|
|
//根据年份获取月份日期
|
|
|
|
|
public String[] getMonthEndTime(String year) {
|
|
|
|
|
String[] array = new String[12];
|
|
|
|
|
array[0] = year+"-"+"01-31 23:59:59";
|
|
|
|
|
array[1] = year+"-"+"02-29 23:59:59";
|
|
|
|
|
array[2] = year+"-"+"03-31 23:59:59";
|
|
|
|
|
array[3] = year+"-"+"04-31 23:59:59";
|
|
|
|
|
array[4] = year+"-"+"05-31 23:59:59";
|
|
|
|
|
array[5] = year+"-"+"06-31 23:59:59";
|
|
|
|
|
array[6] = year+"-"+"07-31 23:59:59";
|
|
|
|
|
array[7] = year+"-"+"08-31 23:59:59";
|
|
|
|
|
array[8] = year+"-"+"09-31 23:59:59";
|
|
|
|
|
array[9] = year+"-"+"10-31 23:59:59";
|
|
|
|
|
array[10] = year+"-"+"11-31 23:59:59";
|
|
|
|
|
array[11] = year+"-"+"12-31 23:59:59";
|
|
|
|
|
return array;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|