|
@@ -1,25 +1,51 @@
|
|
package org.jeecg.modules.billet.storageBill.controller;
|
|
package org.jeecg.modules.billet.storageBill.controller;
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
+import lombok.Data;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
|
+import org.apache.shiro.SecurityUtils;
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
import org.jeecg.common.api.vo.Result;
|
|
import org.jeecg.common.api.vo.Result;
|
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
|
import org.jeecg.common.system.base.controller.JeecgController;
|
|
import org.jeecg.common.system.base.controller.JeecgController;
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
|
|
+import org.jeecg.common.system.vo.LoginUser;
|
|
|
|
+import org.jeecg.common.util.DateUtils;
|
|
|
|
+import org.jeecg.common.util.oConvertUtils;
|
|
|
|
+import org.jeecg.modules.billet.rollClubThree.entity.RollClubThreeDetails;
|
|
|
|
+import org.jeecg.modules.billet.rollClubThree.service.IRollClubThreeDetailsService;
|
|
|
|
+import org.jeecg.modules.billet.rollClubTwo.entity.RollClubTwoDetails;
|
|
|
|
+import org.jeecg.modules.billet.rollClubTwo.service.IRollClubTwoDetailsService;
|
|
|
|
+import org.jeecg.modules.billet.rollDeputyCross.entity.RollDeputyCrossDetails;
|
|
|
|
+import org.jeecg.modules.billet.rollDeputyCross.service.IRollDeputyCrossDetailsService;
|
|
|
|
+import org.jeecg.modules.billet.rollOutShipp.entity.RollOutShipp;
|
|
|
|
+import org.jeecg.modules.billet.rollOutShipp.entity.RollOutShippDetails;
|
|
|
|
+import org.jeecg.modules.billet.rollOutShipp.service.IRollOutShippDetailsService;
|
|
|
|
+import org.jeecg.modules.billet.storageBill.entity.StorageBill;
|
|
import org.jeecg.modules.billet.storageBill.entity.StorageBillPrint;
|
|
import org.jeecg.modules.billet.storageBill.entity.StorageBillPrint;
|
|
import org.jeecg.modules.billet.storageBill.service.IStorageBillPrintService;
|
|
import org.jeecg.modules.billet.storageBill.service.IStorageBillPrintService;
|
|
|
|
+import org.jeecg.modules.deviceSbm.entity.DeviceInformation;
|
|
|
|
+import org.jeecg.modules.deviceSbm.entity.DeviceRegion;
|
|
|
|
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
|
|
|
+import org.jeecgframework.poi.excel.entity.ExportParams;
|
|
|
|
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
-import java.util.Arrays;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @Description: 装运单打印表
|
|
* @Description: 装运单打印表
|
|
@@ -35,6 +61,17 @@ public class StorageBillPrintController extends JeecgController<StorageBillPrint
|
|
@Autowired
|
|
@Autowired
|
|
private IStorageBillPrintService storageBillPrintService;
|
|
private IStorageBillPrintService storageBillPrintService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private IRollClubTwoDetailsService rollClubTwoDetailsService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IRollClubThreeDetailsService rollClubThreeDetailsService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IRollOutShippDetailsService rollOutShippDetailsService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IRollDeputyCrossDetailsService rollDeputyCrossDetailsService;
|
|
/**
|
|
/**
|
|
* 分页列表查询
|
|
* 分页列表查询
|
|
*
|
|
*
|
|
@@ -142,7 +179,151 @@ public class StorageBillPrintController extends JeecgController<StorageBillPrint
|
|
*/
|
|
*/
|
|
@RequestMapping(value = "/exportXls")
|
|
@RequestMapping(value = "/exportXls")
|
|
public ModelAndView exportXls(HttpServletRequest request, StorageBillPrint storageBillPrint) {
|
|
public ModelAndView exportXls(HttpServletRequest request, StorageBillPrint storageBillPrint) {
|
|
- return super.exportXls(request, storageBillPrint, StorageBillPrint.class, "装运单打印表");
|
|
|
|
|
|
+ try {
|
|
|
|
+ QueryWrapper<StorageBillPrint> queryWrapper = new QueryWrapper<>();
|
|
|
|
+
|
|
|
|
+ // 手动设置必要条件,避免 QueryGenerator 自动生成不必要的条件
|
|
|
|
+ if (oConvertUtils.isNotEmpty(storageBillPrint.getCcmNo())) {
|
|
|
|
+ queryWrapper.eq("ccm_no", storageBillPrint.getCcmNo());
|
|
|
|
+ }
|
|
|
|
+ // 开始时间
|
|
|
|
+ Date startTime = storageBillPrint.getArrivalTime();
|
|
|
|
+ // 结束时间
|
|
|
|
+ Date endTime = storageBillPrint.getCreateTime();
|
|
|
|
+
|
|
|
|
+ log.info("查询时间范围:startTime={}, endTime={}", startTime, endTime);
|
|
|
|
+
|
|
|
|
+ // 修改时间范围查询条件为 >= startTime 且 <= endTime
|
|
|
|
+ queryWrapper.ge("arrival_time", startTime) // 大于等于开始时间
|
|
|
|
+ .le("arrival_time", endTime); // 小于等于结束时间
|
|
|
|
+ // Step.2 获取导出数据
|
|
|
|
+ // 打印完整的查询条件
|
|
|
|
+ log.info("最终查询条件:{}", queryWrapper.getSqlSegment());
|
|
|
|
+ List<StorageBillPrint> exportList = storageBillPrintService.list(queryWrapper);
|
|
|
|
+
|
|
|
|
+ // 用于存储拆分后的新数据
|
|
|
|
+ List<StorageBillPrint> splitList = new ArrayList<>();
|
|
|
|
+ // 遍历原始数据,拆分heatNo字段
|
|
|
|
+ for (StorageBillPrint item : exportList) {
|
|
|
|
+ String heatNoJson = item.getHeatNo();
|
|
|
|
+ if (heatNoJson != null && !heatNoJson.isEmpty()) {
|
|
|
|
+ try {
|
|
|
|
+ // 使用FastJSON解析JSON字符串
|
|
|
|
+ JSONObject heatNoObj = JSON.parseObject(heatNoJson);
|
|
|
|
+
|
|
|
|
+ // 遍历JSON中的每个键值对
|
|
|
|
+ for (Map.Entry<String, Object> entry : heatNoObj.entrySet()) {
|
|
|
|
+ String heatNoKey = entry.getKey();
|
|
|
|
+ int quantity = Integer.parseInt(entry.getValue().toString());
|
|
|
|
+
|
|
|
|
+ // 复制原始对象
|
|
|
|
+ StorageBillPrint newItem = new StorageBillPrint();
|
|
|
|
+ BeanUtils.copyProperties(item, newItem);
|
|
|
|
+ // 设置新的heatNo和支数
|
|
|
|
+ newItem.setHeatNo(heatNoKey);
|
|
|
|
+ newItem.setAmountTotal(quantity);
|
|
|
|
+
|
|
|
|
+ // 添加到新列表
|
|
|
|
+ splitList.add(newItem);
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ // 处理JSON解析异常
|
|
|
|
+ log.error("解析heatNo JSON失败: {}", heatNoJson, e);
|
|
|
|
+ // 如果解析失败,保留原始数据
|
|
|
|
+ splitList.add(item);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ // 如果heatNo为空,保留原始数据
|
|
|
|
+ splitList.add(item);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 第二步:根据size字段拆分
|
|
|
|
+ List<StorageBillPrint> finalList = new ArrayList<>();
|
|
|
|
+ for (StorageBillPrint item : splitList) {
|
|
|
|
+ String sizeStr = item.getSize();
|
|
|
|
+ if (sizeStr != null && sizeStr.contains(",")) {
|
|
|
|
+ // 按逗号分割定尺字符串
|
|
|
|
+ String[] sizes = sizeStr.split(",");
|
|
|
|
+
|
|
|
|
+ for (int i = 0; i < sizes.length; i++) {
|
|
|
|
+ // 复制对象
|
|
|
|
+ StorageBillPrint newItem = new StorageBillPrint();
|
|
|
|
+ BeanUtils.copyProperties(item, newItem);
|
|
|
|
+ // 根据装运单ID、炉号、铸机号、定尺、目的地查询对应的明细信息
|
|
|
|
+ if ("棒二".equals(item.getDestination())){
|
|
|
|
+ LambdaQueryWrapper<RollClubTwoDetails> queryWrapper2 = new LambdaQueryWrapper<>();
|
|
|
|
+ queryWrapper2.eq(RollClubTwoDetails::getStorageBillId, item.getId())
|
|
|
|
+ .eq(RollClubTwoDetails::getCcmNo, item.getCcmNo())
|
|
|
|
+ .eq(RollClubTwoDetails::getSize, sizes[i])
|
|
|
|
+ .eq(RollClubTwoDetails::getHeatNo, item.getHeatNo());
|
|
|
|
+ List<RollClubTwoDetails> rollClubTwoDetailsList = rollClubTwoDetailsService.list(queryWrapper2);
|
|
|
|
+ if (rollClubTwoDetailsList.size() > 0) {
|
|
|
|
+ newItem.setAmountTotal(rollClubTwoDetailsList.size());
|
|
|
|
+ newItem.setWeight(BigDecimal.valueOf(rollClubTwoDetailsList.stream().mapToDouble(RollClubTwoDetails::getBlankOutput).sum()));
|
|
|
|
+ }
|
|
|
|
+ }else if ("棒三".equals(item.getDestination())){
|
|
|
|
+ LambdaQueryWrapper<RollClubThreeDetails> queryWrapper3 = new LambdaQueryWrapper<>();
|
|
|
|
+ queryWrapper3.eq(RollClubThreeDetails::getStorageBillId, item.getId())
|
|
|
|
+ .eq(RollClubThreeDetails::getCcmNo, item.getCcmNo())
|
|
|
|
+ .eq(RollClubThreeDetails::getSize, sizes[i])
|
|
|
|
+ .eq(RollClubThreeDetails::getHeatNo, item.getHeatNo());
|
|
|
|
+ List<RollClubThreeDetails> rollClubThreeDetailsList = rollClubThreeDetailsService.list(queryWrapper3);
|
|
|
|
+ if (rollClubThreeDetailsList.size() > 0) {
|
|
|
|
+ newItem.setAmountTotal(rollClubThreeDetailsList.size());
|
|
|
|
+ newItem.setWeight(BigDecimal.valueOf(rollClubThreeDetailsList.stream().mapToDouble(RollClubThreeDetails::getBlankOutput).sum()));
|
|
|
|
+ }
|
|
|
|
+ }else if ("上若".equals(item.getDestination())){
|
|
|
|
+ LambdaQueryWrapper<RollOutShippDetails> queryWrapper4 = new LambdaQueryWrapper<>();
|
|
|
|
+ queryWrapper4.eq(RollOutShippDetails::getStorageBillId, item.getId())
|
|
|
|
+ .eq(RollOutShippDetails::getCcmNo, item.getCcmNo())
|
|
|
|
+ .eq(RollOutShippDetails::getSize, sizes[i])
|
|
|
|
+ .eq(RollOutShippDetails::getHeatNo, item.getHeatNo());
|
|
|
|
+ List<RollOutShippDetails> rollOutShippDetailsList = rollOutShippDetailsService.list(queryWrapper4);
|
|
|
|
+ if (rollOutShippDetailsList.size() > 0) {
|
|
|
|
+ newItem.setAmountTotal(rollOutShippDetailsList.size());
|
|
|
|
+ newItem.setWeight(BigDecimal.valueOf(rollOutShippDetailsList.stream().mapToDouble(RollOutShippDetails::getBlankOutput).sum()));
|
|
|
|
+ }
|
|
|
|
+ }else if ("付跨".equals(item.getDestination())){
|
|
|
|
+ LambdaQueryWrapper<RollDeputyCrossDetails> queryWrapper5 = new LambdaQueryWrapper<>();
|
|
|
|
+ queryWrapper5.eq(RollDeputyCrossDetails::getStorageBillId, item.getId())
|
|
|
|
+ .eq(RollDeputyCrossDetails::getCcmNo, item.getCcmNo())
|
|
|
|
+ .eq(RollDeputyCrossDetails::getSize, sizes[i])
|
|
|
|
+ .eq(RollDeputyCrossDetails::getHeatNo, item.getHeatNo());
|
|
|
|
+ List<RollDeputyCrossDetails> rollDeputyCrossDetailsList = rollDeputyCrossDetailsService.list(queryWrapper5);
|
|
|
|
+ if (rollDeputyCrossDetailsList.size() > 0) {
|
|
|
|
+ newItem.setAmountTotal(rollDeputyCrossDetailsList.size());
|
|
|
|
+ newItem.setWeight(BigDecimal.valueOf(rollDeputyCrossDetailsList.stream().mapToDouble(RollDeputyCrossDetails::getBlankOutput).sum()));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 设置单个定尺
|
|
|
|
+ newItem.setSize(sizes[i]);
|
|
|
|
+ finalList.add(newItem);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ // 如果定尺没有逗号分隔,直接添加
|
|
|
|
+ finalList.add(item);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Step.3 AutoPoi 导出Excel
|
|
|
|
+ ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
|
|
|
+ //此处设置的filename无效 ,前端会重更新设置一下
|
|
|
|
+ mv.addObject(NormalExcelConstants.FILE_NAME, "装运打印信息列表");
|
|
|
|
+ mv.addObject(NormalExcelConstants.CLASS, StorageBillPrint.class);
|
|
|
|
+ ExportParams exportParams=new ExportParams("储运中心数据" + "报表", "admin", "装运打印信息");
|
|
|
|
+ mv.addObject(NormalExcelConstants.PARAMS,exportParams);
|
|
|
|
+ mv.addObject(NormalExcelConstants.DATA_LIST, finalList);
|
|
|
|
+ return mv;
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ log.error("导出Excel失败:", e);
|
|
|
|
+ // 返回错误信息
|
|
|
|
+ ModelAndView mv = new ModelAndView();
|
|
|
|
+ mv.addObject("message", "导出失败:" + e.getMessage());
|
|
|
|
+ mv.setViewName("error/500");
|
|
|
|
+ return mv;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|