白坯不良、返工、缺线分布等报表开发;检验任务二次提醒功能改造

master
zhaoxiaolin 5 months ago
parent 615af4da86
commit 31cbf06fad

@ -2,7 +2,7 @@ package com.op.common.core.constant;
/**
*
*
*
* @author OP
*/
public class HttpStatus {
@ -91,3 +91,5 @@ public class HttpStatus {
*/
public static final int WARN = 601;
}

@ -190,9 +190,9 @@ public class RyTask {
remoteQualityService.createCPBatchTask();
}
//质量检验任务没有检查的,一小时后重新发送微信提醒,三分钟一次
//质量检验任务没有检查的,2小时后重新发送微信提醒一次(除成品检验外)
public void resendWXTask(){
logger.info("++质量管理系统+检验任务一小时后重新发送微信提醒+开始++resendWXTask+++++");
logger.info("++质量管理系统+检验任务2小时后重新发送微信提醒一次(成品检验除外)+开始++resendWXTask+++++");
remoteQualityService.resendWXTask();
}

@ -162,49 +162,61 @@ public class MesLineAssistantQtyServiceImpl implements IMesLineAssistantQtyServi
MesLineAssistantQty manQty = assistMaps.get(mesLineAssistant.getProductDateStr());
if(manQty!=null){
//班长用人=当日人数*工时占比
assistdto.setMonitorQty(new BigDecimal(manQty.getMonitorQty())
assistdto.setMonitorQty(new BigDecimal(manQty.getMonitorQty()==null?0L:manQty.getMonitorQty())
.multiply(new BigDecimal(assistdto.getHourRatio().replace("%","")))
.multiply(new BigDecimal("0.01"))
.toString()
);
//班长工时=当日考勤小时数*工时占比
assistdto.setMonitorHour(
monitorHour.multiply(
new BigDecimal(assistdto.getHourRatio().replace("%",""))).toString());
monitorHour.multiply(new BigDecimal(assistdto.getHourRatio().replace("%","")))
.multiply(new BigDecimal("0.01"))
.toString());
//组长用人=当日人数*工时占比
assistdto.setGroupleaderQty(new BigDecimal(manQty.getGroupleaderQty())
assistdto.setGroupleaderQty(new BigDecimal(manQty.getGroupleaderQty()==null?0L:manQty.getGroupleaderQty())
.multiply(new BigDecimal(assistdto.getHourRatio().replace("%","")))
.multiply(new BigDecimal("0.01"))
.toString()
);
//组长工时=当日考勤小时数*工时占比
assistdto.setGroupLeaderHour(
groupleadeHour.multiply(
new BigDecimal(assistdto.getHourRatio().replace("%",""))).toString());
groupleadeHour.multiply(new BigDecimal(assistdto.getHourRatio().replace("%","")))
.multiply(new BigDecimal("0.01"))
.toString()
);
//物料员用人=当日人数*工时占比
assistdto.setMaterialQty(new BigDecimal(manQty.getMaterialQty())
assistdto.setMaterialQty(new BigDecimal(manQty.getMaterialQty()==null?0L:manQty.getMaterialQty())
.multiply(new BigDecimal(assistdto.getHourRatio().replace("%","")))
.multiply(new BigDecimal("0.01"))
.toString()
);
//物料员工时=当日考勤小时数*工时占比
assistdto.setMaterialHour(
materialHour.multiply(
new BigDecimal(assistdto.getHourRatio().replace("%",""))).toString());
materialHour.multiply(new BigDecimal(assistdto.getHourRatio().replace("%","")))
.multiply(new BigDecimal("0.01"))
.toString());
//药管员用人=当日人数*工时占比
assistdto.setPillMgrQty(new BigDecimal(manQty.getPillMgrQty())
assistdto.setPillMgrQty(new BigDecimal(manQty.getPillMgrQty()==null?0L:manQty.getPillMgrQty())
.multiply(new BigDecimal(assistdto.getHourRatio().replace("%","")))
.multiply(new BigDecimal("0.01"))
.toString()
);
//药管员工时=当日考勤小时数*工时占比
assistdto.setPillMgrHour(
pillMgrHour.multiply(new BigDecimal(assistdto.getHourRatio().replace("%",""))).toString());
pillMgrHour.multiply(new BigDecimal(assistdto.getHourRatio().replace("%","")))
.multiply(new BigDecimal("0.01"))
.toString());
//配药员用人=当日人数*工时占比
assistdto.setPillDisQty(new BigDecimal(manQty.getPillDisQty())
assistdto.setPillDisQty(new BigDecimal(manQty.getPillDisQty()==null?0L:manQty.getPillDisQty())
.multiply(new BigDecimal(assistdto.getHourRatio().replace("%","")))
.multiply(new BigDecimal("0.01"))
.toString()
);
//配药员工时=当日考勤小时数/线体数
//配药员工时=当日考勤小时数*工时占比
assistdto.setPillDisHour(
pillDisHour.multiply(
new BigDecimal(assistdto.getHourRatio().replace("%",""))).toString());
pillDisHour.multiply(new BigDecimal(assistdto.getHourRatio().replace("%","")))
.multiply(new BigDecimal("0.01"))
.toString());
}
}
}
@ -225,7 +237,7 @@ public class MesLineAssistantQtyServiceImpl implements IMesLineAssistantQtyServi
.toString()
);
}
//最后一行
MesLineAssistantQtyVo assistdto0 = new MesLineAssistantQtyVo();
//assistdto0.setProductDate(dtos.get(0).getProductDate());
//assistdto0.setFactoryCode(dtos.get(0).getFactoryCode());
@ -238,16 +250,16 @@ public class MesLineAssistantQtyServiceImpl implements IMesLineAssistantQtyServi
monitorHour.add(groupleadeHour).add(materialHour).add(pillMgrHour).add(pillDisHour).toString()
);
MesLineAssistantQty manQty = assistMaps.get(mesLineAssistant.getProductDateStr());
assistdto0.setMonitorQty(manQty.getMonitorQty().toString());
assistdto0.setMonitorHour(monitorHour.toString());
assistdto0.setGroupleaderQty(manQty.getGroupleaderQty().toString());
assistdto0.setGroupLeaderHour(groupleadeHour.toString());
assistdto0.setMaterialQty(manQty.getMaterialQty().toString());
assistdto0.setMaterialHour(materialHour.toString());
assistdto0.setPillMgrQty(manQty.getPillMgrQty().toString());
assistdto0.setPillMgrHour(pillMgrHour.toString());
assistdto0.setPillDisQty(manQty.getPillDisQty().toString());
assistdto0.setPillDisHour(pillDisHour.toString());
assistdto0.setMonitorQty(manQty.getMonitorQty()==null?"0":manQty.getMonitorQty().toString());
assistdto0.setMonitorHour(monitorHour==null?"0":monitorHour.toString());
assistdto0.setGroupleaderQty(manQty.getGroupleaderQty()==null?"0":manQty.getGroupleaderQty().toString());
assistdto0.setGroupLeaderHour(groupleadeHour==null?"0":groupleadeHour.toString());
assistdto0.setMaterialQty(manQty.getMaterialQty()==null?"0":manQty.getMaterialQty().toString());
assistdto0.setMaterialHour(materialHour==null?"0":materialHour.toString());
assistdto0.setPillMgrQty(manQty.getPillMgrQty()==null?"0":manQty.getPillMgrQty().toString());
assistdto0.setPillMgrHour(pillMgrHour==null?"0":pillMgrHour.toString());
assistdto0.setPillDisQty(manQty.getPillDisQty()==null?"0":manQty.getPillDisQty().toString());
assistdto0.setPillDisHour(pillDisHour==null?"0":pillDisHour.toString());
dtos.add(assistdto0);
if(StringUtils.isNotBlank(mesLineAssistant.getLineCode())){
dtos = dtos.stream().filter(dto ->(dto.getLineCode().equals(mesLineAssistant.getLineCode())))

@ -5,6 +5,7 @@ import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.YearMonth;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
@ -864,4 +865,34 @@ public class QcStaticTableController extends BaseController {
}
}
}
@Log(title = "白坯不良率报表--表头", businessType = BusinessType.QUERY)
@GetMapping("/getMonthOfDateTitle")
public List<String> getMonthOfDateTitle(QcStaticTable qcStaticTable) {
return qcStaticTableService.getDaysOfMonth(qcStaticTable);
}
@Log(title = "白坯不良率报表--数表", businessType = BusinessType.QUERY)
@GetMapping("/getMonthOfData")
public List<Map<String, String>> getMonthOfData(QcStaticTable qcStaticTable) {
return qcStaticTableService.getMonthOfData(qcStaticTable);
}
@Log(title = "白坯不良率报表--图表", businessType = BusinessType.QUERY)
@GetMapping("/getMonthOfLine")
public List<QcStaticTable> getMonthOfLine(QcStaticTable qcStaticTable) {
return qcStaticTableService.getMonthOfLine(qcStaticTable);
}
@Log(title = "白坯返工率报表--数表", businessType = BusinessType.QUERY)
@GetMapping("/getMonthOfDataRework")
public List<Map<String, String>> getMonthOfDataRework(QcStaticTable qcStaticTable) {
return qcStaticTableService.getMonthOfDataRework(qcStaticTable);
}
@Log(title = "白坯返工率报表--图表", businessType = BusinessType.QUERY)
@GetMapping("/getMonthOfLineRework")
public List<QcStaticTable> getMonthOfLineRework(QcStaticTable qcStaticTable) {
return qcStaticTableService.getMonthOfLineRework(qcStaticTable);
}
@Log(title = "白坯缺陷排列报表--数表", businessType = BusinessType.QUERY)
@GetMapping("/getMonthOfDataDefect")
public List<Map<String, String>> getMonthOfDataDefect(QcStaticTable qcStaticTable) {
return qcStaticTableService.getMonthOfDataDefect(qcStaticTable);
}
}

@ -86,9 +86,26 @@ public class QcProCheck extends BaseEntity {
private String passRate;
private String chartType;
private String quality;
private String okQuality;
private String shiftId;
private String quality;
private int qualityNook;
public String getQuality() {
return quality;
}
public void setQuality(String quality) {
this.quality = quality;
}
public int getQualityNook() {
return qualityNook;
}
public void setQualityNook(int qualityNook) {
this.qualityNook = qualityNook;
}
public String getShiftId() {
return shiftId;
@ -106,14 +123,6 @@ public class QcProCheck extends BaseEntity {
this.okQuality = okQuality;
}
public String getQuality() {
return quality;
}
public void setQuality(String quality) {
this.quality = quality;
}
public String getChartType() {
return chartType;
}

@ -121,6 +121,24 @@ public class QcStaticTable extends BaseEntity {
private String lineCode;
private String lineName;
private String checkTypeName;
private String sampleQty;
private String noOkQty;
public String getSampleQty() {
return sampleQty;
}
public void setSampleQty(String sampleQty) {
this.sampleQty = sampleQty;
}
public String getNoOkQty() {
return noOkQty;
}
public void setNoOkQty(String noOkQty) {
this.noOkQty = noOkQty;
}
public String getCheckTypeName() {
return checkTypeName;

@ -119,4 +119,20 @@ public interface QcStaticTableMapper {
Map<String,QcStaticTable> getDLDataDay(QcCPKInfo qcCPKInfo);
List<CheckTypeXJDetail> getXJCheckTableDetailList(QcStaticTable qcStaticTable);
List<QcStaticTable> getBPpMaterials(QcStaticTable qcStaticTable);
@MapKey("ymdms")
Map<String, QcStaticTable> getBPNoOkMap(QcStaticTable qcStaticTable);
@MapKey("ymdms")
Map<String, QcStaticTable> getBPSumNoOkMap(QcStaticTable qcStaticTable);
@MapKey("ymdms")
Map<String, QcStaticTable> getBPReworkMap(QcStaticTable qcStaticTable);
@MapKey("ymdms")
Map<String, QcStaticTable> getBPSumReworkMap(QcStaticTable qcStaticTable);
List<String> getBpDefects(QcStaticTable qcStaticTable);
@MapKey("ymdms")
Map<String, QcStaticTable> getBPDefectMap(QcStaticTable qcStaticTable);
@MapKey("ymdms")
Map<String, QcStaticTable> getSampMap(QcStaticTable qcStaticTable);
}

@ -77,4 +77,13 @@ public interface IQcStaticTableService {
List<ProLineDTO> getProdLineList();
List<CheckTypeXJDetail> getXJCheckTableDetailList(QcStaticTable qcStaticTable);
List<String> getDaysOfMonth(QcStaticTable qcStaticTable);
List<Map<String, String>> getMonthOfData(QcStaticTable qcStaticTable);
List<QcStaticTable> getMonthOfLine(QcStaticTable qcStaticTable);
List<Map<String, String>> getMonthOfDataRework(QcStaticTable qcStaticTable);
List<QcStaticTable> getMonthOfLineRework(QcStaticTable qcStaticTable);
List<Map<String, String>> getMonthOfDataDefect(QcStaticTable qcStaticTable);
}

@ -138,7 +138,7 @@ public class QcCheckTaskDetailServiceImpl implements IQcCheckTaskDetailService {
return qcCheckTaskDetailMapper.deleteQcCheckTaskDetailByRecordId(recordId);
}
/**质量检验任务提醒,一小时后微信二次发送**/
/**质量检验任务提醒,2小时后微信再发送一次提醒未检验(成品检验除外)**/
@Override
public AjaxResult resendWXTask() {
@ -154,7 +154,7 @@ public class QcCheckTaskDetailServiceImpl implements IQcCheckTaskDetailService {
new LinkedBlockingQueue<Runnable>());
try {
dateSources.forEach(dateSource -> {
logger.info("++++++++++++" + dateSource.get("poolName") + "++++质量检验任务提醒,一小时后微信二次发送开始++++++++++");
logger.info("++++++++++++" + dateSource.get("poolName") + "++++质量检验任务二次提醒,2小时后微信二次发送开始++++++++++");
Runnable run = () -> resendWXFunc(dateSource.get("poolName"));
executorService.execute(run);
});
@ -173,8 +173,8 @@ public class QcCheckTaskDetailServiceImpl implements IQcCheckTaskDetailService {
//发企业微信--------------------开始
SysNoticeGroup noticeQo = new SysNoticeGroup();
//筛选成品检验 id 7
List<QcCheckReportIncome> noCheckListCP = noCheckList.stream().filter(condition -> condition.getCheckType().equals("checkTypeCP")).collect(Collectors.toList());
String CP = StringUtils.join(noCheckListCP.stream().map(QcCheckReportIncome::getCheckNo).collect(Collectors.toList()).toArray(),",");
// List<QcCheckReportIncome> noCheckListCP = noCheckList.stream().filter(condition -> condition.getCheckType().equals("checkTypeCP")).collect(Collectors.toList());
// String CP = StringUtils.join(noCheckListCP.stream().map(QcCheckReportIncome::getCheckNo).collect(Collectors.toList()).toArray(),",");
//批次成品检验 id 12
List<QcCheckReportIncome> noCheckListCPPC = noCheckList.stream().filter(condition -> condition.getCheckType().equals("checkTypeCPPC")).collect(Collectors.toList());
String CPPC = StringUtils.join(noCheckListCPPC.stream().map(QcCheckReportIncome::getCheckNo).collect(Collectors.toList()).toArray(),",");
@ -188,10 +188,10 @@ public class QcCheckTaskDetailServiceImpl implements IQcCheckTaskDetailService {
List<QcCheckReportIncome> noCheckListSC = noCheckList.stream().filter(condition -> condition.getCheckType().equals("checkTypeSC")).collect(Collectors.toList());
String SC = StringUtils.join(noCheckListSC.stream().map(QcCheckReportIncome::getCheckNo).collect(Collectors.toList()).toArray(),",");
if(noCheckListCP != null || noCheckListCP.size() > 0) {
noticeQo.setNoticeId(7L);
sendWeChartMessage(noticeQo,CP,noCheckListCP.size()+"个成品检验",noCheckListCP);
}
// if(noCheckListCP != null || noCheckListCP.size() > 0) {
// noticeQo.setNoticeId(7L);
// sendWeChartMessage(noticeQo,CP,noCheckListCP.size()+"个成品检验",noCheckListCP);
// }
if(noCheckListCPPC != null || noCheckListCPPC.size() > 0){
noticeQo.setNoticeId(12L);
sendWeChartMessage(noticeQo,CPPC,noCheckListCPPC.size()+"个批次成品检验",noCheckListCPPC);

@ -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));

@ -208,8 +208,9 @@
confirm_time as confirmTime
from qc_check_task
where del_flag = '0'
and check_status = '0'
and datediff( hour, create_time,CONVERT(varchar(10),GETDATE())) > 1
and check_status = '0' and check_type != 'checkTypeCC'
and datediff( hour, create_time,CONVERT(varchar(10),GETDATE())) >= 2
and create_time > DATEADD(DAY, -1, CAST(GETDATE() AS DATE))
and confirm_time is null
</select>

@ -131,6 +131,9 @@
<if test="isqua != null">isqua,</if>
<if test="fileId != null">file_id,</if>
<if test="quality != null">quality,</if>
<if test="qualityNook != null">quality_nook,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="rfid != null and rfid != ''">#{rfid},</if>
@ -160,6 +163,8 @@
<if test="updateTime != null">#{updateTime},</if>
<if test="isqua != null">#{isqua},</if>
<if test="fileId != null">#{fileId},</if>
<if test="quality != null">#{quality},</if>
<if test="qualityNook != null">#{qualityNook},</if>
</trim>
</insert>
<insert id="insertBaseFileBatch">

@ -1035,5 +1035,161 @@
<if test="incomeTimeEnd != null ">and #{incomeTimeEnd} > CONVERT(varchar(30),qct.income_time, 120)</if>
order by qct.order_no,qct.income_batch_no,pow.product_date desc
</select>
<select id="getBPpMaterials" resultType="com.op.quality.domain.QcStaticTable">
select distinct bp.product_code materialCode,
bp.product_desc_zh materialName
from base_product bp
left join qc_check_task qct on qct.check_type = 'checkTypeLL' and qct.material_code = bp.product_code
where bp.product_group_name ='白坯' and bp.del_flag = '0' and bp.product_desc_zh like '%白坯%' and qct.del_flag = '0'
<if test="materialName != null ">
and (
bp.product_code like concat('%',#{materialName},'%') or
bp.product_desc_zh like concat('%',#{materialName},'%')
)
</if>
and CONVERT(varchar(7),qct.create_time, 120) = #{yearMonth}
order by bp.product_code
</select>
<select id="getBPNoOkMap" resultType="com.op.quality.domain.QcStaticTable">
select sum(t.noOk_quality) noOkQty,
sum(t.sample_quality) sampleQty,
concat(t.material_code,t.ymd) ymdms
from(
select qct.noOk_quality,
qct.sample_quality,
qct.material_code,
CONVERT(varchar(10),qct.create_time, 120) ymd
from qc_check_task qct
left join base_product bp on qct.material_code = bp.product_code
where qct.del_flag = '0' and qct.check_type = 'checkTypeLL'
and CONVERT(varchar(7),qct.create_time, 120) = #{yearMonth}
and check_man_code is not null
<if test="materialName != null ">
and (
bp.product_code like concat('%',#{materialName},'%') or
bp.product_desc_zh like concat('%',#{materialName},'%')
)
</if>
and bp.product_group_name ='白坯' and bp.del_flag = '0' and bp.product_desc_zh like '%白坯%'
) t GROUP BY t.ymd,t.material_code
</select>
<select id="getBPSumNoOkMap" resultType="com.op.quality.domain.QcStaticTable">
select sum(t.noOk_quality) noOkQty,
sum(t.sample_quality) sampleQty,
t.ymd ymdms
from(
select qct.noOk_quality,
qct.sample_quality,
CONVERT(varchar(10),qct.create_time, 120) ymd
from qc_check_task qct
left join base_product bp on qct.material_code = bp.product_code
where qct.del_flag = '0' and qct.check_type = 'checkTypeLL'
and CONVERT(varchar(7),qct.create_time, 120) = #{yearMonth}
and check_man_code is not null
<if test="materialName != null ">
and (
bp.product_code like concat('%',#{materialName},'%') or
bp.product_desc_zh like concat('%',#{materialName},'%')
)
</if>
and bp.product_group_name ='白坯' and bp.del_flag = '0' and bp.product_desc_zh like '%白坯%'
) t GROUP BY t.ymd
</select>
<select id="getBPReworkMap" resultType="com.op.quality.domain.QcStaticTable">
select SUM(CASE WHEN t.check_result = 'N' THEN 1 ELSE 0 END) noOkQty,
count(0) sampleQty,
concat(t.material_code,t.ymd) ymdms
from(
select
qct.check_result,
qct.material_code,
CONVERT(varchar(10),qct.create_time, 120) ymd
from qc_check_task qct
left join base_product bp on qct.material_code = bp.product_code
where qct.del_flag = '0' and qct.check_type = 'checkTypeLL'
and CONVERT(varchar(7),qct.create_time, 120) = #{yearMonth}
and check_man_code is not null
<if test="materialName != null ">
and (
bp.product_code like concat('%',#{materialName},'%') or
bp.product_desc_zh like concat('%',#{materialName},'%')
)
</if>
and bp.product_group_name ='白坯' and bp.del_flag = '0' and bp.product_desc_zh like '%白坯%'
) t GROUP BY t.ymd,t.material_code
</select>
<select id="getBPSumReworkMap" resultType="com.op.quality.domain.QcStaticTable">
select SUM(CASE WHEN t.check_result = 'N' THEN 1 ELSE 0 END) noOkQty,
count(0) sampleQty,
t.ymd ymdms
from(
select
qct.check_result,
CONVERT(varchar(10),qct.create_time, 120) ymd
from qc_check_task qct
left join base_product bp on qct.material_code = bp.product_code
where qct.del_flag = '0' and qct.check_type = 'checkTypeLL'
and CONVERT(varchar(7),qct.create_time, 120) = #{yearMonth}
and check_man_code is not null
<if test="materialName != null ">
and (
bp.product_code like concat('%',#{materialName},'%') or
bp.product_desc_zh like concat('%',#{materialName},'%')
)
</if>
and bp.product_group_name ='白坯' and bp.del_flag = '0' and bp.product_desc_zh like '%白坯%'
) t GROUP BY t.ymd
</select>
<select id="getBpDefects" resultType="java.lang.String">
select qdtc.class_name dataType
from qc_defect_type_class qdtc
where qdtc.defect_id ='8504b23592d44055a0c66661d6318c2e'
and qdtc.remark = '白坯专用' and qdtc.del_flag = '0'
</select>
<select id="getBPDefectMap" resultType="com.op.quality.domain.QcStaticTable">
select count(0) noOkQty,
concat(t.class_name,t.ymd) ymdms
from(
select
qdtc.class_name,
CONVERT(varchar(10),qct.create_time, 120) ymd
from qc_check_task qct
left join qc_defect_type_class qdtc on qct.remark_code = qdtc.id
left join base_product bp on qct.material_code = bp.product_code
where qct.del_flag = '0' and qct.check_type = 'checkTypeLL'
and CONVERT(varchar(7),qct.create_time, 120) = #{yearMonth}
and check_man_code is not null
and qdtc.class_name is not null
and bp.product_group_name ='白坯' and bp.del_flag = '0' and bp.product_desc_zh like '%白坯%'
<if test="materialName != null ">
and (
bp.product_code like concat('%',#{materialName},'%') or
bp.product_desc_zh like concat('%',#{materialName},'%')
)
</if>
) t GROUP BY t.ymd,t.class_name
</select>
<select id="getSampMap" resultType="com.op.quality.domain.QcStaticTable">
select count(0) sampleQty,
t.ymd ymdms
from(
select
CONVERT(varchar(10),qct.create_time, 120) ymd
from qc_check_task qct
left join base_product bp on qct.material_code = bp.product_code
where qct.del_flag = '0' and qct.check_type = 'checkTypeLL'
and CONVERT(varchar(7),qct.create_time, 120) = #{yearMonth}
and check_man_code is not null
and bp.product_group_name ='白坯' and bp.del_flag = '0' and bp.product_desc_zh like '%白坯%'
<if test="materialName != null ">
and (
bp.product_code like concat('%',#{materialName},'%') or
bp.product_desc_zh like concat('%',#{materialName},'%')
)
</if>
) t GROUP BY t.ymd
</select>
</mapper>

Loading…
Cancel
Save