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

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
@@ -0,0 +1,33 @@
package com.cf.imes.module.executor.api.datasource;
import com.cf.imes.framework.common.pojo.CommonResult;
import com.cf.imes.module.executor.api.datasource.dto.PartGoodsRespDTO;
import com.cf.imes.module.executor.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
* @author Gqr
* @since 2024/7/30 9:22
*/
@FeignClient(name = ApiConstants.NAME)
@Tag(name = "RPC 服务 - 配件报表数据源")
public interface OrderPartDatasourceApi {
String PREFIX = ApiConstants.PREFIX + "/order-part";
@GetMapping(PREFIX + "/detail")
@Operation(summary = "配件明细")
@Parameter(name = "orderId", description = "生产单id", required = true, example = "1")
CommonResult<List<PartGoodsRespDTO>> selectPartDetail(@RequestParam("orderId") Long orderId);
@GetMapping(PREFIX + "/summary")
@Operation(summary = "配件汇总")
@Parameter(name = "orderId", description = "生产单id", required = true, example = "1")
CommonResult<List<PartGoodsRespDTO>> selectPartAll(@RequestParam("orderId") Long orderId);
}
@@ -0,0 +1,80 @@
package com.cf.imes.module.executor.api.datasource.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.LocalDateTime;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Schema(description = "管理后台 - 配件对应板材信息 Resp DTO")
public class PartGoodsRespDTO {
@Schema(description = "柜体号", example = "11087")
private Long bodyId;
@Schema(description = "柜体名称", example = "11087")
private String bodyName;
@Schema(description = "房间号", example = "11087")
private Long roomId;
@Schema(description = "房间名称", example = "11087")
private String roomName;
@Schema(description = "配件 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "29347")
private Long id;
@Schema(description = "生产单号", requiredMode = Schema.RequiredMode.REQUIRED)
private Long orderId;
@Schema(description = "商品ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1195")
private String goodsId;
@Schema(description = "配件名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "晨丰")
private String name;
@Schema(description = "材质", requiredMode = Schema.RequiredMode.REQUIRED)
private String material;
@Schema(description = "配件类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
private String type;
@Schema(description = "型号", requiredMode = Schema.RequiredMode.REQUIRED)
private String model;
@Schema(description = "规格", requiredMode = Schema.RequiredMode.REQUIRED)
private String spec;
@Schema(description = "品牌", requiredMode = Schema.RequiredMode.REQUIRED)
private String brand;
@Schema(description = "厂家", requiredMode = Schema.RequiredMode.REQUIRED)
private String factory;
@Schema(description = "单位", requiredMode = Schema.RequiredMode.REQUIRED)
private String unit;
@Schema(description = "价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "29507")
private Double price;
@Schema(description = "是否复合部件:0 否 1 是", requiredMode = Schema.RequiredMode.REQUIRED)
private Boolean isComposite;
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜")
private String remark;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime createTime;
@Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "29507")
private Double num;
@Schema(description = "金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "29507")
private Double totalPrice;
}
@@ -0,0 +1,42 @@
package com.cf.imes.module.executor.api.datasource;
import com.cf.imes.framework.common.pojo.CommonResult;
import com.cf.imes.framework.common.util.object.BeanUtils;
import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils;
import com.cf.imes.module.executor.api.datasource.dto.PartGoodsRespDTO;
import com.cf.imes.module.executor.controller.admin.orderParts.vo.PartGoodsRespVO;
import com.cf.imes.module.executor.dal.mysql.orderParts.OrderPartsMapper;
import com.cf.imes.module.executor.enums.OrderDeletedEnum;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
/**
* @author Gqr
* @since 2024/7/30 9:21
*/
@RestController // 提供 RESTful API 接口,给 Feign 调用
@Validated
public class OrderPartDatasourceApiImpl implements OrderPartDatasourceApi {
@Resource
private OrderPartsMapper orderPartsMapper;
@Override
public CommonResult<List<PartGoodsRespDTO>> selectPartDetail(Long orderId) {
Integer notDeletedStatus = OrderDeletedEnum.NOT_DELETED.getStatus();
// 查询明细列表
List<PartGoodsRespVO> partGoodsRespVOS = orderPartsMapper.selectPartDetail(orderId, SecurityFrameworkUtils.getLoginUser().getOrganId(), notDeletedStatus);
return CommonResult.success(BeanUtils.toBean(partGoodsRespVOS, PartGoodsRespDTO.class));
}
@Override
public CommonResult<List<PartGoodsRespDTO>> selectPartAll(Long orderId) {
Integer notDeletedStatus = OrderDeletedEnum.NOT_DELETED.getStatus();
// 查询明细列表
List<PartGoodsRespVO> partGoodsRespVOS = orderPartsMapper.selectPartAll(orderId, SecurityFrameworkUtils.getLoginUser().getOrganId(), notDeletedStatus);
return CommonResult.success(BeanUtils.toBean(partGoodsRespVOS, PartGoodsRespDTO.class));
}
}
@@ -34,7 +34,7 @@ public class OrderPlateDatasourceApiImpl implements OrderPlateDatasourceApi {
@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));
@@ -357,7 +357,6 @@
left join order_goods ogs on op.goods_id = ogs.id
left join order_item its on op.id = its.plate_id
left join order_body bdy on bdy.id = its.body_id
left join order_goods gods on gods.id = op.goods_id
where op.order_id = #{orderId}
and op.organ_id = #{organId}
and op.deleted = #{deleted}
@@ -385,7 +384,6 @@
left join order_goods ogs on op.goods_id = ogs.id
left join order_item its on op.id = its.plate_id
left join order_body bdy on bdy.id = its.body_id
left join order_goods gods on gods.id = op.goods_id
where op.order_id = #{orderId}
and op.organ_id = #{organId}
and op.deleted = #{deleted}
@@ -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
*