|
|
|
@ -14,7 +14,9 @@ import com.spring.ifs.api.IfsServer; |
|
|
|
import com.spring.ifs.bean.BaseSearchBean; |
|
|
|
import com.spring.ifs.bean.InventoryServiceBean; |
|
|
|
import com.spring.ifs.bean.MasterServiceBean; |
|
|
|
import com.spring.ifs.bean.TechnicalClassBean; |
|
|
|
import com.spring.ifs.data.BaseSearchData; |
|
|
|
import com.spring.ifs.data.TechnicalAttribute; |
|
|
|
import com.spring.modules.app.dao.UserDao; |
|
|
|
import com.spring.modules.app.service.UserService; |
|
|
|
import com.spring.modules.base.data.PartSubPropertiesValueData; |
|
|
|
@ -71,6 +73,9 @@ public class MasterPartInformationServiceImpl extends ServiceImpl<MasterPartInfo |
|
|
|
@Autowired |
|
|
|
private BaseSearchBean baseSearchBean; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private TechnicalClassBean technicalClassBean; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private IfsServer ifsServer; |
|
|
|
|
|
|
|
@ -293,13 +298,11 @@ public class MasterPartInformationServiceImpl extends ServiceImpl<MasterPartInfo |
|
|
|
public Map<String, Object> checkUpdateMasterPart (MasterPartInformationVo inData) { |
|
|
|
// 公共参数 |
|
|
|
String partNo = inData.getPartNo(); |
|
|
|
String codeNo = inData.getCodeNo(); |
|
|
|
String partMainGroup = inData.getPartMainGroup() == null ? "": inData.getPartMainGroup(); |
|
|
|
String codeNo = inData.getCodeNo() == null ? "" : inData.getCodeNo(); |
|
|
|
String functionType = "MP"; |
|
|
|
List<Object> params = new ArrayList<>(); |
|
|
|
params.add(partNo); |
|
|
|
params.add(codeNo); |
|
|
|
params.add(partMainGroup); |
|
|
|
params.add(functionType); |
|
|
|
// 执行方法 |
|
|
|
List<Map<String, Object>> resultList = procedureDao.getProcedureData("checkUpdateMasterPart", params); |
|
|
|
@ -338,8 +341,8 @@ public class MasterPartInformationServiceImpl extends ServiceImpl<MasterPartInfo |
|
|
|
MasterPartInformationEntity masterPart = masterPartInformationMapper.selectOne(new QueryWrapper<MasterPartInformationEntity>().eq("part_no", data.getPartNo())); |
|
|
|
// 查询是否已存在属性 |
|
|
|
List<PartSubPropertiesValueHeaderData> checkValueHeaderData = partInformationMapper.checkValueHeaderData(data); |
|
|
|
if ("Y".equals(masterPart.getOfficialFlag()) && StringUtils.isNotBlank(masterPart.getCodeNo()) && checkValueHeaderData.isEmpty()) { |
|
|
|
// 如果物料是正式物料 && 选择了模板 && 物料属性是空值,则调用接口查出属性新增 |
|
|
|
if (dataUrl && "Y".equals(masterPart.getOfficialFlag()) && StringUtils.isNotBlank(masterPart.getCodeNo()) && checkValueHeaderData.isEmpty()) { |
|
|
|
// 如果接口开关已打开 && 物料是正式物料 && 选择了模板 && 物料属性是空值,则调用接口查出属性新增 |
|
|
|
Server srv = getIfsServer(data.getUpdateBy()); |
|
|
|
BaseSearchData baseSearchData = new BaseSearchData(); |
|
|
|
baseSearchData.setLuName("PartCatalog"); |
|
|
|
@ -349,20 +352,43 @@ public class MasterPartInformationServiceImpl extends ServiceImpl<MasterPartInfo |
|
|
|
throw new RuntimeException("IFS 获取物料件属性异常信息:" + getInfoResponse.get("resultMsg")); |
|
|
|
} |
|
|
|
String s = String.valueOf(getInfoResponse.get("obj")); |
|
|
|
List<RoutingIfsItem> ifsItems = JSON.parseArray(s, RoutingIfsItem.class); |
|
|
|
|
|
|
|
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("*"); |
|
|
|
valueData.setPartNo(data.getPartNo()); |
|
|
|
valueData.setCodeNo(item.getTechnicalClass()); |
|
|
|
valueData.setSubCodeSeqNo(Double.valueOf("1")); |
|
|
|
valueData.setItemNo((double) itemNo++); |
|
|
|
valueData.setPropertiesItemNo(item.getAttribute()); |
|
|
|
if ("Numeric".equals(item.getAttributeType())) { |
|
|
|
valueData.setNumValue(Double.valueOf(item.getValueNo())); |
|
|
|
} else { |
|
|
|
valueData.setTextValue(item.getValueText() == null ? "" : item.getValueText()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 初次或修改物料模板则重新加载模板 |
|
|
|
if (checkValueHeaderData.isEmpty()) { |
|
|
|
// 删除物料的属性和属性值 |
|
|
|
partInformationMapper.deletePartSubPropertiesValueHeader(data); |
|
|
|
partInformationMapper.deletePartSubPropertiesValue(data); |
|
|
|
// 加载默认属性和属性值 |
|
|
|
partInformationMapper.savePartSubPropertiesValueHeader(data); |
|
|
|
partInformationMapper.savePartSubPropertiesValue(data); |
|
|
|
valueData.setRecordType("MP"); |
|
|
|
arrayList.add(valueData); |
|
|
|
} |
|
|
|
// 物料模板 |
|
|
|
partInformationMapper.savePartSubPropertiesValueHeader(data); |
|
|
|
// 物料属性 |
|
|
|
partInformationMapper.savePartSubPropertiesValues(arrayList); |
|
|
|
} |
|
|
|
// else if (checkValueHeaderData.isEmpty()){ |
|
|
|
// // 初次或修改物料模板则重新加载模板 |
|
|
|
// // 删除物料的属性和属性值 |
|
|
|
// partInformationMapper.deletePartSubPropertiesValueHeader(data); |
|
|
|
// partInformationMapper.deletePartSubPropertiesValue(data); |
|
|
|
// // 加载默认属性和属性值 |
|
|
|
// partInformationMapper.savePartSubPropertiesValueHeader(data); |
|
|
|
// partInformationMapper.savePartSubPropertiesValue(data); |
|
|
|
// } |
|
|
|
List<PartSubPropertiesValueData> result = partInformationMapper.getItemModal(data); |
|
|
|
for (int i = 0; i < result.size(); i++) { |
|
|
|
if ("Y".equals(result.get(i).getValueChooseFlag())) { |
|
|
|
@ -421,6 +447,9 @@ public class MasterPartInformationServiceImpl extends ServiceImpl<MasterPartInfo |
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
public void addMasterPartItem(PartSubPropertiesValueData inData) { |
|
|
|
Server srv = getIfsServer(inData.getUpdateBy()); |
|
|
|
List<PartIfsCatalogProperty> ifsProperty = new ArrayList<>(); |
|
|
|
MasterPartInformationEntity partData = masterPartInformationMapper.selectOne(new QueryWrapper<MasterPartInformationEntity>().eq("part_no", inData.getPartNo())); |
|
|
|
for(PartSubPropertiesValueData itemDate : inData.getItemList()) { |
|
|
|
itemDate.setSite(inData.getSite()); |
|
|
|
itemDate.setPartNo(inData.getPartNo()); |
|
|
|
@ -438,8 +467,32 @@ public class MasterPartInformationServiceImpl extends ServiceImpl<MasterPartInfo |
|
|
|
} |
|
|
|
itemDate.setItemNo(partInformationMapper.getModalDetailSeqNo(itemDate)); |
|
|
|
partInformationMapper.addPartItem(itemDate); |
|
|
|
|
|
|
|
if (dataUrl && "Y".equals(partData.getOfficialFlag())) { |
|
|
|
PartIfsCatalogProperty property = new PartIfsCatalogProperty(); |
|
|
|
property.setLuName(luName); |
|
|
|
property.setKeyRef("PART_NO=" + itemDate.getPartNo() + "^"); // 物料编码 |
|
|
|
property.setTechnicalClass(itemDate.getCodeNo()); // 模板编码 |
|
|
|
property.setAttribute(itemDate.getPropertiesItemNo()); // 属性编码 |
|
|
|
property.setAttributeType("N".equals(itemDate.getValueTypeDb()) ? "Numeric" : "T".equals(itemDate.getValueTypeDb()) ? "Alpha" : ""); // 属性类型 |
|
|
|
property.setValueText(itemDate.getTextValue() == null ? "" : itemDate.getTextValue()); // 文本值 |
|
|
|
property.setValueNo(itemDate.getNumValue() == null ? "" : itemDate.getNumValue().toString()); // 数字值 |
|
|
|
property.setLowerLimit(""); |
|
|
|
property.setUpperLimit(""); |
|
|
|
property.setInfo(""); |
|
|
|
ifsProperty.add(property); |
|
|
|
} |
|
|
|
} |
|
|
|
// 同步IFS |
|
|
|
// if (dataUrl && "Y".equals(partData.getOfficialFlag())) { |
|
|
|
// if (!ifsProperty.isEmpty()) { |
|
|
|
// Map<String, String> addMasterPartPropertyResponse = technicalClassBean.syncTechnicalClass(srv, ifsProperty); |
|
|
|
// if (!"200".equals(addMasterPartPropertyResponse.get("resultCode"))) { |
|
|
|
// throw new RuntimeException("IFS物料属性新增异常:" + addMasterPartPropertyResponse.get("resultMsg")); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 删除物料属性 |
|
|
|
@ -448,9 +501,29 @@ public class MasterPartInformationServiceImpl extends ServiceImpl<MasterPartInfo |
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
public void deleteMasterPartItem(PartSubPropertiesValueData inData) { |
|
|
|
Server srv = getIfsServer(inData.getUpdateBy()); |
|
|
|
List<PartIfsCatalogProperty> ifsProperty = new ArrayList<>(); |
|
|
|
MasterPartInformationEntity partData = masterPartInformationMapper.selectOne(new QueryWrapper<MasterPartInformationEntity>().eq("part_no", inData.getPartNo())); |
|
|
|
for(PartSubPropertiesValueData itemDate : inData.getItemList()) { |
|
|
|
partInformationMapper.deletePartItem(itemDate); |
|
|
|
if (dataUrl && "Y".equals(partData.getOfficialFlag())) { |
|
|
|
PartIfsCatalogProperty property = new PartIfsCatalogProperty(); |
|
|
|
property.setLuName(luName); |
|
|
|
property.setKeyRef("PART_NO=" + itemDate.getPartNo() + "^"); // 物料编码 |
|
|
|
property.setTechnicalClass(itemDate.getCodeNo()); // 模板编码 |
|
|
|
property.setAttribute(itemDate.getPropertiesItemNo()); // 属性编码 |
|
|
|
ifsProperty.add(property); |
|
|
|
} |
|
|
|
} |
|
|
|
// 同步IFS |
|
|
|
// if (dataUrl && "Y".equals(partData.getOfficialFlag())) { |
|
|
|
// if (!ifsProperty.isEmpty()) { |
|
|
|
// Map<String, String> deleteMasterPartPropertyResponse = technicalClassBean.removeTechnicalClass(srv, ifsProperty); |
|
|
|
// if (!"200".equals(deleteMasterPartPropertyResponse.get("resultCode"))) { |
|
|
|
// throw new RuntimeException("IFS物料属性删除异常:" + deleteMasterPartPropertyResponse.get("resultMsg")); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -460,19 +533,13 @@ public class MasterPartInformationServiceImpl extends ServiceImpl<MasterPartInfo |
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
public void commitItemValue(PartSubPropertiesValueData data) { |
|
|
|
// // 修改明细记录信息 |
|
|
|
// for (int i = 0; i < data.getItemList().size(); i++) { |
|
|
|
// partInformationMapper.commitItemValue(data.getItemList().get(i)); |
|
|
|
// } |
|
|
|
|
|
|
|
if (!data.getItemList().isEmpty()) { |
|
|
|
Server srv = getIfsServer(data.getUpdateBy()); |
|
|
|
List<PartIfsCatalogProperty> ifsProperty = new ArrayList<>(); |
|
|
|
MasterPartInformationEntity partData = masterPartInformationMapper.selectOne(new QueryWrapper<MasterPartInformationEntity>().eq("part_no", data.getItemList().get(0).getPartNo())); |
|
|
|
// 修改明细记录信息 |
|
|
|
for (PartSubPropertiesValueData valueData : data.getItemList()) { |
|
|
|
valueData.setSite("*"); |
|
|
|
partInformationMapper.commitItemValue(valueData); |
|
|
|
|
|
|
|
if (dataUrl && "Y".equals(partData.getOfficialFlag())) { |
|
|
|
PartIfsCatalogProperty property = new PartIfsCatalogProperty(); |
|
|
|
property.setLuName(luName); |
|
|
|
@ -491,10 +558,10 @@ public class MasterPartInformationServiceImpl extends ServiceImpl<MasterPartInfo |
|
|
|
|
|
|
|
// 同步IFS |
|
|
|
if (dataUrl && "Y".equals(partData.getOfficialFlag())) { |
|
|
|
String updateMasterPartPropertyURL = apiUrl + "/technical/class/modifyTechnicalClassAttributes"; |
|
|
|
ResponseData updateMasterPartPropertyResponse = HttpClientUtil.doPostByRawWithPLM(updateMasterPartPropertyURL, ifsProperty); |
|
|
|
if (!"200".equals(updateMasterPartPropertyResponse.getCode())) { |
|
|
|
throw new RuntimeException("IFS物料件属性修改异常:" + updateMasterPartPropertyResponse.getMsg()); |
|
|
|
if (!ifsProperty.isEmpty()) { |
|
|
|
Map<String, String> updateMasterPartPropertyResponse = technicalClassBean.modifyTechnicalClassAttributes(srv, ifsProperty); |
|
|
|
if (!"200".equals(updateMasterPartPropertyResponse.get("resultCode"))) { |
|
|
|
throw new RuntimeException("IFS物料属性修改异常:" + updateMasterPartPropertyResponse.get("resultMsg")); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|