Showing
10 changed files
with
203 additions
and
0 deletions
| @@ -1931,6 +1931,8 @@ CREATE TABLE `procurement_plan` | @@ -1931,6 +1931,8 @@ CREATE TABLE `procurement_plan` | ||
| 1931 | `salesman_quotation_id` varchar(32) DEFAULT NULL COMMENT '关联业务员报价单ID', | 1931 | `salesman_quotation_id` varchar(32) DEFAULT NULL COMMENT '关联业务员报价单ID', |
| 1932 | `attachment_file_ids` text DEFAULT NULL COMMENT '附件文件ID集合', | 1932 | `attachment_file_ids` text DEFAULT NULL COMMENT '附件文件ID集合', |
| 1933 | `attachment_file_names` text DEFAULT NULL COMMENT '附件文件名称集合', | 1933 | `attachment_file_names` text DEFAULT NULL COMMENT '附件文件名称集合', |
| 1934 | + `change_status` varchar(50) DEFAULT NULL COMMENT '变更状态 CHANGING 变更中 CHANGED 变更完成', | ||
| 1935 | + `replenishment_status` varchar(50) DEFAULT NULL COMMENT '补单状态 REPLENISHING 补单中 REPLENISHED 补单完成', | ||
| 1934 | `create_by_id` varchar(32) DEFAULT NULL COMMENT '创建人ID', | 1936 | `create_by_id` varchar(32) DEFAULT NULL COMMENT '创建人ID', |
| 1935 | `create_by` varchar(64) DEFAULT NULL COMMENT '创建人', | 1937 | `create_by` varchar(64) DEFAULT NULL COMMENT '创建人', |
| 1936 | `update_by_id` varchar(32) DEFAULT NULL COMMENT '更新人ID', | 1938 | `update_by_id` varchar(32) DEFAULT NULL COMMENT '更新人ID', |
| @@ -334,6 +334,18 @@ public class GetProcurementPlanBo extends BaseBo<ProcurementPlan> { | @@ -334,6 +334,18 @@ public class GetProcurementPlanBo extends BaseBo<ProcurementPlan> { | ||
| 334 | private String planType; | 334 | private String planType; |
| 335 | 335 | ||
| 336 | /** | 336 | /** |
| 337 | + * 变更状态 空/未变更 CHANGING 变更中 CHANGED 变更完成 | ||
| 338 | + */ | ||
| 339 | + @ApiModelProperty("变更状态 空/未变更 CHANGING 变更中 CHANGED 变更完成") | ||
| 340 | + private String changeStatus; | ||
| 341 | + | ||
| 342 | + /** | ||
| 343 | + * 补单状态 空/未补单 REPLENISHING 补单中 REPLENISHED 补单完成 | ||
| 344 | + */ | ||
| 345 | + @ApiModelProperty("补单状态 空/未补单 REPLENISHING 补单中 REPLENISHED 补单完成") | ||
| 346 | + private String replenishmentStatus; | ||
| 347 | + | ||
| 348 | + /** | ||
| 337 | * 分厂ID | 349 | * 分厂ID |
| 338 | */ | 350 | */ |
| 339 | @ApiModelProperty("分厂ID") | 351 | @ApiModelProperty("分厂ID") |
| @@ -71,6 +71,28 @@ public class ProcurementPlanController extends DefaultBaseController { | @@ -71,6 +71,28 @@ public class ProcurementPlanController extends DefaultBaseController { | ||
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | /** | 73 | /** |
| 74 | + * 查询可以变更/补单的采购计划数据 | ||
| 75 | + */ | ||
| 76 | + @ApiOperation("查询可变更/补单列表") | ||
| 77 | + @HasPermission({"plan-manage:domestic-plan:query"}) | ||
| 78 | + @GetMapping("/queryCanChangeOrReplenishment") | ||
| 79 | + public InvokeResult<PageResult<GetProcurementPlanBo>> queryCanChangeOrReplenishment(@Valid QueryProcurementPlanVo vo) { | ||
| 80 | + | ||
| 81 | + PageResult<ProcurementPlan> pageResult = procurementPlanService.queryCanChangeOrReplenishmentList(getPageIndex(vo), | ||
| 82 | + getPageSize(vo), vo); | ||
| 83 | + | ||
| 84 | + List<ProcurementPlan> datas = pageResult.getDatas(); | ||
| 85 | + List<GetProcurementPlanBo> results = null; | ||
| 86 | + | ||
| 87 | + if (!CollectionUtil.isEmpty(datas)) { | ||
| 88 | + results = datas.stream().map(GetProcurementPlanBo::new).collect(Collectors.toList()); | ||
| 89 | + fillBuyoutButtons(results, datas); | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + return InvokeResultBuilder.success(PageResultUtil.rebuild(pageResult, results)); | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + /** | ||
| 74 | * 根据ID查询 | 96 | * 根据ID查询 |
| 75 | */ | 97 | */ |
| 76 | @ApiOperation("根据ID查询") | 98 | @ApiOperation("根据ID查询") |
| @@ -283,6 +283,16 @@ public class ProcurementPlan extends BaseEntity implements BaseDto { | @@ -283,6 +283,16 @@ public class ProcurementPlan extends BaseEntity implements BaseDto { | ||
| 283 | private String planType; | 283 | private String planType; |
| 284 | 284 | ||
| 285 | /** | 285 | /** |
| 286 | + * 变更状态 空/未变更 CHANGING 变更中 CHANGED 变更完成 | ||
| 287 | + */ | ||
| 288 | + private String changeStatus; | ||
| 289 | + | ||
| 290 | + /** | ||
| 291 | + * 补单状态 空/未补单 REPLENISHING 补单中 REPLENISHED 补单完成 | ||
| 292 | + */ | ||
| 293 | + private String replenishmentStatus; | ||
| 294 | + | ||
| 295 | + /** | ||
| 286 | * 分厂ID | 296 | * 分厂ID |
| 287 | */ | 297 | */ |
| 288 | private String workshopId; | 298 | private String workshopId; |
| 1 | package com.lframework.xingyun.sc.procurement.impl.change; | 1 | package com.lframework.xingyun.sc.procurement.impl.change; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.bean.BeanUtil; | 3 | import cn.hutool.core.bean.BeanUtil; |
| 4 | +import com.baomidou.mybatisplus.core.conditions.Wrapper; | ||
| 4 | import com.baomidou.mybatisplus.core.toolkit.Wrappers; | 5 | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| 5 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | 6 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| 6 | import com.github.pagehelper.PageInfo; | 7 | import com.github.pagehelper.PageInfo; |
| @@ -120,6 +121,11 @@ public class ProcurementPlanChangeServiceImpl extends | @@ -120,6 +121,11 @@ public class ProcurementPlanChangeServiceImpl extends | ||
| 120 | if (!CollectionUtil.isEmpty(lines)) { | 121 | if (!CollectionUtil.isEmpty(lines)) { |
| 121 | procurementPlanChangeLineService.saveBatch(lines); | 122 | procurementPlanChangeLineService.saveBatch(lines); |
| 122 | } | 123 | } |
| 124 | + //更新采购计划变更状态为 变更中 | ||
| 125 | + Wrapper<ProcurementPlan> parentWrapper = Wrappers.lambdaUpdate(ProcurementPlan.class) | ||
| 126 | + .set(ProcurementPlan::getChangeStatus, "CHANGING") | ||
| 127 | + .eq(ProcurementPlan::getId, vo.getProcurementPlanId()); | ||
| 128 | + procurementPlanService.update(parentWrapper); | ||
| 123 | 129 | ||
| 124 | return planChange.getId(); | 130 | return planChange.getId(); |
| 125 | } | 131 | } |
| @@ -94,6 +94,28 @@ public class ProcurementPlanServiceImpl extends BaseMpServiceImpl<ProcurementPla | @@ -94,6 +94,28 @@ public class ProcurementPlanServiceImpl extends BaseMpServiceImpl<ProcurementPla | ||
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | @Override | 96 | @Override |
| 97 | + public PageResult<ProcurementPlan> queryCanChangeOrReplenishmentList(Integer pageIndex, Integer pageSize, | ||
| 98 | + QueryProcurementPlanVo vo) { | ||
| 99 | + | ||
| 100 | + Assert.greaterThanZero(pageIndex); | ||
| 101 | + Assert.greaterThanZero(pageSize); | ||
| 102 | + | ||
| 103 | + PageHelperUtil.startPage(pageIndex, pageSize); | ||
| 104 | + List<ProcurementPlan> datas = this.queryCanChangeOrReplenishmentList(vo); | ||
| 105 | + if (org.apache.commons.collections.CollectionUtils.isNotEmpty(datas)) { | ||
| 106 | + fillShowExamineInfo(datas); | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + return PageResultUtil.convert(new PageInfo<>(datas)); | ||
| 110 | + } | ||
| 111 | + | ||
| 112 | + @Override | ||
| 113 | + public List<ProcurementPlan> queryCanChangeOrReplenishmentList(QueryProcurementPlanVo vo) { | ||
| 114 | + | ||
| 115 | + return getBaseMapper().queryCanChangeOrReplenishmentList(vo); | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + @Override | ||
| 97 | public GetProcurementPlanBo getDetail(String id) { | 119 | public GetProcurementPlanBo getDetail(String id) { |
| 98 | if (StringUtil.isBlank(id)) { | 120 | if (StringUtil.isBlank(id)) { |
| 99 | throw new InputErrorException("ID不能为空!"); | 121 | throw new InputErrorException("ID不能为空!"); |
| @@ -423,6 +445,32 @@ public class ProcurementPlanServiceImpl extends BaseMpServiceImpl<ProcurementPla | @@ -423,6 +445,32 @@ public class ProcurementPlanServiceImpl extends BaseMpServiceImpl<ProcurementPla | ||
| 423 | .set(ProcurementPlan::getProcessNode, approvalStatus.equals("PASS") ? null : "GYGLKZG") | 445 | .set(ProcurementPlan::getProcessNode, approvalStatus.equals("PASS") ? null : "GYGLKZG") |
| 424 | .eq(ProcurementPlan::getId, id); | 446 | .eq(ProcurementPlan::getId, id); |
| 425 | getBaseMapper().update(wrapper); | 447 | getBaseMapper().update(wrapper); |
| 448 | + | ||
| 449 | + //如果是子计划且审核通过,检查主计划下所有子计划是否都已通过 | ||
| 450 | + if ("PASS".equals(approvalStatus)) { | ||
| 451 | + ProcurementPlan currentPlan = this.getById(id); | ||
| 452 | + | ||
| 453 | + // 判断当前计划是否为子计划(parentId不为空) | ||
| 454 | + if (currentPlan != null && StringUtils.isNotBlank(currentPlan.getParentId())) { | ||
| 455 | + String parentId = currentPlan.getParentId(); | ||
| 456 | + | ||
| 457 | + // 查询主计划下,除了当前子计划外,是否还有未通过(非PASS状态)的子计划 | ||
| 458 | + long unApprovedCount = this.count(Wrappers.<ProcurementPlan>lambdaQuery() | ||
| 459 | + .eq(ProcurementPlan::getParentId, parentId) | ||
| 460 | + .ne(ProcurementPlan::getId, id) // 排除自己 | ||
| 461 | + .ne(ProcurementPlan::getApprovalStatus, "PASS") // 查找未通过的 | ||
| 462 | + ); | ||
| 463 | + | ||
| 464 | + // 如果未通过的数量为0,说明所有子计划都已审核通过 | ||
| 465 | + if (unApprovedCount == 0) { | ||
| 466 | + // 更新主计划的流程状态为 COMPLETED | ||
| 467 | + Wrapper<ProcurementPlan> parentWrapper = Wrappers.lambdaUpdate(ProcurementPlan.class) | ||
| 468 | + .set(ProcurementPlan::getProcessStatus, "COMPLETED") | ||
| 469 | + .eq(ProcurementPlan::getId, parentId); | ||
| 470 | + getBaseMapper().update(parentWrapper); | ||
| 471 | + } | ||
| 472 | + } | ||
| 473 | + } | ||
| 426 | } | 474 | } |
| 427 | 475 | ||
| 428 | @Transactional(rollbackFor = Exception.class) | 476 | @Transactional(rollbackFor = Exception.class) |
| @@ -535,6 +583,12 @@ public class ProcurementPlanServiceImpl extends BaseMpServiceImpl<ProcurementPla | @@ -535,6 +583,12 @@ public class ProcurementPlanServiceImpl extends BaseMpServiceImpl<ProcurementPla | ||
| 535 | getBaseMapper().update(updateWrapper); | 583 | getBaseMapper().update(updateWrapper); |
| 536 | } | 584 | } |
| 537 | 585 | ||
| 586 | + // 更新主计划状态为"已中止" | ||
| 587 | + LambdaUpdateWrapper<ProcurementPlan> updateWrapper = Wrappers.lambdaUpdate(ProcurementPlan.class) | ||
| 588 | + .set(ProcurementPlan::getProcessStatus, "ABORTED") | ||
| 589 | + .eq(ProcurementPlan::getId, mainPlanId); | ||
| 590 | + getBaseMapper().update(updateWrapper); | ||
| 591 | + | ||
| 538 | OpLogUtil.setVariable("id", id); | 592 | OpLogUtil.setVariable("id", id); |
| 539 | OpLogUtil.setExtra(currentPlan); | 593 | OpLogUtil.setExtra(currentPlan); |
| 540 | } | 594 | } |
| @@ -16,5 +16,13 @@ public interface ProcurementPlanMapper extends BaseMapper<ProcurementPlan> { | @@ -16,5 +16,13 @@ public interface ProcurementPlanMapper extends BaseMapper<ProcurementPlan> { | ||
| 16 | */ | 16 | */ |
| 17 | List<ProcurementPlan> query(@Param("vo") QueryProcurementPlanVo vo); | 17 | List<ProcurementPlan> query(@Param("vo") QueryProcurementPlanVo vo); |
| 18 | 18 | ||
| 19 | + /** | ||
| 20 | + * 查询可变更/可补单列表 | ||
| 21 | + * | ||
| 22 | + * @param vo | ||
| 23 | + * @return | ||
| 24 | + */ | ||
| 25 | + List<ProcurementPlan> queryCanChangeOrReplenishmentList(@Param("vo") QueryProcurementPlanVo vo); | ||
| 26 | + | ||
| 19 | ProcurementPlan findById(@Param("id") String id); | 27 | ProcurementPlan findById(@Param("id") String id); |
| 20 | } | 28 | } |
| @@ -22,6 +22,16 @@ public interface ProcurementPlanService extends BaseMpService<ProcurementPlan> { | @@ -22,6 +22,16 @@ public interface ProcurementPlanService extends BaseMpService<ProcurementPlan> { | ||
| 22 | PageResult<ProcurementPlan> query(Integer pageIndex, Integer pageSize, QueryProcurementPlanVo vo); | 22 | PageResult<ProcurementPlan> query(Integer pageIndex, Integer pageSize, QueryProcurementPlanVo vo); |
| 23 | 23 | ||
| 24 | /** | 24 | /** |
| 25 | + * 查询可变更/可补单列表 | ||
| 26 | + * | ||
| 27 | + * @param pageIndex | ||
| 28 | + * @param pageSize | ||
| 29 | + * @param vo | ||
| 30 | + * @return | ||
| 31 | + */ | ||
| 32 | + PageResult<ProcurementPlan> queryCanChangeOrReplenishmentList(Integer pageIndex, Integer pageSize, QueryProcurementPlanVo vo); | ||
| 33 | + | ||
| 34 | + /** | ||
| 25 | * 查询列表 | 35 | * 查询列表 |
| 26 | * | 36 | * |
| 27 | * @param vo | 37 | * @param vo |
| @@ -30,6 +40,14 @@ public interface ProcurementPlanService extends BaseMpService<ProcurementPlan> { | @@ -30,6 +40,14 @@ public interface ProcurementPlanService extends BaseMpService<ProcurementPlan> { | ||
| 30 | List<ProcurementPlan> query(QueryProcurementPlanVo vo); | 40 | List<ProcurementPlan> query(QueryProcurementPlanVo vo); |
| 31 | 41 | ||
| 32 | /** | 42 | /** |
| 43 | + * 查询可变更/可补单列表 | ||
| 44 | + * | ||
| 45 | + * @param vo | ||
| 46 | + * @return | ||
| 47 | + */ | ||
| 48 | + List<ProcurementPlan> queryCanChangeOrReplenishmentList(QueryProcurementPlanVo vo); | ||
| 49 | + | ||
| 50 | + /** | ||
| 33 | * 根据ID查询详情 | 51 | * 根据ID查询详情 |
| 34 | * | 52 | * |
| 35 | * @param id | 53 | * @param id |
| @@ -87,4 +87,12 @@ public class QueryProcurementPlanVo extends SortPageVo { | @@ -87,4 +87,12 @@ public class QueryProcurementPlanVo extends SortPageVo { | ||
| 87 | */ | 87 | */ |
| 88 | @ApiModelProperty("分厂ID") | 88 | @ApiModelProperty("分厂ID") |
| 89 | private String workshopId; | 89 | private String workshopId; |
| 90 | + | ||
| 91 | + /** | ||
| 92 | + * 查询类型 | ||
| 93 | + * CHANGE:变更 | ||
| 94 | + * REPLENISHMENT:补货 | ||
| 95 | + */ | ||
| 96 | + @ApiModelProperty("查询类型:CHANGE变更 REPLENISHMENT补货") | ||
| 97 | + private String queryType; | ||
| 90 | } | 98 | } |
| @@ -55,6 +55,8 @@ | @@ -55,6 +55,8 @@ | ||
| 55 | <result column="process_node" property="processNode"/> | 55 | <result column="process_node" property="processNode"/> |
| 56 | <result column="frozen" property="frozen"/> | 56 | <result column="frozen" property="frozen"/> |
| 57 | <result column="plan_type" property="planType"/> | 57 | <result column="plan_type" property="planType"/> |
| 58 | + <result column="change_status" property="changeStatus"/> | ||
| 59 | + <result column="replenishment_status" property="replenishmentStatus"/> | ||
| 58 | <result column="workshop_id" property="workshopId"/> | 60 | <result column="workshop_id" property="workshopId"/> |
| 59 | <result column="salesman_quotation_id" property="salesmanQuotationId"/> | 61 | <result column="salesman_quotation_id" property="salesmanQuotationId"/> |
| 60 | <result column="attachment_file_ids" property="attachmentFileIds"/> | 62 | <result column="attachment_file_ids" property="attachmentFileIds"/> |
| @@ -121,6 +123,8 @@ | @@ -121,6 +123,8 @@ | ||
| 121 | pp.process_node, | 123 | pp.process_node, |
| 122 | pp.frozen, | 124 | pp.frozen, |
| 123 | pp.plan_type, | 125 | pp.plan_type, |
| 126 | + pp.change_status, | ||
| 127 | + pp.replenishment_status, | ||
| 124 | pp.workshop_id, | 128 | pp.workshop_id, |
| 125 | pp.salesman_quotation_id, | 129 | pp.salesman_quotation_id, |
| 126 | pp.attachment_file_ids, | 130 | pp.attachment_file_ids, |
| @@ -195,4 +199,63 @@ | @@ -195,4 +199,63 @@ | ||
| 195 | <include refid="ProcurementPlan_sql"/> | 199 | <include refid="ProcurementPlan_sql"/> |
| 196 | WHERE pp.id = #{id} | 200 | WHERE pp.id = #{id} |
| 197 | </select> | 201 | </select> |
| 202 | + | ||
| 203 | + <select id="queryCanChangeOrReplenishmentList" resultMap="ProcurementPlan"> | ||
| 204 | + <include refid="ProcurementPlan_sql"/> | ||
| 205 | + <where> | ||
| 206 | + pp.parent_id IS NULL | ||
| 207 | + <if test="vo != null"> | ||
| 208 | + <if test="vo.code != null and vo.code != ''"> | ||
| 209 | + AND pp.code LIKE CONCAT('%', #{vo.code}, '%') | ||
| 210 | + </if> | ||
| 211 | + <if test="vo.companyShortId != null and vo.companyShortId != ''"> | ||
| 212 | + AND pp.company_short_id = #{vo.companyShortId} | ||
| 213 | + </if> | ||
| 214 | + <if test="vo.companyName != null and vo.companyName != ''"> | ||
| 215 | + AND ( | ||
| 216 | + bdcs.company_name LIKE CONCAT('%', #{vo.companyName}, '%') | ||
| 217 | + OR bdcs.short_name LIKE CONCAT('%', #{vo.companyName}, '%') | ||
| 218 | + ) | ||
| 219 | + </if> | ||
| 220 | + <if test="vo.purchaseDepartment != null and vo.purchaseDepartment != ''"> | ||
| 221 | + AND pp.purchase_department = #{vo.purchaseDepartment} | ||
| 222 | + </if> | ||
| 223 | + <if test="vo.startDate != null"> | ||
| 224 | + AND pp.date >= #{vo.startDate} | ||
| 225 | + </if> | ||
| 226 | + <if test="vo.endDate != null"> | ||
| 227 | + <![CDATA[ | ||
| 228 | + AND pp.date <= #{vo.endDate} | ||
| 229 | + ]]> | ||
| 230 | + </if> | ||
| 231 | + <if test="vo.supplierId != null and vo.supplierId != ''"> | ||
| 232 | + AND pp.supplier_id = #{vo.supplierId} | ||
| 233 | + </if> | ||
| 234 | + <if test="vo.supplierName != null and vo.supplierName != ''"> | ||
| 235 | + AND pdc.unit_name LIKE CONCAT('%', #{vo.supplierName}, '%') | ||
| 236 | + </if> | ||
| 237 | + <if test="vo.workshopId != null and vo.workshopId != ''"> | ||
| 238 | + AND pp.workshop_id = #{vo.workshopId} | ||
| 239 | + </if> | ||
| 240 | + <choose> | ||
| 241 | + <when test="vo.queryType == 'CHANGE'"> | ||
| 242 | + AND pp.process_status IN ('COMPLETED', 'ABORTED') | ||
| 243 | + AND (pp.change_status = '' OR pp.change_status IS NULL OR pp.change_status = 'CHANGED') | ||
| 244 | + AND (pp.replenishment_status = '' OR pp.replenishment_status IS NULL OR pp.replenishment_status | ||
| 245 | + = 'REPLENISHED') | ||
| 246 | + </when> | ||
| 247 | + <when test="vo.queryType == 'REPLENISHMENT'"> | ||
| 248 | + AND pp.process_status IN ('COMPLETED', 'ABORTED') | ||
| 249 | + AND (pp.replenishment_status = '' OR pp.replenishment_status IS NULL OR pp.replenishment_status | ||
| 250 | + = 'REPLENISHED') | ||
| 251 | + AND (pp.change_status = '' OR pp.change_status IS NULL OR pp.change_status = 'CHANGED') | ||
| 252 | + </when> | ||
| 253 | + <otherwise> | ||
| 254 | + AND 1 = 0 | ||
| 255 | + </otherwise> | ||
| 256 | + </choose> | ||
| 257 | + </if> | ||
| 258 | + </where> | ||
| 259 | + ORDER BY pp.create_time DESC | ||
| 260 | + </select> | ||
| 198 | </mapper> | 261 | </mapper> |