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

686 lines
34 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.zcloud.entity.Page;
import com.zcloud.entity.PageData;
import com.zcloud.mapper.datasource.bus.CorpInfoMapper;
import com.zcloud.mapper.datasource.xgf.*;
import com.zcloud.service.system.DepartmentService;
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 javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
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;
@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"));
}
/* 主管部门 */
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"));
}
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("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"));
}
/* 主管部门 */
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");
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);
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("CORPINOF_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("CORPINOF_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");
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);
}
}
}
}
@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"));
// 保存审批记录
this.saveLog(x, 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;
}
/* 获取当前用户是否有权限审批 */
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";
}
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";
}
}
private String handle(PageData info, PageData flows) throws Exception {
PageData condition = new PageData();
switch (Integer.parseInt(flows.get("FLOWS_STEP").toString())) {
case 0:// 相关方端推送数据至企业端
flows.put("APPOINT_ZERO_TIME", DateUtil.getTime());
flows.put("APPOINT_ZERO_STATUS", info.getString("STATUS"));
flows.put("APPOINT_ZERO_OPINION", info.getString("OPINION"));
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"));
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);
xgfUserMapper.edit(user);
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 {
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);
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";
}
}
}
//监管部门审批人审批,并根据不同类型的审批规则进行处理
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、通过审核后根据不同的流程进行不同的处理
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_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 根据是否委托辖区单位进行处理(前端传回来)
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);
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);
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 {
// 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);
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("未知的审批类型");
}
}
}
// 委托辖区单位监管部门审批
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: {
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 saveLog(String id, String status, String endFlag) throws Exception {
/* 保存审批记录 */
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"));
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());
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);
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);
}
private String getType(String corpInfoId) {
// 集团单位id
// (河港机械 jtdw002 1e6dbbe16004402f8d2c0e52afd9a676
// (河港港工 jtdw003 3a854eefa7894e06aaa1a2611bca80f6
// (河港检测 jtdw004 020578a4c1f04bc692ee25145c2efbe5
// (方宇物业 jtdw005 90966974de3c4b83aca6f8fd6432d5c2
String jituandanwei = "1e6dbbe16004402f8d2c0e52afd9a6763a854eefa7894e06aaa1a2611bca80f6020578a4c1f04bc692ee25145c2efbe590966974de3c4b83aca6f8fd6432d5c2";
if (jituandanwei.contains(corpInfoId)) {
return "1";
}else {
return "0";
}
}
}