巡检不良分析图表

master
zhaoxiaolin 1 year ago
parent a68a3ac1a8
commit 827657c43d

@ -12,6 +12,24 @@ public class ChartSeriesDTO {
private List<String> yAxisData;
private List<ChartDTO> series;
private List<String> legendData;
private List<String> xAxisData;
public List<String> getxAxisData() {
return xAxisData;
}
public void setxAxisData(List<String> xAxisData) {
this.xAxisData = xAxisData;
}
public List<String> getLegendData() {
return legendData;
}
public void setLegendData(List<String> legendData) {
this.legendData = legendData;
}
public List<String> getyAxisData() {
return yAxisData;

@ -12,6 +12,7 @@ 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.ChartSeriesDTO;
import com.op.system.api.domain.quality.FactoryDto;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -251,4 +252,16 @@ public class QcStaticTableController extends BaseController {
List<QcStaticTable> list = qcStaticTableService.getXJCheckTableDetail(qcStaticTable);
return list;
}
/**巡检小时不良**/
@GetMapping("/getXJChartData")
public ChartSeriesDTO getXJChartData(QcStaticTable qcStaticTable) {
if(StringUtils.isEmpty(qcStaticTable.getYmdms())){
LocalDate date = LocalDate.now();
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String ymStr = dtf.format(date);
qcStaticTable.setYmdms(ymStr);//end
}
ChartSeriesDTO dto = qcStaticTableService.getXJChartData(qcStaticTable);
return dto;
}
}

@ -124,6 +124,15 @@ public class QcCheckReportIncome extends BaseEntity {
private String checkTimeEnd;
private String typeCode;//大类
private String checkType;//小类
private String checkName;
public String getCheckName() {
return checkName;
}
public void setCheckName(String checkName) {
this.checkName = checkName;
}
public BigDecimal getSampleQuality() {
return sampleQuality;

@ -144,6 +144,15 @@ public class QcCheckTaskProduce extends BaseEntity {
@Excel(name = "C类不合格数量")
private BigDecimal cNoOkquality;
private String checkName;
public String getCheckName() {
return checkName;
}
public void setCheckName(String checkName) {
this.checkName = checkName;
}
public String getOrderType() {
return orderType;

@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import com.op.common.core.annotation.Excel;
import com.op.common.core.web.domain.BaseEntity;
import com.op.system.api.domain.quality.ChartDTO;
import com.op.system.api.domain.quality.ChartSeriesDTO;
import java.math.BigDecimal;
import java.util.Date;
@ -83,6 +84,24 @@ public class QcStaticTable extends BaseEntity {
private String column180190;
private String column190200;
private String column200210;
private String startDateStr;
private String endDateStr;
public String getStartDateStr() {
return startDateStr;
}
public void setStartDateStr(String startDateStr) {
this.startDateStr = startDateStr;
}
public String getEndDateStr() {
return endDateStr;
}
public void setEndDateStr(String endDateStr) {
this.endDateStr = endDateStr;
}
public String getColumn080090() {
return column080090;
@ -531,4 +550,5 @@ public class QcStaticTable extends BaseEntity {
public void setSupplierName(String supplierName) {
this.supplierName = supplierName;
}
}

@ -45,4 +45,10 @@ public interface QcStaticTableMapper {
List<QcStaticTable> getXJProjects(QcStaticTable qcStaticTable);
@MapKey("ymdms")
Map<String,QcStaticTable> getProjectDetail(QcStaticTable qcStaticTable);
List<String> getBatchnos(String orderNo);
List<QcStaticTable> getLegendData(QcStaticTable qcStaticTable);
@MapKey("ymdms")
Map<String, QcStaticTable> getXJMapData(QcStaticTable qcStaticTable);
}

@ -4,6 +4,7 @@ import java.util.List;
import java.util.Map;
import com.op.quality.domain.QcStaticTable;
import com.op.system.api.domain.quality.ChartSeriesDTO;
import com.op.system.api.domain.quality.FactoryDto;
/**
@ -33,4 +34,6 @@ public interface IQcStaticTableService {
List<QcStaticTable> getXJCheckTableList(QcStaticTable qcStaticTable);
List<QcStaticTable> getXJCheckTableDetail(QcStaticTable qcStaticTable);
ChartSeriesDTO getXJChartData(QcStaticTable qcStaticTable);
}

@ -389,7 +389,7 @@ public class QcCheckTaskIncomeServiceImpl implements IQcCheckTaskIncomeService {
//发起来料检验OA流程
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("user",qcCheckTaskIncome.getUpdateBy());//提交人工号
paramMap.put("user","019047");//提交人工号qcCheckTaskIncome.getUpdateBy()
paramMap.put("requestLevel",0);//流程紧急度
paramMap.put("requestName","ZL0010-来料检验不合格审批流程(定单:"+qcCheckTaskIncome.getOrderNo()+")");//流程名称
paramMap.put("workflowld","26258");//该流程对应的唯- workFlowld
@ -397,10 +397,10 @@ public class QcCheckTaskIncomeServiceImpl implements IQcCheckTaskIncomeService {
StringBuffer mainObject = new StringBuffer();
mainObject.append("{");
mainObject.append("\"CQ\":"+1);//厂区
mainObject.append("\"LLLB\":"+0);//来料类别【0、1】
mainObject.append("\"MATNR\""+"\"000000010101003200\"");//物料编码
mainObject.append(",\"LLLB\":"+0);//来料类别【0、1】
mainObject.append(",\"MATNR\":"+"\"000000010101003200\"");//物料编码
//mainObject.append("\"MAKTX\""+MATNR);//物料名称
mainObject.append("{");
mainObject.append("}");
paramMap.put("mainObject",mainObject.toString());
logger.info("流程Id 26258:"+ JSONObject.toJSONString(paramMap));
AjaxResult oaR = remoteOpenService.OAInspection(paramMap);
@ -549,24 +549,24 @@ public class QcCheckTaskIncomeServiceImpl implements IQcCheckTaskIncomeService {
n = qcCheckUnqualifiedMapper.insertQcCheckUnqualified(unqualified);
logger.info("qc_check_unqualified:"+n);
//发起来料检验OA流程
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("user",updateBy);//提交人工号
paramMap.put("requestLevel",0);//流程紧急度
paramMap.put("requestName","ZL0010-来料检验不合格审批流程(定单:"+qcCheckTaskIncome.getOrderNo()+")");//流程名称
paramMap.put("workflowld","26258");//该流程对应的唯- workFlowld
StringBuffer mainObject = new StringBuffer();
mainObject.append("{");
mainObject.append("\"CQ\":"+1);//厂区
mainObject.append("\"LLLB\":"+0);//来料类别【0、1】
mainObject.append("\"MATNR\""+"\"000000010101003200\"");//物料编码
//mainObject.append("\"MAKTX\""+MATNR);//物料名称
mainObject.append("{");
paramMap.put("mainObject",mainObject.toString());
AjaxResult oaR = remoteOpenService.OAInspection(paramMap);
logger.info("流程Id 26258:"+ JSONObject.toJSONString(oaR));
// //发起来料检验OA流程
// Map<String, Object> paramMap = new HashMap<>();
// paramMap.put("user",updateBy);//提交人工号
// paramMap.put("requestLevel",0);//流程紧急度
// paramMap.put("requestName","ZL0010-来料检验不合格审批流程(定单:"+qcCheckTaskIncome.getOrderNo()+")");//流程名称
// paramMap.put("workflowld","26258");//该流程对应的唯- workFlowld
//
// StringBuffer mainObject = new StringBuffer();
// mainObject.append("{");
// mainObject.append("\"CQ\":"+1);//厂区
// mainObject.append("\"LLLB\":"+0);//来料类别【0、1】
// mainObject.append("\"MATNR\""+"\"000000010101003200\"");//物料编码
// //mainObject.append("\"MAKTX\""+MATNR);//物料名称
// mainObject.append("{");
// paramMap.put("mainObject",mainObject.toString());
//
// AjaxResult oaR = remoteOpenService.OAInspection(paramMap);
// logger.info("流程Id 26258:"+ JSONObject.toJSONString(oaR));
}
return n ;

@ -1,11 +1,20 @@
package com.op.quality.service.impl;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
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 com.baomidou.dynamic.datasource.annotation.DS;
import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.StringUtils;
import com.op.quality.domain.QcCheckTaskIncome;
import com.op.system.api.domain.quality.ChartDTO;
import com.op.system.api.domain.quality.ChartSeriesDTO;
import com.op.system.api.domain.quality.FactoryDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -141,6 +150,14 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
@DS("#header.poolName")
public List<QcStaticTable> getXJCheckTableList(QcStaticTable qcStaticTable) {
List<QcStaticTable> tabledtos = qcStaticTableMapper.getXJCheckTableList(qcStaticTable);
for(QcStaticTable tabledto:tabledtos){
List<String> batchnos = qcStaticTableMapper.getBatchnos(tabledto.getOrderNo());
String ordernoStr = "";
for(String batchno:batchnos){
ordernoStr += batchno+";";
};
tabledto.setIncomeBatchNo(ordernoStr);
}
return tabledtos;
}
@ -253,5 +270,83 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
project.setColumn200210("-");
}
}
/**巡检小时不良**/
@Override
@DS("#header.poolName")
public ChartSeriesDTO getXJChartData(QcStaticTable qcStaticTable) {
ChartSeriesDTO seriesDTO = new ChartSeriesDTO();
//获取当天参与生产的车间
List<QcStaticTable> legends = qcStaticTableMapper.getLegendData(qcStaticTable);
List<String> legendData = new ArrayList<>();
if(!CollectionUtils.isEmpty(legends)){
legendData=legends.stream().map(QcStaticTable::getSupplierName).collect(Collectors.toList());
}else{
return null;
}
seriesDTO.setLegendData(legendData);
//横轴时间
qcStaticTable.setStartDateStr(qcStaticTable.getYmdms()+" 08:00:00");
qcStaticTable.setEndDateStr(qcStaticTable.getYmdms()+" 08:00:00");
List<String> xAxisData = this.getHourProductionTitle(qcStaticTable);
seriesDTO.setxAxisData(xAxisData);
//数据
Map<String,QcStaticTable> dataMap = qcStaticTableMapper.getXJMapData(qcStaticTable);
List<ChartDTO> series = new ArrayList<>();
ChartDTO serie = null;
for(QcStaticTable legend:legends){
serie= new ChartDTO();
serie.setName(legend.getSupplierName());
List<Double> data = new ArrayList<>();
for(String houreName:xAxisData){
String key = legend.getSupplierCode()+houreName.replace("时","");
QcStaticTable qt = dataMap.get(key);
if(qt!=null&&StringUtils.isNotBlank(qt.getSampleQuality())){
BigDecimal noOkRate = new BigDecimal(qt.getNoOkNums())
.multiply(new BigDecimal(100))
.divide(new BigDecimal(qt.getSampleQuality()),2,BigDecimal.ROUND_HALF_UP);
data.add(noOkRate.doubleValue());
}else{
data.add(0.00);
}
serie.setData(data);
}
serie.setData(data);
series.add(serie);
}
seriesDTO.setSeries(series);
return seriesDTO;
}
private List<String> getHourProductionTitle(QcStaticTable qcStaticTable) {
// 返回的日期集合
List<String> dayHours = new ArrayList<String>();
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH");
try {
Date start = dateFormat.parse(qcStaticTable.getStartDateStr());//开始
Date end = dateFormat.parse(qcStaticTable.getEndDateStr());//结束
Calendar calendar = Calendar.getInstance();
calendar.setTime(end);
calendar.add(Calendar.HOUR_OF_DAY, 14);
end = calendar.getTime();
Calendar tempStart = Calendar.getInstance();
tempStart.setTime(start);
Calendar tempEnd = Calendar.getInstance();
tempEnd.setTime(end);
while (tempStart.before(tempEnd)) {
dayHours.add(dateFormat.format(tempStart.getTime()).split(" ")[1]+"时");
tempStart.add(Calendar.HOUR_OF_DAY, 1);
}
} catch (ParseException e) {
e.printStackTrace();
}
return dayHours;
}
}

@ -34,6 +34,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="factoryCode" column="factory_code" />
<result property="delFlag" column="del_flag" />
<result property="sampleQuality" column="sample_quality" />
<result property="checkName" column="check_name" />
</resultMap>
<sql id="selectQcCheckReportIncomeVo">
@ -49,7 +51,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
qct.supplier_code, qct.supplier_name, qct.income_time, qct.check_loc, qct.check_status,
qct.check_man_code, qct.check_man_name,qct.check_time, qct.check_result, qct.status,qct.sample_quality,
qct.create_by,qct.create_time, qct.update_by, qct.update_time,qct.check_type,
q.type_code
q.type_code,q.check_name
from qc_check_task qct
left join qc_check_type q on q.id = qct.check_type
<where>

@ -36,6 +36,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="factoryCode" column="factory_code" />
<result property="delFlag" column="del_flag" />
<result property="checkType" column="check_type" />
<result property="checkName" column="check_name" />
</resultMap>
<sql id="selectQcCheckTaskProduceVo">
@ -56,7 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
qct.create_by,qct.create_time, qct.update_by, qct.update_time,
qct.check_type,qct.sample_quality,qct.noOk_quality,
qct.aNoOkquality,qct.bNoOkquality,qct.cNoOkquality,
q.type_code
q.type_code,q.check_name
from qc_check_task qct
left join qc_check_type q on q.id = qct.check_type
<where>

@ -63,9 +63,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ctp.sample_num,
ctp.sort
FROM qc_check_type_project ctp
LEFT JOIN qc_check_project cp ON ctp.project_id = cp.id AND cp.del_flag = '0'
LEFT JOIN qc_check_project cp ON ctp.project_id = cp.id
<where>
AND ctp.del_flag = '0'
AND ctp.del_flag = '0' AND cp.del_flag = '0'
<if test="projectId != null and projectId != ''"> and ctp.project_id = #{projectId}</if>
<if test="typeId != null and typeId != ''"> and ctp.type_id = #{typeId}</if>
<if test="standardValue != null and standardValue != ''"> and ctp.standard_value like concat('%', #{standardValue}, '%')</if>

@ -132,26 +132,54 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getProjectDetail" resultType="com.op.quality.domain.QcStaticTable">
select qctd.project_id projectId,
qctd.status,
SUBSTRING(CONVERT(varchar(18),qctd.create_time, 120), 12, 5),
CONVERT(VARCHAR(5),qctd.create_time, 108),
concat(qctd.project_id,
case when '09:00'>= SUBSTRING(CONVERT(varchar(18),qctd.create_time, 120), 12, 5) and SUBSTRING(CONVERT(varchar(18),qctd.create_time, 120), 12, 5)> '08:00' then '08'
when '10:00'>= SUBSTRING(CONVERT(varchar(18),qctd.create_time, 120), 12, 5) and SUBSTRING(CONVERT(varchar(18),qctd.create_time, 120), 12, 5)> '09:00' then '09'
when '11:00'>= SUBSTRING(CONVERT(varchar(18),qctd.create_time, 120), 12, 5) and SUBSTRING(CONVERT(varchar(18),qctd.create_time, 120), 12, 5)> '10:00' then '10'
when '12:00'>= SUBSTRING(CONVERT(varchar(18),qctd.create_time, 120), 12, 5) and SUBSTRING(CONVERT(varchar(18),qctd.create_time, 120), 12, 5)> '11:00' then '11'
when '13:30'>= SUBSTRING(CONVERT(varchar(18),qctd.create_time, 120), 12, 5) and SUBSTRING(CONVERT(varchar(18),qctd.create_time, 120), 12, 5)> '12:30' then '12'
when '14:30'>= SUBSTRING(CONVERT(varchar(18),qctd.create_time, 120), 12, 5) and SUBSTRING(CONVERT(varchar(18),qctd.create_time, 120), 12, 5)> '13:30' then '13'
when '15:30'>= SUBSTRING(CONVERT(varchar(18),qctd.create_time, 120), 12, 5) and SUBSTRING(CONVERT(varchar(18),qctd.create_time, 120), 12, 5)> '14:30' then '14'
when '16:30'>= SUBSTRING(CONVERT(varchar(18),qctd.create_time, 120), 12, 5) and SUBSTRING(CONVERT(varchar(18),qctd.create_time, 120), 12, 5)> '15:30' then '15'
when '17:30'>= SUBSTRING(CONVERT(varchar(18),qctd.create_time, 120), 12, 5) and SUBSTRING(CONVERT(varchar(18),qctd.create_time, 120), 12, 5)> '16:30' then '16'
when '19:00'>= SUBSTRING(CONVERT(varchar(18),qctd.create_time, 120), 12, 5) and SUBSTRING(CONVERT(varchar(18),qctd.create_time, 120), 12, 5)> '18:00' then '18'
when '20:00'>= SUBSTRING(CONVERT(varchar(18),qctd.create_time, 120), 12, 5) and SUBSTRING(CONVERT(varchar(18),qctd.create_time, 120), 12, 5)> '19:00' then '19'
when '21:00'>= SUBSTRING(CONVERT(varchar(18),qctd.create_time, 120), 12, 5) and SUBSTRING(CONVERT(varchar(18),qctd.create_time, 120), 12, 5)> '20:00' then '20'
case when '09:00'>= CONVERT(VARCHAR(5),qctd.create_time, 108) and CONVERT(VARCHAR(5),qctd.create_time, 108)> '08:00' then '08'
when '10:00'>= CONVERT(VARCHAR(5),qctd.create_time, 108) and CONVERT(VARCHAR(5),qctd.create_time, 108)> '09:00' then '09'
when '11:00'>= CONVERT(VARCHAR(5),qctd.create_time, 108) and CONVERT(VARCHAR(5),qctd.create_time, 108)> '10:00' then '10'
when '12:00'>= CONVERT(VARCHAR(5),qctd.create_time, 108) and CONVERT(VARCHAR(5),qctd.create_time, 108)> '11:00' then '11'
when '13:30'>= CONVERT(VARCHAR(5),qctd.create_time, 108) and CONVERT(VARCHAR(5),qctd.create_time, 108)> '12:30' then '12'
when '14:30'>= CONVERT(VARCHAR(5),qctd.create_time, 108) and CONVERT(VARCHAR(5),qctd.create_time, 108)> '13:30' then '13'
when '15:30'>= CONVERT(VARCHAR(5),qctd.create_time, 108) and CONVERT(VARCHAR(5),qctd.create_time, 108)> '14:30' then '14'
when '16:30'>= CONVERT(VARCHAR(5),qctd.create_time, 108) and CONVERT(VARCHAR(5),qctd.create_time, 108)> '15:30' then '15'
when '17:30'>= CONVERT(VARCHAR(5),qctd.create_time, 108) and CONVERT(VARCHAR(5),qctd.create_time, 108)> '16:30' then '16'
when '19:00'>= CONVERT(VARCHAR(5),qctd.create_time, 108) and CONVERT(VARCHAR(5),qctd.create_time, 108)> '18:00' then '18'
when '20:00'>= CONVERT(VARCHAR(5),qctd.create_time, 108) and CONVERT(VARCHAR(5),qctd.create_time, 108)> '19:00' then '19'
when '21:00'>= CONVERT(VARCHAR(5),qctd.create_time, 108) and CONVERT(VARCHAR(5),qctd.create_time, 108)> '20:00' then '20'
else '-' end
)ymdms
from qc_check_task qct
left join qc_check_task_detail qctd on qct.record_id = qctd.belong_to
where qct.income_batch_no = #{incomeBatchNo} and qct.check_type = 'checkTypeSCXJ'
left join qc_check_task_detail qctd on qct.record_id = qctd.belong_to
where qct.qct.order_no = #{orderNo} and qct.check_type = 'checkTypeSCXJ'
order by qctd.create_time
</select>
<select id="getBatchnos" resultType="java.lang.String">
select powb.batch_code batchCode
from pro_order_workorder_batch powb
left join pro_order_workorder pow on powb.workorder_id = pow.workorder_id
where powb.del_flag = '0' and pow.del_flag = '0'
and pow.workorder_code = #{orderNo}
</select>
<select id="getLegendData" resultType="com.op.quality.domain.QcStaticTable">
select DISTINCT supplier_code supplierCode,
supplier_name supplierName
from qc_check_task
where check_type = 'checkTypeSCXJ' and del_flag = '0'
and CONVERT(varchar(10),income_time, 120) = #{ymdms}
</select>
<select id="getXJMapData" resultType="com.op.quality.domain.QcStaticTable">
select qct.supplier_code supplierCode,
qct.supplier_name supplierName,
sum(qct.sample_quality) sampleQuality,
sum(qct.noOk_quality) noOkNums,
concat(qct.supplier_code,CONVERT(VARCHAR(2), qct.check_time, 108)) ymdms
from qc_check_task qct
where qct.check_type = 'checkTypeSCXJ' and qct.del_flag = '0'
and CONVERT(varchar(10),qct.income_time, 120) = #{ymdms}
<if test="orderNo != null "> and qct.check_no like concat('%',#{orderNo},'%')</if>
<if test="materialCode != null "> and qct.material_code like concat('%',#{materialCode},'%')</if>
group by qct.supplier_code,qct.supplier_name,CONVERT(VARCHAR(2), qct.check_time, 108)
</select>
</mapper>

Loading…
Cancel
Save