|
|
|
@ -1,15 +1,18 @@
|
|
|
|
|
package com.op.quality.controller;
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.text.DateFormat;
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
|
|
import com.op.common.core.utils.DateUtils;
|
|
|
|
|
import com.op.system.api.domain.quality.ChartDTO;
|
|
|
|
|
import com.op.system.api.domain.quality.FactoryDto;
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
@ -86,26 +89,68 @@ public class QcStaticTableController extends BaseController {
|
|
|
|
|
qcStaticTable.setYmArrayStart(ymStr);
|
|
|
|
|
qcStaticTable.setYmArrayEnd(ymStr);
|
|
|
|
|
}
|
|
|
|
|
if(StringUtils.isNotBlank(qcStaticTable.getMaterialCode())){
|
|
|
|
|
qcStaticTable.setMaterialCode("'"+qcStaticTable.getMaterialCode().replace(",","','")+"'");
|
|
|
|
|
}
|
|
|
|
|
//xAxis;
|
|
|
|
|
if(qcStaticTable.getYmArrayStart().equals(qcStaticTable.getYmArrayEnd())){
|
|
|
|
|
/**月内每日**/
|
|
|
|
|
List<String> days = this.getXNames(qcStaticTable.getYmArrayStart()+"-01",
|
|
|
|
|
qcStaticTable.getYmArrayEnd()+"-01","ymd");
|
|
|
|
|
resultdto.setxAxis(days);
|
|
|
|
|
|
|
|
|
|
qcStaticTable.setDataType("ymd");
|
|
|
|
|
qcStaticTable.setYmArrayStart(days.get(0));
|
|
|
|
|
qcStaticTable.setYmArrayEnd(days.get(days.size()-1));
|
|
|
|
|
}else{
|
|
|
|
|
/**年内各月**/
|
|
|
|
|
List<String> months = this.getXNames(qcStaticTable.getYmArrayStart(),qcStaticTable.getYmArrayEnd(),"ym");
|
|
|
|
|
resultdto.setxAxis(months);
|
|
|
|
|
|
|
|
|
|
qcStaticTable.setDataType("ym");
|
|
|
|
|
qcStaticTable.setYmArrayStart(months.get(0));
|
|
|
|
|
qcStaticTable.setYmArrayEnd(months.get(months.size()-1));
|
|
|
|
|
}
|
|
|
|
|
//series;//legend.data
|
|
|
|
|
List<QcStaticTable> seriesdtos= qcStaticTableService.getProduceChartData(qcStaticTable);
|
|
|
|
|
ChartDTO chartDTO = new ChartDTO();
|
|
|
|
|
for(QcStaticTable seriesdto:seriesdtos){
|
|
|
|
|
chartDTO.setName(seriesdto.getMaterialName());
|
|
|
|
|
chartDTO.setType("line");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<QcStaticTable> serieDTOs = qcStaticTableService.getProduceNames(qcStaticTable);
|
|
|
|
|
//legendData
|
|
|
|
|
List<String> pnames = serieDTOs.stream().map(u -> u.getMaterialName()).collect(Collectors.toList());
|
|
|
|
|
resultdto.setLegendData(pnames);
|
|
|
|
|
|
|
|
|
|
Map<String,QcStaticTable> seriesdtos= null;
|
|
|
|
|
if("ymd".equals(qcStaticTable.getDataType())){//ymd
|
|
|
|
|
//code->materialCode+yyyy-mm-dd
|
|
|
|
|
seriesdtos= qcStaticTableService.getProduceChartData(qcStaticTable);
|
|
|
|
|
}else{//ym
|
|
|
|
|
//code->materialCode+yyyy-mm-dd
|
|
|
|
|
seriesdtos= qcStaticTableService.getProduceChartDataYM(qcStaticTable);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resultdto.setSeries(null);
|
|
|
|
|
List<ChartDTO> seriesChart = new ArrayList<>();
|
|
|
|
|
for(QcStaticTable serieDTO:serieDTOs){
|
|
|
|
|
ChartDTO chartDTO = new ChartDTO();
|
|
|
|
|
chartDTO.setName(serieDTO.getMaterialName());
|
|
|
|
|
chartDTO.setType("line");
|
|
|
|
|
String keyPre = serieDTO.getMaterialCode();
|
|
|
|
|
List<Double> datas = new ArrayList<>();
|
|
|
|
|
for(String ymd:resultdto.getxAxis()){
|
|
|
|
|
String key = keyPre+ymd;
|
|
|
|
|
QcStaticTable mdata = seriesdtos.get(key);
|
|
|
|
|
if(mdata != null){
|
|
|
|
|
BigDecimal defectRate = (mdata.getaNoOkquality().add(mdata.getbNoOkquality()).multiply(new BigDecimal("0.65"))
|
|
|
|
|
.add(mdata.getcNoOkquality()).multiply(new BigDecimal(0.35)))
|
|
|
|
|
.divide(new BigDecimal(mdata.getSampleQuality()))
|
|
|
|
|
.setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
datas.add(defectRate.doubleValue());
|
|
|
|
|
}else{
|
|
|
|
|
datas.add(0.00);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
chartDTO.setData(datas);
|
|
|
|
|
seriesChart.add(chartDTO);
|
|
|
|
|
}
|
|
|
|
|
resultdto.setSeries(seriesChart);
|
|
|
|
|
|
|
|
|
|
return resultdto;
|
|
|
|
|
}
|
|
|
|
@ -163,4 +208,8 @@ public class QcStaticTableController extends BaseController {
|
|
|
|
|
util.exportExcel(response, list, "质量系统报数据");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/getWorkcenterList")
|
|
|
|
|
public List<FactoryDto> getWorkcenterList(FactoryDto factoryDto) {
|
|
|
|
|
return qcStaticTableService.getWorkcenterList(factoryDto);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|