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

686 lines
34 KiB
Java
Raw Normal View History

2023-12-18 18:54:50 +08:00
package com.zcloud.service.xgf.impl;
import com.zcloud.entity.Page;
import com.zcloud.entity.PageData;
2024-01-19 16:11:49 +08:00
import com.zcloud.mapper.datasource.bus.CorpInfoMapper;
2024-01-17 18:43:03 +08:00
import com.zcloud.mapper.datasource.xgf.*;
2023-12-19 20:03:25 +08:00
import com.zcloud.service.system.DepartmentService;
2023-12-18 18:54:50 +08:00
import com.zcloud.service.xgf.XgfUserService;
2023-12-19 20:03:25 +08:00
import com.zcloud.util.*;
2023-12-18 18:54:50 +08:00
import org.apache.commons.lang3.StringUtils;
2023-12-19 15:01:44 +08:00
import org.springframework.beans.factory.annotation.Value;
2023-12-18 18:54:50 +08:00
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
2023-12-18 19:58:52 +08:00
import java.util.Arrays;
2023-12-18 18:54:50 +08:00
import java.util.List;
2023-12-19 15:01:44 +08:00
import java.util.Map;
import java.util.stream.Collectors;
2023-12-18 18:54:50 +08:00
@Service
public class XgfUserServiceImpl implements XgfUserService {
@Resource
private XgfUserMapper xgfUserMapper;
@Resource
private XgfUserDetailsMapper xgfUserDetailsMapper;
2023-12-26 12:35:28 +08:00
@Resource
2024-01-17 18:43:03 +08:00
private DepartmentService departmentService;
2023-12-26 12:35:28 +08:00
2023-12-19 20:03:25 +08:00
@Resource
2024-01-17 18:43:03 +08:00
private FlowMapper flowMapper;
@Resource
private FlowDetailMapper flowDetailMapper;
2023-12-19 20:03:25 +08:00
2024-01-19 16:11:49 +08:00
@Resource
private XgfFlowsMapper xgfFlowsMapper;
@Resource
private CorpInfoMapper corpInfoMapper;
2023-12-19 15:01:44 +08:00
@Value("${preventionxgf.api.url}")
private String prevention_xgf_url;
2023-12-18 18:54:50 +08:00
@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
2023-12-19 20:03:25 +08:00
public void init(PageData request) throws Exception {
2023-12-18 18:54:50 +08:00
List<PageData> list = Warden.getList(request.getString("infoList"));
2023-12-19 20:03:25 +08:00
PageData condition = new PageData();
2023-12-18 18:54:50 +08:00
for (PageData x : list) {
2023-12-19 20:03:25 +08:00
if (StringUtils.isNotBlank(x.getString("USER_ID"))) {
2024-01-17 18:43:03 +08:00
/* 1、 保存相关方用户信息 */
2023-12-19 20:03:25 +08:00
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"));
2023-12-21 19:55:08 +08:00
x.put("XGF_USER_NAME", x.get("NAME"));
2023-12-19 20:03:25 +08:00
x.put("VALID_FLAG", "1");
2024-01-17 18:43:03 +08:00
x.put("STATUS", "1");
2024-01-19 20:44:33 +08:00
x.put("CHECK_STATUS", "1");
2024-01-19 18:35:26 +08:00
x.put("CHECK_STEP", 0);
2023-12-19 20:03:25 +08:00
x.put("CREATED_TIME", DateUtil.getTime());
x.put("OPERATOR_TIME", DateUtil.getTime());
2023-12-21 19:55:08 +08:00
x.put("IS_DELETE", "0");
x.put("CREATE_TIME", DateUtil.getTime());
2023-12-22 15:49:12 +08:00
/* 监管部门 */
2023-12-19 20:03:25 +08:00
condition.clear();
2023-12-22 15:49:12 +08:00
condition.put("DEPARTMENT_ID", x.get("MANAGER_DEPARTMENT_ID"));
2023-12-19 20:03:25 +08:00
PageData regDepartmentEntity = departmentService.getCorpDepartment(condition);
2023-12-22 13:39:11 +08:00
if (regDepartmentEntity != null && regDepartmentEntity.size() > 0) {
2023-12-22 15:49:12 +08:00
x.put("MANAGER_DEPARTMENT_NAME", regDepartmentEntity.get("NAME"));
}
/* 主管部门 */
condition.clear();
condition.put("DEPARTMENT_ID", x.get("MAIN_DEPARTMENT_ID"));
regDepartmentEntity = departmentService.getCorpDepartment(condition);
x.put("MAIN_DEPARTMENT_NAME", regDepartmentEntity.get("NAME"));
if (regDepartmentEntity.size() > 0) {
x.put("MAIN_DEPARTMENT_NAME", regDepartmentEntity.get("NAME"));
2023-12-22 13:39:11 +08:00
}
2023-12-19 20:03:25 +08:00
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"));
2023-12-21 19:55:08 +08:00
x.put("IS_DELETE", "0");
x.put("CREATE_TIME", DateUtil.getTime());
2023-12-19 20:03:25 +08:00
x.put("OPERATOR_TIME", DateUtil.getTime());
2023-12-22 15:49:12 +08:00
/* 监管部门 */
2023-12-19 20:03:25 +08:00
condition.clear();
2023-12-22 15:49:12 +08:00
condition.put("DEPARTMENT_ID", x.get("MANAGER_DEPARTMENT_ID"));
2023-12-19 20:03:25 +08:00
PageData regDepartmentEntity = departmentService.getCorpDepartment(condition);
2023-12-22 13:39:11 +08:00
if (regDepartmentEntity != null && regDepartmentEntity.size() > 0) {
2023-12-22 15:49:12 +08:00
x.put("MANAGER_DEPARTMENT_NAME", regDepartmentEntity.get("NAME"));
2023-12-22 13:39:11 +08:00
}
2023-12-22 15:49:12 +08:00
/* 主管部门 */
condition.clear();
condition.put("DEPARTMENT_ID", x.get("MAIN_DEPARTMENT_ID"));
regDepartmentEntity = departmentService.getCorpDepartment(condition);
x.put("MAIN_DEPARTMENT_NAME", regDepartmentEntity.get("NAME"));
if (regDepartmentEntity.size() > 0) {
x.put("MAIN_DEPARTMENT_NAME", regDepartmentEntity.get("NAME"));
}
x.put("IS_DELETE", "0");
2023-12-19 20:03:25 +08:00
x.put("VALID_FLAG", "1");
2024-01-17 18:43:03 +08:00
x.put("STATUS", "1");
2024-01-19 20:44:33 +08:00
x.put("CHECK_STATUS", "1");
2024-01-19 18:35:26 +08:00
x.put("CHECK_STEP", 0);
2023-12-26 12:35:28 +08:00
if ("2".equals(x.getString("STUDY_STATUS"))) {
x.put("STUDY_STATUS", "2");
2024-01-17 18:43:03 +08:00
} else {
2023-12-26 12:35:28 +08:00
x.put("STUDY_STATUS", entity.getString("STUDY_STATUS"));
}
2024-01-17 18:43:03 +08:00
x.put("STUDY_STATUS", entity.getString("STUDY_STATUS"));
2023-12-26 12:35:28 +08:00
2023-12-19 20:03:25 +08:00
xgfUserMapper.edit(x);
xgfUserDetailsMapper.edit(x);
}
2024-01-22 14:39:39 +08:00
2024-01-17 18:43:03 +08:00
/* 2、保存相关方人员流程审批信息 */
condition.clear();
2024-01-19 16:11:49 +08:00
condition.put("FLOWS_ID", x.getString("USER_ID"));
PageData flows = xgfFlowsMapper.findById(condition);
if (flows == null || flows.size() <= 0) {
flows = new PageData();
2024-01-22 14:39:39 +08:00
flows.put("FLOWS_TYPE", getType(x.getString("CORPINOF_ID")));
2024-01-19 16:11:49 +08:00
flows.put("FLOWS_ID", x.getString("USER_ID"));
2024-01-19 18:35:26 +08:00
flows.put("FLOWS_STEP", 0);
2024-01-19 16:11:49 +08:00
flows.put("FOREIGN_KEY_ID", x.getString("USER_ID"));
flows.put("FOREIGN_KEY_NAME", "xgf_user=>XGF_USER_ID");
2024-01-19 18:35:26 +08:00
flows.put("IS_DELETE", "0");
2024-01-22 14:39:39 +08:00
flows.put("APPOINT_ZERO_CORP_TYPE", "0");
2024-01-19 18:35:26 +08:00
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"));
2024-01-19 16:11:49 +08:00
xgfFlowsMapper.save(flows);
} else {
2024-01-19 18:35:26 +08:00
flows.put("FLOWS_STEP", 0);
2024-01-22 14:39:39 +08:00
flows.put("FLOWS_TYPE", getType(x.getString("CORPINOF_ID")));
2024-01-19 18:35:26 +08:00
flows.put("APPOINT_ZERO_CORP_NAME", x.getString("APPOINT_CORP_NAME"));
flows.put("APPOINT_ZERO_CORP_ID", x.getString("APPOINT_CORP_ID"));
2024-01-22 14:39:39 +08:00
flows.put("APPOINT_ZERO_CORP_TYPE", "0");
2024-01-19 18:35:26 +08:00
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"));
2024-01-19 16:11:49 +08:00
xgfFlowsMapper.edit(flows);
}
/* 3、流程记录 */
condition.clear();
2024-01-17 18:43:03 +08:00
condition.put("FOREIGN_KEY", x.getString("XGF_USER_ID"));
condition.put("TYPE", "1");
condition.put("VALID_FLAG", "1");
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("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", "");
flowDetail.put("APPROVER_CORPINFO_NAME", "");
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"));
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", "相关方数据将人员打回后重新发送给企业端");
flowDetailMapper.save(nextNode);
currentNode.put("STEP_FLAG", "0");
flowDetailMapper.edit(currentNode);
}
2023-12-18 18:54:50 +08:00
}
}
}
2023-12-18 19:58:52 +08:00
@Override
public void approvalApplication(PageData request) throws Exception {
2023-12-22 17:41:36 +08:00
2023-12-19 15:01:44 +08:00
List<String> list = Arrays.asList(request.getString("xgf_user_ids").split(","));
2023-12-18 19:58:52 +08:00
PageData condition = new PageData();
condition.put("XGF_USER_IDS", list);
List<PageData> entities = xgfUserMapper.listByIds(condition);
2023-12-22 17:41:36 +08:00
/* 校验所有数据是否都是正常状态 */
if (entities.stream().anyMatch(n -> !"2".equals(n.getString("STATUS")))) {
2024-01-17 18:43:03 +08:00
String name = entities.stream().filter(n -> !"2".equals(n.getString("STATUS"))).map(n -> n.getString("NAME")).collect(Collectors.joining(","));
2023-12-22 17:41:36 +08:00
throw new RuntimeException("用户[" + name + "]在系统流程中无法被打回");
}
2023-12-18 19:58:52 +08:00
for (PageData x : entities) {
2023-12-19 15:01:44 +08:00
x.put("VALID_FLAG", "0");
x.put("STATUS", "1");
2023-12-18 19:58:52 +08:00
xgfUserMapper.edit(x);
}
2023-12-19 15:01:44 +08:00
}
@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);
2024-01-19 16:11:49 +08:00
/* 保存审批信息 */
condition.clear();
condition.put("FLOWS_ID", x);
PageData flows = xgfFlowsMapper.findById(condition);
if (flows == null || flows.size() == 0) {
throw new RuntimeException("未找到该用户详细信息");
2023-12-19 15:01:44 +08:00
}
2024-01-19 16:11:49 +08:00
condition.clear();
condition.put("STATUS", request.getString("STATUS"));
2024-01-22 14:39:39 +08:00
condition.put("OPINION", request.getString("OPINION"));
2024-01-19 16:11:49 +08:00
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"));
2024-01-19 20:44:33 +08:00
2024-01-19 16:45:45 +08:00
// 保存审批记录
2024-01-19 20:44:33 +08:00
this.saveLog(x, request.getString("STATUS"), this.handle(condition, flows));
2023-12-19 15:01:44 +08:00
}
2023-12-18 19:58:52 +08:00
}
2023-12-20 19:51:15 +08:00
@Override
public PageData findInfo(PageData condition) {
return xgfUserMapper.getInfoById(condition);
}
2023-12-21 13:58:57 +08:00
@Override
public List<PageData> findRecordList(PageData condition) throws Exception {
return xgfUserMapper.findRecordList(condition);
}
2024-01-18 13:56:15 +08:00
@Override
public List<PageData> getAppointApproveList(Page page) {
List<PageData> list = xgfUserMapper.appointlistPage(page);
for (PageData x : list) {
2024-01-19 16:11:49 +08:00
x.put("power_flag", getPower(x));
2024-01-18 13:56:15 +08:00
}
return list;
}
2024-01-19 16:11:49 +08:00
/* 获取当前用户是否有权限审批 */
private String getPower(PageData x) {
switch (Integer.parseInt(x.get("CHECK_STEP").toString())) {
2024-01-22 14:39:39 +08:00
case 0:
if (Jurisdiction.getUSER_ID().equals(x.getString("APPOINT_ZERO_USER_ID"))) {
return "1";
}
2024-01-19 16:11:49 +08:00
case 1:
if (Jurisdiction.getUSER_ID().equals(x.getString("APPOINT_ONE_USER_ID"))) {
return "1";
}
case 2:
if (Jurisdiction.getUSER_ID().equals(x.getString("APPOINT_TWO_USER_ID"))) {
return "1";
}
case 3:
if (Jurisdiction.getUSER_ID().equals(x.getString("APPOINT_THREE_USER_ID"))) {
return "1";
}
case 4:
if (Jurisdiction.getUSER_ID().equals(x.getString("APPOINT_FOUR_USER_ID"))) {
return "1";
}
case 5:
if (Jurisdiction.getUSER_ID().equals(x.getString("APPOINT_FIVE_USER_ID"))) {
return "1";
}
case 6:
if (Jurisdiction.getUSER_ID().equals(x.getString("APPOINT_SIX_USER_ID"))) {
return "1";
}
case 7:
if (Jurisdiction.getUSER_ID().equals(x.getString("APPOINT_SEVEN_USER_ID"))) {
return "1";
}
default:
return "0";
}
}
2024-01-19 20:44:33 +08:00
private String handle(PageData info, PageData flows) throws Exception {
PageData condition = new PageData();
2024-01-19 16:11:49 +08:00
switch (Integer.parseInt(flows.get("FLOWS_STEP").toString())) {
2024-01-19 20:44:33 +08:00
case 0:// 相关方端推送数据至企业端
2024-01-19 18:35:26 +08:00
flows.put("APPOINT_ZERO_TIME", DateUtil.getTime());
flows.put("APPOINT_ZERO_STATUS", info.getString("STATUS"));
flows.put("APPOINT_ZERO_OPINION", info.getString("OPINION"));
2024-01-22 14:39:39 +08:00
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("APPOINT_ONE_CORP_ID", flows.getString("APPOINT_ZERO_CORP_ID"));
flows.put("APPOINT_ONE_CORP_NAME", flows.getString("APPOINT_ZERO_CORP_NAME"));
2024-01-19 18:35:26 +08:00
flows.put("FLOWS_STEP", 1);
xgfFlowsMapper.edit(flows);
2024-01-22 14:39:39 +08:00
condition.clear();
condition.put("XGF_USER_ID", flows.getString("FLOWS_ID"));
PageData user = xgfUserMapper.findById(condition);
user.put("CHECK_STEP", 1);
2024-01-22 15:23:03 +08:00
xgfUserMapper.edit(user);
2024-01-19 20:44:33 +08:00
return "0";
// 相关方选择的审批人审批,并指定下一位监管部门审批人,不过打回相关方端
case 1: {
condition.clear();
condition.put("XGF_USER_ID", flows.getString("FLOWS_ID"));
PageData entity = xgfUserMapper.findById(condition);
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", info.getString("STATUS"));
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);
return "0";
} else {
2024-01-22 18:11:55 +08:00
if ("1".equals(flows.getString("FLOWS_TYPE"))) {
2024-01-22 14:39:39 +08:00
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);
flows.put("APPOINT_ONE_TIME", DateUtil.getTime());
flows.put("APPOINT_ONE_STATUS", info.getString("STATUS"));
flows.put("APPOINT_ONE_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);
xgfUserMapper.edit(entity);
flows.put("APPOINT_ONE_TIME", DateUtil.getTime());
flows.put("APPOINT_ONE_STATUS", info.getString("STATUS"));
flows.put("APPOINT_ONE_OPINION", info.getString("OPINION"));
flows.put("FLOWS_STEP", 2);
xgfFlowsMapper.edit(flows);
return "1";
2024-01-19 20:44:33 +08:00
}
}
}
//监管部门审批人审批,并根据不同类型的审批规则进行处理
case 2: {
condition.clear();
condition.put("XGF_USER_ID", flows.getString("FLOWS_ID"));
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", info.getString("STATUS"));
Map result = HttpClientService.doPost(prevention_xgf_url + "openApi/user/approve", key);
if (result == null || !"succeed".equals(result.get("result"))) {
throw new RuntimeException("请求失败");
}
return "0";
} else {
// 2、通过审核后根据不同的流程进行不同的处理
2024-01-22 18:11:55 +08:00
switch (flows.getString("FLOWS_TYPE")) {
2024-01-19 20:44:33 +08:00
case "0":// 辖区单位审批
entity.put("CHECK_STATUS", 2);
entity.put("VALID_FLAG", "1");
entity.put("CHECK_STEP", Integer.parseInt(entity.get("CHECK_STEP").toString()) + 1);
xgfUserMapper.edit(entity);
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);
xgfUserMapper.edit(entity);
flows.put("APPOINT_TWO_CORP_ID", info.getString("APPOINT_CORP_ID"));
flows.put("APPOINT_TWO_CORP_NAME", info.getString("APPOINT_CORP_NAME"));
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("APPOINT_TWO_TIME", DateUtil.getTime());
flows.put("APPOINT_TWO_STATUS", info.getString("STATUS"));
flows.put("APPOINT_TWO_OPINION", info.getString("OPINION"));
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);
// 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", info.getString("STATUS"));
Map result = HttpClientService.doPost(prevention_xgf_url + "openApi/user/approve", key);
if (result == null || !"succeed".equals(result.get("result"))) {
throw new RuntimeException("请求失败");
}
return "0";
} else {
// TODO 根据是否委托辖区单位进行处理(前端传回来)
2024-01-22 18:47:25 +08:00
switch (flows.getString("FLOWS_TYPE")) {
2024-01-19 20:44:33 +08:00
case "0":// 由股份端审批
entity.put("CHECK_STATUS", 2);
entity.put("VALID_FLAG", "1");
entity.put("CHECK_STEP", Integer.parseInt(entity.get("CHECK_STEP").toString()) + 1);
xgfUserMapper.edit(entity);
return "1";
case "1":// 辖区单位审批,需要指定审批人
entity.put("CHECK_STEP", Integer.parseInt(entity.get("CHECK_STEP").toString()) + 1);
xgfUserMapper.edit(entity);
2024-01-22 18:21:41 +08:00
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);
2024-01-19 20:44:33 +08:00
flows.put("APPOINT_THREE_TIME", DateUtil.getTime());
flows.put("APPOINT_THREE_STATUS", info.getString("STATUS"));
flows.put("APPOINT_THREE_OPINION", info.getString("OPINION"));
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);
// 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", info.getString("STATUS"));
Map result = HttpClientService.doPost(prevention_xgf_url + "openApi/user/approve", key);
if (result == null || !"succeed".equals(result.get("result"))) {
throw new RuntimeException("请求失败");
}
return "0";
} else {
2024-01-22 18:21:41 +08:00
// 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);
xgfUserMapper.edit(entity);
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);
2024-01-19 20:44:33 +08:00
2024-01-22 18:21:41 +08:00
flows.put("APPOINT_FOUR_TIME", DateUtil.getTime());
flows.put("APPOINT_FOUR_STATUS", info.getString("STATUS"));
flows.put("APPOINT_FOUR_OPINION", info.getString("OPINION"));
flows.put("FLOWS_STEP", 4);
xgfFlowsMapper.edit(flows);
return "1";
default:
throw new RuntimeException("未知的审批类型");
}
2024-01-19 20:44:33 +08:00
}
}
// 委托辖区单位监管部门审批
case 5: {
condition.clear();
condition.put("XGF_USER_ID", flows.getString("FLOWS_ID"));
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", info.getString("STATUS"));
Map result = HttpClientService.doPost(prevention_xgf_url + "openApi/user/approve", key);
if (result == null || !"succeed".equals(result.get("result"))) {
throw new RuntimeException("请求失败");
}
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);
xgfUserMapper.edit(entity);
return "1";
}
}
// 6往后是备用流程
case 6: {
2024-01-19 16:11:49 +08:00
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);
2024-01-19 20:44:33 +08:00
return "0";
}
case 7: {
2024-01-19 16:11:49 +08:00
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);
2024-01-19 20:44:33 +08:00
return "0";
}
default:
return "1";
2024-01-19 16:11:49 +08:00
}
}
2024-01-19 16:45:45 +08:00
2024-01-22 14:39:39 +08:00
private void saveLog(String id, String status, String endFlag) throws Exception {
2024-01-19 16:45:45 +08:00
/* 保存审批记录 */
PageData condition = new PageData();
condition.clear();
condition.put("FOREIGN_KEY", id);
condition.put("TYPE", "1");
condition.put("VALID_FLAG", "1");
PageData flow = flowMapper.findByCondition(condition);
if (flow == null || flow.size() == 0) {
throw new RuntimeException("流程已被暂停,请联系管理员");
}
condition.clear();
condition.put("FLOW_ID", flow.getString("FLOW_ID"));
2024-01-22 14:39:39 +08:00
condition.put("STEP_FLAG", "1");
2024-01-19 16:45:45 +08:00
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");
2024-01-19 20:44:33 +08:00
nextNode.put("STEP_NAME", "企业端审批");
2024-01-19 16:45:45 +08:00
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());
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("NAME"));
}
nextNode.put("PASS_FLAG", status);
2024-01-19 20:44:33 +08:00
nextNode.put("END_FLAG", endFlag);
2024-01-19 16:45:45 +08:00
nextNode.put("ISDELETE", "0");
nextNode.put("PARENT_ID", currentNode.getString("FLOW_DETAIL_ID"));
flowDetailMapper.save(nextNode);
currentNode.put("STEP_FLAG", "0");
flowDetailMapper.edit(currentNode);
}
2024-01-22 14:39:39 +08:00
private String getType(String corpInfoId) {
2024-01-22 15:23:03 +08:00
// 集团单位id
// (河港机械 jtdw002 1e6dbbe16004402f8d2c0e52afd9a676
// (河港港工 jtdw003 3a854eefa7894e06aaa1a2611bca80f6
// (河港检测 jtdw004 020578a4c1f04bc692ee25145c2efbe5
// (方宇物业 jtdw005 90966974de3c4b83aca6f8fd6432d5c2
String jituandanwei = "1e6dbbe16004402f8d2c0e52afd9a6763a854eefa7894e06aaa1a2611bca80f6020578a4c1f04bc692ee25145c2efbe590966974de3c4b83aca6f8fd6432d5c2";
if (jituandanwei.contains(corpInfoId)) {
return "1";
}else {
return "0";
}
2024-01-22 14:39:39 +08:00
}
2023-12-18 18:54:50 +08:00
}