|
@@ -8,17 +8,25 @@ import com.huyi.service.common.flowable.service.ApprovalService;
|
|
|
import com.huyi.service.util.FlowableService;
|
|
|
import com.tianhu.common.core.utils.CommonUtil;
|
|
|
import com.tianhu.common.core.utils.DateUtils;
|
|
|
+import com.tianhu.common.security.service.TokenService;
|
|
|
+import com.tianhu.system.api.RemoteSystemService;
|
|
|
+import com.tianhu.system.api.model.LoginUser;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.cglib.beans.BeanMap;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@Service
|
|
|
public class ApprovalServiceImpl implements ApprovalService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RemoteSystemService remoteSystemService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private FlowableService flowableService;
|
|
|
// 开始流程
|
|
@@ -41,6 +49,9 @@ public class ApprovalServiceImpl implements ApprovalService {
|
|
|
private ApprovalService approvalService;
|
|
|
@Autowired
|
|
|
private IZcFinanceProductService zcFinanceProductService;
|
|
|
+ @Autowired
|
|
|
+ private TokenService tokenService;
|
|
|
+
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -52,36 +63,41 @@ public class ApprovalServiceImpl implements ApprovalService {
|
|
|
@Override
|
|
|
public void coreApproval(@RequestBody Map map) throws Exception {
|
|
|
Map<String, Object> flowParam = new HashMap<String, Object>();
|
|
|
+ //融信Id
|
|
|
+ String zfiId = CommonUtil.objToString(map.get("zfiId"));
|
|
|
+ //融信编号
|
|
|
+ String zfiNumber = CommonUtil.objToString(map.get("zfiNumber"));
|
|
|
//核心企业Id
|
|
|
String zfiCoreId = CommonUtil.objToString(map.get("zfiCoreId"));
|
|
|
+ //融资企业Id
|
|
|
+ String zfiSupplierId = CommonUtil.objToString(map.get("zfiSupplierId"));
|
|
|
LambdaQueryWrapper<SysCompany> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
queryWrapper.eq(SysCompany::getScyId,zfiCoreId);
|
|
|
List<SysCompany> list = iSysCompanyService.findSysCompanys(queryWrapper);
|
|
|
- //根据企业id获取用户id
|
|
|
- LambdaQueryWrapper<SysUserCompanyRel> userQuery = new LambdaQueryWrapper<>();
|
|
|
- userQuery.eq(SysUserCompanyRel::getSucrCompanyId,zfiCoreId);
|
|
|
- //是否经办人
|
|
|
- userQuery.eq(SysUserCompanyRel::getSucrHandler,"1");
|
|
|
- List<SysUserCompanyRel> userList = iSysUserCompanyRelService.findSysUserCompanyRels(userQuery);
|
|
|
- //获取userId
|
|
|
- String userId = String.valueOf(userList.get(0).getSucrUserId());
|
|
|
- //获取userName
|
|
|
- SysUser sysUser = iSysUserService.getById(userId);
|
|
|
- String userName = sysUser.getNickName();
|
|
|
+ //核心企业名称
|
|
|
+ String scyName = list.get(0).getScyName();
|
|
|
//查询当前操作员
|
|
|
+ LoginUser user = tokenService.getLoginUser();
|
|
|
+ //当前企业ID
|
|
|
+ String companyId = user.getSysUser().getCompanyId();
|
|
|
+ Long userId = user.getSysUser().getUserId();
|
|
|
flowParam.put("menuId", "1000000000");
|
|
|
- flowParam.put("companyId", zfiCoreId);
|
|
|
+ flowParam.put("companyId", user.getSysUser().getCompanyId());
|
|
|
//双主键
|
|
|
- flowParam.put("businessKey", CommonUtil.objToString(map.get("zfiId")));
|
|
|
+ flowParam.put("businessKey", zfiId);
|
|
|
//员工编号
|
|
|
flowParam.put("sessionUserId", userId);
|
|
|
- flowParam.put("name",userName + "在" + DateUtils.getDate() + "发起融信开立审批");
|
|
|
+ if (!CommonUtil.isEmpty(scyName)){
|
|
|
+ flowParam.put("name",scyName + "在" + DateUtils.getDate() + "发起融信开立审批");
|
|
|
+ }
|
|
|
JSONObject jsonObj = new JSONObject(map);
|
|
|
flowParam.put("paras", jsonObj.toString());
|
|
|
Map<String, Object> resMap = flowableService.apiPost(STRART_FLOW, flowParam);
|
|
|
if("200".equals(resMap.get("code"))){
|
|
|
ZcFinanceInf zcFinanceInf = new ZcFinanceInf();
|
|
|
- zcFinanceInf.setZfiId(CommonUtil.objToString(map.get("zfiId")));
|
|
|
+ //主键
|
|
|
+ zcFinanceInf.setZfiId(zfiId);
|
|
|
+ //核心企业融资状态(00:审批中, 01:审批通过, 02:审批拒绝, 03:暂存)
|
|
|
zcFinanceInf.setZfiCoreStatus("00");
|
|
|
zcFinanceInfService.updateById(zcFinanceInf);
|
|
|
}else
|
|
@@ -90,15 +106,35 @@ public class ApprovalServiceImpl implements ApprovalService {
|
|
|
//修改状态为通过
|
|
|
ZcFinanceInf zcFinanceInf = new ZcFinanceInf();
|
|
|
//融信Id
|
|
|
- zcFinanceInf.setZfiId(CommonUtil.objToString(map.get("zfiId")));
|
|
|
+ zcFinanceInf.setZfiId(zfiId);
|
|
|
//核心企业融资状态(审批通过)
|
|
|
zcFinanceInf.setZfiCoreStatus("01");
|
|
|
- //审核通过(待签收)
|
|
|
- zcFinanceInf.setZfiStatus("01");
|
|
|
- zcFinanceInf.setUpdateBy(userId);
|
|
|
- zcFinanceInf.setUpdateTime(DateUtils.getNowDate());
|
|
|
zcFinanceInfService.updateById(zcFinanceInf);
|
|
|
- //TODO 发起人最终结果【通过】消息通知
|
|
|
+ //查询融资企业经办人
|
|
|
+ LambdaQueryWrapper<SysUserCompanyRel> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ //融资企业id
|
|
|
+ lambdaQueryWrapper.eq(SysUserCompanyRel::getSucrCompanyId,zfiSupplierId);
|
|
|
+ //是否经办人(1:是)
|
|
|
+ lambdaQueryWrapper.eq(SysUserCompanyRel::getSucrHandler,"1");
|
|
|
+ List<SysUserCompanyRel> listUser = iSysUserCompanyRelService.findSysUserCompanyRels(lambdaQueryWrapper);
|
|
|
+ //获取发送人
|
|
|
+ Long use = null;
|
|
|
+ List<Long> userIdList = new ArrayList<>();
|
|
|
+ if(listUser.size() > 0) {
|
|
|
+ use = listUser.get(0).getSucrUserId();
|
|
|
+ userIdList.add(use);
|
|
|
+ }
|
|
|
+ //发送盖章待办
|
|
|
+ remoteSystemService.sendNotice(zfiSupplierId, zfiId,
|
|
|
+ "核心企业开立审批由"+ scyName + "发起的融信编号为" + zfiNumber + "的资料待盖章",
|
|
|
+ "00",null,"03","0", userIdList,null);
|
|
|
+ //获取发送人
|
|
|
+ List<Long> longUser = new ArrayList<>();
|
|
|
+ longUser.add(userId);
|
|
|
+ //向发起人发送最终结果【通过】消息通知
|
|
|
+ remoteSystemService.sendNotice(companyId, String.valueOf(userId),
|
|
|
+ "核心企业开立审批融信编号为" + zfiNumber + "的资料审批已通过",
|
|
|
+ "01","01",null,"0", longUser, null);
|
|
|
}else if ("450".equals(resMap.get("code"))) {
|
|
|
throw new Exception("未配置审批流程");
|
|
|
}else if (!"200".equals(resMap.get("code"))) {
|
|
@@ -180,24 +216,36 @@ public class ApprovalServiceImpl implements ApprovalService {
|
|
|
@Override
|
|
|
public void coreConfirmationApproval(@RequestBody Map map) throws Exception {
|
|
|
Map<String, Object> flowParam = new HashMap<String, Object>();
|
|
|
+ //主键
|
|
|
+ String zfiId = CommonUtil.objToString(map.get("zfiId"));
|
|
|
//核心企业Id
|
|
|
String zfiCoreId = CommonUtil.objToString(map.get("zfiCoreId"));
|
|
|
- //根据企业id获取用户id
|
|
|
+ //根据主键获取实体
|
|
|
+ ZcFinanceInf financeInf = zcFinanceInfService.getById(zfiId);
|
|
|
+ //融信编号
|
|
|
+ String zfiNumber = financeInf.getZfiNumber();
|
|
|
+ //发起人
|
|
|
+ Long user = Long.valueOf(financeInf.getCreateBy());
|
|
|
+ //获取userName
|
|
|
+ SysUser sysUser = iSysUserService.getById(user);
|
|
|
+ String userName = sysUser.getNickName();
|
|
|
+ //获取核心企业经办人
|
|
|
LambdaQueryWrapper<SysUserCompanyRel> userQuery = new LambdaQueryWrapper<>();
|
|
|
userQuery.eq(SysUserCompanyRel::getSucrCompanyId,zfiCoreId);
|
|
|
//是否经办人
|
|
|
userQuery.eq(SysUserCompanyRel::getSucrHandler,"1");
|
|
|
List<SysUserCompanyRel> userList = iSysUserCompanyRelService.findSysUserCompanyRels(userQuery);
|
|
|
- //获取userId
|
|
|
- String userId = String.valueOf(userList.get(0).getSucrUserId());
|
|
|
- //获取userName
|
|
|
- SysUser sysUser = iSysUserService.getById(userId);
|
|
|
- String userName = sysUser.getNickName();
|
|
|
-
|
|
|
+ //获取经办人Id
|
|
|
+ Long userId = null;
|
|
|
+ List<Long> longUserList = new ArrayList<>();
|
|
|
+ if(userList.size() > 0) {
|
|
|
+ userId = userList.get(0).getSucrUserId();
|
|
|
+ longUserList.add(userId);
|
|
|
+ }
|
|
|
flowParam.put("menuId", "1000000007");
|
|
|
flowParam.put("companyId", zfiCoreId);
|
|
|
//双主键
|
|
|
- flowParam.put("businessKey", CommonUtil.objToString(map.get("zfiId")));
|
|
|
+ flowParam.put("businessKey", zfiId);
|
|
|
//员工编号
|
|
|
flowParam.put("sessionUserId", userId);
|
|
|
flowParam.put("name", userName + "在" + DateUtils.getDate() + "发起确权审批");
|
|
@@ -206,29 +254,34 @@ public class ApprovalServiceImpl implements ApprovalService {
|
|
|
Map<String, Object> resMap = flowableService.apiPost(STRART_FLOW, flowParam);
|
|
|
//成功
|
|
|
if("200".equals(resMap.get("code"))){
|
|
|
- //TODo 核心企业经办人盖章待办
|
|
|
+ //改为审批中
|
|
|
+ ZcFinanceInf zcFinanceInf = new ZcFinanceInf();
|
|
|
+ zcFinanceInf.setZfiId(zfiId);
|
|
|
+ zcFinanceInf.setZfiCoreStatus("00");
|
|
|
+ zcFinanceInfService.updateById(zcFinanceInf);
|
|
|
}else
|
|
|
- //未开启流程实例
|
|
|
- if("300".equals(resMap.get("code")) || "350".equals(resMap.get("code"))){
|
|
|
- ZcFinanceInf zcFinanceInf = zcFinanceInfService.getById(CommonUtil.objToString(map.get("zfiId")));
|
|
|
- String type = zcFinanceInf.getZfiCreateType();
|
|
|
- if("0".equals(type)){
|
|
|
- approvalService.addSignApproval(map);
|
|
|
- }else if("2".equals(type)){
|
|
|
- //已生效
|
|
|
- zcFinanceInf.setZfiStatus("02");
|
|
|
- //签收时间
|
|
|
- zcFinanceInf.setZfiSignDate(DateUtils.getNowDate());
|
|
|
+ //未开启流程实例
|
|
|
+ if("300".equals(resMap.get("code")) || "350".equals(resMap.get("code"))){
|
|
|
+ //审批通过
|
|
|
+ ZcFinanceInf zcFinanceInf = new ZcFinanceInf();
|
|
|
+ zcFinanceInf.setZfiId(zfiId);
|
|
|
+ zcFinanceInf.setZfiCoreStatus("01");
|
|
|
zcFinanceInfService.updateById(zcFinanceInf);
|
|
|
+ List<Long> longUser = new ArrayList<>();
|
|
|
+ longUser.add(user);
|
|
|
+ remoteSystemService.sendNotice(zfiCoreId, zfiId,
|
|
|
+ "确权审批融信编号为" + zfiNumber + "的资料审批已通过",
|
|
|
+ "01","01",null,"0", longUser, null);
|
|
|
+ //向核心企业经办人发送盖章待办
|
|
|
+ remoteSystemService.sendNotice(zfiCoreId, zfiId,
|
|
|
+ "确权审批融信编号为" + zfiNumber + "的资料待盖章,审批发起人为" + userName,
|
|
|
+ "00",null,"03","0", longUserList,null);
|
|
|
+ //未配置审批流程
|
|
|
+ }else if ("450".equals(resMap.get("code"))) {
|
|
|
+ throw new Exception("未配置审批流程");
|
|
|
+ }else if (!"200".equals(resMap.get("code"))) {
|
|
|
+ throw new Exception(resMap.get("message").toString());
|
|
|
}
|
|
|
- //TODO 核心企业经办人最终结果【通过】消息通知
|
|
|
- //TODo 核心企业盖章待办事项。
|
|
|
- //未配置审批流程
|
|
|
- }else if ("450".equals(resMap.get("code"))) {
|
|
|
- throw new Exception("未配置审批流程");
|
|
|
- }else if (!"200".equals(resMap.get("code"))) {
|
|
|
- throw new Exception(resMap.get("message").toString());
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
|