|
|
|
@ -4,6 +4,11 @@ import java.math.BigDecimal;
|
|
|
|
|
import java.text.DateFormat;
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
@ -788,15 +793,17 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
|
|
|
|
|
public QcStaticTable getTableHzTitle(QcStaticTable qcStaticTable) {
|
|
|
|
|
QcStaticTable dto = new QcStaticTable();
|
|
|
|
|
qcStaticTable.setDataType("unqualified_remark");
|
|
|
|
|
qcStaticTable.setRemark("checkTypeCP");
|
|
|
|
|
qcStaticTable.setRemark(qcStaticTable.getCheckType());
|
|
|
|
|
List<String> cols1 = qcStaticTableMapper.getTableHzTitle(qcStaticTable);
|
|
|
|
|
|
|
|
|
|
if(CollectionUtils.isEmpty(cols1)){
|
|
|
|
|
return dto;
|
|
|
|
|
}
|
|
|
|
|
dto.setColumns1(cols1);
|
|
|
|
|
List<String> cols2 = qcStaticTableMapper.getTableHzTitle2(qcStaticTable);
|
|
|
|
|
|
|
|
|
|
dto.setColumns2(cols2);
|
|
|
|
|
dto.setColumns1(cols1);
|
|
|
|
|
// List<String> cols2 = qcStaticTableMapper.getTableHzTitle2(qcStaticTable);
|
|
|
|
|
//
|
|
|
|
|
// dto.setColumns2(cols2);
|
|
|
|
|
return dto;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -876,8 +883,152 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
|
|
|
|
|
return days;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
public List<HashMap> getTableHzData(QcStaticTable qcStaticTable) {
|
|
|
|
|
List<HashMap> dtos = new ArrayList<>();
|
|
|
|
|
qcStaticTable.setDataType("unqualified_remark");
|
|
|
|
|
qcStaticTable.setRemark(qcStaticTable.getCheckType());
|
|
|
|
|
List<String> noOkTyps = qcStaticTableMapper.getTableHzTitle(qcStaticTable);
|
|
|
|
|
//第一列日期
|
|
|
|
|
List<String> days = this.getHzDays(qcStaticTable.getIncomeTimeStr(),qcStaticTable.getYmdms());
|
|
|
|
|
//抽样数、不良数、不良率
|
|
|
|
|
Map<String,QcStaticTable> samples = qcStaticTableMapper.getSamplesNum(qcStaticTable);
|
|
|
|
|
if(samples.isEmpty()){
|
|
|
|
|
return dtos;
|
|
|
|
|
}
|
|
|
|
|
//不良数
|
|
|
|
|
Map<String,QcStaticTable> noOks = qcStaticTableMapper.getNoOkNum(qcStaticTable);
|
|
|
|
|
HashMap colMap = null;
|
|
|
|
|
for(String col:days){
|
|
|
|
|
colMap = new HashMap();
|
|
|
|
|
colMap.put("timeCol",col);
|
|
|
|
|
String samKey = col;
|
|
|
|
|
QcStaticTable sampl = samples.get(samKey);
|
|
|
|
|
if(sampl!=null&&!sampl.getSampleQuality().equals("0.00")){
|
|
|
|
|
colMap.put("sampleQuality",sampl.getSampleQuality().replaceAll("\\..*", ""));
|
|
|
|
|
BigDecimal noOkRate = new BigDecimal(sampl.getNoOkQuality()).multiply(new BigDecimal("100.00"))
|
|
|
|
|
.divide(new BigDecimal(sampl.getSampleQuality()),2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
colMap.put("noOkRate",noOkRate);
|
|
|
|
|
}else{
|
|
|
|
|
colMap.put("sampleQuality","0");
|
|
|
|
|
colMap.put("noOkRate","0");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//缺陷不良
|
|
|
|
|
for(int i=0;i< noOkTyps.size();i++){
|
|
|
|
|
String noOkTyp = noOkTyps.get(0);
|
|
|
|
|
String noOkTypeKey = col+noOkTyp;
|
|
|
|
|
QcStaticTable noOk = noOks.get(noOkTypeKey);
|
|
|
|
|
if(noOk!=null&&noOk.getNoOkQuality()!=null) {
|
|
|
|
|
colMap.put("col"+i, noOk.getNoOkQuality().replaceAll("\\..*", ""));
|
|
|
|
|
}else{
|
|
|
|
|
colMap.put("col"+i, "0");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dtos.add(colMap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return dtos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
public List<QcStaticTable> getTableHzNoOkData(QcStaticTable qcStaticTable) {
|
|
|
|
|
//不良数
|
|
|
|
|
List<QcStaticTable> dtos = qcStaticTableMapper.getTableHzNoOkData(qcStaticTable);
|
|
|
|
|
|
|
|
|
|
BigDecimal totalNoOkQuality = BigDecimal.ZERO;
|
|
|
|
|
//求不良数和
|
|
|
|
|
for (QcStaticTable dto : dtos) {
|
|
|
|
|
totalNoOkQuality = totalNoOkQuality.add(new BigDecimal(dto.getNoOkQuality()));
|
|
|
|
|
}
|
|
|
|
|
//求占比
|
|
|
|
|
for (QcStaticTable dto : dtos) {
|
|
|
|
|
BigDecimal noOkratio = new BigDecimal(dto.getNoOkQuality())
|
|
|
|
|
.divide(totalNoOkQuality,2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
dto.setNoOkNumRate(noOkratio.toString());
|
|
|
|
|
dto.setNoOkQuality(dto.getNoOkQuality().replaceAll("\\..*", ""));
|
|
|
|
|
}
|
|
|
|
|
return dtos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/****/
|
|
|
|
|
public List<String> getHzDays(String timeStr,String ymd) {
|
|
|
|
|
// 返回的日期集合
|
|
|
|
|
List<String> days = new ArrayList<String>();
|
|
|
|
|
DateFormat dateFormat = null;
|
|
|
|
|
try {
|
|
|
|
|
Calendar tempStart = null;
|
|
|
|
|
Calendar tempEnd = null;
|
|
|
|
|
if ("dd".equals(ymd)) {//天内各小时
|
|
|
|
|
for (int i = 0; i < 24; i++) {
|
|
|
|
|
// 使用String.format()格式化小时,保证每个小时都是两位数
|
|
|
|
|
String hourS = String.format("%02d", i);//String.format("%02d:00", i);
|
|
|
|
|
days.add(hourS);
|
|
|
|
|
}
|
|
|
|
|
} else if ("mm".equals(ymd)){//月内各日
|
|
|
|
|
int year = Integer.parseInt(timeStr.split("-")[0]);
|
|
|
|
|
int month = Integer.parseInt(timeStr.split("-")[1]);
|
|
|
|
|
YearMonth yearMonth = YearMonth.of(year, month);
|
|
|
|
|
// 获取该月份的第一天
|
|
|
|
|
LocalDate firstDayOfMonth = yearMonth.atDay(1);
|
|
|
|
|
// 循环直到下一个月的第一天
|
|
|
|
|
LocalDate currentDate = firstDayOfMonth;
|
|
|
|
|
while (currentDate.getMonthValue() == month) {
|
|
|
|
|
// 使用DateTimeFormatter格式化日期为字符串
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
String formattedDate = currentDate.format(formatter);
|
|
|
|
|
days.add(formattedDate);
|
|
|
|
|
|
|
|
|
|
// 移动到下一天
|
|
|
|
|
currentDate = currentDate.plusDays(1);
|
|
|
|
|
}
|
|
|
|
|
} else if ("yyyy".equals(ymd)){//
|
|
|
|
|
for (Month month : Month.values()) {
|
|
|
|
|
// 使用String.format来构造"yyyy-MM"格式的字符串
|
|
|
|
|
// %d用于整数(年份和月份),但月份需要前面补0(使用%02d)
|
|
|
|
|
String formattedMonth = String.format("%d-%02d", Integer.parseInt(timeStr), month.getValue());
|
|
|
|
|
days.add(formattedMonth);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
return days;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static List<String> getDaysOfMonth(int year, int month) {
|
|
|
|
|
List<String> days = new ArrayList<>();
|
|
|
|
|
YearMonth yearMonth = YearMonth.of(year, month);
|
|
|
|
|
// 获取该月份的第一天
|
|
|
|
|
LocalDate firstDayOfMonth = yearMonth.atDay(1);
|
|
|
|
|
|
|
|
|
|
// 循环直到下一个月的第一天
|
|
|
|
|
LocalDate currentDate = firstDayOfMonth;
|
|
|
|
|
while (currentDate.getMonthValue() == month) {
|
|
|
|
|
// 使用DateTimeFormatter格式化日期为字符串
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
String formattedDate = currentDate.format(formatter);
|
|
|
|
|
days.add(formattedDate);
|
|
|
|
|
|
|
|
|
|
// 移动到下一天
|
|
|
|
|
currentDate = currentDate.plusDays(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return days;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String args[]){
|
|
|
|
|
double a = 0.01;
|
|
|
|
|
System.out.println(new BigDecimal(a).compareTo(BigDecimal.ZERO));
|
|
|
|
|
List<String> months = new ArrayList<>();
|
|
|
|
|
for (Month month : Month.values()) {
|
|
|
|
|
// 使用String.format来构造"yyyy-MM"格式的字符串
|
|
|
|
|
// %d用于整数(年份和月份),但月份需要前面补0(使用%02d)
|
|
|
|
|
String formattedMonth = String.format("%d-%02d",2024, month.getValue());
|
|
|
|
|
months.add(formattedMonth);
|
|
|
|
|
}
|
|
|
|
|
System.out.println(months);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|