Commit 5fee6a293b82dcfee8dc492344326ccde49a265e
1 parent
48611c93
采购计划:买断操作申请单生成、废弃按钮展示;选择分厂后自动生成买断操作申请单
Showing
3 changed files
with
69 additions
and
2 deletions
| @@ -351,6 +351,18 @@ public class GetProcurementPlanBo extends BaseBo<ProcurementPlan> { | @@ -351,6 +351,18 @@ public class GetProcurementPlanBo extends BaseBo<ProcurementPlan> { | ||
| 351 | private String salesmanQuotationId; | 351 | private String salesmanQuotationId; |
| 352 | 352 | ||
| 353 | /** | 353 | /** |
| 354 | + * 是否展示「生成买断操作申请单」按钮 | ||
| 355 | + */ | ||
| 356 | + @ApiModelProperty("是否展示「生成买断操作申请单」") | ||
| 357 | + private Boolean showGenerateBuyoutApply; | ||
| 358 | + | ||
| 359 | + /** | ||
| 360 | + * 是否展示「废除买断操作申请单」按钮 | ||
| 361 | + */ | ||
| 362 | + @ApiModelProperty("是否展示「废除买断操作申请单」") | ||
| 363 | + private Boolean showAbolishBuyoutApply; | ||
| 364 | + | ||
| 365 | + /** | ||
| 354 | * 附件文件ID集合 | 366 | * 附件文件ID集合 |
| 355 | */ | 367 | */ |
| 356 | @ApiModelProperty("附件文件ID集合") | 368 | @ApiModelProperty("附件文件ID集合") |
| 1 | package com.lframework.xingyun.sc.procurement.controller.plan; | 1 | package com.lframework.xingyun.sc.procurement.controller.plan; |
| 2 | 2 | ||
| 3 | +import com.baomidou.mybatisplus.core.toolkit.Wrappers; | ||
| 3 | import com.lframework.starter.common.utils.CollectionUtil; | 4 | import com.lframework.starter.common.utils.CollectionUtil; |
| 4 | import com.lframework.starter.web.core.annotations.security.HasPermission; | 5 | import com.lframework.starter.web.core.annotations.security.HasPermission; |
| 5 | import com.lframework.starter.web.core.controller.DefaultBaseController; | 6 | import com.lframework.starter.web.core.controller.DefaultBaseController; |
| @@ -8,7 +9,9 @@ import com.lframework.starter.web.core.components.resp.InvokeResultBuilder; | @@ -8,7 +9,9 @@ import com.lframework.starter.web.core.components.resp.InvokeResultBuilder; | ||
| 8 | import com.lframework.starter.web.core.components.resp.PageResult; | 9 | import com.lframework.starter.web.core.components.resp.PageResult; |
| 9 | import com.lframework.starter.web.core.utils.PageResultUtil; | 10 | import com.lframework.starter.web.core.utils.PageResultUtil; |
| 10 | import com.lframework.xingyun.sc.bo.procurement.GetProcurementPlanBo; | 11 | import com.lframework.xingyun.sc.bo.procurement.GetProcurementPlanBo; |
| 12 | +import com.lframework.xingyun.sc.procurement.entity.ProcurementBuyoutApply; | ||
| 11 | import com.lframework.xingyun.sc.procurement.entity.ProcurementPlan; | 13 | import com.lframework.xingyun.sc.procurement.entity.ProcurementPlan; |
| 14 | +import com.lframework.xingyun.sc.procurement.service.buyout.ProcurementBuyoutApplyService; | ||
| 12 | import com.lframework.xingyun.sc.procurement.service.plan.ProcurementPlanService; | 15 | import com.lframework.xingyun.sc.procurement.service.plan.ProcurementPlanService; |
| 13 | import com.lframework.xingyun.sc.procurement.vo.plan.CreateProcurementPlanVo; | 16 | import com.lframework.xingyun.sc.procurement.vo.plan.CreateProcurementPlanVo; |
| 14 | import com.lframework.xingyun.sc.procurement.vo.plan.QueryProcurementPlanVo; | 17 | import com.lframework.xingyun.sc.procurement.vo.plan.QueryProcurementPlanVo; |
| @@ -16,7 +19,10 @@ import com.lframework.xingyun.sc.procurement.vo.plan.UpdateProcurementPlanVo; | @@ -16,7 +19,10 @@ import com.lframework.xingyun.sc.procurement.vo.plan.UpdateProcurementPlanVo; | ||
| 16 | import io.swagger.annotations.Api; | 19 | import io.swagger.annotations.Api; |
| 17 | import io.swagger.annotations.ApiImplicitParam; | 20 | import io.swagger.annotations.ApiImplicitParam; |
| 18 | import io.swagger.annotations.ApiOperation; | 21 | import io.swagger.annotations.ApiOperation; |
| 22 | +import java.util.HashMap; | ||
| 19 | import java.util.List; | 23 | import java.util.List; |
| 24 | +import java.util.Map; | ||
| 25 | +import java.util.Set; | ||
| 20 | import java.util.stream.Collectors; | 26 | import java.util.stream.Collectors; |
| 21 | import javax.validation.Valid; | 27 | import javax.validation.Valid; |
| 22 | import javax.validation.constraints.NotBlank; | 28 | import javax.validation.constraints.NotBlank; |
| @@ -38,6 +44,8 @@ public class ProcurementPlanController extends DefaultBaseController { | @@ -38,6 +44,8 @@ public class ProcurementPlanController extends DefaultBaseController { | ||
| 38 | 44 | ||
| 39 | @Autowired | 45 | @Autowired |
| 40 | private ProcurementPlanService procurementPlanService; | 46 | private ProcurementPlanService procurementPlanService; |
| 47 | + @Autowired | ||
| 48 | + private ProcurementBuyoutApplyService procurementBuyoutApplyService; | ||
| 41 | 49 | ||
| 42 | /** | 50 | /** |
| 43 | * 查询列表 | 51 | * 查询列表 |
| @@ -56,6 +64,7 @@ public class ProcurementPlanController extends DefaultBaseController { | @@ -56,6 +64,7 @@ public class ProcurementPlanController extends DefaultBaseController { | ||
| 56 | results = datas.stream() | 64 | results = datas.stream() |
| 57 | .map(GetProcurementPlanBo::new) | 65 | .map(GetProcurementPlanBo::new) |
| 58 | .collect(Collectors.toList()); | 66 | .collect(Collectors.toList()); |
| 67 | + fillBuyoutButtons(results, datas); | ||
| 59 | } | 68 | } |
| 60 | 69 | ||
| 61 | return InvokeResultBuilder.success(PageResultUtil.rebuild(pageResult, results)); | 70 | return InvokeResultBuilder.success(PageResultUtil.rebuild(pageResult, results)); |
| @@ -72,6 +81,11 @@ public class ProcurementPlanController extends DefaultBaseController { | @@ -72,6 +81,11 @@ public class ProcurementPlanController extends DefaultBaseController { | ||
| 72 | @NotBlank(message = "ID不能为空!") String id) { | 81 | @NotBlank(message = "ID不能为空!") String id) { |
| 73 | 82 | ||
| 74 | GetProcurementPlanBo result = procurementPlanService.getDetail(id); | 83 | GetProcurementPlanBo result = procurementPlanService.getDetail(id); |
| 84 | + if (result != null) { | ||
| 85 | + ProcurementPlan plan = procurementPlanService.getById(id); | ||
| 86 | + fillBuyoutButtons(java.util.Collections.singletonList(result), | ||
| 87 | + plan == null ? java.util.Collections.emptyList() : java.util.Collections.singletonList(plan)); | ||
| 88 | + } | ||
| 75 | 89 | ||
| 76 | return InvokeResultBuilder.success(result); | 90 | return InvokeResultBuilder.success(result); |
| 77 | } | 91 | } |
| @@ -173,4 +187,35 @@ public class ProcurementPlanController extends DefaultBaseController { | @@ -173,4 +187,35 @@ public class ProcurementPlanController extends DefaultBaseController { | ||
| 173 | 187 | ||
| 174 | return InvokeResultBuilder.success(); | 188 | return InvokeResultBuilder.success(); |
| 175 | } | 189 | } |
| 190 | + | ||
| 191 | + /** | ||
| 192 | + * 填充采购计划买断操作相关两个按钮字段(生成/废除按钮) | ||
| 193 | + */ | ||
| 194 | + private void fillBuyoutButtons(List<GetProcurementPlanBo> results, List<ProcurementPlan> datas) { | ||
| 195 | + if (CollectionUtil.isEmpty(results)) { | ||
| 196 | + return; | ||
| 197 | + } | ||
| 198 | + Set<String> planIds = datas.stream().map(ProcurementPlan::getId).collect(Collectors.toSet()); | ||
| 199 | + Map<String, Long> applyCountMap = new HashMap<>(); | ||
| 200 | + if (!CollectionUtil.isEmpty(planIds)) { | ||
| 201 | + List<ProcurementBuyoutApply> applies = procurementBuyoutApplyService.list( | ||
| 202 | + Wrappers.lambdaQuery(ProcurementBuyoutApply.class) | ||
| 203 | + .select(ProcurementBuyoutApply::getProcurementPlanId) | ||
| 204 | + .in(ProcurementBuyoutApply::getProcurementPlanId, planIds)); | ||
| 205 | + if (!CollectionUtil.isEmpty(applies)) { | ||
| 206 | + applyCountMap = applies.stream() | ||
| 207 | + .collect(Collectors.groupingBy(ProcurementBuyoutApply::getProcurementPlanId, Collectors.counting())); | ||
| 208 | + } | ||
| 209 | + } | ||
| 210 | + for (int i = 0; i < results.size(); i++) { | ||
| 211 | + ProcurementPlan plan = datas.get(i); | ||
| 212 | + GetProcurementPlanBo bo = results.get(i); | ||
| 213 | + boolean buyoutFlag = Boolean.TRUE.equals(plan.getCommodityBuyout()) | ||
| 214 | + || Boolean.TRUE.equals(plan.getQualityBuyout()) | ||
| 215 | + || Boolean.TRUE.equals(plan.getQuantityBuyout()); | ||
| 216 | + long count = applyCountMap.getOrDefault(plan.getId(), 0L); | ||
| 217 | + bo.setShowGenerateBuyoutApply(buyoutFlag && count == 0L); | ||
| 218 | + bo.setShowAbolishBuyoutApply(buyoutFlag && count > 0L); | ||
| 219 | + } | ||
| 220 | + } | ||
| 176 | } | 221 | } |
| @@ -28,8 +28,10 @@ import com.lframework.xingyun.sc.bo.procurement.GetProcurementPlanBo; | @@ -28,8 +28,10 @@ import com.lframework.xingyun.sc.bo.procurement.GetProcurementPlanBo; | ||
| 28 | import com.lframework.xingyun.sc.procurement.entity.ProcurementPlan; | 28 | import com.lframework.xingyun.sc.procurement.entity.ProcurementPlan; |
| 29 | import com.lframework.xingyun.sc.procurement.entity.ProcurementPlanLine; | 29 | import com.lframework.xingyun.sc.procurement.entity.ProcurementPlanLine; |
| 30 | import com.lframework.xingyun.sc.procurement.mappers.plan.ProcurementPlanMapper; | 30 | import com.lframework.xingyun.sc.procurement.mappers.plan.ProcurementPlanMapper; |
| 31 | +import com.lframework.xingyun.sc.procurement.service.buyout.ProcurementBuyoutApplyService; | ||
| 31 | import com.lframework.xingyun.sc.procurement.service.plan.ProcurementPlanLineService; | 32 | import com.lframework.xingyun.sc.procurement.service.plan.ProcurementPlanLineService; |
| 32 | import com.lframework.xingyun.sc.procurement.service.plan.ProcurementPlanService; | 33 | import com.lframework.xingyun.sc.procurement.service.plan.ProcurementPlanService; |
| 34 | +import com.lframework.xingyun.sc.procurement.vo.buyout.CreateProcurementBuyoutApplyVo; | ||
| 33 | import com.lframework.xingyun.sc.procurement.vo.plan.CreateProcurementPlanVo; | 35 | import com.lframework.xingyun.sc.procurement.vo.plan.CreateProcurementPlanVo; |
| 34 | import com.lframework.xingyun.sc.procurement.vo.plan.ProcurementPlanLineVo; | 36 | import com.lframework.xingyun.sc.procurement.vo.plan.ProcurementPlanLineVo; |
| 35 | import com.lframework.xingyun.sc.procurement.vo.plan.ProcurementPlanUpdateLineVo; | 37 | import com.lframework.xingyun.sc.procurement.vo.plan.ProcurementPlanUpdateLineVo; |
| @@ -67,6 +69,8 @@ public class ProcurementPlanServiceImpl extends BaseMpServiceImpl<ProcurementPla | @@ -67,6 +69,8 @@ public class ProcurementPlanServiceImpl extends BaseMpServiceImpl<ProcurementPla | ||
| 67 | private FlowInstanceWrapperService flowInstanceWrapperService; | 69 | private FlowInstanceWrapperService flowInstanceWrapperService; |
| 68 | @Resource | 70 | @Resource |
| 69 | private FlowTaskWrapperService flowTaskWrapperService; | 71 | private FlowTaskWrapperService flowTaskWrapperService; |
| 72 | + @Resource | ||
| 73 | + private ProcurementBuyoutApplyService procurementBuyoutApplyService; | ||
| 70 | 74 | ||
| 71 | @Override | 75 | @Override |
| 72 | public PageResult<ProcurementPlan> query(Integer pageIndex, Integer pageSize, | 76 | public PageResult<ProcurementPlan> query(Integer pageIndex, Integer pageSize, |
| @@ -312,7 +316,10 @@ public class ProcurementPlanServiceImpl extends BaseMpServiceImpl<ProcurementPla | @@ -312,7 +316,10 @@ public class ProcurementPlanServiceImpl extends BaseMpServiceImpl<ProcurementPla | ||
| 312 | .set(ProcurementPlan::getWorkshopId, allLines.get(0).getWorkshopId()) | 316 | .set(ProcurementPlan::getWorkshopId, allLines.get(0).getWorkshopId()) |
| 313 | .eq(ProcurementPlan::getId, id); | 317 | .eq(ProcurementPlan::getId, id); |
| 314 | getBaseMapper().update(updateWrapper); | 318 | getBaseMapper().update(updateWrapper); |
| 315 | - //todo 生成买断操作申请单 | 319 | + //生成买断操作申请单 |
| 320 | + CreateProcurementBuyoutApplyVo vo = new CreateProcurementBuyoutApplyVo(); | ||
| 321 | + vo.setProcurementPlanId(id); | ||
| 322 | + procurementBuyoutApplyService.create(vo); | ||
| 316 | return; | 323 | return; |
| 317 | } | 324 | } |
| 318 | 325 | ||
| @@ -351,7 +358,6 @@ public class ProcurementPlanServiceImpl extends BaseMpServiceImpl<ProcurementPla | @@ -351,7 +358,6 @@ public class ProcurementPlanServiceImpl extends BaseMpServiceImpl<ProcurementPla | ||
| 351 | 358 | ||
| 352 | // 子计划创建(不重新生成编号,因为使用父code+后缀) | 359 | // 子计划创建(不重新生成编号,因为使用父code+后缀) |
| 353 | createSubPlan(subVo); | 360 | createSubPlan(subVo); |
| 354 | - //todo 生成买断操作申请单 | ||
| 355 | } | 361 | } |
| 356 | 362 | ||
| 357 | // 4. 冻结主计划(不再变更主计划) | 363 | // 4. 冻结主计划(不再变更主计划) |
| @@ -559,6 +565,10 @@ public class ProcurementPlanServiceImpl extends BaseMpServiceImpl<ProcurementPla | @@ -559,6 +565,10 @@ public class ProcurementPlanServiceImpl extends BaseMpServiceImpl<ProcurementPla | ||
| 559 | procurementPlanLineService.save(line); | 565 | procurementPlanLineService.save(line); |
| 560 | } | 566 | } |
| 561 | } | 567 | } |
| 568 | + //生成买断操作申请单 | ||
| 569 | + CreateProcurementBuyoutApplyVo buyoutApplyVo = new CreateProcurementBuyoutApplyVo(); | ||
| 570 | + buyoutApplyVo.setProcurementPlanId(plan.getId()); | ||
| 571 | + procurementBuyoutApplyService.create(buyoutApplyVo); | ||
| 562 | } | 572 | } |
| 563 | 573 | ||
| 564 | /** | 574 | /** |