烘房统计报表+产品追溯

master
zhaoxiaolin 3 months ago
parent db16cdcfb7
commit 501ca0b094

@ -135,6 +135,24 @@ public class QcCheckTaskDTO extends BaseEntity {
private BigDecimal aNoOkquality;
private BigDecimal bNoOkquality;
private BigDecimal cNoOkquality;
private String className;
private String reason;
public String getClassName() {
return className;
}
public void setClassName(String className) {
this.className = className;
}
public String getReason() {
return reason;
}
public void setReason(String reason) {
this.reason = reason;
}
public BigDecimal getSampleQuality() {
return sampleQuality;

@ -5,6 +5,7 @@ import javax.servlet.http.HttpServletResponse;
import com.op.common.core.domain.R;
import com.op.common.core.utils.uuid.IdUtils;
import com.op.system.api.domain.quality.QcCheckTaskDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.autoconfigure.metrics.MetricsProperties;
import org.springframework.web.bind.annotation.GetMapping;
@ -113,4 +114,25 @@ public class MesPrepareController extends BaseController {
public R reportWorkTask() {
return mesPrepareService.reportWorkTask();
}
/**
*
*/
@GetMapping("/getBomTraceList")
@Log(title = "产品主键追溯备料单查询", businessType = BusinessType.QUERY)
public TableDataInfo getBomTraceList(MesPrepare mesPrepare) {
startPage();
List<MesPrepare> list = mesPrepareService.getBomTraceList(mesPrepare);
return getDataTable(list);
}
/**
*
*/
@GetMapping("/getCheckTaskTraceList")
@Log(title = "产品主键追溯检验任务查询", businessType = BusinessType.QUERY)
public TableDataInfo getCheckTaskTraceList(QcCheckTaskDTO dto) {
startPage();
List<QcCheckTaskDTO> list = mesPrepareService.getCheckTaskTraceList(dto);
return getDataTable(list);
}
}

@ -1,23 +1,30 @@
package com.op.mes.controller;
import com.op.common.core.domain.ExcelCol;
import com.op.common.core.domain.R;
import com.op.common.core.utils.bean.BeanUtils;
import com.op.common.core.utils.poi.ExcelMapUtil;
import com.op.common.core.utils.poi.ExcelUtil;
import com.op.common.core.web.controller.BaseController;
import com.op.common.core.web.page.TableDataInfo;
import com.op.common.security.annotation.RequiresPermissions;
import com.op.mes.domain.*;
import com.op.mes.domain.vo.DynamicColumnVo;
import com.op.mes.service.IMesReportWorksService;
import com.op.common.core.utils.bean.BeanUtils;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import static com.op.common.core.utils.PageUtils.startPage;
@ -80,4 +87,50 @@ public class MesReportWorksController extends BaseController {
}
}
/**烘房产量统计**/
@GetMapping("/getHFProductionList")
public List<Map<String, Object>> getHFProductionList(HFProduction dto) {
List<DynamicColumnVo> equNames = this.getHFProductionTitle(dto);
dto.setEquNames(equNames);
List<Map<String, Object>> list = mesReportWorksService.getHFProductionList(dto);
return list;
}
@GetMapping("/getHFProductionTitle")
public List<DynamicColumnVo> getHFProductionTitle(HFProduction dto) {
List<DynamicColumnVo> list = mesReportWorksService.getHFProductionTitle(dto);
return list;
}
@PostMapping("/getHFProductionExport")
public void getHFProductionExport(HttpServletResponse response,HFProduction dto) {
List<DynamicColumnVo> equNames = this.getHFProductionTitle(dto);
dto.setEquNames(equNames);
List<Map<String, Object>> list = mesReportWorksService.getHFProductionList(dto);
ArrayList<ExcelCol> excelCols = new ArrayList<>();
excelCols.add(new ExcelCol("日期","ymd",20));
for (DynamicColumnVo column : equNames) {
excelCols.add(new ExcelCol(column.getLabel(), column.getCode(), 20));
}
excelCols.add(new ExcelCol("总产量","totalQuantity",20));
String titleName = "烘房产量统计报表";
SXSSFWorkbook workbook = null;
try {
//设置响应头
response.setHeader("Content-disposition",
"attachment; filename="+ titleName);
response.setContentType("application/octet-stream;charset=UTF-8");
ServletOutputStream outputStream = response.getOutputStream();
//调用工具类
workbook = ExcelMapUtil.initWorkbook(titleName, null, excelCols, list);
workbook.write(outputStream);
} catch (IOException e) {
e.printStackTrace();
}finally {
if (workbook!=null){
workbook.dispose();
}
}
}
}

@ -0,0 +1,83 @@
package com.op.mes.domain;
import com.op.common.core.annotation.Excel;
import com.op.common.core.web.domain.BaseEntity;
import com.op.mes.domain.vo.DynamicColumnVo;
import java.util.List;
/**
*
* @author Open Platform
* @date 2024-12-12
*/
public class HFProduction extends BaseEntity {
private static final long serialVersionUID = 1L;
@Excel(name = "日期")
private String ymd;
@Excel(name = "烘房编码")
private String equCode;
@Excel(name = "烘房名称")
private String equName;
@Excel(name = "产量")
private String quality;
private String ymArrayStart;
private String ymArrayEnd;
private List<DynamicColumnVo> equNames;
public List<DynamicColumnVo> getEquNames() {
return equNames;
}
public void setEquNames(List<DynamicColumnVo> equNames) {
this.equNames = equNames;
}
public String getYmd() {
return ymd;
}
public void setYmd(String ymd) {
this.ymd = ymd;
}
public String getEquCode() {
return equCode;
}
public void setEquCode(String equCode) {
this.equCode = equCode;
}
public String getEquName() {
return equName;
}
public void setEquName(String equName) {
this.equName = equName;
}
public String getQuality() {
return quality;
}
public void setQuality(String quality) {
this.quality = quality;
}
public String getYmArrayStart() {
return ymArrayStart;
}
public void setYmArrayStart(String ymArrayStart) {
this.ymArrayStart = ymArrayStart;
}
public String getYmArrayEnd() {
return ymArrayEnd;
}
public void setYmArrayEnd(String ymArrayEnd) {
this.ymArrayEnd = ymArrayEnd;
}
}

@ -175,6 +175,33 @@ public class MesPrepare extends BaseEntity {
private String factoryCode;
private String prodLineCode;
private String dayStr;
private String recoil;
private String ymArrayStart;
private String ymArrayEnd;
public String getYmArrayStart() {
return ymArrayStart;
}
public void setYmArrayStart(String ymArrayStart) {
this.ymArrayStart = ymArrayStart;
}
public String getYmArrayEnd() {
return ymArrayEnd;
}
public void setYmArrayEnd(String ymArrayEnd) {
this.ymArrayEnd = ymArrayEnd;
}
public String getRecoil() {
return recoil;
}
public void setRecoil(String recoil) {
this.recoil = recoil;
}
public String getProdLineCode() {
return prodLineCode;

@ -4,6 +4,7 @@ import java.util.List;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.op.mes.domain.MesPrepare;
import com.op.system.api.domain.quality.QcCheckTaskDTO;
import org.apache.ibatis.annotations.Mapper;
/**
@ -71,4 +72,8 @@ public interface MesPrepareMapper {
* @return
*/
MesPrepare selectMesPrepareByCode(String workorderCode);
List<MesPrepare> getBomTraceList(MesPrepare mesPrepare);
List<QcCheckTaskDTO> getCheckTaskTraceList(QcCheckTaskDTO dto);
}

@ -8,6 +8,7 @@ import com.op.mes.domain.*;
import com.op.mes.domain.dto.LineChartSeriesDto;
import com.op.mes.domain.dto.QuantityDto;
import com.op.mes.domain.dto.SysFactoryDto;
import com.op.mes.domain.vo.DynamicColumnVo;
import com.op.mes.domain.vo.MesDailyReportVo;
import com.op.mes.domain.vo.MesMonthReportVo;
import com.op.system.api.domain.SysNoticeGroup;
@ -214,4 +215,8 @@ public interface MesReportWorkMapper {
List<ProOrderWorkorder> getWorkList(MesProductTrace qo);
List<ProOrderWorkorder> getWaList(MesProductTrace qo);
List<HFProduction> getHFProductionList(HFProduction dto);
List<DynamicColumnVo> getHFProductionTitle(HFProduction dto);
}

@ -4,6 +4,7 @@ import java.util.List;
import com.op.common.core.domain.R;
import com.op.mes.domain.MesPrepare;
import com.op.system.api.domain.quality.QcCheckTaskDTO;
/**
* Service
@ -66,4 +67,8 @@ public interface IMesPrepareService {
public R getMesPrepare();
public R reportWorkTask();
public List<MesPrepare> getBomTraceList(MesPrepare mesPrepare);
public List<QcCheckTaskDTO> getCheckTaskTraceList(QcCheckTaskDTO dto);
}

@ -1,10 +1,13 @@
package com.op.mes.service;
import com.op.common.core.domain.R;
import com.op.mes.domain.HFProduction;
import com.op.mes.domain.MesProductTrace;
import com.op.mes.domain.MesReportWork;
import com.op.mes.domain.vo.DynamicColumnVo;
import java.util.List;
import java.util.Map;
public interface IMesReportWorksService {
@ -13,4 +16,8 @@ public interface IMesReportWorksService {
R mesProTask();
List<MesProductTrace> getProductTrace(MesProductTrace dto);
List<Map<String, Object>> getHFProductionList(HFProduction dto);
List<DynamicColumnVo> getHFProductionTitle(HFProduction dto);
}

@ -20,6 +20,7 @@ import com.op.mes.mapper.MesReportWorkMapper;
import com.op.system.api.RemoteSapService;
import com.op.system.api.RemoteUserService;
import com.op.system.api.domain.SysUser;
import com.op.system.api.domain.quality.QcCheckTaskDTO;
import com.op.system.api.domain.sap.SapMaterialPreparation;
import com.op.system.api.domain.sap.SapRFW;
import org.slf4j.Logger;
@ -303,4 +304,15 @@ public class MesPrepareServiceImpl implements IMesPrepareService {
Set<String> orderCodes = list.stream().map(SapMaterialPreparation::getAUFNR).collect(Collectors.toSet());
System.out.println(JSON.toJSONString(orderCodes));
}
@Override
@DS("#header.poolName")
public List<MesPrepare> getBomTraceList(MesPrepare mesPrepare) {
return mesPrepareMapper.getBomTraceList(mesPrepare);
}
@Override
@DS("#header.poolName")
public List<QcCheckTaskDTO> getCheckTaskTraceList(QcCheckTaskDTO dto) {
return mesPrepareMapper.getCheckTaskTraceList(dto);
}
}

@ -2,6 +2,7 @@ package com.op.mes.service.impl;
import com.alibaba.fastjson2.JSONObject;
import com.alibaba.nacos.shaded.com.google.common.collect.Lists;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.op.common.core.domain.R;
@ -9,9 +10,8 @@ import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.StringUtils;
import com.op.common.core.utils.bean.BeanUtils;
import com.op.common.core.web.domain.AjaxResult;
import com.op.mes.domain.MesProductTrace;
import com.op.mes.domain.MesReportWork;
import com.op.mes.domain.ProOrderWorkorder;
import com.op.mes.domain.*;
import com.op.mes.domain.vo.DynamicColumnVo;
import com.op.mes.mapper.MesReportWorkMapper;
import com.op.mes.mapper.MesReportWorksMapper;
import com.op.mes.service.IMesReportWorksService;
@ -27,6 +27,8 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
@ -147,6 +149,7 @@ public class MesReportWorksServiceImpl implements IMesReportWorksService {
}
return dtos;
}
public void setMesProInfoFunc(String poolName){
DynamicDataSourceContextHolder.push(poolName);// 这是数据源的key
//工厂名称
@ -199,4 +202,77 @@ public class MesReportWorksServiceImpl implements IMesReportWorksService {
//发企业微信--------------------结束
}
}
@Override
@DS("#header.poolName")
public List<Map<String, Object>> getHFProductionList(HFProduction dto) {
//return mesReportWorkMapper.getHFProductionList(dto);
// 开始日期
String start = dto.getYmArrayStart();
String end = dto.getYmArrayEnd();
// 查询出来时间区间
List<String> listDate = getDateInterval(start,end);
List<DynamicColumnVo> allEquNames = dto.getEquNames();
List<HFProduction> dbMProductList = mesReportWorkMapper.getHFProductionList(dto);
List<Map<String, Object>> results = listDate.stream()
.map(date -> {
Map<String, Object> row = new HashMap<>();
row.put("ymd", date);
//对于每个日期,收集该日期下所有产品的产量数据
Map<String, String> dailyProductQuantities = dbMProductList.stream()
.filter(HFProduction -> HFProduction.getYmd().equals(date))
.collect(Collectors.toMap(
HFProduction::getEquCode,
HFProduction::getQuality
));
// 遍历所有产品如果dailyProduct不存在此产品添加产品产量设为空
for (DynamicColumnVo equ : allEquNames) {
String equCode = equ.getCode();
dailyProductQuantities.putIfAbsent(equCode, "0");
}
row.putAll(dailyProductQuantities);
// 计算并添加当日总产量
int totalQuantity = dailyProductQuantities.values().stream()
.mapToInt(Integer::parseInt)
.sum();
row.put("totalQuantity", totalQuantity);
return row;
}).collect(Collectors.toList());
return results;
}
@Override
@DS("#header.poolName")
public List<DynamicColumnVo> getHFProductionTitle(HFProduction dto) {
//查询sql数据
List<DynamicColumnVo> data = mesReportWorkMapper.getHFProductionTitle(dto);
return data;
}
private List<String> getDateInterval(String start, String end) {
start = start.substring(0,10);
end = end.substring(0,10);
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd");
List<String> dateList = Lists.newArrayList();
LocalDate localStart = LocalDate.parse(start,fmt);
LocalDate localEnd = LocalDate.parse(end,fmt);
LocalDate nextDate = localStart;
do {
String nextDateStr = nextDate.format(fmt);
dateList.add(nextDateStr);
nextDate = nextDate.plusDays(1);
}while (nextDate.compareTo(localEnd) <= 0);
return dateList;
}
}

@ -92,6 +92,58 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from mes_prepare
where workorder_code = #{workorderCode} and del_flag = '0'
</select>
<select id="getBomTraceList" resultType="com.op.mes.domain.MesPrepare">
select
mpd.material_code productCode,
mpd.material_name productName,
mpd.attr1,
sum(mpd.quantity) quantity,
mpd.unit,
mpd.recoil
from (
select workorder_code from pro_order_workorder where parent_order = '0' and del_flag = '0'
and status in('w2','w3')
and product_code = #{productCode}
<if test="ymArrayStart != null ">and CONVERT(varchar(10),product_date, 120) >= #{ymArrayStart}</if>
<if test="ymArrayEnd != null ">and #{ymArrayEnd} >=CONVERT(varchar(10),product_date,120) </if>
) pow
left join mes_prepare mp on pow.workorder_code = mp.workorder_code and mp.del_flag = '0'
left join mes_prepare_detail mpd on mpd.prepare_id = mp.prepare_id and mpd.del_flag = '0'
GROUP BY mpd.material_code,
mpd.material_name,
mpd.attr1,
mpd.unit,
mpd.recoil
order by mpd.recoil
</select>
<select id="getCheckTaskTraceList" resultType="com.op.system.api.domain.quality.QcCheckTaskDTO">
select
pow.workorder_name checkLoc,
qct.check_no checkNo,
qt.check_name checkType,
pow.workorder_code_sap orderNo,
qct.income_batch_no incomeBatchNo,
qct.check_status checkStatus,
qct.check_man_code checkManCode,
qct.check_man_name checkManName,
qct.check_time checkTime,
qct.check_result checkResult,
qct.reason,
qct.remark,
qdtc.class_name className
from (
select workorder_code,workorder_name,workorder_code_sap from pro_order_workorder where parent_order = '0' and del_flag = '0'
and status in('w2','w3')
and product_code = #{materialCode}
<if test="checkTimeStart != null ">and CONVERT(varchar(10),product_date, 120) >= #{checkTimeStart}</if>
<if test="checkTimeEnd != null ">and #{checkTimeEnd} >=CONVERT(varchar(10),product_date,120) </if>
) pow
left join qc_check_task qct on pow.workorder_code = qct.order_no and qct.del_flag = '0'
left join qc_check_type qt on qt.order_code = qct.check_type and qt.del_flag = '0'
left join qc_defect_type_class qdtc on qdtc.id = qct.remark_code and qdtc.del_flag = '0'
where qct.check_type = #{checkType}
order by qct.check_no
</select>
<insert id="insertMesPrepare" parameterType="MesPrepare">
insert into mes_prepare

@ -1187,6 +1187,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="ymArrayEnd != null ">and #{ymArrayEnd} >=CONVERT(varchar(10),qct.income_time,120) </if>
order by ba.area_desc asc,qct.income_time desc
</select>
<select id="getHFProductionList" resultType="com.op.mes.domain.HFProduction">
select mdr.device_code equCode,
mdr.ymd,
count(mdr.devcode1) quality,
be.equipment_name equName
from (
select device_code,devcode1,CONVERT(varchar(10),create_time, 120) ymd
from mes_dryinghouse_result
where type = '1'
<if test="ymArrayStart != null ">and CONVERT(varchar(10),create_time, 120) >= #{ymArrayStart}</if>
<if test="ymArrayEnd != null ">and #{ymArrayEnd} >=CONVERT(varchar(10),create_time,120) </if>
) mdr
left join base_equipment be on be.equipment_code = mdr.device_code
where 1=1
<if test="equName != null ">
and be.equipment_name like concat('%', #{equName}, '%')
</if>
GROUP BY mdr.ymd,mdr.device_code,be.equipment_name
order by mdr.ymd
</select>
<select id="getHFProductionTitle" resultType="com.op.mes.domain.vo.DynamicColumnVo">
select be.equipment_code code,
be.equipment_name label
from base_equipment be
where be.equipment_type_code ='equ_type_hf' and be.del_flag = '0'
<if test="equName != null ">
and be.equipment_name like concat('%', #{equName}, '%')
</if>
order by be.equipment_name
</select>
<insert id="insertMesReportWork" parameterType="MesReportWork">
insert into mes_report_work

@ -285,7 +285,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select max(create_time) from sys_user where create_by = 'job' and del_flag = '0'
</select>
<select id="getExsitCodes" resultType="java.lang.String">
select user_name from sys_user where del_flag = '0' and user_name in
select user_name from sys_user where user_name in
<foreach collection="list" item="code" open="(" separator="," close=")">
#{code}
</foreach>

Loading…
Cancel
Save