|
|
|
@ -3,8 +3,11 @@ package com.spring.modules.Tooling.service.impl; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.spring.ifs.api.IfsServer; |
|
|
|
import com.spring.ifs.bean.BaseSearchBean; |
|
|
|
import com.spring.ifs.bean.TechnicalClassBean; |
|
|
|
import com.spring.ifs.bean.ToolServiceBean; |
|
|
|
import com.spring.ifs.data.BaseSearchData; |
|
|
|
import com.spring.ifs.data.TechnicalAttribute; |
|
|
|
import com.spring.modules.Tooling.dao.BaseConfigDao; |
|
|
|
import com.spring.modules.Tooling.data.*; |
|
|
|
import com.spring.modules.Tooling.dao.ToolDao; |
|
|
|
@ -12,12 +15,16 @@ import com.spring.modules.Tooling.entity.IfsTool; |
|
|
|
import com.spring.modules.Tooling.entity.IfsToolInstance; |
|
|
|
import com.spring.modules.Tooling.entity.IfsToolInstanceDate; |
|
|
|
import com.spring.modules.Tooling.service.ToolService; |
|
|
|
import com.spring.modules.base.data.PartSubPropertiesValueData; |
|
|
|
import com.spring.modules.base.data.PlmPropertiesItemData; |
|
|
|
import com.spring.modules.base.utils.DateUtils; |
|
|
|
import com.spring.modules.part.entity.APIEntity.PartIfsCatalogModel; |
|
|
|
import com.spring.modules.part.mapper.PartInformationMapper; |
|
|
|
import com.spring.modules.report.dao.ProcedureDao; |
|
|
|
import com.spring.modules.sys.dao.SysUserDao; |
|
|
|
import com.spring.modules.sys.entity.SysUserEntity; |
|
|
|
import ifs.fnd.ap.Server; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.shiro.SecurityUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
@ -52,6 +59,10 @@ public class ToolServiceImpl implements ToolService { |
|
|
|
private TechnicalClassBean technicalClassBean; |
|
|
|
@Autowired |
|
|
|
private SysUserDao sysUserDao; |
|
|
|
@Autowired |
|
|
|
private BaseSearchBean baseSearchBean; |
|
|
|
@Autowired |
|
|
|
private PartInformationMapper partInformationMapper; |
|
|
|
|
|
|
|
private static final Logger logger = org.slf4j.LoggerFactory.getLogger(ToolServiceImpl.class); |
|
|
|
|
|
|
|
@ -938,6 +949,89 @@ public class ToolServiceImpl implements ToolService { |
|
|
|
return inData; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
public void syncIfsProperties(PlmPropertiesItemData inData) { |
|
|
|
//公共参数 |
|
|
|
String site = inData.getSite(); |
|
|
|
String partNo = inData.getPartNo(); |
|
|
|
String codeNo = inData.getCodeNo(); |
|
|
|
String recordType = inData.getRecordType(); |
|
|
|
//1.获取IFS属性 |
|
|
|
//获取当前操作的账号 |
|
|
|
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账号和密码!"); |
|
|
|
} |
|
|
|
String ifsUsername = ifsUser.getIfsUsername(); |
|
|
|
String ifsPassword = ifsUser.getIfsPassword(); |
|
|
|
//获取链接 |
|
|
|
Server srv = srv = ifsServer.getIfsServer(ifsUsername, ifsPassword); |
|
|
|
//区分不同类型 设置不同的参数 |
|
|
|
BaseSearchData baseSearchData = new BaseSearchData(); |
|
|
|
if("TL".equalsIgnoreCase(recordType)){ |
|
|
|
baseSearchData.setLuName("ManufTool"); |
|
|
|
baseSearchData.setKeyRef("CONTRACT="+site+"^TOOL_ID="+partNo+"^"); |
|
|
|
}else if("TLI".equalsIgnoreCase(recordType)){ |
|
|
|
baseSearchData.setLuName("ManufToolDetail"); |
|
|
|
String[] toolArr = partNo.split("#"); |
|
|
|
String keyRef = "CONTRACT="+site+"^TOOL_ID="+toolArr[0]+"^TOOL_INSTANCE="+toolArr[1]+"^"; |
|
|
|
baseSearchData.setKeyRef(keyRef); |
|
|
|
} |
|
|
|
|
|
|
|
Map<String, String> getInfoResponse = baseSearchBean.getTechnicalAttributesByCon(srv, baseSearchData); |
|
|
|
if (!"200".equals(getInfoResponse.get("resultCode"))) { |
|
|
|
throw new RuntimeException("IFS 获取物料件属性异常信息:" + getInfoResponse.get("resultMsg")); |
|
|
|
} |
|
|
|
String s = String.valueOf(getInfoResponse.get("obj")); |
|
|
|
List<TechnicalAttribute> ifsItems = JSON.parseArray(s, TechnicalAttribute.class); |
|
|
|
if (ifsItems.isEmpty()) { |
|
|
|
throw new RuntimeException("IFS 获取物料件属性为空值!"); |
|
|
|
} |
|
|
|
// 转成PLM对象 |
|
|
|
List<PartSubPropertiesValueData> arrayList = new ArrayList<>(); |
|
|
|
int itemNo = 1; |
|
|
|
for (TechnicalAttribute item : ifsItems) { |
|
|
|
PartSubPropertiesValueData valueData = new PartSubPropertiesValueData(); |
|
|
|
valueData.setSite(site); |
|
|
|
valueData.setPartNo(partNo); |
|
|
|
valueData.setCodeNo(codeNo); |
|
|
|
valueData.setSubCodeSeqNo(Double.valueOf("1")); |
|
|
|
valueData.setItemNo((double) itemNo++); |
|
|
|
valueData.setPropertiesItemNo(item.getAttribute()); |
|
|
|
if ("Numeric".equals(item.getAttributeType())) { |
|
|
|
valueData.setNumValue(StringUtils.isNotBlank(item.getValueNo()) ? Double.valueOf(item.getValueNo()) : null); |
|
|
|
} else { |
|
|
|
valueData.setTextValue(item.getValueText() == null ? "" : item.getValueText()); |
|
|
|
} |
|
|
|
valueData.setRecordType(recordType); |
|
|
|
arrayList.add(valueData); |
|
|
|
} |
|
|
|
//调用存储过程 删除数据 |
|
|
|
this.deletePartSubPropertiesForSyncIfs(site, partNo, codeNo, recordType); |
|
|
|
//批量新增属性 |
|
|
|
partInformationMapper.savePartSubPropertiesValues(arrayList); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @description: 调用存储过程 删除属性数据 为同步IFS数据 |
|
|
|
* @author HP |
|
|
|
* @date 2025/11/25 11:39 |
|
|
|
* @version 1.0 |
|
|
|
*/ |
|
|
|
public Map<String, Object> deletePartSubPropertiesForSyncIfs(String site, String partNo, String codeNo, String recordType) { |
|
|
|
List<Object> params = new ArrayList<>(); |
|
|
|
params.add(site); |
|
|
|
params.add(partNo); |
|
|
|
params.add(codeNo); |
|
|
|
params.add(recordType); |
|
|
|
//调用存储过程 |
|
|
|
List<Map<String, Object>> resultList = procedureDao.getProcedureData("deletePartSubPropertiesForSyncIfs", params); |
|
|
|
//处理返回的结果 |
|
|
|
return resultList.get(0); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @description: 获取工具的下一个编码 |
|
|
|
* @author LR |
|
|
|
|