Commit 7514592cabf7b9513d3e78f733bbfbb6272238b3

Authored by 房远帅
1 parent 6431f675

采购计划:测试问题修复

... ... @@ -1950,7 +1950,6 @@ CREATE TABLE `procurement_plan`
1950 1950 `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
1951 1951 `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
1952 1952 PRIMARY KEY (`id`),
1953   - UNIQUE KEY `uk_pp_code` (`code`),
1954 1953 KEY `idx_pp_company_short_id` (`company_short_id`),
1955 1954 KEY `idx_pp_supplier_id` (`supplier_id`),
1956 1955 KEY `idx_pp_date` (`date`),
... ... @@ -2018,7 +2017,6 @@ CREATE TABLE `procurement_buyout_apply`
2018 2017 `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
2019 2018 `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
2020 2019 PRIMARY KEY (`id`),
2021   - UNIQUE KEY `uk_pba_code` (`code`),
2022 2020 KEY `idx_pba_plan_id` (`procurement_plan_id`),
2023 2021 KEY `idx_pba_supplier_id` (`supplier_id`),
2024 2022 KEY `idx_pba_date` (`date`),
... ...
... ... @@ -374,13 +374,13 @@ public class ProcurementPlan extends BaseEntity implements BaseDto {
374 374 /**
375 375 * 创建人ID
376 376 */
377   - @TableField(fill = FieldFill.INSERT)
  377 + @TableField(fill = FieldFill.DEFAULT)
378 378 private String createById;
379 379
380 380 /**
381 381 * 创建人
382 382 */
383   - @TableField(fill = FieldFill.INSERT)
  383 + @TableField(fill = FieldFill.DEFAULT)
384 384 private String createBy;
385 385
386 386 /**
... ...
... ... @@ -84,6 +84,7 @@ public class ProcurementPlanReplenishLine extends BaseEntity implements BaseDto
84 84 /**
85 85 * 分厂名称
86 86 */
  87 + @TableField(exist = false)
87 88 private String workshopName;
88 89
89 90 /**
... ...
... ... @@ -455,6 +455,8 @@ public class ProcurementPlanChangeServiceImpl extends
455 455 archivedMain.setId(IdUtil.getId());
456 456 archivedMain.setCode(mainPlan.getCode() + "_HIST");
457 457 archivedMain.setDeleted(Boolean.TRUE);
  458 + archivedMain.setCreateBy(mainPlan.getCreateBy());
  459 + archivedMain.setCreateById(mainPlan.getCreateById());
458 460 procurementPlanService.save(archivedMain);
459 461 // 原主计划子表也复制一份
460 462 List<ProcurementPlanLine> mainLines = procurementPlanLineService.getByProcurementPlanId(planId);
... ... @@ -538,67 +540,70 @@ public class ProcurementPlanChangeServiceImpl extends
538 540 }
539 541 ProcurementPlanChange procurementPlanChange = this.getById(id);
540 542 // 按分厂分组明细
  543 + List<String> allWorkshopIds = new ArrayList<>();
541 544 if (CollectionUtil.isNotEmpty(changeLines)) {
542 545 // workshopId -> workshop code
543   - List<String> allWorkshopIds = changeLines.stream()
  546 + allWorkshopIds = changeLines.stream()
544 547 .map(ProcurementPlanChangeLine::getWorkshopId)
545 548 .filter(StringUtil::isNotBlank)
546 549 .distinct()
547 550 .collect(Collectors.toList());
548 551 Map<String, String> workshop2Code = new HashMap<>();
549   - if (CollectionUtil.isNotEmpty(allWorkshopIds)) {
  552 + if (CollectionUtil.isNotEmpty(allWorkshopIds) && allWorkshopIds.size() > 1) {
550 553 List<Workshop> workshopList = workshopService.listByIds(allWorkshopIds);
551 554 if (CollectionUtil.isNotEmpty(workshopList)) {
552 555 workshop2Code = workshopList.stream()
553 556 .filter(w -> StringUtil.isNotBlank(w.getCode()))
554 557 .collect(Collectors.toMap(Workshop::getId, Workshop::getCode, (v1, v2) -> v1));
555 558 }
556   - }
557   - // 分厂顺序
558   - Map<String, Integer> workOrderMap = new LinkedHashMap<>();
559   - workOrderMap.put("yfc", 1);
560   - workOrderMap.put("efc", 2);
561   - workOrderMap.put("sfc", 3);
562   - workOrderMap.put("ztfc", 4);
563   - Map<String, List<ProcurementPlanChangeLine>> workshopLines = new LinkedHashMap<>();
564   - for (ProcurementPlanChangeLine cl : changeLines) {
565   - String code = workshop2Code.getOrDefault(cl.getWorkshopId(), "");
566   - workshopLines.computeIfAbsent(code, k -> new ArrayList<>()).add(cl);
567   - }
568   - List<Map.Entry<String, List<ProcurementPlanChangeLine>>> sortedEntries = workshopLines.entrySet().stream()
569   - .sorted(Comparator.comparingInt(e -> workOrderMap.getOrDefault(e.getKey(), Integer.MAX_VALUE)))
570   - .collect(Collectors.toList());
571   -
572   - for (Map.Entry<String, List<ProcurementPlanChangeLine>> entry : sortedEntries) {
573   - List<ProcurementPlanChangeLine> wLines = entry.getValue();
574   - if (CollectionUtil.isEmpty(wLines)) {
575   - continue;
  559 + // 分厂顺序
  560 + Map<String, Integer> workOrderMap = new LinkedHashMap<>();
  561 + workOrderMap.put("yfc", 1);
  562 + workOrderMap.put("efc", 2);
  563 + workOrderMap.put("sfc", 3);
  564 + workOrderMap.put("ztfc", 4);
  565 + Map<String, List<ProcurementPlanChangeLine>> workshopLines = new LinkedHashMap<>();
  566 + for (ProcurementPlanChangeLine cl : changeLines) {
  567 + String code = workshop2Code.getOrDefault(cl.getWorkshopId(), "");
  568 + workshopLines.computeIfAbsent(code, k -> new ArrayList<>()).add(cl);
576 569 }
577   - String suffixStr = String.format("%02d", nextSuffix);
578   - String subCode = mainPlan.getCode() + "_" + suffixStr;
579   - nextSuffix++;
580   -
581   - CreateProcurementPlanVo subVo = BeanUtil.copyProperties(entity, CreateProcurementPlanVo.class);
582   - subVo.setCode(subCode);
583   - subVo.setParentId(planId);
584   - subVo.setProcessStatus("COMPLETED");
585   - subVo.setProcessNode(null);
586   - subVo.setWorkshopId(CollectionUtil.isNotEmpty(wLines) ? wLines.get(0).getWorkshopId() : null);
587   - subVo.setPlanType("变");
588   - subVo.setPurchaseDeptName(procurementPlanChange.getPurchaseDeptName());
589   - subVo.setManagementDeptName(procurementPlanChange.getManagementDeptName());
590   - subVo.setSupplyManagerName(procurementPlanChange.getSupplyManagerName());
591   - subVo.setMarketingManagerName(procurementPlanChange.getMarketingManagerName());
592   - subVo.setApprovalPassTime(LocalDateTime.now());
593   -
594   - List<ProcurementPlanLineVo> subLineVos = new ArrayList<>();
595   - for (ProcurementPlanChangeLine cl : wLines) {
596   - ProcurementPlanLineVo lv = BeanUtil.copyProperties(cl, ProcurementPlanLineVo.class);
597   - subLineVos.add(lv);
  570 + List<Map.Entry<String, List<ProcurementPlanChangeLine>>> sortedEntries = workshopLines.entrySet().stream()
  571 + .sorted(Comparator.comparingInt(e -> workOrderMap.getOrDefault(e.getKey(), Integer.MAX_VALUE)))
  572 + .collect(Collectors.toList());
  573 +
  574 + for (Map.Entry<String, List<ProcurementPlanChangeLine>> entry : sortedEntries) {
  575 + List<ProcurementPlanChangeLine> wLines = entry.getValue();
  576 + if (CollectionUtil.isEmpty(wLines)) {
  577 + continue;
  578 + }
  579 + String suffixStr = String.format("%02d", nextSuffix);
  580 + String subCode = mainPlan.getCode() + "_" + suffixStr;
  581 + nextSuffix++;
  582 +
  583 + CreateProcurementPlanVo subVo = BeanUtil.copyProperties(entity, CreateProcurementPlanVo.class);
  584 + subVo.setCode(subCode);
  585 + subVo.setParentId(planId);
  586 + subVo.setProcessStatus("COMPLETED");
  587 + subVo.setProcessNode(null);
  588 + subVo.setWorkshopId(CollectionUtil.isNotEmpty(wLines) ? wLines.get(0).getWorkshopId() : null);
  589 + subVo.setPlanType("变");
  590 + subVo.setPurchaseDeptName(procurementPlanChange.getPurchaseDeptName());
  591 + subVo.setManagementDeptName(procurementPlanChange.getManagementDeptName());
  592 + subVo.setSupplyManagerName(procurementPlanChange.getSupplyManagerName());
  593 + subVo.setMarketingManagerName(procurementPlanChange.getMarketingManagerName());
  594 + subVo.setApprovalPassTime(LocalDateTime.now());
  595 +
  596 + List<ProcurementPlanLineVo> subLineVos = new ArrayList<>();
  597 + for (ProcurementPlanChangeLine cl : wLines) {
  598 + ProcurementPlanLineVo lv = BeanUtil.copyProperties(cl, ProcurementPlanLineVo.class);
  599 + subLineVos.add(lv);
  600 + }
  601 + subVo.setProcurementPlanLineList(subLineVos);
  602 + subVo.setCreateBy(mainPlan.getCreateBy());
  603 + subVo.setCreateById(mainPlan.getCreateById());
  604 + // createSubPlan 内部会保存主表+明细+自动生成买断申请单
  605 + procurementPlanService.createSubPlan(subVo);
598 606 }
599   - subVo.setProcurementPlanLineList(subLineVos);
600   - // createSubPlan 内部会保存主表+明细+自动生成买断申请单
601   - procurementPlanService.createSubPlan(subVo);
602 607 }
603 608 }
604 609
... ... @@ -611,7 +616,7 @@ public class ProcurementPlanChangeServiceImpl extends
611 616 planType = "变 补";
612 617 }
613 618 procurementPlanService.update(Wrappers.lambdaUpdate(ProcurementPlan.class)
614   - .set(ProcurementPlan::getFrozen, Boolean.TRUE)
  619 + .set(ProcurementPlan::getFrozen, allWorkshopIds.size() > 1 ? Boolean.TRUE : Boolean.FALSE)
615 620 .set(ProcurementPlan::getChangeStatus, "CHANGED")
616 621 .set(ProcurementPlan::getProcessStatus, "COMPLETED")
617 622 .set(ProcurementPlan::getProcessNode, null)
... ... @@ -794,10 +799,23 @@ public class ProcurementPlanChangeServiceImpl extends
794 799 if (StringUtil.isBlank(lineVo.getItemId())) {
795 800 lineVo.setItemId(oldLine.getItemId());
796 801 }
797   - ProcurementPlanChangeLine updateLine = BeanUtil.copyProperties(lineVo, ProcurementPlanChangeLine.class);
798   - updateLine.setId(lineVo.getId());
799   - updateLine.setProcurementPlanChangeId(finalChangeId);
800   - procurementPlanChangeLineService.updateById(updateLine);
  802 + log.error("workshopId====" + lineVo.getWorkshopId());
  803 + LambdaUpdateWrapper<ProcurementPlanChangeLine> updateWrapper = new LambdaUpdateWrapper<>(ProcurementPlanChangeLine.class);
  804 + updateWrapper.eq(ProcurementPlanChangeLine::getId, lineVo.getId())
  805 + .set(ProcurementPlanChangeLine::getProcurementPlanChangeId, finalChangeId)
  806 + .set(ProcurementPlanChangeLine::getProductId, lineVo.getProductId())
  807 + .set(ProcurementPlanChangeLine::getMaterialType, lineVo.getMaterialType())
  808 + .set(ProcurementPlanChangeLine::getQuantity, lineVo.getQuantity())
  809 + .set(ProcurementPlanChangeLine::getActualPurchasePrice, lineVo.getActualPurchasePrice())
  810 + .set(ProcurementPlanChangeLine::getIncludingShippingPrice, lineVo.getIncludingShippingPrice())
  811 + .set(ProcurementPlanChangeLine::getPriceListPrices, lineVo.getPriceListPrices())
  812 + .set(ProcurementPlanChangeLine::getCoordinationRange, lineVo.getCoordinationRange())
  813 + .set(ProcurementPlanChangeLine::getEstimatedLoss, lineVo.getEstimatedLoss())
  814 + .set(ProcurementPlanChangeLine::getApplicationAttrition, lineVo.getApplicationAttrition())
  815 + .set(ProcurementPlanChangeLine::getPaintDamageRatio, lineVo.getPaintDamageRatio())
  816 + .set(ProcurementPlanChangeLine::getWorkshopId, lineVo.getWorkshopId())
  817 + .set(ProcurementPlanChangeLine::getItemId, lineVo.getItemId());
  818 + procurementPlanChangeLineService.update(updateWrapper);
801 819 } else {
802 820 ProcurementPlanChangeLine createLine = BeanUtil.copyProperties(lineVo, ProcurementPlanChangeLine.class);
803 821 createLine.setId(IdUtil.getId());
... ...
... ... @@ -34,7 +34,6 @@ import com.lframework.xingyun.sc.bo.procurement.GetProcurementPlanBo;
34 34 import com.lframework.xingyun.sc.enums.CustomerDevelopStatus;
35 35 import com.lframework.xingyun.sc.procurement.dto.DomesticReviewerDto;
36 36 import com.lframework.xingyun.sc.procurement.entity.ProcurementPlan;
37   -import com.lframework.xingyun.sc.procurement.entity.ProcurementPlanChange;
38 37 import com.lframework.xingyun.sc.procurement.entity.ProcurementPlanLine;
39 38 import com.lframework.xingyun.sc.procurement.mappers.plan.ProcurementPlanMapper;
40 39 import com.lframework.xingyun.sc.procurement.service.buyout.ProcurementBuyoutApplyService;
... ... @@ -196,6 +195,12 @@ public class ProcurementPlanServiceImpl extends BaseMpServiceImpl<ProcurementPla
196 195 plan.setPurchaseDeptName(reviewer.getProcurementOffice());
197 196 }
198 197 }
  198 + if (StringUtils.isEmpty(plan.getCreateBy())) {
  199 + plan.setCreateBy(SecurityUtil.getCurrentUser().getName());
  200 + }
  201 + if (StringUtils.isEmpty(plan.getCreateById())) {
  202 + plan.setCreateBy(SecurityUtil.getCurrentUser().getId());
  203 + }
199 204 getBaseMapper().insert(plan);
200 205
201 206 if (!CollectionUtil.isEmpty(vo.getProcurementPlanLineList())) {
... ... @@ -267,9 +272,22 @@ public class ProcurementPlanServiceImpl extends BaseMpServiceImpl<ProcurementPla
267 272 if (StringUtil.isBlank(lineVo.getItemId())) {
268 273 lineVo.setItemId(oldLine.getItemId());
269 274 }
270   - ProcurementPlanLine updateLine = BeanUtil.copyProperties(lineVo, ProcurementPlanLine.class);
271   - updateLine.setId(lineVo.getId());
272   - procurementPlanLineService.updateById(updateLine);
  275 + LambdaUpdateWrapper<ProcurementPlanLine> updateWrapper = new LambdaUpdateWrapper<>(ProcurementPlanLine.class);
  276 + updateWrapper.eq(ProcurementPlanLine::getId, lineVo.getId())
  277 + .set(ProcurementPlanLine::getProcurementPlanId, lineVo.getProcurementPlanId())
  278 + .set(ProcurementPlanLine::getProductId, lineVo.getProductId())
  279 + .set(ProcurementPlanLine::getMaterialType, lineVo.getMaterialType())
  280 + .set(ProcurementPlanLine::getQuantity, lineVo.getQuantity())
  281 + .set(ProcurementPlanLine::getActualPurchasePrice, lineVo.getActualPurchasePrice())
  282 + .set(ProcurementPlanLine::getIncludingShippingPrice, lineVo.getIncludingShippingPrice())
  283 + .set(ProcurementPlanLine::getPriceListPrices, lineVo.getPriceListPrices())
  284 + .set(ProcurementPlanLine::getCoordinationRange, lineVo.getCoordinationRange())
  285 + .set(ProcurementPlanLine::getEstimatedLoss, lineVo.getEstimatedLoss())
  286 + .set(ProcurementPlanLine::getApplicationAttrition, lineVo.getApplicationAttrition())
  287 + .set(ProcurementPlanLine::getPaintDamageRatio, lineVo.getPaintDamageRatio())
  288 + .set(ProcurementPlanLine::getWorkshopId, lineVo.getWorkshopId())
  289 + .set(ProcurementPlanLine::getItemId, lineVo.getItemId());
  290 + procurementPlanLineService.update(updateWrapper);
273 291 } else {
274 292 ProcurementPlanLine createLine = BeanUtil.copyProperties(lineVo, ProcurementPlanLine.class);
275 293 createLine.setId(IdUtil.getId());
... ... @@ -424,7 +442,8 @@ public class ProcurementPlanServiceImpl extends BaseMpServiceImpl<ProcurementPla
424 442 subLineVoList.add(lineVo);
425 443 }
426 444 subVo.setProcurementPlanLineList(subLineVoList);
427   -
  445 + subVo.setCreateBy(mainPlan.getCreateBy());
  446 + subVo.setCreateById(mainPlan.getCreateById());
428 447 // 子计划创建(不重新生成编号,因为使用父code+后缀)
429 448 createSubPlan(subVo);
430 449 }
... ... @@ -674,7 +693,12 @@ public class ProcurementPlanServiceImpl extends BaseMpServiceImpl<ProcurementPla
674 693 }
675 694 }
676 695 plan.setTotalQuantity(totalQuantity);
677   -
  696 + if (StringUtils.isEmpty(plan.getCreateBy())) {
  697 + plan.setCreateBy(SecurityUtil.getCurrentUser().getName());
  698 + }
  699 + if (StringUtils.isEmpty(plan.getCreateById())) {
  700 + plan.setCreateBy(SecurityUtil.getCurrentUser().getId());
  701 + }
678 702 getBaseMapper().insert(plan);
679 703
680 704 if (!CollectionUtil.isEmpty(vo.getProcurementPlanLineList())) {
... ...
... ... @@ -5,7 +5,11 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper;
5 5 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
6 6 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
7 7 import com.github.pagehelper.PageInfo;
  8 +import com.lframework.starter.bpm.dto.FlowTaskDto;
  9 +import com.lframework.starter.bpm.entity.FlowInstanceWrapper;
  10 +import com.lframework.starter.bpm.mappers.FlowTaskWrapperMapper;
8 11 import com.lframework.starter.bpm.service.FlowInstanceWrapperService;
  12 +import com.lframework.starter.bpm.vo.flow.task.QueryTodoTaskListVo;
9 13 import com.lframework.starter.common.exceptions.impl.DefaultClientException;
10 14 import com.lframework.starter.common.exceptions.impl.InputErrorException;
11 15 import com.lframework.starter.common.utils.Assert;
... ... @@ -27,6 +31,8 @@ import com.lframework.xingyun.sc.bo.procurement.GetProcurementPlanReplenishBo;
27 31 import com.lframework.xingyun.sc.bo.procurement.GetProcurementPlanReplenishLineBo;
28 32 import com.lframework.xingyun.sc.enums.CustomerDevelopStatus;
29 33 import com.lframework.xingyun.sc.procurement.entity.ProcurementPlan;
  34 +import com.lframework.xingyun.sc.procurement.entity.ProcurementPlanChange;
  35 +import com.lframework.xingyun.sc.procurement.entity.ProcurementPlanChangeLine;
30 36 import com.lframework.xingyun.sc.procurement.entity.ProcurementPlanLine;
31 37 import com.lframework.xingyun.sc.procurement.entity.replenish.ProcurementPlanReplenish;
32 38 import com.lframework.xingyun.sc.procurement.entity.replenish.ProcurementPlanReplenishLine;
... ... @@ -49,6 +55,8 @@ import java.time.LocalDateTime;
49 55 import java.util.*;
50 56 import java.util.stream.Collectors;
51 57 import javax.annotation.Resource;
  58 +
  59 +import org.apache.commons.lang3.StringUtils;
52 60 import org.springframework.stereotype.Service;
53 61 import org.springframework.transaction.annotation.Transactional;
54 62
... ... @@ -79,6 +87,8 @@ public class ProcurementPlanReplenishServiceImpl
79 87 private WorkshopService workshopService;
80 88 @Resource
81 89 private ProcurementBuyoutApplyService procurementBuyoutApplyService;
  90 + @Resource
  91 + private FlowTaskWrapperMapper flowTaskWrapperMapper;
82 92
83 93
84 94 @Override
... ... @@ -403,7 +413,7 @@ public class ProcurementPlanReplenishServiceImpl
403 413 archivedMain.setCode(entity.getCode());
404 414 archivedMain.setDeleted(Boolean.FALSE);
405 415 archivedMain.setProcessNode(null);
406   - archivedMain.setProcessStatus(null);
  416 + archivedMain.setProcessStatus("COMPLETED");
407 417 archivedMain.setApprovalStatus(null);
408 418 if (CollectionUtil.isNotEmpty(allWorkshopIds) && allWorkshopIds.size() > 1) {
409 419 archivedMain.setFrozen(Boolean.TRUE);
... ... @@ -422,12 +432,6 @@ public class ProcurementPlanReplenishServiceImpl
422 432 archivedMain.setApprovalPassTime(LocalDateTime.now());
423 433 procurementPlanService.save(archivedMain);
424 434
425   - //生成买断操作申请单
426   - if (CollectionUtil.isNotEmpty(allWorkshopIds) && allWorkshopIds.size() == 1) {
427   - CreateProcurementBuyoutApplyVo vo = new CreateProcurementBuyoutApplyVo();
428   - vo.setProcurementPlanId(archivedMain.getId());
429   - procurementBuyoutApplyService.create(vo);
430   - }
431 435 // 主计划子表也复制一份
432 436 List<ProcurementPlanLine> archivedMainLines = new ArrayList<>();
433 437 if (CollectionUtil.isNotEmpty(mainLines)) {
... ... @@ -439,6 +443,14 @@ public class ProcurementPlanReplenishServiceImpl
439 443 }
440 444 procurementPlanLineService.saveBatch(archivedMainLines);
441 445 }
  446 +
  447 + //生成买断操作申请单
  448 + if (CollectionUtil.isNotEmpty(allWorkshopIds) && allWorkshopIds.size() == 1) {
  449 + CreateProcurementBuyoutApplyVo vo = new CreateProcurementBuyoutApplyVo();
  450 + vo.setProcurementPlanId(archivedMain.getId());
  451 + procurementBuyoutApplyService.create(vo);
  452 + }
  453 +
442 454 //拆分了分厂
443 455 if (CollectionUtil.isNotEmpty(allWorkshopIds) && allWorkshopIds.size() > 1) {
444 456 Map<String, String> deptId2CodeMap = new HashMap<>();
... ... @@ -482,7 +494,7 @@ public class ProcurementPlanReplenishServiceImpl
482 494 CreateProcurementPlanVo subVo = BeanUtil.copyProperties(archivedMain, CreateProcurementPlanVo.class);
483 495 subVo.setCode(subCode);
484 496 subVo.setParentId(archivedMain.getId());
485   - subVo.setProcessStatus(null);
  497 + subVo.setProcessStatus("COMPLETED");
486 498 subVo.setProcessNode(null);
487 499 subVo.setApprovalStatus(null);
488 500 subVo.setFrozen(Boolean.FALSE);
... ... @@ -503,6 +515,8 @@ public class ProcurementPlanReplenishServiceImpl
503 515 subLineVoList.add(lineVo);
504 516 }
505 517 subVo.setProcurementPlanLineList(subLineVoList);
  518 + subVo.setCreateBy(entity.getCreateBy());
  519 + subVo.setCreateById(entity.getCreateById());
506 520 // 子计划创建(不重新生成编号,因为使用父code+后缀)
507 521 procurementPlanService.createSubPlan(subVo);
508 522 }
... ... @@ -555,20 +569,20 @@ public class ProcurementPlanReplenishServiceImpl
555 569 Object bizIdObj = map.get("bizId");
556 570 String bizId = bizIdObj == null ? null : String.valueOf(bizIdObj);
557 571
  572 + // 将 Map 转换为 Vo,尝试获取 ID
  573 + String json = JsonUtil.toJsonString(map);
  574 + UpdateProcurementPlanReplenishVo vo = JsonUtil.parseObject(json, UpdateProcurementPlanReplenishVo.class);
558 575 if (StringUtil.isBlank(bizId)) {
559   - // 将 Map 转换为 Vo,尝试获取 ID
560   - String json = JsonUtil.toJsonString(map);
561   - UpdateProcurementPlanReplenishVo vo = JsonUtil.parseObject(json, UpdateProcurementPlanReplenishVo.class);
562   - bizId = vo == null ? null : vo.getId();
563   - if (vo != null && StringUtil.isNotBlank(vo.getId())) {
564   - // 更新主表字段
565   - ProcurementPlanReplenish replenish = new ProcurementPlanReplenish();
566   - BeanUtil.copyProperties(vo, replenish);
567   - this.updateById(replenish);
568   -
569   - // 保存或更新明细
570   - saveOrUpdateLines(vo.getId(), vo.getProcurementPlanReplenishLineList());
571   - }
  576 + bizId = vo.getId();
  577 + }
  578 + if (vo != null && StringUtil.isNotBlank(vo.getId())) {
  579 + // 更新主表字段
  580 + ProcurementPlanReplenish replenish = new ProcurementPlanReplenish();
  581 + BeanUtil.copyProperties(vo, replenish);
  582 + this.updateById(replenish);
  583 +
  584 + // 保存或更新明细
  585 + saveOrUpdateLines(vo.getId(), vo.getProcurementPlanReplenishLineList());
572 586 }
573 587
574 588 if ("PASS".equals(examStatus)) {
... ... @@ -617,7 +631,7 @@ public class ProcurementPlanReplenishServiceImpl
617 631 * @param lineList 明细列表
618 632 */
619 633 private void saveOrUpdateLines(String replenishId,
620   - List<? extends CreateProcurementPlanReplenishLineVo> lineList) {
  634 + List<? extends UpdateProcurementPlanReplenishLineVo> lineList) {
621 635 // 查询旧明细
622 636 List<ProcurementPlanReplenishLine> oldLineList =
623 637 procurementPlanReplenishLineService.getByProcurementPlanReplenishId(replenishId);
... ... @@ -628,24 +642,34 @@ public class ProcurementPlanReplenishServiceImpl
628 642
629 643 List<String> existIdList = new ArrayList<>();
630 644 if (!CollectionUtil.isEmpty(lineList)) {
631   - for (CreateProcurementPlanReplenishLineVo lineVo : lineList) {
632   - UpdateProcurementPlanReplenishLineVo updateLineVo = (UpdateProcurementPlanReplenishLineVo) lineVo;
633   - if (StringUtil.isNotBlank(updateLineVo.getId())) {
  645 + for (UpdateProcurementPlanReplenishLineVo lineVo : lineList) {
  646 + if (StringUtil.isNotBlank(lineVo.getId())) {
634 647 // 更新已有明细
635   - ProcurementPlanReplenishLine oldLine = oldLineMap.get(updateLineVo.getId());
  648 + ProcurementPlanReplenishLine oldLine = oldLineMap.get(lineVo.getId());
636 649 if (oldLine == null) {
637 650 throw new DefaultClientException("采购计划补单明细不存在或不属于当前补单!");
638 651 }
639 652
640   - existIdList.add(updateLineVo.getId());
641   - updateLineVo.setProcurementPlanReplenishId(replenishId);
642   - if (StringUtil.isBlank(updateLineVo.getItemId())) {
643   - updateLineVo.setItemId(oldLine.getItemId());
  653 + existIdList.add(lineVo.getId());
  654 + if (StringUtil.isBlank(lineVo.getItemId())) {
  655 + lineVo.setItemId(oldLine.getItemId());
644 656 }
645   - ProcurementPlanReplenishLine updateLine =
646   - BeanUtil.copyProperties(updateLineVo, ProcurementPlanReplenishLine.class);
647   - updateLine.setId(updateLineVo.getId());
648   - procurementPlanReplenishLineService.updateById(updateLine);
  657 + LambdaUpdateWrapper<ProcurementPlanReplenishLine> updateWrapper = new LambdaUpdateWrapper<>(ProcurementPlanReplenishLine.class);
  658 + updateWrapper.eq(ProcurementPlanReplenishLine::getId, lineVo.getId())
  659 + .set(ProcurementPlanReplenishLine::getProcurementPlanReplenishId, replenishId)
  660 + .set(ProcurementPlanReplenishLine::getProductId, lineVo.getProductId())
  661 + .set(ProcurementPlanReplenishLine::getMaterialType, lineVo.getMaterialType())
  662 + .set(ProcurementPlanReplenishLine::getQuantity, lineVo.getQuantity())
  663 + .set(ProcurementPlanReplenishLine::getActualPurchasePrice, lineVo.getActualPurchasePrice())
  664 + .set(ProcurementPlanReplenishLine::getIncludingShippingPrice, lineVo.getIncludingShippingPrice())
  665 + .set(ProcurementPlanReplenishLine::getPriceListPrices, lineVo.getPriceListPrices())
  666 + .set(ProcurementPlanReplenishLine::getCoordinationRange, lineVo.getCoordinationRange())
  667 + .set(ProcurementPlanReplenishLine::getEstimatedLoss, lineVo.getEstimatedLoss())
  668 + .set(ProcurementPlanReplenishLine::getApplicationAttrition, lineVo.getApplicationAttrition())
  669 + .set(ProcurementPlanReplenishLine::getPaintDamageRatio, lineVo.getPaintDamageRatio())
  670 + .set(ProcurementPlanReplenishLine::getWorkshopId, lineVo.getWorkshopId())
  671 + .set(ProcurementPlanReplenishLine::getItemId, lineVo.getItemId());
  672 + procurementPlanReplenishLineService.update(updateWrapper);
649 673 } else {
650 674 // 新增明细
651 675 ProcurementPlanReplenishLine createLine =
... ... @@ -687,31 +711,24 @@ public class ProcurementPlanReplenishServiceImpl
687 711 return;
688 712 }
689 713
690   - List<String> businessIds = validDatas.stream()
691   - .map(ProcurementPlanReplenish::getId)
692   - .collect(Collectors.toList());
693   -
694 714 // 查询已发起的流程
695   - List<?> flowByConditionList =
696   - flowInstanceWrapperService.getFlowByBusinessIdList(businessIds);
697   - Set<String> flowBusinessIdSet = CollectionUtil.isNotEmpty(flowByConditionList)
698   - ? flowByConditionList.stream()
699   - .map(obj -> {
700   - try {
701   - return BeanUtil.getProperty(obj, "businessId");
702   - } catch (Exception e) {
703   - return null;
704   - }
705   - })
706   - .filter(Objects::nonNull)
707   - .map(String::valueOf)
708   - .collect(Collectors.toSet())
709   - : new HashSet<>();
  715 + List<String> businessIds = validDatas.stream().map(ProcurementPlanReplenish::getId).collect(Collectors.toList());
  716 + List<FlowInstanceWrapper> flowList = flowInstanceWrapperService.getFlowByBusinessIdList(businessIds);
  717 + Set<String> flowBusinessIdSet = CollectionUtil.isNotEmpty(flowList)
  718 + ? flowList.stream().map(FlowInstanceWrapper::getBusinessId).collect(Collectors.toSet())
  719 + : new HashSet<>();
  720 +
  721 + List<FlowTaskDto> todoFlowTaskList = flowTaskWrapperMapper.queryTodoList(
  722 + new QueryTodoTaskListVo(), SecurityUtil.getCurrentUser().getId());
  723 + Set<String> todoBusinessIdSet = CollectionUtil.isNotEmpty(todoFlowTaskList)
  724 + ? todoFlowTaskList.stream().map(FlowTaskDto::getBusinessId).collect(Collectors.toSet())
  725 + : new HashSet<>();
710 726
711 727 for (ProcurementPlanReplenish replenish : validDatas) {
712 728 boolean hasFlow = flowBusinessIdSet.contains(replenish.getId());
713   - replenish.setShowExamineDetail(hasFlow && StringUtil.isNotBlank(replenish.getApprovalStatus()));
714   - replenish.setShowExamine(hasFlow && CustomerDevelopStatus.AUDIT.name().equals(replenish.getApprovalStatus()));
  729 + boolean hasTodo = todoBusinessIdSet.contains(replenish.getId());
  730 + replenish.setShowExamineDetail(hasFlow && StringUtils.isNotBlank(replenish.getApprovalStatus()));
  731 + replenish.setShowExamine(hasTodo && CustomerDevelopStatus.AUDIT.name().equals(replenish.getApprovalStatus()));
715 732 }
716 733 }
717 734 }
... ...
... ... @@ -12,13 +12,12 @@ import com.lframework.starter.web.core.utils.PageHelperUtil;
12 12 import com.lframework.starter.web.core.utils.PageResultUtil;
13 13 import com.lframework.xingyun.sc.bo.procurement.GetDomesticPlanSummaryBo;
14 14 import com.lframework.xingyun.sc.bo.procurement.GetDomesticPlanSummaryDetailBo;
15   -import com.lframework.xingyun.sc.procurement.entity.ProcurementBuyoutApply;
16   -import com.lframework.xingyun.sc.procurement.entity.replenish.ProcurementPlanReplenish;
  15 +import com.lframework.xingyun.sc.procurement.entity.ProcurementPlan;
17 16 import com.lframework.xingyun.sc.procurement.entity.summary.DomesticPlanSummary;
18 17 import com.lframework.xingyun.sc.procurement.entity.summary.DomesticPlanSummaryDetail;
19 18 import com.lframework.xingyun.sc.procurement.mappers.summary.DomesticPlanSummaryDetailMapper;
20 19 import com.lframework.xingyun.sc.procurement.mappers.summary.DomesticPlanSummaryMapper;
21   -import com.lframework.xingyun.sc.procurement.service.buyout.ProcurementBuyoutApplyService;
  20 +import com.lframework.xingyun.sc.procurement.service.plan.ProcurementPlanService;
22 21 import com.lframework.xingyun.sc.procurement.service.replenish.ProcurementPlanReplenishService;
23 22 import com.lframework.xingyun.sc.procurement.service.summary.DomesticPlanSummaryDetailService;
24 23 import com.lframework.xingyun.sc.procurement.service.summary.DomesticPlanSummaryService;
... ... @@ -34,6 +33,7 @@ import java.util.List;
34 33 import java.util.Map;
35 34 import java.util.Objects;
36 35 import java.util.Set;
  36 +import java.util.function.Function;
37 37 import java.util.stream.Collectors;
38 38 import javax.annotation.Resource;
39 39 import org.springframework.stereotype.Service;
... ... @@ -51,9 +51,7 @@ public class DomesticPlanSummaryServiceImpl extends
51 51 @Resource
52 52 private DomesticPlanSummaryDetailService domesticPlanSummaryDetailService;
53 53 @Resource
54   - private ProcurementBuyoutApplyService procurementBuyoutApplyService;
55   - @Resource
56   - private ProcurementPlanReplenishService procurementPlanReplenishService;
  54 + private ProcurementPlanService procurementPlanService;
57 55
58 56 @Override
59 57 public PageResult<DomesticPlanSummary> query(Integer pageIndex, Integer pageSize,
... ... @@ -138,27 +136,14 @@ public class DomesticPlanSummaryServiceImpl extends
138 136 .filter(Objects::nonNull)
139 137 .collect(Collectors.toSet());
140 138
141   - Set<String> buyoutPlanIds = Collections.emptySet();
  139 + Map<String, ProcurementPlan> procurementPlanMap = Collections.emptyMap();
142 140 if (CollectionUtil.isNotEmpty(planIds)) {
143   - buyoutPlanIds = procurementBuyoutApplyService.list(
144   - Wrappers.lambdaQuery(ProcurementBuyoutApply.class)
145   - .in(ProcurementBuyoutApply::getProcurementPlanId, planIds)
146   - .select(ProcurementBuyoutApply::getProcurementPlanId))
147   - .stream()
148   - .map(ProcurementBuyoutApply::getProcurementPlanId)
149   - .collect(Collectors.toSet());
150   - }
151   -
152   - Set<String> replenishPlanIds = Collections.emptySet();
153   - if (CollectionUtil.isNotEmpty(planIds)) {
154   - replenishPlanIds = procurementPlanReplenishService.list(
155   - Wrappers.lambdaQuery(ProcurementPlanReplenish.class)
156   - .in(ProcurementPlanReplenish::getProcurementPlanId, planIds)
157   - .eq(ProcurementPlanReplenish::getApprovalStatus, "PASS")
158   - .select(ProcurementPlanReplenish::getProcurementPlanId))
159   - .stream()
160   - .map(ProcurementPlanReplenish::getProcurementPlanId)
161   - .collect(Collectors.toSet());
  141 + procurementPlanMap = procurementPlanService.list(
  142 + Wrappers.lambdaQuery(ProcurementPlan.class)
  143 + .in(ProcurementPlan::getId, planIds))
  144 + .stream()
  145 + // 以 ID 为 Key,ProcurementPlan 对象为 Value 收集到 Map 中
  146 + .collect(Collectors.toMap(ProcurementPlan::getId, Function.identity()));
162 147 }
163 148
164 149 DomesticPlanSummary summary = new DomesticPlanSummary();
... ... @@ -222,14 +207,18 @@ public class DomesticPlanSummaryServiceImpl extends
222 207 d.setUpdateById("1");
223 208 d.setUpdateBy("系统管理员");
224 209
225   - boolean hasBuyout = buyoutPlanIds.contains(d.getPlanId());
226   - boolean hasReplenish = replenishPlanIds.contains(d.getPlanId());
227   - if (hasBuyout && hasReplenish) {
228   - d.setRemarkFlag("买断 补单");
229   - } else if (hasBuyout) {
230   - d.setRemarkFlag("买断");
231   - } else if (hasReplenish) {
232   - d.setRemarkFlag("补单");
  210 + ProcurementPlan plan = procurementPlanMap.get(d.getPlanId());
  211 + if (plan != null) {
  212 + if ((plan.getCommodityBuyout() || plan.getQuantityBuyout() || plan.getQualityBuyout())
  213 + && plan.getPlanType() != null && plan.getPlanType().contains("补")) {
  214 + d.setRemarkFlag("买断 补单");
  215 + } else if (plan.getCommodityBuyout() || plan.getQuantityBuyout() || plan.getQualityBuyout()) {
  216 + d.setRemarkFlag("买断");
  217 + } else if (plan.getPlanType() != null && plan.getPlanType().contains("补")) {
  218 + d.setRemarkFlag("补单");
  219 + } else {
  220 + d.setRemarkFlag(null);
  221 + }
233 222 } else {
234 223 d.setRemarkFlag(null);
235 224 }
... ...
1 1 package com.lframework.xingyun.sc.procurement.vo.plan;
2 2
  3 +import com.baomidou.mybatisplus.annotation.FieldFill;
  4 +import com.baomidou.mybatisplus.annotation.TableField;
3 5 import com.fasterxml.jackson.annotation.JsonFormat;
4 6 import com.lframework.starter.common.constants.StringPool;
5 7 import com.lframework.starter.common.exceptions.impl.InputErrorException;
... ... @@ -370,6 +372,12 @@ public class CreateProcurementPlanVo implements BaseVo, Serializable {
370 372 @JsonFormat(pattern = StringPool.DATE_TIME_PATTERN)
371 373 private LocalDateTime approvalPassTime;
372 374
  375 + @ApiModelProperty("创建人ID")
  376 + private String createById;
  377 +
  378 + @ApiModelProperty("创建人")
  379 + private String createBy;
  380 +
373 381 /**
374 382 * 明细信息
375 383 */
... ...
... ... @@ -13,6 +13,7 @@ import javax.validation.constraints.NotBlank;
13 13 import javax.validation.constraints.NotEmpty;
14 14 import javax.validation.constraints.NotNull;
15 15 import lombok.Data;
  16 +import org.apache.ibatis.annotations.Update;
16 17 import org.hibernate.validator.constraints.Length;
17 18
18 19 @Data
... ... @@ -179,7 +180,7 @@ public class CreateProcurementPlanReplenishVo implements BaseVo, Serializable {
179 180 @ApiModelProperty(value = "明细信息", required = true)
180 181 @Valid
181 182 @NotEmpty(message = "明细不能为空!")
182   - private List<CreateProcurementPlanReplenishLineVo> procurementPlanReplenishLineList;
  183 + private List<UpdateProcurementPlanReplenishLineVo> procurementPlanReplenishLineList;
183 184
184 185 public void validate() {
185 186 }
... ...
... ... @@ -273,6 +273,7 @@
273 273 </when>
274 274 <when test="vo.queryType == 'REPLENISHMENT'">
275 275 AND pp.process_status IN ('COMPLETED', 'ABORTED')
  276 + AND pp.plan_type NOT LIKE '%补%'
276 277 AND (pp.replenishment_status = '' OR pp.replenishment_status IS NULL OR pp.replenishment_status
277 278 = 'REPLENISHED')
278 279 AND (pp.change_status = '' OR pp.change_status IS NULL OR pp.change_status = 'CHANGED')
... ...