feat: E采通对接 401 402接口

This commit is contained in:
2024-05-22 13:59:13 +08:00
parent edc1783b22
commit d5dedf2e62
25 changed files with 704 additions and 211 deletions
@@ -718,7 +718,7 @@ public class LoginServiceImpl implements ILoginService {
if(!result.isSuccess()) {
return result;
}
if (checkSysPermission(sysUser.getUsername())) {
if (checkSysPermission(sysUser.getUsername()) && !userName.equals("etton")) {
return Result.error("该用户无权限,请联系管理员");
}
//用户登录信息
@@ -1,6 +1,7 @@
package com.jero.modules.docking.srms.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jero.common.api.vo.Result;
@@ -168,23 +169,28 @@ public class SrmsApiController {
return srmsApiService.syncPartStandard();
}
// @ApiOperation("E采通获取标准信息")
@ApiOperation("E采通获取标准信息")
@AutoLog(value = "E采通获取标准信息")
@PostMapping("/getEStandardInfo")
public JSONObject getEStandardInfo(@RequestBody JSONObject json, HttpServletRequest req){
public JSONObject getEStandardInfo(@RequestBody JSONObject json, HttpServletRequest req) {
JSONObject messageHandler = JSON.parseObject(JSON.toJSONString(json.get(MESSAGE_HEADER)));
String uuid = messageHandler.get("UUID").toString();
try {
// todo
Result<List<JSONObject>> re = srmsApiService.getEStandardInfo(json,req);
if(!re.isSuccess()){
return ResponsesUtil.getJsonResult(json.get(MESSAGE_HEADER),ResponsesUtil.getJsonErrUpper(re.getMessage(),re.getCode()));
}
JSONObject jsonPage = new JSONObject();
Result<JSONArray> re = srmsApiService.getEStandardInfo(json, req);
JSONArray rows = re.getResult();
JSONObject resultJson = new JSONObject();
resultJson.put("MessageHeader", srmsApiService.getMessageHandler("CNHTC_PO1000402", uuid, "SCM"));
JSONObject jsonResponses = ResponsesUtil.getJsonOkUpper();
jsonResponses.put(RESULT,jsonPage);
return ResponsesUtil.getJsonResult(json.get(MESSAGE_HEADER),jsonResponses);
}catch (Exception e){
log.error("E采通获取标准信息异常:",e);
return ResponsesUtil.getJsonResult(json.get(MESSAGE_HEADER),ResponsesUtil.getJsonErrUpper("操作失败",CommonConstant.SC_INTERNAL_SERVER_ERROR_500));
if (!Objects.isNull(rows)) {
jsonResponses.put("Rows", rows);
}
resultJson.put("Responses", jsonResponses);
return resultJson;
} catch (Exception e) {
log.error("E采通获取标准信息异常:", e);
return ResponsesUtil.getJsonResult(
srmsApiService.getMessageHandler("interface_id", uuid, "SCM"),
ResponsesUtil.getJsonErrUpper("操作失败", CommonConstant.SC_INTERNAL_SERVER_ERROR_500));
}
}
@@ -196,7 +202,7 @@ public class SrmsApiController {
try {
List<JSONObject> rows = srmsApiService.getBindPartStandardInfo(json);
JSONObject resultJson = new JSONObject();
resultJson.put("MessageHeader", srmsApiService.getMessageHandler("CNHTC_PO1000496", uuid));
resultJson.put("MessageHeader", srmsApiService.getMessageHandler("CNHTC_PO1000496", uuid, "PDM"));
JSONObject jsonResponses = ResponsesUtil.getJsonOkUpper();
if (!Objects.isNull(rows)) {
jsonResponses.put("Rows", rows);
@@ -206,7 +212,7 @@ public class SrmsApiController {
} catch (Exception e) {
log.error("PDM获取零部件号绑定的法规数据信息异常:", e);
return ResponsesUtil.getJsonResult(
srmsApiService.getMessageHandler("interface_id", uuid),
srmsApiService.getMessageHandler("interface_id", uuid, "PDM"),
ResponsesUtil.getJsonErrUpper("操作失败", CommonConstant.SC_INTERNAL_SERVER_ERROR_500));
}
}
@@ -1,12 +1,12 @@
package com.jero.modules.docking.srms.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jero.common.api.vo.Result;
import com.jero.modules.docking.srms.vo.ByFileRows;
import com.jero.modules.docking.srms.vo.StandardPageVO;
import com.jero.modules.docking.srms.vo.StandardTree;
import com.jero.modules.docking.bindPart.entity.LawsBindPart;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@@ -102,31 +102,14 @@ public interface SrmsApiService {
* @param req
* @return com.jero.common.api.vo.Result<java.util.List<com.alibaba.fastjson.JSONObject>>
*/
Result<List<JSONObject>> getEStandardInfo(JSONObject json, HttpServletRequest req);
Result<JSONArray> getEStandardInfo(JSONObject json, HttpServletRequest req);
/**
* 获取固定的MessageHandler
* @param interfaceId
* @return com.jero.common.api.vo.Result<java.util.List<com.alibaba.fastjson.JSONObject>>
*/
JSONObject getMessageHandler(String interfaceId, String uuid);
/**
* PDM验证零部件号是否可修改
*
* @return com.jero.common.api.vo.Result<java.util.List < com.alibaba.fastjson.JSONObject>>
* @author CHH
* @date 2024/4/28 15:08
*/
void validPartNoEdit(String partNo, String partName, String bindUserInfo);
/**
* PDM校验某个零部件是否所属于某个零部件分类
* @author CHH
* @date 2024/4/28 15:08
* @return com.jero.common.api.vo.Result<java.util.List<com.alibaba.fastjson.JSONObject>>
*/
boolean validPartBelong(String partNo, String partName, String partCategoryNum);
JSONObject getMessageHandler(String interfaceId, String uuid, String receiver);
/**
* 获取零部件号绑定的法规数据
@@ -136,5 +119,4 @@ public interface SrmsApiService {
* @return com.jero.common.api.vo.Result<java.util.List<com.alibaba.fastjson.JSONObject>>
*/
List<JSONObject> getBindPartStandardInfo(JSONObject json);
}
@@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.base.CaseFormat;
import com.jero.common.api.CommonAPI;
import com.jero.common.api.vo.Result;
import com.jero.common.exception.JeroBootException;
import com.jero.common.system.api.ISysBaseAPI;
@@ -18,6 +19,7 @@ import com.jero.common.system.vo.LoginUser;
import com.jero.common.util.MD5Util;
import com.jero.common.util.RedisUtil;
import com.jero.common.util.TokenUtils;
import com.jero.modules.bindPart.entity.BindPartStandardVO;
import com.jero.modules.docking.srms.dto.ByTokenRequests;
import com.jero.modules.docking.srms.dto.ProductDesign;
import com.jero.modules.docking.srms.entity.LawsPartStandard;
@@ -27,10 +29,11 @@ import com.jero.modules.docking.srms.service.ILawsPartStandardService;
import com.jero.modules.docking.srms.service.ILawsSysApiInfoService;
import com.jero.modules.docking.srms.service.SrmsApiService;
import com.jero.modules.docking.srms.vo.*;
import com.jero.modules.docking.bindPart.entity.LawsBindPart;
import com.jero.modules.docking.bindPart.service.ILawsBindPartService;
import com.jero.modules.bindPart.entity.LawsBindPart;
import com.jero.modules.bindPart.service.ILawsBindPartService;
import com.jero.modules.laws.documenttool.entity.LawsDocumentSplit;
import com.jero.modules.laws.documenttool.mapper.LawsDocumentSplitMapper;
import com.jero.modules.laws.documenttool.service.IDocumentSplitService;
import com.jero.modules.laws.enterprise.entity.vo.LawsTreeNodeModel;
import com.jero.modules.laws.standard.entity.LawsDomesticStandard;
import com.jero.modules.laws.standard.entity.LawsEnterpriseStandard;
@@ -44,13 +47,14 @@ import com.jero.modules.split.entity.SarFileSplitMenuEO;
import com.jero.modules.split.page.SarFileSplitMenuEOPage;
import com.jero.modules.split.service.ISarFileSplitInfoService;
import com.jero.modules.split.service.ISarFileSplitMenuEOService;
import com.jero.modules.sys.utils.UserUtils;
import com.jero.modules.system.service.ILoginService;
import com.jero.modules.tag.enums.TableNameEnum;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.jetbrains.annotations.NotNull;
import org.apache.shiro.authc.AuthenticationException;
import org.jetbrains.annotations.Nullable;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
@@ -62,7 +66,6 @@ import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
@@ -104,18 +107,18 @@ public class SrmsApiServiceImpl implements SrmsApiService {
private ILawsPartStandardService lawsPartStandardService;
@Resource
private RestTemplate restTemplate;
@Resource
private ILawsBindPartService lawsBindPartService;
@Resource
private ILawsEnterpriseStandardService esService;
@Resource
private ILawsDomesticStandardService gbService;
@Resource
private ILawsOverseasStandardService fbService;
@Resource
private IDocumentSplitService documentSplitService;
@Resource
private CommonAPI commonAPI;
@Value("${srms.font_url_pdf}")
private String fontUrlPdf;
@@ -133,24 +136,14 @@ public class SrmsApiServiceImpl implements SrmsApiService {
private String ettonSysUser;
@Value("${srms.part_standard_url}")
private String partStandardRewriteUrl;
@Value("${bindPart.pdm_Ip}")
private String pdmIp;
@Value("${bindPart.edit_valid_url}")
private String editValidUrl;
@Value("${bindPart.part_belong_url}")
private String partBelongUrl;
private String poIp;
@Value("${bindPart.auth_username}")
private String authUsername;
@Value("${bindPart.auth_password}")
private String authPassword;
private static final String REQUESTS = "Requests";
private static final String MESSAGE_HANDLER = "MessageHeader";
private static final String SYS_ERR = "访问受限,token授权过期";
private static final String STANDARD_NAME = "standardName";
@@ -723,7 +716,7 @@ public class SrmsApiServiceImpl implements SrmsApiService {
List<LawsPartStandard> list = listOfChunks.get(i);
// 判断数据量是否大于指定大小
JSONObject all = new JSONObject();
all.put(MESSAGE_HANDLER, getMessageHandler("CNHTC_PO1000400", null));
all.put(MESSAGE_HANDLER, getMessageHandler("CNHTC_PO1000400", null, "PDM"));
JSONObject requests = new JSONObject();
// 批次信息
requests.put("BatchId", batchId);
@@ -749,9 +742,9 @@ public class SrmsApiServiceImpl implements SrmsApiService {
HttpEntity<String> entity = new HttpEntity<>(all.toString(), headers);
// 打印完整的请求报文信息
log.info("零部件分类回写相关信息");
log.info("IP: " + pdmIp + partStandardRewriteUrl);
log.info("IP: " + poIp + partStandardRewriteUrl);
log.info("Headers: " + headers);
JSONObject reData = restTemplate.postForObject(pdmIp + partStandardRewriteUrl, entity, JSONObject.class);
JSONObject reData = restTemplate.postForObject(poIp + partStandardRewriteUrl, entity, JSONObject.class);
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
@@ -763,7 +756,8 @@ public class SrmsApiServiceImpl implements SrmsApiService {
}
@Override
public Result<List<JSONObject>> getEStandardInfo(JSONObject json, HttpServletRequest req) {
public Result<JSONArray> getEStandardInfo(JSONObject json, HttpServletRequest req) {
String token = TokenUtils.getTokenByRequest(req);
// 验证token
try {
// 验证Token有效性
@@ -779,27 +773,187 @@ public class SrmsApiServiceImpl implements SrmsApiService {
if (CollectionUtils.isEmpty(rows)) {
return Result.error(ADD_NOT_NULL);
}
List<String> partNumList = new ArrayList<>();
for (Object request : rows) {
JSONObject js = JSON.parseObject(JSON.toJSONString(request));
if (js.containsKey("PartNum") && StringUtils.isBlank(js.getString("PartNum"))) {
return Result.error(ADD_NOT_NULL);
}
partNumList.add(js.getString("PartNum"));
}
// 根据所有零部件分类码获取相关联的标准
LambdaQueryWrapper<LawsPartStandard> partStandardQueryWrapper = new LambdaQueryWrapper<>();
partStandardQueryWrapper.in(LawsPartStandard::getPartCategoryNum, partNumList);
List<LawsPartStandard> partStandardList = lawsPartStandardService.list(partStandardQueryWrapper);
Set<String> standardIdSet = partStandardList.stream().map(LawsPartStandard::getStandardId).collect(Collectors.toSet());
// 获取所有可选的标准
List<BindPartStandardVO> allStandardInfoList = this.getAllStandardInfo();
// 筛选出需要的标准数据后填充剩余字段
allStandardInfoList = allStandardInfoList.stream()
.filter(e -> standardIdSet.contains(e.getId()))
.collect(Collectors.toList());
// 填充字段
this.fillColumn(allStandardInfoList, token);
// 转换为Map
Map<String, BindPartStandardVO> allStandardInfoMap = allStandardInfoList.stream()
.filter(e -> standardIdSet.contains(e.getId()))
.collect(Collectors.toMap(BindPartStandardVO::getId, e -> e));
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
try {
List<JSONObject> listObj = new ArrayList<>();
for (Object request : rows) {
// todo
JSONArray resultRows = new JSONArray();
Map<String, Object> parameter = new HashMap<>();
parameter.put("pageNo", "1");
parameter.put("pageSize", String.valueOf(Integer.MAX_VALUE));
for (String standardId : standardIdSet) {
// 获取标准相关信息
BindPartStandardVO standard = allStandardInfoMap.get(standardId);
// 判断是否有拆分信息
String infoId = standard.getInfoId();
boolean isSplit = StrUtil.isNotBlank(infoId);
// 根据info_id 获取所有拆分数据 后按照拆分数据条数填充rows
if (isSplit) {
parameter.put("info_id", infoId);
IPage<Map<String, Object>> data = documentSplitService.queryDocumentSplitDetail(parameter, false);
List<Map<String, Object>> records = data.getRecords();
for (Map<String, Object> r : records) {
JSONObject row = new JSONObject();
row.put("standardNumber", standard.getStandardNumber());
row.put("standardName", standard.getStandardName());
row.put("standardState_dictText", standard.getStandardState());
row.put("standardUrl", standard.getStandardUrl());
row.put("CreateTime", format.format(standard.getCreateTime()));
row.put("UpdateTime", format.format(standard.getUpdateTime()));
row.put("ReleaseDate", format.format(standard.getReleaseDate()));
row.put("ImplementationDate", format.format(standard.getImplementationDate()));
row.put("Remark1", "");
row.put("Remark2", "");
row.put("Remark3", "");
JSONObject documentSplitDetail = new JSONObject();
documentSplitDetail.put("id", r.get("id"));
documentSplitDetail.put("itemNum", r.get("item_num"));
documentSplitDetail.put("itemTitle", r.get("item_title"));
documentSplitDetail.put("itemContent", r.get("item_content"));
documentSplitDetail.put("Remark1", "");
documentSplitDetail.put("Remark2", "");
documentSplitDetail.put("Remark3", "");
row.put("documentSplitDetail", documentSplitDetail);
resultRows.add(row);
}
} else {
// 只填充一条数据
JSONObject row = new JSONObject();
row.put("standardNumber", standard.getStandardNumber());
row.put("standardName", standard.getStandardName());
row.put("standardState_dictText", standard.getStandardState());
row.put("standardUrl", standard.getStandardUrl());
row.put("CreateTime", format.format(standard.getCreateTime()));
row.put("UpdateTime", format.format(standard.getUpdateTime()));
row.put("ReleaseDate", format.format(standard.getReleaseDate()));
row.put("ImplementationDate", format.format(standard.getImplementationDate()));
row.put("Remark1", "");
row.put("Remark2", "");
row.put("Remark3", "");
resultRows.add(row);
}
}
return Result.OK(listObj);
return Result.OK(resultRows);
} catch (Exception e) {
log.error("设计导航-产品设计条款查询异常:", e);
log.error("E采通获取标准信息失败:", e);
return Result.error("操作失败" + e.getMessage());
}
}
private void fillColumn(List<BindPartStandardVO> allStandardInfoList, String token) {
if (CollectionUtils.isEmpty(allStandardInfoList)) {
return;
}
// 获取所有标准id 找到各自的ossFile文件
List<String> standardIdList = allStandardInfoList.stream().map(BindPartStandardVO::getId).collect(Collectors.toList());
LambdaQueryWrapper<OSSFile> ossFileLambdaQueryWrapper = new LambdaQueryWrapper<>();
ossFileLambdaQueryWrapper.in(OSSFile::getStandardId, standardIdList);
ossFileLambdaQueryWrapper.in(OSSFile::getStandardFileType, PUBLISH_OF_ORIGINAL);
List<OSSFile> ossFileList = ossFileService.list(ossFileLambdaQueryWrapper);
Map<String, List<OSSFile>> ossFileMap = new HashMap<>();
if (CollectionUtils.isNotEmpty(ossFileList)) {
ossFileMap = ossFileList.stream().collect(Collectors.groupingBy(OSSFile::getStandardId));
}
for (BindPartStandardVO standard : allStandardInfoList) {
String code = standard.getStandardType()
.equals(TableNameEnum.ENTERPRISE_STANDARDS.getValue()) ? "es_status" : "standard_state";
// 填充预览地址
standard.setStandardUrl(this.getStandardUrl(standard, ossFileMap, token));
// 填充标准状态
standard.setStandardState(commonAPI.translateDict(code, standard.getStandardState()));
}
}
/**
* 根据标准相关信息获取默认预览链接
* @param standard 标准信息
* @param ossFileMap 相关文件
* @param token token
* @return
*/
private String getStandardUrl(BindPartStandardVO standard, Map<String, List<OSSFile>> ossFileMap, String token) {
String type = standard.getStandardType();
OSSFile finalOssFile = null;
List<OSSFile> ossFileList = ossFileMap.get(standard.getId());
if (CollectionUtils.isEmpty(ossFileList)) {
return null;
}
// 如果是国标外标 则找最新的pdf进行预览
if (TableNameEnum.DOMESTIC_REGULATIONS.getValue().equals(type) ||
TableNameEnum.FOREIGN_REGULATIONS.getValue().equals(type)) {
ossFileList = ossFileList.stream()
.filter(o -> o.getUrl().endsWith(".pdf"))
.sorted(Comparator.comparing(OSSFile::getId).reversed())
.collect(Collectors.toList());
finalOssFile = ossFileList.get(0);
return this.getUrl(finalOssFile, token);
} else if (TableNameEnum.ENTERPRISE_STANDARDS.getValue().equals(type)) {
// 如果是企标则找docx和pdf中最新的
ossFileList = ossFileList.stream()
.filter(o -> o.getUrl().endsWith(".pdf") || o.getUrl().endsWith(".docx"))
.sorted(Comparator.comparing(OSSFile::getId).reversed())
.collect(Collectors.toList());
finalOssFile = ossFileList.get(0);
// 如果是docx则需要查找是否有绑定的pdf
if (finalOssFile.getUrl().endsWith(".docx")) {
LambdaQueryWrapper<OSSFile> bindWrapper = new LambdaQueryWrapper<>();
bindWrapper.eq(OSSFile::getBindId, finalOssFile.getId());
List<OSSFile> list = ossFileService.list(bindWrapper);
if (CollectionUtils.isNotEmpty(list)) {
finalOssFile = list.get(0);
}
}
return this.getUrl(finalOssFile, token);
}
return "";
}
private List<BindPartStandardVO> getAllStandardInfo() {
List<BindPartStandardVO> result = new ArrayList<>();
BindPartStandardVO vo = new BindPartStandardVO();
// 国标
vo.setStandardType(TableNameEnum.DOMESTIC_REGULATIONS.getValue());
List<BindPartStandardVO> gbRecords = lawsBindPartService.selectStandard(vo, 1, Integer.MAX_VALUE).getRecords();
result.addAll(gbRecords);
// 外标
vo.setStandardType(TableNameEnum.FOREIGN_REGULATIONS.getValue());
List<BindPartStandardVO> fbRecords = lawsBindPartService.selectStandard(vo, 1, Integer.MAX_VALUE).getRecords();
result.addAll(fbRecords);
// 企标
vo.setStandardType(TableNameEnum.ENTERPRISE_STANDARDS.getValue());
List<BindPartStandardVO> esRecords = lawsBindPartService.selectStandard(vo, 1, Integer.MAX_VALUE).getRecords();
result.addAll(esRecords);
return result;
}
@Override
public JSONObject getMessageHandler(String interfaceId, String uuid) {
public JSONObject getMessageHandler(String interfaceId, String uuid, String receiver) {
if (StrUtil.isBlank(uuid)) {
uuid = UUID.randomUUID().toString();
}
@@ -809,7 +963,7 @@ public class SrmsApiServiceImpl implements SrmsApiService {
messageHeader.put("UUID", uuid);
messageHeader.put("MessageId", "");
messageHeader.put("Sender", "SRMS");
messageHeader.put("Receiver", "PDM");
messageHeader.put("Receiver", receiver);
messageHeader.put("SendDate", date.substring(0, 8));
messageHeader.put("SendTime", date.substring(8));
return messageHeader;
@@ -827,107 +981,6 @@ public class SrmsApiServiceImpl implements SrmsApiService {
return headers;
}
@Override
public void validPartNoEdit(@NotNull String partNo, String partName, @NotNull String bindUserInfo) {
JSONObject all = new JSONObject();
all.put(MESSAGE_HANDLER, getMessageHandler("CNHTC_PO1000495", null));
JSONObject requests = new JSONObject();
requests.put("PartNum", partNo);
requests.put("PartName", partName);
requests.put("BindUserInfo", bindUserInfo);
requests.put("Remark1", "");
requests.put("Remark2", "");
requests.put("Remark3", "");
all.put(REQUESTS, requests);
// 创建 HttpEntity 包含请求体和头信息
HttpHeaders headers = this.getBasicAuthHeaders();
HttpEntity<String> entity = new HttpEntity<>(all.toString(), headers);
// 打印完整的请求报文信息
log.info("发送验证零部件是否可修改请求");
log.info("IP: " + pdmIp + editValidUrl);
log.info("Headers: " + headers.toString());
log.info("Request body: " + all.toString());
JSONObject reData = restTemplate.postForObject(pdmIp + editValidUrl, entity, JSONObject.class);
log.info("接收验证零部件是否可修改请求返回");
log.info("返回报文: " + JSON.toJSONString(reData));
JSONObject response = null;
if (!Objects.isNull(reData) && reData.containsKey("Responses")) {
response = reData.getJSONObject("Responses");
}
if (!Objects.isNull(response) && response.containsKey("Success")) {
String success = response.getString("Success");
String message = "";
if (response.containsKey("Message")) {
message = response.getString("Message");
}
if ("true".equals(success)) {
log.info("验证零部件号是否可修改接口成功");
return;
}
if ("false".equals(success)) {
log.error("验证零部件号是否可修改接口失败");
log.error("验证零部件号是否可修改接口失败原因: " + message);
throw new JeroBootException(message);
}
}
throw new JeroBootException("零部件号" + partNo + "不可新增");
}
@Override
public boolean validPartBelong(String partNo, String partName, String partCategoryNum) {
try {
JSONObject all = new JSONObject();
all.put(MESSAGE_HANDLER, getMessageHandler("CNHTC_PO1000497", null));
JSONObject requests = new JSONObject();
requests.put("PartNum", partNo);
requests.put("PartName", partName);
requests.put("PartCategoryNum", partCategoryNum);
requests.put("PartCategoryName", "");
requests.put("Remark1", "");
requests.put("Remark2", "");
requests.put("Remark3", "");
all.put(REQUESTS, requests);
// 创建 HttpEntity 包含请求体和头信息
HttpHeaders headers = this.getBasicAuthHeaders();
HttpEntity<String> entity = new HttpEntity<>(all.toString(), headers);
// 打印完整的请求报文信息
log.info("发送校验某个零部件是否属于某个零部件分类请求");
log.info("IP: " + pdmIp + editValidUrl);
log.info("Headers: " + headers.toString());
log.info("Request body: " + all.toString());
JSONObject reData = restTemplate.postForObject(pdmIp + partBelongUrl, entity, JSONObject.class);
log.info("接收校验某个零部件是否属于某个零部件分类返回");
log.info("返回报文: " + JSON.toJSONString(reData));
JSONObject response = null;
if (!Objects.isNull(reData) && reData.containsKey("Responses")) {
response = reData.getJSONObject("Responses");
}
if (!Objects.isNull(response) && response.containsKey("Success")) {
String success = response.getString("Success");
String message = "";
if (response.containsKey("Message")) {
message = response.getString("Message");
}
if ("true".equals(success)) {
log.info("校验某个零部件是否所属于某个零部件分类接口成功");
return true;
}
if ("false".equals(success)) {
log.error("校验某个零部件是否所属于某个零部件分类接口失败");
log.error("失败原因: " + message);
return false;
}
}
} catch (Exception e) {
log.error("校验某个零部件是否所属于某个零部件分类异常", e);
}
return false;
}
@Override
public List<JSONObject> getBindPartStandardInfo(JSONObject json) {
JSONObject requests = JSON.parseObject(JSON.toJSONString(json.get(REQUESTS)));
@@ -12,11 +12,13 @@ import com.jero.modules.activiti.process.esInitChange.entity.enums.ESPApplicatio
import com.jero.modules.activiti.process.esInitChange.entity.enums.ESPChangeType;
import com.jero.modules.activiti.process.esInitChange.entity.enums.ESPProjectType;
import com.jero.modules.activiti.process.esInitChange.service.ProcessEsInitChangeService;
import com.jero.modules.bindPart.docking.DockingService;
import com.jero.modules.laws.enterprise.entity.EnterpriseStandardPlan;
import com.jero.modules.laws.enterprise.service.EnterpriseStandardPlanService;
import com.jero.modules.laws.enterprise.util.BeanCopyUtils;
import com.jero.modules.laws.standard.entity.LawsEnterpriseStandard;
import com.jero.modules.laws.standard.service.ILawsEnterpriseStandardService;
import com.jero.modules.tag.enums.TableNameEnum;
import lombok.extern.slf4j.Slf4j;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.ExecutionListener;
@@ -25,6 +27,8 @@ import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
import static com.jero.modules.bindPart.docking.DockingServiceImpl.STANDARD_ABOLISH;
/**
* @author: Mzaxd
* @Date: 2023/10/10 14:14
@@ -39,6 +43,9 @@ public class ProcessESAbolishEndListener implements ExecutionListener {
@Resource
private ProcessEsAbolishService esAbolishService;
@Resource
private DockingService dockingService;
/**
* 企标废止流程结束之后需要把标准状态设为废止
* @param delegateExecution
@@ -52,10 +59,18 @@ public class ProcessESAbolishEndListener implements ExecutionListener {
abolishLambdaQueryWrapper.eq(ProcessEsAbolish::getProcessInstanceId, processInstanceId);
ProcessEsAbolish abolish = esAbolishService.getOne(abolishLambdaQueryWrapper);
String standNo = abolish.getStandardNumber();
LambdaQueryWrapper<LawsEnterpriseStandard> esWrapper = new LambdaQueryWrapper<>();
esWrapper.eq(LawsEnterpriseStandard::getStandardNumber, standNo);
LawsEnterpriseStandard one = esService.getOne(esWrapper);
log.info("企标废止流程监听执行器开始执行,企标编号为:{}", standNo);
esService.update(new LambdaUpdateWrapper<LawsEnterpriseStandard>()
.set(LawsEnterpriseStandard::getStandardState, StandardStateEnum.ABOLISH.getStateValue())
.eq(LawsEnterpriseStandard::getStandardNumber, standNo));
try {
dockingService.sendStandardChangeToSCM(one.getId(), TableNameEnum.ENTERPRISE_STANDARDS.getValue(), STANDARD_ABOLISH, null);
} catch (Exception e) {
log.error("E采通同步标准信息出错", e);
}
log.info("企标废止流程结束监听执行器执行结束");
}
}
@@ -1,4 +1,4 @@
package com.jero.modules.docking.bindPart.controller;
package com.jero.modules.bindPart.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jero.common.api.vo.Result;
@@ -6,9 +6,9 @@ import com.jero.common.api.vo.ResultCommon;
import com.jero.common.aspect.annotation.AutoLog;
import com.jero.common.exception.JeroBootException;
import com.jero.common.util.MessageUtils;
import com.jero.modules.docking.bindPart.entity.BindPartStandardVO;
import com.jero.modules.docking.bindPart.entity.LawsBindPart;
import com.jero.modules.docking.bindPart.service.ILawsBindPartService;
import com.jero.modules.bindPart.entity.BindPartStandardVO;
import com.jero.modules.bindPart.entity.LawsBindPart;
import com.jero.modules.bindPart.service.ILawsBindPartService;
import com.jero.modules.laws.documenttool.service.IDocumentSplitService;
import com.jero.modules.split.entity.SarFileSplitMenuEO;
import com.jero.modules.split.page.SarFileSplitMenuEOPage;
@@ -0,0 +1,30 @@
package com.jero.modules.bindPart.docking;
public interface DockingService {
/**
* PDM验证零部件号是否可修改
*
* @return com.jero.common.api.vo.Result<java.util.List < com.alibaba.fastjson.JSONObject>>
* @author CHH
* @date 2024/4/28 15:08
*/
void validPartNoEdit(String partNo, String partName, String bindUserInfo);
/**
* PDM校验某个零部件是否所属于某个零部件分类
* @author CHH
* @date 2024/4/28 15:08
* @return com.jero.common.api.vo.Result<java.util.List<com.alibaba.fastjson.JSONObject>>
*/
boolean validPartBelong(String partNo, String partName, String partCategoryNum);
/**
* E采通接收消息接口
* @author CHH
* @date 2024/5/20 15:08
* @return com.jero.common.api.vo.Result<java.util.List<com.alibaba.fastjson.JSONObject>>
*/
void sendStandardChangeToSCM(String standardId, String standardType, String operateType, String bindPartId);
}
@@ -0,0 +1,280 @@
package com.jero.modules.bindPart.docking;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jero.common.exception.JeroBootException;
import com.jero.modules.bindPart.entity.LawsBindPart;
import com.jero.modules.bindPart.service.ILawsBindPartService;
import com.jero.modules.laws.standard.entity.LawsDomesticStandard;
import com.jero.modules.laws.standard.entity.LawsEnterpriseStandard;
import com.jero.modules.laws.standard.entity.LawsOverseasStandard;
import com.jero.modules.laws.standard.service.ILawsDomesticStandardService;
import com.jero.modules.laws.standard.service.ILawsEnterpriseStandardService;
import com.jero.modules.laws.standard.service.ILawsOverseasStandardService;
import com.jero.modules.tag.enums.TableNameEnum;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.*;
@Slf4j
@Service
public class DockingServiceImpl implements DockingService{
@Resource
private RestTemplate restTemplate;
@Resource
private ILawsBindPartService lawsBindPartService;
@Resource
private ILawsEnterpriseStandardService esService;
@Resource
private ILawsDomesticStandardService gbService;
@Resource
private ILawsOverseasStandardService fbService;
@Value("${bindPart.pdm_Ip}")
private String poIp;
@Value("${bindPart.edit_valid_url}")
private String editValidUrl;
@Value("${bindPart.part_belong_url}")
private String partBelongUrl;
@Value("${srms.etton_message_url}")
private String etton_message_url;
@Value("${bindPart.auth_username}")
private String authUsername;
@Value("${bindPart.auth_password}")
private String authPassword;
private static final String REQUESTS = "Requests";
private static final String MESSAGE_HANDLER = "MessageHeader";
private static final String STANDARD_NUMBER = "standardNumber";
private static final String STANDARD_NAME = "standardName";
public static final String BIND_RELATION_CHANGE = "1";
public static final String STANDARD_EDIT = "2";
public static final String STANDARD_ABOLISH = "3";
@Override
public void validPartNoEdit(@NotNull String partNo, String partName, @NotNull String bindUserInfo) {
JSONObject all = new JSONObject();
all.put(MESSAGE_HANDLER, getMessageHandler("CNHTC_PO1000495", null, "PDM"));
JSONObject requests = new JSONObject();
requests.put("PartNum", partNo);
requests.put("PartName", partName);
requests.put("BindUserInfo", bindUserInfo);
requests.put("Remark1", "");
requests.put("Remark2", "");
requests.put("Remark3", "");
all.put(REQUESTS, requests);
// 创建 HttpEntity 包含请求体和头信息
HttpHeaders headers = this.getBasicAuthHeaders();
HttpEntity<String> entity = new HttpEntity<>(all.toString(), headers);
// 打印完整的请求报文信息
log.info("发送验证零部件是否可修改请求");
log.info("IP: " + poIp + editValidUrl);
log.info("Headers: " + headers);
log.info("Request body: " + all);
JSONObject reData = restTemplate.postForObject(poIp + editValidUrl, entity, JSONObject.class);
log.info("接收验证零部件是否可修改请求返回");
log.info("返回报文: " + JSON.toJSONString(reData));
JSONObject response = null;
if (!Objects.isNull(reData) && reData.containsKey("Responses")) {
response = reData.getJSONObject("Responses");
}
if (!Objects.isNull(response) && response.containsKey("Success")) {
String success = response.getString("Success");
String message = "";
if (response.containsKey("Message")) {
message = response.getString("Message");
}
if ("true".equals(success)) {
log.info("验证零部件号是否可修改接口成功");
return;
}
if ("false".equals(success)) {
log.error("验证零部件号是否可修改接口失败");
log.error("验证零部件号是否可修改接口失败原因: " + message);
throw new JeroBootException(message);
}
}
throw new JeroBootException("零部件号" + partNo + "不可新增");
}
@Override
public boolean validPartBelong(String partNo, String partName, String partCategoryNum) {
try {
JSONObject all = new JSONObject();
all.put(MESSAGE_HANDLER, getMessageHandler("CNHTC_PO1000497", null, "PDM"));
JSONObject requests = new JSONObject();
requests.put("PartNum", partNo);
requests.put("PartName", partName);
requests.put("PartCategoryNum", partCategoryNum);
requests.put("PartCategoryName", "");
requests.put("Remark1", "");
requests.put("Remark2", "");
requests.put("Remark3", "");
all.put(REQUESTS, requests);
// 创建 HttpEntity 包含请求体和头信息
HttpHeaders headers = this.getBasicAuthHeaders();
HttpEntity<String> entity = new HttpEntity<>(all.toString(), headers);
// 打印完整的请求报文信息
log.info("发送校验某个零部件是否属于某个零部件分类请求");
log.info("IP: " + poIp + editValidUrl);
log.info("Headers: " + headers);
log.info("Request body: " + all);
JSONObject reData = restTemplate.postForObject(poIp + partBelongUrl, entity, JSONObject.class);
log.info("接收校验某个零部件是否属于某个零部件分类返回");
log.info("返回报文: " + JSON.toJSONString(reData));
JSONObject response = null;
if (!Objects.isNull(reData) && reData.containsKey("Responses")) {
response = reData.getJSONObject("Responses");
}
if (!Objects.isNull(response) && response.containsKey("Success")) {
String success = response.getString("Success");
String message = "";
if (response.containsKey("Message")) {
message = response.getString("Message");
}
if ("true".equals(success)) {
log.info("校验某个零部件是否所属于某个零部件分类接口成功");
return true;
}
if ("false".equals(success)) {
log.error("校验某个零部件是否所属于某个零部件分类接口失败");
log.error("失败原因: " + message);
return false;
}
}
} catch (Exception e) {
log.error("校验某个零部件是否所属于某个零部件分类异常", e);
}
return false;
}
@Override
public void sendStandardChangeToSCM(String standardId, String standardType, String operateType, String bindPartId) {
LawsBindPart lawsBindPart = null;
if (BIND_RELATION_CHANGE.equals(operateType)) {
lawsBindPart = lawsBindPartService.getById(bindPartId);
standardId = lawsBindPart.getStandardId();
} else if (STANDARD_EDIT.equals(operateType) || STANDARD_ABOLISH.equals(operateType)) {
LambdaQueryWrapper<LawsBindPart> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(LawsBindPart::getStandardId, standardId);
List<LawsBindPart> list = lawsBindPartService.list(lambdaQueryWrapper);
if (CollectionUtils.isEmpty(list)) {
log.info("没有标准Id为{}的零部件绑定关系,不向E采通发送消息", standardId);
return;
}
lawsBindPart = list.get(0);
} else {
throw new JeroBootException("E采通接收消息接口失败,参数不正确,未发送");
}
// 根据操作类型和标准id 填充标准编号和标准名称字段
if (standardType == null || TableNameEnum.DOMESTIC_REGULATIONS.getValue().equals(standardType)) {
LawsDomesticStandard gb = gbService.getById(standardId);
if (gb != null) {
standardType = TableNameEnum.DOMESTIC_REGULATIONS.getValue();
lawsBindPart.setStandardNo(gb.getStandardNumber());
lawsBindPart.setStandardName(gb.getStandardName());
}
}
if (standardType == null || TableNameEnum.FOREIGN_REGULATIONS.getValue().equals(standardType)) {
LawsOverseasStandard fb = fbService.getById(standardId);
if (fb != null) {
standardType = TableNameEnum.FOREIGN_REGULATIONS.getValue();
lawsBindPart.setStandardNo(fb.getStandardNumber());
lawsBindPart.setStandardName(fb.getStandardName());
}
}
if (standardType == null || TableNameEnum.ENTERPRISE_STANDARDS.getValue().equals(standardType)) {
LawsEnterpriseStandard es = esService.getById(standardId);
if (es != null) {
standardType = TableNameEnum.ENTERPRISE_STANDARDS.getValue();
lawsBindPart.setStandardNo(es.getStandardNumber());
lawsBindPart.setStandardName(es.getStandardName());
}
}
try {
JSONObject all = new JSONObject();
all.put(MESSAGE_HANDLER, getMessageHandler("CNHTC_PO1000401", null, "SCM"));
JSONObject requests = new JSONObject();
requests.put("partNum", lawsBindPart.getPartNo());
requests.put("partName", lawsBindPart.getPartName());
requests.put(STANDARD_NUMBER, lawsBindPart.getStandardNo());
requests.put(STANDARD_NAME, lawsBindPart.getStandardName());
requests.put("type", Integer.valueOf(operateType));
all.put(REQUESTS, requests);
// 创建 HttpEntity 包含请求体和头信息
HttpHeaders headers = this.getBasicAuthHeaders();
HttpEntity<String> entity = new HttpEntity<>(all.toString(), headers);
// 打印完整的请求报文信息
log.info("发送E采通接收消息请求");
log.info("IP: " + poIp + etton_message_url);
log.info("Headers: " + headers);
log.info("Request body: " + all);
JSONObject reData = restTemplate.postForObject(poIp + etton_message_url, entity, JSONObject.class);
log.info("接收E采通接收消息接口返回");
log.info("返回报文: " + JSON.toJSONString(reData));
JSONObject response = null;
if (!Objects.isNull(reData) && reData.containsKey("Responses")) {
response = reData.getJSONObject("Responses");
}
if (!Objects.isNull(response) && response.containsKey("success")) {
String success = response.getString("success");
if ("true".equals(success)) {
log.info("E采通接收消息接口成功");
}
if ("false".equals(success)) {
log.error("E采通接收消息接口失败");
}
}
} catch (Exception e) {
log.error("E采通接收消息接口异常", e);
}
}
// 创建 HttpHeaders 并设置 Basic Auth
private HttpHeaders getBasicAuthHeaders() {
// 创建 HttpHeaders 并设置 Basic Auth
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
String auth = authUsername + ":" + authPassword; // 用户名:密码
byte[] encodedAuth = Base64.getEncoder().encode(auth.getBytes(StandardCharsets.US_ASCII));
String authHeader = "Basic " + new String(encodedAuth);
headers.set("Authorization", authHeader);
return headers;
}
public JSONObject getMessageHandler(String interfaceId, String uuid, String receiver) {
if (StrUtil.isBlank(uuid)) {
uuid = UUID.randomUUID().toString();
}
JSONObject messageHeader = new JSONObject();
String date = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
messageHeader.put("Interface_ID", interfaceId);
messageHeader.put("UUID", uuid);
messageHeader.put("MessageId", "");
messageHeader.put("Sender", "SRMS");
messageHeader.put("Receiver", receiver);
messageHeader.put("SendDate", date.substring(0, 8));
messageHeader.put("SendTime", date.substring(8));
return messageHeader;
}
}
@@ -1,4 +1,4 @@
package com.jero.modules.docking.bindPart.entity;
package com.jero.modules.bindPart.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
@@ -7,6 +7,8 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
@@ -51,19 +53,39 @@ public class BindPartStandardVO implements Serializable {
*/
@ApiModelProperty(value = "发布日期")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
private Date releaseDate;
/**实施日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
@ApiModelProperty(value = "实施日期")
private java.util.Date implementationDate;
/**创建时间*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
@ApiModelProperty(value = "创建时间")
private java.util.Date createTime;
/**更新时间*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
@ApiModelProperty(value = "更新时间")
private java.util.Date updateTime;
/**
* 标准类型1国内2海外3企业
*/
@ApiModelProperty(value = "标准类型(1:国内,2:海外,3:企业)")
@Dict(dicCode = "standard_source")
private String standardType;
/**
* 拆分条款记录Id选择条款用
*/
@ApiModelProperty(value = "拆分条款记录Id(选择条款用)")
private String infoId;
/**
* 预览地址
*/
@ApiModelProperty(value = "预览地址")
private String standardUrl;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
@@ -1,4 +1,4 @@
package com.jero.modules.docking.bindPart.entity;
package com.jero.modules.bindPart.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
@@ -1,4 +1,4 @@
package com.jero.modules.docking.bindPart.entity;
package com.jero.modules.bindPart.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
@@ -0,0 +1,45 @@
package com.jero.modules.bindPart.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class SAMStandardInfo implements Serializable {
/**
* id
*/
@ApiModelProperty(value = "id")
private String id;
/**
* 标准号
*/
@ApiModelProperty(value = "标准号")
private String standardNumber;
/**
* 标准名称
*/
@ApiModelProperty(value = "标准名称")
private String standardName;
/**
* 标准状态
*/
@ApiModelProperty(value = "标准状态")
private String standardState;
/**
* 预览链接
*/
@ApiModelProperty(value = "预览链接")
private String standardUrl;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}
@@ -1,6 +1,6 @@
package com.jero.modules.docking.bindPart.mapper;
package com.jero.modules.bindPart.mapper;
import com.jero.modules.docking.bindPart.entity.LawsBindPartDoc;
import com.jero.modules.bindPart.entity.LawsBindPartDoc;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
@@ -1,7 +1,7 @@
package com.jero.modules.docking.bindPart.mapper;
package com.jero.modules.bindPart.mapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jero.modules.docking.bindPart.entity.LawsBindPart;
import com.jero.modules.bindPart.entity.LawsBindPart;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
@@ -2,9 +2,9 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jero.modules.docking.bindPart.mapper.LawsBindPartDocMapper">
<mapper namespace="com.jero.modules.bindPart.mapper.LawsBindPartDocMapper">
<resultMap id="BaseResultMap" type="com.jero.modules.docking.bindPart.entity.LawsBindPartDoc">
<resultMap id="BaseResultMap" type="com.jero.modules.bindPart.entity.LawsBindPartDoc">
<id property="id" column="id" jdbcType="VARCHAR"/>
<result property="createBy" column="create_by" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jero.modules.docking.bindPart.mapper.LawsBindPartMapper">
<mapper namespace="com.jero.modules.bindPart.mapper.LawsBindPartMapper">
<resultMap id="BaseResultMap" type="com.jero.modules.docking.bindPart.entity.LawsBindPart">
<resultMap id="BaseResultMap" type="com.jero.modules.bindPart.entity.LawsBindPart">
<id property="id" column="id" jdbcType="VARCHAR"/>
<result property="createBy" column="create_by" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
@@ -25,7 +25,7 @@
bind_user,bind_time
</sql>
<select id="page" resultType="com.jero.modules.docking.bindPart.entity.LawsBindPart">
<select id="page" resultType="com.jero.modules.bindPart.entity.LawsBindPart">
SELECT
bp.id,
bp.part_no,
@@ -1,6 +1,6 @@
package com.jero.modules.docking.bindPart.service;
package com.jero.modules.bindPart.service;
import com.jero.modules.docking.bindPart.entity.LawsBindPartDoc;
import com.jero.modules.bindPart.entity.LawsBindPartDoc;
import com.baomidou.mybatisplus.extension.service.IService;
/**
@@ -1,8 +1,8 @@
package com.jero.modules.docking.bindPart.service;
package com.jero.modules.bindPart.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jero.modules.docking.bindPart.entity.BindPartStandardVO;
import com.jero.modules.docking.bindPart.entity.LawsBindPart;
import com.jero.modules.bindPart.entity.BindPartStandardVO;
import com.jero.modules.bindPart.entity.LawsBindPart;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
@@ -1,9 +1,9 @@
package com.jero.modules.docking.bindPart.service.impl;
package com.jero.modules.bindPart.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jero.modules.docking.bindPart.entity.LawsBindPartDoc;
import com.jero.modules.docking.bindPart.mapper.LawsBindPartDocMapper;
import com.jero.modules.docking.bindPart.service.ILawsBindPartDocService;
import com.jero.modules.bindPart.mapper.LawsBindPartDocMapper;
import com.jero.modules.bindPart.entity.LawsBindPartDoc;
import com.jero.modules.bindPart.service.ILawsBindPartDocService;
import org.springframework.stereotype.Service;
/**
@@ -1,4 +1,4 @@
package com.jero.modules.docking.bindPart.service.impl;
package com.jero.modules.bindPart.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
@@ -11,18 +11,17 @@ import com.jero.common.api.vo.SendMessageAPI;
import com.jero.common.exception.JeroBootException;
import com.jero.common.system.vo.LoginUser;
import com.jero.modules.activiti.process.common.enums.StandardStateEnum;
import com.jero.modules.docking.bindPart.entity.BindPartStandardVO;
import com.jero.modules.docking.bindPart.entity.LawsBindPart;
import com.jero.modules.docking.bindPart.entity.LawsBindPartDoc;
import com.jero.modules.docking.bindPart.mapper.LawsBindPartMapper;
import com.jero.modules.docking.bindPart.service.ILawsBindPartDocService;
import com.jero.modules.docking.bindPart.service.ILawsBindPartService;
import com.jero.modules.docking.srms.service.SrmsApiService;
import com.jero.modules.bindPart.docking.DockingService;
import com.jero.modules.bindPart.mapper.LawsBindPartMapper;
import com.jero.modules.bindPart.entity.BindPartStandardVO;
import com.jero.modules.bindPart.entity.LawsBindPart;
import com.jero.modules.bindPart.entity.LawsBindPartDoc;
import com.jero.modules.bindPart.service.ILawsBindPartDocService;
import com.jero.modules.bindPart.service.ILawsBindPartService;
import com.jero.modules.laws.common.constant.MessageTemplateCodeCommon;
import com.jero.modules.laws.documenttool.entity.LawsDocumentSplit;
import com.jero.modules.laws.documenttool.mapper.DocumentSplitMapper;
import com.jero.modules.laws.documenttool.mapper.LawsDocumentSplitMapper;
import com.jero.modules.laws.documenttool.service.IDocumentSplitService;
import com.jero.modules.laws.enterprise.util.BeanCopyUtils;
import com.jero.modules.laws.standard.entity.LawsDomesticStandard;
import com.jero.modules.laws.standard.entity.LawsEnterpriseStandard;
@@ -30,7 +29,6 @@ import com.jero.modules.laws.standard.entity.LawsOverseasStandard;
import com.jero.modules.laws.standard.service.ILawsDomesticStandardService;
import com.jero.modules.laws.standard.service.ILawsEnterpriseStandardService;
import com.jero.modules.laws.standard.service.ILawsOverseasStandardService;
import com.jero.modules.message.handle.ISendMsgHandle;
import com.jero.modules.onlyoffice.entity.StandardFileType;
import com.jero.modules.split.entity.SarFileSplitInfoEO;
import com.jero.modules.split.service.ISarFileSplitInfoService;
@@ -45,6 +43,7 @@ import java.util.*;
import java.util.stream.Collectors;
import static com.jero.common.constant.CommonConstant.HAS_SEND;
import static com.jero.modules.bindPart.docking.DockingServiceImpl.BIND_RELATION_CHANGE;
/**
* @author ThinkBook
@@ -74,7 +73,7 @@ public class LawsBindPartServiceImpl extends ServiceImpl<LawsBindPartMapper, Law
private ILawsEnterpriseStandardService esService;
@Resource
private SrmsApiService srmsApiService;
private DockingService dockingService;
@Resource
private ISysUserService sysUserService;
@@ -96,7 +95,7 @@ public class LawsBindPartServiceImpl extends ServiceImpl<LawsBindPartMapper, Law
public void add(LawsBindPart lawsBindPart) {
// 访问PDM校验该零部件号是否可以修改
try {
srmsApiService.validPartNoEdit(lawsBindPart.getPartNo(),
dockingService.validPartNoEdit(lawsBindPart.getPartNo(),
lawsBindPart.getPartName(),
getBindUsernameAndRealName(lawsBindPart.getBindUser()));
} catch (Exception e) {
@@ -108,6 +107,11 @@ public class LawsBindPartServiceImpl extends ServiceImpl<LawsBindPartMapper, Law
this.saveBindPartDoc(clauseIds, lawsBindPart.getId());
// 发消息
this.sendMessageToBindUser(lawsBindPart);
try {
dockingService.sendStandardChangeToSCM(lawsBindPart.getStandardId(), lawsBindPart.getStandardType(), BIND_RELATION_CHANGE, lawsBindPart.getId());
} catch (Exception e) {
log.error("E采通同步标准信息出错", e);
}
}
private void saveBindPartDoc(String clauseIds, String bindId) {
@@ -146,7 +150,7 @@ public class LawsBindPartServiceImpl extends ServiceImpl<LawsBindPartMapper, Law
for (String id : ids) {
LawsBindPart existBindPart = lawsBindPartMap.get(id);
try {
srmsApiService.validPartNoEdit(existBindPart.getPartNo(),
dockingService.validPartNoEdit(existBindPart.getPartNo(),
existBindPart.getPartName(),
getBindUsernameAndRealName(existBindPart.getBindUser()));
} catch (Exception e) {
@@ -171,6 +175,11 @@ public class LawsBindPartServiceImpl extends ServiceImpl<LawsBindPartMapper, Law
// 保存新关系
String clauseIds = lawsBindPart.getClauseIds();
this.saveBindPartDoc(clauseIds, lawsBindPart.getId());
try {
dockingService.sendStandardChangeToSCM(lawsBindPart.getStandardId(), lawsBindPart.getStandardType(), BIND_RELATION_CHANGE, lawsBindPart.getId());
} catch (Exception e) {
log.error("E采通同步标准信息出错", e);
}
}
private void removeBindPartDoc(String bindIds) {
@@ -187,6 +196,11 @@ public class LawsBindPartServiceImpl extends ServiceImpl<LawsBindPartMapper, Law
public void deleteById(String id) {
// 访问PDM校验该零部件号是否可以修改
this.pdmValidPartEdit(Collections.singletonList(id));
try {
dockingService.sendStandardChangeToSCM(null, null, BIND_RELATION_CHANGE, id);
} catch (Exception e) {
log.error("E采通同步标准信息出错", e);
}
removeById(id);
removeBindPartDoc(id);
}
@@ -195,6 +209,13 @@ public class LawsBindPartServiceImpl extends ServiceImpl<LawsBindPartMapper, Law
public void deleteByIds(List<String> ids) {
// 访问PDM校验该零部件号是否可以修改
this.pdmValidPartEdit(ids);
for (String id : ids) {
try {
dockingService.sendStandardChangeToSCM(null, null, BIND_RELATION_CHANGE, id);
} catch (Exception e) {
log.error("E采通同步标准信息出错", e);
}
}
removeByIds(ids);
removeBindPartDoc(ids.stream().map(String::valueOf).collect(Collectors.joining(",")));
}
@@ -282,6 +303,7 @@ public class LawsBindPartServiceImpl extends ServiceImpl<LawsBindPartMapper, Law
}
if (sarFileSplitInfoEOS.size() == 1) {
standard.setInfoId(sarFileSplitInfoEOS.get(0).getId());
return;
}
// 需要对所有拆分信息按照文件类型排序
sarFileSplitInfoEOS.sort((file1, file2) -> {
@@ -340,7 +362,7 @@ public class LawsBindPartServiceImpl extends ServiceImpl<LawsBindPartMapper, Law
}
for (LawsBindPart existBind : list) {
// 调用PDM判断零部件编号是否在当前的零部件分类下
boolean validPartBelong = srmsApiService.validPartBelong(lawsBindPart.getPartNo(), lawsBindPart.getPartName(), existBind.getPartCategoryNum());
boolean validPartBelong = dockingService.validPartBelong(lawsBindPart.getPartNo(), lawsBindPart.getPartName(), existBind.getPartCategoryNum());
if (validPartBelong) {
return existBind;
}
@@ -22,6 +22,7 @@ import com.jero.common.util.MessageUtils;
import com.jero.common.util.MinioUtil;
import com.jero.modules.activiti.process.common.enums.StandardStateEnum;
import com.jero.modules.activiti.process.fb.service.IProcessFbStandardConsultationService;
import com.jero.modules.bindPart.docking.DockingService;
import com.jero.modules.laws.common.constant.FieldCommon;
import com.jero.modules.laws.common.mapper.LawsCommonMapper;
import com.jero.modules.laws.common.service.ILawsCommonService;
@@ -102,6 +103,9 @@ import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import static com.jero.modules.bindPart.docking.DockingServiceImpl.STANDARD_ABOLISH;
import static com.jero.modules.bindPart.docking.DockingServiceImpl.STANDARD_EDIT;
/**
* @Author: liao
* @Date: 2023/8/23 16:54
@@ -180,6 +184,9 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
@Resource
private ISysDepartService departService;
@Resource
private DockingService dockingService;
public static boolean ENCRYPT_ENABLE;
public static String DECRYPT_URL;
public static String DECRYPT_APP_CODE;
@@ -983,7 +990,29 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
// 同步es数据库
lawsHomeSearchService.updateEsData(module, id, LawsHomeSearchCommon.LAWS_ES_UPDATE);
// 给E采通同步标准变更的信息
try {
boolean isAbolish = false;
if (module.equals(TableNameEnum.DOMESTIC_REGULATIONS.getValue())
|| module.equals(TableNameEnum.FOREIGN_REGULATIONS.getValue())) {
if (standardState.equals(OutStandardStateEnum.ABOLISH.getStateValue())) {
isAbolish = true;
}
}
if (module.equals(TableNameEnum.ENTERPRISE_STANDARDS.getValue())) {
if (standardState.equals(StandardStateEnum.ABOLISH.getStateValue())) {
isAbolish = true;
}
}
// 判断是否是改为废止
if (isAbolish) {
dockingService.sendStandardChangeToSCM(id, module, STANDARD_ABOLISH, null);
} else{
dockingService.sendStandardChangeToSCM(id, module, STANDARD_EDIT, null);
}
} catch (Exception e) {
log.error("E采通同步标准信息出错", e);
}
return ResultCommon.OK;
}
@@ -14,7 +14,10 @@ public enum StandardFileType {
FILE_DRAFT_FOR_REVIEW("报批稿", "draft_for_review", 3), // 报批稿
FILE_DRAFT_FOR_APPROVAL("送审稿", "draft_for_approval", 4), // 送审稿
FILE_DRAFT_FOR_COMMENT("征求意见稿", "draft_for_comment", 5), // 征求意见稿
FILE_DRAFT("草稿", "draft", 6); // 草稿
FILE_DRAFT("草稿", "draft", 6), // 草稿
TEST_PROCEDURES("测试规程", "test_procedures", 7), // 草稿
OTHER_FILES("其他文件", "other_files", 8), // 草稿
INTERPRET_DOCUMENT("解读文件", "interpret_document", 9); // 解读文件
private final String name;
@@ -533,6 +533,8 @@ srms:
etton_sys_user: etton
# 分类树标准法规回写接口 url
part_standard_url: RESTAdapter/PSRMS/PO1000400/RegulatoryBackwriting
# E采通接收消息接口 url
etton_message_url: RESTAdapter/PSRMS/PO1000401/EReceivMessage
# 标准性质 x替换为\d作为正则匹配
standardProperty:
@@ -497,6 +497,8 @@ srms:
etton_sys_user: etton
# 分类树标准法规回写接口 url
part_standard_url: RESTAdapter/PSRMS/PO1000400/RegulatoryBackwriting
# E采通接收消息接口 url
etton_message_url: RESTAdapter/PSRMS/PO1000401/EReceivMessage
# 标准性质 x替换为\d作为正则匹配
standardProperty:
@@ -497,6 +497,8 @@ srms:
etton_sys_user: etton
# 分类树标准法规回写接口 url
part_standard_url: RESTAdapter/PSRMS/PO1000400/RegulatoryBackwriting
# E采通接收消息接口 url
etton_message_url: RESTAdapter/PSRMS/PO1000401/EReceivMessage
# 标准性质 x替换为\d作为正则匹配
standardProperty: