diff --git a/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/agvTask/controller/AgvTaskController.java b/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/agvTask/controller/AgvTaskController.java index 0abc137..65eb441 100644 --- a/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/agvTask/controller/AgvTaskController.java +++ b/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/agvTask/controller/AgvTaskController.java @@ -1,10 +1,22 @@ package org.cpte.modules.agvTask.controller; -import java.util.Arrays; +import java.io.IOException; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.ss.usermodel.Workbook; +import org.cpte.modules.agvTask.mapper.AgvTaskMapper; +import org.cpte.modules.agvTask.vo.ExportAgvTask; import org.cpte.modules.constant.enums.AgvStatusEnum; +import org.cpte.modules.constant.enums.BusinessTypeEnum; +import org.cpte.modules.constant.enums.InventoryStatusEnum; +import org.cpte.modules.inventory.vo.ExportInventory; import org.jeecg.common.api.vo.Result; import org.jeecg.common.system.query.QueryGenerator; import org.cpte.modules.agvTask.entity.AgvTask; @@ -14,9 +26,11 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import lombok.extern.slf4j.Slf4j; import org.jeecg.common.system.base.controller.JeecgController; +import org.jeecgframework.poi.excel.ExcelExportUtil; +import org.jeecgframework.poi.excel.entity.ExportParams; +import org.jeecgframework.poi.excel.entity.params.ExcelExportEntity; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; -import org.springframework.web.servlet.ModelAndView; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.Operation; import org.jeecg.common.aspect.annotation.AutoLog; @@ -34,6 +48,9 @@ import org.apache.shiro.authz.annotation.RequiresPermissions; @Slf4j public class AgvTaskController extends JeecgController { + @Autowired + private AgvTaskMapper agvTaskMapper; + @Autowired private IAgvTaskService agvTaskService; @@ -148,8 +165,74 @@ public class AgvTaskController extends JeecgController */ @RequiresPermissions("agvTask:data_agv_task:exportXls") @RequestMapping(value = "/exportXls") - public ModelAndView exportXls(HttpServletRequest request, AgvTask agvTask) { - return super.exportXls(request, agvTask, AgvTask.class, "AGV任务表"); + public void exportXls(HttpServletRequest request, HttpServletResponse response, AgvTask agvTask) { + try { + + List agvTaskList = agvTaskMapper.queryExportAgvTask(agvTask); + + List> dataList = new ArrayList<>(); + for (ExportAgvTask agv : agvTaskList) { + Map dataMap = new HashMap<>(); + dataMap.put("TES任务号", agv.getTesId()); + dataMap.put("任务号", agv.getId()); + dataMap.put("柜号", agv.getConNo()); + dataMap.put("物料", agv.getItemCode()); + dataMap.put("容器", agv.getCarrierCode()); + dataMap.put("业务类型", BusinessTypeEnum.getDescByValue(agv.getType())); + dataMap.put("起点", agv.getStartCode()); + dataMap.put("终点", agv.getEndCode()); + dataMap.put("创建时间", agv.getCreateTime()); + dataMap.put("下发时间", agv.getStartTime()); + dataMap.put("完成时间", agv.getEndTime()); + dataMap.put("完成耗时", agv.getEndConst()); + dataMap.put("顶升时间", agv.getOutBinTime()); + dataMap.put("顶升耗时", agv.getOutConst()); + // 添加其他需要导出的字段 + dataList.add(dataMap); + } + + List entityList = new ArrayList<>(); + // 根据实际的库存实体字段设置表头 + entityList.add(new ExcelExportEntity("TES任务号", "TES任务号", 10)); + entityList.add(new ExcelExportEntity("任务号", "任务号", 20)); + entityList.add(new ExcelExportEntity("柜号", "柜号", 15)); + entityList.add(new ExcelExportEntity("物料", "物料", 15)); + entityList.add(new ExcelExportEntity("容器", "容器", 15)); + entityList.add(new ExcelExportEntity("业务类型", "业务类型", 15)); + entityList.add(new ExcelExportEntity("起点", "起点", 20)); + entityList.add(new ExcelExportEntity("终点", "终点", 20)); + entityList.add(new ExcelExportEntity("创建时间", "创建时间", 20)); + entityList.add(new ExcelExportEntity("下发时间", "下发时间", 20)); + entityList.add(new ExcelExportEntity("完成时间", "完成时间", 20)); + entityList.add(new ExcelExportEntity("完成耗时", "完成耗时", 20)); + entityList.add(new ExcelExportEntity("顶升时间", "顶升时间", 20)); + entityList.add(new ExcelExportEntity("顶升耗时", "顶升耗时", 20)); + + Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(null, "TES任务信息"), entityList, dataList); + /* // 自动调整列宽 + Sheet sheet = workbook.getSheetAt(0); + for (int i = 0; i < entityList.size(); i++) { + sheet.autoSizeColumn(i); + }*/ + // 设置响应头 + response.setContentType("application/vnd.ms-excel"); + String fileName = "TES任务信息.xls"; + // 对文件名进行URL编码,解决中文字符编码问题 + String encodedFileName = URLEncoder.encode(fileName, StandardCharsets.UTF_8).replaceAll("\\+", "%20"); + response.setHeader("Content-disposition", "attachment;filename*=UTF-8''" + encodedFileName); + + // 直接写入响应输出流 + workbook.write(response.getOutputStream()); + response.flushBuffer(); + } catch (IOException e) { + log.info("excel导出错误:" + e.getMessage()); + try { + response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + response.getWriter().write("导出失败: " + e.getMessage()); + } catch (IOException ex) { + log.error("导出错误处理失败", ex); + } + } } /** diff --git a/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/agvTask/entity/AgvTask.java b/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/agvTask/entity/AgvTask.java index b5975ef..d3d76e1 100644 --- a/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/agvTask/entity/AgvTask.java +++ b/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/agvTask/entity/AgvTask.java @@ -1,8 +1,6 @@ package org.cpte.modules.agvTask.entity; import java.io.Serializable; -import java.sql.Timestamp; - import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; @@ -13,11 +11,7 @@ import lombok.*; import com.fasterxml.jackson.annotation.JsonFormat; import org.jeecg.common.aspect.annotation.Dict; import org.springframework.format.annotation.DateTimeFormat; -import org.jeecgframework.poi.excel.annotation.Excel; import io.swagger.v3.oas.annotations.media.Schema; -import lombok.experimental.Accessors; - -import javax.persistence.Column; /** * @Description: AGV任务表 @@ -45,15 +39,13 @@ public class AgvTask implements Serializable { /** * 上游ID */ - @Excel(name = "上游ID", width = 15) - @Schema(description = "上游ID") + @Schema(description = "TES任务号") @JsonSerialize(using = ToStringSerializer.class) private java.lang.Long tesId; /** * 业务ID */ - @Excel(name = "业务ID", width = 15) @Schema(description = "业务ID") @JsonSerialize(using = ToStringSerializer.class) private java.lang.Long businessDetailId; @@ -61,7 +53,6 @@ public class AgvTask implements Serializable { /** * 物料 */ - @Excel(name = "物料", width = 15) @Schema(description = "物料") @Dict(dictTable = "base_item", dicCode = "id", dicText = "item_code") @JsonSerialize(using = ToStringSerializer.class) @@ -73,66 +64,69 @@ public class AgvTask implements Serializable { /** * 柜号 */ - @Excel(name = "柜号", width = 15) @Schema(description = "柜号") private java.lang.String conNo; /** * 载具编号 */ - @Excel(name = "载具编号", width = 15) @Schema(description = "载具编号") private java.lang.String carrierCode; /** * 载具类型 */ - @Excel(name = "载具类型", width = 15) @Schema(description = "载具类型") private java.lang.String carrierType; /** * 任务类型 */ - @Excel(name = "任务类型", width = 15) @Schema(description = "任务类型") private java.lang.String taskType; /** * 业务类型 */ - @Excel(name = "业务类型", width = 15) @Schema(description = "业务类型") @Dict(dicCode = "business_type") private java.lang.String type; + + /** + * 多状态查询库存 + */ + @TableField(exist = false) + private String type_MultiString; + /** * 任务状态 */ - @Excel(name = "任务状态", width = 15) @Schema(description = "任务状态") @Dict(dicCode = "agv_task_status") private java.lang.Integer status; + + /** + * 多状态查询库存 + */ + @TableField(exist = false) + private String status_MultiString; /** * 优先级 */ - @Excel(name = "优先级", width = 15) @Schema(description = "优先级") private java.lang.Integer priority; /** * 起点位置 */ - @Excel(name = "起点位置", width = 15) @Schema(description = "起点位置") private java.lang.String startCode; /** * 终点位置 */ - @Excel(name = "终点位置", width = 15) @Schema(description = "终点位置") private java.lang.String endCode; /** * AGV供应商 */ - @Excel(name = "AGV供应商", width = 15) @Schema(description = "AGV供应商") @Dict(dicCode = "agv_vendor") private java.lang.String agvVendor; @@ -140,14 +134,12 @@ public class AgvTask implements Serializable { /** * 是否整托0整托,1拆托 */ - @Excel(name = "是否整托", width = 15) @Schema(description = "是否整托") private java.lang.Integer izAll; /** * 返回报文 */ - @Excel(name = "返回报文", width = 15) @Schema(description = "返回报文") private java.lang.String resMessage; /** @@ -180,7 +172,6 @@ public class AgvTask implements Serializable { /** * 租户ID */ - @Excel(name = "租户ID", width = 15) @Schema(description = "租户ID") private java.lang.Long tenantId; /** @@ -195,6 +186,13 @@ public class AgvTask implements Serializable { @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @Schema(description = "创建日期") private java.util.Date createTime; + + @TableField(exist = false) + private String createTime_begin; + + @TableField(exist = false) + private String createTime_end; + /** * 更新人 */ diff --git a/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/agvTask/mapper/AgvTaskMapper.java b/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/agvTask/mapper/AgvTaskMapper.java index 9874e40..b1ac7ac 100644 --- a/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/agvTask/mapper/AgvTaskMapper.java +++ b/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/agvTask/mapper/AgvTaskMapper.java @@ -4,6 +4,7 @@ import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; import org.cpte.modules.agvTask.entity.AgvTask; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.cpte.modules.agvTask.vo.ExportAgvTask; import org.cpte.modules.dashboard.vo.WorkstationTask; import java.util.List; @@ -16,6 +17,14 @@ import java.util.Map; * @Version: V1.0 */ public interface AgvTaskMapper extends BaseMapper { + + /** + * 查询导出AGV数据 + * + * @return List + */ + List queryExportAgvTask(@Param("agvTask") AgvTask agvTask); + /** * 根据容器编码验证AGV任务是否存在 * @@ -29,7 +38,7 @@ public interface AgvTaskMapper extends BaseMapper { * 根据起点编码验证AGV任务是否存在 * * @param startCode 起点 - * @param agvVendor 供应商;AGV/TES + * @param agvVendor 供应商;AGV/TES */ @Select(value = "select 1 from data_agv_task where start_code = #{startCode} and status in (2,3) and agv_vendor = #{agvVendor} LIMIT 1 ") Integer existsByStartCode(@Param("startCode") String startCode, @Param("agvVendor") String agvVendor); @@ -38,8 +47,8 @@ public interface AgvTaskMapper extends BaseMapper { /** * 根据终点编码验证AGV任务是否存在 * - * @param endCode 终点 - * @param agvVendor 供应商;AGV/TES + * @param endCode 终点 + * @param agvVendor 供应商;AGV/TES */ @Select(value = "select 1 from data_agv_task where end_code = #{endCode} and status in (2,3) and agv_vendor = #{agvVendor} LIMIT 1 ") Integer existsByEndCode(@Param("endCode") String endCode, @Param("agvVendor") String agvVendor); diff --git a/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/agvTask/mapper/xml/AgvTaskMapper.xml b/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/agvTask/mapper/xml/AgvTaskMapper.xml index 88d9cd2..cbf585b 100644 --- a/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/agvTask/mapper/xml/AgvTaskMapper.xml +++ b/cpte-boot-module/cpte-module-wms/src/main/java/org/cpte/modules/agvTask/mapper/xml/AgvTaskMapper.xml @@ -1,6 +1,72 @@ + +