|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package com.op.quality.service.impl;
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
|
import java.text.DateFormat;
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
@ -8,7 +9,6 @@ import java.time.LocalDate;
|
|
|
|
|
import java.time.Month;
|
|
|
|
|
import java.time.YearMonth;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
import java.time.format.TextStyle;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
@ -17,6 +17,7 @@ import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
|
|
import com.op.common.core.utils.StringUtils;
|
|
|
|
|
import com.op.quality.domain.*;
|
|
|
|
|
import com.op.quality.mapper.QMSFileMapper;
|
|
|
|
|
import com.op.system.api.domain.mes.ProLineDTO;
|
|
|
|
|
import com.op.system.api.domain.quality.ChartDTO;
|
|
|
|
|
import com.op.system.api.domain.quality.ChartSeriesDTO;
|
|
|
|
|
import com.op.system.api.domain.quality.FactoryDto;
|
|
|
|
@ -189,6 +190,8 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
|
|
|
|
|
return qcStaticTableMapper.getXJDetail(qcStaticTable);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 只适用测量值格式:["1.0.389","2.0.397","3.0.385","4.0.402"]
|
|
|
|
|
* @param qcCPKInfo
|
|
|
|
@ -1253,8 +1256,8 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
|
|
|
|
|
public QcCPKInfo getTableCPKTitle(QcCPKInfo qcCPKInfo) {
|
|
|
|
|
QcCPKInfo dto = new QcCPKInfo();
|
|
|
|
|
List<String> colName1 = null;
|
|
|
|
|
if("week".equals(qcCPKInfo.getTableType())){//周报
|
|
|
|
|
|
|
|
|
|
if("day".equals(qcCPKInfo.getTableType())){//周报
|
|
|
|
|
colName1 = this.getDayOfYear(qcCPKInfo.getYmArrayStart(),qcCPKInfo.getYmArrayEnd());
|
|
|
|
|
}else{//月报
|
|
|
|
|
colName1 = this.getMonthByMonth(qcCPKInfo.getYmArrayStart(),qcCPKInfo.getYmArrayEnd());
|
|
|
|
|
}
|
|
|
|
@ -1264,36 +1267,93 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
public List<HashMap> getTableCPKList(QcCPKInfo qcCPKInfo) {
|
|
|
|
|
public QcCPKInfo getTableCPKList(QcCPKInfo qcCPKInfo) {
|
|
|
|
|
QcCPKInfo resultDto = new QcCPKInfo();
|
|
|
|
|
//表头数据
|
|
|
|
|
List<String> colNameArray = null;
|
|
|
|
|
if("week".equals(qcCPKInfo.getTableType())){//周报
|
|
|
|
|
|
|
|
|
|
//数据列//cpkType,'-',q.ymdms
|
|
|
|
|
Map<String, QcStaticTable> mxMapData = null;
|
|
|
|
|
List<QcCPKInfo> cpkTypeList = cpkTypeList = qcStaticTableMapper.getCpkTypeList(qcCPKInfo);
|
|
|
|
|
if("day".equals(qcCPKInfo.getTableType())){//日报
|
|
|
|
|
colNameArray = this.getDayOfYear(qcCPKInfo.getYmArrayStart(),qcCPKInfo.getYmArrayEnd());
|
|
|
|
|
mxMapData = qcStaticTableMapper.getDLDataDay(qcCPKInfo);
|
|
|
|
|
}else{//月报
|
|
|
|
|
colNameArray = this.getMonthByMonth(qcCPKInfo.getYmArrayStart(),qcCPKInfo.getYmArrayEnd());
|
|
|
|
|
mxMapData = qcStaticTableMapper.getDLData(qcCPKInfo);
|
|
|
|
|
}
|
|
|
|
|
List<HashMap> mapData = new ArrayList<HashMap>();
|
|
|
|
|
//列表数据
|
|
|
|
|
//主列
|
|
|
|
|
List<QcCPKInfo> cpkTypeList = qcStaticTableMapper.getCpkTypeList(qcCPKInfo);
|
|
|
|
|
//数据列
|
|
|
|
|
List<QcCPKInfo> dxData = qcStaticTableMapper.getDlMxList(qcCPKInfo);
|
|
|
|
|
|
|
|
|
|
List<ChartDTO> echartData = new ArrayList<>();
|
|
|
|
|
HashMap dmap = null;
|
|
|
|
|
for(QcCPKInfo cpkInfo:dxData){
|
|
|
|
|
// dmap = new HashMap();
|
|
|
|
|
// double USL = dto.getUpperDiff().doubleValue();
|
|
|
|
|
// double LSL = dto.getDownDiff().doubleValue();
|
|
|
|
|
// double cpk = calculateCpk(data,USL,LSL);
|
|
|
|
|
// BigDecimal cpkVal = new BigDecimal(Double.toString(cpk)).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
// for(int m=0;m<colNameArray.size();m++){
|
|
|
|
|
// String index = (m+1)+"";
|
|
|
|
|
// dmap.put("date"+index,cpkVal);
|
|
|
|
|
// }
|
|
|
|
|
ChartDTO edata = null;
|
|
|
|
|
for(QcCPKInfo cpkT:cpkTypeList){
|
|
|
|
|
dmap = new HashMap();
|
|
|
|
|
|
|
|
|
|
edata = new ChartDTO();
|
|
|
|
|
edata.setType("line");
|
|
|
|
|
edata.setName(cpkT.getCpkTypeName());
|
|
|
|
|
List<Double> serisedata = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
double USL = cpkT.getUpperDiff().doubleValue();
|
|
|
|
|
double LSL = cpkT.getDownDiff().doubleValue();
|
|
|
|
|
dmap.put("cpkTypeName",cpkT.getCpkTypeName());
|
|
|
|
|
int monthNum = 0;//有数据的月份
|
|
|
|
|
BigDecimal monthSum = BigDecimal.ZERO;
|
|
|
|
|
for(int m=0;m<colNameArray.size();m++){
|
|
|
|
|
String key = cpkT.getCpkType() + "-" + colNameArray.get(m);
|
|
|
|
|
QcStaticTable act = mxMapData.get(key);
|
|
|
|
|
if(act!=null){
|
|
|
|
|
String actArrayStr = act.getQuality().replace("[", "")
|
|
|
|
|
.replace("]", "")
|
|
|
|
|
.replace("\"", "");
|
|
|
|
|
List<String> actArray0 = Arrays.asList(actArrayStr.split(","));
|
|
|
|
|
List<String> actArray = new ArrayList<>();
|
|
|
|
|
for(String avg:actArray0){
|
|
|
|
|
if(avg.matches(".*\\..*\\..*")){
|
|
|
|
|
actArray.add(avg.substring(2));
|
|
|
|
|
}else{
|
|
|
|
|
actArray.add(avg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
double[] data = actArray.stream()
|
|
|
|
|
.mapToDouble(Double::parseDouble) // 将String转换为double
|
|
|
|
|
.toArray(); // 转换为double数组 ;
|
|
|
|
|
|
|
|
|
|
double cpk = calculateCpk(data,USL,LSL);
|
|
|
|
|
BigDecimal cpkVal = new BigDecimal(Double.toString(cpk)).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
String index = (m+1)+"";
|
|
|
|
|
dmap.put("date"+index,cpkVal);
|
|
|
|
|
monthSum = monthSum.add(cpkVal);
|
|
|
|
|
++monthNum;
|
|
|
|
|
|
|
|
|
|
serisedata.add(cpkVal.doubleValue());
|
|
|
|
|
}else{
|
|
|
|
|
String index = (m+1)+"";
|
|
|
|
|
dmap.put("date"+index,"0");
|
|
|
|
|
dmap.put("cpkAvg","0");
|
|
|
|
|
|
|
|
|
|
serisedata.add(0.0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
edata.setData(serisedata);
|
|
|
|
|
|
|
|
|
|
if(monthNum>0){
|
|
|
|
|
BigDecimal avgBD = monthSum.divide(new BigDecimal(monthNum),2,RoundingMode.HALF_UP);
|
|
|
|
|
dmap.put("cpkAvg",avgBD.toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mapData.add(dmap);
|
|
|
|
|
echartData.add(edata);
|
|
|
|
|
}
|
|
|
|
|
//List<QcCPKInfo> myObjectList = convertList(mapData);
|
|
|
|
|
return mapData;
|
|
|
|
|
resultDto.setTableData(mapData);
|
|
|
|
|
resultDto.setEchartData(echartData);
|
|
|
|
|
return resultDto;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
public List<ProLineDTO> getProdLineList() {
|
|
|
|
|
return qcStaticTableMapper.getProdLineList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取指定范围内得月份输出格式yyyy-mm
|
|
|
|
@ -1311,6 +1371,23 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
|
|
|
|
|
}
|
|
|
|
|
return months;
|
|
|
|
|
}
|
|
|
|
|
//获取指定年的周数
|
|
|
|
|
private List<String> getDayOfYear(String startM,String endM){
|
|
|
|
|
String dateFormat = "yyyy-MM-dd";
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(dateFormat);
|
|
|
|
|
LocalDate startDate = LocalDate.parse(startM, formatter);
|
|
|
|
|
LocalDate endDate = LocalDate.parse(endM, formatter);
|
|
|
|
|
|
|
|
|
|
List<String> dateList = new ArrayList<>();
|
|
|
|
|
LocalDate currentDate = startDate;
|
|
|
|
|
|
|
|
|
|
while (!currentDate.isAfter(endDate)) {
|
|
|
|
|
dateList.add(currentDate.format(formatter));
|
|
|
|
|
currentDate = currentDate.plusDays(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return dateList;
|
|
|
|
|
}
|
|
|
|
|
public static void main(String args[]){
|
|
|
|
|
String ymd = "1、0.4016";
|
|
|
|
|
System.out.println(ymd.substring(2));
|
|
|
|
|