feat: 验证零部件是否可以新增接口使用PDM返回的提示信息

This commit is contained in:
2024-05-07 13:37:50 +08:00
parent 243a4ee8b1
commit fb3a31be9a
4 changed files with 230 additions and 218 deletions
@@ -59,8 +59,10 @@ public class LawsBindPartController {
@AutoLog(value = "绑定零部件-是否显示使用绑定关系") @AutoLog(value = "绑定零部件-是否显示使用绑定关系")
@ApiOperation(value="绑定零部件-是否显示使用绑定关系", notes="绑定零部件-是否显示使用绑定关系") @ApiOperation(value="绑定零部件-是否显示使用绑定关系", notes="绑定零部件-是否显示使用绑定关系")
@GetMapping(value = "/isShowUseBindRelation") @GetMapping(value = "/isShowUseBindRelation")
public Result<LawsBindPart> isShowUseBindRelation(LawsBindPart lawsBindPart) { public Result<?> isShowUseBindRelation(LawsBindPart lawsBindPart) {
return Result.OK(lawsBindPartService.isShowUseBindRelation(lawsBindPart)); LawsBindPart showUseBindRelation = lawsBindPartService.isShowUseBindRelation(lawsBindPart);
return Result.OK();
} }
@AutoLog(value = "绑定零部件-使用绑定关系") @AutoLog(value = "绑定零部件-使用绑定关系")
@@ -95,11 +95,12 @@ public class LawsBindPartServiceImpl extends ServiceImpl<LawsBindPartMapper, Law
@Override @Override
public void add(LawsBindPart lawsBindPart) { public void add(LawsBindPart lawsBindPart) {
// 访问PDM校验该零部件号是否可以修改 // 访问PDM校验该零部件号是否可以修改
boolean canEdit = srmsApiService.validPartNoEdit(lawsBindPart.getPartNo(), try {
lawsBindPart.getPartName(), srmsApiService.validPartNoEdit(lawsBindPart.getPartNo(),
getBindUsernameAndRealName(lawsBindPart.getBindUser())); lawsBindPart.getPartName(),
if (!canEdit) { getBindUsernameAndRealName(lawsBindPart.getBindUser()));
throw new JeroBootException("零部件号" + lawsBindPart.getPartNo() + "不可新增"); } catch (Exception e) {
throw new JeroBootException(e.getMessage());
} }
lawsBindPart.setBindTime(new Date()); lawsBindPart.setBindTime(new Date());
save(lawsBindPart); save(lawsBindPart);
@@ -144,10 +145,11 @@ public class LawsBindPartServiceImpl extends ServiceImpl<LawsBindPartMapper, Law
// 访问PDM校验该零部件号是否可以修改 // 访问PDM校验该零部件号是否可以修改
for (String id : ids) { for (String id : ids) {
LawsBindPart existBindPart = lawsBindPartMap.get(id); LawsBindPart existBindPart = lawsBindPartMap.get(id);
boolean canEdit = srmsApiService.validPartNoEdit(existBindPart.getPartNo(), try {
existBindPart.getPartName(), srmsApiService.validPartNoEdit(existBindPart.getPartNo(),
getBindUsernameAndRealName(existBindPart.getBindUser())); existBindPart.getPartName(),
if (!canEdit) { getBindUsernameAndRealName(existBindPart.getBindUser()));
} catch (Exception e) {
errPartSet.add(existBindPart.getPartNo()); errPartSet.add(existBindPart.getPartNo());
} }
} }
@@ -118,7 +118,7 @@ public interface SrmsApiService {
* @author CHH * @author CHH
* @date 2024/4/28 15:08 * @date 2024/4/28 15:08
*/ */
boolean validPartNoEdit(String partNo, String partName, String bindUserInfo); void validPartNoEdit(String partNo, String partName, String bindUserInfo);
/** /**
* PDM校验某个零部件是否所属于某个零部件分类 * PDM校验某个零部件是否所属于某个零部件分类
@@ -157,38 +157,36 @@ public class SrmsApiServiceImpl implements SrmsApiService {
private static final String PRINT_TOKEN = "token============================"; private static final String PRINT_TOKEN = "token============================";
@Override @Override
public Result<JSONObject> getByToken(JSONObject json) { public Result<JSONObject> getByToken(JSONObject json) {
try { try {
ByTokenRequests byTokenRequests = JSON.parseObject(JSON.toJSONString(json.get(REQUESTS)),ByTokenRequests.class); ByTokenRequests byTokenRequests = JSON.parseObject(JSON.toJSONString(json.get(REQUESTS)), ByTokenRequests.class);
// 验证数据必填项 // 验证数据必填项
if(StringUtils.isAllBlank(byTokenRequests.getUsername()) if (StringUtils.isAllBlank(byTokenRequests.getUsername())
|| StringUtils.isBlank(byTokenRequests.getAppkey()) || StringUtils.isBlank(byTokenRequests.getAppkey())
|| StringUtils.isBlank(byTokenRequests.getSecret())){ || StringUtils.isBlank(byTokenRequests.getSecret())) {
return Result.error(ADD_NOT_NULL); return Result.error(ADD_NOT_NULL);
} }
LambdaQueryWrapper<LawsSysApiInfo> queryLawsSysApiInfo = new LambdaQueryWrapper<>(); LambdaQueryWrapper<LawsSysApiInfo> queryLawsSysApiInfo = new LambdaQueryWrapper<>();
queryLawsSysApiInfo.eq(LawsSysApiInfo::getAppKey,byTokenRequests.getAppkey()); queryLawsSysApiInfo.eq(LawsSysApiInfo::getAppKey, byTokenRequests.getAppkey());
queryLawsSysApiInfo.eq(LawsSysApiInfo::getSecret,byTokenRequests.getSecret()); queryLawsSysApiInfo.eq(LawsSysApiInfo::getSecret, byTokenRequests.getSecret());
LawsSysApiInfo lawsSysApiInfo = lawsSysApiInfoService.getOne(queryLawsSysApiInfo,false); LawsSysApiInfo lawsSysApiInfo = lawsSysApiInfoService.getOne(queryLawsSysApiInfo, false);
if(Objects.isNull(lawsSysApiInfo)){ if (Objects.isNull(lawsSysApiInfo)) {
return Result.error(403,SYS_ERR); return Result.error(403, SYS_ERR);
} }
Result<JSONObject> re; Result<JSONObject> re;
// E彩通访问,使用默认账户 // E彩通访问,使用默认账户
if(Objects.equals(ettonSysCode,lawsSysApiInfo.getSysCode())){ if (Objects.equals(ettonSysCode, lawsSysApiInfo.getSysCode())) {
re = loginService.srmsByToken(ettonSysUser); re = loginService.srmsByToken(ettonSysUser);
String token = re.getResult().get("token").toString(); String token = re.getResult().get("token").toString();
String tokenKey = byTokenRequests.getUsername() + token; String tokenKey = byTokenRequests.getUsername() + token;
redisUtil.set(tokenKey,token,3600); redisUtil.set(tokenKey, token, 3600);
}else{ } else {
re = loginService.srmsByToken(byTokenRequests.getUsername()); re = loginService.srmsByToken(byTokenRequests.getUsername());
} }
return re; return re;
}catch (Exception e){ } catch (Exception e) {
log.error("获取token异常:",e); log.error("获取token异常:", e);
return Result.error("操作失败"); return Result.error("操作失败");
} }
} }
@@ -201,16 +199,16 @@ public class SrmsApiServiceImpl implements SrmsApiService {
log.info(PRINT_TOKEN + token); log.info(PRINT_TOKEN + token);
// 验证Token有效性 // 验证Token有效性
boolean tokenOK = TokenUtils.verifyToken(req, sysBaseAPI, redisUtil); boolean tokenOK = TokenUtils.verifyToken(req, sysBaseAPI, redisUtil);
if(!tokenOK){ if (!tokenOK) {
return Result.error(403,SYS_ERR); return Result.error(403, SYS_ERR);
} }
} catch (Exception ignored) { } catch (Exception ignored) {
return Result.error(403,SYS_ERR); return Result.error(403, SYS_ERR);
} }
JSONObject requests = JSON.parseObject(JSON.toJSONString(json.get(REQUESTS))); JSONObject requests = JSON.parseObject(JSON.toJSONString(json.get(REQUESTS)));
// 零部件-分类内部码(精准查询) // 零部件-分类内部码(精准查询)
String partCategoryNum = getStr(requests, "partCategoryNum"); String partCategoryNum = getStr(requests, "partCategoryNum");
if(StringUtils.isBlank(partCategoryNum)){ if (StringUtils.isBlank(partCategoryNum)) {
return Result.error("零部件-分类内部码不能为空"); return Result.error("零部件-分类内部码不能为空");
} }
try { try {
@@ -230,63 +228,63 @@ public class SrmsApiServiceImpl implements SrmsApiService {
standardVO.setStandardState(standardState); standardVO.setStandardState(standardState);
// 是否存在拆分信息,默认false; true-是,false-否 // 是否存在拆分信息,默认false; true-是,false-否
setHasSplit(requests, standardVO); setHasSplit(requests, standardVO);
List<ByFileRows> listByFileRows = getByFileRows(partCategoryNum, standardVO,token); List<ByFileRows> listByFileRows = getByFileRows(partCategoryNum, standardVO, token);
return Result.OK(listByFileRows); return Result.OK(listByFileRows);
}catch (Exception e){ } catch (Exception e) {
log.error("标准法规文档查询异常:",e); log.error("标准法规文档查询异常:", e);
return Result.error("操作失败" + e.getMessage()); return Result.error("操作失败" + e.getMessage());
} }
} }
@Nullable @Nullable
private List<ByFileRows> getByFileRows(String partCategoryNum, StandardVO standardVO,String token) { private List<ByFileRows> getByFileRows(String partCategoryNum, StandardVO standardVO, String token) {
List<ByFileRows> listByFileRows = lawsStandardMapper.getStandard(standardVO); List<ByFileRows> listByFileRows = lawsStandardMapper.getStandard(standardVO);
if(CollectionUtils.isEmpty(listByFileRows)) { if (CollectionUtils.isEmpty(listByFileRows)) {
return listByFileRows; return listByFileRows;
} }
List<String> listFileId = listByFileRows.stream().map(ByFileRows::getId).collect(Collectors.toList()); List<String> listFileId = listByFileRows.stream().map(ByFileRows::getId).collect(Collectors.toList());
LambdaQueryWrapper<OSSFile> queryOssFile = new LambdaQueryWrapper<>(); LambdaQueryWrapper<OSSFile> queryOssFile = new LambdaQueryWrapper<>();
queryOssFile.in(OSSFile::getStandardId,listFileId); queryOssFile.in(OSSFile::getStandardId, listFileId);
queryOssFile.eq(OSSFile::getStandardFileType,PUBLISH_OF_ORIGINAL); queryOssFile.eq(OSSFile::getStandardFileType, PUBLISH_OF_ORIGINAL);
queryOssFile.orderByDesc(OSSFile::getCreateTime); queryOssFile.orderByDesc(OSSFile::getCreateTime);
List<OSSFile> listOssFile = ossFileService.list(queryOssFile); List<OSSFile> listOssFile = ossFileService.list(queryOssFile);
// 查询零件名称 // 查询零件名称
LambdaQueryWrapper<PartName> queryPartName = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PartName> queryPartName = new LambdaQueryWrapper<>();
queryPartName.eq(PartName::getCode,partCategoryNum); queryPartName.eq(PartName::getCode, partCategoryNum);
PartName partName = partNameService.getOne(queryPartName,false); PartName partName = partNameService.getOne(queryPartName, false);
for (ByFileRows byFileRows : listByFileRows) { for (ByFileRows byFileRows : listByFileRows) {
byFileRows.setPartCategoryNum(partCategoryNum); byFileRows.setPartCategoryNum(partCategoryNum);
if(!Objects.isNull(partName)){ if (!Objects.isNull(partName)) {
byFileRows.setPartCategoryName(partName.getName()); byFileRows.setPartCategoryName(partName.getName());
} }
byFileRows.setStandardState_dictText(sysBaseAPI.translateDict("standard_state", byFileRows.getStandardState())); byFileRows.setStandardState_dictText(sysBaseAPI.translateDict("standard_state", byFileRows.getStandardState()));
if(!CollectionUtils.isEmpty(listOssFile)){ if (!CollectionUtils.isEmpty(listOssFile)) {
List<OSSFile> listFile = listOssFile.stream().filter(o-> Objects.equals(o.getStandardId(),byFileRows.getId())).collect(Collectors.toList()); List<OSSFile> listFile = listOssFile.stream().filter(o -> Objects.equals(o.getStandardId(), byFileRows.getId())).collect(Collectors.toList());
if(!CollectionUtils.isEmpty(listFile)){ if (!CollectionUtils.isEmpty(listFile)) {
listFile = listFile.stream().sorted(Comparator.comparing(OSSFile::getCreateTime).reversed()).collect(Collectors.toList()); listFile = listFile.stream().sorted(Comparator.comparing(OSSFile::getCreateTime).reversed()).collect(Collectors.toList());
byFileRows.setStandardUrl(getUrl(listFile.get(0),token)); byFileRows.setStandardUrl(getUrl(listFile.get(0), token));
} }
} }
LambdaQueryWrapper<SarFileSplitInfoEO> querySarFileSplitInfoEo = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SarFileSplitInfoEO> querySarFileSplitInfoEo = new LambdaQueryWrapper<>();
querySarFileSplitInfoEo.eq(SarFileSplitInfoEO::getStandardId,byFileRows.getId()); querySarFileSplitInfoEo.eq(SarFileSplitInfoEO::getStandardId, byFileRows.getId());
querySarFileSplitInfoEo.isNull(SarFileSplitInfoEO::getPublishBeforeId); querySarFileSplitInfoEo.isNull(SarFileSplitInfoEO::getPublishBeforeId);
querySarFileSplitInfoEo.eq(SarFileSplitInfoEO::getFileType,PUBLISH_OF_ORIGINAL); querySarFileSplitInfoEo.eq(SarFileSplitInfoEO::getFileType, PUBLISH_OF_ORIGINAL);
SarFileSplitInfoEO sarFileSplitInfoEo = sarFileSplitInfoService.getOne(querySarFileSplitInfoEo,false); SarFileSplitInfoEO sarFileSplitInfoEo = sarFileSplitInfoService.getOne(querySarFileSplitInfoEo, false);
addSarFileSplitInfoEO(byFileRows, sarFileSplitInfoEo); addSarFileSplitInfoEO(byFileRows, sarFileSplitInfoEo);
} }
return listByFileRows; return listByFileRows;
} }
private void addSarFileSplitInfoEO(ByFileRows byFileRows, SarFileSplitInfoEO sarFileSplitInfoEo) { private void addSarFileSplitInfoEO(ByFileRows byFileRows, SarFileSplitInfoEO sarFileSplitInfoEo) {
if(!Objects.isNull(sarFileSplitInfoEo)){ if (!Objects.isNull(sarFileSplitInfoEo)) {
SarFileSplitMenuEOPage page = new SarFileSplitMenuEOPage(); SarFileSplitMenuEOPage page = new SarFileSplitMenuEOPage();
page.setValidFlag("0"); page.setValidFlag("0");
page.setOrderBy("display_seq asc"); page.setOrderBy("display_seq asc");
page.setInfoId(sarFileSplitInfoEo.getId()); page.setInfoId(sarFileSplitInfoEo.getId());
List<SarFileSplitMenuEO> getList = sarFileSplitMenuEOService.queryByApiList(page); List<SarFileSplitMenuEO> getList = sarFileSplitMenuEOService.queryByApiList(page);
if(!CollectionUtils.isEmpty(getList)){ if (!CollectionUtils.isEmpty(getList)) {
List<SarFileSplitMenu> listSarFileSplitMenu = new ArrayList<>(); List<SarFileSplitMenu> listSarFileSplitMenu = new ArrayList<>();
for (SarFileSplitMenuEO sarFileSplitMenuEo : getList) { for (SarFileSplitMenuEO sarFileSplitMenuEo : getList) {
SarFileSplitMenu sarFileSplitMenu = new SarFileSplitMenu(); SarFileSplitMenu sarFileSplitMenu = new SarFileSplitMenu();
@@ -297,14 +295,14 @@ public class SrmsApiServiceImpl implements SrmsApiService {
listSarFileSplitMenu.add(sarFileSplitMenu); listSarFileSplitMenu.add(sarFileSplitMenu);
} }
SplitResult splitResult = new SplitResult(); SplitResult splitResult = new SplitResult();
if(!CollectionUtils.isEmpty(listSarFileSplitMenu)){ if (!CollectionUtils.isEmpty(listSarFileSplitMenu)) {
List<String> listIds = listSarFileSplitMenu.stream().map(SarFileSplitMenu::getId).collect(Collectors.toList()); List<String> listIds = listSarFileSplitMenu.stream().map(SarFileSplitMenu::getId).collect(Collectors.toList());
LambdaQueryWrapper<LawsDocumentSplit> queryLawsDocumentSplit = new LambdaQueryWrapper<>(); LambdaQueryWrapper<LawsDocumentSplit> queryLawsDocumentSplit = new LambdaQueryWrapper<>();
queryLawsDocumentSplit.in(LawsDocumentSplit::getMenuId,listIds); queryLawsDocumentSplit.in(LawsDocumentSplit::getMenuId, listIds);
queryLawsDocumentSplit.eq(LawsDocumentSplit::getDelFlag,"0"); queryLawsDocumentSplit.eq(LawsDocumentSplit::getDelFlag, "0");
List<LawsDocumentSplit> listLawsDocumentSplit = lawsDocumentSplitMapper.selectList(queryLawsDocumentSplit); List<LawsDocumentSplit> listLawsDocumentSplit = lawsDocumentSplitMapper.selectList(queryLawsDocumentSplit);
if(!CollectionUtils.isEmpty(listLawsDocumentSplit)){ if (!CollectionUtils.isEmpty(listLawsDocumentSplit)) {
List<DocumentSplitDetail> listDocumentSplitDetail = JSON.parseArray(JSON.toJSONString(listLawsDocumentSplit),DocumentSplitDetail.class); List<DocumentSplitDetail> listDocumentSplitDetail = JSON.parseArray(JSON.toJSONString(listLawsDocumentSplit), DocumentSplitDetail.class);
splitResult.setDocumentSplitDetail(listDocumentSplitDetail); splitResult.setDocumentSplitDetail(listDocumentSplitDetail);
} }
@@ -320,11 +318,11 @@ public class SrmsApiServiceImpl implements SrmsApiService {
} }
private void setHasSplit(JSONObject requests, StandardVO standardVO) { private void setHasSplit(JSONObject requests, StandardVO standardVO) {
if(!Objects.isNull(requests.get("hasSplit"))){ if (!Objects.isNull(requests.get("hasSplit"))) {
boolean hasSplit = Boolean.parseBoolean(requests.get("hasSplit").toString()); boolean hasSplit = Boolean.parseBoolean(requests.get("hasSplit").toString());
if(hasSplit){ if (hasSplit) {
standardVO.setHasSplit("1"); standardVO.setHasSplit("1");
}else{ } else {
standardVO.setHasSplit("2"); standardVO.setHasSplit("2");
} }
} }
@@ -348,26 +346,26 @@ public class SrmsApiServiceImpl implements SrmsApiService {
log.info(PRINT_TOKEN + token); log.info(PRINT_TOKEN + token);
// 验证Token有效性 // 验证Token有效性
boolean tokenOK = TokenUtils.verifyToken(req, sysBaseAPI, redisUtil); boolean tokenOK = TokenUtils.verifyToken(req, sysBaseAPI, redisUtil);
if(!tokenOK){ if (!tokenOK) {
return Result.error(403,SYS_ERR); return Result.error(403, SYS_ERR);
} }
} catch (Exception ignored) { } catch (Exception ignored) {
return Result.error(403,SYS_ERR); return Result.error(403, SYS_ERR);
} }
JSONObject requests = JSON.parseObject(JSON.toJSONString(json.get(REQUESTS))); JSONObject requests = JSON.parseObject(JSON.toJSONString(json.get(REQUESTS)));
JSONArray rows = JSON.parseArray(JSON.toJSONString(requests.get("Rows"))); JSONArray rows = JSON.parseArray(JSON.toJSONString(requests.get("Rows")));
if(CollectionUtils.isEmpty(rows)){ if (CollectionUtils.isEmpty(rows)) {
return Result.error(ADD_NOT_NULL); return Result.error(ADD_NOT_NULL);
} }
List<ProductDesign> listProductDesign = new ArrayList<>(); List<ProductDesign> listProductDesign = new ArrayList<>();
String queryLabels = "queryLabels"; String queryLabels = "queryLabels";
for (Object request : rows) { for (Object request : rows) {
JSONObject js = JSON.parseObject(JSON.toJSONString(request)); JSONObject js = JSON.parseObject(JSON.toJSONString(request));
if(!js.containsKey("ID") || !js.containsKey(STANDARD_NUMBER) || !js.containsKey(queryLabels)){ if (!js.containsKey("ID") || !js.containsKey(STANDARD_NUMBER) || !js.containsKey(queryLabels)) {
return Result.error(ADD_NOT_NULL); return Result.error(ADD_NOT_NULL);
} }
if(StringUtils.isBlank(js.getString("ID")) || StringUtils.isBlank(js.getString(STANDARD_NUMBER)) if (StringUtils.isBlank(js.getString("ID")) || StringUtils.isBlank(js.getString(STANDARD_NUMBER))
|| StringUtils.isBlank(js.getString(queryLabels))){ || StringUtils.isBlank(js.getString(queryLabels))) {
return Result.error(ADD_NOT_NULL); return Result.error(ADD_NOT_NULL);
} }
ProductDesign productDesign = new ProductDesign(); ProductDesign productDesign = new ProductDesign();
@@ -379,20 +377,20 @@ public class SrmsApiServiceImpl implements SrmsApiService {
try { try {
List<JSONObject> listObj = new ArrayList<>(); List<JSONObject> listObj = new ArrayList<>();
for (ProductDesign productDesign : listProductDesign) { for (ProductDesign productDesign : listProductDesign) {
List<Map<String,String>> list = lawsStandardMapper.getStandardByProductDesign(productDesign.getStandardNumber(),productDesign.getQueryLabels()); List<Map<String, String>> list = lawsStandardMapper.getStandardByProductDesign(productDesign.getStandardNumber(), productDesign.getQueryLabels());
for (Map<String, String> stringStringMap : list) { for (Map<String, String> stringStringMap : list) {
JSONObject obj = new JSONObject(); JSONObject obj = new JSONObject();
obj.put("ID",productDesign.getId()); obj.put("ID", productDesign.getId());
obj.put(queryLabels,productDesign.getQueryLabels()); obj.put(queryLabels, productDesign.getQueryLabels());
obj.put("itemContent",stringStringMap.get("item_content")); obj.put("itemContent", stringStringMap.get("item_content"));
obj.put(STANDARD_NUMBER,stringStringMap.get("standard_number")); obj.put(STANDARD_NUMBER, stringStringMap.get("standard_number"));
listObj.add(obj); listObj.add(obj);
} }
} }
return Result.OK(listObj); return Result.OK(listObj);
}catch (Exception e){ } catch (Exception e) {
log.error("设计导航-产品设计条款查询异常:",e); log.error("设计导航-产品设计条款查询异常:", e);
return Result.error("操作失败" + e.getMessage()); return Result.error("操作失败" + e.getMessage());
} }
} }
@@ -405,36 +403,36 @@ public class SrmsApiServiceImpl implements SrmsApiService {
log.info(PRINT_TOKEN + token); log.info(PRINT_TOKEN + token);
// 验证Token有效性 // 验证Token有效性
boolean tokenOK = TokenUtils.verifyToken(req, sysBaseAPI, redisUtil); boolean tokenOK = TokenUtils.verifyToken(req, sysBaseAPI, redisUtil);
if(!tokenOK){ if (!tokenOK) {
return Result.error(403,SYS_ERR); return Result.error(403, SYS_ERR);
} }
} catch (Exception ignored) { } catch (Exception ignored) {
return Result.error(403,SYS_ERR); return Result.error(403, SYS_ERR);
} }
JSONObject requests = JSON.parseObject(JSON.toJSONString(json.get(REQUESTS))); JSONObject requests = JSON.parseObject(JSON.toJSONString(json.get(REQUESTS)));
String nodeName = ""; String nodeName = "";
if(!Objects.isNull(requests) && requests.containsKey("nodeName")){ if (!Objects.isNull(requests) && requests.containsKey("nodeName")) {
nodeName = requests.get("nodeName").toString(); nodeName = requests.get("nodeName").toString();
} }
try { try {
List<StandardTree> listStandardTreeAll = new ArrayList<>(); List<StandardTree> listStandardTreeAll = new ArrayList<>();
// 国内标准 // 国内标准
List<LawsTreeNodeModel> listDomestic = lawsTreeNodeService.queryTreeNodeList(TableNameEnum.DOMESTIC_REGULATIONS.getValue(), nodeName, "1"); List<LawsTreeNodeModel> listDomestic = lawsTreeNodeService.queryTreeNodeList(TableNameEnum.DOMESTIC_REGULATIONS.getValue(), nodeName, "1");
getStandardTree(listStandardTreeAll, listDomestic,nodeName); getStandardTree(listStandardTreeAll, listDomestic, nodeName);
// 海外标准 // 海外标准
List<LawsTreeNodeModel> listForeign = lawsTreeNodeService.queryTreeNodeList(TableNameEnum.FOREIGN_REGULATIONS.getValue(), nodeName, "1"); List<LawsTreeNodeModel> listForeign = lawsTreeNodeService.queryTreeNodeList(TableNameEnum.FOREIGN_REGULATIONS.getValue(), nodeName, "1");
getStandardTree(listStandardTreeAll, listForeign,nodeName); getStandardTree(listStandardTreeAll, listForeign, nodeName);
// 企业标准 // 企业标准
List<LawsTreeNodeModel> listEnterprise = lawsTreeNodeService.queryTreeNodeList(TableNameEnum.ENTERPRISE_STANDARDS.getValue(), nodeName, "1"); List<LawsTreeNodeModel> listEnterprise = lawsTreeNodeService.queryTreeNodeList(TableNameEnum.ENTERPRISE_STANDARDS.getValue(), nodeName, "1");
getStandardTree(listStandardTreeAll, listEnterprise,nodeName); getStandardTree(listStandardTreeAll, listEnterprise, nodeName);
return Result.OK(listStandardTreeAll); return Result.OK(listStandardTreeAll);
}catch (Exception e){ } catch (Exception e) {
log.error("获取所有体系数据异常:",e); log.error("获取所有体系数据异常:", e);
return Result.error("操作失败" + e.getMessage()); return Result.error("操作失败" + e.getMessage());
} }
} }
private void getStandardTree(List<StandardTree> listStandardTreeAll, List<LawsTreeNodeModel> listEnterprise,String nodeName) { private void getStandardTree(List<StandardTree> listStandardTreeAll, List<LawsTreeNodeModel> listEnterprise, String nodeName) {
if (CollectionUtils.isEmpty(listEnterprise)) { if (CollectionUtils.isEmpty(listEnterprise)) {
return; return;
} }
@@ -450,18 +448,18 @@ public class SrmsApiServiceImpl implements SrmsApiService {
standardTree.setChildren(sub); standardTree.setChildren(sub);
} }
} }
if(!StringUtils.isBlank(nodeName)){ if (!StringUtils.isBlank(nodeName)) {
if(!CollectionUtils.isEmpty(lawsTreeNodeModel.getChildren()) || lawsTreeNodeModel.getNodeName().contains(nodeName)){ if (!CollectionUtils.isEmpty(lawsTreeNodeModel.getChildren()) || lawsTreeNodeModel.getNodeName().contains(nodeName)) {
listStandardTreeAll.add(standardTree); listStandardTreeAll.add(standardTree);
} }
}else{ } else {
listStandardTreeAll.add(standardTree); listStandardTreeAll.add(standardTree);
} }
} }
} }
private List<StandardTree> getTree(List<LawsTreeNodeModel> listEnterprise){ private List<StandardTree> getTree(List<LawsTreeNodeModel> listEnterprise) {
if(CollectionUtils.isEmpty(listEnterprise)){ if (CollectionUtils.isEmpty(listEnterprise)) {
return Collections.emptyList(); return Collections.emptyList();
} }
List<StandardTree> list = new ArrayList<>(); List<StandardTree> list = new ArrayList<>();
@@ -470,9 +468,9 @@ public class SrmsApiServiceImpl implements SrmsApiService {
obj.setNodeCode(treeNodeModel.getNodeCode()); obj.setNodeCode(treeNodeModel.getNodeCode());
obj.setNodeName(treeNodeModel.getNodeName()); obj.setNodeName(treeNodeModel.getNodeName());
List<LawsTreeNodeModel> listSub = treeNodeModel.getChildren(); List<LawsTreeNodeModel> listSub = treeNodeModel.getChildren();
if(!CollectionUtils.isEmpty(listSub)){ if (!CollectionUtils.isEmpty(listSub)) {
List<StandardTree> listStandardTree = getTree(listSub); List<StandardTree> listStandardTree = getTree(listSub);
if(!CollectionUtils.isEmpty(listStandardTree)){ if (!CollectionUtils.isEmpty(listStandardTree)) {
obj.setChildren(listStandardTree); obj.setChildren(listStandardTree);
} }
} }
@@ -489,38 +487,38 @@ public class SrmsApiServiceImpl implements SrmsApiService {
log.info(PRINT_TOKEN + token); log.info(PRINT_TOKEN + token);
// 验证Token有效性 // 验证Token有效性
boolean tokenOK = TokenUtils.verifyToken(req, sysBaseAPI, redisUtil); boolean tokenOK = TokenUtils.verifyToken(req, sysBaseAPI, redisUtil);
if(!tokenOK){ if (!tokenOK) {
return Result.error(403,SYS_ERR); return Result.error(403, SYS_ERR);
} }
} catch (Exception ignored) { } catch (Exception ignored) {
return Result.error(403,SYS_ERR); return Result.error(403, SYS_ERR);
} }
JSONObject requests = JSON.parseObject(JSON.toJSONString(json.get(REQUESTS))); JSONObject requests = JSON.parseObject(JSON.toJSONString(json.get(REQUESTS)));
if(Objects.isNull(requests)){ if (Objects.isNull(requests)) {
return Result.error(ADD_NOT_NULL); return Result.error(ADD_NOT_NULL);
} }
String pageNoKey = "pageNo"; String pageNoKey = "pageNo";
String pageSizeKey = "pageSize"; String pageSizeKey = "pageSize";
if(!requests.containsKey(pageNoKey) || !requests.containsKey(pageSizeKey) ){ if (!requests.containsKey(pageNoKey) || !requests.containsKey(pageSizeKey)) {
return Result.error(ADD_NOT_NULL); return Result.error(ADD_NOT_NULL);
} }
try { try {
Long.parseLong(requests.get(pageNoKey).toString()); Long.parseLong(requests.get(pageNoKey).toString());
Long.parseLong(requests.get(pageSizeKey).toString()); Long.parseLong(requests.get(pageSizeKey).toString());
}catch (Exception e){ } catch (Exception e) {
return Result.error(ADD_NOT_NULL); return Result.error(ADD_NOT_NULL);
} }
QueryWrapper<StandardPageVO> queryStandardPageVO = new QueryWrapper<>(); QueryWrapper<StandardPageVO> queryStandardPageVO = new QueryWrapper<>();
setQuery(requests, queryStandardPageVO); setQuery(requests, queryStandardPageVO);
String columnKey = "column"; String columnKey = "column";
if(requests.containsKey(columnKey) && !StringUtils.isBlank(requests.get(columnKey).toString())){ if (requests.containsKey(columnKey) && !StringUtils.isBlank(requests.get(columnKey).toString())) {
String[] column = requests.get(columnKey).toString().split(","); String[] column = requests.get(columnKey).toString().split(",");
String[] order = null; String[] order = null;
String orderKey = "order"; String orderKey = "order";
if(requests.containsKey(orderKey) && StringUtils.isBlank(requests.get(orderKey).toString())){ if (requests.containsKey(orderKey) && StringUtils.isBlank(requests.get(orderKey).toString())) {
order = requests.get(orderKey).toString().split(","); order = requests.get(orderKey).toString().split(",");
if(column.length != order.length){ if (column.length != order.length) {
return Result.error("排序参数异常"); return Result.error("排序参数异常");
} }
} }
@@ -528,74 +526,74 @@ public class SrmsApiServiceImpl implements SrmsApiService {
} }
Page<StandardPageVO> page = new Page<>(Long.parseLong(requests.get(pageNoKey).toString()), Page<StandardPageVO> page = new Page<>(Long.parseLong(requests.get(pageNoKey).toString()),
Long.parseLong(requests.get(pageSizeKey).toString())); Long.parseLong(requests.get(pageSizeKey).toString()));
IPage<StandardPageVO> pageList = lawsStandardMapper.getByLawsStandardPage(page,queryStandardPageVO); IPage<StandardPageVO> pageList = lawsStandardMapper.getByLawsStandardPage(page, queryStandardPageVO);
getListStandardPageVO(pageList,token); getListStandardPageVO(pageList, token);
return Result.OK(pageList); return Result.OK(pageList);
} }
private void setQuery(JSONObject requests, QueryWrapper<StandardPageVO> queryStandardPageVO) { private void setQuery(JSONObject requests, QueryWrapper<StandardPageVO> queryStandardPageVO) {
queryStandardPageVO.eq("'1'","1"); queryStandardPageVO.eq("'1'", "1");
String nodeCodeKey = "nodeCode"; String nodeCodeKey = "nodeCode";
if(requests.containsKey(nodeCodeKey) && !StringUtils.isEmpty(requests.get(nodeCodeKey).toString())){ if (requests.containsKey(nodeCodeKey) && !StringUtils.isEmpty(requests.get(nodeCodeKey).toString())) {
String nodeCode = requests.get(nodeCodeKey).toString(); String nodeCode = requests.get(nodeCodeKey).toString();
queryStandardPageVO.eq(!StringUtils.isEmpty(nodeCode),"l.node_code",nodeCode); queryStandardPageVO.eq(!StringUtils.isEmpty(nodeCode), "l.node_code", nodeCode);
} }
if(requests.containsKey(STANDARD_NUMBER) && !StringUtils.isEmpty(requests.get(STANDARD_NUMBER).toString())){ if (requests.containsKey(STANDARD_NUMBER) && !StringUtils.isEmpty(requests.get(STANDARD_NUMBER).toString())) {
String standardNumber = requests.get(STANDARD_NUMBER).toString(); String standardNumber = requests.get(STANDARD_NUMBER).toString();
queryStandardPageVO.like("standard_number",standardNumber); queryStandardPageVO.like("standard_number", standardNumber);
} }
if(requests.containsKey(STANDARD_NAME) && !StringUtils.isEmpty(requests.get(STANDARD_NAME).toString())){ if (requests.containsKey(STANDARD_NAME) && !StringUtils.isEmpty(requests.get(STANDARD_NAME).toString())) {
String standardName = requests.get(STANDARD_NAME).toString(); String standardName = requests.get(STANDARD_NAME).toString();
queryStandardPageVO.like("standard_name",standardName); queryStandardPageVO.like("standard_name", standardName);
} }
} }
private void setOrder(QueryWrapper<StandardPageVO> queryStandardPageVO, String[] column, String[] order) { private void setOrder(QueryWrapper<StandardPageVO> queryStandardPageVO, String[] column, String[] order) {
for (int i = 0; i < column.length; i++) { for (int i = 0; i < column.length; i++) {
String c = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, column[i]); String c = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, column[i]);
if(Objects.isNull(order)){ if (Objects.isNull(order)) {
queryStandardPageVO.orderByDesc(c); queryStandardPageVO.orderByDesc(c);
}else{ } else {
if(Objects.equals(order[i],"asc") || Objects.equals(order[i],"ASC")){ if (Objects.equals(order[i], "asc") || Objects.equals(order[i], "ASC")) {
queryStandardPageVO.orderByAsc(c); queryStandardPageVO.orderByAsc(c);
}else{ } else {
queryStandardPageVO.orderByDesc(c); queryStandardPageVO.orderByDesc(c);
} }
} }
} }
} }
private void getListStandardPageVO(IPage<StandardPageVO> pageList,String token) { private void getListStandardPageVO(IPage<StandardPageVO> pageList, String token) {
List<StandardPageVO> listStandardPageVO = pageList.getRecords(); List<StandardPageVO> listStandardPageVO = pageList.getRecords();
if(CollectionUtils.isEmpty(listStandardPageVO)){ if (CollectionUtils.isEmpty(listStandardPageVO)) {
return; return;
} }
List<String> listFileId = listStandardPageVO.stream().map(StandardPageVO::getId).collect(Collectors.toList()); List<String> listFileId = listStandardPageVO.stream().map(StandardPageVO::getId).collect(Collectors.toList());
QueryWrapper<OSSFile> queryOssFile = new QueryWrapper<>(); QueryWrapper<OSSFile> queryOssFile = new QueryWrapper<>();
queryOssFile.eq("lower(right(url, 4))",".pdf"); queryOssFile.eq("lower(right(url, 4))", ".pdf");
queryOssFile.lambda().in(OSSFile::getStandardId,listFileId); queryOssFile.lambda().in(OSSFile::getStandardId, listFileId);
queryOssFile.lambda().eq(OSSFile::getStandardFileType,PUBLISH_OF_ORIGINAL); queryOssFile.lambda().eq(OSSFile::getStandardFileType, PUBLISH_OF_ORIGINAL);
queryOssFile.lambda().orderByDesc(OSSFile::getCreateTime); queryOssFile.lambda().orderByDesc(OSSFile::getCreateTime);
List<OSSFile> listOssFile = ossFileService.list(queryOssFile); List<OSSFile> listOssFile = ossFileService.list(queryOssFile);
List<StandardPageVO> listStandardPageVOPartName = listStandardPageVO.stream().filter(o->!StringUtils.isBlank(o.getPartCategoryNum())).collect(Collectors.toList()); List<StandardPageVO> listStandardPageVOPartName = listStandardPageVO.stream().filter(o -> !StringUtils.isBlank(o.getPartCategoryNum())).collect(Collectors.toList());
List<PartName> listPartName = getPartNames(listStandardPageVOPartName); List<PartName> listPartName = getPartNames(listStandardPageVOPartName);
for (StandardPageVO standardPageVO : listStandardPageVO) { for (StandardPageVO standardPageVO : listStandardPageVO) {
standardPageVO.setStandardState_dictText(sysBaseAPI.translateDict("standard_state", standardPageVO.getStandardState())); standardPageVO.setStandardState_dictText(sysBaseAPI.translateDict("standard_state", standardPageVO.getStandardState()));
if(!CollectionUtils.isEmpty(listOssFile)){ if (!CollectionUtils.isEmpty(listOssFile)) {
List<OSSFile> listOssFileOne = listOssFile.stream().filter(o-> Objects.equals(o.getStandardId(),standardPageVO.getId())).collect(Collectors.toList()); List<OSSFile> listOssFileOne = listOssFile.stream().filter(o -> Objects.equals(o.getStandardId(), standardPageVO.getId())).collect(Collectors.toList());
if(!CollectionUtils.isEmpty(listOssFileOne)){ if (!CollectionUtils.isEmpty(listOssFileOne)) {
listOssFileOne = listOssFileOne.stream().sorted(Comparator.comparing(OSSFile::getCreateTime).reversed()).collect(Collectors.toList()); listOssFileOne = listOssFileOne.stream().sorted(Comparator.comparing(OSSFile::getCreateTime).reversed()).collect(Collectors.toList());
standardPageVO.setStandardUrl(getUrl(listOssFileOne.get(0),token)); standardPageVO.setStandardUrl(getUrl(listOssFileOne.get(0), token));
} }
} }
// 零件号查询 // 零件号查询
if(!CollectionUtils.isEmpty(listPartName) && !StringUtils.isBlank(standardPageVO.getPartCategoryNum())){ if (!CollectionUtils.isEmpty(listPartName) && !StringUtils.isBlank(standardPageVO.getPartCategoryNum())) {
List<PartName> listPartNameNew = listPartName.stream().filter(o->Arrays.asList(standardPageVO.getPartCategoryNum().split(",")).contains(o.getCode())).collect(Collectors.toList()); List<PartName> listPartNameNew = listPartName.stream().filter(o -> Arrays.asList(standardPageVO.getPartCategoryNum().split(",")).contains(o.getCode())).collect(Collectors.toList());
if(!CollectionUtils.isEmpty(listPartNameNew)){ if (!CollectionUtils.isEmpty(listPartNameNew)) {
List<String> listName = listPartNameNew.stream().map(PartName::getName).collect(Collectors.toList()); List<String> listName = listPartNameNew.stream().map(PartName::getName).collect(Collectors.toList());
standardPageVO.setPartCategoryName(String.join(",",listName)); standardPageVO.setPartCategoryName(String.join(",", listName));
} }
} }
} }
@@ -603,37 +601,37 @@ public class SrmsApiServiceImpl implements SrmsApiService {
private List<PartName> getPartNames(List<StandardPageVO> listStandardPageVOPartName) { private List<PartName> getPartNames(List<StandardPageVO> listStandardPageVOPartName) {
List<PartName> listPartName = new ArrayList<>(); List<PartName> listPartName = new ArrayList<>();
if(!CollectionUtils.isEmpty(listStandardPageVOPartName)){ if (!CollectionUtils.isEmpty(listStandardPageVOPartName)) {
List<String> listPartCategoryNum = listStandardPageVOPartName.stream().map(StandardPageVO::getPartCategoryNum).collect(Collectors.toList()); List<String> listPartCategoryNum = listStandardPageVOPartName.stream().map(StandardPageVO::getPartCategoryNum).collect(Collectors.toList());
if(!CollectionUtils.isEmpty(listPartCategoryNum)){ if (!CollectionUtils.isEmpty(listPartCategoryNum)) {
// 零件号查询 // 零件号查询
LambdaQueryWrapper<PartName> queryPartName = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PartName> queryPartName = new LambdaQueryWrapper<>();
queryPartName.in(PartName::getCode, Arrays.stream(String.join(",",listPartCategoryNum).split(",")).collect(Collectors.toList()).stream().distinct().collect(Collectors.toList())); queryPartName.in(PartName::getCode, Arrays.stream(String.join(",", listPartCategoryNum).split(",")).collect(Collectors.toList()).stream().distinct().collect(Collectors.toList()));
listPartName = partNameService.list(queryPartName); listPartName = partNameService.list(queryPartName);
} }
} }
return listPartName; return listPartName;
} }
private String getUrl(OSSFile ossFile,String token){ private String getUrl(OSSFile ossFile, String token) {
String url = ""; String url = "";
try{ try {
if(ossFile.getFileName().toUpperCase().lastIndexOf(".PDF") > 0){ if (ossFile.getFileName().toUpperCase().lastIndexOf(".PDF") > 0) {
// 拼接url pdf预览 // 拼接url pdf预览
String back = backUrlPdf.replace("{id}",ossFile.getId()).replace("{token}",token); String back = backUrlPdf.replace("{id}", ossFile.getId()).replace("{token}", token);
url = fontUrlPdf.replace("{back_url_pdf}", URLEncoder.encode(back, StandardCharsets.UTF_8.name())); url = fontUrlPdf.replace("{back_url_pdf}", URLEncoder.encode(back, StandardCharsets.UTF_8.name()));
}else{ } else {
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
String mark = loginUser.getUsername() + loginUser.getRealname() + LocalDateTime.now(); String mark = loginUser.getUsername() + loginUser.getRealname() + LocalDateTime.now();
String markMd5 = MD5Util.MD5Encode(mark + otherMd5Mark,null); String markMd5 = MD5Util.MD5Encode(mark + otherMd5Mark, null);
String backOther = backUrlOther.replace("{id}",ossFile.getId()).replace("{token}",token) String backOther = backUrlOther.replace("{id}", ossFile.getId()).replace("{token}", token)
.replace("{file_name}",ossFile.getFileName()); .replace("{file_name}", ossFile.getFileName());
url = fontUrlOther.replace("{back_url_other}",URLEncoder.encode(Base64.getEncoder().encodeToString(backOther.getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8.name())) url = fontUrlOther.replace("{back_url_other}", URLEncoder.encode(Base64.getEncoder().encodeToString(backOther.getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8.name()))
.replace("{mark}",URLEncoder.encode(mark, StandardCharsets.UTF_8.name())) .replace("{mark}", URLEncoder.encode(mark, StandardCharsets.UTF_8.name()))
.replace("{mark_md5}",markMd5); .replace("{mark_md5}", markMd5);
} }
}catch (Exception e){ } catch (Exception e) {
log.error("拼接url异常",e); log.error("拼接url异常", e);
} }
return url; return url;
} }
@@ -643,18 +641,18 @@ public class SrmsApiServiceImpl implements SrmsApiService {
try { try {
JSONObject requests = JSON.parseObject(JSON.toJSONString(json.get(REQUESTS))); JSONObject requests = JSON.parseObject(JSON.toJSONString(json.get(REQUESTS)));
JSONArray rows = JSON.parseArray(JSON.toJSONString(requests.get("Rows"))); JSONArray rows = JSON.parseArray(JSON.toJSONString(requests.get("Rows")));
if(CollectionUtils.isEmpty(rows)){ if (CollectionUtils.isEmpty(rows)) {
return Result.error(ADD_NOT_NULL); return Result.error(ADD_NOT_NULL);
} }
List<PartName> listPartName = new ArrayList<>(); List<PartName> listPartName = new ArrayList<>();
for (Object request : rows) { for (Object request : rows) {
JSONObject js = JSON.parseObject(JSON.toJSONString(request)); JSONObject js = JSON.parseObject(JSON.toJSONString(request));
if(!js.containsKey(PART_CATEGORY_NUM) || !js.containsKey(PART_CATEGORY_NAME) || !js.containsKey(PARENT_NUM)){ if (!js.containsKey(PART_CATEGORY_NUM) || !js.containsKey(PART_CATEGORY_NAME) || !js.containsKey(PARENT_NUM)) {
return Result.error(ADD_NOT_NULL); return Result.error(ADD_NOT_NULL);
} }
if(StringUtils.isBlank(js.getString(PART_CATEGORY_NUM)) if (StringUtils.isBlank(js.getString(PART_CATEGORY_NUM))
|| StringUtils.isBlank(js.getString(PART_CATEGORY_NAME)) || StringUtils.isBlank(js.getString(PART_CATEGORY_NAME))
|| StringUtils.isBlank(js.getString(PARENT_NUM))){ || StringUtils.isBlank(js.getString(PARENT_NUM))) {
return Result.error(ADD_NOT_NULL); return Result.error(ADD_NOT_NULL);
} }
PartName partName = new PartName(); PartName partName = new PartName();
@@ -666,10 +664,10 @@ public class SrmsApiServiceImpl implements SrmsApiService {
partName.setRemark3(js.getString("Remark3")); partName.setRemark3(js.getString("Remark3"));
listPartName.add(partName); listPartName.add(partName);
} }
if(!CollectionUtils.isEmpty(listPartName)){ if (!CollectionUtils.isEmpty(listPartName)) {
// 清空数据 // 清空数据
LambdaUpdateWrapper<PartName> updatePartName = new LambdaUpdateWrapper<>(); LambdaUpdateWrapper<PartName> updatePartName = new LambdaUpdateWrapper<>();
updatePartName.eq(PartName::getDelFlag,"0"); updatePartName.eq(PartName::getDelFlag, "0");
partNameService.remove(updatePartName); partNameService.remove(updatePartName);
// 保存数据 // 保存数据
partNameService.saveBatch(listPartName); partNameService.saveBatch(listPartName);
@@ -677,8 +675,8 @@ public class SrmsApiServiceImpl implements SrmsApiService {
lawsStandardMapper.updatePartParentId(); lawsStandardMapper.updatePartParentId();
} }
return Result.OK("操作成功"); return Result.OK("操作成功");
}catch (Exception e){ } catch (Exception e) {
log.error("零部件分类树同步接口异常:",e); log.error("零部件分类树同步接口异常:", e);
return Result.error("操作失败" + e.getMessage()); return Result.error("操作失败" + e.getMessage());
} }
} }
@@ -687,7 +685,7 @@ public class SrmsApiServiceImpl implements SrmsApiService {
public Result<String> syncPartStandard() { public Result<String> syncPartStandard() {
// 清理数据 // 清理数据
LambdaUpdateWrapper<LawsPartStandard> updateLawsPartStandard = new LambdaUpdateWrapper<>(); LambdaUpdateWrapper<LawsPartStandard> updateLawsPartStandard = new LambdaUpdateWrapper<>();
updateLawsPartStandard.eq(LawsPartStandard::getDelFlag,"0"); updateLawsPartStandard.eq(LawsPartStandard::getDelFlag, "0");
lawsPartStandardService.remove(updateLawsPartStandard); lawsPartStandardService.remove(updateLawsPartStandard);
// 同步数据到分类树标准法规回写表 // 同步数据到分类树标准法规回写表
List<LawsPartStandard> listLawsPartStandard = lawsStandardMapper.getSyncPartStandard(); List<LawsPartStandard> listLawsPartStandard = lawsStandardMapper.getSyncPartStandard();
@@ -703,40 +701,40 @@ public class SrmsApiServiceImpl implements SrmsApiService {
JSONObject messageHeader = new JSONObject(); JSONObject messageHeader = new JSONObject();
String date = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()); String date = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
// todo Interface_ID,UUID // todo Interface_ID,UUID
messageHeader.put("Interface_ID",""); messageHeader.put("Interface_ID", "");
messageHeader.put("UUID",""); messageHeader.put("UUID", "");
messageHeader.put("MessageId",""); messageHeader.put("MessageId", "");
messageHeader.put("Sender","SRMS"); messageHeader.put("Sender", "SRMS");
messageHeader.put("Receiver","PDM"); messageHeader.put("Receiver", "PDM");
messageHeader.put("SendDate",date.substring(0,8)); messageHeader.put("SendDate", date.substring(0, 8));
messageHeader.put("SendTime",date.substring(8)); messageHeader.put("SendTime", date.substring(8));
all.put("MessageHeader",messageHeader); all.put("MessageHeader", messageHeader);
List<JSONObject> listObj = new ArrayList<>(); List<JSONObject> listObj = new ArrayList<>();
if(!CollectionUtils.isEmpty(listLawsPartStandard)){ if (!CollectionUtils.isEmpty(listLawsPartStandard)) {
for (LawsPartStandard lawsPartStandard : listLawsPartStandard) { for (LawsPartStandard lawsPartStandard : listLawsPartStandard) {
JSONObject rows = new JSONObject(); JSONObject rows = new JSONObject();
rows.put(PART_CATEGORY_NUM,lawsPartStandard.getPartCategoryNum()); rows.put(PART_CATEGORY_NUM, lawsPartStandard.getPartCategoryNum());
rows.put("StandardPdmType",lawsPartStandard.getStandardPdmType()); rows.put("StandardPdmType", lawsPartStandard.getStandardPdmType());
rows.put("StandardNumber",lawsPartStandard.getStandardNumber()); rows.put("StandardNumber", lawsPartStandard.getStandardNumber());
rows.put("Remark1",lawsPartStandard.getRemark1()); rows.put("Remark1", lawsPartStandard.getRemark1());
rows.put("Remark2",lawsPartStandard.getRemark2()); rows.put("Remark2", lawsPartStandard.getRemark2());
rows.put("Remark3",lawsPartStandard.getRemark3()); rows.put("Remark3", lawsPartStandard.getRemark3());
listObj.add(rows); listObj.add(rows);
} }
} }
JSONObject requests = new JSONObject(); JSONObject requests = new JSONObject();
requests.put("Rows",listObj); requests.put("Rows", listObj);
all.put(REQUESTS,requests); all.put(REQUESTS, requests);
// todo url // todo url
JSONObject reData = restTemplate.postForObject(partStandardUrl,all,JSONObject.class); JSONObject reData = restTemplate.postForObject(partStandardUrl, all, JSONObject.class);
log.info(JSON.toJSONString(reData)); log.info(JSON.toJSONString(reData));
if(!Objects.isNull(reData) && reData.containsKey("Success") && Objects.equals("true",reData.getString("Success"))){ if (!Objects.isNull(reData) && reData.containsKey("Success") && Objects.equals("true", reData.getString("Success"))) {
log.info("分类树标准法规回写接口成功"); log.info("分类树标准法规回写接口成功");
}else{ } else {
log.error("分类树标准法规回写接口失败"); log.error("分类树标准法规回写接口失败");
} }
}catch (Exception e){ } catch (Exception e) {
log.error("分类树标准法规回写接口失败",e); log.error("分类树标准法规回写接口失败", e);
} }
} }
@@ -746,20 +744,20 @@ public class SrmsApiServiceImpl implements SrmsApiService {
try { try {
// 验证Token有效性 // 验证Token有效性
boolean tokenOK = TokenUtils.verifyToken(req, sysBaseAPI, redisUtil); boolean tokenOK = TokenUtils.verifyToken(req, sysBaseAPI, redisUtil);
if(!tokenOK){ if (!tokenOK) {
return Result.error(403,SYS_ERR); return Result.error(403, SYS_ERR);
} }
} catch (Exception ignored) { } catch (Exception ignored) {
return Result.error(403,SYS_ERR); return Result.error(403, SYS_ERR);
} }
JSONObject requests = JSON.parseObject(JSON.toJSONString(json.get(REQUESTS))); JSONObject requests = JSON.parseObject(JSON.toJSONString(json.get(REQUESTS)));
JSONArray rows = JSON.parseArray(JSON.toJSONString(requests.get("Rows"))); JSONArray rows = JSON.parseArray(JSON.toJSONString(requests.get("Rows")));
if(CollectionUtils.isEmpty(rows)){ if (CollectionUtils.isEmpty(rows)) {
return Result.error(ADD_NOT_NULL); return Result.error(ADD_NOT_NULL);
} }
for (Object request : rows) { for (Object request : rows) {
JSONObject js = JSON.parseObject(JSON.toJSONString(request)); JSONObject js = JSON.parseObject(JSON.toJSONString(request));
if(js.containsKey("PartNum") && StringUtils.isBlank(js.getString("PartNum"))){ if (js.containsKey("PartNum") && StringUtils.isBlank(js.getString("PartNum"))) {
return Result.error(ADD_NOT_NULL); return Result.error(ADD_NOT_NULL);
} }
} }
@@ -770,8 +768,8 @@ public class SrmsApiServiceImpl implements SrmsApiService {
// todo // todo
} }
return Result.OK(listObj); return Result.OK(listObj);
}catch (Exception e){ } catch (Exception e) {
log.error("设计导航-产品设计条款查询异常:",e); log.error("设计导航-产品设计条款查询异常:", e);
return Result.error("操作失败" + e.getMessage()); return Result.error("操作失败" + e.getMessage());
} }
} }
@@ -806,46 +804,51 @@ public class SrmsApiServiceImpl implements SrmsApiService {
} }
@Override @Override
public boolean validPartNoEdit(@NotNull String partNo, String partName, @NotNull String bindUserInfo) { public void validPartNoEdit(@NotNull String partNo, String partName, @NotNull String bindUserInfo) {
try { JSONObject all = new JSONObject();
JSONObject all = new JSONObject(); all.put(MESSAGE_HANDLER, getMessageHandler("CNHTC_PO1000495", null));
all.put(MESSAGE_HANDLER, getMessageHandler("CNHTC_PO1000495", null)); JSONObject requests = new JSONObject();
JSONObject requests = new JSONObject(); requests.put("PartNum", partNo);
requests.put("PartNum", partNo); requests.put("PartName", partName);
requests.put("PartName", partName); requests.put("BindUserInfo", bindUserInfo);
requests.put("BindUserInfo", bindUserInfo); requests.put("Remark1", "");
requests.put("Remark1", ""); requests.put("Remark2", "");
requests.put("Remark2", ""); requests.put("Remark3", "");
requests.put("Remark3", ""); all.put(REQUESTS, requests);
all.put(REQUESTS, requests);
// 创建 HttpEntity 包含请求体和头信息 // 创建 HttpEntity 包含请求体和头信息
HttpHeaders headers = this.getBasicAuthHeaders(); HttpHeaders headers = this.getBasicAuthHeaders();
HttpEntity<String> entity = new HttpEntity<>(all.toString(), headers); HttpEntity<String> entity = new HttpEntity<>(all.toString(), headers);
// 打印完整的请求报文信息 // 打印完整的请求报文信息
log.info("发送验证零部件是否可修改请求"); log.info("发送验证零部件是否可修改请求");
log.info("IP: " + pdmIp + editValidUrl); log.info("IP: " + pdmIp + editValidUrl);
log.info("Headers: " + headers.toString()); log.info("Headers: " + headers.toString());
log.info("Request body: " + all.toString()); log.info("Request body: " + all.toString());
JSONObject reData = restTemplate.postForObject(pdmIp + editValidUrl, entity, JSONObject.class); JSONObject reData = restTemplate.postForObject(pdmIp + editValidUrl, entity, JSONObject.class);
log.info("接收验证零部件是否可修改请求返回"); log.info("接收验证零部件是否可修改请求返回");
log.info("Response: " + JSON.toJSONString(reData)); log.info("返回报文: " + JSON.toJSONString(reData));
if (!Objects.isNull(reData) && reData.containsKey("Success")) { JSONObject response = null;
String success = reData.getString("Success"); if (!Objects.isNull(reData) && reData.containsKey("Responses")) {
if ("true".equals(success)) { response = reData.getJSONObject("Responses");
log.info("验证零部件号是否可修改接口成功");
return true;
}
if ("false".equals(success)) {
log.error("验证零部件号是否可修改接口失败");
return false;
}
}
} catch (Exception e) {
log.error("验证零部件号是否可修改异常", e);
} }
return false; 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 @Override
@@ -877,12 +880,17 @@ public class SrmsApiServiceImpl implements SrmsApiService {
log.info("Response: " + JSON.toJSONString(reData)); log.info("Response: " + JSON.toJSONString(reData));
if (!Objects.isNull(reData) && reData.containsKey("Success")) { if (!Objects.isNull(reData) && reData.containsKey("Success")) {
String success = reData.getString("Success"); String success = reData.getString("Success");
String message = "";
if (reData.containsKey("Message")) {
message = reData.getString("Message");
}
if ("true".equals(success)) { if ("true".equals(success)) {
log.info("校验某个零部件是否所属于某个零部件分类接口成功"); log.info("校验某个零部件是否所属于某个零部件分类接口成功");
return true; return true;
} }
if ("false".equals(success)) { if ("false".equals(success)) {
log.error("校验某个零部件是否所属于某个零部件分类接口失败"); log.error("校验某个零部件是否所属于某个零部件分类接口失败");
log.error("失败原因: " + message);
return false; return false;
} }
} }