Browse Source

工具业务 BUG 修尬

master
Rui_Li 9 months ago
parent
commit
7db6d56608
  1. 34
      src/main/java/com/spring/modules/base/service/Impl/PropertiesServiceImpl.java
  2. 4
      src/main/resources/application.yml

34
src/main/java/com/spring/modules/base/service/Impl/PropertiesServiceImpl.java

@ -1,10 +1,13 @@
package com.spring.modules.base.service.Impl; package com.spring.modules.base.service.Impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.spring.common.exception.XJException; import com.spring.common.exception.XJException;
import com.spring.common.utils.PageUtils; import com.spring.common.utils.PageUtils;
import com.spring.ifs.api.IfsServer;
import com.spring.ifs.bean.TechnicalClassBean;
import com.spring.modules.Tooling.dao.BaseConfigDao; import com.spring.modules.Tooling.dao.BaseConfigDao;
import com.spring.modules.Tooling.data.TechnicalClass; import com.spring.modules.Tooling.data.TechnicalClass;
import com.spring.modules.Tooling.data.TechnicalClassAttribute; import com.spring.modules.Tooling.data.TechnicalClassAttribute;
@ -16,13 +19,16 @@ import com.spring.modules.base.service.PropertiesGroupService;
import com.spring.modules.base.service.PropertiesService; import com.spring.modules.base.service.PropertiesService;
import com.spring.modules.base.utils.HttpClientUtil; import com.spring.modules.base.utils.HttpClientUtil;
import com.spring.modules.base.utils.ResponseData; import com.spring.modules.base.utils.ResponseData;
import com.spring.modules.part.entity.APIEntity.PartIfsCatalogProperty;
import com.spring.modules.part.mapper.PartInformationMapper; import com.spring.modules.part.mapper.PartInformationMapper;
import com.spring.modules.project.dao.ProjectDao; import com.spring.modules.project.dao.ProjectDao;
import com.spring.modules.project.data.PlmProjectPartData; import com.spring.modules.project.data.PlmProjectPartData;
import com.spring.modules.report.dao.ProcedureDao; import com.spring.modules.report.dao.ProcedureDao;
import com.spring.modules.sys.dao.SysUserDao;
import com.spring.modules.sys.entity.DictData; import com.spring.modules.sys.entity.DictData;
import com.spring.modules.sys.entity.SysMenuEntity; import com.spring.modules.sys.entity.SysMenuEntity;
import com.spring.modules.sys.entity.SysUserEntity; import com.spring.modules.sys.entity.SysUserEntity;
import ifs.fnd.ap.Server;
import org.apache.shiro.SecurityUtils; import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
@ -48,7 +54,12 @@ public class PropertiesServiceImpl implements PropertiesService {
@Autowired @Autowired
private PartInformationMapper partInformationMapper; private PartInformationMapper partInformationMapper;
@Autowired @Autowired
private BaseConfigDao baseConfigDao;
private IfsServer ifsServer;
@Autowired
private SysUserDao sysUserDao;
@Autowired
private TechnicalClassBean technicalClassBean;
//接口使用的参数 //接口使用的参数
@Value("${ifs-api.api-url}") @Value("${ifs-api.api-url}")
@ -466,6 +477,12 @@ public class PropertiesServiceImpl implements PropertiesService {
* @version 1.0 * @version 1.0
*/ */
public void syncToolPropertyValues(List<PartSubPropertiesValue> datas, String recordType) { public void syncToolPropertyValues(List<PartSubPropertiesValue> datas, String recordType) {
String username = ((SysUserEntity) SecurityUtils.getSubject().getPrincipal()).getUsername();
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());
//需要区分是工具的属性还是工具实例的属性 //需要区分是工具的属性还是工具实例的属性
String site = datas.get(0).getSite(); String site = datas.get(0).getSite();
String partNo = datas.get(0).getPartNo(); String partNo = datas.get(0).getPartNo();
@ -482,7 +499,7 @@ public class PropertiesServiceImpl implements PropertiesService {
keyRef = "CONTRACT="+site+"^TOOL_ID="+toolArr[0]+"^TOOL_INSTANCE="+toolArr[1]+"^"; keyRef = "CONTRACT="+site+"^TOOL_ID="+toolArr[0]+"^TOOL_INSTANCE="+toolArr[1]+"^";
} }
//循环产生数据 //循环产生数据
List<TechnicalClass> propertyList = new ArrayList<>();
List<PartIfsCatalogProperty> propertyList = new ArrayList<>();
//遍历插入数据 //遍历插入数据
for(PartSubPropertiesValue propertyValue : datas){ for(PartSubPropertiesValue propertyValue : datas){
String attribute = propertyValue.getPropertiesItemNo(); String attribute = propertyValue.getPropertiesItemNo();
@ -491,17 +508,17 @@ public class PropertiesServiceImpl implements PropertiesService {
Double numValue = propertyValue.getNumValue(); Double numValue = propertyValue.getNumValue();
String numValueStr = ""; String numValueStr = "";
//null处理 //null处理
if(null == textValue){
if(null == textValue || "".equals(textValue)){
textValue = ""; textValue = "";
} }
if(null == numValue){ if(null == numValue){
numValueStr = "";
numValue = 0.0;
}else { }else {
numValueStr = String.valueOf(numValue); numValueStr = String.valueOf(numValue);
BigDecimal bd = new BigDecimal(numValueStr).stripTrailingZeros(); BigDecimal bd = new BigDecimal(numValueStr).stripTrailingZeros();
numValueStr = bd.toString(); numValueStr = bd.toString();
} }
TechnicalClassAttribute technicalAttribute = new TechnicalClassAttribute();
PartIfsCatalogProperty technicalAttribute = new PartIfsCatalogProperty();
technicalAttribute.setLuName(luName); technicalAttribute.setLuName(luName);
technicalAttribute.setKeyRef(keyRef); technicalAttribute.setKeyRef(keyRef);
technicalAttribute.setTechnicalClass(technicalClassNo); technicalAttribute.setTechnicalClass(technicalClassNo);
@ -520,10 +537,9 @@ public class PropertiesServiceImpl implements PropertiesService {
propertyList.add(technicalAttribute); propertyList.add(technicalAttribute);
} }
//调用ifs的api //调用ifs的api
String toolURL = apiUrl + "/technical/class/modifyTechnicalClassAttributes";
ResponseData toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, propertyList);
if (!"200".equals(toolResponse.getCode())) {
throw new RuntimeException("IFS Tool属性修改异常:" + toolResponse.getMsg());
Map<String, String> addMasterPartPropertyResponse = technicalClassBean.modifyTechnicalClassAttributes(srv, propertyList);
if (!"200".equals(addMasterPartPropertyResponse.get("resultCode"))) {
throw new RuntimeException("IFS 物料件属性新增异常:" + addMasterPartPropertyResponse.get("resultMsg"));
} }
} }

4
src/main/resources/application.yml

@ -36,8 +36,8 @@ spring:
redis: redis:
open: false # 是否开启redis缓存 true开启 false关闭 open: false # 是否开启redis缓存 true开启 false关闭
database: 0 database: 0
host: 192.168.1.83
port: 6379
host: 47.102.202.239
port: 8379
password: xujieredis # 密码(默认为空) password: xujieredis # 密码(默认为空)
timeout: 6000ms # 连接超时时长(毫秒) timeout: 6000ms # 连接超时时长(毫秒)
jedis: jedis:

Loading…
Cancel
Save