Browse Source

Merge remote-tracking branch 'origin/master'

zhanglei
fanzongzhe 2 years ago
parent
commit
d16e8a1d20
  1. 33
      anrui-buscenter/anrui-buscenter-biz/src/main/java/com/yxt/anrui/buscenter/biz/bussalesorder/BusSalesOrderService.java
  2. 15
      anrui-fin/anrui-fin-api/src/main/java/com/yxt/anrui/fin/api/finfundscarriedforwardapply/FinCustNameAndPhone.java
  3. 35
      anrui-fin/anrui-fin-api/src/main/java/com/yxt/anrui/fin/api/finfundscarriedforwardapply/TzDto.java
  4. 25
      anrui-fin/anrui-fin-api/src/main/java/com/yxt/anrui/fin/api/finfundscarriedforwardapply/ZC.java
  5. 25
      anrui-fin/anrui-fin-api/src/main/java/com/yxt/anrui/fin/api/finfundscarriedforwardapply/ZR.java
  6. 2
      anrui-fin/anrui-fin-api/src/main/java/com/yxt/anrui/fin/api/kingdee/otherarreceivable/OtherReceivable.java
  7. 10
      anrui-fin/anrui-fin-biz/src/main/java/com/yxt/anrui/fin/biz/fincollectionconfirmation/FinCollectionConfirmationMapper.xml
  8. 5
      anrui-fin/anrui-fin-biz/src/main/java/com/yxt/anrui/fin/biz/fincollectionconfirmation/FinCollectionConfirmationService.java
  9. 497
      anrui-fin/anrui-fin-biz/src/main/java/com/yxt/anrui/fin/biz/finfundscarriedforwardapply/FinFundsCarriedForwardApplyService.java
  10. 7
      anrui-fin/anrui-fin-biz/src/main/java/com/yxt/anrui/fin/biz/finfundscarriedforwardveh/FinFundsCarriedForwardVehMapper.java
  11. 32
      anrui-fin/anrui-fin-biz/src/main/java/com/yxt/anrui/fin/biz/finfundscarriedforwardveh/FinFundsCarriedForwardVehMapper.xml
  12. 13
      anrui-fin/anrui-fin-biz/src/main/java/com/yxt/anrui/fin/biz/finfundscarriedforwardveh/FinFundsCarriedForwardVehService.java
  13. 2
      anrui-fin/anrui-fin-biz/src/main/java/com/yxt/anrui/fin/biz/finselectedreceivablesdetailed/FinSelectedReceivablesDetailedMapper.java
  14. 17
      anrui-fin/anrui-fin-biz/src/main/java/com/yxt/anrui/fin/biz/finselectedreceivablesdetailed/FinSelectedReceivablesDetailedMapper.xml
  15. 4
      anrui-fin/anrui-fin-biz/src/main/java/com/yxt/anrui/fin/biz/finselectedreceivablesdetailed/FinSelectedReceivablesDetailedService.java
  16. 5
      anrui-fin/anrui-fin-biz/src/main/java/com/yxt/anrui/fin/biz/kingdee/otherreceivablebill/OtherReceivableBillService.java
  17. 2
      anrui-fin/anrui-fin-biz/src/main/java/com/yxt/anrui/fin/biz/kingdee/otherreceivablebill/data_model.json
  18. 34
      anrui-flowable/anrui-flowable-api/src/main/java/com/yxt/anrui/flowable/api/flow2/FlowFeign.java
  19. 9
      anrui-flowable/anrui-flowable-api/src/main/java/com/yxt/anrui/flowable/api/flow2/FlowFeignback.java
  20. 15
      anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flow/FlowableRest.java
  21. 14
      anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flow2/FlowMapper.java
  22. 4
      anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flow2/FlowMapper.xml
  23. 104
      anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flow2/FlowRest.java
  24. 719
      anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flow2/FlowService.java
  25. 2
      anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/processcomment/ProcessCommentMapper.java
  26. 4
      anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/processcomment/ProcessCommentMapper.xml
  27. 4
      anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/processcomment/ProcessCommentService.java
  28. 4
      anrui-riskcenter/anrui-riskcenter-api/src/main/java/com/yxt/anrui/riskcenter/api/loanpreloancreditapply/LoanPreloanCreditApplyVo.java
  29. 20
      anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanpreloancreditapply/LoanPreloanCreditApplyService.java
  30. 1006
      工作内容需要的文档/单据模板/款项结转打印模板/kxjz.ftl
  31. 7
      工作内容需要的文档/单据模板/款项结转打印模板/款项结转(调账申请).doc

33
anrui-buscenter/anrui-buscenter-biz/src/main/java/com/yxt/anrui/buscenter/biz/bussalesorder/BusSalesOrderService.java

@ -138,6 +138,7 @@ import com.yxt.anrui.fin.api.finuncollectedreceivablesdetailed.UnCollectionDto;
import com.yxt.anrui.flowable.api.flow.FlowSelectVo;
import com.yxt.anrui.flowable.api.flow.FlowableFeign;
import com.yxt.anrui.flowable.api.flow.UpdateFlowFieldVo;
import com.yxt.anrui.flowable.api.flow2.FlowFeign;
import com.yxt.anrui.flowable.api.flowtask.FlowTaskFeign;
import com.yxt.anrui.flowable.api.flowtask.FlowTaskVo;
import com.yxt.anrui.flowable.api.flowtask.FlowableQuery;
@ -252,6 +253,8 @@ public class BusSalesOrderService extends MybatisBaseService<BusSalesOrderMapper
@Autowired
private FlowableFeign flowableFeign;
@Autowired
private FlowFeign flowFeign;
@Autowired
private com.yxt.anrui.portal.api.flow.FlowableFeign flowableFeignPro;
@Autowired
private FlowTaskFeign flowTaskFeign;
@ -3471,6 +3474,7 @@ public class BusSalesOrderService extends MybatisBaseService<BusSalesOrderMapper
}
BusSalesOrderMakeup busSalesOrderMakeup = busSalesOrderMakeupService.detailsss(sid);
String topMessage = "";
if(busSalesOrderMakeup != null){
//颜色
if (StringUtils.isNotBlank(busSalesOrderMakeup.getColor())) {
topMessage = topMessage + busSalesOrderMakeup.getColor();
@ -3515,6 +3519,8 @@ public class BusSalesOrderService extends MybatisBaseService<BusSalesOrderMapper
if (StringUtils.isNotBlank(busSalesOrderMakeup.getMoreConfig()) && !"-".equals(busSalesOrderMakeup.getMoreConfig())) {
topMessage = topMessage + "、" + busSalesOrderMakeup.getMoreConfig();
}
}
vo.setTopMessage(topMessage);
}
/***************************主车优惠***************************************/
@ -4763,7 +4769,7 @@ public class BusSalesOrderService extends MybatisBaseService<BusSalesOrderMapper
//流程定义id
bv.setModelId(ProcDefEnum.SALESORDER.getProDefId());
if (r == 1) {
ResultBean<UpdateFlowFieldVo> voResultBean = flowableFeign.startProcess(bv);
ResultBean<UpdateFlowFieldVo> voResultBean = flowFeign.startProcess(bv);
if (!voResultBean.getSuccess()) {
return rb.setMsg(voResultBean.getMsg());
}
@ -4819,7 +4825,7 @@ public class BusSalesOrderService extends MybatisBaseService<BusSalesOrderMapper
} catch (Exception e) {
e.printStackTrace();
}
//==============================
/* //==============================
//如果创建人与部门主管一样,则自动到下一环节。
if (busSalesOrder.get().getCreateBySid().equals(nextNodeUserSids_)) {
busSalesOrderOne = fetchBySid(businessSid);
@ -4835,7 +4841,7 @@ public class BusSalesOrderService extends MybatisBaseService<BusSalesOrderMapper
bv.setOrgSidPath(busSalesOrderOne.getOrgSidPath());
bv.setComment("因与申请人相同,系统自动处理,需以下一级审批人审批意见为准!");
return complete(bv);
}
}*/
try {
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder()
.setNameFormat("demo-pool-%d").build();
@ -5121,28 +5127,39 @@ public class BusSalesOrderService extends MybatisBaseService<BusSalesOrderMapper
//流程定义id
bv.setModelId(busSalesOrder.getProcDefId());
if (bv.getTaskId().equals(busSalesOrder.getTaskId())) {
ResultBean<UpdateFlowFieldVo> resultBean = flowableFeign.handleProsess(bv);
ResultBean<UpdateFlowFieldVo> resultBean = flowFeign.handleProsess(bv);
if (!resultBean.getSuccess()) {
return rb.setMsg(resultBean.getMsg());
}
UpdateFlowFieldVo ufVo = resultBean.getData();
updateFlowFiled(BeanUtil.beanToMap(resultBean.getData()));
busSalesOrder = fetchBySid(bv.getBusinessSid());
//极光推送
if (!"Event_end".equals(resultBean.getData().getTaskDefKey())) {
try {
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder()
.setNameFormat("demo-pool-%d").build();
ExecutorService pool = new ThreadPoolExecutor(2, 100,
0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>(1024), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy());
BusSalesOrder finalBusSalesOrder = busSalesOrder;
Future future1 = pool.submit(() -> {
//极光推送
busSalesOrder = fetchBySid(bv.getBusinessSid());
MessageFlowableQuery messageFlowableQuery = new MessageFlowableQuery();
MessageFlowVo messageFlowVo = new MessageFlowVo();
BeanUtil.copyProperties(ufVo, messageFlowVo);
ufVo.setProcInsId(busSalesOrder.getProcInstId());
ufVo.setProcInsId(finalBusSalesOrder.getProcInstId());
messageFlowableQuery.setUfVo(messageFlowVo);
messageFlowableQuery.setAppMap((Map<String, Object>) variables.get("app"));
messageFlowableQuery.setBusinessSid(bv.getBusinessSid());
messageFlowableQuery.setModuleName("销售订单申请");
messageFlowableQuery.setMsgContent(busSalesOrder.getStaffName() + "提交的" + messageFlowableQuery.getModuleName() + ",请审批");
messageFlowableQuery.setMsgContent(finalBusSalesOrder.getStaffName() + "提交的" + messageFlowableQuery.getModuleName() + ",请审批");
messageFlowableQuery.setMsgTitle("销售订单");
ResultBean<String> stringResultBean = messageFeign.pushMessage(messageFlowableQuery);
});
} catch (Exception e) {
e.printStackTrace();
}
} else {
ResultBean<AppOrderDetailsVo> details = getSaleOrderDetails(bv.getBusinessSid());
AppOrderDetailsVo vo = details.getData();

15
anrui-fin/anrui-fin-api/src/main/java/com/yxt/anrui/fin/api/finfundscarriedforwardapply/FinCustNameAndPhone.java

@ -0,0 +1,15 @@
package com.yxt.anrui.fin.api.finfundscarriedforwardapply;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class FinCustNameAndPhone {
@ApiModelProperty("付款人姓名")
private String draweeName;
@ApiModelProperty("付款人联系电话")
private String draweeMobile;
@ApiModelProperty("业务员sid")
private String staffSid;
}

35
anrui-fin/anrui-fin-api/src/main/java/com/yxt/anrui/fin/api/finfundscarriedforwardapply/TzDto.java

@ -0,0 +1,35 @@
package com.yxt.anrui.fin.api.finfundscarriedforwardapply;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TzDto {
@ApiModelProperty("业务sud")
private String busSid;
@ApiModelProperty("调账类型")
private String tzType;
@ApiModelProperty("合同编号")
private String conNo;
@ApiModelProperty("客户sid")
private String custSid;
@ApiModelProperty("客户名称")
private String name;
@ApiModelProperty("客户编码")
private String custNo;
@ApiModelProperty("物料编码")
private String vinNo;
@ApiModelProperty("调出金额")
private Integer dcje = 0;
@ApiModelProperty("调入金额")
private Integer drje = 0;
public TzDto(String busSid, String zc, String conNo, String name, String custNo, String vinNo, int i) {
}
}

25
anrui-fin/anrui-fin-api/src/main/java/com/yxt/anrui/fin/api/finfundscarriedforwardapply/ZC.java

@ -1,25 +0,0 @@
package com.yxt.anrui.fin.api.finfundscarriedforwardapply;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class ZC {
@ApiModelProperty("调账类型")
private String zc;
@ApiModelProperty("合同编号")
private String conNo;
@ApiModelProperty("客户名称")
private String name;
@ApiModelProperty("物料编码")
private String vinNo;
@ApiModelProperty("调出金额")
private String dcje;
@ApiModelProperty("调入金额")
private String drje;
@ApiModelProperty("调出前余额")
private String dcqye;
@ApiModelProperty("调出后余额")
private String dchye;
}

25
anrui-fin/anrui-fin-api/src/main/java/com/yxt/anrui/fin/api/finfundscarriedforwardapply/ZR.java

@ -1,25 +0,0 @@
package com.yxt.anrui.fin.api.finfundscarriedforwardapply;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class ZR {
@ApiModelProperty("调账类型")
private String zr;
@ApiModelProperty("合同编号")
private String conNo;
@ApiModelProperty("客户名称")
private String name;
@ApiModelProperty("物料编码")
private String vinNo;
@ApiModelProperty("调出金额")
private String dcje;
@ApiModelProperty("调入金额")
private String drje;
@ApiModelProperty("调出前余额")
private String dcqye;
@ApiModelProperty("调出后余额")
private String dchye;
}

2
anrui-fin/anrui-fin-api/src/main/java/com/yxt/anrui/fin/api/kingdee/otherarreceivable/OtherReceivable.java

@ -15,6 +15,8 @@ import java.util.List;
@Data
public class OtherReceivable {
@ApiModelProperty("单据编号")
public String billNo;
@ApiModelProperty("单据类型")
public String billType = "QTYSD01_SYS";
@ApiModelProperty("往来单位类型")

10
anrui-fin/anrui-fin-biz/src/main/java/com/yxt/anrui/fin/biz/fincollectionconfirmation/FinCollectionConfirmationMapper.xml

@ -201,13 +201,13 @@
<select id="jyddkydjListPage"
resultType="com.yxt.anrui.fin.api.fincollectionconfirmation.FinCollectionConfirmationJYDDKYDJVo">
SELECT
fcc.sid,
fsrd.sid,
fcc.useOrgSid,
fcc.staffDeptName,
fcc.staffUserSid AS staffSid,
fcc.staffName,
fcc.`billNo`,
fcc.`payerName`,
fsrd.`customerName`,
bd.`draweeMobile` AS phone,
fcc.collectionDate,
fcc.collectionMoney,
@ -215,9 +215,9 @@
fcc.collectionMoney - COALESCE(SUM(ffc.`thisUseMoney`), 0)
) AS balance
FROM
fin_collection_confirmation fcc
LEFT JOIN fin_selected_receivables_detailed fsrd
ON fcc.`sid` = fsrd.`collSid`
fin_selected_receivables_detailed fsrd
JOIN fin_collection_confirmation fcc
ON fcc.`sid` = fsrd.`collSid` AND fcc.`pushMessgae` = 1
LEFT JOIN anrui_buscenter.`bus_deposit` bd
ON fcc.`busSid` = bd.`billSid`
LEFT JOIN `fin_funds_carried_forward_veh` ffc

5
anrui-fin/anrui-fin-biz/src/main/java/com/yxt/anrui/fin/biz/fincollectionconfirmation/FinCollectionConfirmationService.java

@ -2771,7 +2771,7 @@ public class FinCollectionConfirmationService extends MybatisBaseService<FinColl
qw.like("fcc.billNo", query.getBillNo());
}
if (StringUtils.isNotBlank(query.getPayerName())) {
qw.like("fcc.payerName", query.getPayerName());
qw.like("fsrd.customerName", query.getPayerName());
}
if (StringUtils.isNotBlank(query.getPhone())) {
qw.like("bd.draweeMobile", query.getPhone());
@ -2784,8 +2784,7 @@ public class FinCollectionConfirmationService extends MybatisBaseService<FinColl
if (StringUtils.isNotBlank(query.getName())) {
qw.and(wrapper -> wrapper.like("fcc.billNo", query.getName()).or().like("fcc.staffDeptName", query.getName()).or().like("fcc.staffName", query.getName()).or().like("fcc.payerName", query.getName()).or().like("bd.draweeMobile", query.getName()));
}
qw.isNotNull("fcc.busSid");
qw.groupBy("fcc.sid");
qw.groupBy("fsrd.sid");
if (StringUtils.isNotBlank(query.getCollectionSmallMoney()) && StringUtils.isNotBlank(query.getCollectionBigMoney())){
qw.having("balance > 0").having("balance >= {0}", query.getCollectionSmallMoney()).having("balance <= {0}", query.getCollectionBigMoney());
}else {

497
anrui-fin/anrui-fin-biz/src/main/java/com/yxt/anrui/fin/biz/finfundscarriedforwardapply/FinFundsCarriedForwardApplyService.java

@ -36,7 +36,6 @@ import com.yxt.anrui.base.api.commonappendix.CommonAppendixDto;
import com.yxt.anrui.base.api.commonappendix.CommonAppendixFeign;
import com.yxt.anrui.base.api.commonappendix.CommonAppendixVo;
import com.yxt.anrui.base.common.utils.Rule;
import com.yxt.anrui.buscenter.api.bussalesorder.BusSalesOrder;
import com.yxt.anrui.buscenter.api.bussalesorder.BusSalesOrderFeign;
import com.yxt.anrui.buscenter.api.bussalesordervehicle.BusSalesOrderVehicle;
import com.yxt.anrui.buscenter.api.bussalesordervehicle.BusSalesOrderVehicleFeign;
@ -53,12 +52,10 @@ import com.yxt.anrui.fin.api.finfundscarriedforwardveh.FinFundsCarriedForwardVeh
import com.yxt.anrui.fin.api.finfundscarriedforwardveh.FinFundsCarriedForwardVehDto;
import com.yxt.anrui.fin.api.finselectedreceivablesdetailed.FinSelectedReceivablesDetailed;
import com.yxt.anrui.fin.api.finselectedreceivablesdetailed.FinSelectedReceivablesDetailedVo;
import com.yxt.anrui.fin.api.kingdee.FinKingDeeFeign;
import com.yxt.anrui.fin.api.kingdee.otherarreceivable.OtherReceivable;
import com.yxt.anrui.fin.biz.fincollectionconfirmation.FinCollectionConfirmationService;
import com.yxt.anrui.fin.biz.finfundscarriedforwardveh.FinFundsCarriedForwardVehService;
import com.yxt.anrui.fin.biz.finselectedreceivablesdetailed.FinSelectedReceivablesDetailedService;
import com.yxt.anrui.fin.biz.kingdee.FinKingDeeService;
import com.yxt.anrui.fin.biz.kingdee.otherreceivablebill.OtherReceivableBillService;
import com.yxt.anrui.flowable.api.flow.FlowableFeign;
import com.yxt.anrui.flowable.api.flow.UpdateFlowFieldVo;
@ -360,24 +357,13 @@ public class FinFundsCarriedForwardApplyService extends MybatisBaseService<FinFu
for (String busSid : busSids) {
FinFundsCarriedForwardVehDetailsVo finFundsCarriedForwardVehDetailsVo = new FinFundsCarriedForwardVehDetailsVo();
finFundsCarriedForwardVehDetailsVo.setBusSid(busSid);
if ("简易订单订金".equals(finFundsCarriedForwardApplyInitQuery.getSource())) {
finCollectionConfirmation = finCollectionConfirmationService.fetchBySid(busSid);
finFundsCarriedForwardVehDetailsVo.setBusBillNo(finCollectionConfirmation.getBillNo());
finFundsCarriedForwardVehDetailsVo.setCustomerName(finCollectionConfirmation.getPayerName());
finFundsCarriedForwardVehDetailsVo.setBalance(finCollectionConfirmation.getBalance().toString());
} else if ("已认款".equals(finFundsCarriedForwardApplyInitQuery.getSource())) {
FinSelectedReceivablesDetailed finSelectedReceivablesDetailed = finSelectedReceivablesDetailedService.fetchBySid(busSid);
FinSelectedReceivablesDetailed finSelectedReceivablesDetailed = finSelectedReceivablesDetailedService.fetchYeBySid(busSid);
finCollectionConfirmation = finCollectionConfirmationService.fetchBySid(finSelectedReceivablesDetailed.getCollSid());
finFundsCarriedForwardVehDetailsVo.setBusBillNo(finSelectedReceivablesDetailed.getContractNo());
finFundsCarriedForwardVehDetailsVo.setCustomerSid(finSelectedReceivablesDetailed.getCustomerSid());
finFundsCarriedForwardVehDetailsVo.setCustomerName(finSelectedReceivablesDetailed.getCustomerName());
finFundsCarriedForwardVehDetailsVo.setVinNo(finSelectedReceivablesDetailed.getVIN());
if (StringUtils.isBlank(finSelectedReceivablesDetailed.getBalance())) {
finFundsCarriedForwardVehDetailsVo.setBalance(finSelectedReceivablesDetailed.getSubscriptionMoney().toString());
} else {
finFundsCarriedForwardVehDetailsVo.setBalance(finSelectedReceivablesDetailed.getBalance());
}
}
finFundsCarriedForwardVehDetailsVos.add(finFundsCarriedForwardVehDetailsVo);
}
finFundsCarriedForwardApplyDetailsVo.setSaleDeptSid(finCollectionConfirmation.getStaffDeptSid());
@ -469,7 +455,7 @@ public class FinFundsCarriedForwardApplyService extends MybatisBaseService<FinFu
finSelectedReceivablesDetailed.setAuditState(3);
}
finSelectedReceivablesDetailed.setAuditDate(DateUtil.formatDate(new Date()));
if(finSelectedReceivablesDetailed.getSubscribedOf() == 1){
if (finSelectedReceivablesDetailed.getSubscribedOf() == 1) {
finSelectedReceivablesDetailed.setSelectSid(yxysFinFundsCarriedForwardYXYSKXVo.getSid());
}
finSelectedReceivablesDetailedService.save(finSelectedReceivablesDetailed);
@ -513,7 +499,7 @@ public class FinFundsCarriedForwardApplyService extends MybatisBaseService<FinFu
finSelectedReceivablesDetailed.setUseOrgSid(yxysFinFundsCarriedForwardYXYSKXVo.getUseOrgSid());
finSelectedReceivablesDetailed.setSubscribedOf(yxysFinFundsCarriedForwardYXYSKXVo.getSubscribedOf());
finSelectedReceivablesDetailed.setCollSid(dtoSid);
if(finSelectedReceivablesDetailed.getSubscribedOf() == 1){
if (finSelectedReceivablesDetailed.getSubscribedOf() == 1) {
finSelectedReceivablesDetailed.setSelectSid(yxysFinFundsCarriedForwardYXYSKXVo.getSid());
}
finSelectedReceivablesDetailedService.save(finSelectedReceivablesDetailed);
@ -541,10 +527,7 @@ public class FinFundsCarriedForwardApplyService extends MybatisBaseService<FinFu
ResultBean rb = ResultBean.fireFail();
//用户的组织全路径
FinFundsCarriedForwardApply finFundsCarriedForwardApply = fetchBySid(dto.getSid());
//销售部门信息
SysOrganizationVo sysOrganizationVo1 = sysOrganizationFeign.fetchBySid(finFundsCarriedForwardApply.getSaleDeptSid()).getData();
//分公司信息
SysOrganizationVo sysOrganizationVo2 = sysOrganizationFeign.fetchBySid(finFundsCarriedForwardApply.getUseOrgSid()).getData();
//根据结转申请sid查询转出转入的list集合
List<FinFundsCarriedForwardVehDto> finFundsCarriedForwardVehDetailsVos = dto.getFinFundsCarriedForwardVehDetailsVos();
List<AppFinFundsCarriedForwardYXYSKXDto> yxysFinFundsCarriedForwardYXYSKXVos = dto.getYxysFinFundsCarriedForwardYXYSKXVos();
if (finFundsCarriedForwardVehDetailsVos.size() > 1 && yxysFinFundsCarriedForwardYXYSKXVos.size() > 1) {
@ -591,100 +574,9 @@ public class FinFundsCarriedForwardApplyService extends MybatisBaseService<FinFu
dto.setIsOneSale(true);
String sid = saveOrUpdateAll(dto).getData();
finFundsCarriedForwardApply = fetchBySid(sid);
FinFundsCarriedForwardApplyDetailsVo data = fetchDetailsVoBySid(sid).getData();
List<FinFundsCarriedForwardVehDetailsVo> finFundsCarriedForwardVehDetailsVos1 = data.getFinFundsCarriedForwardVehDetailsVos();
List<AppFinFundsCarriedForwardYXYSKXVo> yxysFinFundsCarriedForwardYXYSKXVos1 = data.getYxysFinFundsCarriedForwardYXYSKXVos();
String pdfPath = createPdf(sid, finFundsCarriedForwardApply.getCreateByName()).getData();
baseMapper.updatePathBySid(pdfPath, sid);
List<Map<String,String>> jzCustNos = new ArrayList<>();
List<Map<String,String>> ysCustNos = new ArrayList<>();
for (FinFundsCarriedForwardVehDetailsVo finFundsCarriedForwardVehDetailsVo2 : finFundsCarriedForwardVehDetailsVos1) {
FinSelectedReceivablesDetailed finSelectedReceivablesDetailed = finSelectedReceivablesDetailedService.fetchBySid(finFundsCarriedForwardVehDetailsVo2.getBusSid());
String custNo = "";
if ("1".equals(finSelectedReceivablesDetailed.getPayTypeKey())) {//全款
Map<String, String> map = new HashMap<>();
custNo = finSelectedReceivablesDetailed.getContractNo();
map.put("type","全款");
map.put("custNo",custNo);
jzCustNos.add(map);
} else {//贷款
BaseVehicle baseVehicle = baseVehicleFeign.selectByVinNoAndOrgSid(finSelectedReceivablesDetailed.getVIN(), finSelectedReceivablesDetailed.getUseOrgSid()).getData();
BusSalesOrderVehicle busSalesOrderVehicle = busSalesOrderVehicleFeign.selectByNoAndVinSid(finSelectedReceivablesDetailed.getContractNo(), baseVehicle.getSid()).getData();
custNo = busSalesOrderVehicle.getTemporaryNo();
Map<String, String> map = new HashMap<>();
map.put("type","贷款");
map.put("custNo",custNo);
jzCustNos.add(map);
}
}
jzCustNos = jzCustNos.stream().distinct().collect(Collectors.toList());
for (Map jzCustNo : jzCustNos) {
String custNo = (String) jzCustNo.get("custNo");
OtherReceivable otherReceivable = new OtherReceivable();
otherReceivable.setCommUnit(custNo);
otherReceivable.setCollectionOrg(sysOrganizationVo2.getOrgCode());
otherReceivable.setBussDate(DateUtil.formatDate(new Date()));
List<OtherReceivable.CollectionDetailDto> collectionDetailDtoList = new ArrayList<>();
List<String> stringList;
if (jzCustNo.get("type").equals("全款")){
stringList = finFundsCarriedForwardVehService.fetchJzMoneyByContractNoAndMainSid(custNo, finFundsCarriedForwardApply.getSid());
}else {
custNo = custNo.substring(0, custNo.length() - 2);
stringList = finFundsCarriedForwardVehService.fetchJzMoneyByContractNoAndMainSid(custNo, finFundsCarriedForwardApply.getSid());
}
for (String s : stringList) {
OtherReceivable.CollectionDetailDto collectionDetailDto = new OtherReceivable.CollectionDetailDto();
collectionDetailDto.setDearDept(sysOrganizationVo1.getOrgCode());
collectionDetailDto.setExTaxMoney(s);
collectionDetailDtoList.add(collectionDetailDto);
}
otherReceivable.setCollectionDetails(collectionDetailDtoList);
otherReceivableBillService.otherReceivableBillService(otherReceivable);
}
for (AppFinFundsCarriedForwardYXYSKXVo yxysFinFundsCarriedForwardYXYSKXVo2 : yxysFinFundsCarriedForwardYXYSKXVos1) {
FinSelectedReceivablesDetailed finSelectedReceivablesDetailed = finSelectedReceivablesDetailedService.fetchBySid(yxysFinFundsCarriedForwardYXYSKXVo2.getSid());
String custNo = "";
if ("1".equals(finSelectedReceivablesDetailed.getPayTypeKey())) {//全款
custNo = finSelectedReceivablesDetailed.getContractNo();
Map<String, String> map = new HashMap<>();
map.put("type","全款");
map.put("custNo",custNo);
ysCustNos.add(map);
} else {//贷款
BaseVehicle baseVehicle = baseVehicleFeign.selectByVinNoAndOrgSid(finSelectedReceivablesDetailed.getVIN(), finSelectedReceivablesDetailed.getUseOrgSid()).getData();
BusSalesOrderVehicle busSalesOrderVehicle = busSalesOrderVehicleFeign.selectByNoAndVinSid(finSelectedReceivablesDetailed.getContractNo(), baseVehicle.getSid()).getData();
custNo = busSalesOrderVehicle.getTemporaryNo();
Map<String, String> map = new HashMap<>();
map.put("type","贷款");
map.put("custNo",custNo);
ysCustNos.add(map);
}
}
ysCustNos = ysCustNos.stream().distinct().collect(Collectors.toList());
for (Map ysCustNo : ysCustNos) {
OtherReceivable otherReceivable = new OtherReceivable();
String custNo = (String)ysCustNo.get("custNo");
otherReceivable.setCommUnit(custNo);
otherReceivable.setCollectionOrg(sysOrganizationVo2.getOrgCode());
otherReceivable.setBussDate(DateUtil.formatDate(new Date()));
List<OtherReceivable.CollectionDetailDto> collectionDetailDtoList = new ArrayList<>();
List<String> stringList;
if (ysCustNo.get("type").equals("全款")){
stringList = finSelectedReceivablesDetailedService.fetchJzMoneyByContractNoAndMainSid(custNo, finFundsCarriedForwardApply.getSid());
}else {
custNo = custNo.substring(0, custNo.length() - 2);
stringList = finSelectedReceivablesDetailedService.fetchJzMoneyByContractNoAndMainSid(custNo, finFundsCarriedForwardApply.getSid());
}
for (String s : stringList) {
OtherReceivable.CollectionDetailDto collectionDetailDto = new OtherReceivable.CollectionDetailDto();
collectionDetailDto.setDearDept(sysOrganizationVo1.getOrgCode());
collectionDetailDto.setExTaxMoney("-" + s);
collectionDetailDtoList.add(collectionDetailDto);
}
otherReceivable.setCollectionDetails(collectionDetailDtoList);
otherReceivableBillService.otherReceivableBillService(otherReceivable);
}
//baseMapper.updateNodeStateBySid("已办结",finFundsCarriedForwardApply.getSid());
//String pdfPath = createPdf(sid, finFundsCarriedForwardApply.getCreateByName()).getData();
//baseMapper.updatePathBySid(pdfPath, sid);
tsqtysd(sid);
return rb.success();
}
}
@ -767,6 +659,180 @@ public class FinFundsCarriedForwardApplyService extends MybatisBaseService<FinFu
return null;
}
public void tsqtysd(String applySid) {
//1.根据结转申请sid查询转出转入的list集合 listi(转入)listo(转出)
FinFundsCarriedForwardApplyDetailsVo data = fetchDetailsVoBySid(applySid).getData();
//转出
List<FinFundsCarriedForwardVehDetailsVo> finFundsCarriedForwardVehDetailsVos = data.getFinFundsCarriedForwardVehDetailsVos();
//转入
List<AppFinFundsCarriedForwardYXYSKXVo> yxysFinFundsCarriedForwardYXYSKXVos = data.getYxysFinFundsCarriedForwardYXYSKXVos();
//分公司信息
SysOrganizationVo sysOrganizationVo1 = sysOrganizationFeign.fetchBySid(data.getUseOrgSid()).getData();
//销售部门信息
SysOrganizationVo sysOrganizationVo2 = sysOrganizationFeign.fetchBySid(data.getSaleDeptSid()).getData();
List<TzDto> zcList = new ArrayList<>();
List<TzDto> zrList = new ArrayList<>();
//构建对象
for (FinFundsCarriedForwardVehDetailsVo finFundsCarriedForwardVehDetailsVo : finFundsCarriedForwardVehDetailsVos) {
TzDto zc = new TzDto();
zc.setBusSid(finFundsCarriedForwardVehDetailsVo.getBusSid());
zc.setTzType("转出");
zc.setCustSid(finFundsCarriedForwardVehDetailsVo.getCustomerSid());
zc.setConNo(finFundsCarriedForwardVehDetailsVo.getBusBillNo());
zc.setName(finFundsCarriedForwardVehDetailsVo.getCustomerName());
zc.setVinNo(finFundsCarriedForwardVehDetailsVo.getVinNo());
zc.setDcje(Integer.valueOf(finFundsCarriedForwardVehDetailsVo.getThisUseMoney()));
zcList.add(zc);
}
for (AppFinFundsCarriedForwardYXYSKXVo yxysFinFundsCarriedForwardYXYSKXVo : yxysFinFundsCarriedForwardYXYSKXVos) {
TzDto zr = new TzDto();
zr.setBusSid(yxysFinFundsCarriedForwardYXYSKXVo.getSid());
zr.setTzType("转入");
zr.setCustSid(yxysFinFundsCarriedForwardYXYSKXVo.getCustomerSid());
zr.setConNo(yxysFinFundsCarriedForwardYXYSKXVo.getContractId());
zr.setName(yxysFinFundsCarriedForwardYXYSKXVo.getName());
zr.setVinNo(yxysFinFundsCarriedForwardYXYSKXVo.getVin());
zr.setDrje(Integer.parseInt(yxysFinFundsCarriedForwardYXYSKXVo.getConfirmMoney()));
zrList.add(zr);
}
//2.设置listi和listo中财务系统客户编码值
if ("简易订单订金".equals(data.getSource())) {
for (TzDto zc : zcList) {
//从已认款中获取客户编码
if (StringUtils.isNotBlank(zc.getCustSid())) {
CrmCustomerTempVo crmCustomerTempVo = crmCustomerTempFeign.fetchSid(zc.getCustSid()).getData();
zc.setCustNo(crmCustomerTempVo.getCustomerNo());
} else {
List<FinCustNameAndPhone> finCustNameAndPhoneList = finFundsCarriedForwardVehService.fetchNameAndPhoneByBusSid(zc.getBusSid());
for (FinCustNameAndPhone finCustNameAndPhone : finCustNameAndPhoneList) {
String custNo = getPrefix(finCustNameAndPhone.getStaffSid(), finCustNameAndPhone.getDraweeName(), finCustNameAndPhone.getDraweeMobile());
zc.setCustNo(custNo);
}
}
}
} else {
for (TzDto zc : zcList) {
zc.setCustNo(getCustNoCW(zc.getBusSid()));
}
}
for (TzDto zr : zrList) {
zr.setCustNo(getCustNoCW(zr.getBusSid()));
}
List<TzDto> listOne;
List<TzDto> listMany;
if (zcList.size() > 1) {
listOne = zcList;
listMany = zrList;
} else {
listOne = zrList;
listMany = zcList;
}
//3.循环判断多条中是否存在相同的财务系统客户编码,如果有相同的则合并为一条,结转金额相加
List<TzDto> manyRemoveList = manyHB(listMany);
Boolean aBoolean = subMoney(listOne, manyRemoveList);
if (!aBoolean) {
return;
}
//5.判断一条的余额是否大于0,大于0推送,否则不推送
if (listOne.get(0).getDrje() > 0 || listOne.get(0).getDcje() > 0) {
//一条的推送
OtherReceivable otherReceivableOne = new OtherReceivable();
otherReceivableOne.setBillNo(data.getBillNo());
otherReceivableOne.setCommUnit(listOne.get(0).getCustNo());
otherReceivableOne.setCollectionOrg(sysOrganizationVo1.getOrgCode());
otherReceivableOne.setBussDate(DateUtil.formatDate(new Date()));
List<OtherReceivable.CollectionDetailDto> collectionDetailDtoListOne = new ArrayList<>();
OtherReceivable.CollectionDetailDto collectionDetailDtoOne = new OtherReceivable.CollectionDetailDto();
collectionDetailDtoOne.setDearDept(sysOrganizationVo2.getOrgCode());
if (listOne.get(0).getTzType().equals("转入")) {
collectionDetailDtoOne.setExTaxMoney("-" + listOne.get(0).getDrje());
} else {
collectionDetailDtoOne.setExTaxMoney(listOne.get(0).getDcje().toString());
}
collectionDetailDtoListOne.add(collectionDetailDtoOne);
otherReceivableOne.setCollectionDetails(collectionDetailDtoListOne);
otherReceivableBillService.otherReceivableBillService(otherReceivableOne);
//多条的推送
OtherReceivable otherReceivableMany = new OtherReceivable();
int i = 1;
for (TzDto tzDto : manyRemoveList) {
String temporaryNum = String.format("%02d", i);
otherReceivableMany.setBillNo(data.getBillNo() + "-" + temporaryNum);
otherReceivableMany.setCommUnit(tzDto.getCustNo());
otherReceivableMany.setCollectionOrg(sysOrganizationVo1.getOrgCode());
otherReceivableMany.setBussDate(DateUtil.formatDate(new Date()));
List<OtherReceivable.CollectionDetailDto> collectionDetailDtoListMany = new ArrayList<>();
OtherReceivable.CollectionDetailDto collectionDetailDtoMany = new OtherReceivable.CollectionDetailDto();
collectionDetailDtoMany.setDearDept(sysOrganizationVo2.getOrgCode());
if (tzDto.getTzType().equals("转入")) {
collectionDetailDtoMany.setExTaxMoney("-" + tzDto.getDrje());
} else {
collectionDetailDtoMany.setExTaxMoney(tzDto.getDcje().toString());
}
collectionDetailDtoListMany.add(collectionDetailDtoMany);
otherReceivableMany.setCollectionDetails(collectionDetailDtoListMany);
otherReceivableBillService.otherReceivableBillService(otherReceivableMany);
i = i + 1;
}
}
}
/*
* 财务中的客户编码
* */
private String getCustNoCW(String busSid) {
String custNo = "";
FinSelectedReceivablesDetailed finSelectedReceivablesDetailed = finSelectedReceivablesDetailedService.fetchBySid(busSid);
if ("1".equals(finSelectedReceivablesDetailed.getPayTypeKey())) {//全款
custNo = finSelectedReceivablesDetailed.getContractNo();
} else {//贷款
if (finSelectedReceivablesDetailed.getVIN().length() > 3) {
BaseVehicle baseVehicle = baseVehicleFeign.selectByVinNoAndOrgSid(finSelectedReceivablesDetailed.getVIN(), finSelectedReceivablesDetailed.getUseOrgSid()).getData();
BusSalesOrderVehicle busSalesOrderVehicle = busSalesOrderVehicleFeign.selectByNoAndVinSid(finSelectedReceivablesDetailed.getContractNo(), baseVehicle.getSid()).getData();
custNo = busSalesOrderVehicle.getTemporaryNo();
} else {
//没有车架号,拼接合同号和临时编号
custNo = finSelectedReceivablesDetailed.getContractNo() + finSelectedReceivablesDetailed.getVIN();
}
}
return custNo;
}
private List<TzDto> manyHB(List<TzDto> list) {
//转出为多条,转入为一条
List<TzDto> manyRemoveList = new ArrayList<>();
list.parallelStream().collect(Collectors.groupingBy(tzDto -> tzDto.getCustNo(), Collectors.toList())).forEach((id, transfer) -> {
transfer.stream().reduce((a, b) -> new TzDto(
a.getBusSid(),
a.getTzType(),
a.getConNo(),
a.getName(),
a.getCustNo(),
a.getVinNo(),
a.getDcje() + b.getDcje())).ifPresent(manyRemoveList::add);
});
return manyRemoveList;
}
private Boolean subMoney(List<TzDto> listOne, List<TzDto> removeList) {
//4.对比一条的和多条的是否存在相同的客户编码,相同的结转金额相减,多条中相同客户编码的记录去除
String custNo = listOne.get(0).getCustNo();
for (TzDto tzDto : removeList) {
if (tzDto.getCustNo().equals(custNo)) {
if (tzDto.getTzType().equals("转入")) {
listOne.get(0).setDcje(listOne.get(0).getDcje() - tzDto.getDrje());
} else {
listOne.get(0).setDrje(listOne.get(0).getDrje() - tzDto.getDcje());
}
removeList.remove(tzDto);
}
if (removeList.size() == 0) {
return false;
}
}
return true;
}
/**
* 更新流程相关的状态
*
@ -1020,170 +1086,7 @@ public class FinFundsCarriedForwardApplyService extends MybatisBaseService<FinFu
for (AppFinFundsCarriedForwardYXYSKXVo appFinFundsCarriedForwardYXYSKXVo : yxysFinFundsCarriedForwardYXYSKXVos) {
finSelectedReceivablesDetailedService.updateAuditStateBySid(3, appFinFundsCarriedForwardYXYSKXVo.getSid());
}
List<FinFundsCarriedForwardVehDetailsVo> finFundsCarriedForwardVehDetailsVos = data.getFinFundsCarriedForwardVehDetailsVos();
List<Map<String,String>> jyddNos = new ArrayList<>();
List<Map<String,String>> jzCustNos = new ArrayList<>();
List<Map<String,String>> ysCustNos = new ArrayList<>();
if ("简易订单订金".equals(finFundsCarriedForwardApply.getSource())) {
List<FinFundsCarriedForwardVehDetailsVo> finFundsCarriedForwardVehDetailsVos1 = finFundsCarriedForwardVehService.fetchByMainSidAndGroupCustPhone(finFundsCarriedForwardApply.getSid());
for (FinFundsCarriedForwardVehDetailsVo finFundsCarriedForwardVehDetailsVo : finFundsCarriedForwardVehDetailsVos1) {
FinSelectedReceivablesDetailed finSelectedReceivablesDetailed = finSelectedReceivablesDetailedService.fetchBySid(finFundsCarriedForwardVehDetailsVo.getBusSid());
CrmCustomerTempVo crmCustomerTempVo = crmCustomerTempFeign.fetchSid(finSelectedReceivablesDetailed.getCustomerSid()).getData();
Map<String, String> map = new HashMap<>();
map.put("custSid",crmCustomerTempVo.getSid());
map.put("custNo",crmCustomerTempVo.getCustomerNo());
jyddNos.add(map);
}
jyddNos = jyddNos.stream().distinct().collect(Collectors.toList());
for (Map<String, String> jyddNo : jyddNos) {
OtherReceivable otherReceivable = new OtherReceivable();
String custNo = jyddNo.get("custNo");
otherReceivable.setCommUnit(custNo);
otherReceivable.setCollectionOrg(sysOrganizationVo2.getOrgCode());
otherReceivable.setBussDate(DateUtil.formatDate(new Date()));
List<OtherReceivable.CollectionDetailDto> collectionDetailDtoList = new ArrayList<>();
String custSid = jyddNo.get("custSid");
List<String> stringList = finFundsCarriedForwardVehService.fetchJzMoneyByCustSidAndMainSid(custSid, finFundsCarriedForwardApply.getSid());
for (String s : stringList) {
OtherReceivable.CollectionDetailDto collectionDetailDto = new OtherReceivable.CollectionDetailDto();
collectionDetailDto.setDearDept(sysOrganizationVo1.getOrgCode());
collectionDetailDto.setExTaxMoney(s);
collectionDetailDtoList.add(collectionDetailDto);
}
otherReceivable.setCollectionDetails(collectionDetailDtoList);
otherReceivableBillService.otherReceivableBillService(otherReceivable);
}
for (AppFinFundsCarriedForwardYXYSKXVo yxysFinFundsCarriedForwardYXYSKXVo2 : yxysFinFundsCarriedForwardYXYSKXVos) {
FinSelectedReceivablesDetailed finSelectedReceivablesDetailed = finSelectedReceivablesDetailedService.fetchBySid(yxysFinFundsCarriedForwardYXYSKXVo2.getSid());
String custNo = "";
if ("1".equals(finSelectedReceivablesDetailed.getPayTypeKey())) {//全款
custNo = finSelectedReceivablesDetailed.getContractNo();
Map<String, String> map = new HashMap<>();
map.put("type","全款");
map.put("custNo",custNo);
ysCustNos.add(map);
} else {//贷款
BaseVehicle baseVehicle = baseVehicleFeign.selectByVinNoAndOrgSid(finSelectedReceivablesDetailed.getVIN(), finSelectedReceivablesDetailed.getUseOrgSid()).getData();
BusSalesOrderVehicle busSalesOrderVehicle = busSalesOrderVehicleFeign.selectByNoAndVinSid(finSelectedReceivablesDetailed.getContractNo(), baseVehicle.getSid()).getData();
custNo = busSalesOrderVehicle.getTemporaryNo();
Map<String, String> map = new HashMap<>();
map.put("type","贷款");
map.put("custNo",custNo);
ysCustNos.add(map);
}
}
ysCustNos = ysCustNos.stream().distinct().collect(Collectors.toList());
for (Map ysCustNo : ysCustNos) {
OtherReceivable otherReceivable = new OtherReceivable();
String custNo = (String)ysCustNo.get("custNo");
otherReceivable.setCommUnit(custNo);
otherReceivable.setCollectionOrg(sysOrganizationVo2.getOrgCode());
otherReceivable.setBussDate(DateUtil.formatDate(new Date()));
List<OtherReceivable.CollectionDetailDto> collectionDetailDtoList = new ArrayList<>();
List<String> stringList;
if (ysCustNo.get("type").equals("全款")){
stringList = finSelectedReceivablesDetailedService.fetchJzMoneyByContractNoAndMainSid(custNo, finFundsCarriedForwardApply.getSid());
}else {
custNo = custNo.substring(0, custNo.length() - 2);
stringList = finSelectedReceivablesDetailedService.fetchJzMoneyByContractNoAndMainSid(custNo, finFundsCarriedForwardApply.getSid());
}
for (String s : stringList) {
OtherReceivable.CollectionDetailDto collectionDetailDto = new OtherReceivable.CollectionDetailDto();
collectionDetailDto.setDearDept(sysOrganizationVo1.getOrgCode());
collectionDetailDto.setExTaxMoney("-" + s);
collectionDetailDtoList.add(collectionDetailDto);
}
otherReceivable.setCollectionDetails(collectionDetailDtoList);
otherReceivableBillService.otherReceivableBillService(otherReceivable);
}
} else if ("已认款".equals(finFundsCarriedForwardApply.getSource())) {
for (FinFundsCarriedForwardVehDetailsVo finFundsCarriedForwardVehDetailsVo2 : finFundsCarriedForwardVehDetailsVos) {
FinSelectedReceivablesDetailed finSelectedReceivablesDetailed = finSelectedReceivablesDetailedService.fetchBySid(finFundsCarriedForwardVehDetailsVo2.getBusSid());
String custNo = "";
if ("1".equals(finSelectedReceivablesDetailed.getPayTypeKey())) {//全款
Map<String, String> map = new HashMap<>();
custNo = finSelectedReceivablesDetailed.getContractNo();
map.put("type","全款");
map.put("custNo",custNo);
jzCustNos.add(map);
} else {//贷款
BaseVehicle baseVehicle = baseVehicleFeign.selectByVinNoAndOrgSid(finSelectedReceivablesDetailed.getVIN(), finSelectedReceivablesDetailed.getUseOrgSid()).getData();
BusSalesOrderVehicle busSalesOrderVehicle = busSalesOrderVehicleFeign.selectByNoAndVinSid(finSelectedReceivablesDetailed.getContractNo(), baseVehicle.getSid()).getData();
custNo = busSalesOrderVehicle.getTemporaryNo();
Map<String, String> map = new HashMap<>();
map.put("type","贷款");
map.put("custNo",custNo);
jzCustNos.add(map);
}
}
jzCustNos = jzCustNos.stream().distinct().collect(Collectors.toList());
for (Map jzCustNo : jzCustNos) {
String custNo = (String) jzCustNo.get("custNo");
OtherReceivable otherReceivable = new OtherReceivable();
otherReceivable.setCommUnit(custNo);
otherReceivable.setCollectionOrg(sysOrganizationVo2.getOrgCode());
otherReceivable.setBussDate(DateUtil.formatDate(new Date()));
List<OtherReceivable.CollectionDetailDto> collectionDetailDtoList = new ArrayList<>();
List<String> stringList;
if (jzCustNo.get("type").equals("全款")){
stringList = finFundsCarriedForwardVehService.fetchJzMoneyByContractNoAndMainSid(custNo, finFundsCarriedForwardApply.getSid());
}else {
custNo = custNo.substring(0, custNo.length() - 2);
stringList = finFundsCarriedForwardVehService.fetchJzMoneyByContractNoAndMainSid(custNo, finFundsCarriedForwardApply.getSid());
}
for (String s : stringList) {
OtherReceivable.CollectionDetailDto collectionDetailDto = new OtherReceivable.CollectionDetailDto();
collectionDetailDto.setDearDept(sysOrganizationVo1.getOrgCode());
collectionDetailDto.setExTaxMoney(s);
collectionDetailDtoList.add(collectionDetailDto);
}
otherReceivable.setCollectionDetails(collectionDetailDtoList);
otherReceivableBillService.otherReceivableBillService(otherReceivable);
}
for (AppFinFundsCarriedForwardYXYSKXVo yxysFinFundsCarriedForwardYXYSKXVo2 : yxysFinFundsCarriedForwardYXYSKXVos) {
FinSelectedReceivablesDetailed finSelectedReceivablesDetailed = finSelectedReceivablesDetailedService.fetchBySid(yxysFinFundsCarriedForwardYXYSKXVo2.getSid());
String custNo = "";
if ("1".equals(finSelectedReceivablesDetailed.getPayTypeKey())) {//全款
custNo = finSelectedReceivablesDetailed.getContractNo();
Map<String, String> map = new HashMap<>();
map.put("type","全款");
map.put("custNo",custNo);
ysCustNos.add(map);
} else {//贷款
BaseVehicle baseVehicle = baseVehicleFeign.selectByVinNoAndOrgSid(finSelectedReceivablesDetailed.getVIN(), finSelectedReceivablesDetailed.getUseOrgSid()).getData();
BusSalesOrderVehicle busSalesOrderVehicle = busSalesOrderVehicleFeign.selectByNoAndVinSid(finSelectedReceivablesDetailed.getContractNo(), baseVehicle.getSid()).getData();
custNo = busSalesOrderVehicle.getTemporaryNo();
Map<String, String> map = new HashMap<>();
map.put("type","贷款");
map.put("custNo",custNo);
ysCustNos.add(map);
}
}
ysCustNos = ysCustNos.stream().distinct().collect(Collectors.toList());
for (Map ysCustNo : ysCustNos) {
OtherReceivable otherReceivable = new OtherReceivable();
String custNo = (String)ysCustNo.get("custNo");
otherReceivable.setCommUnit(custNo);
otherReceivable.setCollectionOrg(sysOrganizationVo2.getOrgCode());
otherReceivable.setBussDate(DateUtil.formatDate(new Date()));
List<OtherReceivable.CollectionDetailDto> collectionDetailDtoList = new ArrayList<>();
List<String> stringList;
if (ysCustNo.get("type").equals("全款")){
stringList = finSelectedReceivablesDetailedService.fetchJzMoneyByContractNoAndMainSid(custNo, finFundsCarriedForwardApply.getSid());
}else {
custNo = custNo.substring(0, custNo.length() - 2);
stringList = finSelectedReceivablesDetailedService.fetchJzMoneyByContractNoAndMainSid(custNo, finFundsCarriedForwardApply.getSid());
}
for (String s : stringList) {
OtherReceivable.CollectionDetailDto collectionDetailDto = new OtherReceivable.CollectionDetailDto();
collectionDetailDto.setDearDept(sysOrganizationVo1.getOrgCode());
collectionDetailDto.setExTaxMoney("-" + s);
collectionDetailDtoList.add(collectionDetailDto);
}
otherReceivable.setCollectionDetails(collectionDetailDtoList);
otherReceivableBillService.otherReceivableBillService(otherReceivable);
}
}
tsqtysd(businessSid);
} else {
//极光推送
finFundsCarriedForwardApply = fetchBySid(businessSid);
@ -1339,31 +1242,27 @@ public class FinFundsCarriedForwardApplyService extends MybatisBaseService<FinFu
}
}
}
List<ZC> zcList = new ArrayList<>();
List<ZR> zrList = new ArrayList<>();
List<TzDto> tzList = new ArrayList<>();
for (FinFundsCarriedForwardVehDetailsVo finFundsCarriedForwardVehDetailsVo : finFundsCarriedForwardVehDetailsVos) {
ZC zc = new ZC();
zc.setZc("转出");
zc.setConNo(finFundsCarriedForwardVehDetailsVo.getBusBillNo());
zc.setName(finFundsCarriedForwardVehDetailsVo.getCustomerName());
zc.setVinNo(finFundsCarriedForwardVehDetailsVo.getVinNo());
zc.setDcje(finFundsCarriedForwardVehDetailsVo.getThisUseMoney());
zc.setDcqye(finFundsCarriedForwardVehDetailsVo.getBalance());
zc.setDchye(new BigDecimal(finFundsCarriedForwardVehDetailsVo.getBalance()).subtract(new BigDecimal(finFundsCarriedForwardVehDetailsVo.getThisUseMoney())).toString());
zcList.add(zc);
TzDto tzDto = new TzDto();
tzDto.setTzType("转出");
tzDto.setConNo(finFundsCarriedForwardVehDetailsVo.getBusBillNo());
tzDto.setName(finFundsCarriedForwardVehDetailsVo.getCustomerName());
tzDto.setVinNo(finFundsCarriedForwardVehDetailsVo.getVinNo());
tzDto.setDcje(Integer.parseInt(finFundsCarriedForwardVehDetailsVo.getThisUseMoney()));
tzList.add(tzDto);
}
for (AppFinFundsCarriedForwardYXYSKXVo yxysFinFundsCarriedForwardYXYSKXVo : yxysFinFundsCarriedForwardYXYSKXVos) {
ZR zr = new ZR();
zr.setZr("转入");
zr.setConNo(yxysFinFundsCarriedForwardYXYSKXVo.getContractId());
zr.setName(yxysFinFundsCarriedForwardYXYSKXVo.getName());
zr.setVinNo(yxysFinFundsCarriedForwardYXYSKXVo.getVin());
zr.setDrje(yxysFinFundsCarriedForwardYXYSKXVo.getConfirmMoney().toString());
zrList.add(zr);
TzDto tzDto = new TzDto();
tzDto.setTzType("转入");
tzDto.setConNo(yxysFinFundsCarriedForwardYXYSKXVo.getContractId());
tzDto.setName(yxysFinFundsCarriedForwardYXYSKXVo.getName());
tzDto.setVinNo(yxysFinFundsCarriedForwardYXYSKXVo.getVin());
tzDto.setDrje(Integer.parseInt(yxysFinFundsCarriedForwardYXYSKXVo.getConfirmMoney()));
tzList.add(tzDto);
}
dataMap.put("saleDate", DateUtil.formatDate(new Date()));
dataMap.put("zcList", zcList);
dataMap.put("zrList", zrList);
dataMap.put("tzList", tzList);
dataMap.put("makeName", data.getCreateByName() + data.getCreateByDate());
//获取模板
//模板路径

7
anrui-fin/anrui-fin-biz/src/main/java/com/yxt/anrui/fin/biz/finfundscarriedforwardveh/FinFundsCarriedForwardVehMapper.java

@ -29,6 +29,7 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.yxt.anrui.fin.api.finfundscarriedforwardapply.FinCustNameAndPhone;
import com.yxt.anrui.fin.api.finfundscarriedforwardveh.FinFundsCarriedForwardVehDetailsVo;
import org.apache.ibatis.annotations.*;
import com.yxt.anrui.fin.api.finfundscarriedforwardveh.FinFundsCarriedForwardVeh;
@ -77,9 +78,5 @@ public interface FinFundsCarriedForwardVehMapper extends BaseMapper<FinFundsCarr
String selectByBusSid(List<String> sidsList);
List<FinFundsCarriedForwardVehDetailsVo> fetchByMainSidAndGroupCustPhone(String sid);
List<String> fetchJzMoneyByContractNoAndMainSid(@Param("jzCustNo") String jzCustNo,@Param("sid") String sid);
List<String> fetchJzMoneyByCustSidAndMainSid(@Param("custSid") String custSid,@Param("sid") String sid);
List<FinCustNameAndPhone> fetchNameAndPhoneByBusSid(String busSid);
}

32
anrui-fin/anrui-fin-biz/src/main/java/com/yxt/anrui/fin/biz/finfundscarriedforwardveh/FinFundsCarriedForwardVehMapper.xml

@ -45,29 +45,21 @@
</foreach>
</select>
<select id="fetchByMainSidAndGroupCustPhone"
resultType="com.yxt.anrui.fin.api.finfundscarriedforwardveh.FinFundsCarriedForwardVehDetailsVo">
SELECT ffv.*, bd.draweeMobile
<select id="fetchNameAndPhoneByBusSid"
resultType="com.yxt.anrui.fin.api.finfundscarriedforwardapply.FinCustNameAndPhone">
SELECT bd.`draweeName`,
bd.draweeMobile,
ffa.`staffSid`
FROM fin_funds_carried_forward_veh ffv
LEFT JOIN fin_funds_carried_forward_apply ffa
ON ffv.`mainSid` = ffa.`sid`
LEFT JOIN fin_selected_receivables_detailed fsrd
ON ffv.`busSid` = fsrd.`sid`
LEFT JOIN fin_collection_confirmation fcc
ON ffv.`busSid` = fcc.`sid`
ON fsrd.`collSid` = fcc.`sid`
AND fcc.`pushMessgae` = 1
LEFT JOIN anrui_buscenter.`bus_deposit` bd
ON fcc.`busSid` = bd.`billSid`
WHERE ffv.`mainSid` = #{sid}
GROUP BY bd.`draweeMobile`
</select>
<select id="fetchJzMoneyByContractNoAndMainSid" resultType="java.lang.String">
SELECT ffc.`thisUseMoney` AS jzMoney
FROM fin_funds_carried_forward_veh ffc
WHERE ffc.busBillNo = #{jzCustNo}
AND ffc.mainSid = #{sid}
</select>
<select id="fetchJzMoneyByCustSidAndMainSid" resultType="java.lang.String">
SELECT ffc.`thisUseMoney` AS jzMoney
FROM fin_funds_carried_forward_veh ffc
WHERE ffc.customerSid = #{custSid}
AND ffc.mainSid = #{sid}
WHERE ffv.`busSid` = #{busSid}
</select>
</mapper>

13
anrui-fin/anrui-fin-biz/src/main/java/com/yxt/anrui/fin/biz/finfundscarriedforwardveh/FinFundsCarriedForwardVehService.java

@ -43,6 +43,7 @@ import com.yxt.anrui.buscenter.api.bussalesordermodel.BusSalesOrderModel;
import com.yxt.anrui.buscenter.api.bussalesorderprice.BusSalesOrderPrice;
import com.yxt.anrui.buscenter.api.bussalesordersubmit.BusSalesOrderSubmit;
import com.yxt.anrui.buscenter.api.bussalesordervehicle.BusSalesOrderVehicle;
import com.yxt.anrui.fin.api.finfundscarriedforwardapply.FinCustNameAndPhone;
import com.yxt.anrui.portal.api.flow.PCHistTaskListAndCommentList;
import com.yxt.anrui.portal.api.sysorganization.SysOrganization;
import com.yxt.anrui.portal.api.sysorganization.SysOrganizationVo;
@ -162,15 +163,7 @@ public class FinFundsCarriedForwardVehService extends MybatisBaseService<FinFund
return baseMapper.selectByBusSid(sidsList);
}
public List<FinFundsCarriedForwardVehDetailsVo> fetchByMainSidAndGroupCustPhone(String sid) {
return baseMapper.fetchByMainSidAndGroupCustPhone(sid);
}
public List<String> fetchJzMoneyByContractNoAndMainSid(String jzCustNo, String sid) {
return baseMapper.fetchJzMoneyByContractNoAndMainSid(jzCustNo,sid);
}
public List<String> fetchJzMoneyByCustSidAndMainSid(String custSid, String sid) {
return baseMapper.fetchJzMoneyByCustSidAndMainSid(custSid,sid);
public List<FinCustNameAndPhone> fetchNameAndPhoneByBusSid(String busSid) {
return baseMapper.fetchNameAndPhoneByBusSid(busSid);
}
}

2
anrui-fin/anrui-fin-biz/src/main/java/com/yxt/anrui/fin/biz/finselectedreceivablesdetailed/FinSelectedReceivablesDetailedMapper.java

@ -161,4 +161,6 @@ public interface FinSelectedReceivablesDetailedMapper extends BaseMapper<FinSele
String selectBalanceByReceivedSid(String receivablesSid);
IPage<FinSelectReceivablesDetailedVo> selectPageLists(IPage<FinSelectedReceivablesPaymentDetailsQuery> page, @Param(Constants.WRAPPER) QueryWrapper<AppFinUncollectedReceivablesDetailedVo> qw, @Param("name") String name);
FinSelectedReceivablesDetailed fetchYeBySid(String busSid);
}

17
anrui-fin/anrui-fin-biz/src/main/java/com/yxt/anrui/fin/biz/finselectedreceivablesdetailed/FinSelectedReceivablesDetailedMapper.xml

@ -487,4 +487,21 @@
WHERE fsr.`contractNo` = #{ysCustNo}
AND fsr.`collSid` = #{sid}
</select>
<select id="fetchYeBySid"
resultType="com.yxt.anrui.fin.api.finselectedreceivablesdetailed.FinSelectedReceivablesDetailed">
SELECT fsrd.contractNo,
fsrd.`customerSid`,
fsrd.`customerName`,
fsrd.`VIN`,
fsrd.collSid,
(
fsrd.`subscriptionMoney` - COALESCE(SUM(ffc.`thisUseMoney`), 0)
) AS balance
FROM fin_selected_receivables_detailed fsrd
LEFT JOIN `fin_funds_carried_forward_veh` ffc
ON ffc.`busSid` = fsrd.`sid`
WHERE fsrd.`sid` = #{busSid}
GROUP BY fsrd.sid
</select>
</mapper>

4
anrui-fin/anrui-fin-biz/src/main/java/com/yxt/anrui/fin/biz/finselectedreceivablesdetailed/FinSelectedReceivablesDetailedService.java

@ -622,4 +622,8 @@ public class FinSelectedReceivablesDetailedService extends MybatisBaseService<Fi
public List<String> fetchJzMoneyByContractNoAndMainSid(String ysCustNo, String sid) {
return baseMapper.fetchJzMoneyByContractNoAndMainSid(ysCustNo,sid);
}
public FinSelectedReceivablesDetailed fetchYeBySid(String busSid) {
return baseMapper.fetchYeBySid(busSid);
}
}

5
anrui-fin/anrui-fin-biz/src/main/java/com/yxt/anrui/fin/biz/kingdee/otherreceivablebill/OtherReceivableBillService.java

@ -27,6 +27,11 @@ public class OtherReceivableBillService extends FinKingDeeService {
//业务表的主表数据集合
Map<String,String> map_fEntityModel_=new HashMap<>();
//物料的数组集合
//单据编号
if(otherReceivable.getBillNo()==null){
return rb.setMsg("单据编号不能为空");
}
map_fEntityModel_.put("FBillNo",otherReceivable.getBillNo());
//业务日期
if(otherReceivable.getBussDate()==null){
return rb.setMsg("业务日期不能为空");

2
anrui-fin/anrui-fin-biz/src/main/java/com/yxt/anrui/fin/biz/kingdee/otherreceivablebill/data_model.json

@ -3,7 +3,7 @@
"FBillTypeID": {
"FNUMBER": "QTYSD01_SYS"
},
"FBillNo": "",
"FBillNo": "@KD_FBillNo",
"FDATE": "@KD_FDATE",
"FENDDATE_H": "1900-01-01",
"FISINIT": "false",

34
anrui-flowable/anrui-flowable-api/src/main/java/com/yxt/anrui/flowable/api/flow2/FlowFeign.java

@ -0,0 +1,34 @@
package com.yxt.anrui.flowable.api.flow2;
import com.yxt.anrui.flowable.api.flow.UpdateFlowFieldVo;
import com.yxt.anrui.flowable.sqloperationsymbol.BusinessVariables;
import com.yxt.common.core.result.ResultBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* @description:
* @author: dimengzhe
* @date: 2023/7/20
**/
@FeignClient(
contextId = "anrui-flowable-Flow",
name = "anrui-flowable",
path = "v2/flow",
fallback = FlowFeignback.class)
public interface FlowFeign {
@ApiOperation(value = "启动流程")
@PostMapping(value = "/startProcess")
@ResponseBody
ResultBean<UpdateFlowFieldVo> startProcess(@RequestBody BusinessVariables dto);
@ApiOperation(value = "处理流程")
@PostMapping(value = "/handleProsess")
@ResponseBody
ResultBean<UpdateFlowFieldVo> handleProsess(@RequestBody BusinessVariables bv);
}

9
anrui-flowable/anrui-flowable-api/src/main/java/com/yxt/anrui/flowable/api/flow2/FlowFeignback.java

@ -0,0 +1,9 @@
package com.yxt.anrui.flowable.api.flow2;
/**
* @description:
* @author: dimengzhe
* @date: 2023/7/20
**/
public class FlowFeignback {
}

15
anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flow/FlowableRest.java

@ -205,6 +205,13 @@ public class FlowableRest implements FlowableFeign {
if (processVariables.containsKey("sendRecommendSid")) {//增加的其他的抄送人
userSids.append(processVariables.get("sendRecommendSid").toString()).append(",");
}
//查询是否有设置转办的,抄送给设置转办人员
List<String> zbUserSids = processCommentService.selectByIdAndComment("转办",bv.getInstanceId());
zbUserSids.removeAll(Collections.singleton(null));
if(!zbUserSids.isEmpty()){
String zbUser = String.join(",",zbUserSids);
userSids.append(zbUser).append(",");
}
userSids.deleteCharAt(userSids.length() - 1);
mfq.setUserSids(userSids.toString());
mfq.setOrgPath(createrOrgPath);
@ -284,11 +291,9 @@ public class FlowableRest implements FlowableFeign {
public ResultBean<UpdateFlowFieldVo> startProcess(BusinessVariables dto) {
log.info("startProcess.dto:{}", dto);
ResultBean rb = ResultBean.fireFail();
if (StringUtils.isBlank(dto.getBusinessSid())) {
return rb.setMsg("businessSid 不能为空!");
}
if (dto.getFormVariables() == null)
dto.setFormVariables(new HashMap<String, Object>());
Map<String, Object> formVariables = dto.getFormVariables();
@ -296,20 +301,17 @@ public class FlowableRest implements FlowableFeign {
String orgPath = dto.getOrgSidPath();
formVariables.put("createrOrgPath", orgPath);//发起人的组织结构sid
}
dto.getFormVariables().put("businessSid", dto.getBusinessSid());
String nextNodeUserSids_ = dto.getNextNodeUserSids();
if (StringUtils.isBlank(nextNodeUserSids_)) {
ResultBean<UserAndOrgPath> nextNodeUserSidsOfCreate = getNextNodeUserSidsOfCreate(dto);
boolean success = nextNodeUserSidsOfCreate.getSuccess();
if (!success) {
// return rb.setMsg(nextNodeUserSidsOfCreate.getMsg());
nextNodeUserSids_ = ProcDefEnum.DEFAUL_TADMIN_SID.getProDefId();
} else {
nextNodeUserSids_ = nextNodeUserSidsOfCreate.getData().getUserSid();
dto.getFormVariables().put(BusinessVariables.ORGPATH, nextNodeUserSidsOfCreate.getData().getOrgPath());
}
}
dto.setNextNodeUserSids(nextNodeUserSids_);
ResultBean resultBean1 = flowableService.businessStart(dto);
@ -431,7 +433,7 @@ public class FlowableRest implements FlowableFeign {
//若下一环节用户与系统管理员一致,则自动审批
if (ProcDefEnum.DEFAUL_TADMIN_SID.getProDefId().equals(nextUserSid)) {
adminContains = true;
}else{
} else {
//下一环节不为空,查询下一环节用户是否有转办人
if (nextUserSid != null) {
List<String> nextUserList = Arrays.asList(nextUserSid.split(","));
@ -531,6 +533,7 @@ public class FlowableRest implements FlowableFeign {
dto.setTaskId(vo.getTaskId());
dto.setTaskDefKey(taskDefKey);
dto.setComment("系统自动跳过");
dto.setNextNodeUserSids("");
return handleProsess(dto, false);
}
List<FlowElement> flowElements = processService.calApprovePath(dto.getModelId(), dto.getModelId(),

14
anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flow2/FlowMapper.java

@ -0,0 +1,14 @@
package com.yxt.anrui.flowable.biz.flow2;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yxt.anrui.flowable.api.flow.Flowable;
import org.apache.ibatis.annotations.Mapper;
/**
* @description:
* @author: dimengzhe
* @date: 2023/7/20
**/
@Mapper
public interface FlowMapper extends BaseMapper<Flowable> {
}

4
anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flow2/FlowMapper.xml

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yxt.anrui.flowable.biz.flow2.FlowMapper">
</mapper>

104
anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flow2/FlowRest.java

@ -0,0 +1,104 @@
package com.yxt.anrui.flowable.biz.flow2;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSONObject;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.yxt.anrui.flowable.api.flow.UpdateFlowFieldVo;
import com.yxt.anrui.flowable.api.flow2.FlowFeign;
import com.yxt.anrui.flowable.biz.process.ProcessService;
import com.yxt.anrui.flowable.feign.MessageFeign;
import com.yxt.anrui.flowable.feign.form.MessageFlowVo;
import com.yxt.anrui.flowable.feign.form.MessageFlowableQuery;
import com.yxt.anrui.flowable.sqloperationsymbol.BusinessVariables;
import com.yxt.anrui.portal.api.sysflowcc.SysFlowccFeign;
import com.yxt.anrui.portal.api.sysflowcc.SysFlowccVo;
import com.yxt.anrui.portal.api.sysuser.SysUserFeign;
import com.yxt.anrui.portal.api.sysuser.SysUserVo;
import com.yxt.anrui.portal.api.sysuser.UserByRolesAndOrgQuery;
import com.yxt.common.base.utils.StringUtils;
import com.yxt.common.core.result.ResultBean;
import org.apache.tomcat.util.threads.ThreadPoolExecutor;
import org.flowable.engine.HistoryService;
import org.flowable.task.api.history.HistoricTaskInstance;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.*;
/**
* @description:
* @author: dimengzhe
* @date: 2023/7/20
**/
@RestController
@RequestMapping("v2/flow")
public class FlowRest implements FlowFeign {
Logger log = LoggerFactory.getLogger(FlowRest.class);
@Autowired
private FlowService flowService;
@Autowired
private SysUserFeign sysUserFeign;
@Override
public ResultBean<UpdateFlowFieldVo> startProcess(BusinessVariables bv) {
ResultBean<UpdateFlowFieldVo> rb = ResultBean.fireFail();
//获取表单中的参数
Map<String, Object> formVariables = bv.getFormVariables();
formVariables = formVariables == null ? new HashMap<>() : formVariables;
//发起人的组织全路径
String orgPath = bv.getOrgSidPath();
formVariables.put("createrOrgPath", orgPath);
formVariables.put("businessSid", bv.getBusinessSid());
//获取下一环节待办人
ResultBean<String> userResultBean = flowService.getNextNodeUser(bv);
bv.setNextNodeUserSids(userResultBean.getData());
//启动流程实例
ResultBean<UpdateFlowFieldVo> startResultBean = flowService.businessStartProcessInstanceById(bv);
return startResultBean;
}
@Override
public ResultBean<UpdateFlowFieldVo> handleProsess(BusinessVariables bv) {
ResultBean<UpdateFlowFieldVo> rb = ResultBean.fireFail();
ResultBean<UpdateFlowFieldVo> updateFlowFieldVoResultBean = flowService.handleProsess(bv, true);
//添加抄送
log.info("流程返回:{}", JSONObject.toJSONString(updateFlowFieldVoResultBean));
//需要判断办结后再执行 TODO
if (updateFlowFieldVoResultBean.getSuccess()) {
log.info("流程返回:{}", JSONObject.toJSONString(updateFlowFieldVoResultBean));
if ("Event_end".equals(updateFlowFieldVoResultBean.getData().getTaskDefKey())) {
try {
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder()
.setNameFormat("demo-pool-%d").build();
ExecutorService pool = new ThreadPoolExecutor(2, 100,
0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>(1024), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy());
Future future1 = pool.submit(() -> {
HashMap<String, Object> map = new HashMap<>();
map.put("bv", bv);
UpdateFlowFieldVo ufVo = updateFlowFieldVoResultBean.getData();
ufVo.setTaskId(bv.getTaskId());
map.put("uff", ufVo);
flowService.cc(map, bv.getTaskDefKey());
});
} catch (Exception e) {
e.printStackTrace();
return rb.setMsg("抄送失败");
}
}
}
return updateFlowFieldVoResultBean;
}
}

719
anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flow2/FlowService.java

@ -0,0 +1,719 @@
package com.yxt.anrui.flowable.biz.flow2;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yxt.anrui.flowable.api.flow.Flowable;
import com.yxt.anrui.flowable.api.flow.UpdateFlowFieldVo;
import com.yxt.anrui.flowable.api.flowcomment.FlowComment;
import com.yxt.anrui.flowable.api.flowtask.FlowTask;
import com.yxt.anrui.flowable.api.flowtask.LatestTaskVo;
import com.yxt.anrui.flowable.api.processcomment.ProcessCommentDto;
import com.yxt.anrui.flowable.api.utils.ProcDefEnum;
import com.yxt.anrui.flowable.biz.flowtask.FlowTaskService;
import com.yxt.anrui.flowable.biz.process.ExpressionCmd;
import com.yxt.anrui.flowable.biz.process.ProcessService;
import com.yxt.anrui.flowable.biz.processcomment.ProcessCommentService;
import com.yxt.anrui.flowable.common.ProcessConstants;
import com.yxt.anrui.flowable.feign.MessageFeign;
import com.yxt.anrui.flowable.feign.form.MessageFlowVo;
import com.yxt.anrui.flowable.feign.form.MessageFlowableQuery;
import com.yxt.anrui.flowable.sqloperationsymbol.BusinessVariables;
import com.yxt.anrui.portal.api.sysflowableconfig.SysFlowableConfigFeign;
import com.yxt.anrui.portal.api.sysflowableconfig.SysFlowableConfigQuery;
import com.yxt.anrui.portal.api.sysflowableconfig.SysFlowableConfigVvo;
import com.yxt.anrui.portal.api.sysflowcc.SysFlowccFeign;
import com.yxt.anrui.portal.api.sysflowcc.SysFlowccVo;
import com.yxt.anrui.portal.api.sysuser.*;
import com.yxt.common.base.service.MybatisBaseService;
import com.yxt.common.base.utils.StringUtils;
import com.yxt.common.core.result.ResultBean;
import lombok.extern.slf4j.Slf4j;
import org.flowable.bpmn.model.*;
import org.flowable.engine.*;
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.flowable.engine.repository.ProcessDefinition;
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.task.api.DelegationState;
import org.flowable.task.api.Task;
import org.flowable.task.api.history.HistoricTaskInstance;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
/**
* @description:
* @author: dimengzhe
* @date: 2023/7/20
**/
@Service
@Slf4j
public class FlowService extends MybatisBaseService<FlowMapper, Flowable> {
@Autowired
RepositoryService repositoryService;
@Autowired
RuntimeService runtimeService;
@Autowired
ManagementService managementService;
@Autowired
ProcessEngineConfigurationImpl processEngineConfiguration;
@Autowired
private SysUserFeign sysUserFeign;
@Autowired
protected IdentityService identityService;
@Autowired
protected TaskService taskService;
@Autowired
private SysFlowableConfigFeign sysFlowableConfigFeign;
@Autowired
private FlowTaskService flowTaskService;
@Autowired
private ProcessCommentService processCommentService;
@Autowired
protected HistoryService historyService;
@Autowired
private ProcessService processService;
@Autowired
private MessageFeign messageFeign;
@Autowired
private SysFlowccFeign sysFlowccFeign;
public ResultBean<String> getNextNodeUser(BusinessVariables bv) {
ResultBean<String> rb = ResultBean.fireFail();
//根据业务参数取流程流转的环节 信息
List<Map<String, Object>> list = (List<Map<String, Object>>) getProcessCirculationNodesByMap(bv).getData();
if (list == null || list.size() < 2) {
return rb.setMsg("流程设计问题");
}
//取第二个环节的配置角色
Object o = list.get(1).get("candidateGroups");
if (o == null) {
return rb.setMsg("流程设计问题");
}
JSONArray jsonArray = JSONArray.parseArray(JSON.toJSONString(o));
String roleSid = jsonArray.get(0).toString();
//根据组织架构、角色两个参数取相关符合条件的用户信息
UserQuery userQuery = new UserQuery();
userQuery.setRoleSid(roleSid);
userQuery.setOrgSidPath(bv.getOrgSidPath());
String nextNodeUserSids_ = "";
List<SysUserVo> sysUserVos = sysUserFeign.getUserByRole(userQuery).getData();
if (sysUserVos == null || sysUserVos.size() < 1) {
nextNodeUserSids_ = ProcDefEnum.DEFAUL_TADMIN_SID.getProDefId();
} else {
StringBuilder nextNodeUserSids = new StringBuilder();
for (SysUserVo su : sysUserVos) {
nextNodeUserSids.append(su.getSid()).append(",");
}
//符合条件的用户的sid,拼接的字符串
nextNodeUserSids_ = nextNodeUserSids.toString();
nextNodeUserSids_ = nextNodeUserSids_.substring(0, nextNodeUserSids_.length() - 1);
}
return rb.success().setData(nextNodeUserSids_);
}
public ResultBean getProcessCirculationNodesByMap(BusinessVariables bv) {
ResultBean<List<Map<String, Object>>> rb = new ResultBean<List<Map<String, Object>>>();
String modelId = bv.getModelId();
List<FlowElement> flowElements = calApprovePath(modelId, bv.getFormVariables());
List<Map<String, Object>> list = new ArrayList<>();
for (FlowElement f : flowElements) {
Map<String, Object> map = new HashMap<>();
map.put("name", f.getName());
map.put("id", f.getId());
String s = JSON.toJSONString(f);
JSONObject jsonObject = JSONObject.parseObject(s);
log.info("item:{}", jsonObject);
Object candidateGroups = jsonObject.get("candidateGroups");
map.put("candidateGroups", candidateGroups);
list.add(map);
}
return rb.setData(list);
}
/**
* 1. 首先拿到BpmnModel所有流程定义信息都可以通过BpmnModel获取若流程尚未发起则用modelId查询最新部署的流程定义数据
* 若流程已经发起可以通过流程实例的processDefinitionId查询流程定义的历史数据
*
* @param variableMap 流程变量用于计算条件分支
*/
public List<FlowElement> calApprovePath(String modelId, Map<String, Object> variableMap) {
BpmnModel bpmnModel = repositoryService.getBpmnModel(modelId);
Collection<FlowElement> flowElements = new ArrayList<>();
Collection<FlowElement> flowElements2 = bpmnModel.getMainProcess().getFlowElements();
flowElements.addAll(flowElements2);
List<FlowElement> passElements = new ArrayList<>();
dueStartElement(passElements, flowElements, variableMap);
return passElements;
}
/**
* 2. 找到开始节点通过它的目标节点然后再不断往下找
*/
private void dueStartElement(List<FlowElement> passElements, Collection<FlowElement> flowElements, Map<String, Object> variableMap) {
Optional<FlowElement> startElementOpt = flowElements.stream().filter(flowElement -> flowElement instanceof StartEvent).findFirst();
startElementOpt.ifPresent(startElement -> {
flowElements.remove(startElement);
List<SequenceFlow> outgoingFlows = ((StartEvent) startElement).getOutgoingFlows();
String targetRef = outgoingFlows.get(0).getTargetRef();
// 根据ID找到FlowElement
FlowElement targetElementOfStartElement = getFlowElement(flowElements, targetRef);
if (targetElementOfStartElement instanceof UserTask) {
this.getPassElementList(passElements, flowElements, targetElementOfStartElement, variableMap);
}
});
}
/**
* 3. 我只用到了UserTaskExclusiveGatewayParallelGateway所以代码里只列举了这三种如果用到了其他的可以再自己补充
*/
private void getPassElementList(List<FlowElement> passElements, Collection<FlowElement> flowElements, FlowElement curFlowElement, Map<String, Object> variableMap) {
// 任务节点
if (curFlowElement instanceof UserTask) {
this.dueUserTaskElement(passElements, flowElements, curFlowElement, variableMap);
return;
}
// 排他网关
if (curFlowElement instanceof ExclusiveGateway) {
this.dueExclusiveGateway(passElements, flowElements, curFlowElement, variableMap);
return;
}
// 并行网关
if (curFlowElement instanceof ParallelGateway) {
this.dueParallelGateway(passElements, flowElements, curFlowElement, variableMap);
}
}
private void dueUserTaskElement(List<FlowElement> passElements, Collection<FlowElement> flowElements,
FlowElement curFlowElement, Map<String, Object> variableMap) {
passElements.add(curFlowElement);
List<SequenceFlow> outgoingFlows = ((UserTask) curFlowElement).getOutgoingFlows();
String targetRef = outgoingFlows.get(0).getTargetRef();
if (outgoingFlows.size() > 1) {
// 找到表达式成立的sequenceFlow
SequenceFlow sequenceFlow = getSequenceFlow(variableMap, outgoingFlows);
targetRef = sequenceFlow.getTargetRef();
}
// 根据ID找到FlowElement
FlowElement targetElement = getFlowElement(flowElements, targetRef);
this.getPassElementList(passElements, flowElements, targetElement, variableMap);
}
private void dueExclusiveGateway(List<FlowElement> passElements, Collection<FlowElement> flowElements, FlowElement curFlowElement, Map<String, Object> variableMap) {
// 获取符合条件的sequenceFlow的目标FlowElement
List<SequenceFlow> exclusiveGatewayOutgoingFlows = ((ExclusiveGateway) curFlowElement).getOutgoingFlows();
flowElements.remove(curFlowElement);
// 找到表达式成立的sequenceFlow
SequenceFlow sequenceFlow = getSequenceFlow(variableMap, exclusiveGatewayOutgoingFlows);
// 根据ID找到FlowElement
FlowElement targetElement = getFlowElement(flowElements, sequenceFlow.getTargetRef());
this.getPassElementList(passElements, flowElements, targetElement, variableMap);
}
private void dueParallelGateway(List<FlowElement> passElements, Collection<FlowElement> flowElements, FlowElement curFlowElement, Map<String, Object> variableMap) {
FlowElement targetElement;
List<SequenceFlow> parallelGatewayOutgoingFlows = ((ParallelGateway) curFlowElement).getOutgoingFlows();
for (SequenceFlow sequenceFlow : parallelGatewayOutgoingFlows) {
targetElement = getFlowElement(flowElements, sequenceFlow.getTargetRef());
this.getPassElementList(passElements, flowElements, targetElement, variableMap);
}
}
private FlowElement getFlowElement(Collection<FlowElement> flowElements, String targetRef) {
return flowElements.stream().filter(flowElement -> targetRef.equals(flowElement.getId())).findFirst().orElse(null);
}
/**
* 4. 根据传入的变量计算出表达式成立的那一条SequenceFlow
*
* @param variableMap
* @param outgoingFlows
* @return
*/
private SequenceFlow getSequenceFlow(Map<String, Object> variableMap, List<SequenceFlow> outgoingFlows) {
Optional<SequenceFlow> sequenceFlowOpt = outgoingFlows.stream().filter(item -> {
try {
return this.getElValue(item.getConditionExpression(), variableMap);
} catch (Exception e) {
log.error(e.getMessage(), e);
return false;
}
}).findFirst();
return sequenceFlowOpt.orElse(outgoingFlows.get(0));
}
private boolean getElValue(String exp, Map<String, Object> variableMap) {
return managementService.executeCommand(new ExpressionCmd(runtimeService, processEngineConfiguration, null, exp, variableMap));
}
public ResultBean<UpdateFlowFieldVo> businessStartProcessInstanceById(BusinessVariables bv) {
ResultBean<UpdateFlowFieldVo> rb = ResultBean.fireFail();
UpdateFlowFieldVo updateFlowFieldVo = new UpdateFlowFieldVo();
String procDefId = bv.getModelId();
String userSid = bv.getUserSid();
String nextNodeUserSids = bv.getNextNodeUserSids();
Map<String, Object> variables = bv.getFormVariables();
Map<String, Object> variablesSeconds = bv.getFormVariables();
//根据流程定义id查询
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(procDefId)
.latestVersion().singleResult();
if (Objects.nonNull(processDefinition) && processDefinition.isSuspended()) {
return rb.setMsg("流程已被挂起,请先激活流程");
}
// 设置流程发起人Id到流程中
ResultBean<SysUserVo> sysUserVoResultBean = sysUserFeign.fetchBySid(userSid);
SysUserVo sysUser = sysUserVoResultBean.getData();
identityService.setAuthenticatedUserId(sysUser.getSid());
variables.put(ProcessConstants.PROCESS_INITIATOR, userSid);
variables.put(ProcessConstants.USER_TYPE_ASSIGNEE, userSid);
ProcessInstance processInstance = runtimeService.startProcessInstanceById(procDefId, variables);
// 给第一步申请人节点设置任务执行人和意见 todo:第一个节点不设置为申请人节点有点问题?
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).singleResult();
if (Objects.nonNull(task)) {
taskService.addComment(task.getId(), processInstance.getProcessInstanceId(), FlowComment.START.getType(),
sysUser.getName() + "发起流程申请");
taskService.setAssignee(task.getId(), userSid);
taskService.setVariablesLocal(task.getId(), variables);
taskService.complete(task.getId(), variables);
}
//根据流程实例的id查询最新的待办环节
ResultBean<List<LatestTaskVo>> latestTasksNew = flowTaskService.getLatestTasksNew(processInstance.getId());
List<LatestTaskVo> data = latestTasksNew.getData();
LatestTaskVo latestTaskVo = data.get(0);
String id_ = latestTaskVo.getId_();
String task_def_key_ = latestTaskVo.getTask_def_key_();
//查询下一环节是否有转办并添加评论
nextNodeUserSids = change(nextNodeUserSids, processInstance.getProcessInstanceId());
taskService.setAssignee(id_, nextNodeUserSids);
if (ProcDefEnum.DEFAUL_TADMIN_SID.getProDefId().equals(nextNodeUserSids)) {
bv.setModelId(procDefId);
bv.setInstanceId(task.getProcessInstanceId());
bv.setTaskId(id_);
bv.setUserSid(nextNodeUserSids);
bv.setBusinessSid(bv.getBusinessSid());
bv.setTaskDefKey(task_def_key_);
bv.setFormVariables(variables);
bv.setOrgSidPath(bv.getOrgSidPath());
bv.setComment("系统自动跳过!");
bv.setFormVariables(variablesSeconds);
bv.setNextNodeUserSids("");
ResultBean<UpdateFlowFieldVo> updateFlowFieldVoResultBean = handleProsess(bv, false);
if (updateFlowFieldVoResultBean.getSuccess() && updateFlowFieldVoResultBean.getData() != null) {
UpdateFlowFieldVo vo = updateFlowFieldVoResultBean.getData();
updateFlowFieldVo.setProcInsId(vo.getProcInsId());
updateFlowFieldVo.setNodeState(vo.getNodeState());
updateFlowFieldVo.setTaskId(vo.getTaskId());
updateFlowFieldVo.setTaskDefKey(vo.getTaskDefKey());
updateFlowFieldVo.setProcDefId(bv.getModelId());
updateFlowFieldVo.setSid(bv.getBusinessSid());
return rb.success().setData(updateFlowFieldVo).setMsg("流程启动成功");
}
}
if (bv.getUserSid().equals(nextNodeUserSids)) {
//如果申请人与下一环节审批人相同,则自动审批
bv.setModelId(procDefId);
bv.setInstanceId(task.getProcessInstanceId());
bv.setTaskId(id_);
bv.setUserSid(nextNodeUserSids);
bv.setBusinessSid(bv.getBusinessSid());
bv.setTaskDefKey(task_def_key_);
bv.setFormVariables(variables);
bv.setOrgSidPath(bv.getOrgSidPath());
bv.setFormVariables(variablesSeconds);
bv.setComment("因与申请人相同,系统自动处理,需以下一级审批人审批意见为准!");
bv.setNextNodeUserSids("");
ResultBean<UpdateFlowFieldVo> updateFlowFieldVoResultBean = handleProsess(bv, false);
if (updateFlowFieldVoResultBean.getSuccess() && updateFlowFieldVoResultBean.getData() != null) {
UpdateFlowFieldVo vo = updateFlowFieldVoResultBean.getData();
updateFlowFieldVo.setProcInsId(vo.getProcInsId());
updateFlowFieldVo.setNodeState(vo.getNodeState());
updateFlowFieldVo.setTaskId(vo.getTaskId());
updateFlowFieldVo.setTaskDefKey(vo.getTaskDefKey());
updateFlowFieldVo.setProcDefId(bv.getModelId());
updateFlowFieldVo.setSid(bv.getBusinessSid());
return rb.success().setData(updateFlowFieldVo).setMsg("流程启动成功");
}
}
updateFlowFieldVo.setProcInsId(task.getProcessInstanceId());
updateFlowFieldVo.setNodeState(latestTaskVo.getName_());
updateFlowFieldVo.setTaskId(id_);
updateFlowFieldVo.setTaskDefKey(task_def_key_);
updateFlowFieldVo.setProcDefId(bv.getModelId());
updateFlowFieldVo.setSid(bv.getBusinessSid());
return rb.success().setData(updateFlowFieldVo).setMsg("流程启动成功");
}
/**
* 查询下一环节用户是否有转办用户若有转办用户则添加转办评论
*
* @param nextNodeUserSids 下一环节用户
* @param instanceId 实例id
* @return
*/
public String change(String nextNodeUserSids, String instanceId) {
//查询下一环节是否有转办
String firstSid = "";
String firstName = "";
//默认无转办
boolean isChange = false;
if (StringUtils.isNotBlank(nextNodeUserSids)) {
List<String> nextUserList = Arrays.asList(nextNodeUserSids.split(","));
if (nextUserList.size() == 1) {
firstSid = nextUserList.get(0);
ResultBean<SysUserVo> userVoResultBean = sysUserFeign.fetchBySid(firstSid);
if (userVoResultBean.getData() != null) {
firstName = userVoResultBean.getData().getName();
}
SysFlowableConfigQuery sysFlowableConfigQuery = new SysFlowableConfigQuery();
sysFlowableConfigQuery.setUserSid(firstSid);
sysFlowableConfigQuery.setNowDate(new Date());
ResultBean<SysFlowableConfigVvo> sysFlowableConfigVvoResultBean = sysFlowableConfigFeign.selectByUserSid(sysFlowableConfigQuery);
if (sysFlowableConfigVvoResultBean.getData() != null) {
if (StringUtils.isNotBlank(sysFlowableConfigVvoResultBean.getData().getChangeUserSid())) {
nextNodeUserSids = sysFlowableConfigVvoResultBean.getData().getChangeUserSid();
isChange = true;
}
}
}
}
if (isChange) {//添加评论
ResultBean<SysUserVo> userVoResultBean = sysUserFeign.fetchBySid(nextNodeUserSids);
ProcessCommentDto processCommentDto = new ProcessCommentDto();
processCommentDto.setReviewerSid(firstSid);
if (userVoResultBean.getData() != null) {
String changeName = userVoResultBean.getData().getName();
processCommentDto.setReviewer(firstName);
processCommentDto.setContent("交" + changeName + "转办");
}
processCommentDto.setTime(new Date());
processCommentDto.setProcessId(instanceId);
processCommentService.saveOrUpdateDto(processCommentDto);
}
return nextNodeUserSids;
}
public ResultBean<UpdateFlowFieldVo> handleProsess(BusinessVariables bv, boolean b) {
ResultBean<UpdateFlowFieldVo> rb = ResultBean.fireFail();
UpdateFlowFieldVo vo = new UpdateFlowFieldVo();
//获取表单中的参数
Map<String, Object> formVariables = bv.getFormVariables();
formVariables = formVariables == null ? new HashMap<>() : formVariables;
formVariables.put("businessSid", bv.getBusinessSid());
String nextUserSid = bv.getNextNodeUserSids();
String taskId = bv.getTaskId();
String userSid = bv.getUserSid();
String instanceId = bv.getInstanceId();
String comment = bv.getComment();
String nodeState = "";
String taskDefKey = "";
String orgPath = bv.getOrgSidPath();
//设置下一环节审批人是否自动审批通过,默认否
boolean contains = false;
//设置是否是管理员自动审批,默认否
boolean adminContains = false;
if (StringUtils.isBlank(nextUserSid)) {
ResultBean<String> stringResultBean = getNextNodeUserSidsOfSubmit(bv);
if (!stringResultBean.getSuccess()) {
//下一环节用户为空的情况
nextUserSid = ProcDefEnum.DEFAUL_TADMIN_SID.getProDefId();
adminContains = true;
} else {
nextUserSid = stringResultBean.getData();
}
} else {
//若下一环节用户与系统管理员一致,则自动审批
if (ProcDefEnum.DEFAUL_TADMIN_SID.getProDefId().equals(nextUserSid)) {
adminContains = true;
}
}
//查询任务id为taskId的任务是否存在
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
if (Objects.isNull(task)) {
return rb.setMsg("任务不存在");
}
String assignee = task.getAssignee();
if (b && (StringUtils.isNotBlank(assignee) && assignee.indexOf(userSid) < 0)) {
return rb.setMsg("当前用户不是环节的待办人,不能进行办理操作!");
}
if (DelegationState.PENDING.equals(task.getDelegationState())) {
//加签
taskService.addComment(taskId, instanceId,
FlowComment.DELEGATE.getType(), comment);
taskService.resolveTask(taskId, formVariables);
} else {
//当前环节办理通过,且将下一环节用户放入流程中
taskService.addComment(taskId, instanceId, FlowComment.NORMAL.getType(), comment);
log.error("taskid:{},userSid:{}", taskId, userSid);
log.error("formVariables:{}", JSON.toJSONString(formVariables));
taskService.setAssignee(taskId, userSid);
taskService.complete(taskId, formVariables);//当前用户办理通过
//根据流程实例的id取最新的待办环节,给环节设置上用户sid
ResultBean<List<LatestTaskVo>> ll = flowTaskService.getLatestTasksNew(instanceId);
if (ll.getData().size() > 0) {
LatestTaskVo latestTaskVo = ll.getData().get(0);
String id_ = latestTaskVo.getId_();
//查询下一环节用户是否有转办人
nextUserSid = change(nextUserSid, bv.getInstanceId());
taskService.setAssignee(id_, nextUserSid);//将下一环节用户放入流程中
vo.setTaskId(id_);
//在act_ru_variable表中增加环节上的业务参数的变量
taskService.setVariablesLocal(id_, formVariables);
nodeState = latestTaskVo.getName_();
taskDefKey = latestTaskVo.getTask_def_key_();
} else {
nodeState = FlowComment.SETTLE.getRemark();
taskDefKey = "Event_end";
vo.setNodeState(FlowComment.SETTLE.getRemark());
}
}
//设置管理员是否自动审批的字段是否是是。//若下一环节用户与系统管理员一致,则自动审批
if (adminContains) {
bv.setUserSid(nextUserSid);
bv.setTaskId(vo.getTaskId());
bv.setTaskDefKey(taskDefKey);
bv.setComment("系统自动跳过");
bv.setNextNodeUserSids("");
return handleProsess(bv, false);
}
//获取该流程所有要走的环节节点
List<FlowElement> flowElements = calApprovePath(bv.getModelId(),
bv.getFormVariables());
for (int i = 0; i < flowElements.size(); i++) {
FlowElement flowElement = flowElements.get(i);
String id = flowElement.getId();
if (taskDefKey.equals(id) && i + 1 < flowElements.size()) {
//获取下下一环节
FlowElement flowElement1 = flowElements.get(i + 1);
List<SysUserVo> sysUserVoLists2 = new ArrayList<>();
if (i + 2 < flowElements.size()) {
//获取下下下一环节用户
FlowElement flowElement2 = flowElements.get(i + 2);
if (flowElement2 instanceof UserTask) {
UserTask userTask = (UserTask) flowElement2;
List<String> candidateGroups = userTask.getCandidateGroups();
UserssQuery userssQuery = new UserssQuery();
userssQuery.setCandidateGroups(candidateGroups);
userssQuery.setOrgSidPath(orgPath);
sysUserVoLists2 = sysUserFeign.getUsersByRoles(userssQuery).getData();
if (sysUserVoLists2 == null) {
sysUserVoLists2 = new ArrayList<>();
}
}
}
if (flowElement1 instanceof UserTask) {
UserTask userTask = (UserTask) flowElement1;
List<String> candidateGroups = userTask.getCandidateGroups();
List<SysUserVo> sysUserVoLists = new ArrayList<>();
UserssQuery userssQuery = new UserssQuery();
userssQuery.setCandidateGroups(candidateGroups);
userssQuery.setOrgSidPath(orgPath);
sysUserVoLists = sysUserFeign.getUsersByRoles(userssQuery).getData();
if (sysUserVoLists == null) {
sysUserVoLists = new ArrayList<>();
}
//当前环节运营部总经理 刘丽艳 点击同意 下一环节 事业部副总经理 (nextUserSid) 和事业部总经理(sysUserVoLists.get(0).getSid())
//判断查询回来的用户的集合size是1 并且用户的sid和下一环节的用户的sid相同。
if (sysUserVoLists.size() == 1 && sysUserVoLists.get(0).getSid().equals(nextUserSid)) {
contains = true;
break;
}
//如果下下一环节无用户,下下下一环节用户与下一环节用户相同且只有一个,则下一环节用户自动审批。
if (sysUserVoLists.size() == 0 && sysUserVoLists2.size() == 1 && sysUserVoLists2.get(0).getSid().equals(nextUserSid)) {
contains = true;
break;
}
}
}
if (contains) {
break;
}
}
if (contains) {
bv.setUserSid(nextUserSid);
bv.setTaskId(vo.getTaskId());
bv.setTaskDefKey(taskDefKey);
bv.setComment("因与下一级审批人相同,系统自动处理,需以下一级审批人审批意见为准!");
return handleProsess(bv, false);
}
vo.setProcInsId(instanceId);
vo.setProcDefId(bv.getModelId());
vo.setNodeState(nodeState);
vo.setTaskDefKey(taskDefKey);
vo.setSid(bv.getBusinessSid());
return rb.success().setData(vo);
}
/**
* 获取下一环节用户
*
* @param bv
* @return
*/
public ResultBean<String> getNextNodeUserSidsOfSubmit(BusinessVariables bv) {
ResultBean<String> rb = ResultBean.fireFail();
String orgPath = bv.getOrgSidPath();
String taskDefKey = bv.getTaskDefKey();
//根据业务参数取流程流转的环节 信息
List<Map<String, Object>> list = (List<Map<String, Object>>) getProcessCirculationNodesByMap(bv).getData();
Map<String, Object> task_map = new HashMap<>();
boolean endTask = true;
for (int i = 0; i < list.size(); i++) {
String id = list.get(i).get("id").toString();
if (id.equals(taskDefKey) && i + 1 < list.size()) {
task_map = list.get(i + 1);
endTask = false;
}
}
if (endTask) {
task_map.put("name", "结束");
return rb.success();
} else {
Object o = task_map.get("candidateGroups");
JSONArray jsonArray = JSONArray.parseArray(JSON.toJSONString(o));
String roleSid = jsonArray.get(0).toString();
//根据组织架构、角色两个参数取相关符合条件的用户信息
UserQuery userQuery = new UserQuery();
userQuery.setRoleSid(roleSid);
userQuery.setOrgSidPath(orgPath);
String nextNodeUserSids_ = "";
List<SysUserVo> sysUserVos = sysUserFeign.getUserByRole(userQuery).getData();
if (sysUserVos == null || sysUserVos.size() < 1) {
return rb;
} else {
StringBuilder nextNodeUserSids = new StringBuilder();
for (SysUserVo su : sysUserVos) {
nextNodeUserSids.append(su.getSid()).append(",");
}
//符合条件的用户的sid,拼接的字符串
nextNodeUserSids_ = nextNodeUserSids.toString();
nextNodeUserSids_ = nextNodeUserSids_.substring(0, nextNodeUserSids_.length() - 1);
}
return rb.success().setData(nextNodeUserSids_);
}
}
/**
* 流程抄送的功能
*
* @param map
* @return
*/
public ResultBean cc(Map<String, Object> map, String taskDefKey) {
ResultBean rb = ResultBean.fireFail();
log.info("FlowableRest-cc:{}", JSONObject.toJSONString(map));
Object bv1 = map.get("bv");
BusinessVariables bv = new BusinessVariables();
BeanUtil.copyProperties(bv1, bv);
Object uff1 = map.get("uff");
UpdateFlowFieldVo uff = new UpdateFlowFieldVo();
BeanUtil.copyProperties(uff1, uff);
uff.setTaskDefKey(taskDefKey);
//流程定义的id
String modelId = bv.getModelId();
//将modelId根据冒号:分成三部分,取第一部分作为key
List<String> stringList = Arrays.asList(modelId.split(":"));
modelId = stringList.get(0);
//抄送的角色的sid
ResultBean<SysFlowccVo> roleSidByModelId = sysFlowccFeign.getRoleSidByModelId(modelId);
//组织机构sid
String orgSidPath = bv.getOrgSidPath();
if (roleSidByModelId.getData() == null) {
log.info("抄送失败,没有配置对应的角色!");
return rb.setMsg("抄送失败,没有配置对应的角色!");
}
SysFlowccVo data = roleSidByModelId.getData();
if (StringUtils.isBlank(data.getRoleSid())) {
log.info("抄送失败,没有配置对应的角色!");
return rb.setMsg("抄送失败,没有配置对应的角色!");
}
List<String> list = Arrays.asList(data.getRoleSid().split(","));
UserByRolesAndOrgQuery userQuery = new UserByRolesAndOrgQuery();
userQuery.setRoleSids(list);
userQuery.setOrgSidPath(orgSidPath);
List<SysUserVo> sysUserVos = sysUserFeign.getUserByRoles(userQuery).getData();
if (sysUserVos == null || sysUserVos.size() < 1) {
log.info("抄送失败,没有用户!");
return rb.setMsg("抄送失败,没有用户!");
}
StringBuilder userName = new StringBuilder();
StringBuilder userSids = new StringBuilder();
sysUserVos.forEach(f -> {
userName.append(f.getName()).append(",");
userSids.append(f.getSid()).append(",");
});
//抄送的业务逻辑
MessageFlowableQuery mfq = new MessageFlowableQuery();
MessageFlowVo messageFlowVo = new MessageFlowVo();
BeanUtil.copyProperties(uff, messageFlowVo);
mfq.setUfVo(messageFlowVo);
//移动端的参数
HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery()
.includeProcessVariables().taskId(bv.getTaskId()).singleResult();
if (historicTaskInstance == null) {
log.info("抄送失败:没有获取到业务参数!");
return rb.setMsg("抄送失败!");
}
Map<String, Object> processVariables = historicTaskInstance.getProcessVariables();
String createrOrgPath = (String) processVariables.get("createrOrgPath");
if (historicTaskInstance == null) {
log.info("抄送失败:没有获取到业务参数!");
return rb.setMsg("抄送失败!");
}
Map<String, Object> app = new HashMap<>();
if (processVariables.get("app") != null) {
app = (Map<String, Object>) processVariables.get("app");
}
log.info("抄送方法-historicTaskInstance:{}", JSONObject.toJSONString(historicTaskInstance));
mfq.setAppMap(app);
mfq.setBusinessSid(bv.getBusinessSid());
mfq.setMsgContent("系统抄送的流程审批,请查看");
// act_re_procdef
Map<String, String> process = processService.getProcessDefByDefId(historicTaskInstance.getProcessDefinitionId());
log.info("抄送成功-process:{}", process);
if (process == null) {
log.info("抄送失败,流程定义不存在!");
return rb.setMsg("抄送失败,流程定义不存在!");
}
mfq.setModuleName(process.get("NAME_"));
if (processVariables.containsKey("orderNames")) {
mfq.setMsgTitle(processVariables.get("orderNames").toString());
} else {
mfq.setMsgTitle(process.get("NAME_"));
}
if (processVariables.containsKey("sendRecommendSid")) {//增加的其他的抄送人
userSids.append(processVariables.get("sendRecommendSid").toString()).append(",");
}
//查询是否有设置转办的,抄送给设置转办人员
List<String> zbUserSids = processCommentService.selectByIdAndComment("转办",bv.getInstanceId());
zbUserSids.removeAll(Collections.singleton(null));
if(!zbUserSids.isEmpty()){
String zbUser = String.join(",",zbUserSids);
userSids.append(zbUser).append(",");
}
userSids.deleteCharAt(userSids.length() - 1);
mfq.setUserSids(userSids.toString());
mfq.setOrgPath(createrOrgPath);
ResultBean<String> resultBean = messageFeign.pushMessageCC(mfq);
log.info("抄送成功:{}", userName.toString());
log.info("抄送成功-resultBean:{}", resultBean);
if (!resultBean.getSuccess()) {
log.info("抄送失败,同送消息异常!:{}", JSONObject.toJSONString(resultBean));
return rb.setMsg("抄送失败,同送消息异常!");
}
return rb.success().setMsg("抄送" + userName.toString() + "成功!");
}
}

2
anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/processcomment/ProcessCommentMapper.java

@ -69,4 +69,6 @@ public interface ProcessCommentMapper extends BaseMapper<ProcessComment> {
ProcessComment fetchBySid(@Param("sid")String sid);
void insertByDto(ProcessCommentDto dto);
List<String> selectByIdAndComment(@Param("comment") String comment, @Param("instanceId") String instanceId);
}

4
anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/processcomment/ProcessCommentMapper.xml

@ -17,4 +17,8 @@
insert into `process_comment` ( `sid`, `reviewer`, `reviewerSid`, `time`, `content`, `processId`, `processInstSid`,processFile)
values(#{sid},#{reviewer},#{reviewerSid},#{time},#{content},#{processId},#{processInstSid},#{processFile});
</insert>
<select id="selectByIdAndComment" resultType="java.lang.String">
select reviewerSid from process_comment where content like concat('%',#{comment}) and processId = #{instanceId}
</select>
</mapper>

4
anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/processcomment/ProcessCommentService.java

@ -135,4 +135,8 @@ public class ProcessCommentService extends MybatisBaseService<ProcessCommentMapp
}
return commentList;
}
public List<String> selectByIdAndComment(String comment, String instanceId) {
return baseMapper.selectByIdAndComment(comment, instanceId);
}
}

4
anrui-riskcenter/anrui-riskcenter-api/src/main/java/com/yxt/anrui/riskcenter/api/loanpreloancreditapply/LoanPreloanCreditApplyVo.java

@ -67,4 +67,8 @@ public class LoanPreloanCreditApplyVo implements Vo {
private String zffkjg;
@ApiModelProperty("申诉结果")
private String ssjg;
@ApiModelProperty("是否可以办理")
private Boolean isEdit;
@ApiModelProperty("是否可以删除")
private Boolean isDelete;
}

20
anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanpreloancreditapply/LoanPreloanCreditApplyService.java

@ -141,6 +141,16 @@ public class LoanPreloanCreditApplyService extends MybatisBaseService<LoanPreloa
}
IPage<LoanPreloanCreditApply> page = PagerUtil.queryToPage(pq);
IPage<LoanPreloanCreditApplyVo> pagging = baseMapper.selectPageVo(page, qw);
for (LoanPreloanCreditApplyVo record : pagging.getRecords()) {
String state = record.getState();
if ("1".equals(state)){
record.setIsEdit(true);
record.setIsDelete(true);
}else {
record.setIsEdit(false);
record.setIsDelete(false);
}
}
PagerVo<LoanPreloanCreditApplyVo> p = PagerUtil.pageToVo(pagging, null);
return p;
}
@ -224,6 +234,16 @@ public class LoanPreloanCreditApplyService extends MybatisBaseService<LoanPreloa
}
IPage<LoanPreloanCreditApply> page = PagerUtil.queryToPage(pq);
IPage<LoanPreloanCreditApplyVo> pagging = baseMapper.selectPageVo(page, qw);
for (LoanPreloanCreditApplyVo record : pagging.getRecords()) {
String state = record.getState();
if ("0".equals(state)){
record.setIsEdit(true);
record.setIsDelete(false);
}else {
record.setIsEdit(false);
record.setIsDelete(false);
}
}
PagerVo<LoanPreloanCreditApplyVo> p = PagerUtil.pageToVo(pagging, null);
return p;
}

1006
工作内容需要的文档/单据模板/款项结转打印模板/kxjz.ftl

File diff suppressed because it is too large

7
工作内容需要的文档/单据模板/款项结转打印模板/款项结转(调账申请).doc

@ -1,6 +1,9 @@
|调账申请 |
|${saleDate!} |
|调账类|合同编号 |客户 |物料编码 |
|型 | |名称 | |
|调账类型 |合同编号 |客户名称 |物料编码 |调出金额 |调入金额 |
|${tz.tzTyp|${tz.conNo|${tz.name!|${tz.vinNo|${tz.dcje!|${tz.drje!|
|e!} |!} |} |!} |} |} |
|申请人|${makeName!} |审核 |${spName!} |
|: | |人: | |

Loading…
Cancel
Save