Showing
5 changed files
with
140 additions
and
2 deletions
| ... | ... | @@ -22,6 +22,7 @@ import com.lframework.xingyun.sc.procurement.entity.ProcurementDomesticCustomerC |
| 22 | 22 | import com.lframework.xingyun.sc.procurement.entity.ProcurementForeignTradeCredit; |
| 23 | 23 | import com.lframework.xingyun.sc.procurement.service.credit.ProcurementDomesticCustomerCreditService; |
| 24 | 24 | import com.lframework.xingyun.sc.procurement.service.credit.ProcurementForeignTradeCreditService; |
| 25 | +import com.lframework.xingyun.sc.procurement.service.plan.ProcurementPlanService; | |
| 25 | 26 | import com.lframework.xingyun.sc.procurement.service.quotation.SalesmanQuotationService; |
| 26 | 27 | import com.lframework.xingyun.sc.service.contract.ContractDistributorLineService; |
| 27 | 28 | import com.lframework.xingyun.sc.service.contract.ContractChangeApplicationService; |
| ... | ... | @@ -157,6 +158,8 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic |
| 157 | 158 | private ProcurementForeignTradeCreditService procurementForeignTradeCreditService; |
| 158 | 159 | @Resource |
| 159 | 160 | private SalesmanQuotationService salesmanQuotationService; |
| 161 | + @Resource | |
| 162 | + private ProcurementPlanService procurementPlanService; | |
| 160 | 163 | |
| 161 | 164 | |
| 162 | 165 | |
| ... | ... | @@ -247,6 +250,9 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic |
| 247 | 250 | case "SALESMAN_QUOTATION": |
| 248 | 251 | handleSalesmanQuotationData(flowStatus, businessId); |
| 249 | 252 | break; |
| 253 | + case "PROCUREMENT_PLAN": | |
| 254 | + handleProcurementPlanData(flowStatus, businessId); | |
| 255 | + break; | |
| 250 | 256 | default: |
| 251 | 257 | break; |
| 252 | 258 | } |
| ... | ... | @@ -1123,4 +1129,22 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic |
| 1123 | 1129 | salesmanQuotationService.updateApprovalStatus(businessId, "REFUSE"); |
| 1124 | 1130 | } |
| 1125 | 1131 | } |
| 1132 | + | |
| 1133 | + /** | |
| 1134 | + * 采购计划审核业务数据处理 | |
| 1135 | + * | |
| 1136 | + * @param flowStatus 审核结果 | |
| 1137 | + * @param businessId 业务ID | |
| 1138 | + */ | |
| 1139 | + private void handleProcurementPlanData(String flowStatus, String businessId) { | |
| 1140 | + if (FlowInstanceStatus.APPROVE_PASS.getCode().equals(flowStatus) | |
| 1141 | + || FlowInstanceStatus.FINISH.getCode().equals(flowStatus)) { | |
| 1142 | + procurementPlanService.updateApprovalStatus(businessId, "PASS"); | |
| 1143 | + } else if (FlowInstanceStatus.REVOKE.getCode().equals(flowStatus) | |
| 1144 | + || FlowInstanceStatus.REFUSE.getCode().equals(flowStatus) | |
| 1145 | + || FlowInstanceStatus.TERMINATION.getCode().equals(flowStatus)) { | |
| 1146 | + procurementPlanService.updateApprovalStatus(businessId, "REFUSE"); | |
| 1147 | + } | |
| 1148 | + } | |
| 1149 | + | |
| 1126 | 1150 | } | ... | ... |
| ... | ... | @@ -17,6 +17,7 @@ import com.lframework.xingyun.sc.entity.ContractDistributorStandard; |
| 17 | 17 | import com.lframework.xingyun.sc.entity.FundCoordination; |
| 18 | 18 | import com.lframework.xingyun.sc.entity.ProductSampleConfirmationSlip; |
| 19 | 19 | import com.lframework.xingyun.sc.handlers.TransactorHandler; |
| 20 | +import com.lframework.xingyun.sc.procurement.service.plan.ProcurementPlanService; | |
| 20 | 21 | import com.lframework.xingyun.sc.service.contract.ContractDistributorStandardService; |
| 21 | 22 | import com.lframework.xingyun.sc.service.customer.CustomerCreditService; |
| 22 | 23 | import com.lframework.xingyun.sc.service.ledger.FundCoordinationService; |
| ... | ... | @@ -59,6 +60,8 @@ public class FlowTaskServiceImpl implements FlowTaskService { |
| 59 | 60 | private SampleResultTrackingService sampleResultTrackingService; |
| 60 | 61 | @Resource |
| 61 | 62 | private ContractDistributorStandardService contractDistributorStandardService; |
| 63 | + @Resource | |
| 64 | + private ProcurementPlanService procurementPlanService; | |
| 62 | 65 | |
| 63 | 66 | |
| 64 | 67 | @OpLog(type = OtherOpLogType.class, name = "修改客户资信,ID:{}", params = {"#id"}) |
| ... | ... | @@ -437,6 +440,15 @@ public class FlowTaskServiceImpl implements FlowTaskService { |
| 437 | 440 | } |
| 438 | 441 | |
| 439 | 442 | @Override |
| 443 | + public void updateProcurementPlanMap(Map<String, Object> map) { | |
| 444 | + //主键 | |
| 445 | + Object i = map.get("id"); | |
| 446 | + String id = String.valueOf(i); | |
| 447 | + | |
| 448 | + procurementPlanService.updateExamine(id); | |
| 449 | + } | |
| 450 | + | |
| 451 | + @Override | |
| 440 | 452 | public Map<String, Object> findById(String s) { |
| 441 | 453 | ProductSampleConfirmationSlip slip = productSampleConfirmationSlipService.findById(s); |
| 442 | 454 | Map<String, Object> map = new HashMap<>(); | ... | ... |
| ... | ... | @@ -133,6 +133,20 @@ public class ProcurementPlanController extends DefaultBaseController { |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | /** |
| 136 | + * 发起审核 | |
| 137 | + */ | |
| 138 | + @ApiOperation("发起审核") | |
| 139 | + @ApiImplicitParam(value = "ID", name = "id", paramType = "query", required = true) | |
| 140 | + @HasPermission({"plan-manage:domestic-plan:goapprove"}) | |
| 141 | + @PostMapping("/submitAudit") | |
| 142 | + public InvokeResult<Void> submitAudit(@NotBlank(message = "ID不能为空!") String id) { | |
| 143 | + | |
| 144 | + procurementPlanService.submitAudit(id); | |
| 145 | + | |
| 146 | + return InvokeResultBuilder.success(); | |
| 147 | + } | |
| 148 | + | |
| 149 | + /** | |
| 136 | 150 | * 删除 |
| 137 | 151 | */ |
| 138 | 152 | @ApiOperation("删除") | ... | ... |
| ... | ... | @@ -5,17 +5,19 @@ 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.service.FlowInstanceWrapperService; | |
| 8 | 9 | import com.lframework.starter.common.exceptions.impl.DefaultClientException; |
| 9 | 10 | import com.lframework.starter.common.exceptions.impl.InputErrorException; |
| 10 | 11 | import com.lframework.starter.common.utils.Assert; |
| 11 | 12 | import com.lframework.starter.common.utils.CollectionUtil; |
| 12 | 13 | import com.lframework.starter.common.utils.NumberUtil; |
| 13 | 14 | import com.lframework.starter.common.utils.StringUtil; |
| 15 | +import com.lframework.starter.web.core.annotations.oplog.OpLog; | |
| 14 | 16 | import com.lframework.starter.web.core.impl.BaseMpServiceImpl; |
| 15 | 17 | import com.lframework.starter.web.core.utils.IdUtil; |
| 18 | +import com.lframework.starter.web.core.utils.OpLogUtil; | |
| 16 | 19 | import com.lframework.starter.web.core.utils.PageHelperUtil; |
| 17 | -import com.lframework.starter.web.inner.entity.SysDept; | |
| 18 | -import com.lframework.starter.web.inner.service.system.SysDeptService; | |
| 20 | +import com.lframework.starter.web.inner.components.oplog.OtherOpLogType; | |
| 19 | 21 | import com.lframework.starter.web.core.components.resp.PageResult; |
| 20 | 22 | import com.lframework.starter.web.core.utils.PageResultUtil; |
| 21 | 23 | import com.lframework.xingyun.basedata.entity.Workshop; |
| ... | ... | @@ -53,10 +55,14 @@ import javax.annotation.Resource; |
| 53 | 55 | public class ProcurementPlanServiceImpl extends BaseMpServiceImpl<ProcurementPlanMapper, ProcurementPlan> |
| 54 | 56 | implements ProcurementPlanService { |
| 55 | 57 | |
| 58 | + private static final String BPM_FLAG = "PROCUREMENT_PLAN"; | |
| 59 | + | |
| 56 | 60 | @Autowired |
| 57 | 61 | private ProcurementPlanLineService procurementPlanLineService; |
| 58 | 62 | @Resource |
| 59 | 63 | private WorkshopService workshopService; |
| 64 | + @Resource | |
| 65 | + private FlowInstanceWrapperService flowInstanceWrapperService; | |
| 60 | 66 | |
| 61 | 67 | @Override |
| 62 | 68 | public PageResult<ProcurementPlan> query(Integer pageIndex, Integer pageSize, |
| ... | ... | @@ -353,6 +359,71 @@ public class ProcurementPlanServiceImpl extends BaseMpServiceImpl<ProcurementPla |
| 353 | 359 | getBaseMapper().update(mainUpdateWrapper); |
| 354 | 360 | } |
| 355 | 361 | |
| 362 | + @OpLog(type = OtherOpLogType.class, name = "发起采购计划审核,ID:{}", params = {"#id"}) | |
| 363 | + @Transactional(rollbackFor = Exception.class) | |
| 364 | + @Override | |
| 365 | + public void submitAudit(String id) { | |
| 366 | + if (StringUtil.isBlank(id)) { | |
| 367 | + throw new InputErrorException("ID不能为空!"); | |
| 368 | + } | |
| 369 | + | |
| 370 | + ProcurementPlan plan = getBaseMapper().findById(id); | |
| 371 | + if (plan == null) { | |
| 372 | + throw new DefaultClientException("采购计划不存在!"); | |
| 373 | + } | |
| 374 | + | |
| 375 | + if (Boolean.TRUE.equals(plan.getFrozen())) { | |
| 376 | + throw new DefaultClientException("当前采购计划已冻结,无法发起审核!"); | |
| 377 | + } | |
| 378 | + | |
| 379 | + List<ProcurementPlanLine> planLineList = procurementPlanLineService.getByProcurementPlanId(id); | |
| 380 | + if (CollectionUtil.isEmpty(planLineList)) { | |
| 381 | + throw new DefaultClientException("采购计划明细为空,无法发起审核!"); | |
| 382 | + } | |
| 383 | + | |
| 384 | + // 更新主表审核状态/流程节点:标记为已发起审核中 | |
| 385 | + LambdaUpdateWrapper<ProcurementPlan> updateWrapper = Wrappers.lambdaUpdate(ProcurementPlan.class) | |
| 386 | + .set(ProcurementPlan::getApprovalStatus, "AUDIT") | |
| 387 | + .set(ProcurementPlan::getProcessStatus, "AUDIT") | |
| 388 | + .set(ProcurementPlan::getProcessNode, "GYBZG") | |
| 389 | + .eq(ProcurementPlan::getId, id); | |
| 390 | + getBaseMapper().update(updateWrapper); | |
| 391 | + | |
| 392 | + ProcurementPlan freshPlan = getBaseMapper().findById(id); | |
| 393 | + flowInstanceWrapperService.startInstance(BPM_FLAG, freshPlan.getId(), BPM_FLAG, freshPlan); | |
| 394 | + | |
| 395 | + OpLogUtil.setVariable("id", freshPlan.getId()); | |
| 396 | + OpLogUtil.setExtra(freshPlan); | |
| 397 | + } | |
| 398 | + | |
| 399 | + @Transactional(rollbackFor = Exception.class) | |
| 400 | + @Override | |
| 401 | + public void updateApprovalStatus(String id, String approvalStatus) { | |
| 402 | + if (StringUtils.isBlank(id) || StringUtils.isBlank(approvalStatus)) { | |
| 403 | + throw new DefaultClientException("采购计划ID、审核状态不能为空!"); | |
| 404 | + } | |
| 405 | + | |
| 406 | + Wrapper<ProcurementPlan> wrapper = Wrappers.lambdaUpdate(ProcurementPlan.class) | |
| 407 | + .set(ProcurementPlan::getApprovalStatus, approvalStatus) | |
| 408 | + .set(ProcurementPlan::getProcessStatus, approvalStatus.equals("PASS") ? "COMPLETED" : "REFUSE") | |
| 409 | + .set(ProcurementPlan::getProcessNode, approvalStatus.equals("PASS") ? null : "GYGLKZG") | |
| 410 | + .eq(ProcurementPlan::getId, id); | |
| 411 | + getBaseMapper().update(wrapper); | |
| 412 | + } | |
| 413 | + | |
| 414 | + @Transactional(rollbackFor = Exception.class) | |
| 415 | + @Override | |
| 416 | + public void updateExamine(String id) { | |
| 417 | + if (StringUtils.isBlank(id)) { | |
| 418 | + throw new DefaultClientException("采购计划ID不能为空!"); | |
| 419 | + } | |
| 420 | + | |
| 421 | + Wrapper<ProcurementPlan> wrapper = Wrappers.lambdaUpdate(ProcurementPlan.class) | |
| 422 | + .set(ProcurementPlan::getProcessNode, "YSFG") | |
| 423 | + .eq(ProcurementPlan::getId, id); | |
| 424 | + getBaseMapper().update(wrapper); | |
| 425 | + } | |
| 426 | + | |
| 356 | 427 | /** |
| 357 | 428 | * 子计划创建:与 create() 逻辑一致,但不重新 buildPlanCode(因为子计划编号已按父code+后缀生成) |
| 358 | 429 | */ | ... | ... |
| ... | ... | @@ -72,4 +72,21 @@ public interface ProcurementPlanService extends BaseMpService<ProcurementPlan> { |
| 72 | 72 | * @param id |
| 73 | 73 | */ |
| 74 | 74 | void submit(String id); |
| 75 | + | |
| 76 | + /** | |
| 77 | + * 发起审核 | |
| 78 | + * | |
| 79 | + * @param id | |
| 80 | + */ | |
| 81 | + void submitAudit(String id); | |
| 82 | + | |
| 83 | + /** | |
| 84 | + * 更新审核状态 | |
| 85 | + * | |
| 86 | + * @param id | |
| 87 | + * @param approvalStatus | |
| 88 | + */ | |
| 89 | + void updateApprovalStatus(String id, String approvalStatus); | |
| 90 | + | |
| 91 | + void updateExamine(String id); | |
| 75 | 92 | } | ... | ... |