diff --git a/dataimport/src/main/java/com/foreverwin/mesnac/dataimport/client/ItemWSClient.java b/dataimport/src/main/java/com/foreverwin/mesnac/dataimport/client/ItemWSClient.java index ffa83558..1aed110e 100644 --- a/dataimport/src/main/java/com/foreverwin/mesnac/dataimport/client/ItemWSClient.java +++ b/dataimport/src/main/java/com/foreverwin/mesnac/dataimport/client/ItemWSClient.java @@ -4,14 +4,17 @@ import com.alibaba.fastjson.JSONObject; import com.foreverwin.mesnac.common.enums.HandleEnum; import com.foreverwin.mesnac.common.util.ExceptionUtil; import com.foreverwin.mesnac.common.util.StringUtil; +import com.foreverwin.modular.core.exception.BusinessException; import com.foreverwin.modular.core.meext.MEServices; +import com.sap.me.common.MaterialType; import com.sap.me.common.ObjectAliasEnum; import com.sap.me.common.ObjectReference; -import com.sap.me.productdefinition.ItemConfigurationServiceInterface; -import com.sap.me.productdefinition.ItemFullConfiguration; -import com.sap.me.productdefinition.QuantityRestriction; +import com.sap.me.common.ProcurementType; +import com.sap.me.productdefinition.*; import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; /** * 物料主数据操作类 @@ -46,6 +49,123 @@ public class ItemWSClient { return null; } + /** + * 新增物料 + * + * @param jsonObject + * @return + */ + public static String insert(JSONObject jsonObject) { + try { + String site = (String) jsonObject.get("site"); + String item = jsonObject.getString("item"); + //物料描述 + String itemDescription = jsonObject.getString("itemDesc"); + //计量单位 + String unitOfMeasure = jsonObject.getString("unit"); + //状态 + String statusBo = HandleEnum.STATUS.getHandle(site, "201"); + + //物料类型(FERT(已完成)/ROH(原始)/HALB(半成品)/KMAT(可配置)/INST(安装)/VERP(包装)/FHMI(生产资源/工具)/CSTM(自定义)) + String itemTypeDesc = jsonObject.getString("materialType"); + if (!"已完成".equals(itemTypeDesc) && !"原始".equals(itemTypeDesc) && !"半成品".equals(itemTypeDesc)) { + throw BusinessException.build("物料类型可维护的值为:FERT(已完成)、ROH(原始)、HALB(半成品)"); + } + String itemType = "ROH"; + switch (itemTypeDesc) { + case "原始": + itemType = "ROH"; + break; + case "半成品": + itemType = "HALB"; + break; + case "已完成": + itemType = "FERT"; + break; + default: + break; + } + + //采购类型(M(制造)/P(采购)/B(制造/采购)) + String procurementTypeDesc = jsonObject.getString("itemType"); + if (!"M".equals(procurementTypeDesc) && !"P".equals(procurementTypeDesc) && !"B".equals(procurementTypeDesc)) { + throw BusinessException.build("采购类型可维护的值为:M(制造)、P(采购)、B(制造/采购)"); + } + String procurementType = "P"; + switch (procurementTypeDesc) { + case "采购": + itemType = "P"; + break; + case "制造/采购": + itemType = "B"; + break; + case "制造": + itemType = "M"; + break; + default: + break; + } + + //批次大小 + String lotSize = jsonObject.getString("lotSize"); + lotSize = StringUtil.notBlank(lotSize) ? lotSize : "999999"; + + //数量限制 + String qtyRestrictionDesc = jsonObject.getString("qtyRestriction"); + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + //物料标准API + ItemConfigurationServiceInterface itemServiceInterFace = MEServices.create("com.sap.me.productdefinition", "ItemConfigurationService", site); + + //创建物料 + ItemConfiguration itemConfiguration = new ItemConfiguration(); + itemConfiguration.setItem(item); + itemConfiguration.setRevision("A"); + itemConfiguration.setProcurementType(ProcurementType.fromValue(procurementType)); + itemConfiguration.setLotSize(new BigDecimal(lotSize)); + itemConfiguration.setRef(HandleEnum.ITEM.getHandle(site, item, "A")); + itemConfiguration.setCurrentRevision(true); + itemConfiguration.setUnitOfMeasurement(unitOfMeasure); + itemConfiguration.setMaterialType(MaterialType.fromValue(itemType)); + + String dataTypeBo = "DataTypeBO:" +site+ ",ASSEMBLY,INV_NAC"; + itemConfiguration.setInventoryAssemblyDataTypeRef(dataTypeBo); + //物料描述赋值 + List itemTranslationList = new ArrayList<>(); + ItemTranslation itemTranslation = new ItemTranslation(); + itemTranslation.setLocale("zh"); + itemTranslation.setDescription(itemDescription); + itemTranslationList.add(itemTranslation); + itemConfiguration.setItemTranslationList(itemTranslationList); + itemConfiguration.setStatusRef(statusBo); + //数量限制 + switch (qtyRestrictionDesc) { + case "仅1.0": + itemConfiguration.setQuantityRestriction(QuantityRestriction.ONLY_1); + break; + case "任意数字": + itemConfiguration.setQuantityRestriction(QuantityRestriction.ANY_NUMBER); + break; + case "正数": + itemConfiguration.setQuantityRestriction(QuantityRestriction.WHOLE_NUMBER); + break; + default: + itemConfiguration.setQuantityRestriction(QuantityRestriction.ANY_NUMBER); + break; + } + + //创建物料 + itemServiceInterFace.createItem(itemConfiguration); + + //自定义字段保存 + CustomDataWSClient.update(jsonObject, itemConfiguration.getRef(), ObjectAliasEnum.ITEM.value()); + } catch (Exception e) { + return ExceptionUtil.getExceptionMsg(e); + } + + return null; + } + /** * 更新物料 * diff --git a/dataimport/src/main/java/com/foreverwin/mesnac/dataimport/controller/DataImportController.java b/dataimport/src/main/java/com/foreverwin/mesnac/dataimport/controller/DataImportController.java index 53b33285..b4c67f11 100644 --- a/dataimport/src/main/java/com/foreverwin/mesnac/dataimport/controller/DataImportController.java +++ b/dataimport/src/main/java/com/foreverwin/mesnac/dataimport/controller/DataImportController.java @@ -28,7 +28,7 @@ public class DataImportController { private MasterDataImportServiceImpl masterDataImportService; @PostMapping("/import") - public String importFile(@PathParam("fileType") String fileType, @PathParam("site") String site, @PathParam("user") String user, @PathParam("handleType") final String handleType, @PathParam("mode") final String mode, @RequestParam("file") MultipartFile multipartFile) { + public String importFile(@PathParam("fileType") String fileType, @PathParam("site") String site, @PathParam("handleType") final String handleType, @PathParam("mode") final String mode, @PathParam("user") String user, @RequestParam("file") MultipartFile multipartFile) { ImportRequest importRequest = new ImportRequest(); importRequest.setFileType(fileType); importRequest.setSite(site); diff --git a/dataimport/src/main/java/com/foreverwin/mesnac/dataimport/handler/ItemHandler.java b/dataimport/src/main/java/com/foreverwin/mesnac/dataimport/handler/ItemHandler.java index 538e0b92..b6c1d5a5 100644 --- a/dataimport/src/main/java/com/foreverwin/mesnac/dataimport/handler/ItemHandler.java +++ b/dataimport/src/main/java/com/foreverwin/mesnac/dataimport/handler/ItemHandler.java @@ -62,10 +62,9 @@ public class ItemHandler extends BaseHandler { jsonObject.put("site", site); ItemFullConfiguration itemFull = ItemWSClient.find(jsonObject); if (itemFull == null) { - resultMessage = "物料主数据不存在"; + resultMessage = ItemWSClient.insert(jsonObject); } else { ItemWSClient.update(jsonObject, itemFull); - return 1; } if (resultMessage != null) { @@ -74,6 +73,8 @@ public class ItemHandler extends BaseHandler { buffer.append("第" + index + "行:" + I18nUtil.getI18nText("MaterData.import.update.fail", params) + "\n"); return 0; } + + return 1; } return 0; diff --git a/dataimport/src/main/java/com/foreverwin/mesnac/dataimport/service/MasterObjectDefine.java b/dataimport/src/main/java/com/foreverwin/mesnac/dataimport/service/MasterObjectDefine.java index 9aa4d097..127acdd3 100644 --- a/dataimport/src/main/java/com/foreverwin/mesnac/dataimport/service/MasterObjectDefine.java +++ b/dataimport/src/main/java/com/foreverwin/mesnac/dataimport/service/MasterObjectDefine.java @@ -20,8 +20,13 @@ public class MasterObjectDefine { cvsHeadsMapping = new HashMap<>(); cvsHeadsMapping.put("seqNum","序号"); - cvsHeadsMapping.put("item","物料编码"); + cvsHeadsMapping.put("item", "*物料编码"); + cvsHeadsMapping.put("itemDesc", "物料描述(中文)"); + cvsHeadsMapping.put("materialType", "物料类型"); + cvsHeadsMapping.put("itemType", "采购类型"); cvsHeadsMapping.put("lotSize","批次大小"); + cvsHeadsMapping.put("qtyRestriction","数量限制"); + cvsHeadsMapping.put("unit","计量单位"); break; diff --git a/equip/src/main/java/com/foreverwin/mesnac/equip/dto/ResourceInspectTaskDto.java b/equip/src/main/java/com/foreverwin/mesnac/equip/dto/ResourceInspectTaskDto.java index 17124e2a..dea4150e 100644 --- a/equip/src/main/java/com/foreverwin/mesnac/equip/dto/ResourceInspectTaskDto.java +++ b/equip/src/main/java/com/foreverwin/mesnac/equip/dto/ResourceInspectTaskDto.java @@ -92,6 +92,17 @@ public class ResourceInspectTaskDto implements Serializable { private List spareList; /**用户名称**/ private String fullName; + /**任务执行日期**/ + private String taskDay; + + + public String getTaskDay() { + return taskDay; + } + + public void setTaskDay(String taskDay) { + this.taskDay = taskDay; + } public String getFullName() { return fullName; diff --git a/equip/src/main/resources/mapper/ResourceInspectTaskMapper.xml b/equip/src/main/resources/mapper/ResourceInspectTaskMapper.xml index f7c5dfca..e5085bf6 100644 --- a/equip/src/main/resources/mapper/ResourceInspectTaskMapper.xml +++ b/equip/src/main/resources/mapper/ResourceInspectTaskMapper.xml @@ -643,7 +643,7 @@