报表基础模块:新增支持生产单报表 (板材明细-按房间/板材)导出

This commit is contained in:
gaoqr
2024-07-29 18:25:29 +08:00
parent 51663d06a7
commit c961547fc8
6 changed files with 142 additions and 13 deletions
@@ -21,8 +21,13 @@ import java.util.List;
public interface OrderPlateDatasourceApi { public interface OrderPlateDatasourceApi {
String PREFIX = ApiConstants.PREFIX + "/order-plate"; String PREFIX = ApiConstants.PREFIX + "/order-plate";
@GetMapping(PREFIX + "/summary/byPlate") @GetMapping(PREFIX + "/summary")
@Operation(summary = "板材汇总板材数据") @Operation(summary = "板材汇总")
@Parameter(name = "orderId", description = "生产单id", required = true, example = "1") @Parameter(name = "orderId", description = "生产单id", required = true, example = "1")
CommonResult<List<PlateGoodsRespDTO>> selectPlateGoodsListSummary(@RequestParam("orderId") Long orderId); CommonResult<List<PlateGoodsRespDTO>> selectPlateGoodsListSummary(@RequestParam("orderId") Long orderId);
@GetMapping(PREFIX + "/detail")
@Operation(summary = "板材明细")
@Parameter(name = "orderId", description = "生产单id", required = true, example = "1")
CommonResult<List<PlateGoodsRespDTO>> selectPlateGoodsList(@RequestParam("orderId") Long orderId);
} }
@@ -154,7 +154,7 @@ public class PlateGoodsRespDTO {
@Schema(description = "是否孤形对角") @Schema(description = "是否孤形对角")
private Boolean isArcAcross; private Boolean isArcAcross;
@Schema(description = "是否异") @Schema(description = "是否异")
private Boolean isSpecialShaped; private Boolean isSpecialShaped;
@Schema(description = "是否造型") @Schema(description = "是否造型")
@@ -0,0 +1,40 @@
package com.cf.imes.module.executor.enums;
/**
* 板材开门类型枚举
*
* @author Gqr
* @since 2024/7/29 9:58
*/
public enum OrderPlateOpenDoorTypeEnum {
NO(0, ""),
LEFT(1, ""),
RIGHT(2, ""),
UP(3, ""),
DOWN(4, "");
private final int code;
private final String desc;
OrderPlateOpenDoorTypeEnum(int code, String desc) {
this.code = code;
this.desc = desc;
}
public int getCode() {
return code;
}
public String getDesc() {
return desc;
}
public static String getDescFromCode(int code) {
for (OrderPlateOpenDoorTypeEnum orderPlateOpenDoorTypeEnum : OrderPlateOpenDoorTypeEnum.values()) {
if (orderPlateOpenDoorTypeEnum.getCode() == code) {
return orderPlateOpenDoorTypeEnum.getDesc();
}
}
return null;
}
}
@@ -31,4 +31,12 @@ public class OrderPlateDatasourceApiImpl implements OrderPlateDatasourceApi {
List<PlateGoodsRespVO> plateGoodsRespVOS = plateMapper.selectPlateGoodsListSummary(orderId, SecurityFrameworkUtils.getLoginUser().getOrganId(), notDeletedStatus); List<PlateGoodsRespVO> plateGoodsRespVOS = plateMapper.selectPlateGoodsListSummary(orderId, SecurityFrameworkUtils.getLoginUser().getOrganId(), notDeletedStatus);
return CommonResult.success(BeanUtils.toBean(plateGoodsRespVOS, PlateGoodsRespDTO.class)); return CommonResult.success(BeanUtils.toBean(plateGoodsRespVOS, PlateGoodsRespDTO.class));
} }
@Override
public CommonResult<List<PlateGoodsRespDTO>> selectPlateGoodsList(Long orderId) {
// 查询分组统计
Integer notDeletedStatus = OrderDeletedEnum.NOT_DELETED.getStatus();
List<PlateGoodsRespVO> plateGoodsRespVOS = plateMapper.selectPlateGoodsList(orderId, SecurityFrameworkUtils.getLoginUser().getOrganId(), notDeletedStatus);
return CommonResult.success(BeanUtils.toBean(plateGoodsRespVOS, PlateGoodsRespDTO.class));
}
} }
@@ -7,6 +7,7 @@ import com.cf.imes.module.executor.api.datasource.OrderDatasourceApi;
import com.cf.imes.module.executor.api.datasource.OrderPlateDatasourceApi; 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.OrderDTO;
import com.cf.imes.module.executor.api.datasource.dto.PlateGoodsRespDTO; 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; import com.cf.imes.module.report.framework.ureport.annotation.CfReportSpringbeanDatasource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -76,15 +77,15 @@ public class OrderSummaryBeanDatasource {
} }
/** /**
* 板材汇总-按板材 * 板材汇总
* *
* @param dsName * @param dsName
* @param datasetName * @param datasetName
* @param parameters * @param parameters
* @return * @return
*/ */
public List<Map<String, Object>> orderPlateSummaryByPlate(String dsName, String datasetName, Map<String, Object> parameters) { public List<Map<String, Object>> orderPlateGoodsSummary(String dsName, String datasetName, Map<String, Object> parameters) {
log.info("报表数据源[OrderSummaryBeanDatasource][orderPlateSummaryByPlate][{}][{}]调用开始", dsName, datasetName); log.info("报表数据源[OrderSummaryBeanDatasource][orderPlateGoodsSummary][{}][{}]调用开始", dsName, datasetName);
List<Map<String, Object>> resultList = new ArrayList<>(); List<Map<String, Object>> resultList = new ArrayList<>();
Object orderId = parameters.get(ORDER_ID_FIELD_NAME); Object orderId = parameters.get(ORDER_ID_FIELD_NAME);
@@ -100,19 +101,94 @@ public class OrderSummaryBeanDatasource {
// 构造报表所需结构 // 构造报表所需结构
resultMap.put("roomName", p.getRoomName()); resultMap.put("roomName", p.getRoomName());
resultMap.put("bodyName", p.getBodyName()); resultMap.put("bodyName", p.getBodyName());
resultMap.put("thickness", p.getThickness()); resultMap.put("thickness", stripTrailingZeros(p.getThickness()));
resultMap.put("name", p.getName()); resultMap.put("name", p.getName());
resultMap.put("height", p.getHeight()); resultMap.put("height", stripTrailingZeros(p.getHeight()));
resultMap.put("width", p.getWidth()); resultMap.put("width", stripTrailingZeros(p.getWidth()));
resultMap.put("count", count); resultMap.put("count", count);
resultMap.put("area", area); resultMap.put("area", stripTrailingZeros(area));
resultMap.put("openDoorType", p.getOpenDoorType()); 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", p.getRemark());
resultMap.put("areaAll", area.multiply(BigDecimal.valueOf(count))); resultMap.put("areaAll", stripTrailingZeros(area.multiply(BigDecimal.valueOf(count))));
resultList.add(resultMap); resultList.add(resultMap);
}); });
} }
log.info("报表数据源[OrderSummaryBeanDatasource][orderPlateSummaryByPlate][{}][{}]调用结束", dsName, datasetName); log.info("报表数据源[OrderSummaryBeanDatasource][orderPlateGoodsSummary][{}][{}]调用结束", dsName, datasetName);
return resultList; return resultList;
} }
/**
* 板材明细
*
* @param dsName
* @param datasetName
* @param parameters
* @return
*/
public List<Map<String, Object>> orderPlateGoodsList(String dsName, String datasetName, Map<String, Object> parameters) {
log.info("报表数据源[OrderSummaryBeanDatasource][orderPlateGoodsList][{}][{}]调用开始", dsName, datasetName);
List<Map<String, Object>> resultList = new ArrayList<>();
Object orderId = parameters.get(ORDER_ID_FIELD_NAME);
// 查询统计信息
CommonResult<List<PlateGoodsRespDTO>> commonResult = orderPlateDatasourceApi.selectPlateGoodsList(Long.parseLong(orderId.toString()));
List<PlateGoodsRespDTO> plateGoodsRespDTOS = commonResult.getData();
if (CollUtil.isNotEmpty(plateGoodsRespDTOS)) {
plateGoodsRespDTOS.forEach(p -> {
Map<String, Object> resultMap = new HashMap<>();
BigDecimal area = p.getArea();
Integer count = p.getCount();
// 构造报表所需结构
resultMap.put("goodsName", p.getGoodsName());
resultMap.put("name", p.getName());
resultMap.put("material", p.getMaterial());
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("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("isSpecialShaped", getBooleanString(p.getIsSpecialShaped()));
resultMap.put("isSculpt", getBooleanString(p.getIsSculpt()));
resultMap.put("openDoorType", OrderPlateOpenDoorTypeEnum.getDescFromCode(p.getOpenDoorType()));
resultMap.put("seal", String.join(",", stripTrailingZeros(p.getSealLeft()), stripTrailingZeros(p.getSealRight()), stripTrailingZeros(p.getSealUp()), stripTrailingZeros(p.getSealDown())));
resultMap.put("areaAll", stripTrailingZeros(area.multiply(BigDecimal.valueOf(count))));
resultList.add(resultMap);
});
}
log.info("报表数据源[OrderSummaryBeanDatasource][orderPlateGoodsList][{}][{}]调用结束", dsName, datasetName);
return resultList;
}
/**
* 移除尾数的0600.000 -> 600
*
* @param data
* @return
*/
private String stripTrailingZeros(BigDecimal data) {
if (ObjectUtil.isNotNull(data)) {
return data.stripTrailingZeros().toPlainString();
} else {
return "";
}
}
/**
* 布尔值转是否
*
* @param b
* @return
*/
private String getBooleanString(Boolean b) {
return b ? "" : "";
}
} }