Merge remote-tracking branch 'origin/master'

master
philip 3 years ago
commit 3c08291833

@ -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<ItemTranslation> 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;
}
/**
*
*

@ -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);

@ -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;

@ -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;

@ -92,6 +92,17 @@ public class ResourceInspectTaskDto implements Serializable {
private List<ResourceInspectTaskSpare> 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;

@ -643,7 +643,7 @@
<!--自定义sql模糊查询检验任务所有字段、车间、设备名称等字段-->
<select id="findResourceInspectTaskList" resultType="com.foreverwin.mesnac.equip.dto.ResourceInspectTaskDto">
SELECT DISTINCT RIK.* , ZNU.FULL_NAME, RIP.PLAN_NO AS PLAN_NO ,
SELECT DISTINCT RIK.* , TO_CHAR(RIK.TASK_CREATE_DATE, 'yyyy-mm-dd') TASK_DAY , ZNU.FULL_NAME, RIP.PLAN_NO AS PLAN_NO ,
R.RESRCE AS RESOURCE_NO ,R.DESCRIPTION AS RESOURCE_DESCRIPTION ,
RTR.RESOURCE_TYPE_BO ,RT.RESOURCE_TYPE AS RESOURCE_TYPE_NO ,RT.DESCRIPTION AS RESOURCE_TYPE_DESCRIPTION ,
WCT.DESCRIPTION AS WORK_CENTER

Loading…
Cancel
Save