1、看板料罐车数获取;2、小时产量加班次、分钟数做活,导出功能;3、工序完成记录加入班次

highway
zhaoxiaolin 1 year ago
parent 497e14c965
commit d4ce34c332

@ -0,0 +1,49 @@
package com.op.common.core.domain;
import com.op.common.core.annotation.Excel;
import com.op.common.core.web.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* base_file
*
* @author Open Platform
* @date 2023-07-10
*/
public class ExcelCol extends BaseEntity {
private static final long serialVersionUID = 1L;
private String title;//表头名称
private String field;//内容名称(与数据库传回的参数字段对应)
private int width;//单元格宽度
public ExcelCol(String title, String field, int width) {
this.title = title;
this.field = field;
this.width = width;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getField() {
return field;
}
public void setField(String field) {
this.field = field;
}
public int getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
}

@ -0,0 +1,118 @@
package com.op.common.core.utils.poi;
import com.alibaba.fastjson2.JSONObject;
import com.op.common.core.domain.ExcelCol;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
/**
* Excel
*
* @author OP
*/
public class ExcelMapUtil {
//下载
public static <T> SXSSFWorkbook initWorkbook(String sheetName , String title , List<ExcelCol> excelCol , List<T> data){
SXSSFWorkbook workbook = new SXSSFWorkbook();
int colSize = excelCol.size();
//创建Sheet工作簿
Sheet sheet = null;
if (!StringUtils.hasText(sheetName)){
sheet = workbook.createSheet();
}else{
sheet = workbook.createSheet(sheetName);
}
// //创建主标题行(第一行)
// Row sheetTitleRow = sheet.createRow(0);
// Cell titleCell = sheetTitleRow.createCell(0);//创建第一行第一个单元格
// titleCell.setCellValue(title);//传值
// titleCell.setCellStyle(getHeaderFont(sheet.getWorkbook()));//设置样式
// //主标题行合并单元格
// CellRangeAddress cellAddresses = new CellRangeAddress(0, 0, 0, colSize - 1);
// sheet.addMergedRegion(cellAddresses);
//创建表头行(第二行)
Row sheetHeadRow = sheet.createRow(0);//1
//遍历表头名称,创建表头单元格
for(int i = 0 ; i < colSize ; i++){
sheet.setColumnWidth(i,(excelCol.get(i).getWidth())*256);//宽度单位是字符的256分之一
Cell headCell = sheetHeadRow.createCell(i);
headCell.setCellValue(excelCol.get(i).getTitle());//传值
headCell.setCellStyle(getHeaderFont(sheet.getWorkbook()));//设置样式
}
//将data中的值填充到excel
int rowNum = sheet.getLastRowNum()+1;
Iterator<T> iterator = data.iterator();
//遍历数据
for (;iterator.hasNext();){
Row dataRow = sheet.createRow(rowNum);//创建行
T obj = iterator.next();//获取当前行对应的数据
JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(obj));
for (int i = 0 ; i < colSize ; i++ ){
Cell dataCell = dataRow.createCell(i);
dataCell.setCellStyle(getDataFont(workbook));
if(i>=2){
dataCell.setCellValue(getValueNum(jsonObject.get(excelCol.get(i).getField())));
}else{
dataCell.setCellValue(getValue(jsonObject.get(excelCol.get(i).getField())));
}
}
iterator.remove();
rowNum++;
}
return workbook;
}
//标题样式
public static CellStyle getHeaderFont(Workbook workbook){
Font font = workbook.createFont();
font.setFontHeightInPoints((short) 16);//字体大小
font.setBold(true);//加粗
CellStyle cellStyle = workbook.createCellStyle();
cellStyle.setFont(font);
cellStyle.setAlignment(HorizontalAlignment.CENTER_SELECTION);//设置水平居中
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);//设置垂直居中
return cellStyle;
}
//内容样式
public static CellStyle getDataFont(Workbook workbook){
Font font = workbook.createFont();
font.setFontHeightInPoints((short) 12);//字体大小
font.setBold(false);//不加粗
CellStyle cellStyle = workbook.createCellStyle();
cellStyle.setFont(font);
cellStyle.setAlignment(HorizontalAlignment.CENTER_SELECTION);//设置水平居中
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);//设置垂直居中
return cellStyle;
}
//处理数据
public static String getValue(Object object){
if (object==null){
return "";
}else {
return object.toString();
}
}
//处理数据
public static Integer getValueNum(Object object){
if (object==null){
return 0;
}else {
return Integer.parseInt(object.toString());
}
}
}

@ -4,18 +4,19 @@ 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.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.poi.ExcelMapUtil;
import com.op.common.core.utils.uuid.IdUtils;
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;
import org.apache.commons.lang.StringUtils;
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;
@ -196,7 +197,7 @@ public class MesReportWorkController extends BaseController {
*/
@RequiresPermissions("mes:hourProduction:list")
@GetMapping("/getHourProductionTitle")
public List<String> getProcessFinishList(MesHourReport mesHourReport) {
public List<String> getHourProductionTitle(MesHourReport mesHourReport) {
//默认时间范围T 00:00:00~T+1 00:00:00
if(StringUtils.isEmpty(mesHourReport.getProductDateStart())){
mesHourReport.setProductDateStart(DateUtils.getDate()+" 00:00:00");//start
@ -210,8 +211,20 @@ public class MesReportWorkController extends BaseController {
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());
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);
@ -228,18 +241,68 @@ public class MesReportWorkController extends BaseController {
return dayHours;
}
/**
* list
*
* @return
*/
@GetMapping("/getProShifts")
public AjaxResult getProShifts() {
return success(mesReportWorkService.getProShifts());
}
/**
*
*/
@RequiresPermissions("mes:hourProduction:list")
@GetMapping("/getHourProductionList")
public List<HashMap> getHourProductionList(MesHourReport mesHourReport) {
List<String> hourNames = this.getProcessFinishList(mesHourReport);
List<String> hourNames = this.getHourProductionTitle(mesHourReport);
mesHourReport.setHourNames(hourNames);
List<HashMap> list = mesReportWorkService.getHourProductionList(mesHourReport);
return list;
}
@RequiresPermissions("mes:hourProduction:list")
@PostMapping("/getHourProductionExport")
public void getHourProductionExport(HttpServletResponse response,MesHourReport mesHourReport) {
List<String> hourNames = this.getHourProductionTitle(mesHourReport);
mesHourReport.setHourNames(hourNames);
List<HashMap> list = mesReportWorkService.getHourProductionList(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, titleName, excelCols, list);
workbook.write(outputStream);
} catch (Exception e) {
e.printStackTrace();
}finally {
if (workbook!=null){
workbook.dispose();
}
}
}
public static void main(String args[]){
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:00:00");

@ -57,7 +57,7 @@ public class WCSInterfaceController extends BaseController {
return success(WCInterfaceService.requestDestinationStations(wcsdto));
}
@Log(title = "获取料罐用量", businessType = BusinessType.GRANT)
@Log(title = "获取料罐用量(废弃,留着以后给别的功能用)", businessType = BusinessType.GRANT)
@PostMapping("/saveLGusedLog")
public AjaxResult saveLGusedLog(@RequestBody List<LGInfoDto> lgdtos) {
if(CollectionUtils.isEmpty(lgdtos)){

@ -28,6 +28,15 @@ public class MesHourReport extends BaseEntity {
private String workorderCode;
private List<String> hourNames;
private String equCodeHour;
private String shiftId;
public String getShiftId() {
return shiftId;
}
public void setShiftId(String shiftId) {
this.shiftId = shiftId;
}
public String getEquCodeHour() {
return equCodeHour;

@ -46,6 +46,15 @@ public class MesProcessReport extends BaseEntity {
private String unit;
private String productDateStart;
private String productDateEnd;
private String shiftId;
public String getShiftId() {
return shiftId;
}
public void setShiftId(String shiftId) {
this.shiftId = shiftId;
}
public String getEquCode() {
return equCode;

@ -0,0 +1,39 @@
package com.op.mes.domain;
//班次实体类
public class MesShift {
private Integer shiftId;
private String shiftDesc;
@Override
public String toString() {
return "ProShift{" +
"shiftId=" + shiftId +
", shiftDesc='" + shiftDesc + '\'' +
'}';
}
public Integer getShiftId() {
return shiftId;
}
public void setShiftId(Integer shiftId) {
this.shiftId = shiftId;
}
public String getShiftDesc() {
return shiftDesc;
}
public void setShiftDesc(String shiftDesc) {
this.shiftDesc = shiftDesc;
}
public MesShift(Integer shiftId, String shiftDesc) {
this.shiftId = shiftId;
this.shiftDesc = shiftDesc;
}
public MesShift() {
}
}

@ -85,4 +85,6 @@ public interface MesReportWorkMapper {
Map<String,MesHourReport> getHourProductionList(MesHourReport mesHourReport);
List<MesHourReport> getEquNames(MesHourReport mesHourReport);
List<MesShift> selectProShift();
}

@ -75,4 +75,6 @@ public interface IMesReportWorkService {
LineChartDto getLineChartData(MesReportProduction mesReportProduction);
List<HashMap> getHourProductionList(MesHourReport mesHourReport);
List<MesShift> getProShifts();
}

@ -150,7 +150,7 @@ public class IWCInterfaceServiceImpl implements IWCSInterfaceService {
List<BoardDTO> totals = null;
List<BoardDTO> everys = null;
if("equ_type_lg".equals(boardDTO.getEquTypeCode())){//equ_type_lg 湿料罐
boardDTO.setYmd(boardDTO.getYmd().replace("-",""));
totals = mesMapper.getTotalNumL(boardDTO);
everys = mesMapper.getEveryNumL(boardDTO);
}else{//成型机、烘房、收坯机
@ -158,7 +158,6 @@ public class IWCInterfaceServiceImpl implements IWCSInterfaceService {
everys = mesMapper.getEveryNum(boardDTO);
}
boardMap.put("totalNum", totals);
boardMap.put("everyNum", everys);
return boardMap;

@ -289,6 +289,16 @@ public class MesReportWorkServiceImpl implements IMesReportWorkService {
return days;
}
/**
* list
* @return
*/
@Override
@DS("#header.poolName")
public List<MesShift> getProShifts() {
return mesReportWorkMapper.selectProShift();
}
public static void main(String[] args) {
Calendar calendar = Calendar.getInstance();
Date now = calendar.getTime();

@ -116,23 +116,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select count(0) totalNum,
equ.equipment_type_code equTypeCode,
equ.equipment_type_name equTypeName
from pro_lg_used_log mt
left join base_equipment equ on mt.device_code = equ.equipment_code
where mt.createDate = #{ymd} and equ.equipment_name is not null
and equ.equipment_type_code = #{equTypeCode}
from mes_material_transfer_result mt
left join base_equipment equ on mt.equipmentCode = equ.equipment_code
where CONVERT(varchar(10),mt.create_time, 120) = #{ymd} and equ.equipment_name is not null
and equ.equipment_type_code = #{equTypeCode} and mt.status = 2
group by equ.equipment_type_code,
equ.equipment_type_name
</select>
<select id="getEveryNumL" resultType="com.op.system.api.domain.dto.BoardDTO">
select count(0) totalNum,
mt.device_code equCode,
mt.equipmentCode equCode,
equ.equipment_name equName,
equ.equipment_type_code equTypeCode
from pro_lg_used_log mt
left join base_equipment equ on mt.device_code = equ.equipment_code
where mt.createDate = #{ymd} and equ.equipment_name is not null
and equ.equipment_type_code = #{equTypeCode}
group by mt.device_code,
from mes_material_transfer_result mt
left join base_equipment equ on mt.equipmentCode = equ.equipment_code
where CONVERT(varchar(10),mt.create_time, 120) = #{ymd} and equ.equipment_name is not null
and equ.equipment_type_code = #{equTypeCode} and mt.status = 2
group by mt.equipmentCode,
equ.equipment_name,
equ.equipment_type_code
</select>

@ -105,6 +105,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join pro_order_workorder pow on pow.workorder_id = mt.OrderCode
left join pro_process ps on ps.process_id = mt.now_process_id
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>
@ -255,6 +258,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
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="shiftId != null and shiftId != ''">
and pow.shift_id = #{shiftId}
</if>
<if test="orderCode != null and orderCode != ''">
and pow.order_code like concat('%', #{orderCode}, '%')
</if>
@ -297,7 +303,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
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="shiftId != null and shiftId != ''">
and pow.shift_id = #{shiftId}
</if>
<if test="orderCode != null and orderCode != ''">
and pow.order_code like concat('%', #{orderCode}, '%')
</if>
@ -318,6 +326,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
mt.equipmentCode,
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
</select>
<insert id="insertMesReportWork" parameterType="MesReportWork">
insert into mes_report_work

Loading…
Cancel
Save