看板、小时产量报表

highway
zhaoxiaolin 1 year ago
parent 433a307c75
commit f6ebd9e321

@ -1,13 +1,17 @@
package com.op.mes.controller;
import java.util.List;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import javax.servlet.http.HttpServletResponse;
import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.uuid.IdUtils;
import com.op.mes.domain.MesDailyReport;
import com.op.mes.domain.MesProcessReport;
import com.op.mes.domain.MesReportProduction;
import com.op.mes.domain.*;
import com.op.mes.domain.dto.LineChartDto;
import com.op.mes.domain.dto.SysFactoryDto;
import com.op.mes.mapper.MesReportWorkMapper;
@ -24,7 +28,6 @@ import org.springframework.web.bind.annotation.RestController;
import com.op.common.log.annotation.Log;
import com.op.common.log.enums.BusinessType;
import com.op.common.security.annotation.RequiresPermissions;
import com.op.mes.domain.MesReportWork;
import com.op.mes.service.IMesReportWorkService;
import com.op.common.core.web.controller.BaseController;
import com.op.common.core.web.domain.AjaxResult;
@ -42,8 +45,6 @@ import com.op.common.core.utils.poi.ExcelUtilDailyReport;
public class MesReportWorkController extends BaseController {
@Autowired
private IMesReportWorkService mesReportWorkService;
@Autowired
private MesReportWorkMapper mesReportWorkMapper;
/**
*
*/
@ -189,6 +190,76 @@ public class MesReportWorkController extends BaseController {
return mesReportWorkService.getLineChartData(mesReportProduction);
}
/**
*
*/
@RequiresPermissions("mes:hourProduction:list")
@GetMapping("/getHourProductionTitle")
public List<String> getProcessFinishList(MesHourReport mesHourReport) {
//默认时间范围T 00:00:00~T+1 00:00:00
if(StringUtils.isEmpty(mesHourReport.getProductDateStart())){
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
}
// 返回的日期集合
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());
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;
}
/**
*
*/
@RequiresPermissions("mes:hourProduction:list")
@GetMapping("/getHourProductionList")
public List<HashMap> getHourProductionList(MesHourReport mesHourReport) {
List<String> hourNames = this.getProcessFinishList(mesHourReport);
mesHourReport.setHourNames(hourNames);
List<HashMap> list = mesReportWorkService.getHourProductionList(mesHourReport);
return list;
}
public static void main(String args[]){
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:00:00");
try {
Date start = dateFormat.parse("2023-10-12 09:00:00");
Date end = dateFormat.parse("2023-10-13 18:00:00");
Calendar tempStart = Calendar.getInstance();
tempStart.setTime(start);
Calendar tempEnd = Calendar.getInstance();
tempEnd.setTime(end);
while (tempStart.before(tempEnd)) {
System.out.println(dateFormat.format(tempStart.getTime()));
tempStart.add(Calendar.HOUR_OF_DAY, 1);
}
} catch (ParseException e) {
e.printStackTrace();
}
}
}

@ -0,0 +1,143 @@
package com.op.mes.domain;
import com.op.common.core.web.domain.BaseEntity;
import java.util.Date;
import java.util.List;
/**
*
*
* @author Open Platform
* @date 2023-08-24
*/
public class MesHourReport extends BaseEntity {
private static final long serialVersionUID = 1L;
private String productCode;//产品编码
private String productName;//产品名称
private String quantity;//数量
private String unit;//单位
private String hourName;
private String productDateStart;
private String productDateEnd;
private String ymdh;
private String equCode;
private String equName;
private String orderCode;
private String workorderCode;
private List<String> hourNames;
private String equCodeHour;
public String getEquCodeHour() {
return equCodeHour;
}
public void setEquCodeHour(String equCodeHour) {
this.equCodeHour = equCodeHour;
}
public List<String> getHourNames() {
return hourNames;
}
public void setHourNames(List<String> hourNames) {
this.hourNames = hourNames;
}
public String getOrderCode() {
return orderCode;
}
public void setOrderCode(String orderCode) {
this.orderCode = orderCode;
}
public String getWorkorderCode() {
return workorderCode;
}
public void setWorkorderCode(String workorderCode) {
this.workorderCode = workorderCode;
}
public String getYmdh() {
return ymdh;
}
public void setYmdh(String ymdh) {
this.ymdh = ymdh;
}
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 getProductDateStart() {
return productDateStart;
}
public void setProductDateStart(String productDateStart) {
this.productDateStart = productDateStart;
}
public String getProductDateEnd() {
return productDateEnd;
}
public void setProductDateEnd(String productDateEnd) {
this.productDateEnd = productDateEnd;
}
public String getProductCode() {
return productCode;
}
public void setProductCode(String productCode) {
this.productCode = productCode;
}
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
public String getQuantity() {
return quantity;
}
public void setQuantity(String quantity) {
this.quantity = quantity;
}
public String getUnit() {
return unit;
}
public void setUnit(String unit) {
this.unit = unit;
}
public String getHourName() {
return hourName;
}
public void setHourName(String hourName) {
this.hourName = hourName;
}
}

@ -3,10 +3,7 @@ package com.op.mes.mapper;
import java.util.List;
import java.util.Map;
import com.op.mes.domain.MesDailyReport;
import com.op.mes.domain.MesProcessReport;
import com.op.mes.domain.MesReportProduction;
import com.op.mes.domain.MesReportWork;
import com.op.mes.domain.*;
import com.op.mes.domain.dto.SysFactoryDto;
import org.apache.ibatis.annotations.MapKey;
@ -84,4 +81,8 @@ public interface MesReportWorkMapper {
Map<String,MesReportProduction> getLineChartsDatas(MesReportProduction mesReportProduction);
List<String> getLineChartsNames(MesReportProduction mesReportProduction);
@MapKey("equCodeHour")
Map<String,MesHourReport> getHourProductionList(MesHourReport mesHourReport);
List<MesHourReport> getEquNames(MesHourReport mesHourReport);
}

@ -1,11 +1,9 @@
package com.op.mes.service;
import java.util.HashMap;
import java.util.List;
import com.op.mes.domain.MesDailyReport;
import com.op.mes.domain.MesProcessReport;
import com.op.mes.domain.MesReportProduction;
import com.op.mes.domain.MesReportWork;
import com.op.mes.domain.*;
import com.op.mes.domain.dto.LineChartDto;
import com.op.mes.domain.dto.SysFactoryDto;
@ -75,4 +73,6 @@ public interface IMesReportWorkService {
List<SysFactoryDto> getWorkcenterList(MesDailyReport mesDailyReport);
LineChartDto getLineChartData(MesReportProduction mesReportProduction);
List<HashMap> getHourProductionList(MesHourReport mesHourReport);
}

@ -8,16 +8,13 @@ import java.util.*;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.op.common.core.utils.DateUtils;
import com.op.mes.domain.MesDailyReport;
import com.op.mes.domain.MesProcessReport;
import com.op.mes.domain.MesReportProduction;
import com.op.mes.domain.*;
import com.op.mes.domain.dto.LineChartDto;
import com.op.mes.domain.dto.LineChartSeriesDto;
import com.op.mes.domain.dto.SysFactoryDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.op.mes.mapper.MesReportWorkMapper;
import com.op.mes.domain.MesReportWork;
import com.op.mes.service.IMesReportWorkService;
import org.springframework.util.CollectionUtils;
@ -191,7 +188,7 @@ public class MesReportWorkServiceImpl implements IMesReportWorkService {
* data: [120, 132, 101, 134, 90, 230, 210,120, 132, 101, 134, 90, 230, 210]
* }
* ]
* @param mesDailyReport
* @param
* @return
*/
@Override
@ -238,6 +235,33 @@ public class MesReportWorkServiceImpl implements IMesReportWorkService {
lineChartDto.setSeriesDatas(seriesDatas);
return lineChartDto;
}
@DS("#header.poolName")
@Override
public List<HashMap> getHourProductionList(MesHourReport mesHourReport) {
List<HashMap> hourPros = new ArrayList<>();
List<MesHourReport> equs = mesReportWorkMapper.getEquNames(mesHourReport);
List<String> hourNames = mesHourReport.getHourNames();
Map<String,MesHourReport> equProMap = mesReportWorkMapper.getHourProductionList(mesHourReport);
for(MesHourReport equ:equs){
HashMap result = new HashMap();
result.put("equCode",equ.getEquCode());
result.put("equName",equ.getEquName());
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;
}
/**两个日期之间的所有日期**/
public static List<String> getDays(String startTime,String endTime) {

@ -244,6 +244,76 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
CONVERT(varchar(10),mrw.feedback_time, 120) >= #{productDateStart}
and #{productDateEnd} >= CONVERT(varchar(10),mrw.feedback_time, 120)
</select>
<select id="getEquNames" resultType="com.op.mes.domain.MesHourReport">
select
DISTINCT mt.equipmentCode equCode,
equ.equipment_name equName
from mes_material_transfer_result mt
left join base_equipment equ on mt.equipmentCode = equ.equipment_code
left join pro_order_workorder pow on pow.workorder_id = mt.OrderCode
where 1=1
<if test="productDateStart != null "> and CONVERT(varchar(30),mt.update_time, 120) >= #{productDateStart}</if>
<if test="productDateEnd != null "> and #{productDateEnd} > CONVERT(varchar(30),mt.update_time, 120)</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>
order by mt.equipmentCode
</select>
<select id="getHourProductionList" resultType="com.op.mes.domain.MesHourReport">
select
concat(mt.equipmentCode,mt.ymdh) equCodeHour,
mt.ymdh,
mt.equipmentCode equCode,
equ.equipment_name equName,
count(0) quantity,
'车' unit
from
(
select
SUBSTRING(CONVERT(varchar(100),update_time, 20), 0, 14) ymdh,
equipmentCode,
OrderCode
from mes_material_transfer_result
where 1=1
<if test="productDateStart != null "> and CONVERT(varchar(30),update_time, 120) >= #{productDateStart}</if>
<if test="productDateEnd != null "> and #{productDateEnd} > CONVERT(varchar(30),update_time, 120)</if>
)mt
left join base_equipment equ on mt.equipmentCode = equ.equipment_code
left join pro_order_workorder pow on pow.workorder_id = mt.OrderCode
where pow.order_code is not null
<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.equipmentCode,
equ.equipment_name
</select>
<insert id="insertMesReportWork" parameterType="MesReportWork">
insert into mes_report_work

Loading…
Cancel
Save