|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package com.op.quality.service.impl;
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.math.BigInteger;
|
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
|
import java.text.DateFormat;
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
@ -1393,6 +1394,268 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
|
|
|
|
|
return qcStaticTableMapper.getXJCheckTableDetailList(qcStaticTable);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<String> getDaysOfMonth(QcStaticTable qcStaticTable) {
|
|
|
|
|
return getDaysOfMonth(Integer.parseInt(qcStaticTable.getYearMonth().split("-")[0]),
|
|
|
|
|
Integer.parseInt(qcStaticTable.getYearMonth().split("-")[1])
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
public List<Map<String, String>> getMonthOfData(QcStaticTable qcStaticTable) {
|
|
|
|
|
List<Map<String, String>> dtos = new ArrayList<>();
|
|
|
|
|
//获取白坯种类
|
|
|
|
|
List<QcStaticTable> bpMaterials = qcStaticTableMapper.getBPpMaterials(qcStaticTable);
|
|
|
|
|
Map<String,QcStaticTable> sampMaps = qcStaticTableMapper.getBPNoOkMap(qcStaticTable);
|
|
|
|
|
List<String> days = getDaysOfMonth(Integer.parseInt(qcStaticTable.getYearMonth().split("-")[0]),
|
|
|
|
|
Integer.parseInt(qcStaticTable.getYearMonth().split("-")[1]));
|
|
|
|
|
//List<String> itemNames = new ArrayList<String>(Arrays.asList("抽检数","不良品数","不良率%"));
|
|
|
|
|
Map<String,String> dto1,dto2,dto3 = null;
|
|
|
|
|
for(QcStaticTable bpMaterial:bpMaterials){
|
|
|
|
|
dto1 = new HashMap<>();
|
|
|
|
|
dto1.put("materialName",bpMaterial.getMaterialName());
|
|
|
|
|
dto1.put("dataType","抽检数");
|
|
|
|
|
for(int m=0;m<days.size();m++){
|
|
|
|
|
|
|
|
|
|
QcStaticTable sampMap = sampMaps.get(bpMaterial.getMaterialCode()+days.get(m));
|
|
|
|
|
if(sampMap!=null){
|
|
|
|
|
dto1.put("monthNum"+m,sampMap.getSampleQty().replace(".00",""));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
dtos.add(dto1);
|
|
|
|
|
|
|
|
|
|
dto2 = new HashMap<>();
|
|
|
|
|
dto2.put("materialName",bpMaterial.getMaterialName());
|
|
|
|
|
dto2.put("dataType","不良品数");
|
|
|
|
|
for(int m=0;m<days.size();m++){
|
|
|
|
|
QcStaticTable sampMap = sampMaps.get(bpMaterial.getMaterialCode()+days.get(m));
|
|
|
|
|
if(sampMap!=null){
|
|
|
|
|
dto2.put("monthNum"+m,sampMap.getNoOkQty().replace(".00",""));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
dtos.add(dto2);
|
|
|
|
|
|
|
|
|
|
dto3 = new HashMap<>();
|
|
|
|
|
dto3.put("materialName",bpMaterial.getMaterialName());
|
|
|
|
|
dto3.put("dataType","不良率%");
|
|
|
|
|
for(int m=0;m<days.size();m++){
|
|
|
|
|
QcStaticTable sampMap = sampMaps.get(bpMaterial.getMaterialCode()+days.get(m));
|
|
|
|
|
if(sampMap!=null){
|
|
|
|
|
BigDecimal nookqty = new BigDecimal(StringUtils.isEmpty(sampMap.getNoOkQty())?"0":sampMap.getNoOkQty());
|
|
|
|
|
BigDecimal sampleqty = new BigDecimal(sampMap.getSampleQty());
|
|
|
|
|
if(StringUtils.isEmpty(sampMap.getSampleQty())||sampleqty.compareTo(BigDecimal.ZERO)==0){
|
|
|
|
|
dto3.put("monthNum"+m,"0.00%");
|
|
|
|
|
}else{
|
|
|
|
|
BigDecimal nookrate = nookqty.multiply(new BigDecimal("100"))
|
|
|
|
|
.divide(sampleqty,2,BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
dto3.put("monthNum"+m,nookrate+"%");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
dtos.add(dto3);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return dtos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
public List<QcStaticTable> getMonthOfLine(QcStaticTable qcStaticTable) {
|
|
|
|
|
List<QcStaticTable> dtos = new ArrayList<>();
|
|
|
|
|
Map<String,QcStaticTable> sampMaps = qcStaticTableMapper.getBPSumNoOkMap(qcStaticTable);
|
|
|
|
|
List<String> days = getDaysOfMonth(Integer.parseInt(qcStaticTable.getYearMonth().split("-")[0]),
|
|
|
|
|
Integer.parseInt(qcStaticTable.getYearMonth().split("-")[1]));
|
|
|
|
|
QcStaticTable dto = null;
|
|
|
|
|
for(int m=0;m<days.size();m++){
|
|
|
|
|
dto = new QcStaticTable();
|
|
|
|
|
dto.setYmdms(days.get(m));
|
|
|
|
|
QcStaticTable sampMap = sampMaps.get(days.get(m));
|
|
|
|
|
if(sampMap!=null){
|
|
|
|
|
BigDecimal nookqty = new BigDecimal(StringUtils.isEmpty(sampMap.getNoOkQty())?"0":sampMap.getNoOkQty());
|
|
|
|
|
BigDecimal sampleqty = new BigDecimal(sampMap.getSampleQty());
|
|
|
|
|
if(StringUtils.isEmpty(sampMap.getSampleQty())||sampleqty.compareTo(BigDecimal.ZERO)==0){
|
|
|
|
|
dto.setNoOkBatchRate("0.00");
|
|
|
|
|
}else{
|
|
|
|
|
BigDecimal nookrate = nookqty.multiply(new BigDecimal("100"))
|
|
|
|
|
.divide(sampleqty,2,BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
dto.setNoOkBatchRate(nookrate+"");
|
|
|
|
|
}
|
|
|
|
|
dtos.add(dto);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return dtos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
public List<Map<String, String>> getMonthOfDataRework(QcStaticTable qcStaticTable) {
|
|
|
|
|
List<Map<String, String>> dtos = new ArrayList<>();
|
|
|
|
|
//获取白坯种类
|
|
|
|
|
List<QcStaticTable> bpMaterials = qcStaticTableMapper.getBPpMaterials(qcStaticTable);
|
|
|
|
|
Map<String,QcStaticTable> sampMaps = qcStaticTableMapper.getBPReworkMap(qcStaticTable);
|
|
|
|
|
List<String> days = getDaysOfMonth(Integer.parseInt(qcStaticTable.getYearMonth().split("-")[0]),
|
|
|
|
|
Integer.parseInt(qcStaticTable.getYearMonth().split("-")[1]));
|
|
|
|
|
//List<String> itemNames = new ArrayList<String>(Arrays.asList("抽检数","不良品数","不良率%"));
|
|
|
|
|
Map<String,String> dto1,dto2,dto3 = null;
|
|
|
|
|
for(QcStaticTable bpMaterial:bpMaterials){
|
|
|
|
|
dto1 = new HashMap<>();
|
|
|
|
|
dto1.put("materialName",bpMaterial.getMaterialName());
|
|
|
|
|
dto1.put("dataType","抽检次数");
|
|
|
|
|
for(int m=0;m<days.size();m++){
|
|
|
|
|
|
|
|
|
|
QcStaticTable sampMap = sampMaps.get(bpMaterial.getMaterialCode()+days.get(m));
|
|
|
|
|
if(sampMap!=null){
|
|
|
|
|
dto1.put("monthNum"+m,sampMap.getSampleQty().replace(".00",""));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
dtos.add(dto1);
|
|
|
|
|
|
|
|
|
|
dto2 = new HashMap<>();
|
|
|
|
|
dto2.put("materialName",bpMaterial.getMaterialName());
|
|
|
|
|
dto2.put("dataType","返工次数");
|
|
|
|
|
for(int m=0;m<days.size();m++){
|
|
|
|
|
QcStaticTable sampMap = sampMaps.get(bpMaterial.getMaterialCode()+days.get(m));
|
|
|
|
|
if(sampMap!=null){
|
|
|
|
|
dto2.put("monthNum"+m,sampMap.getNoOkQty().replace(".00",""));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
dtos.add(dto2);
|
|
|
|
|
|
|
|
|
|
dto3 = new HashMap<>();
|
|
|
|
|
dto3.put("materialName",bpMaterial.getMaterialName());
|
|
|
|
|
dto3.put("dataType","返工率%");
|
|
|
|
|
for(int m=0;m<days.size();m++){
|
|
|
|
|
QcStaticTable sampMap = sampMaps.get(bpMaterial.getMaterialCode()+days.get(m));
|
|
|
|
|
if(sampMap!=null){
|
|
|
|
|
BigDecimal nookqty = new BigDecimal(StringUtils.isEmpty(sampMap.getNoOkQty())?"0":sampMap.getNoOkQty());
|
|
|
|
|
BigDecimal sampleqty = new BigDecimal(sampMap.getSampleQty());
|
|
|
|
|
if(StringUtils.isEmpty(sampMap.getSampleQty())||sampleqty.compareTo(BigDecimal.ZERO)==0){
|
|
|
|
|
dto3.put("monthNum"+m,"0.00%");
|
|
|
|
|
}else{
|
|
|
|
|
BigDecimal nookrate = nookqty.multiply(new BigDecimal("100"))
|
|
|
|
|
.divide(sampleqty,2,BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
dto3.put("monthNum"+m,nookrate+"%");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
dtos.add(dto3);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return dtos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
public List<QcStaticTable> getMonthOfLineRework(QcStaticTable qcStaticTable) {
|
|
|
|
|
List<QcStaticTable> dtos = new ArrayList<>();
|
|
|
|
|
Map<String,QcStaticTable> sampMaps = qcStaticTableMapper.getBPSumReworkMap(qcStaticTable);
|
|
|
|
|
List<String> days = getDaysOfMonth(Integer.parseInt(qcStaticTable.getYearMonth().split("-")[0]),
|
|
|
|
|
Integer.parseInt(qcStaticTable.getYearMonth().split("-")[1]));
|
|
|
|
|
QcStaticTable dto = null;
|
|
|
|
|
for(int m=0;m<days.size();m++){
|
|
|
|
|
dto = new QcStaticTable();
|
|
|
|
|
dto.setYmdms(days.get(m));
|
|
|
|
|
QcStaticTable sampMap = sampMaps.get(days.get(m));
|
|
|
|
|
if(sampMap!=null){
|
|
|
|
|
BigDecimal nookqty = new BigDecimal(StringUtils.isEmpty(sampMap.getNoOkQty())?"0":sampMap.getNoOkQty());
|
|
|
|
|
BigDecimal sampleqty = new BigDecimal(sampMap.getSampleQty());
|
|
|
|
|
if(StringUtils.isEmpty(sampMap.getSampleQty())||sampleqty.compareTo(BigDecimal.ZERO)==0){
|
|
|
|
|
dto.setNoOkBatchRate("0.00");
|
|
|
|
|
}else{
|
|
|
|
|
BigDecimal nookrate = nookqty.multiply(new BigDecimal("100"))
|
|
|
|
|
.divide(sampleqty,2,BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
dto.setNoOkBatchRate(nookrate+"");
|
|
|
|
|
}
|
|
|
|
|
dtos.add(dto);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return dtos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
public List<Map<String, String>> getMonthOfDataDefect(QcStaticTable qcStaticTable) {
|
|
|
|
|
List<Map<String, String>> dtos = new ArrayList<>();
|
|
|
|
|
//获取不良种类
|
|
|
|
|
List<String> bpDefects = qcStaticTableMapper.getBpDefects(qcStaticTable);
|
|
|
|
|
Map<String,QcStaticTable> defectMaps = qcStaticTableMapper.getBPDefectMap(qcStaticTable);
|
|
|
|
|
List<String> days = getDaysOfMonth(Integer.parseInt(qcStaticTable.getYearMonth().split("-")[0]),
|
|
|
|
|
Integer.parseInt(qcStaticTable.getYearMonth().split("-")[1]));
|
|
|
|
|
Map<String,String> dto1 = null;
|
|
|
|
|
for(String defectName:bpDefects){
|
|
|
|
|
dto1 = new HashMap<>();
|
|
|
|
|
dto1.put("dataType",defectName);
|
|
|
|
|
BigDecimal rowSum= BigDecimal.ZERO;
|
|
|
|
|
for(int m=0;m<days.size();m++){
|
|
|
|
|
QcStaticTable sampMap = defectMaps.get(defectName+days.get(m));
|
|
|
|
|
if(sampMap!=null){
|
|
|
|
|
dto1.put("monthNum"+m,sampMap.getNoOkQty().replace(".00",""));
|
|
|
|
|
rowSum = rowSum.add(new BigDecimal(sampMap.getNoOkQty()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
dto1.put("rowSum",rowSum.toString().replace(".00",""));
|
|
|
|
|
dtos.add(dto1);
|
|
|
|
|
}
|
|
|
|
|
//合计行
|
|
|
|
|
if(!CollectionUtils.isEmpty(dtos)){
|
|
|
|
|
Map<String,String> dto2 = this.getHJRow(dtos,days.size());
|
|
|
|
|
dtos.add(dto2);
|
|
|
|
|
}
|
|
|
|
|
//抽样数行
|
|
|
|
|
Map<String,QcStaticTable> sampMaps = qcStaticTableMapper.getSampMap(qcStaticTable);
|
|
|
|
|
Map<String,String> dto3 = this.getSampRow(days,sampMaps);
|
|
|
|
|
dtos.add(dto3);
|
|
|
|
|
return dtos;
|
|
|
|
|
}
|
|
|
|
|
protected Map<String,String> getHJRow(List<Map<String, String>> dtos,int days){
|
|
|
|
|
Map<String,String> dto2 = new HashMap<>();
|
|
|
|
|
dto2.put("dataType","合计");
|
|
|
|
|
for(int day=1;day<=days;day++){
|
|
|
|
|
int daym =day;
|
|
|
|
|
dto2.put("monthNum"+day,dtos.stream()
|
|
|
|
|
.map(map -> map.get("monthNum"+daym))
|
|
|
|
|
.filter(numStr -> numStr != null)
|
|
|
|
|
.mapToDouble(numStr -> {
|
|
|
|
|
try {
|
|
|
|
|
return Double.parseDouble(numStr);
|
|
|
|
|
} catch (NumberFormatException e) {
|
|
|
|
|
System.err.println("无法将 " + numStr + " 转换为数字,跳过该元素。");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.sum()+"");
|
|
|
|
|
}
|
|
|
|
|
dto2.put("rowSum",dtos.stream()
|
|
|
|
|
.map(map -> map.get("rowSum"))
|
|
|
|
|
.filter(numStr -> numStr != null)
|
|
|
|
|
.mapToDouble(numStr -> {
|
|
|
|
|
try {
|
|
|
|
|
return Double.parseDouble(numStr);
|
|
|
|
|
} catch (NumberFormatException e) {
|
|
|
|
|
System.err.println("无法将 " + numStr + " 转换为数字,跳过该元素。");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.sum()+"");
|
|
|
|
|
return dto2;
|
|
|
|
|
}
|
|
|
|
|
protected Map<String,String> getSampRow(List<String> days,Map<String,QcStaticTable> sampMaps){
|
|
|
|
|
Map<String,String> dto3 = new HashMap<>();
|
|
|
|
|
dto3.put("dataType","抽样数");
|
|
|
|
|
BigDecimal rowSum= BigDecimal.ZERO;
|
|
|
|
|
for(int m=0;m<days.size();m++){
|
|
|
|
|
QcStaticTable sampMap = sampMaps.get(days.get(m));
|
|
|
|
|
if(sampMap!=null){
|
|
|
|
|
dto3.put("monthNum"+m,sampMap.getSampleQty().replace(".00",""));
|
|
|
|
|
rowSum = rowSum.add(new BigDecimal(sampMap.getSampleQty()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
dto3.put("rowSum",rowSum.toString().replace(".00",""));
|
|
|
|
|
return dto3;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取指定范围内得月份输出格式yyyy-mm
|
|
|
|
|
private List<String> getMonthByMonth(String startM,String endM){
|
|
|
|
|
YearMonth start = YearMonth.of(Integer.parseInt(startM.split("-")[0]), Integer.parseInt(startM.split("-")[1]));
|
|
|
|
@ -1425,6 +1688,7 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
|
|
|
|
|
|
|
|
|
|
return dateList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String args[]){
|
|
|
|
|
String ymd = "1、0.4016";
|
|
|
|
|
System.out.println(ymd.substring(2));
|
|
|
|
|