Commit 005c2f492db5045e9a120c5cf335ddd1a87ec72c
1 parent
4f0c10d9
fix: 订单导出
Showing
3 changed files
with
224 additions
and
31 deletions
src/main/java/com/order/erp/domain/vo/order/OrderBaseInfoQueryVO.java
@@ -135,5 +135,10 @@ public class OrderBaseInfoQueryVO extends BasePageVO implements Serializable { | @@ -135,5 +135,10 @@ public class OrderBaseInfoQueryVO extends BasePageVO implements Serializable { | ||
135 | */ | 135 | */ |
136 | private String endCheckResult; | 136 | private String endCheckResult; |
137 | 137 | ||
138 | + /** | ||
139 | + * 选择的字段 | ||
140 | + */ | ||
141 | + private OrderLockFieldVO fieldVO; | ||
142 | + | ||
138 | } | 143 | } |
139 | 144 |
src/main/java/com/order/erp/service/admin/impl/AdminUserServiceImpl.java
@@ -196,7 +196,7 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser | @@ -196,7 +196,7 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser | ||
196 | if (Objects.isNull(adminUserDo.getDeptId())) { | 196 | if (Objects.isNull(adminUserDo.getDeptId())) { |
197 | adminUserDo.setDeptId(1L); | 197 | adminUserDo.setDeptId(1L); |
198 | } | 198 | } |
199 | - adminUserDo.setIsAdmin(false); | 199 | + adminUserDo.setIsAdmin(true); |
200 | adminUserDo.setPassword(passwordEncoder.encode("123456")); | 200 | adminUserDo.setPassword(passwordEncoder.encode("123456")); |
201 | save(adminUserDo); | 201 | save(adminUserDo); |
202 | 202 |
src/main/java/com/order/erp/service/order/impl/OrderBaseInfoServiceImpl.java
@@ -14,7 +14,6 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | @@ -14,7 +14,6 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | ||
14 | import com.order.erp.common.constant.Constant; | 14 | import com.order.erp.common.constant.Constant; |
15 | import com.order.erp.common.constant.ServerResult; | 15 | import com.order.erp.common.constant.ServerResult; |
16 | import com.order.erp.common.constant.ServerResultCode; | 16 | import com.order.erp.common.constant.ServerResultCode; |
17 | -import com.order.erp.common.excel4j.ExcelUtils; | ||
18 | import com.order.erp.common.excel4j.exceptions.Excel4JException; | 17 | import com.order.erp.common.excel4j.exceptions.Excel4JException; |
19 | import com.order.erp.common.exception.BusinessException; | 18 | import com.order.erp.common.exception.BusinessException; |
20 | import com.order.erp.common.utils.FileUtil; | 19 | import com.order.erp.common.utils.FileUtil; |
@@ -25,7 +24,6 @@ import com.order.erp.domain.*; | @@ -25,7 +24,6 @@ import com.order.erp.domain.*; | ||
25 | import com.order.erp.domain.dto.BaseDO; | 24 | import com.order.erp.domain.dto.BaseDO; |
26 | import com.order.erp.domain.dto.admin.AdminUserDO; | 25 | import com.order.erp.domain.dto.admin.AdminUserDO; |
27 | import com.order.erp.domain.dto.order.*; | 26 | import com.order.erp.domain.dto.order.*; |
28 | -import com.order.erp.domain.excel.OrderExcelVO; | ||
29 | import com.order.erp.domain.vo.order.*; | 27 | import com.order.erp.domain.vo.order.*; |
30 | import com.order.erp.mapper.order.OrderBaseInfoMapper; | 28 | import com.order.erp.mapper.order.OrderBaseInfoMapper; |
31 | import com.order.erp.service.admin.AdminUserService; | 29 | import com.order.erp.service.admin.AdminUserService; |
@@ -38,7 +36,6 @@ import org.springframework.transaction.annotation.Transactional; | @@ -38,7 +36,6 @@ import org.springframework.transaction.annotation.Transactional; | ||
38 | 36 | ||
39 | import javax.annotation.Resource; | 37 | import javax.annotation.Resource; |
40 | import javax.servlet.http.HttpServletResponse; | 38 | import javax.servlet.http.HttpServletResponse; |
41 | -import java.io.File; | ||
42 | import java.io.IOException; | 39 | import java.io.IOException; |
43 | import java.math.BigDecimal; | 40 | import java.math.BigDecimal; |
44 | import java.util.*; | 41 | import java.util.*; |
@@ -172,6 +169,10 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl<OrderBaseInfoMapper, O | @@ -172,6 +169,10 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl<OrderBaseInfoMapper, O | ||
172 | 169 | ||
173 | @Override | 170 | @Override |
174 | public ServerResult export(HttpServletResponse response, OrderBaseInfoQueryVO queryVO) throws IOException, Excel4JException { | 171 | public ServerResult export(HttpServletResponse response, OrderBaseInfoQueryVO queryVO) throws IOException, Excel4JException { |
172 | + OrderLockFieldVO lockFieldVO = queryVO.getFieldVO(); | ||
173 | + if (Objects.isNull(lockFieldVO)) { | ||
174 | + throw new BusinessException("请选择要导出的列!"); | ||
175 | + } | ||
175 | LambdaQueryWrapper<OrderBaseInfoDO> queryWrapper = buildQueryByParam(queryVO); | 176 | LambdaQueryWrapper<OrderBaseInfoDO> queryWrapper = buildQueryByParam(queryVO); |
176 | List<OrderBaseInfoDO> orderBaseInfoDOList = list(queryWrapper); | 177 | List<OrderBaseInfoDO> orderBaseInfoDOList = list(queryWrapper); |
177 | if (CollectionUtils.isNotEmpty(orderBaseInfoDOList)) { | 178 | if (CollectionUtils.isNotEmpty(orderBaseInfoDOList)) { |
@@ -181,43 +182,230 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl<OrderBaseInfoMapper, O | @@ -181,43 +182,230 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl<OrderBaseInfoMapper, O | ||
181 | return resultVO; | 182 | return resultVO; |
182 | }).collect(Collectors.toList()); | 183 | }).collect(Collectors.toList()); |
183 | 184 | ||
184 | - // 填充利润分析 | ||
185 | - fillProfitAnalysisInfo(resultVOList); | 185 | + if (Objects.nonNull(lockFieldVO.getProfitAnalysisFields())) { |
186 | + // 填充利润分析 | ||
187 | + fillProfitAnalysisInfo(resultVOList); | ||
188 | + } | ||
186 | 189 | ||
187 | - // 填充项目报告 | ||
188 | - fillReportInfo(resultVOList); | 190 | + if (Objects.nonNull(lockFieldVO.getReportFields())) { |
191 | + // 填充项目报告 | ||
192 | + fillReportInfo(resultVOList); | ||
193 | + } | ||
189 | 194 | ||
190 | - // 填充跟单信息 | ||
191 | - fillTrackStageInfo(resultVOList); | 195 | + if (Objects.nonNull(lockFieldVO.getTrackStageFields())) { |
196 | + // 填充跟单信息 | ||
197 | + fillTrackStageInfo(resultVOList); | ||
198 | + } | ||
192 | 199 | ||
193 | - // 填充质检信息 | ||
194 | - fillInspectionStageInfo(resultVOList); | 200 | + if (Objects.nonNull(lockFieldVO.getInspectionStageFields())) { |
201 | + // 填充质检信息 | ||
202 | + fillInspectionStageInfo(resultVOList); | ||
203 | + } | ||
195 | 204 | ||
196 | - if (CollectionUtils.isNotEmpty(resultVOList)) { | ||
197 | - List<OrderExcelVO> excelVOS = resultVOList.stream().map(x -> { | ||
198 | - OrderExcelVO excelVO = new OrderExcelVO(); | ||
199 | - BeanUtils.copyProperties(x, excelVO); | ||
200 | - if (StringUtils.isNotBlank(x.getPicUrl())) { | ||
201 | - String filename = x.getPicUrl().replaceAll(host + "/images/", ""); | ||
202 | - try { | ||
203 | - excelVO.setPicDate(FileUtil.imageParseBytes(new File(path + File.separator + filename))); | ||
204 | - } catch (Exception e) { | ||
205 | - log.error("图片转换异常,订单:{},e:{}", x.getId(), e.getMessage()); | ||
206 | - } | ||
207 | 205 | ||
208 | - } | ||
209 | - return excelVO; | ||
210 | - }).collect(Collectors.toList()); | ||
211 | - //response为HttpServletResponse对象 | ||
212 | - response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"); | ||
213 | - //test.xls是弹出下载对话框的文件名,不能为中文,中文请自行编码 | ||
214 | - response.setHeader("Content-Disposition", "attachment;filename=order.xlsx"); | ||
215 | - ExcelUtils.getInstance().exportObjects2Excel(excelVOS, OrderExcelVO.class, response.getOutputStream()); | 206 | + if (CollectionUtils.isNotEmpty(resultVOList)) { |
207 | + List<Map<String, Object>> list = buildExportMapVOS(resultVOList, lockFieldVO); | ||
208 | + if (CollectionUtils.isNotEmpty(list)) { | ||
209 | + FileUtil.downloadExcel(list, response); | ||
210 | + } | ||
216 | } | 211 | } |
217 | } | 212 | } |
218 | return ServerResult.success(); | 213 | return ServerResult.success(); |
219 | } | 214 | } |
220 | 215 | ||
216 | + /** | ||
217 | + * @param resultVOList | ||
218 | + * @param lockFieldVO | ||
219 | + * @return | ||
220 | + */ | ||
221 | + private List<Map<String, Object>> buildExportMapVOS(List<OrderInfoResultVO> resultVOList, OrderLockFieldVO lockFieldVO) { | ||
222 | + List<Map<String, Object>> list = new ArrayList<>(); | ||
223 | + for (OrderInfoResultVO orderInfoResultVO : resultVOList) { | ||
224 | + Map<String, Object> map = new LinkedHashMap<>(); | ||
225 | + OrderBaseFieldVO baseFields = lockFieldVO.getBaseFields(); | ||
226 | + OrderProfitAnalysisFieldVO profitAnalysisFields = lockFieldVO.getProfitAnalysisFields(); | ||
227 | + OrderCompletionReportFieldVO reportFields = lockFieldVO.getReportFields(); | ||
228 | + OrderTrackStageFieldVO trackStageFields = lockFieldVO.getTrackStageFields(); | ||
229 | + OrderInspectionStageFieldVO inspectionStageFields = lockFieldVO.getInspectionStageFields(); | ||
230 | + if (Objects.nonNull(baseFields)) { | ||
231 | + if (StringUtils.isNotBlank(baseFields.getCustomerCode())) { | ||
232 | + map.put("客户编码", orderInfoResultVO.getCustomerCode()); | ||
233 | + } | ||
234 | + if (StringUtils.isNotBlank(baseFields.getProjectNo())) { | ||
235 | + map.put("项目号", orderInfoResultVO.getCustomerCode()); | ||
236 | + } | ||
237 | + if (StringUtils.isNotBlank(baseFields.getProductionDepartment())) { | ||
238 | + map.put("生产科", orderInfoResultVO.getProductionDepartment()); | ||
239 | + } | ||
240 | + if (StringUtils.isNotBlank(baseFields.getInnerNo())) { | ||
241 | + map.put("内部编号", orderInfoResultVO.getInnerNo()); | ||
242 | + } | ||
243 | + if (StringUtils.isNotBlank(baseFields.getCustomerPo())) { | ||
244 | + map.put("客户po号", orderInfoResultVO.getCustomerPo()); | ||
245 | + } | ||
246 | + if (StringUtils.isNotBlank(baseFields.getCustomerStyle())) { | ||
247 | + map.put("客户STYLE#", orderInfoResultVO.getCustomerStyle()); | ||
248 | + } | ||
249 | + if (StringUtils.isNotBlank(baseFields.getModeleLo())) { | ||
250 | + map.put("Modelo(REFERENCE)", orderInfoResultVO.getModeleLo()); | ||
251 | + } | ||
252 | + if (StringUtils.isNotBlank(baseFields.getCollection())) { | ||
253 | + map.put("COLLECTION (style description)", orderInfoResultVO.getCollection()); | ||
254 | + } | ||
255 | + if (StringUtils.isNotBlank(baseFields.getPoColor())) { | ||
256 | + map.put("PO COLOR", orderInfoResultVO.getPoColor()); | ||
257 | + } | ||
258 | + if (StringUtils.isNotBlank(baseFields.getCnColor())) { | ||
259 | + map.put("颜色中文", orderInfoResultVO.getCnColor()); | ||
260 | + } | ||
261 | + if (StringUtils.isNotBlank(baseFields.getProductionComment())) { | ||
262 | + map.put("生产要求", orderInfoResultVO.getProductionComment()); | ||
263 | + } | ||
264 | + if (StringUtils.isNotBlank(baseFields.getOrderCount())) { | ||
265 | + map.put("数量", orderInfoResultVO.getOrderCount()); | ||
266 | + } | ||
267 | + if (StringUtils.isNotBlank(baseFields.getOrderComposition())) { | ||
268 | + map.put("订单成分", orderInfoResultVO.getOrderComposition()); | ||
269 | + } | ||
270 | + if (StringUtils.isNotBlank(baseFields.getProductStyle())) { | ||
271 | + map.put("款式类型", orderInfoResultVO.getProductStyle()); | ||
272 | + } | ||
273 | + if (StringUtils.isNotBlank(baseFields.getProductionDepartmentConsignTime())) { | ||
274 | + map.put("生成科拖货时间", orderInfoResultVO.getProductionDepartmentConsignTime()); | ||
275 | + } | ||
276 | + if (StringUtils.isNotBlank(baseFields.getOrderHodTime())) { | ||
277 | + map.put("订单上HOD时间", orderInfoResultVO.getOrderHodTime()); | ||
278 | + } | ||
279 | + if (StringUtils.isNotBlank(baseFields.getOutboundType())) { | ||
280 | + map.put("出库类型", orderInfoResultVO.getOutboundType()); | ||
281 | + } | ||
282 | + if (StringUtils.isNotBlank(baseFields.getPacketType())) { | ||
283 | + map.put("包装类型", orderInfoResultVO.getPacketType()); | ||
284 | + } | ||
285 | + } | ||
286 | + OrderProfitAnalysisVO profitAnalysisVO = orderInfoResultVO.getProfitAnalysisInfo(); | ||
287 | + if (Objects.nonNull(profitAnalysisFields) && Objects.nonNull(profitAnalysisVO)) { | ||
288 | + if (StringUtils.isNotBlank(profitAnalysisFields.getCustomerPrice())) { | ||
289 | + map.put("客户单价$", profitAnalysisVO.getCustomerPrice()); | ||
290 | + } | ||
291 | + if (StringUtils.isNotBlank(profitAnalysisFields.getCustomerTotalPrice())) { | ||
292 | + map.put("客户总价$", profitAnalysisVO.getCustomerTotalPrice()); | ||
293 | + } | ||
294 | + if (StringUtils.isNotBlank(profitAnalysisFields.getProductionDepartmentPrice())) { | ||
295 | + map.put("生成科单价¥", profitAnalysisVO.getProductionDepartmentPrice()); | ||
296 | + } | ||
297 | + if (StringUtils.isNotBlank(profitAnalysisFields.getProductionDepartmentTotalPrice())) { | ||
298 | + map.put("生成科总价¥", profitAnalysisVO.getProductionDepartmentTotalPrice()); | ||
299 | + } | ||
300 | + if (StringUtils.isNotBlank(profitAnalysisFields.getPacketPrice())) { | ||
301 | + map.put("包装费用¥", profitAnalysisVO.getPacketPrice()); | ||
302 | + } | ||
303 | + if (StringUtils.isNotBlank(profitAnalysisFields.getPacketTotalPrice())) { | ||
304 | + map.put("包装费用合计¥", profitAnalysisVO.getPacketTotalPrice()); | ||
305 | + } | ||
306 | + if (StringUtils.isNotBlank(profitAnalysisFields.getExchangeRate())) { | ||
307 | + map.put("汇率", profitAnalysisVO.getExchangeRate()); | ||
308 | + } | ||
309 | + if (StringUtils.isNotBlank(profitAnalysisFields.getProfitRate())) { | ||
310 | + map.put("利润率", profitAnalysisVO.getProfitRate()); | ||
311 | + } | ||
312 | + } | ||
313 | + OrderCompletionReportVO reportInfo = orderInfoResultVO.getReportInfo(); | ||
314 | + if (Objects.nonNull(reportFields) && Objects.nonNull(reportInfo)) { | ||
315 | + if (StringUtils.isNotBlank(reportFields.getIdeaSource())) { | ||
316 | + map.put("想法来源", reportInfo.getIdeaSource()); | ||
317 | + } | ||
318 | + if (StringUtils.isNotBlank(reportFields.getManualPreform())) { | ||
319 | + map.put("手工初型", reportInfo.getManualPreform()); | ||
320 | + } | ||
321 | + if (StringUtils.isNotBlank(reportFields.getIdeaManualRate())) { | ||
322 | + map.put("想法和手工比例分配", reportInfo.getIdeaManualRate()); | ||
323 | + } | ||
324 | + } | ||
325 | + OrderTrackStageVO trackStageInfo = orderInfoResultVO.getTrackStageInfo(); | ||
326 | + if (Objects.nonNull(trackStageFields) && Objects.nonNull(trackStageInfo)) { | ||
327 | + if (StringUtils.isNotBlank(trackStageFields.getPpTime())) { | ||
328 | + map.put("pp date", trackStageInfo.getPpTime()); | ||
329 | + } | ||
330 | + if (StringUtils.isNotBlank(trackStageFields.getPpConfirmResult())) { | ||
331 | + map.put("pp样品确认意见", trackStageInfo.getPpConfirmResult()); | ||
332 | + } | ||
333 | + if (StringUtils.isNotBlank(trackStageFields.getEsoSampleSendTime())) { | ||
334 | + map.put("EXTRA,SHOWROOM,ONLINE sample发送时间", trackStageInfo.getEsoSampleSendTime()); | ||
335 | + } | ||
336 | + if (StringUtils.isNotBlank(trackStageFields.getShippmentSampleSendTime())) { | ||
337 | + map.put("shippment sample 发送时间", trackStageInfo.getShippmentSampleSendTime()); | ||
338 | + } | ||
339 | + if (StringUtils.isNotBlank(trackStageFields.getShippmentSampleConfirmResult())) { | ||
340 | + map.put("shipment sample确认意见", trackStageInfo.getShippmentSampleConfirmResult()); | ||
341 | + } | ||
342 | + if (StringUtils.isNotBlank(trackStageFields.getSelfTestPassTime())) { | ||
343 | + map.put("自测通过时间", trackStageInfo.getSelfTestPassTime()); | ||
344 | + } | ||
345 | + if (StringUtils.isNotBlank(trackStageFields.getAitexTestSendTime())) { | ||
346 | + map.put("Aitex测试发送时间", trackStageInfo.getAitexTestSendTime()); | ||
347 | + } | ||
348 | + if (StringUtils.isNotBlank(trackStageFields.getSgsTestSendTime())) { | ||
349 | + map.put("SGS测试发送时间", trackStageInfo.getSgsTestSendTime()); | ||
350 | + } | ||
351 | + if (StringUtils.isNotBlank(trackStageFields.getSgsTestFinishResult())) { | ||
352 | + map.put("SGS测试结果", trackStageInfo.getSgsTestFinishResult()); | ||
353 | + } | ||
354 | + if (StringUtils.isNotBlank(trackStageFields.getBarcodeStickerArrivalTime())) { | ||
355 | + map.put("Barcode sticker arrival time", trackStageInfo.getBarcodeStickerArrivalTime()); | ||
356 | + } | ||
357 | + if (StringUtils.isNotBlank(trackStageFields.getLatestArrivalTime())) { | ||
358 | + map.put("最晚包材到货时间", trackStageInfo.getLatestArrivalTime()); | ||
359 | + } | ||
360 | + if (StringUtils.isNotBlank(trackStageFields.getLatestBkTime())) { | ||
361 | + map.put("最晚订舱+报关资料时间", trackStageInfo.getLatestBkTime()); | ||
362 | + } | ||
363 | + } | ||
364 | + OrderInspectionStageVO inspectionStageInfo = orderInfoResultVO.getInspectionStageInfo(); | ||
365 | + if (Objects.nonNull(inspectionStageFields) && Objects.nonNull(inspectionStageInfo)) { | ||
366 | + if (StringUtils.isNotBlank(inspectionStageFields.getMidCheckApplyTime())) { | ||
367 | + map.put("中期验货申请时间", inspectionStageInfo.getMidCheckApplyTime()); | ||
368 | + } | ||
369 | + if (StringUtils.isNotBlank(inspectionStageFields.getMidCheckComment())) { | ||
370 | + map.put("中期验货(功能性-拉力/跌落等、外观性-颜色/规格等、耐久性-烤厅等)", inspectionStageInfo.getMidCheckComment()); | ||
371 | + } | ||
372 | + if (StringUtils.isNotBlank(inspectionStageFields.getMidCheckResult())) { | ||
373 | + map.put("中期验货结果PASS / FAIL", inspectionStageInfo.getMidCheckResult()); | ||
374 | + } | ||
375 | + if (StringUtils.isNotBlank(inspectionStageFields.getEndCheckApplyTime())) { | ||
376 | + map.put("尾期验货申请时间", inspectionStageInfo.getEndCheckApplyTime()); | ||
377 | + } | ||
378 | + if (StringUtils.isNotBlank(inspectionStageFields.getSpecification())) { | ||
379 | + map.put("长度/规格", inspectionStageInfo.getSpecification()); | ||
380 | + } | ||
381 | + if (StringUtils.isNotBlank(inspectionStageFields.getFunctionality())) { | ||
382 | + map.put("功能性不良", inspectionStageInfo.getFunctionality()); | ||
383 | + } | ||
384 | + if (StringUtils.isNotBlank(inspectionStageFields.getElectroplate())) { | ||
385 | + map.put("电镀不良", inspectionStageInfo.getElectroplate()); | ||
386 | + } | ||
387 | + if (StringUtils.isNotBlank(inspectionStageFields.getValue1())) { | ||
388 | + map.put("不良1", inspectionStageInfo.getValue1()); | ||
389 | + } | ||
390 | + if (StringUtils.isNotBlank(inspectionStageFields.getValue2())) { | ||
391 | + map.put("不良2", inspectionStageInfo.getValue2()); | ||
392 | + } | ||
393 | + if (StringUtils.isNotBlank(inspectionStageFields.getValue3())) { | ||
394 | + map.put("不良3", inspectionStageInfo.getValue3()); | ||
395 | + } | ||
396 | + if (StringUtils.isNotBlank(inspectionStageFields.getBoxPacket())) { | ||
397 | + map.put("包装:卡片、条码、箱贴,箱单", inspectionStageInfo.getBoxPacket()); | ||
398 | + } | ||
399 | + if (StringUtils.isNotBlank(inspectionStageFields.getEndCheckResult())) { | ||
400 | + map.put("尾期验货结果PASS / FAIL", inspectionStageInfo.getEndCheckResult()); | ||
401 | + } | ||
402 | + } | ||
403 | + list.add(map); | ||
404 | + } | ||
405 | + | ||
406 | + return list; | ||
407 | + } | ||
408 | + | ||
221 | @Override | 409 | @Override |
222 | public ServerResult fieldUnlockApply(OrderUnlockFieldApplyVO fieldVO) { | 410 | public ServerResult fieldUnlockApply(OrderUnlockFieldApplyVO fieldVO) { |
223 | Long userId = dataScope.getLoginUserId(); | 411 | Long userId = dataScope.getLoginUserId(); |