qa-prevention-gwj/src/main/java/com/zcloud/service/xgf/impl/XgfUserServiceImpl.java

1234 lines
62 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.zcloud.service.xgf.impl;
import com.alibaba.fastjson.JSONObject;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.zcloud.entity.Page;
import com.zcloud.entity.PageData;
import com.zcloud.flow.xgf.util.XgfFlowDto;
import com.zcloud.mapper.datasource.bus.CorpInfoMapper;
import com.zcloud.mapper.datasource.xgf.*;
import com.zcloud.service.system.DepartmentService;
import com.zcloud.service.system.UsersService;
import com.zcloud.service.xgf.XgfUserService;
import com.zcloud.util.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.net.PasswordAuthentication;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class XgfUserServiceImpl implements XgfUserService {
@Resource
private XgfUserMapper xgfUserMapper;
@Resource
private XgfUserDetailsMapper xgfUserDetailsMapper;
@Resource
private DepartmentService departmentService;
@Resource
private FlowMapper flowMapper;
@Resource
private FlowDetailMapper flowDetailMapper;
@Resource
private XgfFlowsMapper xgfFlowsMapper;
@Resource
private CorpInfoMapper corpInfoMapper;
@Value("${preventionxgf.api.url}")
private String prevention_xgf_url;
@Resource
private FlowExecutor flowExecutor;
@Resource
private UsersService usersService;
@Override
public void save(PageData pd) throws Exception {
xgfUserMapper.save(pd);
}
@Override
public void saveDetail(PageData pd) throws Exception {
xgfUserDetailsMapper.save(pd);
}
@Override
public List<PageData> list(Page page) throws Exception {
return xgfUserDetailsMapper.listPage(page);
}
@Override
@Transactional
public void init(PageData request) throws Exception {
List<PageData> list = Warden.getList(request.getString("infoList"));
PageData condition = new PageData();
for (PageData x : list) {
if (StringUtils.isNotBlank(x.getString("USER_ID"))) {
/* 1、 保存相关方用户信息 */
condition.put("XGF_USER_ID", x.getString("USER_ID"));
PageData entity = xgfUserMapper.findById(condition);
if (entity == null || entity.size() <= 0) {
x.put("XGF_USER_ID", x.get("USER_ID"));
x.put("XGF_USER_DETAILS_ID", x.get("USER_ID"));
x.put("XGF_USER_NAME", x.get("NAME"));
x.put("VALID_FLAG", "1");
x.put("STATUS", "1");
x.put("CHECK_STATUS", "1");
x.put("CHECK_STEP", 0);
x.put("CREATED_TIME", DateUtil.getTime());
x.put("OPERATOR_TIME", DateUtil.getTime());
x.put("IS_DELETE", "0");
x.put("CREATE_TIME", DateUtil.getTime());
/* 监管部门 */
condition.clear();
condition.put("DEPARTMENT_ID", x.get("MANAGER_DEPARTMENT_ID"));
PageData regDepartmentEntity = departmentService.getCorpDepartment(condition);
if (regDepartmentEntity != null && regDepartmentEntity.size() > 0) {
x.put("MANAGER_DEPARTMENT_NAME", regDepartmentEntity.get("NAME"));
}
/* 主管部门 */
// 2024-03-20 liu jun :为了兼容新老数据这里做特殊处理
if (x.get("MAIN_DEPARTMENT_ID") != null && StringUtils.isNotBlank(x.get("MAIN_DEPARTMENT_ID").toString())) {
if (x.getString("MAIN_DEPARTMENT_ID").contains("]")) {
List<String> mainDepartmentIds = JSONObject.parseArray(x.getString("MAIN_DEPARTMENT_ID"),String.class);
List<String> mainDepartmentNames = new ArrayList<>();
for (String mainDepartmentId : mainDepartmentIds) {
condition.clear();
condition.put("DEPARTMENT_ID", mainDepartmentId);
regDepartmentEntity = departmentService.getCorpDepartment(condition);
if (regDepartmentEntity != null && regDepartmentEntity.size() > 0) {
mainDepartmentNames.add(regDepartmentEntity.getString("NAME"));
}
}
x.put("MAIN_DEPARTMENT_NAME", StringUtils.join(mainDepartmentNames, ","));
}else {
condition.clear();
condition.put("DEPARTMENT_ID", x.get("MAIN_DEPARTMENT_ID"));
regDepartmentEntity = departmentService.getCorpDepartment(condition);
if (regDepartmentEntity != null && regDepartmentEntity.size() > 0) {
x.put("MAIN_DEPARTMENT_NAME", regDepartmentEntity.get("NAME"));
}
}
} else {
throw new RuntimeException("主管部门ID不能为空");
}
entity = new PageData();
entity.putAll(x);
xgfUserMapper.save(x);
xgfUserDetailsMapper.save(x);
} else {
x.put("XGF_USER_ID", x.get("USER_ID"));
x.put("XGF_USER_DETAILS_ID", x.get("USER_ID"));
x.put("XGF_USER_NAME", x.get("NAME"));
x.put("IS_DELETE", "0");
x.put("CREATE_TIME", DateUtil.getTime());
x.put("OPERATOR_TIME", DateUtil.getTime());
/* 监管部门 */
condition.clear();
condition.put("DEPARTMENT_ID", x.get("MANAGER_DEPARTMENT_ID"));
PageData regDepartmentEntity = departmentService.getCorpDepartment(condition);
if (regDepartmentEntity != null && regDepartmentEntity.size() > 0) {
x.put("MANAGER_DEPARTMENT_NAME", regDepartmentEntity.get("NAME"));
}
/* 主管部门 */
// 2024-03-20 liu jun :为了兼容新老数据这里做特殊处理
if (x.get("MAIN_DEPARTMENT_ID") != null && StringUtils.isNotBlank(x.get("MAIN_DEPARTMENT_ID").toString())) {
if (x.getString("MAIN_DEPARTMENT_ID").contains("]")) {
List<String> mainDepartmentIds = JSONObject.parseArray(x.getString("MAIN_DEPARTMENT_ID"), String.class);
List<String> mainDepartmentNames = new ArrayList<>();
for (String mainDepartmentId : mainDepartmentIds) {
condition.clear();
condition.put("DEPARTMENT_ID", mainDepartmentId);
regDepartmentEntity = departmentService.getCorpDepartment(condition);
if (regDepartmentEntity != null && regDepartmentEntity.size() > 0) {
mainDepartmentNames.add(regDepartmentEntity.getString("NAME"));
}
}
x.put("MAIN_DEPARTMENT_NAME", StringUtils.join(mainDepartmentNames, ","));
} else {
condition.clear();
condition.put("DEPARTMENT_ID", x.get("MAIN_DEPARTMENT_ID"));
regDepartmentEntity = departmentService.getCorpDepartment(condition);
if (regDepartmentEntity != null && regDepartmentEntity.size() > 0) {
x.put("MAIN_DEPARTMENT_NAME", regDepartmentEntity.get("NAME"));
}
}
} else {
throw new RuntimeException("主管部门ID不能为空");
}
x.put("IS_DELETE", "0");
x.put("VALID_FLAG", "1");
x.put("STATUS", "1");
x.put("CHECK_STATUS", "1");
x.put("CHECK_STEP", 0);
if ("2".equals(x.getString("STUDY_STATUS"))) {
x.put("STUDY_STATUS", "2");
} else {
x.put("STUDY_STATUS", entity.getString("STUDY_STATUS"));
}
x.put("STUDY_STATUS", entity.getString("STUDY_STATUS"));
xgfUserMapper.edit(x);
// 2024-02-26 created by liu jun 清空上传文件信息
x.put("ATTORNEY", "");
x.put("COMMITMENT_LETTER", "");
xgfUserDetailsMapper.edit(x);
}
/* 2、保存相关方人员流程审批信息 */
condition.clear();
condition.put("FLOWS_ID", x.getString("USER_ID"));
PageData flows = xgfFlowsMapper.findById(condition);
if (flows == null || flows.size() <= 0) {
flows = new PageData();
flows.put("FLOWS_TYPE", getType(x.getString("CORPINFO_ID")));
flows.put("FLOWS_ID", x.getString("USER_ID"));
flows.put("FLOWS_STEP", 0);
flows.put("FOREIGN_KEY_ID", x.getString("USER_ID"));
flows.put("FOREIGN_KEY_NAME", "xgf_user=>XGF_USER_ID");
flows.put("IS_DELETE", "0");
flows.put("APPOINT_ZERO_CORP_TYPE", "0");
flows.put("APPOINT_ZERO_CORP_ID", x.getString("APPOINT_CORP_ID"));
flows.put("APPOINT_ZERO_CORP_NAME", x.getString("APPOINT_CORP_NAME"));
flows.put("APPOINT_ZERO_DEPARTMENT_ID", x.getString("APPOINT_DEPARTMENT_ID"));
flows.put("APPOINT_ZERO_DEPARTMENT_NAME", x.getString("APPOINT_DEPARTMENT_NAME"));
flows.put("APPOINT_ZERO_USER_ID", x.getString("APPOINT_USER_ID"));
flows.put("APPOINT_ZERO_USER_NAME", x.getString("APPOINT_USER_NAME"));
xgfFlowsMapper.save(flows);
} else {
flows.put("FLOWS_STEP", 0);
flows.put("FLOWS_TYPE", getType(x.getString("CORPINFO_ID")));
flows.put("APPOINT_ZERO_CORP_NAME", x.getString("APPOINT_CORP_NAME"));
flows.put("APPOINT_ZERO_CORP_ID", x.getString("APPOINT_CORP_ID"));
flows.put("APPOINT_ZERO_CORP_TYPE", "0");
flows.put("APPOINT_ZERO_DEPARTMENT_ID", x.getString("APPOINT_DEPARTMENT_ID"));
flows.put("APPOINT_ZERO_DEPARTMENT_NAME", x.getString("APPOINT_DEPARTMENT_NAME"));
flows.put("APPOINT_ZERO_USER_ID", x.getString("APPOINT_USER_ID"));
flows.put("APPOINT_ZERO_USER_NAME", x.getString("APPOINT_USER_NAME"));
xgfFlowsMapper.edit(flows);
}
/* 3、流程记录 */
condition.clear();
condition.put("FOREIGN_KEY", x.getString("XGF_USER_ID"));
condition.put("TYPE", "1");
condition.put("VALID_FLAG", "1");
condition.put("END_FLAG", "0");
PageData flow = flowMapper.findByCondition(condition);
if (flow == null || flow.size() == 0) {
/* 保存审批流程信息 */
flow = new PageData();
flow.put("FLOW_ID", Warden.get32UUID());
flow.put("TYPE", "1");
flow.put("CREATOR", "");
flow.put("CREATOR_NAME", "");
flow.put("CREATOR_TIME", DateUtil.getTime());
flow.put("VALID_FLAG", "1");
flow.put("ISDELETE", "0");
flow.put("END_FLAG", "0");
flow.put("FOREIGN_KEY", x.getString("XGF_USER_ID"));
flowMapper.save(flow);
/* 保存审批流程明细信息 */
PageData flowDetail = new PageData();
flowDetail.put("FLOW_DETAIL_ID", Warden.get32UUID());
flowDetail.put("FLOW_ID", flow.getString("FLOW_ID"));
flowDetail.put("STEP_FLAG", "1");
flowDetail.put("STEP_NAME", "相关方提交人员信息到发包单位");
flowDetail.put("SORT", 0);
flowDetail.put("APPROVER_ID", "");
flowDetail.put("APPROVER_NAME", "");
flowDetail.put("APPROVER_TIME", DateUtil.getTime());
flowDetail.put("APPROVER_CORPINFO_ID", entity.getString("BELONG_TO_CORP"));
flowDetail.put("APPROVER_CORPINFO_NAME", entity.getString("BELONG_TO_CORP_NAME"));
flowDetail.put("APPOINT_ANNEX", x.getString("ANNEX"));
flowDetail.put("PASS_FLAG", "1");
flowDetail.put("END_FLAG", "0");
flowDetail.put("ISDELETE", "0");
flowDetail.put("PARENT_ID", "0");
flowDetailMapper.save(flowDetail);
} else {
condition.clear();
condition.put("FLOW_ID", flow.getString("FLOW_ID"));
condition.put("STEP_FLAG", "1");
PageData currentNode = flowDetailMapper.selectOne(condition);
PageData nextNode = new PageData();
nextNode.putAll(currentNode);
nextNode.put("FLOW_DETAIL_ID", Warden.get32UUID());
nextNode.put("SORT", Integer.parseInt(currentNode.get("SORT").toString()) + 1);
nextNode.put("PARENT_ID", currentNode.getString("FLOW_DETAIL_ID"));
nextNode.put("STEP_NAME", "相关方重新提交人员信息给发包单位");
nextNode.put("PASS_FLAG", "1");
nextNode.put("APPROVER_TIME", DateUtil.getTime());
nextNode.put("APPROVER_ID", "");
nextNode.put("APPROVER_NAME", "");
nextNode.put("APPROVER_OPINION", "");
nextNode.put("APPROVER_CORPINFO_ID", entity.getString("BELONG_TO_CORP"));
nextNode.put("APPROVER_CORPINFO_NAME", entity.getString("BELONG_TO_CORP_NAME"));
nextNode.put("APPOINT_ANNEX", x.getString("ANNEX"));
flowDetailMapper.save(nextNode);
currentNode.put("STEP_FLAG", "0");
flowDetailMapper.edit(currentNode);
}
}
}
}
@Override
public void approvalApplication(PageData request) throws Exception {
List<String> list = Arrays.asList(request.getString("xgf_user_ids").split(","));
PageData condition = new PageData();
condition.put("XGF_USER_IDS", list);
List<PageData> entities = xgfUserMapper.listByIds(condition);
/* 校验所有数据是否都是正常状态 */
if (entities.stream().anyMatch(n -> !"2".equals(n.getString("STATUS")))) {
String name = entities.stream().filter(n -> !"2".equals(n.getString("STATUS"))).map(n -> n.getString("NAME")).collect(Collectors.joining(","));
throw new RuntimeException("用户[" + name + "]在系统流程中无法被打回");
}
for (PageData x : entities) {
x.put("VALID_FLAG", "0");
x.put("STATUS", "1");
xgfUserMapper.edit(x);
}
}
@Override
public List<PageData> flowlistPage(Page page) throws Exception {
return xgfUserMapper.flowlistPage(page);
}
@Override
@Transactional
public void approve(PageData request) throws Exception {
List<PageData> _list = Warden.getList(request.getString("list"));
if (_list == null || _list.size() == 0) {
throw new RuntimeException("请求数据异常");
}
List<String> list = _list.stream().map(x -> x.getString("XGF_USER_ID")).collect(Collectors.toList());
PageData condition = new PageData();
for (String x : list) {
condition.put("XGF_USER_ID", x);
/* 保存审批信息 */
condition.clear();
condition.put("FLOWS_ID", x);
PageData flows = xgfFlowsMapper.findById(condition);
if (flows == null || flows.size() == 0) {
throw new RuntimeException("未找到该用户详细信息");
}
condition.clear();
condition.put("STATUS", request.getString("STATUS"));
condition.put("OPINION", request.getString("OPINION"));
condition.put("APPOINT_CORP_ID", request.getString("APPOINT_CORP_ID"));
condition.put("APPOINT_CORP_NAME", request.getString("APPOINT_CORP_NAME"));
condition.put("APPOINT_DEPARTMENT_ID", request.getString("APPOINT_DEPARTMENT_ID"));
condition.put("APPOINT_DEPARTMENT_NAME", request.getString("APPOINT_DEPARTMENT_NAME"));
condition.put("APPOINT_USER_ID", request.getString("APPOINT_USER_ID"));
condition.put("APPOINT_USER_NAME", request.getString("APPOINT_USER_NAME"));
condition.put("LIMIT_END_TIME", request.get("LIMIT_END_TIME"));
if (request.get("APPOINT_ANNEX") != null) {
condition.put("APPOINT_ANNEX", request.getString("APPOINT_ANNEX"));
}
condition.put("FLOWS_ID", x);
// 保存审批记录
this.saveLog(condition, request.getString("STATUS"), this.handle(condition, flows));
}
}
@Override
public PageData findInfo(PageData condition) {
return xgfUserMapper.getInfoById(condition);
}
@Override
public List<PageData> findRecordList(PageData condition) throws Exception {
return xgfUserMapper.findRecordList(condition);
}
@Override
public List<PageData> getAppointApproveList(Page page) {
List<PageData> list = xgfUserMapper.appointlistPage(page);
for (PageData x : list) {
x.put("power_flag", getPower(x));
}
return list;
}
@Override
public Object getApproveInfo(PageData request) {
PageData condition = new PageData();
condition.put("FOREIGN_KEY", request.getString("XGF_USER_ID"));
condition.put("TYPE", "1");
List<PageData> list = flowMapper.getList(condition);
for (PageData x : list) {
condition.clear();
condition.put("FLOW_ID", x.getString("FLOW_ID"));
List<PageData> flow = flowDetailMapper.getList(condition);
flow = flow.stream().sorted(Comparator.comparing(o -> new BigDecimal(String.valueOf(o.get("SORT"))))).collect(Collectors.toList());
x.put("flow",flow);
}
return list;
}
@Override
public Object getFlowInfo(PageData request) {
PageData condition = new PageData();
condition.put("FLOWS_ID", request.getString("XGF_USER_ID"));
PageData entity = xgfFlowsMapper.findById(condition);
List<PageData> list = new ArrayList<>();
PageData zero = new PageData();
int index = Integer.parseInt(entity.getString("FLOWS_STEP"));
if (index >= 0) {
zero.put("INDEX", "0");
zero.put("APPOINT_CORP_ID", entity.getString("APPOINT_ZERO_CORP_ID"));
zero.put("APPOINT_CORP_NAME", entity.getString("APPOINT_ZERO_CORP_NAME"));
zero.put("APPOINT_DEPARTMENT_ID", entity.getString("APPOINT_ZERO_DEPARTMENT_ID"));
zero.put("APPOINT_DEPARTMENT_NAME", entity.getString("APPOINT_ZERO_DEPARTMENT_NAME"));
zero.put("APPOINT_USER_ID", entity.getString("APPOINT_ZERO_USER_ID"));
zero.put("APPOINT_USER_NAME", entity.getString("APPOINT_ZERO_USER_NAME"));
zero.put("APPOINT_STATUS", entity.getString("APPOINT_ZERO_STATUS"));
zero.put("APPOINT_OPINION", entity.getString("APPOINT_ZERO_OPINION"));
zero.put("APPOINT_TIME", entity.getString("APPOINT_ZERO_TIME"));
list.add(zero);
}
if (index >= 1) {
PageData one = new PageData();
one.put("INDEX", "1");
one.put("APPOINT_CORP_ID", entity.getString("APPOINT_ONE_CORP_ID"));
one.put("APPOINT_CORP_NAME", entity.getString("APPOINT_ONE_CORP_NAME"));
one.put("APPOINT_DEPARTMENT_ID", entity.getString("APPOINT_ONE_DEPARTMENT_ID"));
one.put("APPOINT_DEPARTMENT_NAME", entity.getString("APPOINT_ONE_DEPARTMENT_NAME"));
one.put("APPOINT_USER_ID", entity.getString("APPOINT_ONE_USER_ID"));
one.put("APPOINT_USER_NAME", entity.getString("APPOINT_ONE_USER_NAME"));
one.put("APPOINT_STATUS", entity.getString("APPOINT_ONE_STATUS"));
one.put("APPOINT_OPINION", entity.getString("APPOINT_ONE_OPINION"));
one.put("APPOINT_TIME", entity.getString("APPOINT_ONE_TIME"));
list.add(one);
}
if (index >= 2) {
PageData two = new PageData();
two.put("INDEX", "2");
two.put("APPOINT_CORP_ID", entity.getString("APPOINT_TWO_CORP_ID"));
two.put("APPOINT_CORP_NAME", entity.getString("APPOINT_TWO_CORP_NAME"));
two.put("APPOINT_DEPARTMENT_ID", entity.getString("APPOINT_TWO_DEPARTMENT_ID"));
two.put("APPOINT_DEPARTMENT_NAME", entity.getString("APPOINT_TWO_DEPARTMENT_NAME"));
two.put("APPOINT_USER_ID", entity.getString("APPOINT_TWO_USER_ID"));
two.put("APPOINT_USER_NAME", entity.getString("APPOINT_TWO_USER_NAME"));
two.put("APPOINT_STATUS", entity.getString("APPOINT_TWO_STATUS"));
two.put("APPOINT_OPINION", entity.getString("APPOINT_TWO_OPINION"));
two.put("APPOINT_TIME", entity.getString("APPOINT_TWO_TIME"));
list.add(two);
}
if (index >= 3) {
PageData three = new PageData();
three.put("INDEX", "3");
three.put("APPOINT_CORP_ID", entity.getString("APPOINT_THREE_CORP_ID"));
three.put("APPOINT_CORP_NAME", entity.getString("APPOINT_THREE_CORP_NAME"));
three.put("APPOINT_DEPARTMENT_ID", entity.getString("APPOINT_THREE_DEPARTMENT_ID"));
three.put("APPOINT_DEPARTMENT_NAME", entity.getString("APPOINT_THREE_DEPARTMENT_NAME"));
three.put("APPOINT_USER_ID", entity.getString("APPOINT_THREE_USER_ID"));
three.put("APPOINT_USER_NAME", entity.getString("APPOINT_THREE_USER_NAME"));
three.put("APPOINT_STATUS", entity.getString("APPOINT_THREE_STATUS"));
three.put("APPOINT_OPINION", entity.getString("APPOINT_THREE_OPINION"));
three.put("APPOINT_TIME", entity.getString("APPOINT_THREE_TIME"));
list.add(three);
}
if (index >= 4) {
PageData four = new PageData();
four.put("INDEX", "4");
four.put("APPOINT_CORP_ID", entity.getString("APPOINT_FOUR_CORP_ID"));
four.put("APPOINT_CORP_NAME", entity.getString("APPOINT_FOUR_CORP_NAME"));
four.put("APPOINT_DEPARTMENT_ID", entity.getString("APPOINT_FOUR_DEPARTMENT_ID"));
four.put("APPOINT_DEPARTMENT_NAME", entity.getString("APPOINT_FOUR_DEPARTMENT_NAME"));
four.put("APPOINT_USER_ID", entity.getString("APPOINT_FOUR_USER_ID"));
four.put("APPOINT_USER_NAME", entity.getString("APPOINT_FOUR_USER_NAME"));
four.put("APPOINT_STATUS", entity.getString("APPOINT_FOUR_STATUS"));
four.put("APPOINT_OPINION", entity.getString("APPOINT_FOUR_OPINION"));
four.put("APPOINT_TIME", entity.getString("APPOINT_FOUR_TIME"));
list.add(four);
}
if (index >= 5) {
PageData five = new PageData();
five.put("INDEX", "5");
five.put("APPOINT_CORP_ID", entity.getString("APPOINT_FIVE_CORP_ID"));
five.put("APPOINT_CORP_NAME", entity.getString("APPOINT_FIVE_CORP_NAME"));
five.put("APPOINT_DEPARTMENT_ID", entity.getString("APPOINT_FIVE_DEPARTMENT_ID"));
five.put("APPOINT_DEPARTMENT_NAME", entity.getString("APPOINT_FIVE_DEPARTMENT_NAME"));
five.put("APPOINT_USER_ID", entity.getString("APPOINT_FIVE_USER_ID"));
five.put("APPOINT_USER_NAME", entity.getString("APPOINT_FIVE_USER_NAME"));
five.put("APPOINT_STATUS", entity.getString("APPOINT_FIVE_STATUS"));
five.put("APPOINT_OPINION", entity.getString("APPOINT_FIVE_OPINION"));
five.put("APPOINT_TIME", entity.getString("APPOINT_FIVE_TIME"));
list.add(five);
}
if (index >= 6) {
PageData six = new PageData();
six.put("INDEX", "6");
six.put("APPOINT_CORP_ID", entity.getString("APPOINT_SIX_CORP_ID"));
six.put("APPOINT_CORP_NAME", entity.getString("APPOINT_SIX_CORP_NAME"));
six.put("APPOINT_DEPARTMENT_ID", entity.getString("APPOINT_SIX_DEPARTMENT_ID"));
six.put("APPOINT_DEPARTMENT_NAME", entity.getString("APPOINT_SIX_DEPARTMENT_NAME"));
six.put("APPOINT_USER_ID", entity.getString("APPOINT_SIX_USER_ID"));
six.put("APPOINT_USER_NAME", entity.getString("APPOINT_SIX_USER_NAME"));
six.put("APPOINT_STATUS", entity.getString("APPOINT_SIX_STATUS"));
six.put("APPOINT_OPINION", entity.getString("APPOINT_SIX_OPINION"));
six.put("APPOINT_TIME", entity.getString("APPOINT_SIX_TIME"));
list.add(six);
}
PageData info = new PageData();
info.put("info", list);
info.put("STEP", entity.getString("FLOWS_STEP"));
condition.clear();
condition.put("XGF_USER_ID", request.getString("XGF_USER_ID"));
PageData userInfo = xgfUserMapper.findById(condition);
if (userInfo == null || userInfo.size() == 0) {
throw new RuntimeException("未找到该用户详细信息");
}
info.put("endFlag", userInfo.getString("CHECK_STATUS"));
return info;
}
@Override
@Transactional
public void approvePlus(PageData request, MultipartFile[] chengNuoShu) throws Exception {
if (chengNuoShu != null && chengNuoShu.length > 0) {
request.put("APPOINT_ANNEX", Warden.saveFile(Warden.createZip(chengNuoShu), Jurisdiction.getCORPINFO_ID()));
}
this.approve(request);
}
/* 获取当前用户是否有权限审批 */
private String getPower(PageData x) {
switch (Integer.parseInt(x.get("CHECK_STEP").toString())) {
case 0:
if (Jurisdiction.getUSER_ID().equals(x.getString("APPOINT_ZERO_USER_ID"))) {
return "1";
} else {
return "0";
}
case 1:
if (Jurisdiction.getUSER_ID().equals(x.getString("APPOINT_ONE_USER_ID"))) {
return "1";
} else {
return "0";
}
case 2:
if (Jurisdiction.getUSER_ID().equals(x.getString("APPOINT_TWO_USER_ID"))) {
return "1";
} else {
return "0";
}
case 3:
if (Jurisdiction.getUSER_ID().equals(x.getString("APPOINT_THREE_USER_ID"))) {
return "1";
} else {
return "0";
}
case 4:
if (Jurisdiction.getUSER_ID().equals(x.getString("APPOINT_FOUR_USER_ID"))) {
return "1";
} else {
return "0";
}
case 5:
if (Jurisdiction.getUSER_ID().equals(x.getString("APPOINT_FIVE_USER_ID"))) {
return "1";
} else {
return "0";
}
case 6:
if (Jurisdiction.getUSER_ID().equals(x.getString("APPOINT_SIX_USER_ID"))) {
return "1";
} else {
return "0";
}
case 7:
if (Jurisdiction.getUSER_ID().equals(x.getString("APPOINT_SEVEN_USER_ID"))) {
return "1";
} else {
return "0";
}
default:
return "0";
}
}
private String handle(PageData info, PageData flows) throws Exception {
PageData condition = new PageData();
condition.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
PageData corpEntity = corpInfoMapper.findById(condition);
switch (Integer.parseInt(flows.get("FLOWS_STEP").toString())) {
case 0: {// 相关方端推送数据至企业端
condition.clear();
condition.put("XGF_USER_ID", flows.getString("FLOWS_ID"));
PageData entity = xgfUserMapper.findById(condition);
flows.put("APPOINT_ZERO_TIME", DateUtil.getTime());
flows.put("APPOINT_ZERO_STATUS", info.getString("STATUS"));
flows.put("APPOINT_ZERO_OPINION", info.getString("OPINION"));
if ("0".equals(info.getString("STATUS"))) {
entity.put("STATUS", "0");
entity.put("VALID_FLAG", "0");
entity.put("CHECK_STATUS", "-2");
PageData key = new PageData();
key.putAll(entity);
key.put("USER_ID", condition.get("XGF_USER_ID"));
key.put("STATUS", "1");
Map result = HttpClientService.doPost(prevention_xgf_url + "openApi/user/approve", key);
if (result == null || !"succeed".equals(result.get("result"))) {
throw new RuntimeException("请求失败");
}
xgfUserMapper.edit(entity);
this.clearInfo(flows);
xgfFlowsMapper.edit(flows);
return "0";
} else {
flows.put("APPOINT_ONE_CORP_TYPE", "0");
flows.put("APPOINT_ONE_DEPARTMENT_ID", info.getString("APPOINT_DEPARTMENT_ID"));
flows.put("APPOINT_ONE_DEPARTMENT_NAME", info.getString("APPOINT_DEPARTMENT_NAME"));
flows.put("APPOINT_ONE_USER_ID", info.getString("APPOINT_USER_ID"));
flows.put("APPOINT_ONE_USER_NAME", info.getString("APPOINT_USER_NAME"));
flows.put("FLOWS_STEP", 1);
xgfFlowsMapper.edit(flows);
condition.clear();
condition.put("XGF_USER_ID", flows.getString("FLOWS_ID"));
PageData user = xgfUserMapper.findById(condition);
user.put("CHECK_STEP", 1);
user.put("LIMIT_END_TIME", info.get("LIMIT_END_TIME"));
// created by liu jun 2024-02-26 如果有委托书则保存委托书
if (StringUtils.isNotBlank(info.getString("APPOINT_ANNEX"))) {
condition.clear();
condition.put("XGF_USER_DETAILS_ID", flows.getString("FLOWS_ID"));
PageData userInfo = xgfUserDetailsMapper.findById(condition);
userInfo.put("COMMITMENT_LETTER", info.getString("APPOINT_ANNEX"));
xgfUserDetailsMapper.edit(userInfo);
}
xgfUserMapper.edit(user);
return "0";
}
} // 相关方选择的审批人审批,并指定下一位监管部门审批人,不过打回相关方端
case 1: {
condition.clear();
condition.put("XGF_USER_ID", flows.getString("FLOWS_ID"));
PageData entity = xgfUserMapper.findById(condition);
flows.put("APPOINT_ONE_CORP_ID", Jurisdiction.getUSER_ID());
flows.put("APPOINT_ONE_CORP_NAME", corpEntity.getString("CORP_NAME"));
flows.put("APPOINT_ONE_TIME", DateUtil.getTime());
flows.put("APPOINT_ONE_STATUS", info.getString("STATUS"));
flows.put("APPOINT_ONE_OPINION", info.getString("OPINION"));
if ("0".equals(info.getString("STATUS"))) {
entity.put("STATUS", "0");
entity.put("VALID_FLAG", "0");
entity.put("CHECK_STATUS", "-2");
PageData key = new PageData();
key.putAll(entity);
key.put("USER_ID", condition.get("XGF_USER_ID"));
key.put("STATUS", "1");
Map result = HttpClientService.doPost(prevention_xgf_url + "openApi/user/approve", key);
if (result == null || !"succeed".equals(result.get("result"))) {
throw new RuntimeException("请求失败");
}
xgfUserMapper.edit(entity);
this.clearInfo(flows);
xgfFlowsMapper.edit(flows);
return "0";
} else {
if ("1".equals(flows.getString("FLOWS_TYPE"))) {
entity.put("CHECK_STATUS", 1);
entity.put("VALID_FLAG", "2");
entity.put("CHECK_STEP", Integer.parseInt(entity.get("CHECK_STEP").toString()) + 1);
xgfUserMapper.edit(entity);
flows.put("APPOINT_TWO_CORP_TYPE", "0");
flows.put("APPOINT_TWO_DEPARTMENT_ID", info.getString("APPOINT_DEPARTMENT_ID"));
flows.put("APPOINT_TWO_DEPARTMENT_NAME", info.getString("APPOINT_DEPARTMENT_NAME"));
flows.put("APPOINT_TWO_USER_ID", info.getString("APPOINT_USER_ID"));
flows.put("APPOINT_TWO_USER_NAME", info.getString("APPOINT_USER_NAME"));
flows.put("FLOWS_STEP", 2);
xgfFlowsMapper.edit(flows);
return "0";
} else {
entity.put("CHECK_STATUS", 2);
entity.put("VALID_FLAG", "1");
entity.put("STATUS", "2");
entity.put("CHECK_STEP", Integer.parseInt(entity.get("CHECK_STEP").toString()) + 1);
xgfUserMapper.edit(entity);
flows.put("FLOWS_STEP", 2);
xgfFlowsMapper.edit(flows);
return "1";
}
}
}
//监管部门审批人审批,并根据不同类型的审批规则进行处理
case 2: {
condition.clear();
condition.put("XGF_USER_ID", flows.getString("FLOWS_ID"));
PageData entity = xgfUserMapper.findById(condition);
flows.put("APPOINT_TWO_CORP_ID", Jurisdiction.getCORPINFO_ID());
flows.put("APPOINT_TWO_CORP_NAME", corpEntity.getString("CORP_NAME"));
flows.put("APPOINT_TWO_TIME", DateUtil.getTime());
flows.put("APPOINT_TWO_STATUS", info.getString("STATUS"));
flows.put("APPOINT_TWO_OPINION", info.getString("OPINION"));
// 1、判断是否通过审核
if ("0".equals(info.getString("STATUS"))) {
entity.put("STATUS", "0");
entity.put("VALID_FLAG", "0");
entity.put("CHECK_STATUS", "-2");
PageData key = new PageData();
xgfUserMapper.edit(entity);
key.putAll(entity);
key.put("USER_ID", condition.get("XGF_USER_ID"));
key.put("STATUS", "1");
Map result = HttpClientService.doPost(prevention_xgf_url + "openApi/user/approve", key);
if (result == null || !"succeed".equals(result.get("result"))) {
throw new RuntimeException("请求失败");
}
this.clearInfo(flows);
xgfFlowsMapper.edit(flows);
return "0";
} else {
// 2、通过审核后根据不同的流程进行不同的处理
switch (flows.getString("FLOWS_TYPE")) {
case "0":// 辖区单位审批
entity.put("CHECK_STATUS", 2);
entity.put("VALID_FLAG", "1");
entity.put("CHECK_STEP", Integer.parseInt(entity.get("CHECK_STEP").toString()) + 1);
entity.put("STATUS", "2");
xgfUserMapper.edit(entity);
xgfFlowsMapper.edit(flows);
return "1";
case "1":// 集团单位审批,需要指定下一位人员进行审批
entity.put("CHECK_STATUS", 1);
entity.put("VALID_FLAG", "2");
entity.put("CHECK_STEP", Integer.parseInt(entity.get("CHECK_STEP").toString()) + 1);
entity.put("LIMIT_END_TIME", info.get("LIMIT_END_TIME"));
xgfUserMapper.edit(entity);
flows.put("APPOINT_THREE_CORP_ID", info.getString("APPOINT_CORP_ID"));
flows.put("APPOINT_THREE_CORP_NAME", info.getString("APPOINT_CORP_NAME"));
flows.put("APPOINT_THREE_CORP_TYPE", "0");
flows.put("APPOINT_THREE_DEPARTMENT_ID", info.getString("APPOINT_DEPARTMENT_ID"));
flows.put("APPOINT_THREE_DEPARTMENT_NAME", info.getString("APPOINT_DEPARTMENT_NAME"));
flows.put("APPOINT_THREE_USER_ID", info.getString("APPOINT_USER_ID"));
flows.put("APPOINT_THREE_USER_NAME", info.getString("APPOINT_USER_NAME"));
flows.put("FLOWS_STEP", 3);
xgfFlowsMapper.edit(flows);
return "0";
default:
throw new RuntimeException("未知的审批类型");
}
}
}
case 3: {
condition.clear();
condition.put("XGF_USER_ID", flows.getString("FLOWS_ID"));
PageData entity = xgfUserMapper.findById(condition);
flows.put("APPOINT_THREE_CORP_ID", Jurisdiction.getCORPINFO_ID());
flows.put("APPOINT_THREE_CORP_NAME", corpEntity.getString("CORP_NAME"));
flows.put("APPOINT_THREE_TIME", DateUtil.getTime());
flows.put("APPOINT_THREE_STATUS", info.getString("STATUS"));
flows.put("APPOINT_THREE_OPINION", info.getString("OPINION"));
// 1、判断是否通过审核
if ("0".equals(info.getString("STATUS"))) {
entity.put("STATUS", "0");
entity.put("VALID_FLAG", "0");
entity.put("CHECK_STATUS", "-2");
xgfUserMapper.edit(entity);
PageData key = new PageData();
key.putAll(entity);
key.put("USER_ID", condition.get("XGF_USER_ID"));
key.put("STATUS", "1");
Map result = HttpClientService.doPost(prevention_xgf_url + "openApi/user/approve", key);
if (result == null || !"succeed".equals(result.get("result"))) {
throw new RuntimeException("请求失败");
}
this.clearInfo(flows);
xgfFlowsMapper.edit(flows);
return "0";
} else {
// TODO 根据是否委托辖区单位进行处理(前端传回来)
switch (flows.getString("FLOWS_TYPE")) {
case "1":// 由股份端审批
entity.put("CHECK_STATUS", 2);
entity.put("VALID_FLAG", "1");
entity.put("CHECK_STEP", Integer.parseInt(entity.get("CHECK_STEP").toString()) + 1);
entity.put("STATUS", "2");
xgfUserMapper.edit(entity);
return "1";
case "0":// 辖区单位审批,需要指定审批人
entity.put("CHECK_STEP", Integer.parseInt(entity.get("CHECK_STEP").toString()) + 1);
xgfUserMapper.edit(entity);
flows.put("APPOINT_FOUR_CORP_ID", info.getString("APPOINT_CORP_ID"));
flows.put("APPOINT_FOUR_CORP_NAME", info.getString("APPOINT_CORP_NAME"));
flows.put("APPOINT_FOUR_DEPARTMENT_ID", info.getString("APPOINT_DEPARTMENT_ID"));
flows.put("APPOINT_FOUR_DEPARTMENT_NAME", info.getString("APPOINT_DEPARTMENT_NAME"));
flows.put("APPOINT_FOUR_USER_ID", info.getString("APPOINT_USER_ID"));
flows.put("APPOINT_FOUR_USER_NAME", info.getString("APPOINT_USER_NAME"));
flows.put("FLOWS_STEP", 4);
xgfFlowsMapper.edit(flows);
return "0";
default:
throw new RuntimeException("未知的审批类型");
}
}
}
// 委托先去单位审批
case 4: {
condition.clear();
condition.put("XGF_USER_ID", flows.getString("FLOWS_ID"));
PageData entity = xgfUserMapper.findById(condition);
flows.put("APPOINT_FOUR_CORP_ID", Jurisdiction.getCORPINFO_ID());
flows.put("APPOINT_FOUR_CORP_NAME", corpEntity.getString("CORP_NAME"));
flows.put("APPOINT_FOUR_TIME", DateUtil.getTime());
flows.put("APPOINT_FOUR_STATUS", info.getString("STATUS"));
flows.put("APPOINT_FOUR_OPINION", info.getString("OPINION"));
// 1、判断是否通过审核
if ("0".equals(info.getString("STATUS"))) {
entity.put("STATUS", "0");
entity.put("VALID_FLAG", "0");
entity.put("CHECK_STATUS", "-2");
xgfUserMapper.edit(entity);
PageData key = new PageData();
key.putAll(entity);
key.put("USER_ID", condition.get("XGF_USER_ID"));
key.put("STATUS", "1");
Map result = HttpClientService.doPost(prevention_xgf_url + "openApi/user/approve", key);
if (result == null || !"succeed".equals(result.get("result"))) {
throw new RuntimeException("请求失败");
}
this.clearInfo(flows);
xgfFlowsMapper.edit(flows);
return "0";
} else {
// TODO 根据是否委托辖区单位进行处理(前端传回来)
switch (flows.getString("FLOWS_TYPE")) {
case "0":// 由股份端审批
entity.put("CHECK_STATUS", 2);
entity.put("VALID_FLAG", "1");
entity.put("CHECK_STEP", Integer.parseInt(entity.get("CHECK_STEP").toString()) + 1);
entity.put("STATUS", "2");
xgfUserMapper.edit(entity);
xgfFlowsMapper.edit(flows);
return "1";
case "1":// 辖区单位审批,需要指定审批人
entity.put("CHECK_STEP", Integer.parseInt(entity.get("CHECK_STEP").toString()) + 1);
entity.put("CHECK_STATUS", 2);
entity.put("VALID_FLAG", "1");
entity.put("STATUS", "2");
xgfUserMapper.edit(entity);
flows.put("FLOWS_STEP", 5);
xgfFlowsMapper.edit(flows);
return "1";
default:
throw new RuntimeException("未知的审批类型");
}
}
}
// 委托辖区单位监管部门审批
case 5: {
condition.clear();
condition.put("XGF_USER_ID", flows.getString("FLOWS_ID"));
flows.put("APPOINT_FIVE_CORP_ID", "1");
flows.put("APPOINT_FIVE_CORP_NAME", "秦港股份有限公司");
flows.put("APPOINT_FIVE_TIME", DateUtil.getTime());
flows.put("APPOINT_FIVE_STATUS", info.getString("STATUS"));
flows.put("APPOINT_FIVE_OPINION", info.getString("OPINION"));
PageData entity = xgfUserMapper.findById(condition);
// 1、判断是否通过审核
if ("0".equals(info.getString("STATUS"))) {
entity.put("STATUS", "0");
entity.put("VALID_FLAG", "0");
entity.put("CHECK_STATUS", "-2");
PageData key = new PageData();
key.putAll(entity);
key.put("USER_ID", condition.get("XGF_USER_ID"));
key.put("STATUS", "1");
Map result = HttpClientService.doPost(prevention_xgf_url + "openApi/user/approve", key);
if (result == null || !"succeed".equals(result.get("result"))) {
throw new RuntimeException("请求失败");
}
xgfUserMapper.edit(entity);
flows.put("APPOINT_FIVE_TIME", DateUtil.getTime());
flows.put("APPOINT_FIVE_STATUS", info.getString("STATUS"));
flows.put("APPOINT_FIVE_OPINION", info.getString("OPINION"));
xgfFlowsMapper.edit(flows);
return "0";
} else {
entity.put("CHECK_STATUS", 2);
entity.put("VALID_FLAG", "1");
entity.put("CHECK_STEP", Integer.parseInt(entity.get("CHECK_STEP").toString()) + 1);
entity.put("STATUS", "2");
xgfUserMapper.edit(entity);
return "1";
}
}
// 6往后是备用流程
case 6: {
flows.put("APPOINT_SIX_CORP_ID", info.getString("APPOINT_CORP_ID"));
flows.put("APPOINT_SIX_CORP_NAME", info.getString("APPOINT_CORP_NAME"));
flows.put("APPOINT_SIX_DEPARTMENT_ID", info.getString("APPOINT_DEPARTMENT_ID"));
flows.put("APPOINT_SIX_DEPARTMENT_NAME", info.getString("APPOINT_DEPARTMENT_NAME"));
flows.put("APPOINT_SIX_USER_ID", info.getString("APPOINT_USER_ID"));
flows.put("APPOINT_SIX_USER_NAME", info.getString("APPOINT_USER_NAME"));
flows.put("APPOINT_SIX_TIME", DateUtil.getTime());
flows.put("APPOINT_SIX_STATUS", info.getString("STATUS"));
flows.put("APPOINT_SIX_OPINION", info.getString("OPINION"));
flows.put("FLOWS_STEP", 7);
xgfFlowsMapper.edit(flows);
return "0";
}
case 7: {
flows.put("APPOINT_SEVEN_CORP_ID", info.getString("APPOINT_CORP_ID"));
flows.put("APPOINT_SEVEN_CORP_NAME", info.getString("APPOINT_CORP_NAME"));
flows.put("APPOINT_SEVEN_DEPARTMENT_ID", info.getString("APPOINT_DEPARTMENT_ID"));
flows.put("APPOINT_SEVEN_DEPARTMENT_NAME", info.getString("APPOINT_DEPARTMENT_NAME"));
flows.put("APPOINT_SEVEN_USER_ID", info.getString("APPOINT_USER_ID"));
flows.put("APPOINT_SEVEN_USER_NAME", info.getString("APPOINT_USER_NAME"));
flows.put("APPOINT_SEVEN_TIME", DateUtil.getTime());
flows.put("APPOINT_SEVEN_STATUS", info.getString("STATUS"));
flows.put("APPOINT_SEVEN_OPINION", info.getString("OPINION"));
flows.put("FLOWS_STEP", 8);
xgfFlowsMapper.edit(flows);
return "0";
}
default:
return "1";
}
}
private void clearInfo(PageData flow) {
flow.put("APPOINT_ONE_USER_ID", "");
flow.put("APPOINT_TWO_USER_ID", "");
flow.put("APPOINT_THREE_USER_ID", "");
flow.put("APPOINT_FOUR_USER_ID", "");
flow.put("APPOINT_FIVE_USER_ID", "");
flow.put("APPOINT_SIX_USER_ID", "");
flow.put("APPOINT_SEVEN_USER_ID", "");
}
/**
* 保存操作记录
* @param info
* @param status 通过标识符
* @param endFlag 流程结束标识符
* @throws Exception
*/
public void saveLog(PageData info, String status, String endFlag) throws Exception {
/* 保存审批记录 */
PageData condition = new PageData();
condition.clear();
condition.put("FOREIGN_KEY", info.getString("FLOWS_ID"));
condition.put("TYPE", "1");
condition.put("VALID_FLAG", "1");
condition.put("END_FLAG", "0");
PageData flow = flowMapper.findByCondition(condition);
if (flow == null || flow.size() == 0) {
throw new RuntimeException("流程已被暂停,请联系管理员");
}
condition.clear();
condition.put("FLOW_ID", flow.getString("FLOW_ID"));
condition.put("STEP_FLAG", "1");
PageData currentNode = flowDetailMapper.selectOne(condition);
PageData nextNode = new PageData();
nextNode.put("FLOW_DETAIL_ID", Warden.get32UUID());
nextNode.put("FLOW_ID", flow.getString("FLOW_ID"));
nextNode.put("STEP_FLAG", "1");
nextNode.put("STEP_NAME", "企业端审批");
nextNode.put("SORT", Integer.parseInt(currentNode.get("SORT").toString()) + 1);
nextNode.put("APPROVER_ID", Jurisdiction.getUSER_ID());
nextNode.put("APPROVER_NAME", Jurisdiction.getName());
nextNode.put("APPROVER_TIME", DateUtil.getTime());
nextNode.put("APPROVER_CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
nextNode.put("APPROVER_OPINION", info.get("OPINION"));
nextNode.put("APPOINT_ANNEX", info.getString("APPOINT_ANNEX"));
if ("1".equals(Jurisdiction.getCORPINFO_ID())) {
nextNode.put("APPROVER_CORPINFO_NAME", "秦皇岛股份有限公司");
} else {
condition.clear();
condition.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
PageData corpInfo = corpInfoMapper.findById(condition);
if (corpInfo != null && corpInfo.size() > 0) {
nextNode.put("APPROVER_CORPINFO_NAME", corpInfo.getString("CORP_NAME"));
}
}
nextNode.put("PASS_FLAG", status);
nextNode.put("END_FLAG", endFlag);
nextNode.put("ISDELETE", "0");
nextNode.put("PARENT_ID", currentNode.getString("FLOW_DETAIL_ID"));
flowDetailMapper.save(nextNode);
currentNode.put("STEP_FLAG", "0");
flowDetailMapper.edit(currentNode);
flow.put("END_FLAG", endFlag);
flowMapper.edit(flow);
}
@Override
public void saveLog(XgfFlowDto info, String status, String endFlag) throws Exception {
PageData _info = new PageData();
_info.put("OPINION", info.getOPINION());
_info.put("APPOINT_ANNEX", info.getAPPOINT_ANNEX());
_info.put("FLOWS_ID", info.getFLOWS_ID());
this.saveLog(_info, status, endFlag);
}
@Override
public void repulse(PageData flows, XgfFlowDto info) throws Exception {
// add by liu jun 相关方可指定打回至指定节点 -1 为默认打回至相关方端
if ("-1".equals(info.getBACK_STEP())){
PageData condition = new PageData();
condition.put("XGF_USER_ID", flows.getString("FLOWS_ID"));
PageData entity = xgfUserMapper.findById(condition);
entity.put("STATUS", "0");
entity.put("VALID_FLAG", "0");
entity.put("CHECK_STATUS", "-2");
PageData key = new PageData();
key.putAll(entity);
key.put("USER_ID", condition.get("XGF_USER_ID"));
key.put("STATUS", "1");
key.put("OPINION", flows.get("OPINION"));
Map result = HttpClientService.doPost(prevention_xgf_url + "openApi/user/approve", key);
if (result == null || !"succeed".equals(result.get("result"))) {
throw new RuntimeException("请求失败");
}
xgfUserMapper.edit(entity);
this.clearInfo(flows);
xgfFlowsMapper.edit(flows);
} else {
// 1、判断不能自己打回到自己
PageData condition = new PageData();
condition.put("FLOWS_ID",flows.getString("FLOWS_ID"));
PageData flowEntity = xgfFlowsMapper.findById(condition);
if (flowEntity != null && flowEntity.size() > 0 && (flowEntity.get("FLOWS_STEP").toString()).equals(info.getBACK_STEP())){
info.setErrorMsg("不能自己打回到自己");
}
flowEntity.put("FLOWS_STEP", info.getBACK_STEP());
xgfFlowsMapper.edit(flowEntity);
// 清理数据
clearsInfo(flowEntity,info.getBACK_STEP());
xgfFlowsMapper.edit(flowEntity);
condition.clear();
condition.put("XGF_USER_ID", flows.getString("FLOWS_ID"));
PageData entity = xgfUserMapper.findById(condition);
entity.put("CHECK_STEP",info.getBACK_STEP());
xgfUserMapper.edit(entity);
// 判断要不要清理委托书
if (clearWeiTuo(flowEntity, info.getBACK_STEP())) {
condition.clear();
condition.put("XGF_USER_DETAILS_ID", flows.getString("FLOWS_ID"));
PageData infoEntity = xgfUserDetailsMapper.findById(condition);
infoEntity.put("ATTORNEY", null);
xgfUserDetailsMapper.edit(infoEntity);
}
}
}
private boolean clearWeiTuo(PageData flowEntity,String backStep) throws Exception{
if ("1".equals(flowEntity.getString("FLOWS_TYPE"))){
return 1 <= Integer.parseInt(backStep);
}
if ("2".equals(flowEntity.getString("FLOWS_TYPE"))){
return 0 <= Integer.parseInt(backStep);
}
return false;
}
private void clearsInfo(PageData entity,String step) throws Exception {
if ("0".equals(step)){
entity.put("APPOINT_ONE_USER_ID", "");
entity.put("APPOINT_TWO_USER_ID", "");
entity.put("APPOINT_THREE_USER_ID", "");
entity.put("APPOINT_FOUR_USER_ID", "");
entity.put("APPOINT_FIVE_USER_ID", "");
entity.put("APPOINT_SIX_USER_ID", "");
entity.put("APPOINT_SEVEN_USER_ID", "");
}
if ("1".equals(step)){
entity.put("APPOINT_TWO_USER_ID", "");
entity.put("APPOINT_THREE_USER_ID", "");
entity.put("APPOINT_FOUR_USER_ID", "");
entity.put("APPOINT_FIVE_USER_ID", "");
entity.put("APPOINT_SIX_USER_ID", "");
entity.put("APPOINT_SEVEN_USER_ID", "");
}
if ("2".equals(step)){
entity.put("APPOINT_THREE_USER_ID", "");
entity.put("APPOINT_FOUR_USER_ID", "");
entity.put("APPOINT_FIVE_USER_ID", "");
entity.put("APPOINT_SIX_USER_ID", "");
entity.put("APPOINT_SEVEN_USER_ID", "");
}
if ("3".equals(step)){
entity.put("APPOINT_FOUR_USER_ID", "");
entity.put("APPOINT_FIVE_USER_ID", "");
entity.put("APPOINT_SIX_USER_ID", "");
entity.put("APPOINT_SEVEN_USER_ID", "");
}
if ("4".equals(step)){
entity.put("APPOINT_FIVE_USER_ID", "");
entity.put("APPOINT_SIX_USER_ID", "");
entity.put("APPOINT_SEVEN_USER_ID", "");
}
if ("5".equals(step)){
entity.put("APPOINT_SIX_USER_ID", "");
entity.put("APPOINT_SEVEN_USER_ID", "");
}
if ("6".equals(step)){
entity.put("APPOINT_SEVEN_USER_ID", "");
}
}
@Override
@Transactional
public void approveMax(PageData request, MultipartFile[] chengNuoShu) throws Exception {
if (chengNuoShu != null && chengNuoShu.length > 0) {
request.put("APPOINT_ANNEX", Warden.saveFile(Warden.createZip(chengNuoShu), Jurisdiction.getCORPINFO_ID()));
}
List<PageData> _list = Warden.getList(request.getString("list"));
if (_list == null || _list.size() == 0) {
throw new RuntimeException("请求数据异常");
}
PageData condition = new PageData();
condition.put("USER_ID",request.getString("APPOINT_USER_ID"));
PageData userInfo = usersService.findById(condition);
if (userInfo != null && userInfo.size() > 0 && userInfo.get("ISMAIN") != null){
if ("1".equals(userInfo.getString("ISMAIN"))){
throw new RuntimeException("审批人不能指定主账号");
}
}
List<String> list = _list.stream().map(x -> x.getString("XGF_USER_ID")).collect(Collectors.toList());
for (String x : list) {
condition.clear();
condition.put("FLOWS_ID", x);
PageData flows = xgfFlowsMapper.findById(condition);
if (flows == null || flows.size() == 0) {
throw new RuntimeException("未找到该用户详细信息");
}
XgfFlowDto info = new XgfFlowDto();
info.setFLOWS_STEP(flows.getString("FLOWS_STEP"));
info.setIterator(flows.getString("FLOWS_STEP"));
info.setFLOWS_TYPE(flows.getString("FLOWS_TYPE"));
info.setFLOWS_ID(x);
info.setSTATUS(request.getString("STATUS"));
info.setOPINION(request.getString("OPINION"));
info.setAPPOINT_DEPARTMENT_ID(request.getString("APPOINT_DEPARTMENT_ID"));
info.setAPPOINT_DEPARTMENT_NAME(request.getString("APPOINT_DEPARTMENT_NAME"));
info.setAPPOINT_USER_ID(request.getString("APPOINT_USER_ID"));
info.setAPPOINT_USER_NAME(request.getString("APPOINT_USER_NAME"));
if (request.get("LIMIT_END_TIME") != null) {
info.setLIMIT_END_TIME(request.getString("LIMIT_END_TIME"));
}
if (request.get("APPOINT_ANNEX") != null) {
info.setAPPOINT_ANNEX(request.getString("APPOINT_ANNEX"));
}
info.setBACK_STEP(request.getString("BACK_STEP"));
// 进行数据审核
LiteflowResponse response = flowExecutor.execute2Resp("chain1", info);
if (response.isSuccess()) {
System.out.println("流程信息:" + response.getExecuteStepStrWithTime());
} else {
Exception e = response.getCause();
e.printStackTrace();
throw new RuntimeException(e.getMessage());
}
}
}
@Override
public List<PageData> getWorkTask(PageData condition) throws Exception {
return xgfUserMapper.getWorkTask(condition);
}
@Override
public void syncPhoto(PageData request) throws Exception {
PageData condition = new PageData();
condition.put("XGF_USER_DETAILS_ID",request.get("USER_ID"));
PageData detailEntity = xgfUserDetailsMapper.findById(condition);
if (detailEntity == null || detailEntity.size() == 0){
throw new RuntimeException("未找到该用户详细信息");
}
detailEntity.put("PHOTO",request.get("PHOTO"));
xgfUserDetailsMapper.edit(detailEntity);
}
private String getType(String corpInfoId) {
// created bu liu jun - 港务局要求,可以直接指定集团单位
if ("1".equals(corpInfoId)) {
return "2";
}
// 集团单位id
// (河港机械 jtdw002 1e6dbbe16004402f8d2c0e52afd9a676
// (河港港工 jtdw003 3a854eefa7894e06aaa1a2611bca80f6
// (河港检测 jtdw004 020578a4c1f04bc692ee25145c2efbe5
// (方宇物业 jtdw005 90966974de3c4b83aca6f8fd6432d5c2
// (河北港口集团数联科技(雄安)有限公司 5cee11f6152d42e0a08ae38dc6abcfdf)
// (河港城发 f42d930a7e694123a2d6ad3e546ba695)
String jituandanwei = "1e6dbbe16004402f8d2c0e52afd9a6763a854eefa7894e06aaa1a2611bca80f6020578a4c1f04bc692ee25145c2efbe590966974de3c4b83aca6f8fd6432d5c25cee11f6152d42e0a08ae38dc6abcfdff42d930a7e694123a2d6ad3e546ba695";
if (jituandanwei.contains(corpInfoId)) {
return "1";
}
return "0";
}
@Override
@Transactional(rollbackFor = Exception.class)
public void edit4Mq(PageData syncInfo) {
// 相关方推送更新
syncInfo.put("XGF_USER_ID",syncInfo.getString("USER_ID"));
PageData localData = xgfUserMapper.findById(syncInfo);
if (localData != null && !localData.isEmpty()){
syncInfo.put("STUDY_STATUS", syncInfo.getString("STATUS"));
syncInfo.put("STATUS", "");
syncInfo.put("BELONG_TO_CORP", syncInfo.getString("EMPLOYER"));
syncInfo.put("BELONG_TO_CORP_NAME", syncInfo.getString("EMPLOYER_NAME"));
syncInfo.put("XGF_USER_NAME", syncInfo.getString("NAME"));
xgfUserMapper.edit(syncInfo);
// details
syncInfo.put("XGF_USER_DETAILS_ID",localData.getString("XGF_USER_ID"));
PageData localDetailsData = xgfUserDetailsMapper.findById(syncInfo);
if (localDetailsData != null && !localDetailsData.isEmpty()){
xgfUserDetailsMapper.edit(syncInfo);
}
}
}
}