报表基础模块:新增支持生产单报表 (配件汇总/明细)导出

This commit is contained in:
gaoqr
2024-07-30 10:33:00 +08:00
parent c961547fc8
commit bfcc070b94
7 changed files with 232 additions and 10 deletions
@@ -1,11 +1,12 @@
package com.cf.imes.module.report.framework.rpc.config;
import com.cf.imes.module.executor.api.datasource.OrderDatasourceApi;
import com.cf.imes.module.executor.api.datasource.OrderPartDatasourceApi;
import com.cf.imes.module.executor.api.datasource.OrderPlateDatasourceApi;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Configuration;
@Configuration(proxyBeanMethods = false)
@EnableFeignClients(clients = {OrderPlateDatasourceApi.class, OrderDatasourceApi.class})
@EnableFeignClients(clients = {OrderPlateDatasourceApi.class, OrderDatasourceApi.class, OrderPartDatasourceApi.class})
public class RpcConfiguration {
}
@@ -4,8 +4,10 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.cf.imes.framework.common.pojo.CommonResult;
import com.cf.imes.module.executor.api.datasource.OrderDatasourceApi;
import com.cf.imes.module.executor.api.datasource.OrderPartDatasourceApi;
import com.cf.imes.module.executor.api.datasource.OrderPlateDatasourceApi;
import com.cf.imes.module.executor.api.datasource.dto.OrderDTO;
import com.cf.imes.module.executor.api.datasource.dto.PartGoodsRespDTO;
import com.cf.imes.module.executor.api.datasource.dto.PlateGoodsRespDTO;
import com.cf.imes.module.executor.enums.OrderPlateOpenDoorTypeEnum;
import com.cf.imes.module.report.framework.ureport.annotation.CfReportSpringbeanDatasource;
@@ -34,7 +36,14 @@ public class OrderSummaryBeanDatasource {
@Resource
private OrderDatasourceApi orderDatasourceApi;
@Resource
private OrderPartDatasourceApi orderPartDatasourceApi;
// 常用的字段key
private static final String ORDER_ID_FIELD_NAME = "orderId";
private static final String BODY_NAME_FIELD_NAME = "bodyName";
private static final String ROOM_NAME_FIELD_NAME = "roomName";
private static final String REMARK_FIELD_NAME = "remark";
/**
* 生产单信息
@@ -99,8 +108,8 @@ public class OrderSummaryBeanDatasource {
BigDecimal area = p.getArea();
Integer count = p.getCount();
// 构造报表所需结构
resultMap.put("roomName", p.getRoomName());
resultMap.put("bodyName", p.getBodyName());
resultMap.put(ROOM_NAME_FIELD_NAME, p.getRoomName());
resultMap.put(BODY_NAME_FIELD_NAME, p.getBodyName());
resultMap.put("thickness", stripTrailingZeros(p.getThickness()));
resultMap.put("name", p.getName());
resultMap.put("height", stripTrailingZeros(p.getHeight()));
@@ -110,7 +119,7 @@ public class OrderSummaryBeanDatasource {
resultMap.put("openDoorType", OrderPlateOpenDoorTypeEnum.getDescFromCode(p.getOpenDoorType()));
resultMap.put("material", p.getMaterial());
resultMap.put("color", p.getColor());
resultMap.put("remark", p.getRemark());
resultMap.put(REMARK_FIELD_NAME, p.getRemark());
resultMap.put("areaAll", stripTrailingZeros(area.multiply(BigDecimal.valueOf(count))));
resultList.add(resultMap);
});
@@ -148,14 +157,14 @@ public class OrderSummaryBeanDatasource {
resultMap.put("color", p.getColor());
resultMap.put("goodsThickness", p.getGoodsThickness());
resultMap.put("count", p.getCount());
resultMap.put("roomName", p.getRoomName());
resultMap.put("bodyName", p.getBodyName());
resultMap.put(ROOM_NAME_FIELD_NAME, p.getRoomName());
resultMap.put(BODY_NAME_FIELD_NAME, p.getBodyName());
resultMap.put("plateNo", p.getPlateNo());
resultMap.put("height", stripTrailingZeros(p.getHeight()));
resultMap.put("width", stripTrailingZeros(p.getWidth()));
resultMap.put("thickness", stripTrailingZeros(p.getThickness()));
resultMap.put("area", stripTrailingZeros(area));
resultMap.put("remark", p.getRemark());
resultMap.put(REMARK_FIELD_NAME, p.getRemark());
resultMap.put("isSpecialShaped", getBooleanString(p.getIsSpecialShaped()));
resultMap.put("isSculpt", getBooleanString(p.getIsSculpt()));
resultMap.put("openDoorType", OrderPlateOpenDoorTypeEnum.getDescFromCode(p.getOpenDoorType()));
@@ -168,6 +177,65 @@ public class OrderSummaryBeanDatasource {
return resultList;
}
public List<Map<String, Object>> orderPartDetailList(String dsName, String datasetName, Map<String, Object> parameters) {
log.info("报表数据源[OrderSummaryBeanDatasource][orderPartDetailList][{}][{}]调用开始", dsName, datasetName);
List<Map<String, Object>> resultList = new ArrayList<>();
Object orderId = parameters.get(ORDER_ID_FIELD_NAME);
CommonResult<List<PartGoodsRespDTO>> commonResult = orderPartDatasourceApi.selectPartDetail(Long.parseLong(orderId.toString()));
List<PartGoodsRespDTO> partGoodsRespDTOS = commonResult.getData();
if (CollUtil.isNotEmpty(partGoodsRespDTOS)) {
partGoodsRespDTOS.forEach(p -> {
Map<String, Object> resultMap = new HashMap<>();
// 构造报表所需结构
resultMap.put(ROOM_NAME_FIELD_NAME, p.getRoomName());
resultMap.put(BODY_NAME_FIELD_NAME, p.getBodyName());
resultMap.put("name", p.getName());
resultMap.put("brand", p.getBrand());
resultMap.put("factory", p.getFactory());
resultMap.put("model", p.getModel());
resultMap.put("spec", p.getSpec());
resultMap.put("num", p.getNum());
resultMap.put("unit", p.getUnit());
resultMap.put("price", p.getPrice());
resultMap.put("totalPrice", p.getTotalPrice());
resultMap.put(REMARK_FIELD_NAME, p.getRemark());
resultList.add(resultMap);
});
}
log.info("报表数据源[OrderSummaryBeanDatasource][orderPartDetailList][{}][{}]调用结束", dsName, datasetName);
return resultList;
}
public List<Map<String, Object>> orderPartSummary(String dsName, String datasetName, Map<String, Object> parameters) {
log.info("报表数据源[OrderSummaryBeanDatasource][orderPartSummary][{}][{}]调用开始", dsName, datasetName);
List<Map<String, Object>> resultList = new ArrayList<>();
Object orderId = parameters.get(ORDER_ID_FIELD_NAME);
CommonResult<List<PartGoodsRespDTO>> commonResult = orderPartDatasourceApi.selectPartAll(Long.parseLong(orderId.toString()));
List<PartGoodsRespDTO> partGoodsRespDTOS = commonResult.getData();
if (CollUtil.isNotEmpty(partGoodsRespDTOS)) {
partGoodsRespDTOS.forEach(p -> {
Map<String, Object> resultMap = new HashMap<>();
// 构造报表所需结构
resultMap.put("name", p.getName());
resultMap.put("model", p.getModel());
resultMap.put("spec", p.getSpec());
resultMap.put("num", p.getNum());
resultMap.put("unit", p.getUnit());
resultMap.put("brand", p.getBrand());
resultMap.put(REMARK_FIELD_NAME, p.getRemark());
resultList.add(resultMap);
});
}
log.info("报表数据源[OrderSummaryBeanDatasource][orderPartSummary][{}][{}]调用结束", dsName, datasetName);
return resultList;
}
/**
* 移除尾数的0600.000 -> 600
*