白坯排列图、白坯性能报表开发

master
zhaoxiaolin 3 months ago
parent 4ad32953ee
commit 39575abf1a

@ -98,6 +98,53 @@ public class ExcelMapUtil {
}
}
// 指定要检查的列索引例如B列的索引是1
int columnIndex = 0;
// 遍历所有行从第二行开始索引1因为第一行可能是标题行
for (int rowIndex = 2; rowIndex <= sheet.getLastRowNum(); ) {
Row currentRow = sheet.getRow(rowIndex);
if (currentRow != null) {
Cell currentCell = currentRow.getCell(columnIndex);
if (currentCell != null && currentCell.getCellType() == CellType.STRING) { // 假设我们处理字符串类型的单元格
String currentValue = currentCell.getStringCellValue();
// 查找连续相同值的行
int lastRowIndex = rowIndex;
while (lastRowIndex + 1 <= sheet.getLastRowNum()) {
Row nextRow = sheet.getRow(lastRowIndex + 1);
if (nextRow != null) {
Cell nextCell = nextRow.getCell(columnIndex);
if (nextCell != null && nextCell.getCellType() == CellType.STRING &&
nextCell.getStringCellValue().equals(currentValue)) {
lastRowIndex++; // 继续向下查找
} else {
break; // 找到不同值,停止查找
}
} else {
break; // 没有更多行,停止查找
}
}
// 合并找到的行
if (rowIndex != lastRowIndex) { // 只有在找到连续相同值的行时才进行合并
sheet.addMergedRegion(new CellRangeAddress(rowIndex, lastRowIndex, 0, 0));
}
// else{
// sheet.addMergedRegion(new CellRangeAddress(rowIndex, rowIndex, 0, 0));
// }
// 更新rowIndex以跳过已合并的行
rowIndex = lastRowIndex + 1; // 从下一个未合并的行开始继续遍历
} else {
// 如果当前单元格不是字符串类型,则直接跳到下一行
rowIndex++;
}
} else {
// 如果当前行为空,则直接跳到下一行
rowIndex++;
}
}
return workbook;
}
@ -132,6 +179,14 @@ public class ExcelMapUtil {
cellStyle.setFont(font);
cellStyle.setAlignment(HorizontalAlignment.CENTER_SELECTION);//设置水平居中
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);//设置垂直居中
// 设置上边框
cellStyle.setBorderTop(BorderStyle.THIN);
// 设置下边框
cellStyle.setBorderBottom(BorderStyle.THIN);
// 设置左边框
cellStyle.setBorderLeft(BorderStyle.THIN);
// 设置右边框
cellStyle.setBorderRight(BorderStyle.THIN);
cellStyle.setWrapText(true);//设置单元格内容自动换行
return cellStyle;
}

@ -241,4 +241,5 @@ public interface MesReportWorkMapper {
List<ConsumptionDiff> getReportWorksList(ConsumptionDiff consumptionDiff);
String getLastCPPC(MesReportWork rwork);
}

@ -179,6 +179,10 @@ public class MesReportWorkServiceImpl implements IMesReportWorkService {
pTabs.setTitle("第"+i+"层工单信息");
mesReportWork.setParentOrder("0");
List<MesReportWork> liblist0 = mesReportWorkMapper.getReportList(mesReportWork);
for(MesReportWork rwork:liblist0){
String checkResult = mesReportWorkMapper.getLastCPPC(rwork);
rwork.setCheckResult(checkResult);
}
pTabs.setLibList(liblist0);
pTabs.setRemark(liblist0.get(0).getRemark());
@ -463,7 +467,7 @@ public class MesReportWorkServiceImpl implements IMesReportWorkService {
sumQua = sonMesReport.getQuantityFeedbackSum();
realQua = parentMesReport.getQuantityFeedbackSum();
workTime = sonMesReport.getWorkTime();
useMan = sonMesReport.getUseMan();
useMan = sonMesReport.getUseMan().add(parentMesReport.getUseMan());
dto.setQuantityAct(String.valueOf(sumQua));
dto.setQuantityFeedback(String.valueOf(realQua));
dto.setWorkTime(workTime);
@ -478,7 +482,7 @@ public class MesReportWorkServiceImpl implements IMesReportWorkService {
dto.setCompleteRate(completeRate.toString()+"%");
//标准工时=母单数量*规格/产线标准效率
BigDecimal workTimeStandard = BigDecimal.ZERO;
if(dto.getEfficiency() != null){
if(dto.getEfficiency() != null&&dto.getEfficiency().compareTo(BigDecimal.ZERO)!=0){
workTimeStandard = new BigDecimal(realQua)
.multiply(new BigDecimal(dto.getSpec()))
.divide(dto.getEfficiency(),2,BigDecimal.ROUND_HALF_UP);

@ -662,14 +662,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
pow.workorder_code_sap workorderCodeSap,
mrw.remark,mrw.report_code reportCode,
mrw.machine_code machineCode,
mrw.attr1,mrw.upload_status uploadStatus,
qct.check_result checkResult
mrw.attr1,mrw.upload_status uploadStatus
from mes_report_work mrw
left join pro_order_workorder pow on mrw.workorder_code = pow.workorder_code
left join qc_check_task qct on qct.check_type = 'checkTypeCPPC'
and qct.order_no = mrw.workorder_code
and mrw.batch = qct.income_batch_no
and qct.del_flag = '0'
where mrw.del_flag='0' and pow.del_flag = '0'
<if test='parentOrder=="0"'>
and mrw.workorder_code = #{workorderCode}
@ -682,6 +677,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
order by mrw.batch
</select>
<select id="getLastCPPC" resultType="java.lang.String">
select top 1 check_result
from qc_check_task qct
where qct.check_type = 'checkTypeCPPC'
and qct.order_no = #{workorderCode}
and qct.income_batch_no = #{batch}
and qct.del_flag = '0'
order by qct.create_time desc
</select>
<select id="getPrepareList" resultType="com.op.mes.domain.MesPrepareDetail">
select
mp.workorder_code workorderCode,
@ -846,7 +850,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="getRealQuantity" resultType="com.op.mes.domain.dto.QuantityDto">
select sum(quantity_feedback) quantityFeedbackSum
select sum(quantity_feedback) quantityFeedbackSum,
sum(use_man) useMan
from mes_report_work
where workorder_code = #{workorderCode} and del_flag = '0' and machine_code = #{machineCode}
<if test="board == null">

@ -13,8 +13,10 @@ import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import com.op.common.core.domain.ExcelCol;
import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.bean.BeanUtils;
import com.op.common.core.utils.poi.ExcelMapUtil;
import com.op.common.core.utils.poi.ExcelReportMapUtil;
import com.op.quality.domain.*;
import com.op.system.api.domain.mes.ProLineDTO;
import com.op.system.api.domain.quality.ChartDTO;
@ -880,6 +882,40 @@ public class QcStaticTableController extends BaseController {
public List<QcStaticTable> getMonthOfLine(QcStaticTable qcStaticTable) {
return qcStaticTableService.getMonthOfLine(qcStaticTable);
}
@Log(title = "白坯不良率报表导出", businessType = BusinessType.EXPORT)
@PostMapping("/getMonthOfDataExport")
public void getMonthOfDataExport(HttpServletResponse response, QcStaticTable qcStaticTable) {
List<Map<String,String>> list = qcStaticTableService.getMonthOfData(qcStaticTable);
//表格结构数据
List<String> titils = qcStaticTableService.getDaysOfMonth(qcStaticTable);
ArrayList<ExcelCol> excelCols = new ArrayList<>();
excelCols.add(new ExcelCol("白坯名称", "materialName", 30));
excelCols.add(new ExcelCol("日期", "dataType", 30));
for(int m=0;m<titils.size();m++){
excelCols.add(new ExcelCol(titils.get(m), "monthNum"+m, 30));
}
String sheetName = "白坯不良率报表";
SXSSFWorkbook workbook = null;
try {
//设置响应头
response.setHeader("Content-disposition",
"attachment; filename=" + sheetName);
response.setContentType("application/octet-stream;charset=UTF-8");
ServletOutputStream outputStream = response.getOutputStream();
//调用工具类
workbook = ExcelMapUtil.initWorkbook(sheetName, qcStaticTable.getYearMonth()+"白坯不良率报表", excelCols, list);
workbook.write(outputStream);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (workbook != null) {
workbook.dispose();
}
}
}
@Log(title = "白坯返工率报表--数表", businessType = BusinessType.QUERY)
@GetMapping("/getMonthOfDataRework")
public List<Map<String, String>> getMonthOfDataRework(QcStaticTable qcStaticTable) {
@ -890,9 +926,166 @@ public class QcStaticTableController extends BaseController {
public List<QcStaticTable> getMonthOfLineRework(QcStaticTable qcStaticTable) {
return qcStaticTableService.getMonthOfLineRework(qcStaticTable);
}
@Log(title = "白坯返工率报表导出", businessType = BusinessType.EXPORT)
@PostMapping("/getMonthOfDataReworkExport")
public void getMonthOfDataReworkExport(HttpServletResponse response, QcStaticTable qcStaticTable) {
List<Map<String,String>> list = qcStaticTableService.getMonthOfDataRework(qcStaticTable);
//表格结构数据
List<String> titils = qcStaticTableService.getDaysOfMonth(qcStaticTable);
ArrayList<ExcelCol> excelCols = new ArrayList<>();
excelCols.add(new ExcelCol("白坯名称", "materialName", 30));
excelCols.add(new ExcelCol("日期", "dataType", 30));
for(int m=0;m<titils.size();m++){
excelCols.add(new ExcelCol(titils.get(m), "monthNum"+m, 30));
}
String sheetName = "白坯返工率报表";
SXSSFWorkbook workbook = null;
try {
//设置响应头
response.setHeader("Content-disposition",
"attachment; filename=" + sheetName);
response.setContentType("application/octet-stream;charset=UTF-8");
ServletOutputStream outputStream = response.getOutputStream();
//调用工具类
workbook = ExcelMapUtil.initWorkbook(sheetName, qcStaticTable.getYearMonth()+"白坯返工率", excelCols, list);
workbook.write(outputStream);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (workbook != null) {
workbook.dispose();
}
}
}
@Log(title = "白坯缺陷排列报表--数表", businessType = BusinessType.QUERY)
@GetMapping("/getMonthOfDataDefect")
public List<Map<String, String>> getMonthOfDataDefect(QcStaticTable qcStaticTable) {
return qcStaticTableService.getMonthOfDataDefect(qcStaticTable);
}
@Log(title = "白坯缺陷排列报表导出", businessType = BusinessType.EXPORT)
@PostMapping("/getMonthOfDataDefectExport")
public void getMonthOfDataDefectExport(HttpServletResponse response, QcStaticTable qcStaticTable) {
List<Map<String,String>> list = qcStaticTableService.getMonthOfDataDefect(qcStaticTable);
//表格结构数据
List<String> titils = qcStaticTableService.getDaysOfMonth(qcStaticTable);
ArrayList<ExcelCol> excelCols = new ArrayList<>();
excelCols.add(new ExcelCol("不良项目", "dataType", 30));
for(int m=0;m<titils.size();m++){
excelCols.add(new ExcelCol(titils.get(m), "monthNum"+m, 30));
}
String sheetName = "白坯缺陷排列报表";
SXSSFWorkbook workbook = null;
try {
//设置响应头
response.setHeader("Content-disposition",
"attachment; filename=" + sheetName);
response.setContentType("application/octet-stream;charset=UTF-8");
ServletOutputStream outputStream = response.getOutputStream();
//调用工具类
workbook = ExcelMapUtil.initWorkbook(sheetName, qcStaticTable.getYearMonth()+"白坯缺陷排列", excelCols, list);
workbook.write(outputStream);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (workbook != null) {
workbook.dispose();
}
}
}
@Log(title = "白坯不良项目报表--表头", businessType = BusinessType.QUERY)
@GetMapping("/getDefectItemTitle")
public List<String> getDefectItemTitle(QcStaticTable qcStaticTable) {
return qcStaticTableService.getDefectItemTitle(qcStaticTable);
}
@Log(title = "白坯不良项目报表--数表", businessType = BusinessType.QUERY)
@GetMapping("/getDefectItemData")
public List<Map<String, String>> getDefectItemData(QcStaticTable qcStaticTable) {
return qcStaticTableService.getDefectItemData(qcStaticTable);
}
@Log(title = "白坯不良项目报表--图表", businessType = BusinessType.QUERY)
@GetMapping("/getDefectItemLine")
public QcStaticTable getDefectItemLine(QcStaticTable qcStaticTable) {
return qcStaticTableService.getDefectItemLine(qcStaticTable);
}
@Log(title = "白坯不良项目报表导出", businessType = BusinessType.EXPORT)
@PostMapping("/getDefectItemDataExport")
public void getDefectItemDataExport(HttpServletResponse response, QcStaticTable qcStaticTable) {
List<Map<String,String>> list = qcStaticTableService.getDefectItemData(qcStaticTable);
//表格结构数据
List<String> titils = qcStaticTableService.getDefectItemTitle(qcStaticTable);
ArrayList<ExcelCol> excelCols = new ArrayList<>();
excelCols.add(new ExcelCol("项目", "dataType", 30));
for(int m=0;m<titils.size();m++){
excelCols.add(new ExcelCol(titils.get(m), "item"+m, 30));
}
String sheetName = "白坯不良项目报表";
SXSSFWorkbook workbook = null;
try {
//设置响应头
response.setHeader("Content-disposition",
"attachment; filename=" + sheetName);
response.setContentType("application/octet-stream;charset=UTF-8");
ServletOutputStream outputStream = response.getOutputStream();
//调用工具类
workbook = ExcelMapUtil.initWorkbook(sheetName, qcStaticTable.getYearMonth()+"白坯不良项目", excelCols, list);
workbook.write(outputStream);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (workbook != null) {
workbook.dispose();
}
}
}
@Log(title = "白坯性能--数表", businessType = BusinessType.QUERY)
@GetMapping("/getDefectItemDataPC")
public List<Map<String, String>> getDefectItemDataPC(QcStaticTable qcStaticTable) {
return qcStaticTableService.getDefectItemDataPC(qcStaticTable);
}
@Log(title = "白坯性能--图表", businessType = BusinessType.QUERY)
@GetMapping("/getDefectItemLinePC")
public QcStaticTable getDefectItemLinePC(QcStaticTable qcStaticTable) {
return qcStaticTableService.getDefectItemLinePC(qcStaticTable);
}
@Log(title = "白坯性能报表导出", businessType = BusinessType.EXPORT)
@PostMapping("/getDefectItemDataPCExport")
public void getDefectItemDataPCExport(HttpServletResponse response, QcStaticTable qcStaticTable) {
List<Map<String,String>> list = qcStaticTableService.getDefectItemDataPC(qcStaticTable);
//表格结构数据
List<String> titils = qcStaticTableService.getDefectItemTitle(qcStaticTable);
ArrayList<ExcelCol> excelCols = new ArrayList<>();
excelCols.add(new ExcelCol("项目", "dataType", 30));
for(int m=0;m<titils.size();m++){
excelCols.add(new ExcelCol(titils.get(m), "item"+m, 30));
}
String sheetName = "白坯性能报表";
SXSSFWorkbook workbook = null;
try {
//设置响应头
response.setHeader("Content-disposition",
"attachment; filename=" + sheetName);
response.setContentType("application/octet-stream;charset=UTF-8");
ServletOutputStream outputStream = response.getOutputStream();
//调用工具类
workbook = ExcelMapUtil.initWorkbook(sheetName, qcStaticTable.getYearMonth()+"白坯性能", excelCols, list);
workbook.write(outputStream);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (workbook != null) {
workbook.dispose();
}
}
}
}

@ -69,6 +69,7 @@ public class QcStaticTable extends BaseEntity {
private int noOkNums;
@Excel(name = "不良比例")
private String noOkNumRate;
private String okNumRate;
private BigDecimal aNoOkquality;
private BigDecimal bNoOkquality;
private BigDecimal cNoOkquality;
@ -124,6 +125,14 @@ public class QcStaticTable extends BaseEntity {
private String sampleQty;
private String noOkQty;
public String getOkNumRate() {
return okNumRate;
}
public void setOkNumRate(String okNumRate) {
this.okNumRate = okNumRate;
}
public String getSampleQty() {
return sampleQty;
}

@ -124,10 +124,14 @@ public interface QcStaticTableMapper {
@MapKey("ymdms")
Map<String, QcStaticTable> getBPNoOkMap(QcStaticTable qcStaticTable);
@MapKey("ymdms")
Map<String, QcStaticTable> getBPNoOkHzMap(QcStaticTable qcStaticTable);
@MapKey("ymdms")
Map<String, QcStaticTable> getBPSumNoOkMap(QcStaticTable qcStaticTable);
@MapKey("ymdms")
Map<String, QcStaticTable> getBPReworkMap(QcStaticTable qcStaticTable);
@MapKey("ymdms")
Map<String, QcStaticTable> getBPReworkHzMap(QcStaticTable qcStaticTable);
@MapKey("ymdms")
Map<String, QcStaticTable> getBPSumReworkMap(QcStaticTable qcStaticTable);
List<String> getBpDefects(QcStaticTable qcStaticTable);
@ -135,4 +139,10 @@ public interface QcStaticTableMapper {
Map<String, QcStaticTable> getBPDefectMap(QcStaticTable qcStaticTable);
@MapKey("ymdms")
Map<String, QcStaticTable> getSampMap(QcStaticTable qcStaticTable);
@MapKey("ymdms")
Map<String, QcStaticTable> getBPDefectMothMap(QcStaticTable qcStaticTable);
QcStaticTable getBPHzInfo(QcStaticTable qcStaticTable);
@MapKey("ymdms")
Map<String, QcStaticTable> getBPDefectMothPCMap(QcStaticTable qcStaticTable);
}

@ -86,4 +86,11 @@ public interface IQcStaticTableService {
List<QcStaticTable> getMonthOfLineRework(QcStaticTable qcStaticTable);
List<Map<String, String>> getMonthOfDataDefect(QcStaticTable qcStaticTable);
List<String> getDefectItemTitle(QcStaticTable qcStaticTable);
List<Map<String, String>> getDefectItemData(QcStaticTable qcStaticTable);
QcStaticTable getDefectItemLine(QcStaticTable qcStaticTable);
List<Map<String, String>> getDefectItemDataPC(QcStaticTable qcStaticTable);
QcStaticTable getDefectItemLinePC(QcStaticTable qcStaticTable);
}

@ -1455,6 +1455,41 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
dtos.add(dto3);
}
//总合计
Map<String,QcStaticTable> sampHzMaps = qcStaticTableMapper.getBPNoOkHzMap(qcStaticTable);
Map<String,String> dto4 = new HashMap<>();
dto4.put("materialName","总合计");
dto4.put("dataType","抽检数");
Map<String,String> dto5 = new HashMap<>();
dto5.put("materialName","总合计");
dto5.put("dataType","不良品数");
Map<String,String> dto6 = new HashMap<>();
dto6.put("materialName","总合计");
dto6.put("dataType","不良率%");
for(int m=0;m<days.size();m++){
QcStaticTable sampMap = sampHzMaps.get(days.get(m));
if(sampMap!=null){
BigDecimal nookqty = new BigDecimal(StringUtils.isEmpty(sampMap.getNoOkQty())?"0":sampMap.getNoOkQty());
BigDecimal sampleqty = new BigDecimal(sampMap.getSampleQty());
dto4.put("monthNum"+m,sampMap.getSampleQty().replace(".00",""));
dto5.put("monthNum"+m,sampMap.getNoOkQty().replace(".00",""));
if(StringUtils.isEmpty(sampMap.getSampleQty())||sampleqty.compareTo(BigDecimal.ZERO)==0){
dto6.put("monthNum"+m,"0.00%");
}else{
BigDecimal nookrate = nookqty.multiply(new BigDecimal("100"))
.divide(sampleqty,2,BigDecimal.ROUND_HALF_UP);
dto6.put("monthNum"+m,nookrate+"%");
}
}
}
dtos.add(dto4);
dtos.add(dto5);
dtos.add(dto6);
return dtos;
}
@ -1542,6 +1577,41 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
dtos.add(dto3);
}
//总合计
Map<String,QcStaticTable> sampHzMaps = qcStaticTableMapper.getBPReworkHzMap(qcStaticTable);
Map<String,String> dto4 = new HashMap<>();
dto4.put("materialName","总合计");
dto4.put("dataType","抽检次数");
Map<String,String> dto5 = new HashMap<>();
dto5.put("materialName","总合计");
dto5.put("dataType","返工次数");
Map<String,String> dto6 = new HashMap<>();
dto6.put("materialName","总合计");
dto6.put("dataType","返工率%");
for(int m=0;m<days.size();m++){
QcStaticTable sampMap = sampHzMaps.get(days.get(m));
if(sampMap!=null){
BigDecimal nookqty = new BigDecimal(StringUtils.isEmpty(sampMap.getNoOkQty())?"0":sampMap.getNoOkQty());
BigDecimal sampleqty = new BigDecimal(sampMap.getSampleQty());
dto4.put("monthNum"+m,sampMap.getSampleQty().replace(".00",""));
dto5.put("monthNum"+m,sampMap.getNoOkQty().replace(".00",""));
if(StringUtils.isEmpty(sampMap.getSampleQty())||sampleqty.compareTo(BigDecimal.ZERO)==0){
dto6.put("monthNum"+m,"0.00%");
}else{
BigDecimal nookrate = nookqty.multiply(new BigDecimal("100"))
.divide(sampleqty,2,BigDecimal.ROUND_HALF_UP);
dto6.put("monthNum"+m,nookrate+"%");
}
}
}
dtos.add(dto4);
dtos.add(dto5);
dtos.add(dto6);
return dtos;
}
@ -1609,6 +1679,239 @@ public class QcStaticTableServiceImpl implements IQcStaticTableService {
dtos.add(dto3);
return dtos;
}
@Override
@DS("#header.poolName")
public List<String> getDefectItemTitle(QcStaticTable qcStaticTable) {
return qcStaticTableMapper.getBpDefects(qcStaticTable);
}
@Override
@DS("#header.poolName")
public List<Map<String, String>> getDefectItemData(QcStaticTable qcStaticTable) {
List<Map<String, String>> dtos = new ArrayList<>();
//获取不良种类
List<String> bpDefects = qcStaticTableMapper.getBpDefects(qcStaticTable);
Map<String,QcStaticTable> defectMaps = qcStaticTableMapper.getBPDefectMothMap(qcStaticTable);
BigDecimal rowSum= BigDecimal.ZERO;
BigDecimal rowSumRate= BigDecimal.ZERO;
Map<String,String> dto1= new HashMap<>();
dto1.put("dataType","不良品数");
for(int i=0;i<bpDefects.size();i++){
String defectName = bpDefects.get(i);
QcStaticTable sampMap = defectMaps.get(defectName);
if(sampMap!=null){
dto1.put("item"+i,sampMap.getNoOkQty().replace(".00",""));
rowSum = rowSum.add(new BigDecimal(sampMap.getNoOkQty()));
}
}
dtos.add(dto1);
Map<String,String> dto2= new HashMap<>();
dto2.put("dataType","不良比例");
Map<String,String> dto3 = new HashMap<>();
dto3.put("dataType","累计不良率");
for(int i=0;i<bpDefects.size();i++){
String defectName = bpDefects.get(i);
QcStaticTable sampMap = defectMaps.get(defectName);
if(sampMap!=null){
if(rowSum.compareTo(BigDecimal.ZERO)!=0){
BigDecimal nookRate = new BigDecimal(sampMap.getNoOkQty())
.multiply(new BigDecimal("100"))
.divide(rowSum,2,BigDecimal.ROUND_HALF_UP);
rowSumRate = rowSumRate.add(nookRate);
dto2.put("item"+i,nookRate.toString()+"%");
dto3.put("item"+i,rowSumRate.toString()+"%");
}
}
}
dtos.add(dto2);
dtos.add(dto3);
return dtos;
}
@Override
@DS("#header.poolName")
public QcStaticTable getDefectItemLine(QcStaticTable qcStaticTable) {
QcStaticTable dto = new QcStaticTable();
//获取不良种类
List<String> bpDefects = qcStaticTableMapper.getBpDefects(qcStaticTable);
dto.setSupplierCodes(bpDefects);
Map<String,QcStaticTable> defectMaps = qcStaticTableMapper.getBPDefectMothMap(qcStaticTable);
BigDecimal rowSum= BigDecimal.ZERO;
BigDecimal rowSumRate= BigDecimal.ZERO;
Map<String,String> dto1= new HashMap<>();
dto1.put("dataType","不良品数");
for(int i=0;i<bpDefects.size();i++){
String defectName = bpDefects.get(i);
QcStaticTable sampMap = defectMaps.get(defectName);
if(sampMap!=null){
rowSum = rowSum.add(new BigDecimal(sampMap.getNoOkQty()));
}
}
//左侧y轴
List<String> titleCol1 = new ArrayList<>();
//右侧y轴
List<String> titleCol2 = new ArrayList<>();
for(int i=0;i<bpDefects.size();i++){
String defectName = bpDefects.get(i);
QcStaticTable sampMap = defectMaps.get(defectName);
if(sampMap!=null){
if(rowSum.compareTo(BigDecimal.ZERO)!=0){
BigDecimal nookRate = new BigDecimal(sampMap.getNoOkQty())
.multiply(new BigDecimal("100"))
.divide(rowSum,2,BigDecimal.ROUND_HALF_UP);
rowSumRate = rowSumRate.add(nookRate);
titleCol1.add(nookRate.toString());
titleCol2.add(rowSumRate.toString());
}
}
}
dto.setColumns1(titleCol1);
dto.setColumns2(titleCol2);
//form
dto.setColumn080090(qcStaticTable.getYearMonth().split("-")[0]);
dto.setColumn090100(qcStaticTable.getYearMonth().split("-")[1]);
dto.setMaterialName("白坯");
dto.setWorkCenter("白坯车间");
QcStaticTable hzdto = qcStaticTableMapper.getBPHzInfo(qcStaticTable);
dto.setSampleQty(hzdto.getSampleQty());
dto.setNoOkQty(hzdto.getNoOkQty());
dto.setNoOkNumRate(
new BigDecimal(hzdto.getNoOkQty())
.multiply(new BigDecimal("100"))
.divide(new BigDecimal(hzdto.getSampleQty()),2,BigDecimal.ROUND_HALF_UP)+"%"
);
dto.setOkNumRate(
new BigDecimal("100")
.subtract(
new BigDecimal(hzdto.getNoOkQty())
.multiply(new BigDecimal("100"))
.divide(new BigDecimal(hzdto.getSampleQty()),2,BigDecimal.ROUND_HALF_UP)
)+"%"
);
return dto;
}
@Override
@DS("#header.poolName")
public List<Map<String, String>> getDefectItemDataPC(QcStaticTable qcStaticTable) {
List<Map<String, String>> dtos = new ArrayList<>();
//获取不良种类
List<String> bpDefects = qcStaticTableMapper.getBpDefects(qcStaticTable);
Map<String,QcStaticTable> defectMaps = qcStaticTableMapper.getBPDefectMothPCMap(qcStaticTable);
BigDecimal rowSum= BigDecimal.ZERO;
BigDecimal rowSumRate= BigDecimal.ZERO;
Map<String,String> dto1= new HashMap<>();
dto1.put("dataType","不良数");
for(int i=0;i<bpDefects.size();i++){
String defectName = bpDefects.get(i);
QcStaticTable sampMap = defectMaps.get(defectName);
if(sampMap!=null){
dto1.put("item"+i,sampMap.getNoOkQty().replace(".00",""));
rowSum = rowSum.add(new BigDecimal(sampMap.getNoOkQty()));
}
}
dtos.add(dto1);
Map<String,String> dto2= new HashMap<>();
dto2.put("dataType","不良比例");
Map<String,String> dto3 = new HashMap<>();
dto3.put("dataType","累计不良率");
for(int i=0;i<bpDefects.size();i++){
String defectName = bpDefects.get(i);
QcStaticTable sampMap = defectMaps.get(defectName);
if(sampMap!=null){
if(rowSum.compareTo(BigDecimal.ZERO)!=0){
BigDecimal nookRate = new BigDecimal(sampMap.getNoOkQty())
.multiply(new BigDecimal("100"))
.divide(rowSum,2,BigDecimal.ROUND_HALF_UP);
rowSumRate = rowSumRate.add(nookRate);
dto2.put("item"+i,nookRate.toString()+"%");
dto3.put("item"+i,rowSumRate.toString()+"%");
}
}
}
dtos.add(dto2);
dtos.add(dto3);
return dtos;
}
@Override
@DS("#header.poolName")
public QcStaticTable getDefectItemLinePC(QcStaticTable qcStaticTable) {
QcStaticTable dto = new QcStaticTable();
//获取不良种类
List<String> bpDefects = qcStaticTableMapper.getBpDefects(qcStaticTable);
dto.setSupplierCodes(bpDefects);
Map<String,QcStaticTable> defectMaps = qcStaticTableMapper.getBPDefectMothPCMap(qcStaticTable);
BigDecimal rowSum= BigDecimal.ZERO;
BigDecimal rowSumRate= BigDecimal.ZERO;
Map<String,String> dto1= new HashMap<>();
dto1.put("dataType","不良数");
for(int i=0;i<bpDefects.size();i++){
String defectName = bpDefects.get(i);
QcStaticTable sampMap = defectMaps.get(defectName);
if(sampMap!=null){
rowSum = rowSum.add(new BigDecimal(sampMap.getNoOkQty()));
}
}
//左侧y轴
List<String> titleCol1 = new ArrayList<>();
//右侧y轴
List<String> titleCol2 = new ArrayList<>();
for(int i=0;i<bpDefects.size();i++){
String defectName = bpDefects.get(i);
QcStaticTable sampMap = defectMaps.get(defectName);
if(sampMap!=null){
if(rowSum.compareTo(BigDecimal.ZERO)!=0){
BigDecimal nookRate = new BigDecimal(sampMap.getNoOkQty())
.multiply(new BigDecimal("100"))
.divide(rowSum,2,BigDecimal.ROUND_HALF_UP);
rowSumRate = rowSumRate.add(nookRate);
titleCol1.add(nookRate.toString());
titleCol2.add(rowSumRate.toString());
}
}
}
dto.setColumns1(titleCol1);
dto.setColumns2(titleCol2);
//form
dto.setColumn080090(qcStaticTable.getYearMonth().split("-")[0]);
dto.setColumn090100(qcStaticTable.getYearMonth().split("-")[1]);
dto.setMaterialName("白坯");
dto.setWorkCenter("白坯车间");
QcStaticTable hzdto = qcStaticTableMapper.getBPHzInfo(qcStaticTable);
dto.setSampleQty(hzdto.getSampleQty());
dto.setNoOkNums(hzdto.getNoOkNums());
dto.setNoOkNumRate(
new BigDecimal(hzdto.getNoOkNums())
.multiply(new BigDecimal("100"))
.divide(new BigDecimal(hzdto.getSampleQty()),2,BigDecimal.ROUND_HALF_UP)+"%"
);
dto.setOkNumRate(
new BigDecimal("100")
.subtract(
new BigDecimal(hzdto.getNoOkNums())
.multiply(new BigDecimal("100"))
.divide(new BigDecimal(hzdto.getSampleQty()),2,BigDecimal.ROUND_HALF_UP)
)+"%"
);
return dto;
}
protected Map<String,String> getHJRow(List<Map<String, String>> dtos,int days){
Map<String,String> dto2 = new HashMap<>();
dto2.put("dataType","合计");

@ -130,10 +130,7 @@
<if test="updateTime != null">update_time,</if>
<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>
@ -164,7 +161,6 @@
<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">

@ -1074,6 +1074,28 @@
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="getBPNoOkHzMap" 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="getBPSumNoOkMap" resultType="com.op.quality.domain.QcStaticTable">
select sum(t.noOk_quality) noOkQty,
@ -1120,6 +1142,28 @@
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="getBPReworkHzMap" 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="getBPSumReworkMap" resultType="com.op.quality.domain.QcStaticTable">
select SUM(CASE WHEN t.check_result = 'N' THEN 1 ELSE 0 END) noOkQty,
count(0) sampleQty,
@ -1191,5 +1235,73 @@
</if>
) t GROUP BY t.ymd
</select>
<select id="getBPDefectMothMap" resultType="com.op.quality.domain.QcStaticTable">
select sum(t.noOk_quality) noOkQty,
t.class_name ymdms
from(
select
qdtc.class_name,
qct.noOk_quality
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.class_name
</select>
<select id="getBPDefectMothPCMap" resultType="com.op.quality.domain.QcStaticTable">
select count(0) noOkQty,t.class_name ymdms
from(
select
qdtc.class_name
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 qct.check_result = 'N'
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.class_name
</select>
<select id="getBPHzInfo" resultType="com.op.quality.domain.QcStaticTable">
select sum(t.noOk_quality) noOkQty,
sum(t.sample_quality) sampleQty
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
</select>
</mapper>

Loading…
Cancel
Save