Showing
9 changed files
with
135 additions
and
0 deletions
| ... | ... | @@ -2624,6 +2624,7 @@ CREATE TABLE IF NOT EXISTS `procurement_assay_apply` |
| 2624 | 2624 | `product_name` varchar(200) DEFAULT NULL COMMENT '品种名称(冗余展示)', |
| 2625 | 2625 | `department` varchar(20) DEFAULT NULL COMMENT '科室 LABORATORY-化验室 METROLOGY-计量室', |
| 2626 | 2626 | `approval_status` varchar(50) DEFAULT NULL COMMENT '审核状态 DRAFT-草稿 AUDIT-审核中 PASS-审核通过 REFUSE-已驳回 CANCEL-已取消', |
| 2627 | + `deleted` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否作废 0-有效单 1-作废单(作废单只能查看)', | |
| 2627 | 2628 | `create_by_id` varchar(32) DEFAULT NULL COMMENT '创建人ID', |
| 2628 | 2629 | `create_by` varchar(64) DEFAULT NULL COMMENT '创建人', |
| 2629 | 2630 | `update_by_id` varchar(32) DEFAULT NULL COMMENT '更新人ID', | ... | ... |
| ... | ... | @@ -48,6 +48,9 @@ public class GetProcurementAssayApplyBo extends BaseBo<ProcurementAssayApply> { |
| 48 | 48 | @ApiModelProperty("审核状态 DRAFT/AUDIT/PASS/REFUSE/CANCEL") |
| 49 | 49 | private String approvalStatus; |
| 50 | 50 | |
| 51 | + @ApiModelProperty("是否作废单") | |
| 52 | + private Boolean deleted; | |
| 53 | + | |
| 51 | 54 | @ApiModelProperty("是否展示审核按钮") |
| 52 | 55 | private Boolean showExamine; |
| 53 | 56 | ... | ... |
| ... | ... | @@ -132,4 +132,13 @@ public class ProcurementAssayApplyController extends DefaultBaseController { |
| 132 | 132 | procurementAssayApplyService.cancel(id); |
| 133 | 133 | return InvokeResultBuilder.success(); |
| 134 | 134 | } |
| 135 | + | |
| 136 | + @ApiOperation("作废化验送样单(审核通过状态可作废,作废后只能查看)") | |
| 137 | + @ApiImplicitParam(value = "ID", name = "id", paramType = "query", required = true) | |
| 138 | + @HasPermission({"warehouse-manage:sample-submission:delete"}) | |
| 139 | + @PutMapping("/delete") | |
| 140 | + public InvokeResult<Void> delete(@NotBlank(message = "ID不能为空!") String id) { | |
| 141 | + procurementAssayApplyService.delete(id); | |
| 142 | + return InvokeResultBuilder.success(); | |
| 143 | + } | |
| 135 | 144 | } | ... | ... |
| ... | ... | @@ -80,6 +80,11 @@ public class ProcurementAssayApply extends BaseEntity implements BaseDto { |
| 80 | 80 | private String approvalStatus; |
| 81 | 81 | |
| 82 | 82 | /** |
| 83 | + * 是否作废/删除 0-有效单 1-作废单(作废单只能查看) | |
| 84 | + */ | |
| 85 | + private Boolean deleted; | |
| 86 | + | |
| 87 | + /** | |
| 83 | 88 | * 创建人ID |
| 84 | 89 | */ |
| 85 | 90 | @TableField(fill = FieldFill.INSERT) | ... | ... |
| ... | ... | @@ -6,6 +6,7 @@ import com.lframework.starter.bpm.dto.FlowTaskDto; |
| 6 | 6 | import com.lframework.starter.bpm.entity.FlowInstanceWrapper; |
| 7 | 7 | import com.lframework.starter.bpm.mappers.FlowTaskWrapperMapper; |
| 8 | 8 | import com.lframework.starter.bpm.service.FlowInstanceWrapperService; |
| 9 | +import com.lframework.starter.bpm.service.FlowTaskWrapperService; | |
| 9 | 10 | import com.lframework.starter.bpm.vo.flow.task.QueryTodoTaskListVo; |
| 10 | 11 | import com.lframework.starter.common.exceptions.impl.DefaultClientException; |
| 11 | 12 | import com.lframework.starter.common.exceptions.impl.InputErrorException; |
| ... | ... | @@ -94,6 +95,9 @@ public class ProcurementAssayApplyServiceImpl |
| 94 | 95 | @Resource |
| 95 | 96 | private FlowTaskWrapperMapper flowTaskWrapperMapper; |
| 96 | 97 | |
| 98 | + @Resource | |
| 99 | + private FlowTaskWrapperService flowTaskWrapperService; | |
| 100 | + | |
| 97 | 101 | @Override |
| 98 | 102 | public PageResult<ProcurementAssayApply> query(Integer pageIndex, Integer pageSize, |
| 99 | 103 | QueryProcurementAssayApplyVo vo) { |
| ... | ... | @@ -217,6 +221,8 @@ public class ProcurementAssayApplyServiceImpl |
| 217 | 221 | if (oldEntity == null) { |
| 218 | 222 | throw new DefaultClientException("化验送样单不存在!"); |
| 219 | 223 | } |
| 224 | + // 作废单只能查看 | |
| 225 | + assertValid(oldEntity); | |
| 220 | 226 | // 仅草稿、已驳回可修改;审核中、审核通过、已取消不可修改 |
| 221 | 227 | assertEditable(oldEntity); |
| 222 | 228 | |
| ... | ... | @@ -240,6 +246,8 @@ public class ProcurementAssayApplyServiceImpl |
| 240 | 246 | if (entity == null) { |
| 241 | 247 | throw new DefaultClientException("化验送样单不存在!"); |
| 242 | 248 | } |
| 249 | + // 作废单只能查看 | |
| 250 | + assertValid(entity); | |
| 243 | 251 | if (!STATUS_DRAFT.equals(entity.getApprovalStatus()) && !STATUS_REFUSE.equals(entity.getApprovalStatus())) { |
| 244 | 252 | throw new DefaultClientException("当前单据状态不允许提交审核!"); |
| 245 | 253 | } |
| ... | ... | @@ -267,6 +275,8 @@ public class ProcurementAssayApplyServiceImpl |
| 267 | 275 | if (entity == null) { |
| 268 | 276 | throw new DefaultClientException("化验送样单不存在!"); |
| 269 | 277 | } |
| 278 | + // 作废单只能查看 | |
| 279 | + assertValid(entity); | |
| 270 | 280 | if (!STATUS_REFUSE.equals(entity.getApprovalStatus())) { |
| 271 | 281 | throw new DefaultClientException("只有已驳回的化验送样单可以取消!"); |
| 272 | 282 | } |
| ... | ... | @@ -281,6 +291,75 @@ public class ProcurementAssayApplyServiceImpl |
| 281 | 291 | |
| 282 | 292 | @Override |
| 283 | 293 | @Transactional(rollbackFor = Exception.class) |
| 294 | + @OpLog(type = OtherOpLogType.class, name = "作废化验送样单,ID:{}", params = {"#id"}) | |
| 295 | + public void delete(String id) { | |
| 296 | + Assert.notBlank(id); | |
| 297 | + | |
| 298 | + ProcurementAssayApply entity = assayApplyMapper.findById(id); | |
| 299 | + if (entity == null) { | |
| 300 | + throw new DefaultClientException("化验送样单不存在!"); | |
| 301 | + } | |
| 302 | + // 作废单只能查看 | |
| 303 | + assertValid(entity); | |
| 304 | + | |
| 305 | + // 审核中的单据需要先终止流程,再作废;其余状态直接作废 | |
| 306 | + if (STATUS_AUDIT.equals(entity.getApprovalStatus())) { | |
| 307 | + terminateRunningFlow(id); | |
| 308 | + } | |
| 309 | + | |
| 310 | + this.update(Wrappers.lambdaUpdate(ProcurementAssayApply.class) | |
| 311 | + .set(ProcurementAssayApply::getDeleted, true) | |
| 312 | + .eq(ProcurementAssayApply::getId, id)); | |
| 313 | + | |
| 314 | + OpLogUtil.setVariable("id", id); | |
| 315 | + OpLogUtil.setExtra(entity); | |
| 316 | + } | |
| 317 | + | |
| 318 | + @Override | |
| 319 | + @Transactional(rollbackFor = Exception.class) | |
| 320 | + public void deleteByWeighingTicketId(String weighingTicketId) { | |
| 321 | + if (StringUtil.isBlank(weighingTicketId)) { | |
| 322 | + return; | |
| 323 | + } | |
| 324 | + | |
| 325 | + // 该码单下所有未作废的化验送样单,联动作废 | |
| 326 | + List<ProcurementAssayApply> applies = this.list( | |
| 327 | + Wrappers.lambdaQuery(ProcurementAssayApply.class) | |
| 328 | + .eq(ProcurementAssayApply::getWeighingTicketId, weighingTicketId) | |
| 329 | + .eq(ProcurementAssayApply::getDeleted, false)); | |
| 330 | + if (CollectionUtil.isEmpty(applies)) { | |
| 331 | + return; | |
| 332 | + } | |
| 333 | + | |
| 334 | + for (ProcurementAssayApply apply : applies) { | |
| 335 | + // 审核中的先终止流程,再作废 | |
| 336 | + if (STATUS_AUDIT.equals(apply.getApprovalStatus())) { | |
| 337 | + terminateRunningFlow(apply.getId()); | |
| 338 | + } | |
| 339 | + this.update(Wrappers.lambdaUpdate(ProcurementAssayApply.class) | |
| 340 | + .set(ProcurementAssayApply::getDeleted, true) | |
| 341 | + .set(STATUS_AUDIT.equals(apply.getApprovalStatus()), ProcurementAssayApply::getApprovalStatus, STATUS_REFUSE) | |
| 342 | + .eq(ProcurementAssayApply::getId, apply.getId())); | |
| 343 | + } | |
| 344 | + } | |
| 345 | + | |
| 346 | + /** | |
| 347 | + * 终止单据进行中的审核流程(作废审核中的单据前先终止流程) | |
| 348 | + */ | |
| 349 | + private void terminateRunningFlow(String businessId) { | |
| 350 | + List<FlowInstanceWrapper> flowList = flowInstanceWrapperService.getFlowByBusinessIdList( | |
| 351 | + Collections.singletonList(businessId)); | |
| 352 | + if (CollectionUtil.isEmpty(flowList)) { | |
| 353 | + return; | |
| 354 | + } | |
| 355 | + flowList.stream() | |
| 356 | + .filter(f -> f != null && f.getId() != null) | |
| 357 | + .findFirst() | |
| 358 | + .ifPresent(flow -> flowTaskWrapperService.termination(flow.getId())); | |
| 359 | + } | |
| 360 | + | |
| 361 | + @Override | |
| 362 | + @Transactional(rollbackFor = Exception.class) | |
| 284 | 363 | public void updateApprovalStatus(String id, String approvalStatus) { |
| 285 | 364 | if (StringUtil.isBlank(id) || StringUtil.isBlank(approvalStatus)) { |
| 286 | 365 | throw new DefaultClientException("化验送样单ID、审核状态不能为空!"); |
| ... | ... | @@ -356,6 +435,15 @@ public class ProcurementAssayApplyServiceImpl |
| 356 | 435 | } |
| 357 | 436 | |
| 358 | 437 | /** |
| 438 | + * 作废单校验:作废单只能查看 | |
| 439 | + */ | |
| 440 | + private void assertValid(ProcurementAssayApply entity) { | |
| 441 | + if (Boolean.TRUE.equals(entity.getDeleted())) { | |
| 442 | + throw new DefaultClientException("作废单据只能查看,不允许该操作!"); | |
| 443 | + } | |
| 444 | + } | |
| 445 | + | |
| 446 | + /** | |
| 359 | 447 | * 编辑校验:仅草稿、已驳回可修改 |
| 360 | 448 | */ |
| 361 | 449 | private void assertEditable(ProcurementAssayApply entity) { | ... | ... |
| ... | ... | @@ -38,6 +38,7 @@ import com.lframework.xingyun.sc.procurement.entity.weighing.ProcurementWeighing |
| 38 | 38 | import com.lframework.xingyun.sc.procurement.mappers.weighing.ProcurementWeighingTicketMapper; |
| 39 | 39 | import com.lframework.xingyun.sc.procurement.service.plan.ProcurementPlanLineService; |
| 40 | 40 | import com.lframework.xingyun.sc.procurement.service.plan.ProcurementPlanService; |
| 41 | +import com.lframework.xingyun.sc.procurement.service.weighing.ProcurementAssayApplyService; | |
| 41 | 42 | import com.lframework.xingyun.sc.procurement.service.weighing.ProcurementWeighingTicketApplyLineService; |
| 42 | 43 | import com.lframework.xingyun.sc.procurement.service.weighing.ProcurementWeighingTicketLineService; |
| 43 | 44 | import com.lframework.xingyun.sc.procurement.service.weighing.ProcurementWeighingTicketPlanService; |
| ... | ... | @@ -111,6 +112,8 @@ public class ProcurementWeighingTicketServiceImpl |
| 111 | 112 | private FlowInstanceWrapperService flowInstanceWrapperService; |
| 112 | 113 | @Resource |
| 113 | 114 | private FlowTaskWrapperMapper flowTaskWrapperMapper; |
| 115 | + @Resource | |
| 116 | + private ProcurementAssayApplyService assayApplyService; | |
| 114 | 117 | |
| 115 | 118 | @Override |
| 116 | 119 | public PageResult<ProcurementWeighingTicket> query(Integer pageIndex, Integer pageSize, |
| ... | ... | @@ -552,6 +555,9 @@ public class ProcurementWeighingTicketServiceImpl |
| 552 | 555 | // 作废后重算关联采购计划的差值标识(该码单的过磅数量不再纳入计算) |
| 553 | 556 | recalcPlanDiffFlags(collectPlanIdsByTicketId(id)); |
| 554 | 557 | |
| 558 | + // 联动作废该码单关联的化验送样单(审核中的先终止流程再作废) | |
| 559 | + assayApplyService.deleteByWeighingTicketId(id); | |
| 560 | + | |
| 555 | 561 | OpLogUtil.setVariable("id", id); |
| 556 | 562 | OpLogUtil.setExtra(entity); |
| 557 | 563 | } | ... | ... |
| ... | ... | @@ -67,6 +67,16 @@ public interface ProcurementAssayApplyService extends BaseMpService<ProcurementA |
| 67 | 67 | void cancel(String id); |
| 68 | 68 | |
| 69 | 69 | /** |
| 70 | + * 作废化验送样单(所有审核状态均可作废;审核中的先终止流程再作废,作废后只能查看) | |
| 71 | + */ | |
| 72 | + void delete(String id); | |
| 73 | + | |
| 74 | + /** | |
| 75 | + * 过磅码单作废时联动作废该码单下所有未作废的化验送样单(审核中的先终止流程再作废) | |
| 76 | + */ | |
| 77 | + void deleteByWeighingTicketId(String weighingTicketId); | |
| 78 | + | |
| 79 | + /** | |
| 70 | 80 | * 审核流程回调更新审核状态(流程结束时由 BusinessDataHandlerService 调用) |
| 71 | 81 | * |
| 72 | 82 | * @param id 化验送样单ID | ... | ... |
| ... | ... | @@ -29,6 +29,9 @@ public class QueryProcurementAssayApplyVo extends SortPageVo implements Serializ |
| 29 | 29 | @ApiModelProperty("审核状态 DRAFT/AUDIT/PASS/REFUSE/CANCEL") |
| 30 | 30 | private String approvalStatus; |
| 31 | 31 | |
| 32 | + @ApiModelProperty("是否作废单 true=作废单 false=有效单,不传默认查有效单") | |
| 33 | + private Boolean deleted; | |
| 34 | + | |
| 32 | 35 | @ApiModelProperty("创建人(模糊匹配)") |
| 33 | 36 | private String createBy; |
| 34 | 37 | ... | ... |
| ... | ... | @@ -15,6 +15,7 @@ |
| 15 | 15 | <result column="product_name" property="productName"/> |
| 16 | 16 | <result column="department" property="department"/> |
| 17 | 17 | <result column="approval_status" property="approvalStatus"/> |
| 18 | + <result column="deleted" property="deleted"/> | |
| 18 | 19 | <result column="create_by_id" property="createById"/> |
| 19 | 20 | <result column="create_by" property="createBy"/> |
| 20 | 21 | <result column="update_by_id" property="updateById"/> |
| ... | ... | @@ -37,6 +38,7 @@ |
| 37 | 38 | paa.product_name, |
| 38 | 39 | paa.department, |
| 39 | 40 | paa.approval_status, |
| 41 | + paa.deleted, | |
| 40 | 42 | paa.create_by_id, |
| 41 | 43 | paa.create_by, |
| 42 | 44 | paa.update_by_id, |
| ... | ... | @@ -50,6 +52,14 @@ |
| 50 | 52 | <select id="query" resultMap="ProcurementAssayApplyResult"> |
| 51 | 53 | <include refid="PAA_sql"/> |
| 52 | 54 | <where> |
| 55 | + <choose> | |
| 56 | + <when test="vo.deleted != null"> | |
| 57 | + AND paa.deleted = #{vo.deleted} | |
| 58 | + </when> | |
| 59 | + <otherwise> | |
| 60 | + AND paa.deleted = 0 | |
| 61 | + </otherwise> | |
| 62 | + </choose> | |
| 53 | 63 | <if test="vo.weighingTicketCode != null and vo.weighingTicketCode != ''"> |
| 54 | 64 | AND paa.weighing_ticket_code LIKE CONCAT('%', #{vo.weighingTicketCode}, '%') |
| 55 | 65 | </if> | ... | ... |