Showing
4 changed files
with
338 additions
and
12 deletions
| ... | ... | @@ -15,6 +15,7 @@ import com.lframework.xingyun.sc.enums.ExportType; |
| 15 | 15 | import com.lframework.xingyun.sc.excel.statistics.OrderDetailReportExportTaskWorker; |
| 16 | 16 | import com.lframework.xingyun.sc.excel.statistics.QualityOrderDetailReportExportTaskWorker; |
| 17 | 17 | import com.lframework.xingyun.sc.excel.statistics.StockInOrderDetailReportExportTaskWorker; |
| 18 | +import com.lframework.xingyun.sc.excel.statistics.StockInboundOrderDetailReportExportTaskWorker; | |
| 18 | 19 | import com.lframework.xingyun.sc.service.statistics.OrderDetailReportService; |
| 19 | 20 | import com.lframework.xingyun.sc.vo.statistics.orderDetail.CreateOrderDetailReportVo; |
| 20 | 21 | import com.lframework.xingyun.sc.vo.statistics.orderDetail.QueryOrderDetailReportVo; |
| ... | ... | @@ -93,7 +94,15 @@ public class OrderDetailReportController extends DefaultBaseController { |
| 93 | 94 | public InvokeResult<PageResult<QueryOrderDetailReportBo>> stockInQuery(@Valid QueryOrderDetailReportVo vo) { |
| 94 | 95 | vo.setExcludeInventoryUnlocked(Boolean.TRUE); |
| 95 | 96 | vo.setInventoryUnlockedOnly(null); |
| 96 | - return query(vo); | |
| 97 | + PageResult<OrderDetailReport> pageResult = orderDetailReportService.query(getPageIndex(vo), getPageSize(vo), vo); | |
| 98 | + List<OrderDetailReport> datas = pageResult.getDatas(); | |
| 99 | + List<QueryOrderDetailReportBo> results = null; | |
| 100 | + | |
| 101 | + if (!CollectionUtil.isEmpty(datas)) { | |
| 102 | + results = datas.stream().map(QueryOrderDetailReportBo::new).collect(Collectors.toList()); | |
| 103 | + } | |
| 104 | + | |
| 105 | + return InvokeResultBuilder.success(PageResultUtil.rebuild(pageResult, results)); | |
| 97 | 106 | } |
| 98 | 107 | |
| 99 | 108 | /** |
| ... | ... | @@ -164,7 +173,7 @@ public class OrderDetailReportController extends DefaultBaseController { |
| 164 | 173 | vo.setExcludeInventoryUnlocked(Boolean.TRUE); |
| 165 | 174 | vo.setInventoryUnlockedOnly(null); |
| 166 | 175 | vo.setExportType(ExportType.STOCK_IN_ORDER_DETAIL_REPORT.getCode()); |
| 167 | - ExportTaskUtil.exportTask("入库订单明细报表", StockInOrderDetailReportExportTaskWorker.class, vo); | |
| 176 | + ExportTaskUtil.exportTask("入库订单明细报表", StockInboundOrderDetailReportExportTaskWorker.class, vo); | |
| 168 | 177 | return InvokeResultBuilder.success(); |
| 169 | 178 | } |
| 170 | 179 | ... | ... |
| 1 | +package com.lframework.xingyun.sc.excel.statistics; | |
| 2 | + | |
| 3 | +import com.lframework.starter.common.utils.CollectionUtil; | |
| 4 | +import com.lframework.starter.mq.core.components.export.ExportTaskWorker; | |
| 5 | +import com.lframework.starter.web.core.components.resp.PageResult; | |
| 6 | +import com.lframework.starter.web.core.utils.ApplicationUtil; | |
| 7 | +import com.lframework.starter.web.core.utils.JsonUtil; | |
| 8 | +import com.lframework.starter.web.core.utils.PageResultUtil; | |
| 9 | +import com.lframework.xingyun.sc.bo.statistics.orderDetail.QueryOrderDetailReportBo; | |
| 10 | +import com.lframework.xingyun.sc.entity.OrderDetailReport; | |
| 11 | +import com.lframework.xingyun.sc.service.statistics.OrderDetailReportService; | |
| 12 | +import com.lframework.xingyun.sc.utils.CommonUtil; | |
| 13 | +import com.lframework.xingyun.sc.vo.statistics.orderDetail.QueryOrderDetailReportVo; | |
| 14 | +import org.apache.commons.lang3.StringUtils; | |
| 15 | + | |
| 16 | +import java.math.BigDecimal; | |
| 17 | +import java.time.LocalDate; | |
| 18 | +import java.time.ZoneId; | |
| 19 | +import java.util.List; | |
| 20 | +import java.util.Date; | |
| 21 | +import java.util.stream.Collectors; | |
| 22 | + | |
| 23 | +public class StockInboundOrderDetailReportExportTaskWorker implements | |
| 24 | + ExportTaskWorker<QueryOrderDetailReportVo, QueryOrderDetailReportBo, StockInboundOrderDetailReportModel> { | |
| 25 | + | |
| 26 | + @Override | |
| 27 | + public QueryOrderDetailReportVo parseParams(String json) { | |
| 28 | + return JsonUtil.parseObject(json, QueryOrderDetailReportVo.class); | |
| 29 | + } | |
| 30 | + | |
| 31 | + @Override | |
| 32 | + public PageResult<QueryOrderDetailReportBo> getDataList(int pageIndex, int pageSize, QueryOrderDetailReportVo params) { | |
| 33 | + OrderDetailReportService orderDetailReportService = ApplicationUtil.getBean(OrderDetailReportService.class); | |
| 34 | + PageResult<OrderDetailReport> pageResult = orderDetailReportService.query(pageIndex, pageSize, params); | |
| 35 | + List<QueryOrderDetailReportBo> results = null; | |
| 36 | + if (!CollectionUtil.isEmpty(pageResult.getDatas())) { | |
| 37 | + results = pageResult.getDatas().stream().map(QueryOrderDetailReportBo::new).collect(Collectors.toList()); | |
| 38 | + } | |
| 39 | + return PageResultUtil.rebuild(pageResult, results); | |
| 40 | + } | |
| 41 | + | |
| 42 | + @Override | |
| 43 | + public StockInboundOrderDetailReportModel exportData(QueryOrderDetailReportBo data) { | |
| 44 | + String thicknessTol = CommonUtil.handleTolData( | |
| 45 | + data.getThicknessTolPos() != null ? data.getThicknessTolPos().doubleValue() : null, | |
| 46 | + data.getThicknessTolNeg() != null ? data.getThicknessTolNeg().doubleValue() : null); | |
| 47 | + String widthTol = CommonUtil.handleTolData( | |
| 48 | + data.getWidthTolPos() != null ? data.getWidthTolPos().doubleValue() : null, | |
| 49 | + data.getWidthTolNeg() != null ? data.getWidthTolNeg().doubleValue() : null); | |
| 50 | + String lengthTol = CommonUtil.handleTolData( | |
| 51 | + data.getLengthTolPos() != null ? data.getLengthTolPos().doubleValue() : null, | |
| 52 | + data.getLengthTolNeg() != null ? data.getLengthTolNeg().doubleValue() : null); | |
| 53 | + | |
| 54 | + StockInboundOrderDetailReportModel model = new StockInboundOrderDetailReportModel(); | |
| 55 | + model.setDate(toDate(data.getOrderDate())); | |
| 56 | + model.setOrderNo(data.getOrderNo()); | |
| 57 | + model.setDeptCode(data.getDeptCode()); | |
| 58 | + model.setCustomerShortName(data.getCustomerShortName()); | |
| 59 | + model.setOrderDate(toDate(data.getOrderDate())); | |
| 60 | + model.setWorkshopName(data.getWorkshopName()); | |
| 61 | + model.setDeptName(data.getDeptName()); | |
| 62 | + model.setRegionName(data.getRegionName()); | |
| 63 | + model.setCustomerName(data.getOrderingUnitName()); | |
| 64 | + model.setIndustry(data.getIndustry()); | |
| 65 | + model.setStructureReportUsed(data.getStructureReportUsed()); | |
| 66 | + model.setBrand(data.getBrand()); | |
| 67 | + model.setThickness(data.getThickness()); | |
| 68 | + model.setThicknessTol(thicknessTol); | |
| 69 | + model.setWidth(data.getWidth()); | |
| 70 | + model.setWidthTol(widthTol); | |
| 71 | + model.setLength(data.getLength()); | |
| 72 | + model.setLengthTol(lengthTol); | |
| 73 | + model.setStatus(data.getStatus()); | |
| 74 | + model.setQuantity(data.getQuantity()); | |
| 75 | + model.setSuggestedPrice(toBigDecimalOrZero(data.getSuggestedPrice())); | |
| 76 | + model.setDeliveryDate(toDate(data.getDeliveryDate())); | |
| 77 | + model.setAssessmentExceedsAgreement(toBigDecimalOrZero(data.getAssessmentExceedsAgreement())); | |
| 78 | + model.setExecutionStandard(data.getExecutionStandard()); | |
| 79 | + model.setSalesPrice(toBigDecimalOrZero(data.getSalesPrice())); | |
| 80 | + model.setPriceListNo(data.getPriceListNo()); | |
| 81 | + model.setPackagingFee(stringToBigDecimal(data.getPackagingFee())); | |
| 82 | + model.setSettlementTerms(data.getSettlementTerms()); | |
| 83 | + model.setPieceWeightHeader(data.getPieceWeightHeader()); | |
| 84 | + model.setSurface(data.getSurface()); | |
| 85 | + model.setTolerance(data.getTolerance()); | |
| 86 | + model.setPerformance(data.getPerformance()); | |
| 87 | + model.setPackaging(data.getPackaging()); | |
| 88 | + model.setSpecialRequirements(data.getSpecialRequirements()); | |
| 89 | + model.setRemarks(data.getRemarks()); | |
| 90 | + model.setSalesman(data.getContractCreateBy()); | |
| 91 | + model.setShippingCost(stringToBigDecimal(data.getShippingCost())); | |
| 92 | + model.setReturnShippingCost(stringToBigDecimal(data.getReturnShippingCost())); | |
| 93 | + model.setCustomerType(data.getCustomerType()); | |
| 94 | + model.setQuality(data.getQuality()); | |
| 95 | + model.setProcessingAndDistributor(data.getContractType()); | |
| 96 | + model.setActualCustomer(data.getOrderingUnitName()); | |
| 97 | + model.setOrderType(data.getContractTypeName()); | |
| 98 | + model.setLeadCadmiumPpm("Pb≤ppm\n" + "Cd≤ppm"); | |
| 99 | + model.setIronConductivity("Fe≤ppm\n" + "Co+Ni≤ppm\n" + "%IACS"); | |
| 100 | + model.setReserve3(data.getOrderNo()); | |
| 101 | + model.setReserve4(data.getOrderNo()); | |
| 102 | + return model; | |
| 103 | + } | |
| 104 | + | |
| 105 | + @Override | |
| 106 | + public Class<StockInboundOrderDetailReportModel> getModelClass() { | |
| 107 | + return StockInboundOrderDetailReportModel.class; | |
| 108 | + } | |
| 109 | + | |
| 110 | + private static Date toDate(LocalDate date) { | |
| 111 | + if (date == null) { | |
| 112 | + return null; | |
| 113 | + } | |
| 114 | + return Date.from(date.atStartOfDay(ZoneId.systemDefault()).toInstant()); | |
| 115 | + } | |
| 116 | + | |
| 117 | + private static BigDecimal toBigDecimalOrZero(String value) { | |
| 118 | + if (StringUtils.isBlank(value)) { | |
| 119 | + return BigDecimal.ZERO; | |
| 120 | + } | |
| 121 | + try { | |
| 122 | + return new BigDecimal(value.trim()); | |
| 123 | + } catch (Exception e) { | |
| 124 | + return BigDecimal.ZERO; | |
| 125 | + } | |
| 126 | + } | |
| 127 | + | |
| 128 | + public static BigDecimal stringToBigDecimal(String str) { | |
| 129 | + // 1. 判空处理:如果为 null 或去除空格后为空字符串,直接返回 null | |
| 130 | + if (str == null || str.trim().isEmpty()) { | |
| 131 | + return null; | |
| 132 | + } | |
| 133 | + | |
| 134 | + // 2. 尝试转换 | |
| 135 | + try { | |
| 136 | + // 建议先 trim() 去除首尾空格,避免 " 100 " 这种格式报错 | |
| 137 | + return new BigDecimal(str.trim()); | |
| 138 | + } catch (NumberFormatException e) { | |
| 139 | + // 3. 如果字符串格式不合法(如 "abc"),根据业务需求处理,这里同样返回 null | |
| 140 | + return null; | |
| 141 | + } | |
| 142 | + } | |
| 143 | + | |
| 144 | +} | |
| 145 | + | ... | ... |
| 1 | +package com.lframework.xingyun.sc.excel.statistics; | |
| 2 | + | |
| 3 | +import com.alibaba.excel.annotation.ExcelProperty; | |
| 4 | +import com.alibaba.excel.annotation.format.DateTimeFormat; | |
| 5 | +import com.lframework.starter.web.core.components.excel.ExcelModel; | |
| 6 | +import lombok.Data; | |
| 7 | + | |
| 8 | +import java.math.BigDecimal; | |
| 9 | +import java.util.Date; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * 入库订单明细 | |
| 13 | + */ | |
| 14 | +@Data | |
| 15 | +public class StockInboundOrderDetailReportModel implements ExcelModel { | |
| 16 | + | |
| 17 | + @ExcelProperty(value = "日期", index = 0) | |
| 18 | + @DateTimeFormat("yyyy-MM-dd") | |
| 19 | + private Date date; | |
| 20 | + | |
| 21 | + @ExcelProperty(value = "订单编号", index = 1) | |
| 22 | + private String orderNo; | |
| 23 | + | |
| 24 | + @ExcelProperty(value = "办事处编码", index = 2) | |
| 25 | + private String deptCode; | |
| 26 | + | |
| 27 | + @ExcelProperty(value = "客户简称", index = 3) | |
| 28 | + private String customerShortName; | |
| 29 | + | |
| 30 | + @ExcelProperty(value = "订货日期", index = 4) | |
| 31 | + @DateTimeFormat("yyyy-MM-dd") | |
| 32 | + private Date orderDate; | |
| 33 | + | |
| 34 | + @ExcelProperty(value = "生产厂", index = 5) | |
| 35 | + private String workshopName; | |
| 36 | + | |
| 37 | + @ExcelProperty(value = "科办", index = 6) | |
| 38 | + private String deptName; | |
| 39 | + | |
| 40 | + @ExcelProperty(value = "片", index = 7) | |
| 41 | + private String regionName; | |
| 42 | + | |
| 43 | + @ExcelProperty(value = "客户名称", index = 8) | |
| 44 | + private String customerName; | |
| 45 | + | |
| 46 | + @ExcelProperty(value = "行业(用途)", index = 9) | |
| 47 | + private String industry; | |
| 48 | + | |
| 49 | + @ExcelProperty(value = "结构报表用", index = 10) | |
| 50 | + private String structureReportUsed; | |
| 51 | + | |
| 52 | + @ExcelProperty(value = "牌号", index = 11) | |
| 53 | + private String brand; | |
| 54 | + | |
| 55 | + @ExcelProperty(value = "厚", index = 12) | |
| 56 | + private BigDecimal thickness; | |
| 57 | + | |
| 58 | + @ExcelProperty(value = "误差", index = 13) | |
| 59 | + private String thicknessTol; | |
| 60 | + | |
| 61 | + @ExcelProperty(value = "宽", index = 14) | |
| 62 | + private BigDecimal width; | |
| 63 | + | |
| 64 | + @ExcelProperty(value = "误差", index = 15) | |
| 65 | + private String widthTol; | |
| 66 | + | |
| 67 | + @ExcelProperty(value = "长", index = 16) | |
| 68 | + private BigDecimal length; | |
| 69 | + | |
| 70 | + @ExcelProperty(value = "误差", index = 17) | |
| 71 | + private String lengthTol; | |
| 72 | + | |
| 73 | + @ExcelProperty(value = "状态", index = 18) | |
| 74 | + private String status; | |
| 75 | + | |
| 76 | + @ExcelProperty(value = "订单数量", index = 19) | |
| 77 | + private BigDecimal quantity; | |
| 78 | + | |
| 79 | + @ExcelProperty(value = "指导价", index = 20) | |
| 80 | + private BigDecimal suggestedPrice; | |
| 81 | + | |
| 82 | + @ExcelProperty(value = "交货日期", index = 21) | |
| 83 | + @DateTimeFormat("yyyy-MM-dd") | |
| 84 | + private Date deliveryDate; | |
| 85 | + | |
| 86 | + @ExcelProperty(value = "超价协调价", index = 22) | |
| 87 | + private BigDecimal assessmentExceedsAgreement; | |
| 88 | + | |
| 89 | + @ExcelProperty(value = "执行标准", index = 23) | |
| 90 | + private String executionStandard; | |
| 91 | + | |
| 92 | + @ExcelProperty(value = "销售价", index = 24) | |
| 93 | + private BigDecimal salesPrice; | |
| 94 | + | |
| 95 | + @ExcelProperty(value = "价格表编号", index = 25) | |
| 96 | + private String priceListNo; | |
| 97 | + | |
| 98 | + @ExcelProperty(value = "包装费", index = 26) | |
| 99 | + private BigDecimal packagingFee; | |
| 100 | + | |
| 101 | + @ExcelProperty(value = "结算方式", index = 27) | |
| 102 | + private String settlementTerms; | |
| 103 | + | |
| 104 | + @ExcelProperty(value = "件重条头", index = 28) | |
| 105 | + private String pieceWeightHeader; | |
| 106 | + | |
| 107 | + @ExcelProperty(value = "表面", index = 29) | |
| 108 | + private String surface; | |
| 109 | + | |
| 110 | + @ExcelProperty(value = "公差", index = 30) | |
| 111 | + private String tolerance; | |
| 112 | + | |
| 113 | + @ExcelProperty(value = "性能", index = 31) | |
| 114 | + private String performance; | |
| 115 | + | |
| 116 | + @ExcelProperty(value = "包装", index = 32) | |
| 117 | + private String packaging; | |
| 118 | + | |
| 119 | + @ExcelProperty(value = "特别注重要求", index = 33) | |
| 120 | + private String specialRequirements; | |
| 121 | + | |
| 122 | + @ExcelProperty(value = "备注", index = 34) | |
| 123 | + private String remarks; | |
| 124 | + | |
| 125 | + @ExcelProperty(value = "业务员", index = 35) | |
| 126 | + private String salesman; | |
| 127 | + | |
| 128 | + @ExcelProperty(value = "运费", index = 36) | |
| 129 | + private BigDecimal shippingCost; | |
| 130 | + | |
| 131 | + @ExcelProperty(value = "回程运费", index = 37) | |
| 132 | + private BigDecimal returnShippingCost; | |
| 133 | + | |
| 134 | + @ExcelProperty(value = "客户类型", index = 38) | |
| 135 | + private String customerType; | |
| 136 | + | |
| 137 | + @ExcelProperty(value = "品质", index = 39) | |
| 138 | + private String quality; | |
| 139 | + | |
| 140 | + @ExcelProperty(value = "加工双经销", index = 40) | |
| 141 | + private String processingAndDistributor; | |
| 142 | + | |
| 143 | + @ExcelProperty(value = "实际客户", index = 41) | |
| 144 | + private String actualCustomer; | |
| 145 | + | |
| 146 | + @ExcelProperty(value = "订单类型", index = 42) | |
| 147 | + private String orderType; | |
| 148 | + | |
| 149 | + @ExcelProperty(value = "铅、镉含量ppm", index = 43) | |
| 150 | + private String leadCadmiumPpm; | |
| 151 | + | |
| 152 | + @ExcelProperty(value = "铁含量导电率%IACS", index = 44) | |
| 153 | + private String ironConductivity; | |
| 154 | + | |
| 155 | + @ExcelProperty(value = "备用", index = 45) | |
| 156 | + private String reserve1; | |
| 157 | + | |
| 158 | + @ExcelProperty(value = "加工来料", index = 46) | |
| 159 | + private String processingIncomingMaterial; | |
| 160 | + | |
| 161 | + @ExcelProperty(value = "加工料补价代购锌锭", index = 47) | |
| 162 | + private String processingExtraPriceOrPurchaseZinc; | |
| 163 | + | |
| 164 | + @ExcelProperty(value = "备用", index = 48) | |
| 165 | + private String reserve2; | |
| 166 | + | |
| 167 | + @ExcelProperty(value = "原库存订单号", index = 49) | |
| 168 | + private String reserve3; | |
| 169 | + | |
| 170 | + @ExcelProperty(value = "备用", index = 50) | |
| 171 | + private String reserve4; | |
| 172 | +} | |
| 173 | + | ... | ... |
| ... | ... | @@ -288,18 +288,17 @@ |
| 288 | 288 | AND (c.price_spec_locked = 0 OR c.price_spec_locked IS NULL) |
| 289 | 289 | </if> |
| 290 | 290 | <if test="vo.excludeInventoryUnlocked != null and vo.excludeInventoryUnlocked"> |
| 291 | - -- 没关联上合同表的数据(集合C),直接保留 | |
| 292 | - c.id IS NULL | |
| 291 | + AND (c.id IS NULL | |
| 293 | 292 | OR |
| 294 | - -- 关联上了,但不满足那4个特定条件的数据(集合B),保留 | |
| 295 | 293 | NOT( |
| 296 | - c.type IN ('DIST_STOCK_CONTRACT', 'INTL_INVENTORY_AGMT') | |
| 297 | - AND c.status = 'FORMAL' | |
| 298 | - AND poi.type = 'PRODUCTION' | |
| 299 | - AND ( | |
| 300 | - c.price_spec_locked = 0 | |
| 301 | - OR c.price_spec_locked IS NULL | |
| 302 | - ) | |
| 294 | + c.type IN ('DIST_STOCK_CONTRACT', 'INTL_INVENTORY_AGMT') | |
| 295 | + AND c.status = 'FORMAL' | |
| 296 | + AND poi.type = 'PRODUCTION' | |
| 297 | + AND ( | |
| 298 | + c.price_spec_locked = 0 | |
| 299 | + OR c.price_spec_locked IS NULL | |
| 300 | + ) | |
| 301 | + ) | |
| 303 | 302 | ) |
| 304 | 303 | </if> |
| 305 | 304 | </where> | ... | ... |