From 7db6d5660842f189fdf95a0d08a0172e46440652 Mon Sep 17 00:00:00 2001 From: Rui_Li <877258667@qq.com> Date: Fri, 25 Apr 2025 10:18:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E5=85=B7=E4=B8=9A=E5=8A=A1=20BUG=20?= =?UTF-8?q?=E4=BF=AE=E5=B0=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/Impl/PropertiesServiceImpl.java | 34 ++++++++++++++----- src/main/resources/application.yml | 4 +-- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/spring/modules/base/service/Impl/PropertiesServiceImpl.java b/src/main/java/com/spring/modules/base/service/Impl/PropertiesServiceImpl.java index e6b4ea95..1448be85 100644 --- a/src/main/java/com/spring/modules/base/service/Impl/PropertiesServiceImpl.java +++ b/src/main/java/com/spring/modules/base/service/Impl/PropertiesServiceImpl.java @@ -1,10 +1,13 @@ package com.spring.modules.base.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.exception.XJException; 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.data.TechnicalClass; 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.utils.HttpClientUtil; 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.project.dao.ProjectDao; import com.spring.modules.project.data.PlmProjectPartData; 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.SysMenuEntity; import com.spring.modules.sys.entity.SysUserEntity; +import ifs.fnd.ap.Server; import org.apache.shiro.SecurityUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -48,7 +54,12 @@ public class PropertiesServiceImpl implements PropertiesService { @Autowired private PartInformationMapper partInformationMapper; @Autowired - private BaseConfigDao baseConfigDao; + private IfsServer ifsServer; + + @Autowired + private SysUserDao sysUserDao; + @Autowired + private TechnicalClassBean technicalClassBean; //接口使用的参数 @Value("${ifs-api.api-url}") @@ -466,6 +477,12 @@ public class PropertiesServiceImpl implements PropertiesService { * @version 1.0 */ public void syncToolPropertyValues(List datas, String recordType) { + String username = ((SysUserEntity) SecurityUtils.getSubject().getPrincipal()).getUsername(); + SysUserEntity ifsUser = sysUserDao.selectOne(new QueryWrapper().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 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]+"^"; } //循环产生数据 - List propertyList = new ArrayList<>(); + List propertyList = new ArrayList<>(); //遍历插入数据 for(PartSubPropertiesValue propertyValue : datas){ String attribute = propertyValue.getPropertiesItemNo(); @@ -491,17 +508,17 @@ public class PropertiesServiceImpl implements PropertiesService { Double numValue = propertyValue.getNumValue(); String numValueStr = ""; //null处理 - if(null == textValue){ + if(null == textValue || "".equals(textValue)){ textValue = ""; } if(null == numValue){ - numValueStr = ""; + numValue = 0.0; }else { numValueStr = String.valueOf(numValue); BigDecimal bd = new BigDecimal(numValueStr).stripTrailingZeros(); numValueStr = bd.toString(); } - TechnicalClassAttribute technicalAttribute = new TechnicalClassAttribute(); + PartIfsCatalogProperty technicalAttribute = new PartIfsCatalogProperty(); technicalAttribute.setLuName(luName); technicalAttribute.setKeyRef(keyRef); technicalAttribute.setTechnicalClass(technicalClassNo); @@ -520,10 +537,9 @@ public class PropertiesServiceImpl implements PropertiesService { propertyList.add(technicalAttribute); } //调用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 addMasterPartPropertyResponse = technicalClassBean.modifyTechnicalClassAttributes(srv, propertyList); + if (!"200".equals(addMasterPartPropertyResponse.get("resultCode"))) { + throw new RuntimeException("IFS 物料件属性新增异常:" + addMasterPartPropertyResponse.get("resultMsg")); } } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 8d03530b..4991275b 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -36,8 +36,8 @@ spring: redis: open: false # 是否开启redis缓存 true开启 false关闭 database: 0 - host: 192.168.1.83 - port: 6379 + host: 47.102.202.239 + port: 8379 password: xujieredis # 密码(默认为空) timeout: 6000ms # 连接超时时长(毫秒) jedis: