烘房和成型机小时产量报表

master
zhaoxiaolin 3 months ago
parent 36cf3ed508
commit 468feefe18

@ -392,6 +392,116 @@ public class MesReportWorkController extends BaseController {
List<HashMap> list = mesReportWorkService.getHourProductionList(mesHourReport);
return list;
}
/**
* new
*/
//@RequiresPermissions("mes:hourProduction:list")
@GetMapping("/getHourProductionTitleNew")
public List<String> getHourProductionTitleNew(MesHourReport mesHourReport) {
//根据根据时间范围得工单,获取最早和最晚小时
List<String> dateStartEnd = this.getStartEndTimeByProDate(mesHourReport);
mesHourReport.setProductDateStart(dateStartEnd.get(0));
mesHourReport.setProductDateEnd(dateStartEnd.get(1));
// 返回的日期集合
List<String> dayHours = new ArrayList<String>();
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH");
try {
Date start = dateFormat.parse(mesHourReport.getProductDateStart());//开始
Date end = dateFormat.parse(mesHourReport.getProductDateEnd());//结束
//如果有分钟数,默认加一小时
String endTimeStr1 = mesHourReport.getProductDateEnd();
String[] endTime2 = endTimeStr1.split(" ");
String endTime3 = endTime2[1].split(":")[1];
if(Integer.parseInt(endTime3)!=0){
Calendar calendar = Calendar.getInstance();
calendar.setTime(end);
calendar.add(Calendar.HOUR_OF_DAY, 1);
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()));
tempStart.add(Calendar.HOUR_OF_DAY, 1);
}
} catch (ParseException e) {
e.printStackTrace();
}
return dayHours;
}
public List<String> getStartEndTimeByProDate(MesHourReport mesHourReport){
return mesReportWorkService.getStartEndTimeByProDate(mesHourReport);
}
/**
* new()
*/
@GetMapping("/getHourProductionListNew")
@Log(title = "设备小时产量查询(烘房、成型机)", businessType = BusinessType.QUERY)
public List<HashMap> getHourProductionListNew(MesHourReport mesHourReport) {
List<String> hourNames = null;
if("equ_type_hf".equals(mesHourReport.getEquTypeCode())){
hourNames = this.getHourProductionTitle(mesHourReport);
}else if("equ_type_cxj".equals(mesHourReport.getEquTypeCode())){
hourNames = this.getHourProductionTitleNew(mesHourReport);
}
mesHourReport.setHourNames(hourNames);
List<HashMap> list = mesReportWorkService.getHourProductionHFList(mesHourReport);
return list;
}
@PostMapping("/getHourProductionNewExport")
public void getHourProductionNewExport(HttpServletResponse response,MesHourReport mesHourReport) {
List<String> hourNames = null;
if("equ_type_hf".equals(mesHourReport.getEquTypeCode())){
hourNames = this.getHourProductionTitle(mesHourReport);
mesHourReport.setHourNames(hourNames);
}else if("equ_type_cxj".equals(mesHourReport.getEquTypeCode())){
hourNames = this.getHourProductionTitleNew(mesHourReport);
mesHourReport.setHourNames(hourNames);
}
List<HashMap> list = mesReportWorkService.getHourProductionHFList(mesHourReport);
//表格结构数据
String title = "表主标题";
ArrayList<ExcelCol> excelCols = new ArrayList<>();
excelCols.add(new ExcelCol("设备编码","equCode",20));
excelCols.add(new ExcelCol("设备名称","equName",20));
excelCols.add(new ExcelCol("设备总产量","quantity",20));
for(int n = 0;n<hourNames.size();n++){
String hourName = hourNames.get(n);
excelCols.add(new ExcelCol(hourName,"hourPro"+n,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 (Exception e) {
e.printStackTrace();
}finally {
if (workbook!=null){
workbook.dispose();
}
}
}
@GetMapping("/getHourProductionLists")
@Log(title = "近7天产量查询", businessType = BusinessType.QUERY)
public List<MesHourReport> getHourProductionLists(MesHourReport mesHourReport) {

@ -32,6 +32,15 @@ public class MesHourReport extends BaseEntity {
private String shiftId;
@JsonFormat(pattern = "yyyy-MM-dd")
private Date pdate;
private String equTypeCode;
public String getEquTypeCode() {
return equTypeCode;
}
public void setEquTypeCode(String equTypeCode) {
this.equTypeCode = equTypeCode;
}
public Date getPdate() {
return pdate;

@ -103,6 +103,10 @@ public interface MesReportWorkMapper {
@MapKey("equCodeHour")
Map<String, MesHourReport> getHourProductionList(MesHourReport mesHourReport);
@MapKey("equCodeHour")
Map<String, MesHourReport> getHourProductionHFList(MesHourReport mesHourReport);
@MapKey("equCodeHour")
Map<String, MesHourReport> getHourProductionCXJList(MesHourReport mesHourReport);
//烘房当班产量
@MapKey("shiftId")
List<Map> getHFDailyProduction(String shiftId);
@ -221,4 +225,12 @@ public interface MesReportWorkMapper {
List<DynamicColumnVo> getHFProductionTitle(HFProduction dto);
List<HFProduction> getCXJProductionList(HFProduction dto);
List<MesHourReport> getEquNamesByEquType(MesHourReport mesHourReport);
String getCXJFirstTime(MesHourReport mesHourReport);
String getCXJLastTime(MesHourReport mesHourReport);
List<MesHourReport> getHFEquNames(MesHourReport mesHourReport);
List<MesHourReport> getCXJEquNames(MesHourReport mesHourReport);
}

@ -87,6 +87,7 @@ public interface IMesReportWorkService {
LineChartDto getLineChartData(MesReportProduction mesReportProduction);
List<HashMap> getHourProductionList(MesHourReport mesHourReport);
List<HashMap> getHourProductionHFList(MesHourReport mesHourReport);
List<MesHourReport> getHourProductionLists(MesHourReport mesHourReport);
List<Map<String, Object>> getMachineProductionList(MesMachineReport mesMachineReport);
@ -143,4 +144,6 @@ public interface IMesReportWorkService {
Map getmonthProductionSut(MesMonthReportVo mesMonthReportVo);
AjaxResult PlanAchievementRate();
List<String> getStartEndTimeByProDate(MesHourReport mesHourReport);
}

@ -731,6 +731,40 @@ public class MesReportWorkServiceImpl implements IMesReportWorkService {
return hourPros;
}
/**烘房小时产量**/
@DS("#header.poolName")
@Override
public List<HashMap> getHourProductionHFList(MesHourReport mesHourReport) {
List<HashMap> hourPros = new ArrayList<>();
List<MesHourReport> equs = null;
List<String> hourNames = mesHourReport.getHourNames();
Map<String,MesHourReport> equProMap = null;
if("equ_type_hf".equals(mesHourReport.getEquTypeCode())) {
equs = mesReportWorkMapper.getHFEquNames(mesHourReport);
equProMap = mesReportWorkMapper.getHourProductionHFList(mesHourReport);
}else{
equs = mesReportWorkMapper.getCXJEquNames(mesHourReport);
equProMap = mesReportWorkMapper.getHourProductionCXJList(mesHourReport);
}
for(MesHourReport equ:equs){
HashMap result = new HashMap();
result.put("equCode",equ.getEquCode());
result.put("equName",equ.getEquName());
result.put("quantity",equ.getQuantity());
for(int n = 0;n < hourNames.size();n++){
String hourName = hourNames.get(n);
String key = equ.getEquCode()+hourName;
MesHourReport hourdto = equProMap.get(key);
if(hourdto!=null){
result.put("hourPro"+n,hourdto.getQuantity());
}else{
result.put("hourPro"+n,"0");
}
}
hourPros.add(result);
}
return hourPros;
}
@DS("#header.poolName")
@Override
@ -1001,6 +1035,38 @@ public class MesReportWorkServiceImpl implements IMesReportWorkService {
return AjaxResult.success(percentage,resultmap);
}
@Override
@DS("#header.poolName")
public List<String> getStartEndTimeByProDate(MesHourReport mesHourReport) {
List<String> arrays = new ArrayList<>();
//班次为空,则找白班的第一车的开始时间和夜班的最后一车的时间
if("equ_type_cxj".equals(mesHourReport.getEquTypeCode())){
String startTime = mesReportWorkMapper.getCXJFirstTime(mesHourReport);
if(StringUtils.isBlank(startTime)){
startTime = DateUtils.getDate()+" 00:00:00";
}
arrays.add(startTime);
String endTime = mesReportWorkMapper.getCXJLastTime(mesHourReport);
if(StringUtils.isBlank(endTime)){
LocalDate date = LocalDate.now();
LocalDate dateEnd = date.plusDays(1);
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
endTime = dtf.format(dateEnd)+" 00:00:00";
}
arrays.add(endTime);
}
mesHourReport.setProductDateStart(DateUtils.getDate()+" 00:00:00");//start
LocalDate date = LocalDate.now();
LocalDate dateEnd = date.plusDays(1);
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String dateEndStr = dtf.format(dateEnd)+" 00:00:00";
mesHourReport.setProductDateEnd(dateEndStr);//end
return arrays;
}
public static String calculatePercentage(int numerator, int denominator) {
if (denominator == 0) {
return "0%"; // 防止除以零

@ -415,6 +415,80 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
mt.equipmentCode,
equ.equipment_name
</select>
<select id="getHourProductionHFList" resultType="com.op.mes.domain.MesHourReport">
select
concat(mt.device_code,mt.ymdh) equCodeHour,
mt.ymdh,
mt.device_code equCode,
equ.equipment_name equName,
count(0) quantity,
'车' unit
from
(
select
SUBSTRING(CONVERT(varchar(100),create_time, 20), 0, 14) ymdh,
device_code,
workorder_code
from mes_dryinghouse_result
where type = '1'
and CONVERT(varchar(30),create_time, 120) >= #{productDateStart}
and #{productDateEnd} > CONVERT(varchar(30),create_time, 120)
)mt
left join base_equipment equ on mt.device_code = equ.equipment_code
where 1=1
<if test="equName != null and equName != ''">
and equ.equipment_name like concat('%', #{equName}, '%')
</if>
group by
mt.ymdh,
mt.device_code,
equ.equipment_name
</select>
<select id="getHourProductionCXJList" resultType="com.op.mes.domain.MesHourReport">
select
concat(mt.workorder_name,mt.ymdh) equCodeHour,
mt.ymdh,
mt.workorder_name equCode,
equ.equipment_name equName,
count(0) quantity,
'车' unit
from
(
select
SUBSTRING(CONVERT(varchar(100),create_time, 20), 0, 14) ymdh,
workorder_name,
workorder_code
from mes_cxj_producted
where CONVERT(varchar(30),create_time, 120) >= #{productDateStart}
and #{productDateEnd} > CONVERT(varchar(30),create_time, 120)
)mt
left join base_equipment equ on mt.workorder_name = equ.equipment_code
left join pro_order_workorder pow on pow.workorder_id = mt.workorder_code
where pow.order_code is not null
<if test="shiftId != null and shiftId != ''">
and pow.shift_id = #{shiftId}
</if>
<if test="orderCode != null and orderCode != ''">
and pow.order_code like concat('%', #{orderCode}, '%')
</if>
<if test="productCode != null and productCode != ''">
and pow.product_code like concat('%', #{productCode}, '%')
</if>
<if test="productName != null and productName != ''">
and pow.product_name like concat('%', #{productName}, '%')
</if>
<if test="workorderCode != null and workorderCode != ''">
and pow.workorder_code like concat('%', #{workorderCode}, '%')
</if>
<if test="equName != null and equName != ''">
and equ.equipment_name like concat('%', #{equName}, '%')
</if>
group by
mt.ymdh,
mt.workorder_name,
equ.equipment_name
</select>
<select id="selectProShift" resultType="com.op.mes.domain.MesShift">
SELECT bst.Shift_Id shiftId,bst.Shift_Desc shiftDesc
FROM base_shifts_t bst
@ -1243,7 +1317,97 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
GROUP BY t.workorder_name,be.equipment_name,t.product_date
</select>
<select id="getEquNamesByEquType" resultType="com.op.mes.domain.MesHourReport">
select equipment_code equCode,
equipment_name equName
from base_equipment
where equipment_type_code = #{equTypeCode}
and del_flag ='0'
order by equipment_name
</select>
<sql id="getCXJTime">
from mes_cxj_producted mdi
join pro_order_workorder pow on mdi.workorder_code = pow.workorder_id
left join base_equipment be on be.equipment_code = mdi.workorder_name
where pow.product_date >=#{productDateStart} and #{productDateEnd} >= pow.product_date
<if test="shiftId != null">and pow.shift_id = #{shiftId}</if>
<if test="orderCode != null and orderCode != ''">
and pow.order_code like concat('%', #{orderCode}, '%')
</if>
<if test="productCode != null and productCode != ''">
and pow.product_code like concat('%', #{productCode}, '%')
</if>
<if test="productName != null and productName != ''">
and pow.product_name like concat('%', #{productName}, '%')
</if>
<if test="workorderCode != null and workorderCode != ''">
and pow.workorder_code like concat('%', #{workorderCode}, '%')
</if>
<if test="equName != null and equName != ''">
and equ.equipment_name like concat('%', #{equName}, '%')
</if>
</sql>
<select id="getCXJFirstTime" resultType="java.lang.String">
select min(mdi.create_time)
<include refid="getCXJTime"/>
</select>
<select id="getCXJLastTime" resultType="java.lang.String">
select max(mdi.create_time)
<include refid="getCXJTime"/>
</select>
<select id="getHFEquNames" resultType="com.op.mes.domain.MesHourReport">
select
mdr.device_code equCode,
equ.equipment_name equName,
count(0) quantity
from mes_dryinghouse_result mdr
left join base_equipment equ on mdr.device_code = equ.equipment_code
where mdr.type = '1'
<if test="productDateStart != null "> and CONVERT(varchar(30),mdr.create_time, 120) >= #{productDateStart}</if>
<if test="productDateEnd != null "> and #{productDateEnd} > CONVERT(varchar(30),mdr.create_time, 120)</if>
<if test="equName != null and equName != ''">
and equ.equipment_name like concat('%', #{equName}, '%')
</if>
group by
mdr.device_code,
equ.equipment_name
order by equ.equipment_name
</select>
<select id="getCXJEquNames" resultType="com.op.mes.domain.MesHourReport">
select
mt.workorder_name equCode,
equ.equipment_name equName,
count(0) quantity
from mes_cxj_producted mt
left join base_equipment equ on mt.workorder_name = equ.equipment_code
left join pro_order_workorder pow on pow.workorder_id = mt.workorder_code
where 1=1
<if test="productDateStart != null "> and CONVERT(varchar(30),mt.create_time, 120) >= #{productDateStart}</if>
<if test="productDateEnd != null "> and #{productDateEnd} > CONVERT(varchar(30),mt.create_time, 120)</if>
<if test="shiftId != null and shiftId != ''">
and pow.shift_id = #{shiftId}
</if>
<if test="orderCode != null and orderCode != ''">
and pow.order_code like concat('%', #{orderCode}, '%')
</if>
<if test="productCode != null and productCode != ''">
and pow.product_code like concat('%', #{productCode}, '%')
</if>
<if test="productName != null and productName != ''">
and pow.product_name like concat('%', #{productName}, '%')
</if>
<if test="workorderCode != null and workorderCode != ''">
and pow.workorder_code like concat('%', #{workorderCode}, '%')
</if>
<if test="equName != null and equName != ''">
and equ.equipment_name like concat('%', #{equName}, '%')
</if>
group by
mt.workorder_name,
equ.equipment_name
order by equ.equipment_name
</select>
<insert id="insertMesReportWork" parameterType="MesReportWork">
insert into mes_report_work
<trim prefix="(" suffix=")" suffixOverrides=",">

@ -159,12 +159,12 @@ public class ProProcessController extends BaseController {
/**
*
*/
// @RequiresPermissions("mes:pro:process:list")
// @GetMapping("/selectSysFactoryList")
// public AjaxResult selectSysFactoryList(SysFactory sysFactory) {
// List<SysFactory> list = proProcessService.selectSysFactoryList(sysFactory);
// return success(list);
// }
@RequiresPermissions("mes:pro:process:list")
@GetMapping("/selectSysFactoryList")
public AjaxResult selectSysFactoryList(SysFactory sysFactory) {
List<SysFactory> list = proProcessService.selectSysFactoryList(sysFactory);
return success(list);
}
/**
*

@ -74,7 +74,7 @@ public interface ProProcessMapper {
List<BomComponent> selectBaseBomComponentList(BomComponent bomComponent);
//查询树形工厂模型
// public List<SysFactory> selectSysFactoryList(SysFactory sysFactory);
public List<SysFactory> selectSysFactoryList(SysFactory sysFactory);
//查询下拉式工作中心
public List<SysFactory> getWorkCenterList(SysFactory sysFactory);

@ -73,11 +73,12 @@ public interface IProProcessService {
public List<BomComponent> selectBaseBomComponentList(BomComponent bomComponent);
//查询树形工作中心结构
//public List<SysFactory> selectSysFactoryList(SysFactory sysFactory);
public List<SysFactory> selectSysFactoryList(SysFactory sysFactory);
//查询下拉式工作中心
List<SysFactory> getWorkCenterList(SysFactory sysFactory);
//查询设备类型
List<Equipment> getEquipmentTypeList(Equipment equipment);
}

@ -223,17 +223,17 @@ public class ProProcessServiceImpl implements IProProcessService {
return proProcessMapper.selectBaseBomComponentList(bomComponent);
}
// /**
// * 查询工厂模型列表
// *
// * @param sysFactory 工厂模型
// * @return 工厂模型
// */
// @Override
// @DS("#header.poolName")
// public List<SysFactory> selectSysFactoryList(SysFactory sysFactory) {
// return proProcessMapper.selectSysFactoryList(sysFactory);
// }
/**
*
*
* @param sysFactory
* @return
*/
@Override
@DS("#header.poolName")
public List<SysFactory> selectSysFactoryList(SysFactory sysFactory) {
return proProcessMapper.selectSysFactoryList(sysFactory);
}
/**
*

Loading…
Cancel
Save