|
|
|
@ -1,10 +1,24 @@ |
|
|
|
package com.spring.modules.proofing.service.impl; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.TypeReference; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
import com.spring.common.utils.Constant; |
|
|
|
import com.spring.common.utils.DateUtils; |
|
|
|
import com.spring.common.utils.PageUtils; |
|
|
|
import com.spring.datasource.config.AESUtil; |
|
|
|
import com.spring.modules.base.utils.HttpClientUtil; |
|
|
|
import com.spring.modules.base.utils.ResponseData; |
|
|
|
import com.spring.modules.change.entity.APIEntity.*; |
|
|
|
import com.spring.modules.change.entity.ParamData; |
|
|
|
import com.spring.modules.change.entity.ProcessFormEntity; |
|
|
|
import com.spring.modules.change.mapper.ChangeManagementMapper; |
|
|
|
import com.spring.modules.change.service.ChangeManagementService; |
|
|
|
import com.spring.modules.customer.vo.CustomerInformationVo; |
|
|
|
import com.spring.modules.oss.dao.SysOssDao; |
|
|
|
import com.spring.modules.oss.entity.SysOssEntity; |
|
|
|
@ -21,17 +35,24 @@ import com.spring.modules.quotation.entity.QuotationInformationEntity; |
|
|
|
import com.spring.modules.quotation.mapper.QuotationInformationMapper; |
|
|
|
import com.spring.modules.quotation.vo.QuotationInformationVo; |
|
|
|
import com.spring.modules.quotation.vo.SysOssVo; |
|
|
|
import com.spring.modules.request.vo.PlmRequestDetailVo; |
|
|
|
import com.spring.modules.request.vo.PlmRequestHeaderVo; |
|
|
|
import com.spring.modules.sys.dao.SysUserDao; |
|
|
|
import com.spring.modules.sys.entity.SysUserEntity; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
import static com.spring.modules.base.utils.CommonUtils.convertToInt; |
|
|
|
import static com.spring.modules.base.utils.CommonUtils.getPropertyValue; |
|
|
|
|
|
|
|
@Service |
|
|
|
@Slf4j |
|
|
|
public class ProofingInformationServiceImpl extends ServiceImpl<ProofingInformationMapper, ProofingInformationEntity> implements ProofingInformationService { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
@ -52,6 +73,22 @@ public class ProofingInformationServiceImpl extends ServiceImpl<ProofingInformat |
|
|
|
@Value("${sys-file.file-path}") |
|
|
|
private String filePath; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private SysUserDao sysUserDao; |
|
|
|
|
|
|
|
@Value("${oa-api.api-url}") |
|
|
|
private String apiUrlOa; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private ChangeManagementMapper changeManagementMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private ChangeManagementService changeManagementService; |
|
|
|
|
|
|
|
|
|
|
|
@Value("${login-token-url}") |
|
|
|
private String loginTokenUrl; |
|
|
|
|
|
|
|
/** |
|
|
|
* @description: 打样信息列表 |
|
|
|
* @author: fengyuan_yang |
|
|
|
@ -83,6 +120,7 @@ public class ProofingInformationServiceImpl extends ServiceImpl<ProofingInformat |
|
|
|
String proofingNo = proofingInformationMapper.getProofingNo(data); |
|
|
|
data.setProofingNo("DY" + proofingNo); |
|
|
|
data.setTestPartNo(testPartNo); |
|
|
|
data.setStepId(10); |
|
|
|
data.setProofingResultStatus(data.getProofingResultStatus()); |
|
|
|
proofingInformationMapper.insert(data); |
|
|
|
// site和打样单号赋值 |
|
|
|
@ -145,8 +183,8 @@ public class ProofingInformationServiceImpl extends ServiceImpl<ProofingInformat |
|
|
|
proofingInformationMapper.deleteByMap(map1); |
|
|
|
// 编辑打样相关 人员处理 |
|
|
|
delegateAccessService.lambdaUpdate() |
|
|
|
.eq(ProofingDelegateAccess::getSite, data.getSite()) |
|
|
|
.eq(ProofingDelegateAccess::getProofingNo, data.getProofingNo()) |
|
|
|
.eq(ProofingDelegateAccess::getSite, entity.getSite()) |
|
|
|
.eq(ProofingDelegateAccess::getProofingNo, entity.getProofingNo()) |
|
|
|
.remove(); |
|
|
|
// 删除打样相关文件 |
|
|
|
sysOssDao.deleteByMap(map2); |
|
|
|
@ -365,11 +403,669 @@ public class ProofingInformationServiceImpl extends ServiceImpl<ProofingInformat |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
public void proofingInformationEditStatus(ProofingInformationEntity data) { |
|
|
|
public void proofingInformationEditStatus(ProofingInformationVo data) { |
|
|
|
// 1、获取当前登陆人的域控账号 |
|
|
|
SysUserEntity user = sysUserDao.selectOne(new LambdaQueryWrapper<SysUserEntity>().eq(SysUserEntity::getUsername, data.getUserName())); |
|
|
|
OaUserInfoParam oaUserInfoParam = new OaUserInfoParam(); |
|
|
|
oaUserInfoParam.setLoginId(user.getDomainControlAccount()); |
|
|
|
|
|
|
|
// 2、调用 获取OA人员信息 接口, 获得域控账号对应的OA人员ID |
|
|
|
String getOaUserInfoURL = apiUrlOa + "/oa/interface/getOaUserInfo"; |
|
|
|
ResponseData getOaUserInfoResponse = HttpClientUtil.doPostByRawWithOA(getOaUserInfoURL, oaUserInfoParam); |
|
|
|
if (!"0".equals(getOaUserInfoResponse.getCode())) { |
|
|
|
throw new RuntimeException("OA接口获取人员异常信息:" + getOaUserInfoResponse.getMsg()); |
|
|
|
} |
|
|
|
List<Map<String, Object>> result = JSON.parseObject(String.valueOf(getOaUserInfoResponse.getObj()), new TypeReference<List<Map<String, Object>>>(){}); |
|
|
|
if (result.isEmpty()) { |
|
|
|
throw new RuntimeException("未获取到域控账号对应的OA人员!"); |
|
|
|
} |
|
|
|
Map<String, Object> map = result.get(0); |
|
|
|
String userId = (String) map.get("id"); |
|
|
|
|
|
|
|
// 3、调用新建流程接口 |
|
|
|
// 3.1 根据当前页面的menuId查 流程ID 和 流程标题(名称 + 人员 + 时间) |
|
|
|
List<PlmRequestHeaderVo> requestHeader = changeManagementMapper.queryRequestHeader(data.getSite(), data.getMenuId()); |
|
|
|
if (requestHeader.isEmpty()) { |
|
|
|
throw new RuntimeException("流程ID获取有误!"); |
|
|
|
} |
|
|
|
String workflowId = requestHeader.get(0).getWorkflowId(); |
|
|
|
String workflowname = requestHeader.get(0).getWorkflowname(); |
|
|
|
String requestName = requestHeader.get(0).getWorkflowname() + "-" + data.getUserName() + "-" + DateUtils.getStringNow(); |
|
|
|
String reqUrl = requestHeader.get(0).getUrl(); |
|
|
|
String path = "/".equals(String.valueOf(reqUrl.charAt(0))) ? reqUrl.substring(1).replaceAll("/", "-") : reqUrl.replaceAll("/", "-"); |
|
|
|
|
|
|
|
// 3.2 获取mainData |
|
|
|
List<MainData> mainData = new ArrayList<>(); |
|
|
|
List<PlmRequestDetailVo> nodeDetails = changeManagementMapper.queryNodeDetailFirst(data.getSite(), workflowId, data.getMenuId()); |
|
|
|
|
|
|
|
// 查出询价单相关表的数据 |
|
|
|
// 主信息 |
|
|
|
ProofingInformationEntity changeRequest = baseMapper.selectOne(new LambdaQueryWrapper<ProofingInformationEntity>().eq(ProofingInformationEntity::getSite, data.getSite()).eq(ProofingInformationEntity::getProofingNo, data.getProofingNo())); |
|
|
|
List<ProofingDelegateAccess> list = delegateAccessService.lambdaQuery().eq(ProofingDelegateAccess::getSite, data.getSite()).eq(ProofingDelegateAccess::getProofingNo, data.getProofingNo()).list(); |
|
|
|
// 根据字段对应的数据库表+字段查询出数据 |
|
|
|
for (PlmRequestDetailVo nodeDetail : nodeDetails) { |
|
|
|
if (Objects.isNull(nodeDetail.getId())){ |
|
|
|
continue; |
|
|
|
} |
|
|
|
MainData md = new MainData(); |
|
|
|
StringBuilder fieldValues = new StringBuilder(); |
|
|
|
md.setFieldName(nodeDetail.getOaField()); |
|
|
|
if (!nodeDetail.getFieldValue().isEmpty()) { |
|
|
|
md.setFieldValue(nodeDetail.getFieldValue()); |
|
|
|
mainData.add(md); |
|
|
|
continue; |
|
|
|
} |
|
|
|
// 获取指定属性值 |
|
|
|
if ("plm_proofing_information".equals(nodeDetail.getPlmTable())) { // 主信息字段 |
|
|
|
String fieldValue = ""; |
|
|
|
fieldValue = (String) getPropertyValue(changeRequest, nodeDetail.getPlmField()); |
|
|
|
if ("A".equals(nodeDetail.getFieldType())) { // 判断是否为人员 |
|
|
|
String account = sysUserDao.selectOne(new LambdaQueryWrapper<SysUserEntity>().eq(SysUserEntity::getUsername, fieldValue)).getDomainControlAccount(); |
|
|
|
OaUserInfoParam oaUserInfoParam2 = new OaUserInfoParam(); |
|
|
|
oaUserInfoParam2.setLoginId(account); |
|
|
|
String getOaUserInfoURL2 = apiUrlOa + "/oa/interface/getOaUserInfo"; |
|
|
|
ResponseData getOaUserInfoResponse2 = HttpClientUtil.doPostByRawWithOA(getOaUserInfoURL2, oaUserInfoParam2); |
|
|
|
if (!"0".equals(getOaUserInfoResponse2.getCode())) { |
|
|
|
throw new RuntimeException("OA接口获取人员异常信息:" + getOaUserInfoResponse2.getMsg()); |
|
|
|
} |
|
|
|
List<Map<String, Object>> result2 = JSON.parseObject(String.valueOf(getOaUserInfoResponse2.getObj()), new TypeReference<List<Map<String, Object>>>(){}); |
|
|
|
if (result2.isEmpty()) { |
|
|
|
throw new RuntimeException("未获取到域控账号对应的OA人员!"); |
|
|
|
} |
|
|
|
Map<String, Object> map2 = result2.get(0); |
|
|
|
String userId2 = (String) map2.get("id"); |
|
|
|
md.setFieldValue(userId2); |
|
|
|
} else { |
|
|
|
md.setFieldValue(fieldValue); |
|
|
|
} |
|
|
|
mainData.add(md); |
|
|
|
}else if ("plm_proofing_delegate_access".equals(nodeDetail.getPlmTable())){ |
|
|
|
for (ProofingDelegateAccess access : list) { |
|
|
|
String fieldValue = ""; |
|
|
|
fieldValue = (String) getPropertyValue(access, nodeDetail.getPlmField()); |
|
|
|
md.setFieldName(nodeDetail.getOaField()); |
|
|
|
if ("A".equals(nodeDetail.getFieldType())) { // 判断是否为人员 |
|
|
|
String account = sysUserDao.selectOne(new LambdaQueryWrapper<SysUserEntity>().eq(SysUserEntity::getUsername, access.getDelegateAccess())).getDomainControlAccount(); |
|
|
|
OaUserInfoParam oaUserInfoParam2 = new OaUserInfoParam(); |
|
|
|
oaUserInfoParam2.setLoginId(account); |
|
|
|
String getOaUserInfoURL2 = apiUrlOa + "/oa/interface/getOaUserInfo"; |
|
|
|
ResponseData getOaUserInfoResponse2 = HttpClientUtil.doPostByRawWithOA(getOaUserInfoURL2, oaUserInfoParam2); |
|
|
|
if (!"0".equals(getOaUserInfoResponse2.getCode())) { |
|
|
|
throw new RuntimeException("OA接口获取人员异常信息:" + getOaUserInfoResponse2.getMsg()); |
|
|
|
} |
|
|
|
List<Map<String, Object>> result2 = JSON.parseObject(String.valueOf(getOaUserInfoResponse2.getObj()), new TypeReference<List<Map<String, Object>>>(){}); |
|
|
|
if (result2.isEmpty()) { |
|
|
|
throw new RuntimeException("未获取到域控账号对应的OA人员!"); |
|
|
|
} |
|
|
|
Map<String, Object> map2 = result2.get(0); |
|
|
|
String userId2 = (String) map2.get("id"); |
|
|
|
md.setFieldValue(userId2); |
|
|
|
} else { |
|
|
|
md.setFieldValue(fieldValue); |
|
|
|
} |
|
|
|
mainData.add(md); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
ParamData paramData = new ParamData(data.getSite(), user.getDomainControlAccount(), nodeDetails.get(0).getNodeId(), |
|
|
|
data.getProofingNo(), data.getUserName(), requestHeader.get(0).getClassificationNo(), |
|
|
|
nodeDetails.get(0).getStepId(), requestHeader.get(0).getMenuId(), userId, workflowId, |
|
|
|
workflowname, requestName, mainData, path, "", "plm_proofing_information", "proofing_no"); |
|
|
|
try { |
|
|
|
issueFunction(paramData); |
|
|
|
// 10、修改单据状态为 "审批中" |
|
|
|
data.setStepId(paramData.getStepId()); |
|
|
|
data.setProofingStatus("审批中"); |
|
|
|
} catch (Exception e) { |
|
|
|
rollBackFunction(paramData); |
|
|
|
throw new RuntimeException(e.getMessage()); |
|
|
|
} |
|
|
|
|
|
|
|
// 编辑打样信息 |
|
|
|
UpdateWrapper<ProofingInformationEntity> updateInformationWrapper = new UpdateWrapper<>(); |
|
|
|
updateInformationWrapper.eq("site", data.getSite()); |
|
|
|
updateInformationWrapper.eq("proofing_no", data.getProofingNo()); |
|
|
|
proofingInformationMapper.update(data, updateInformationWrapper); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
public void submitChange(ProofingInformationVo data) { |
|
|
|
// 保存修改信息 |
|
|
|
lambdaUpdate() |
|
|
|
.eq(ProofingInformationEntity::getSite, data.getSite()) |
|
|
|
.eq(ProofingInformationEntity::getProofingNo, data.getProofingNo()).update(data); |
|
|
|
|
|
|
|
// 1、获取当前登陆人的域控账号 |
|
|
|
SysUserEntity user = sysUserDao.selectOne(new LambdaQueryWrapper<SysUserEntity>().eq(SysUserEntity::getUsername, data.getUserName())); |
|
|
|
OaUserInfoParam oaUserInfoParam = new OaUserInfoParam(); |
|
|
|
oaUserInfoParam.setLoginId(user.getDomainControlAccount()); |
|
|
|
|
|
|
|
// 2、调用 获取OA人员信息 接口, 获得域控账号对应的OA人员ID |
|
|
|
String getOaUserInfoURL = apiUrlOa + "/oa/interface/getOaUserInfo"; |
|
|
|
ResponseData getOaUserInfoResponse = HttpClientUtil.doPostByRawWithOA(getOaUserInfoURL, oaUserInfoParam); |
|
|
|
if (!"0".equals(getOaUserInfoResponse.getCode())) { |
|
|
|
throw new RuntimeException("OA接口获取人员异常信息:" + getOaUserInfoResponse.getMsg()); |
|
|
|
} |
|
|
|
List<Map<String, Object>> result = JSON.parseObject(String.valueOf(getOaUserInfoResponse.getObj()), new TypeReference<List<Map<String, Object>>>(){}); |
|
|
|
if (result.isEmpty()) { |
|
|
|
throw new RuntimeException("未获取到域控账号对应的OA人员!"); |
|
|
|
} |
|
|
|
Map<String, Object> map = result.get(0); |
|
|
|
String userId = (String) map.get("id"); |
|
|
|
|
|
|
|
// 3、获取待提交的 流程请求ID |
|
|
|
data.setBu(""); |
|
|
|
List<ProcessFormEntity> processFormList = changeManagementMapper.queryRequestId(data.getSite(), data.getBu(), data.getProofingNo()); |
|
|
|
if (processFormList.isEmpty()) { |
|
|
|
throw new RuntimeException("流程请求ID获取有误!"); |
|
|
|
} |
|
|
|
String requestId = processFormList.get(0).getRequestId(); |
|
|
|
String requestName = processFormList.get(0).getWorkflowname() + "-" + data.getUserName() + "-" + DateUtils.getStringNow(); |
|
|
|
String reqUrl = processFormList.get(0).getUrl(); |
|
|
|
String path = "/".equals(String.valueOf(reqUrl.charAt(0))) ? reqUrl.substring(1).replaceAll("/", "-") : reqUrl.replaceAll("/", "-"); |
|
|
|
|
|
|
|
// 4、 接口:流程提交接口(同意) / 流程退回接口(驳回) |
|
|
|
// 主信息 |
|
|
|
ProofingInformationEntity changeRequest = baseMapper.selectOne(new LambdaQueryWrapper<ProofingInformationEntity>().eq(ProofingInformationEntity::getSite, data.getSite()).eq(ProofingInformationEntity::getProofingNo, data.getProofingNo())); |
|
|
|
List<ProofingDelegateAccess> list = delegateAccessService.lambdaQuery().eq(ProofingDelegateAccess::getSite, data.getSite()).eq(ProofingDelegateAccess::getProofingNo, data.getProofingNo()).list(); |
|
|
|
ParamData paramData = new ParamData(data.getSite(), processFormList.get(0).getNodeId(), data.getProofingNo(), data.getUserName(), processFormList.get(0).getClassificationNo(), |
|
|
|
userId, processFormList.get(0).getWorkflowId(), processFormList.get(0).getWorkflowname(), requestName, path, requestId, |
|
|
|
"plm_proofing_information", "proofing_no", "proofing_status", |
|
|
|
changeRequest.getStepId(), data.getBu(), user.getDomainControlAccount(), processFormList.get(0).getMenuId()); |
|
|
|
|
|
|
|
if ("Y".equals(data.getNodeConclusion())) { // 同意 |
|
|
|
// 创建 mainData |
|
|
|
List<MainData> mainData = new ArrayList<>(); |
|
|
|
List<PlmRequestDetailVo> nodeDetails = changeManagementMapper.queryNodeDetails(processFormList.get(0)); |
|
|
|
// 根据字段对应的数据库表+字段查询出数据 |
|
|
|
for (PlmRequestDetailVo nodeDetail : nodeDetails) { |
|
|
|
if (nodeDetail.getId() == null) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
MainData md = new MainData(); |
|
|
|
StringBuilder fieldValues = new StringBuilder(); |
|
|
|
md.setFieldName(nodeDetail.getOaField()); |
|
|
|
if (!nodeDetail.getFieldValue().isEmpty()) { |
|
|
|
md.setFieldValue(nodeDetail.getFieldValue()); |
|
|
|
mainData.add(md); |
|
|
|
continue; |
|
|
|
} |
|
|
|
// 获取指定属性值 |
|
|
|
if ("plm_proofing_information".equals(nodeDetail.getPlmTable())) { // 主信息字段 |
|
|
|
String fieldValue = ""; |
|
|
|
fieldValue = (String) getPropertyValue(changeRequest, nodeDetail.getPlmField()); |
|
|
|
if ("A".equals(nodeDetail.getFieldType())) { // 判断是否为人员 |
|
|
|
String account = sysUserDao.selectOne(new LambdaQueryWrapper<SysUserEntity>().eq(SysUserEntity::getUsername, fieldValue)).getDomainControlAccount(); |
|
|
|
OaUserInfoParam oaUserInfoParam2 = new OaUserInfoParam(); |
|
|
|
oaUserInfoParam2.setLoginId(account); |
|
|
|
String getOaUserInfoURL2 = apiUrlOa + "/oa/interface/getOaUserInfo"; |
|
|
|
ResponseData getOaUserInfoResponse2 = HttpClientUtil.doPostByRawWithOA(getOaUserInfoURL2, oaUserInfoParam2); |
|
|
|
if (!"0".equals(getOaUserInfoResponse2.getCode())) { |
|
|
|
throw new RuntimeException("OA接口获取人员异常信息:" + getOaUserInfoResponse2.getMsg()); |
|
|
|
} |
|
|
|
List<Map<String, Object>> result2 = JSON.parseObject(String.valueOf(getOaUserInfoResponse2.getObj()), new TypeReference<List<Map<String, Object>>>(){}); |
|
|
|
if (result2.isEmpty()) { |
|
|
|
throw new RuntimeException("未获取到域控账号对应的OA人员!"); |
|
|
|
} |
|
|
|
Map<String, Object> map2 = result2.get(0); |
|
|
|
String userId2 = (String) map2.get("id"); |
|
|
|
md.setFieldValue(userId2); |
|
|
|
} else { |
|
|
|
md.setFieldValue(fieldValue); |
|
|
|
} |
|
|
|
mainData.add(md); |
|
|
|
}else if ("plm_proofing_delegate_access".equals(nodeDetail.getPlmTable())){ |
|
|
|
for (ProofingDelegateAccess access : list) { |
|
|
|
String fieldValue = ""; |
|
|
|
fieldValue = (String) getPropertyValue(access, nodeDetail.getPlmField()); |
|
|
|
md.setFieldName(nodeDetail.getOaField()); |
|
|
|
if ("A".equals(nodeDetail.getFieldType())) { // 判断是否为人员 |
|
|
|
String account = sysUserDao.selectOne(new LambdaQueryWrapper<SysUserEntity>().eq(SysUserEntity::getUsername, access.getDelegateAccess())).getDomainControlAccount(); |
|
|
|
OaUserInfoParam oaUserInfoParam2 = new OaUserInfoParam(); |
|
|
|
oaUserInfoParam2.setLoginId(account); |
|
|
|
String getOaUserInfoURL2 = apiUrlOa + "/oa/interface/getOaUserInfo"; |
|
|
|
ResponseData getOaUserInfoResponse2 = HttpClientUtil.doPostByRawWithOA(getOaUserInfoURL2, oaUserInfoParam2); |
|
|
|
if (!"0".equals(getOaUserInfoResponse2.getCode())) { |
|
|
|
throw new RuntimeException("OA接口获取人员异常信息:" + getOaUserInfoResponse2.getMsg()); |
|
|
|
} |
|
|
|
List<Map<String, Object>> result2 = JSON.parseObject(String.valueOf(getOaUserInfoResponse2.getObj()), new TypeReference<List<Map<String, Object>>>(){}); |
|
|
|
if (result2.isEmpty()) { |
|
|
|
throw new RuntimeException("未获取到域控账号对应的OA人员!"); |
|
|
|
} |
|
|
|
Map<String, Object> map2 = result2.get(0); |
|
|
|
String userId2 = (String) map2.get("id"); |
|
|
|
md.setFieldValue(userId2); |
|
|
|
} else { |
|
|
|
md.setFieldValue(fieldValue); |
|
|
|
} |
|
|
|
mainData.add(md); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
paramData.setMainData(mainData); |
|
|
|
try { |
|
|
|
agreeFunction(paramData); |
|
|
|
} catch (Exception e) { |
|
|
|
// 撤回接口 |
|
|
|
DoForceDrawBackParam doForceDrawBackParam = new DoForceDrawBackParam(); |
|
|
|
doForceDrawBackParam.setUserId(paramData.getUserId()); |
|
|
|
doForceDrawBackParam.setRequestId(paramData.getRequestId()); |
|
|
|
String doForceDrawBackURL = apiUrlOa + "/oa/interface/doForceDrawBack"; |
|
|
|
ResponseData doForceDrawBackResponses = HttpClientUtil.doPostByRawWithOA(doForceDrawBackURL, doForceDrawBackParam); |
|
|
|
if (!"0".equals(doForceDrawBackResponses.getCode())) { |
|
|
|
throw new RuntimeException("OA撤回流程异常信息:" + doForceDrawBackResponses.getMsg()); |
|
|
|
} |
|
|
|
throw new RuntimeException(e.getMessage()); |
|
|
|
} |
|
|
|
} else { // 驳回 |
|
|
|
try { |
|
|
|
rejectFunction(paramData); |
|
|
|
} catch (Exception e) { |
|
|
|
log.info("{}",e.getMessage()); |
|
|
|
// 撤回接口 |
|
|
|
DoForceDrawBackParam doForceDrawBackParam = new DoForceDrawBackParam(); |
|
|
|
doForceDrawBackParam.setUserId(paramData.getUserId()); |
|
|
|
doForceDrawBackParam.setRequestId(paramData.getRequestId()); |
|
|
|
String doForceDrawBackURL = apiUrlOa + "/oa/interface/doForceDrawBack"; |
|
|
|
ResponseData doForceDrawBackResponses = HttpClientUtil.doPostByRawWithOA(doForceDrawBackURL, doForceDrawBackParam); |
|
|
|
if (!"0".equals(doForceDrawBackResponses.getCode())) { |
|
|
|
throw new RuntimeException("OA撤回流程异常信息:" + doForceDrawBackResponses.getMsg()); |
|
|
|
} |
|
|
|
throw new RuntimeException(e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 封装的同意提交方法 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Transactional |
|
|
|
public void agreeFunction (ParamData paramData) { |
|
|
|
SubmitRequestParam submitRequestParam = new SubmitRequestParam(); |
|
|
|
submitRequestParam.setUserId(paramData.getUserId()); |
|
|
|
submitRequestParam.setRequestId(paramData.getRequestId()); |
|
|
|
submitRequestParam.setMainData(paramData.getMainData()); |
|
|
|
String submitRequestURL = apiUrlOa + "/oa/interface/submitRequest"; |
|
|
|
ResponseData submitRequestResponses = HttpClientUtil.doPostByRawWithOA(submitRequestURL, submitRequestParam); |
|
|
|
if (!"0".equals(submitRequestResponses.getCode())) { |
|
|
|
throw new RuntimeException("OA提交流程异常信息:" + submitRequestResponses.getMsg()); |
|
|
|
} |
|
|
|
// 获取流程流转信息 |
|
|
|
RequestOperatorInfoParam requestOperatorInfoParam = new RequestOperatorInfoParam(); |
|
|
|
requestOperatorInfoParam.setUserId(paramData.getUserId()); |
|
|
|
requestOperatorInfoParam.setRequestId(paramData.getRequestId()); |
|
|
|
String getRequestOperatorInfoURL = apiUrlOa + "/oa/interface/getRequestOperatorInfo"; |
|
|
|
ResponseData getRequestOperatorInfoResponses = HttpClientUtil.doPostByRawWithOA(getRequestOperatorInfoURL, requestOperatorInfoParam); |
|
|
|
if (!"0".equals(getRequestOperatorInfoResponses.getCode())) { |
|
|
|
throw new RuntimeException("OA获取流程流转信息异常信息:" + getRequestOperatorInfoResponses.getMsg()); |
|
|
|
} |
|
|
|
// 全部流转信息 |
|
|
|
List<Map<String, Object>> res = JSON.parseObject(String.valueOf(getRequestOperatorInfoResponses.getObj()), new TypeReference<List<Map<String, Object>>>(){}); |
|
|
|
// isRemark 为0的流转信息 |
|
|
|
List<Map<String, Object>> isRemarks = res.stream().filter(a -> convertToInt(a.get("isremark")) == 0).collect(Collectors.toList()); |
|
|
|
// 将记录表中 isRemark 为0的修改为1 |
|
|
|
changeManagementMapper.updateProcessForm2(paramData); |
|
|
|
if (isRemarks.isEmpty()) { // 已结束 |
|
|
|
// 反刷单据状态为 "已完成" |
|
|
|
paramData.setStatus("已完成"); |
|
|
|
changeManagementMapper.updateChangeStatus2(paramData); |
|
|
|
} else { // 未结束 |
|
|
|
// 存放isRemark为0的域控账号 |
|
|
|
Map<String, String> dcas = new HashMap<>(); |
|
|
|
int stepId = changeManagementMapper.getStepId(paramData.getClassificationNo(), String.valueOf(isRemarks.get(0).get("nodeid"))); |
|
|
|
paramData.setStepId(stepId); |
|
|
|
for (Map<String, Object> isRemark : isRemarks) { |
|
|
|
ProcessFormEntity processFormEntity = new ProcessFormEntity(); |
|
|
|
processFormEntity.setSite(paramData.getSite()); |
|
|
|
processFormEntity.setBu(""); |
|
|
|
processFormEntity.setRequestId(paramData.getRequestId()); |
|
|
|
processFormEntity.setWorkflowId(paramData.getWorkflowId()); |
|
|
|
processFormEntity.setNodeId(String.valueOf(isRemark.get("nodeid"))); |
|
|
|
// 根据 userId 调用获取人员信息接口获得域控账号 |
|
|
|
OaUserInfoParam oaUserInfoParam2 = new OaUserInfoParam(); |
|
|
|
oaUserInfoParam2.setId(String.valueOf(isRemark.get("userid"))); |
|
|
|
String getOaUserInfoURL2 = apiUrlOa + "/oa/interface/getOaUserInfo"; |
|
|
|
ResponseData getOaUserInfoResponse2 = HttpClientUtil.doPostByRawWithOA(getOaUserInfoURL2, oaUserInfoParam2); |
|
|
|
if (!"0".equals(getOaUserInfoResponse2.getCode())) { |
|
|
|
throw new RuntimeException("OA接口获取人员异常信息:" + getOaUserInfoResponse2.getMsg()); |
|
|
|
} |
|
|
|
List<Map<String, Object>> resList = JSON.parseObject(String.valueOf(getOaUserInfoResponse2.getObj()), new TypeReference<List<Map<String, Object>>>(){}); |
|
|
|
if (resList.isEmpty()) { |
|
|
|
throw new RuntimeException("未获取到OA人员对应的域控账号!"); |
|
|
|
} |
|
|
|
|
|
|
|
// 域控账号 |
|
|
|
isRemark.put("domainControlAccount", resList.get(0).get("loginid")); |
|
|
|
// 节点名称 |
|
|
|
String nodeName = changeManagementMapper.getNodeName(paramData.getSite(), paramData.getClassificationNo(), String.valueOf(isRemark.get("nodeid"))); |
|
|
|
isRemark.put("nodeName", nodeName); |
|
|
|
try { // 域控账号和token |
|
|
|
dcas.put(String.valueOf(resList.get(0).get("loginid")), AESUtil.encrypt(String.valueOf(resList.get(0).get("loginid"))) + "#" + isRemark.get("userid")); |
|
|
|
} catch (Exception e) { |
|
|
|
log.info(e.getMessage()); |
|
|
|
} |
|
|
|
processFormEntity.setDomainControlAccount(String.valueOf(resList.get(0).get("loginid"))); |
|
|
|
processFormEntity.setDocumentNo(paramData.getDocNo()); |
|
|
|
processFormEntity.setDocumentType(Constant.DY_PR); |
|
|
|
processFormEntity.setCreateBy(paramData.getUserName()); |
|
|
|
processFormEntity.setIsRemark(0); |
|
|
|
processFormEntity.setClassificationNo(paramData.getClassificationNo()); |
|
|
|
// 根据 site、bu、requestId 得到序号 |
|
|
|
int seqNo = changeManagementMapper.getSeqNo(processFormEntity); |
|
|
|
processFormEntity.setSeqNo(seqNo); |
|
|
|
processFormEntity.setStepId(stepId); |
|
|
|
processFormEntity.setMenuId(paramData.getMenuId()); |
|
|
|
if ("N".equals(paramData.getNodeConclusion())) { |
|
|
|
processFormEntity.setRejectNodeId(paramData.getNodeId()); |
|
|
|
} |
|
|
|
changeManagementMapper.saveProcessForm(processFormEntity); |
|
|
|
} |
|
|
|
// 修改该变更单的 stepId |
|
|
|
changeManagementMapper.updateStepId2(paramData); |
|
|
|
|
|
|
|
// 9、统一待办接口 |
|
|
|
for (String key : dcas.keySet()) { |
|
|
|
// 创建单点登录地址 |
|
|
|
String url = loginTokenUrl + "?dca=" + key + "&token=" + dcas.get(key).split("#")[0] + "&site=" + paramData.getSite() + "&path=" + paramData.getPath() + "&docNo=" + paramData.getDocNo(); |
|
|
|
ReceiveRequestInfoParam receiveRequestInfoParam = new ReceiveRequestInfoParam( |
|
|
|
paramData.getUserId(), |
|
|
|
"PLM", |
|
|
|
paramData.getWorkflowId(), |
|
|
|
paramData.getRequestName(), |
|
|
|
paramData.getWorkflowName(), |
|
|
|
String.valueOf(isRemarks.get(0).get("nodeName")), |
|
|
|
url, |
|
|
|
"0", |
|
|
|
"0", |
|
|
|
paramData.getUserId(), |
|
|
|
DateUtils.getStringNow(), |
|
|
|
dcas.get(key).split("#")[1], |
|
|
|
DateUtils.getStringNow(), |
|
|
|
String.valueOf(new Date().getTime())); |
|
|
|
String receiveRequestInfoURL = apiUrlOa + "/oa/interface/receiveRequestInfoByJson"; |
|
|
|
ResponseData receiveRequestInfoResponse = HttpClientUtil.doPostByRawWithOA(receiveRequestInfoURL, receiveRequestInfoParam); |
|
|
|
if (!"0".equals(receiveRequestInfoResponse.getCode())) { |
|
|
|
throw new RuntimeException("统一待办异常信息:" + receiveRequestInfoResponse.getMsg()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 封装的驳回提交方法 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Transactional |
|
|
|
public void rejectFunction (ParamData paramData) { |
|
|
|
SubmitRequestParam submitRequestParam = new SubmitRequestParam(); |
|
|
|
submitRequestParam.setUserId(paramData.getUserId()); |
|
|
|
submitRequestParam.setRequestId(paramData.getRequestId()); |
|
|
|
submitRequestParam.setMainData(paramData.getMainData()); |
|
|
|
String submitRequestURL = apiUrlOa + "/oa/interface/rejectRequest"; |
|
|
|
ResponseData submitRequestResponses = HttpClientUtil.doPostByRawWithOA(submitRequestURL, submitRequestParam); |
|
|
|
if (!"0".equals(submitRequestResponses.getCode())) { |
|
|
|
throw new RuntimeException("OA流程退回异常信息:" + submitRequestResponses.getMsg()); |
|
|
|
} |
|
|
|
// 修改变更单的退回标记为Y,stepId为当前stepId |
|
|
|
paramData.setRejectFlag("Y"); |
|
|
|
paramData.setRejectStepId(paramData.getRejectStepId()); |
|
|
|
changeManagementMapper.updateChangeReject2(paramData); |
|
|
|
// 修改当前流程记录的退回标记为Y,并记录当前节点 |
|
|
|
changeManagementMapper.updateProcessReject(paramData.getSite(), paramData.getBu(), paramData.getRequestId(), paramData.getDomainControlAccount()); |
|
|
|
ProcessFormEntity processForm = changeManagementMapper.getProcessNodeId(paramData.getSite(), paramData.getBu(), paramData.getRequestId(), paramData.getDomainControlAccount()); |
|
|
|
|
|
|
|
// 获取流程流转信息 |
|
|
|
RequestOperatorInfoParam requestOperatorInfoParam = new RequestOperatorInfoParam(); |
|
|
|
requestOperatorInfoParam.setUserId(paramData.getUserId()); |
|
|
|
requestOperatorInfoParam.setRequestId(paramData.getRequestId()); |
|
|
|
String getRequestOperatorInfoURL = apiUrlOa + "/oa/interface/getRequestOperatorInfo"; |
|
|
|
ResponseData getRequestOperatorInfoResponses = HttpClientUtil.doPostByRawWithOA(getRequestOperatorInfoURL, requestOperatorInfoParam); |
|
|
|
if (!"0".equals(getRequestOperatorInfoResponses.getCode())) { |
|
|
|
throw new RuntimeException("OA获取流程流转信息异常信息:" + getRequestOperatorInfoResponses.getMsg()); |
|
|
|
} |
|
|
|
// 得到全部流转信息 |
|
|
|
List<Map<String, Object>> res = JSON.parseObject(String.valueOf(getRequestOperatorInfoResponses.getObj()), new TypeReference<List<Map<String, Object>>>(){}); |
|
|
|
// 得到 isRemark 为0的流转信息 |
|
|
|
List<Map<String, Object>> isRemarks = res.stream().filter(a -> convertToInt(a.get("isremark")) == 0).collect(Collectors.toList()); |
|
|
|
// 将记录表中 isRemark 为0的修改为1 |
|
|
|
changeManagementMapper.updateProcessForm2(paramData); |
|
|
|
if (isRemarks.isEmpty()) { // 已结束 |
|
|
|
// 反刷单据状态为 "已完成" |
|
|
|
paramData.setStatus("已完成"); |
|
|
|
changeManagementMapper.updateChangeStatus2(paramData); |
|
|
|
} else { // 未结束 |
|
|
|
// 存放isRemark为0的域控账号 |
|
|
|
Map<String, String> dcas = new HashMap<>(); |
|
|
|
int stepId = changeManagementMapper.getStepId(paramData.getClassificationNo(), String.valueOf(isRemarks.get(0).get("nodeid"))); |
|
|
|
paramData.setStepId(stepId); |
|
|
|
for (Map<String, Object> isRemark : isRemarks) { |
|
|
|
// 根据 userId 调用获取人员信息接口获得域控账号 |
|
|
|
OaUserInfoParam oaUserInfoParam2 = new OaUserInfoParam(); |
|
|
|
oaUserInfoParam2.setId(String.valueOf(isRemark.get("userid"))); |
|
|
|
String getOaUserInfoURL2 = apiUrlOa + "/oa/interface/getOaUserInfo"; |
|
|
|
ResponseData getOaUserInfoResponse2 = HttpClientUtil.doPostByRawWithOA(getOaUserInfoURL2, oaUserInfoParam2); |
|
|
|
if (!"0".equals(getOaUserInfoResponse2.getCode())) { |
|
|
|
throw new RuntimeException("OA接口获取人员异常信息:" + getOaUserInfoResponse2.getMsg()); |
|
|
|
} |
|
|
|
List<Map<String, Object>> resList = JSON.parseObject(String.valueOf(getOaUserInfoResponse2.getObj()), new TypeReference<List<Map<String, Object>>>(){}); |
|
|
|
if (resList.isEmpty()) { |
|
|
|
throw new RuntimeException("未获取到OA人员对应的域控账号!"); |
|
|
|
} |
|
|
|
// 域控账号 |
|
|
|
isRemark.put("domainControlAccount", resList.get(0).get("loginid")); |
|
|
|
// 节点名称 |
|
|
|
String nodeName = changeManagementMapper.getNodeName(paramData.getSite(), paramData.getClassificationNo(), String.valueOf(isRemark.get("nodeid"))); |
|
|
|
isRemark.put("nodeName", nodeName); |
|
|
|
try { // 域控账号和token |
|
|
|
dcas.put(String.valueOf(resList.get(0).get("loginid")), AESUtil.encrypt(String.valueOf(resList.get(0).get("loginid"))) + "#" + isRemark.get("userid")); |
|
|
|
} catch (Exception e) { |
|
|
|
log.info(e.getMessage()); |
|
|
|
} |
|
|
|
// 新增流程单据表 |
|
|
|
ProcessFormEntity processFormEntity = new ProcessFormEntity(); |
|
|
|
processFormEntity.setSite(paramData.getSite()); |
|
|
|
processFormEntity.setBu(""); |
|
|
|
processFormEntity.setRequestId(paramData.getRequestId()); |
|
|
|
processFormEntity.setWorkflowId(paramData.getWorkflowId()); |
|
|
|
processFormEntity.setNodeId(String.valueOf(isRemark.get("nodeid"))); |
|
|
|
processFormEntity.setDomainControlAccount(String.valueOf(resList.get(0).get("loginid"))); |
|
|
|
processFormEntity.setDocumentNo(paramData.getDocNo()); |
|
|
|
processFormEntity.setDocumentType(Constant.DY_PR); |
|
|
|
processFormEntity.setCreateBy(paramData.getUserName()); |
|
|
|
processFormEntity.setIsRemark(0); |
|
|
|
processFormEntity.setClassificationNo(paramData.getClassificationNo()); |
|
|
|
processFormEntity.setMenuId(paramData.getMenuId()); |
|
|
|
// 根据 site、bu、requestId 得到序号 |
|
|
|
int seqNo = changeManagementMapper.getSeqNo(processFormEntity); |
|
|
|
processFormEntity.setSeqNo(seqNo); |
|
|
|
processFormEntity.setStepId(stepId); |
|
|
|
processFormEntity.setRejectNodeId(processForm.getNodeId()); |
|
|
|
changeManagementMapper.saveProcessForm(processFormEntity); |
|
|
|
} |
|
|
|
// 修改该变更单的 stepId |
|
|
|
changeManagementMapper.updateStepId2(paramData); |
|
|
|
|
|
|
|
// 9、统一待办接口 |
|
|
|
for (String key : dcas.keySet()) { |
|
|
|
// 创建单点登录地址 |
|
|
|
String url = loginTokenUrl + "?dca=" + key + "&token=" + dcas.get(key).split("#")[0] + "&site=" + paramData.getSite() + "&path=" + paramData.getPath() + "&docNo=" + paramData.getDocNo(); |
|
|
|
ReceiveRequestInfoParam receiveRequestInfoParam = new ReceiveRequestInfoParam( |
|
|
|
paramData.getUserId(), |
|
|
|
"PLM", |
|
|
|
paramData.getWorkflowId(), |
|
|
|
paramData.getRequestName(), |
|
|
|
paramData.getWorkflowName(), |
|
|
|
String.valueOf(isRemarks.get(0).get("nodeName")), |
|
|
|
url, |
|
|
|
"0", |
|
|
|
"0", |
|
|
|
paramData.getUserId(), |
|
|
|
DateUtils.getStringNow(), |
|
|
|
dcas.get(key).split("#")[1], |
|
|
|
DateUtils.getStringNow(), |
|
|
|
String.valueOf(new Date().getTime())); |
|
|
|
String receiveRequestInfoURL = apiUrlOa + "/oa/interface/receiveRequestInfoByJson"; |
|
|
|
ResponseData receiveRequestInfoResponse = HttpClientUtil.doPostByRawWithOA(receiveRequestInfoURL, receiveRequestInfoParam); |
|
|
|
if (!"0".equals(receiveRequestInfoResponse.getCode())) { |
|
|
|
throw new RuntimeException("统一待办异常信息:" + receiveRequestInfoResponse.getMsg()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Transactional |
|
|
|
public void issueFunction(ParamData paramData) throws Exception { |
|
|
|
// 给接口对象赋值,得到 requestId |
|
|
|
OaCreateRequestParam oaCreateRequestParam = new OaCreateRequestParam(paramData.getUserId(), paramData.getWorkflowId(), paramData.getRequestName(), paramData.getMainData()); |
|
|
|
String doCreateRequestURL = apiUrlOa + "/oa/interface/doCreateRequest"; |
|
|
|
ResponseData doCreateRequestResponses = HttpClientUtil.doPostByRawWithOA(doCreateRequestURL, oaCreateRequestParam); |
|
|
|
if (!"0".equals(doCreateRequestResponses.getCode())) { |
|
|
|
paramData.setRequestId(String.valueOf(doCreateRequestResponses.getObj())); |
|
|
|
throw new RuntimeException("OA新建流程异常信息:" + doCreateRequestResponses.getMsg()); |
|
|
|
} |
|
|
|
paramData.setRequestId(String.valueOf(doCreateRequestResponses.getObj())); |
|
|
|
|
|
|
|
// 根据 RequestID 插入PLM流程单据表 |
|
|
|
ProcessFormEntity processFormEntity = new ProcessFormEntity(); |
|
|
|
processFormEntity.setSite(paramData.getSite()); |
|
|
|
processFormEntity.setBu(""); |
|
|
|
processFormEntity.setRequestId(paramData.getRequestId()); |
|
|
|
processFormEntity.setWorkflowId(paramData.getWorkflowId()); |
|
|
|
processFormEntity.setNodeId(paramData.getNodeId()); |
|
|
|
processFormEntity.setDomainControlAccount(paramData.getDomainControlAccount()); |
|
|
|
processFormEntity.setDocumentNo(paramData.getDocNo()); |
|
|
|
processFormEntity.setDocumentType(Constant.DY_PR); |
|
|
|
processFormEntity.setCreateBy(paramData.getUserName()); |
|
|
|
processFormEntity.setIsRemark(1); |
|
|
|
processFormEntity.setClassificationNo(paramData.getClassificationNo()); |
|
|
|
processFormEntity.setStepId(paramData.getStepId()); |
|
|
|
processFormEntity.setMenuId(paramData.getMenuId()); |
|
|
|
// 根据 site、bu、requestId 得到序号 |
|
|
|
int seqNo = changeManagementMapper.getSeqNo(processFormEntity); |
|
|
|
processFormEntity.setSeqNo(seqNo); |
|
|
|
changeManagementMapper.saveProcessForm(processFormEntity); |
|
|
|
// 修改该变更单的 stepId |
|
|
|
changeManagementMapper.updateStepId2(paramData); |
|
|
|
|
|
|
|
// 获取流程流转信息 |
|
|
|
RequestOperatorInfoParam requestOperatorInfoParam = new RequestOperatorInfoParam(); |
|
|
|
requestOperatorInfoParam.setUserId(paramData.getUserId()); |
|
|
|
requestOperatorInfoParam.setRequestId(paramData.getRequestId()); |
|
|
|
String getRequestOperatorInfoURL = apiUrlOa + "/oa/interface/getRequestOperatorInfo"; |
|
|
|
ResponseData getRequestOperatorInfoResponses = HttpClientUtil.doPostByRawWithOA(getRequestOperatorInfoURL, requestOperatorInfoParam); |
|
|
|
if (!"0".equals(getRequestOperatorInfoResponses.getCode())) { |
|
|
|
throw new RuntimeException("OA获取流程流转信息异常信息:" + getRequestOperatorInfoResponses.getMsg()); |
|
|
|
} |
|
|
|
// 得到全部流转信息 |
|
|
|
List<Map<String, Object>> res = JSON.parseObject(String.valueOf(getRequestOperatorInfoResponses.getObj()), new TypeReference<List<Map<String, Object>>>(){}); |
|
|
|
// 得到isRemark为0的流转信息 |
|
|
|
List<Map<String, Object>> isRemarks = res.stream().filter(a -> convertToInt(a.get("isremark")) == 0).collect(Collectors.toList()); |
|
|
|
if (isRemarks.isEmpty()) { |
|
|
|
throw new RuntimeException("未获得流转信息!"); |
|
|
|
} |
|
|
|
|
|
|
|
// 存放isRemark为0的域控账号 |
|
|
|
Map<String, String> dcas = new HashMap<>(); |
|
|
|
|
|
|
|
// 新增PLM流程单据表信息 |
|
|
|
int stepId = changeManagementMapper.getStepId(paramData.getClassificationNo(), String.valueOf(isRemarks.get(0).get("nodeid"))); |
|
|
|
paramData.setStepId(stepId); |
|
|
|
for (Map<String, Object> remark : isRemarks) { |
|
|
|
// 根据 userId 调用获取人员信息接口获得域控账号 |
|
|
|
OaUserInfoParam oaUserInfoParam2 = new OaUserInfoParam(); |
|
|
|
oaUserInfoParam2.setId(String.valueOf(remark.get("userid"))); |
|
|
|
String getOaUserInfoURL2 = apiUrlOa + "/oa/interface/getOaUserInfo"; |
|
|
|
ResponseData getOaUserInfoResponse2 = HttpClientUtil.doPostByRawWithOA(getOaUserInfoURL2, oaUserInfoParam2); |
|
|
|
if (!"0".equals(getOaUserInfoResponse2.getCode())) { |
|
|
|
throw new RuntimeException("OA接口获取人员异常信息:" + getOaUserInfoResponse2.getMsg()); |
|
|
|
} |
|
|
|
List<Map<String, Object>> resList = JSON.parseObject(String.valueOf(getOaUserInfoResponse2.getObj()), new TypeReference<List<Map<String, Object>>>(){}); |
|
|
|
if (resList.isEmpty()) { |
|
|
|
throw new RuntimeException("未获取到OA人员对应的域控账号!"); |
|
|
|
} |
|
|
|
// 域控账号 |
|
|
|
remark.put("domainControlAccount", resList.get(0).get("loginid")); |
|
|
|
// 节点名称 |
|
|
|
String nodeName = changeManagementMapper.getNodeName(paramData.getSite(), paramData.getClassificationNo(), String.valueOf(remark.get("nodeid"))); |
|
|
|
remark.put("nodeName", nodeName); |
|
|
|
// 域控账号和token |
|
|
|
dcas.put(String.valueOf(resList.get(0).get("loginid")), AESUtil.encrypt(String.valueOf(resList.get(0).get("loginid"))) + "#" + remark.get("userid")); |
|
|
|
// 新增流程单据表 |
|
|
|
ProcessFormEntity processForm = new ProcessFormEntity(); |
|
|
|
processForm.setSite(paramData.getSite()); |
|
|
|
processForm.setBu(""); |
|
|
|
processForm.setRequestId(paramData.getRequestId()); |
|
|
|
processForm.setWorkflowId(paramData.getWorkflowId()); |
|
|
|
processForm.setNodeId(String.valueOf(remark.get("nodeid"))); |
|
|
|
processForm.setDomainControlAccount(String.valueOf(remark.get("domainControlAccount"))); |
|
|
|
processForm.setDocumentNo(paramData.getDocNo()); |
|
|
|
processForm.setDocumentType(Constant.DY_PR); |
|
|
|
processForm.setCreateBy(paramData.getUserName()); |
|
|
|
processForm.setIsRemark(0); |
|
|
|
processForm.setClassificationNo(paramData.getClassificationNo()); |
|
|
|
processForm.setMenuId(paramData.getMenuId()); |
|
|
|
// 根据 site、bu、requestId 得到序号 |
|
|
|
int seq = changeManagementMapper.getSeqNo(processForm); |
|
|
|
processForm.setSeqNo(seq); |
|
|
|
processForm.setStepId(stepId); |
|
|
|
changeManagementMapper.saveProcessForm(processForm); |
|
|
|
} |
|
|
|
// 修改该变更单的 stepId |
|
|
|
changeManagementMapper.updateStepId2(paramData); |
|
|
|
|
|
|
|
// 统一待办接口 |
|
|
|
for (String key : dcas.keySet()) { |
|
|
|
// 创建单点登录地址 |
|
|
|
String url = loginTokenUrl + "?dca=" + key + "&token=" + dcas.get(key).split("#")[0] + "&site=" + paramData.getSite() + "&path=" + paramData.getPath() + "&docNo=" + paramData.getDocNo(); |
|
|
|
ReceiveRequestInfoParam receiveRequestInfoParam = new ReceiveRequestInfoParam( |
|
|
|
paramData.getUserId(), |
|
|
|
"PLM", |
|
|
|
paramData.getWorkflowId(), |
|
|
|
paramData.getRequestName(), |
|
|
|
paramData.getWorkflowName(), |
|
|
|
String.valueOf(isRemarks.get(0).get("nodeName")), |
|
|
|
url, |
|
|
|
"0", |
|
|
|
"0", |
|
|
|
paramData.getUserId(), |
|
|
|
DateUtils.getStringNow(), |
|
|
|
dcas.get(key).split("#")[1], |
|
|
|
DateUtils.getStringNow(), |
|
|
|
String.valueOf(new Date().getTime())); |
|
|
|
String receiveRequestInfoURL = apiUrlOa + "/oa/interface/receiveRequestInfoByJson"; |
|
|
|
ResponseData receiveRequestInfoResponse = HttpClientUtil.doPostByRawWithOA(receiveRequestInfoURL, receiveRequestInfoParam); |
|
|
|
if (!"0".equals(receiveRequestInfoResponse.getCode())) { |
|
|
|
throw new RuntimeException("统一待办异常信息:" + receiveRequestInfoResponse.getMsg()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 回滚方法 |
|
|
|
*/ |
|
|
|
public void rollBackFunction(ParamData paramData) { |
|
|
|
// 撤回接口 |
|
|
|
DoForceDrawBackParam doForceDrawBackParam = new DoForceDrawBackParam(); |
|
|
|
doForceDrawBackParam.setUserId(paramData.getUserId()); |
|
|
|
doForceDrawBackParam.setRequestId(paramData.getRequestId()); |
|
|
|
String doForceDrawBackURL = apiUrlOa + "/oa/interface/doForceDrawBack"; |
|
|
|
ResponseData doForceDrawBackResponses = HttpClientUtil.doPostByRawWithOA(doForceDrawBackURL, doForceDrawBackParam); |
|
|
|
if (!"0".equals(doForceDrawBackResponses.getCode())) { |
|
|
|
throw new RuntimeException("OA撤回流程异常信息:" + doForceDrawBackResponses.getMsg()); |
|
|
|
} |
|
|
|
// 调用删除流程接口 |
|
|
|
RequestOperatorInfoParam requestOperatorInfoParam = new RequestOperatorInfoParam(); |
|
|
|
requestOperatorInfoParam.setUserId(paramData.getUserId()); |
|
|
|
requestOperatorInfoParam.setRequestId(paramData.getRequestId()); |
|
|
|
String deleteRequestURL = apiUrlOa + "/oa/interface/deleteRequest"; |
|
|
|
ResponseData deleteRequestResponses = HttpClientUtil.doPostByRawWithOA(deleteRequestURL, requestOperatorInfoParam); |
|
|
|
if (!"0".equals(deleteRequestResponses.getCode())) { |
|
|
|
throw new RuntimeException("OA删除流程异常信息:" + deleteRequestResponses.getMsg()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |