|
|
|
@ -1,9 +1,12 @@ |
|
|
|
package com.spring.modules.part.service.impl; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.spring.common.utils.PageUtils; |
|
|
|
import com.spring.ifs.api.IfsServer; |
|
|
|
import com.spring.ifs.bean.RoutingServiceBean; |
|
|
|
import com.spring.modules.base.utils.HttpClientUtil; |
|
|
|
import com.spring.modules.base.utils.ResponseData; |
|
|
|
import com.spring.modules.part.entity.*; |
|
|
|
@ -16,6 +19,9 @@ import com.spring.modules.part.mapper.WorkGuidelinesMapper; |
|
|
|
import com.spring.modules.part.service.BomSearch3Service; |
|
|
|
import com.spring.modules.part.service.WorkGuidelinesService; |
|
|
|
import com.spring.modules.part.vo.*; |
|
|
|
import com.spring.modules.sys.dao.SysUserDao; |
|
|
|
import com.spring.modules.sys.entity.SysUserEntity; |
|
|
|
import ifs.fnd.ap.Server; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
@ -25,6 +31,7 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.LinkedList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
@Service |
|
|
|
public class WorkGuidelinesServiceImpl implements WorkGuidelinesService { |
|
|
|
@ -35,12 +42,33 @@ public class WorkGuidelinesServiceImpl implements WorkGuidelinesService { |
|
|
|
@Autowired |
|
|
|
private RoutingManagementMapper routingManagementMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private IfsServer ifsServer; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private SysUserDao sysUserDao; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private RoutingServiceBean routingServiceBean; |
|
|
|
|
|
|
|
@Value("${ifs-api.api-url}") |
|
|
|
private String apiUrl; |
|
|
|
|
|
|
|
@Value("${ifs-control.control-flag}") |
|
|
|
private Boolean dataUrl; |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取ifsServer |
|
|
|
*/ |
|
|
|
private Server getIfsServer(String username) { |
|
|
|
SysUserEntity ifsUser = sysUserDao.selectOne(new QueryWrapper<SysUserEntity>().eq("username", username)); |
|
|
|
if (ifsUser == null || !org.apache.commons.lang3.StringUtils.isNotBlank(ifsUser.getIfsUsername()) || !org.apache.commons.lang3.StringUtils.isNotBlank(ifsUser.getIfsPassword())) { |
|
|
|
throw new RuntimeException("获取用户的IFS账号密码为空值!"); |
|
|
|
} |
|
|
|
Server srv = ifsServer.getIfsServer(ifsUser.getIfsUsername(), ifsUser.getIfsPassword()); |
|
|
|
return srv; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* routing 替代列表查询 |
|
|
|
* @param data |
|
|
|
@ -92,6 +120,7 @@ public class WorkGuidelinesServiceImpl implements WorkGuidelinesService { |
|
|
|
|
|
|
|
if (dataUrl) { |
|
|
|
// 判断是否为正式替代 |
|
|
|
Server srv = getIfsServer(data.getCreateBy()); |
|
|
|
RoutingDetailEntity routingDetailEntity = new RoutingDetailEntity(); |
|
|
|
BeanUtils.copyProperties(data, routingDetailEntity); |
|
|
|
List<RoutingDetailEntity> checkList = routingManagementMapper.checkRoutingDetailOnlyOne(routingDetailEntity); |
|
|
|
@ -118,16 +147,15 @@ public class WorkGuidelinesServiceImpl implements WorkGuidelinesService { |
|
|
|
routingIfsGuideLine.setIfsRowId(componentEntity.getIfsRowId()); |
|
|
|
routingIfsGuideLine.setIfsRowVersion(componentEntity.getIfsRowVersion()); |
|
|
|
routingIfsGuideLines.add(routingIfsGuideLine); |
|
|
|
String saveRoutingGuidelineURL = apiUrl + "/routing/ifs/syncRoutingIfsGuideLinesToIfs"; |
|
|
|
ResponseData saveRoutingGuidelineResponse = HttpClientUtil.doPostByRawWithPLM(saveRoutingGuidelineURL, routingIfsGuideLines); |
|
|
|
if (!"200".equals(saveRoutingGuidelineResponse.getCode())) { |
|
|
|
throw new RuntimeException("IFS RoutingGuideline新增异常:" + saveRoutingGuidelineResponse.getMsg()); |
|
|
|
Map<String, String> addRoutingGuidelineResponse = routingServiceBean.syncRoutingGuideLines(srv, routingIfsGuideLines); |
|
|
|
if (!"200".equals(addRoutingGuidelineResponse.get("resultCode"))) { |
|
|
|
throw new RuntimeException("IFS RoutingGuideline新增异常:" + addRoutingGuidelineResponse.get("resultMsg")); |
|
|
|
} |
|
|
|
String s = String.valueOf(saveRoutingGuidelineResponse.getObj()); |
|
|
|
List<RoutingIfsGuideLine> routingGuideline = JSON.parseArray(s, RoutingIfsGuideLine.class); |
|
|
|
if (!routingGuideline.isEmpty()) { |
|
|
|
for (RoutingIfsGuideLine routingIfsTool : routingGuideline) { |
|
|
|
routingManagementMapper.updateIfsGuidelineRowKeyAndRevision(routingIfsTool); |
|
|
|
String RoutingGuidelineObj = String.valueOf(addRoutingGuidelineResponse.get("obj")); |
|
|
|
List<RoutingIfsGuideLine> ifsGuidelines = JSON.parseArray(RoutingGuidelineObj, RoutingIfsGuideLine.class); |
|
|
|
if (!ifsGuidelines.isEmpty()) { |
|
|
|
for (RoutingIfsGuideLine ifsGuideline : ifsGuidelines) { // 修改ifs关键字 |
|
|
|
routingManagementMapper.updateIfsGuidelineRowKeyAndRevision(ifsGuideline); |
|
|
|
} |
|
|
|
} else { |
|
|
|
throw new RuntimeException("IFS RoutingGuideline新增接口返回值异常!"); |
|
|
|
@ -147,18 +175,18 @@ public class WorkGuidelinesServiceImpl implements WorkGuidelinesService { |
|
|
|
|
|
|
|
if (dataUrl) { |
|
|
|
// 判断是否为正式替代 |
|
|
|
Server srv = getIfsServer(data.getUpdateBy()); |
|
|
|
RoutingDetailEntity routingDetailEntity = new RoutingDetailEntity(); |
|
|
|
BeanUtils.copyProperties(data, routingDetailEntity); |
|
|
|
List<RoutingDetailEntity> checkList = routingManagementMapper.checkRoutingDetailOnlyOne(routingDetailEntity); |
|
|
|
if ("Y".equals(checkList.get(0).getOfficialFlag())) { |
|
|
|
RoutingIfsGuideLine routingIfsGuideLine = workGuidelinesMapper.getRoutingGuidelineToIfs(data.getId()); |
|
|
|
String updateRoutingGuidelineURL = apiUrl + "/routing/ifs/modifyRoutingIfsGuideLineToIfs"; |
|
|
|
ResponseData updateRoutingGuidelineResponse = HttpClientUtil.doPostByRawWithPLM(updateRoutingGuidelineURL, routingIfsGuideLine); |
|
|
|
if (!"200".equals(updateRoutingGuidelineResponse.getCode())) { |
|
|
|
throw new RuntimeException("IFS RoutingGuideline修改异常:" + updateRoutingGuidelineResponse.getMsg()); |
|
|
|
Map<String, String> updateRoutingGuidelineResponse = routingServiceBean.modifyRoutingGuideLine(srv, routingIfsGuideLine); |
|
|
|
if (!"200".equals(updateRoutingGuidelineResponse.get("resultCode"))) { |
|
|
|
throw new RuntimeException("IFS RoutingGuideline修改异常:" + updateRoutingGuidelineResponse.get("resultMsg")); |
|
|
|
} |
|
|
|
// 更新 ifs_row_id ifs_row_version |
|
|
|
String s = String.valueOf(updateRoutingGuidelineResponse.getObj()); |
|
|
|
String s = String.valueOf(updateRoutingGuidelineResponse.get("obj")); |
|
|
|
RoutingIfsGuideLine ifsGuidelines = JSON.parseObject(s, RoutingIfsGuideLine.class); |
|
|
|
if (ifsGuidelines != null) { |
|
|
|
data.setIfsRowId(ifsGuidelines.getIfsRowId()); |
|
|
|
@ -190,10 +218,10 @@ public class WorkGuidelinesServiceImpl implements WorkGuidelinesService { |
|
|
|
} |
|
|
|
if (dataUrl) { |
|
|
|
if ("Y".equals(checkList.get(0).getOfficialFlag())) { |
|
|
|
String deleteRoutingGuidelineURL = apiUrl + "/routing/ifs/removeRoutingIfsGuideLinesToIfs"; |
|
|
|
ResponseData deleteRoutingGuidelineResponse = HttpClientUtil.doPostByRawWithPLM(deleteRoutingGuidelineURL, routingIfsGuideLines); |
|
|
|
if (!"200".equals(deleteRoutingGuidelineResponse.getCode())) { |
|
|
|
throw new RuntimeException("IFS RoutingGuideline删除异常:" + deleteRoutingGuidelineResponse.getMsg()); |
|
|
|
Server srv = getIfsServer(data.getUpdateBy()); |
|
|
|
Map<String, String> deleteRoutingGuidelineResponse = routingServiceBean.removeRoutingGuideLines(srv, routingIfsGuideLines); |
|
|
|
if (!"200".equals(deleteRoutingGuidelineResponse.get("resultCode"))) { |
|
|
|
throw new RuntimeException("IFS RoutingGuideline删除异常:" + deleteRoutingGuidelineResponse.get("resultMsg")); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|