|
1
|
package com.lframework.xingyun.sc.procurement.impl.fundpayment;
|
1
|
package com.lframework.xingyun.sc.procurement.impl.fundpayment;
|
|
2
|
|
2
|
|
|
3
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
4
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
3
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
5
|
import com.github.pagehelper.PageInfo;
|
4
|
import com.github.pagehelper.PageInfo;
|
|
6
|
import com.lframework.starter.bpm.dto.FlowTaskDto;
|
5
|
import com.lframework.starter.bpm.dto.FlowTaskDto;
|
|
@@ -170,6 +169,8 @@ public class FundPaymentRequestServiceImpl |
|
@@ -170,6 +169,8 @@ public class FundPaymentRequestServiceImpl |
|
170
|
if (entity == null) {
|
169
|
if (entity == null) {
|
|
171
|
// 能自动带出/计算的字段直接落库,申请金额等需人工填写的字段留空,由前端修改请款单时补充
|
170
|
// 能自动带出/计算的字段直接落库,申请金额等需人工填写的字段留空,由前端修改请款单时补充
|
|
172
|
entity = buildDraft(source, sourceId, null);
|
171
|
entity = buildDraft(source, sourceId, null);
|
|
|
|
172
|
+ } else {
|
|
|
|
173
|
+ throw new DefaultClientException("该过磅码单已存在在途请款单,审核通过后再生成下一张请款单!");
|
|
173
|
}
|
174
|
}
|
|
174
|
|
175
|
|
|
175
|
OpLogUtil.setVariable("id", entity.getId());
|
176
|
OpLogUtil.setVariable("id", entity.getId());
|
|
@@ -343,6 +344,31 @@ public class FundPaymentRequestServiceImpl |
|
@@ -343,6 +344,31 @@ public class FundPaymentRequestServiceImpl |
|
343
|
|
344
|
|
|
344
|
@Override
|
345
|
@Override
|
|
345
|
@Transactional(rollbackFor = Exception.class)
|
346
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
347
|
+ @OpLog(type = OtherOpLogType.class, name = "取消资金支付请款单,ID:{}", params = {"#id"})
|
|
|
|
348
|
+ public void cancel(String id) {
|
|
|
|
349
|
+ Assert.notBlank(id);
|
|
|
|
350
|
+
|
|
|
|
351
|
+ FundPaymentRequest entity = this.getById(id);
|
|
|
|
352
|
+ if (entity == null) {
|
|
|
|
353
|
+ throw new DefaultClientException("请款单不存在!");
|
|
|
|
354
|
+ }
|
|
|
|
355
|
+ assertValid(entity);
|
|
|
|
356
|
+ if (!STATUS_DRAFT.equals(entity.getApprovalStatus()) && !STATUS_REFUSE.equals(entity.getApprovalStatus())) {
|
|
|
|
357
|
+ throw new DefaultClientException("当前单据状态不允许取消!");
|
|
|
|
358
|
+ }
|
|
|
|
359
|
+
|
|
|
|
360
|
+ this.update(Wrappers.lambdaUpdate(FundPaymentRequest.class)
|
|
|
|
361
|
+ .set(FundPaymentRequest::getDeleted, true)
|
|
|
|
362
|
+ .set(FundPaymentRequest::getFlowNode, null)
|
|
|
|
363
|
+ .set(FundPaymentRequest::getApprovalStatus, "CANCEL")
|
|
|
|
364
|
+ .eq(FundPaymentRequest::getId, id));
|
|
|
|
365
|
+
|
|
|
|
366
|
+ OpLogUtil.setVariable("id", id);
|
|
|
|
367
|
+ OpLogUtil.setExtra(entity);
|
|
|
|
368
|
+ }
|
|
|
|
369
|
+
|
|
|
|
370
|
+ @Override
|
|
|
|
371
|
+ @Transactional(rollbackFor = Exception.class)
|
|
346
|
@OpLog(type = OtherOpLogType.class, name = "作废资金支付请款单,ID:{}", params = {"#id"})
|
372
|
@OpLog(type = OtherOpLogType.class, name = "作废资金支付请款单,ID:{}", params = {"#id"})
|
|
347
|
public void invalid(String id) {
|
373
|
public void invalid(String id) {
|
|
348
|
Assert.notBlank(id);
|
374
|
Assert.notBlank(id);
|
|
@@ -406,49 +432,6 @@ public class FundPaymentRequestServiceImpl |
|
@@ -406,49 +432,6 @@ public class FundPaymentRequestServiceImpl |
|
406
|
|
432
|
|
|
407
|
@Override
|
433
|
@Override
|
|
408
|
@Transactional(rollbackFor = Exception.class)
|
434
|
@Transactional(rollbackFor = Exception.class)
|
|
409
|
- public void updateNoFlowInstance(Map<String, Object> map) {
|
|
|
|
410
|
- try {
|
|
|
|
411
|
- // 审核状态
|
|
|
|
412
|
- Object examStatusObj = map.get("examStatus");
|
|
|
|
413
|
- String examStatus = examStatusObj == null ? null : String.valueOf(examStatusObj);
|
|
|
|
414
|
-
|
|
|
|
415
|
- // 刚审核完成的环节编码
|
|
|
|
416
|
- Object nodeObj = map.get("nodeCode");
|
|
|
|
417
|
- String nodeCode = nodeObj == null ? null : String.valueOf(nodeObj);
|
|
|
|
418
|
-
|
|
|
|
419
|
- // 业务ID(兼容 variables 子 map 包裹)
|
|
|
|
420
|
- String bizId = resolveBizId(map);
|
|
|
|
421
|
- if (StringUtil.isBlank(bizId)) {
|
|
|
|
422
|
- throw new DefaultClientException("请款单审核回调缺少业务ID!");
|
|
|
|
423
|
- }
|
|
|
|
424
|
-
|
|
|
|
425
|
- boolean gyglkzgNode = nodeCode != null && nodeCode.endsWith("gyglkzg");
|
|
|
|
426
|
- if (!gyglkzgNode) {
|
|
|
|
427
|
- return;
|
|
|
|
428
|
- }
|
|
|
|
429
|
-
|
|
|
|
430
|
- // 拒绝/撤销/终止:统一回到供应管理科资金管理员(制单)
|
|
|
|
431
|
- if (StringUtil.isNotBlank(examStatus) && !"PASS".equals(examStatus)) {
|
|
|
|
432
|
- this.update(Wrappers.lambdaUpdate(FundPaymentRequest.class)
|
|
|
|
433
|
- .set(FundPaymentRequest::getFlowNode, NODE_GYGLKZJY)
|
|
|
|
434
|
- .eq(FundPaymentRequest::getId, bizId));
|
|
|
|
435
|
- return;
|
|
|
|
436
|
- }
|
|
|
|
437
|
-
|
|
|
|
438
|
- // 审核通过:记录供应管理科主管审核人
|
|
|
|
439
|
- String userId = SecurityUtil.getCurrentUser().getId();
|
|
|
|
440
|
- String userName = SecurityUtil.getCurrentUser().getName();
|
|
|
|
441
|
- this.update(Wrappers.lambdaUpdate(FundPaymentRequest.class)
|
|
|
|
442
|
- .set(FundPaymentRequest::getGyglkzgId, userId)
|
|
|
|
443
|
- .set(FundPaymentRequest::getGyglkzgName, userName)
|
|
|
|
444
|
- .eq(FundPaymentRequest::getId, bizId));
|
|
|
|
445
|
- } catch (Exception ex) {
|
|
|
|
446
|
- ex.printStackTrace();
|
|
|
|
447
|
- }
|
|
|
|
448
|
- }
|
|
|
|
449
|
-
|
|
|
|
450
|
- @Override
|
|
|
|
451
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
|
452
|
public void deleteByWeighingTicketId(String weighingTicketId) {
|
435
|
public void deleteByWeighingTicketId(String weighingTicketId) {
|
|
453
|
if (StringUtil.isBlank(weighingTicketId)) {
|
436
|
if (StringUtil.isBlank(weighingTicketId)) {
|
|
454
|
return;
|
437
|
return;
|
|
@@ -540,9 +523,8 @@ public class FundPaymentRequestServiceImpl |
|
@@ -540,9 +523,8 @@ public class FundPaymentRequestServiceImpl |
|
540
|
context.setWorkshopName(ticket.getWorkshopName());
|
523
|
context.setWorkshopName(ticket.getWorkshopName());
|
|
541
|
context.setTicketId(ticket.getId());
|
524
|
context.setTicketId(ticket.getId());
|
|
542
|
context.setTicketCode(ticket.getCode());
|
525
|
context.setTicketCode(ticket.getCode());
|
|
543
|
- // 同一码单存在审核通过的请款单时,本次生成为补充请款单
|
|
|
|
544
|
- context.setRequestKind(hasPassedRequest(r -> r.eq(FundPaymentRequest::getTicketId, ticket.getId()))
|
|
|
|
545
|
- ? KIND_SUPPLEMENT : KIND_NORMAL);
|
526
|
+ // 送货到厂-正常:在过磅码单生成请款单可生成多张(第一张审核通过后才能生成下一张,界限值依次扣减),均为正常请款单
|
|
|
|
527
|
+ context.setRequestKind(KIND_NORMAL);
|
|
546
|
return context;
|
528
|
return context;
|
|
547
|
}
|
529
|
}
|
|
548
|
|
530
|
|
|
@@ -573,12 +555,12 @@ public class FundPaymentRequestServiceImpl |
|
@@ -573,12 +555,12 @@ public class FundPaymentRequestServiceImpl |
|
573
|
context.setTicketId(receive.getWeighingTicketId());
|
555
|
context.setTicketId(receive.getWeighingTicketId());
|
|
574
|
context.setTicketCode(receive.getWeighingTicketCode());
|
556
|
context.setTicketCode(receive.getWeighingTicketCode());
|
|
575
|
context.setReceiveId(receive.getId());
|
557
|
context.setReceiveId(receive.getId());
|
|
576
|
- // 补充请款单只针对送货到厂正常:同一码单链上已有审核通过的码单请款单时,收料单尾款视为补充;
|
|
|
|
577
|
- // 买断自提尾款、退料收料单均为正常请款单,不要求填写补充说明及附件
|
|
|
|
578
|
- boolean supplement = DELIVERY_MODE_FACTORY_DELIVERY.equals(context.getBizType())
|
|
|
|
579
|
- && StringUtil.isNotBlank(context.getTicketId())
|
|
|
|
580
|
- && hasPassedRequest(r -> r.eq(FundPaymentRequest::getSource, SOURCE_TICKET)
|
|
|
|
581
|
- .eq(FundPaymentRequest::getTicketId, context.getTicketId()));
|
558
|
+ // 过磅码单类型为退料换料(RETURN)的才是补充请款单(在仓库收料单生成,只生成一张);其余均为正常请款单
|
|
|
|
559
|
+ boolean supplement = false;
|
|
|
|
560
|
+ if (StringUtil.isNotBlank(receive.getWeighingTicketId())) {
|
|
|
|
561
|
+ ProcurementWeighingTicket linkedTicket = weighingTicketMapper.selectById(receive.getWeighingTicketId());
|
|
|
|
562
|
+ supplement = linkedTicket != null && "RETURN".equals(linkedTicket.getType());
|
|
|
|
563
|
+ }
|
|
582
|
context.setRequestKind(supplement ? KIND_SUPPLEMENT : KIND_NORMAL);
|
564
|
context.setRequestKind(supplement ? KIND_SUPPLEMENT : KIND_NORMAL);
|
|
583
|
return context;
|
565
|
return context;
|
|
584
|
}
|
566
|
}
|
|
@@ -809,17 +791,6 @@ public class FundPaymentRequestServiceImpl |
|
@@ -809,17 +791,6 @@ public class FundPaymentRequestServiceImpl |
|
809
|
}
|
791
|
}
|
|
810
|
|
792
|
|
|
811
|
/**
|
793
|
/**
|
|
812
|
- * 条件存在审核通过请款单(简单条件封装)
|
|
|
|
813
|
- */
|
|
|
|
814
|
- private boolean hasPassedRequest(java.util.function.Consumer<LambdaQueryWrapper<FundPaymentRequest>> condition) {
|
|
|
|
815
|
- LambdaQueryWrapper<FundPaymentRequest> wrapper = Wrappers.lambdaQuery(FundPaymentRequest.class)
|
|
|
|
816
|
- .eq(FundPaymentRequest::getApprovalStatus, STATUS_PASS)
|
|
|
|
817
|
- .eq(FundPaymentRequest::getDeleted, false);
|
|
|
|
818
|
- condition.accept(wrapper);
|
|
|
|
819
|
- return this.count(wrapper) > 0;
|
|
|
|
820
|
- }
|
|
|
|
821
|
-
|
|
|
|
822
|
- /**
|
|
|
|
823
|
* 保存明细并回填主表合计(合计预付/合计申请)
|
794
|
* 保存明细并回填主表合计(合计预付/合计申请)
|
|
824
|
*/
|
795
|
*/
|
|
825
|
private void saveLines(String requestId, List<FundPaymentRequestLine> lines) {
|
796
|
private void saveLines(String requestId, List<FundPaymentRequestLine> lines) {
|
|
@@ -904,7 +875,7 @@ public class FundPaymentRequestServiceImpl |
|
@@ -904,7 +875,7 @@ public class FundPaymentRequestServiceImpl |
|
904
|
* 来源单可用性校验:计划(买断自提首付款)
|
875
|
* 来源单可用性校验:计划(买断自提首付款)
|
|
905
|
*/
|
876
|
*/
|
|
906
|
private ProcurementPlan assertPlanUsable(String planId) {
|
877
|
private ProcurementPlan assertPlanUsable(String planId) {
|
|
907
|
- ProcurementPlan plan = procurementPlanMapper.selectById(planId);
|
878
|
+ ProcurementPlan plan = procurementPlanMapper.findById(planId);
|
|
908
|
if (plan == null || Boolean.TRUE.equals(plan.getDeleted())) {
|
879
|
if (plan == null || Boolean.TRUE.equals(plan.getDeleted())) {
|
|
909
|
throw new DefaultClientException("采购计划不存在!");
|
880
|
throw new DefaultClientException("采购计划不存在!");
|
|
910
|
}
|
881
|
}
|
|
@@ -962,6 +933,14 @@ public class FundPaymentRequestServiceImpl |
|
@@ -962,6 +933,14 @@ public class FundPaymentRequestServiceImpl |
|
962
|
if (occupied > 0) {
|
933
|
if (occupied > 0) {
|
|
963
|
throw new DefaultClientException("该过磅码单已存在在途请款单,审核通过后再生成下一张请款单!");
|
934
|
throw new DefaultClientException("该过磅码单已存在在途请款单,审核通过后再生成下一张请款单!");
|
|
964
|
}
|
935
|
}
|
|
|
|
936
|
+ // 同一码单在仓库收料单阶段已生成有效请款单(尾款/一次性结算)时,码单阶段不允许再生成请款单
|
|
|
|
937
|
+ int receiveOccupied = this.count(Wrappers.lambdaQuery(FundPaymentRequest.class)
|
|
|
|
938
|
+ .eq(FundPaymentRequest::getSource, SOURCE_RECEIVE)
|
|
|
|
939
|
+ .eq(FundPaymentRequest::getTicketId, ticketId)
|
|
|
|
940
|
+ .eq(FundPaymentRequest::getDeleted, false));
|
|
|
|
941
|
+ if (receiveOccupied > 0) {
|
|
|
|
942
|
+ throw new DefaultClientException("该过磅码单已在仓库收料单生成有效请款单(尾款),不允许再生成请款单!");
|
|
|
|
943
|
+ }
|
|
965
|
return ticket;
|
944
|
return ticket;
|
|
966
|
}
|
945
|
}
|
|
967
|
|
946
|
|
|
@@ -990,7 +969,32 @@ public class FundPaymentRequestServiceImpl |
|
@@ -990,7 +969,32 @@ public class FundPaymentRequestServiceImpl |
|
990
|
.eq(FundPaymentRequest::getReceiveId, receiveId)
|
969
|
.eq(FundPaymentRequest::getReceiveId, receiveId)
|
|
991
|
.eq(FundPaymentRequest::getDeleted, false));
|
970
|
.eq(FundPaymentRequest::getDeleted, false));
|
|
992
|
if (occupied > 0) {
|
971
|
if (occupied > 0) {
|
|
993
|
- throw new DefaultClientException("该仓库收料单已存在请款单,同一时间只能生成一张请款单!");
|
972
|
+ throw new DefaultClientException("该仓库收料单已存在请款单,不允许重复生成!");
|
|
|
|
973
|
+ }
|
|
|
|
974
|
+ // 退料换料码单的补充请款单只生成一张(同码单链维度占用)
|
|
|
|
975
|
+ if (StringUtil.isNotBlank(receive.getWeighingTicketId())) {
|
|
|
|
976
|
+ ProcurementWeighingTicket linkedTicket = weighingTicketMapper.selectById(receive.getWeighingTicketId());
|
|
|
|
977
|
+ if (linkedTicket != null && "RETURN".equals(linkedTicket.getType())) {
|
|
|
|
978
|
+ int supplementOccupied = this.count(Wrappers.lambdaQuery(FundPaymentRequest.class)
|
|
|
|
979
|
+ .eq(FundPaymentRequest::getSource, SOURCE_RECEIVE)
|
|
|
|
980
|
+ .eq(FundPaymentRequest::getTicketId, receive.getWeighingTicketId())
|
|
|
|
981
|
+ .eq(FundPaymentRequest::getDeleted, false));
|
|
|
|
982
|
+ if (supplementOccupied > 0) {
|
|
|
|
983
|
+ throw new DefaultClientException("该退料换料码单已生成过补充请款单,不允许重复生成!");
|
|
|
|
984
|
+ }
|
|
|
|
985
|
+ }
|
|
|
|
986
|
+ }
|
|
|
|
987
|
+ // 过磅码单阶段存在在途(草稿/审核中/已驳回)请款单时,不允许在收料单生成请款单;
|
|
|
|
988
|
+ // 码单阶段所有请款单(除作废的外)全部审核通过后才能生成尾款请款单
|
|
|
|
989
|
+ if (StringUtil.isNotBlank(receive.getWeighingTicketId())) {
|
|
|
|
990
|
+ int inFlightTicketRequest = this.count(Wrappers.lambdaQuery(FundPaymentRequest.class)
|
|
|
|
991
|
+ .eq(FundPaymentRequest::getSource, SOURCE_TICKET)
|
|
|
|
992
|
+ .eq(FundPaymentRequest::getTicketId, receive.getWeighingTicketId())
|
|
|
|
993
|
+ .eq(FundPaymentRequest::getDeleted, false)
|
|
|
|
994
|
+ .in(FundPaymentRequest::getApprovalStatus, STATUS_DRAFT, STATUS_AUDIT, STATUS_REFUSE));
|
|
|
|
995
|
+ if (inFlightTicketRequest > 0) {
|
|
|
|
996
|
+ throw new DefaultClientException("该过磅码单存在未审核通过的请款单,全部审核通过后才能在仓库收料单生成请款单!");
|
|
|
|
997
|
+ }
|
|
994
|
}
|
998
|
}
|
|
995
|
// 买断自提专属规则:结算比例100%(含未维护)时首付款已含全款,收料单不展示申请按钮、无尾款可请;
|
999
|
// 买断自提专属规则:结算比例100%(含未维护)时首付款已含全款,收料单不展示申请按钮、无尾款可请;
|
|
996
|
// 且一个计划分多车时只允许在其中一张审核通过的收料单上生成一张尾款请款单
|
1000
|
// 且一个计划分多车时只允许在其中一张审核通过的收料单上生成一张尾款请款单
|