增加修改派工单状态接口
parent
33e6094af0
commit
c63daa7ef6
@ -0,0 +1,21 @@
|
||||
package com.foreverwin.mesnac.common.service;
|
||||
|
||||
/**
|
||||
* 派工公用接口
|
||||
*
|
||||
*
|
||||
* @author Leon
|
||||
* @date2021/7/7
|
||||
*/
|
||||
public interface SfcDispatchCommonService {
|
||||
|
||||
/**
|
||||
* 修改派工单状态
|
||||
*
|
||||
* @param site
|
||||
* @param user
|
||||
* @param dispatchNo
|
||||
* @param dispatchStatus
|
||||
*/
|
||||
void updateSfcDispatchStatus(String site, String user, String dispatchNo, String dispatchStatus);
|
||||
}
|
@ -0,0 +1,247 @@
|
||||
package com.foreverwin.mesnac.dataimport.client;
|
||||
|
||||
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.meext.MEServices;
|
||||
import com.sap.me.common.BasicStatusEnum;
|
||||
import com.sap.me.common.ObjectReference;
|
||||
import com.sap.me.nonconformance.*;
|
||||
|
||||
import javax.xml.datatype.DatatypeConstants;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 不良代码操作类
|
||||
*
|
||||
* @author Leon
|
||||
* @date 2021/7/6
|
||||
*/
|
||||
public class NcCodeWSClient {
|
||||
|
||||
/**
|
||||
* 查询不合格代码
|
||||
*
|
||||
* @param jsonObject
|
||||
* @return
|
||||
*/
|
||||
public static NcCodeFullConfiguration find(JSONObject jsonObject) {
|
||||
NcCodeFullConfiguration ncCodeFullConfiguration = null;
|
||||
|
||||
try {
|
||||
String site = jsonObject.getString("site");
|
||||
String ncCode = jsonObject.getString("ncCode");
|
||||
String ncCodeBo = HandleEnum.NC_CODE.getHandle(site, ncCode);
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
NcCodeConfigurationServiceInterface ncCodeConfigurationService = MEServices.create("com.sap.me.nonconformance", "NcCodeConfigurationService", site);
|
||||
ObjectReference objectReference = new ObjectReference(ncCodeBo);
|
||||
ncCodeFullConfiguration = ncCodeConfigurationService.readNcCode(objectReference);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
return ncCodeFullConfiguration;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 不合格代码创建
|
||||
*
|
||||
* @param jsonObject
|
||||
* @return
|
||||
*/
|
||||
public static String create(JSONObject jsonObject) {
|
||||
try {
|
||||
String site = jsonObject.getString("site");
|
||||
String ncCode = jsonObject.getString("ncCode");
|
||||
String ncCodeBo = HandleEnum.NC_CODE.getHandle(site, ncCode);
|
||||
String category = jsonObject.getString("category");
|
||||
String dataType = jsonObject.getString("dataType");
|
||||
String description = jsonObject.getString("descZH");
|
||||
String closureRequired = jsonObject.getString("closureRequired");
|
||||
String canBePrimaryCode = jsonObject.getString("canBePrimaryCode");
|
||||
String autoClosePrimary = jsonObject.getString("autoClosePrimary");
|
||||
String autoCloseIncident = jsonObject.getString("autoCloseIncident");
|
||||
String secondaryRequireForClose = jsonObject.getString("secondaryRequireForClose");
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
NcCodeConfiguration ncCodeConfiguration = new NcCodeConfiguration();
|
||||
ncCodeConfiguration.setRef(ncCodeBo);
|
||||
ncCodeConfiguration.setNcCode(ncCode);
|
||||
ncCodeConfiguration.setDescription(description);
|
||||
ncCodeConfiguration.setStatus(BasicStatusEnum.ENABLED);
|
||||
|
||||
//不合格代码组
|
||||
String ncGroup = jsonObject.getString("ncGroup");
|
||||
NcGroupMember ncGroupMember = new NcGroupMember();
|
||||
String ncGroupBo = HandleEnum.NC_GROUP.getHandle(site, ncGroup);
|
||||
ncGroupMember.setNcGroupRef(ncGroupBo);
|
||||
ncCodeConfiguration.getNcGroupMemberList().add(ncGroupMember);
|
||||
|
||||
//不合格代码类型
|
||||
NCCategory ncCodeCategory = NCCategory.FAILURE;
|
||||
switch (category) {
|
||||
case "故障" :
|
||||
ncCodeCategory = NCCategory.FAILURE;
|
||||
break;
|
||||
case "缺陷" :
|
||||
ncCodeCategory = NCCategory.DEFECT;
|
||||
break;
|
||||
case "修复" :
|
||||
ncCodeCategory = NCCategory.REPAIR;
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
ncCodeConfiguration.setNcCategory(ncCodeCategory);
|
||||
|
||||
//不合格数据类型
|
||||
dataType = StringUtil.notBlank(dataType) ? dataType : "SIMPLE";
|
||||
String ncDataTypeRef = HandleEnum.DATA_TYPE.getHandle(site, "NC", dataType);
|
||||
ncCodeConfiguration.setNcDataTypeRef(ncDataTypeRef);
|
||||
|
||||
//需要关闭
|
||||
ncCodeConfiguration.setClosureRequired("是".equals(closureRequired) ? true : false);
|
||||
//是否可以是主要代码
|
||||
ncCodeConfiguration.setCanBePrimaryCode("是".equals(canBePrimaryCode) ? true : false);
|
||||
ncCodeConfiguration.setAutoClosePrimary("是".equals(autoClosePrimary) ? true : false);
|
||||
ncCodeConfiguration.setAutoCloseIncident("是".equals(autoCloseIncident) ? true : false);
|
||||
ncCodeConfiguration.setSecondaryRequiredForClose("是".equals(secondaryRequireForClose) ? true : false);
|
||||
|
||||
//次要不良项目
|
||||
String secondaryCodes = jsonObject.getString("secondaryCode");
|
||||
if (StringUtil.notBlank(secondaryCodes)) {
|
||||
List<NcSecondaryCode> ncSecondaryCodeList = new ArrayList<>();
|
||||
|
||||
if (!secondaryCodes.contains(":")) {
|
||||
NcSecondaryCode ncSecondaryCode = new NcSecondaryCode();
|
||||
String ncCodeRef = HandleEnum.NC_CODE.getHandle(site, secondaryCodes);
|
||||
ncSecondaryCode.setNcCodeRef(ncCodeRef);
|
||||
ncSecondaryCodeList.add(ncSecondaryCode);
|
||||
} else {
|
||||
String [] secondaryCodeArray = secondaryCodes.split(":");
|
||||
for (String secondaryCode: secondaryCodeArray) {
|
||||
NcSecondaryCode ncSecondaryCode = new NcSecondaryCode();
|
||||
String ncCodeRef = HandleEnum.NC_CODE.getHandle(site, secondaryCode);
|
||||
ncSecondaryCode.setNcCodeRef(ncCodeRef);
|
||||
ncSecondaryCodeList.add(ncSecondaryCode);
|
||||
}
|
||||
}
|
||||
|
||||
ncCodeConfiguration.setNcSecondaryCodeList(ncSecondaryCodeList);
|
||||
}
|
||||
|
||||
//NC最大限制值
|
||||
String maxNcLimit = jsonObject.getString("maxNcLimit");
|
||||
maxNcLimit = StringUtil.notBlank(maxNcLimit) ? maxNcLimit : "10";
|
||||
ncCodeConfiguration.setMaxNcLimit(new BigDecimal(maxNcLimit));
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
NcCodeConfigurationServiceInterface ncCodeConfigurationService = MEServices.create("com.sap.me.nonconformance", "NcCodeConfigurationService", site);
|
||||
ncCodeConfigurationService.createNcCode(ncCodeConfiguration);
|
||||
} catch (Exception e) {
|
||||
return ExceptionUtil.getExceptionMsg(e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 不合格代码更新
|
||||
*
|
||||
* @param jsonObject
|
||||
* @param ncCodeFullConfiguration
|
||||
* @return
|
||||
*/
|
||||
public static String update(JSONObject jsonObject, NcCodeFullConfiguration ncCodeFullConfiguration) {
|
||||
try {
|
||||
String site = jsonObject.getString("site");
|
||||
String category = jsonObject.getString("category");
|
||||
String dataType = jsonObject.getString("dataType");
|
||||
String description = jsonObject.getString("descZH");
|
||||
String closureRequired = jsonObject.getString("closureRequired");
|
||||
String canBePrimaryCode = jsonObject.getString("canBePrimaryCode");
|
||||
String autoClosePrimary = jsonObject.getString("autoClosePrimary");
|
||||
String autoCloseIncident = jsonObject.getString("autoCloseIncident");
|
||||
String secondaryRequireForClose = jsonObject.getString("secondaryRequireForClose");
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
ncCodeFullConfiguration.setDescription(description);
|
||||
ncCodeFullConfiguration.setStatus(BasicStatusEnum.ENABLED);
|
||||
|
||||
//不合格代码组
|
||||
String ncGroup = jsonObject.getString("ncGroup");
|
||||
NcGroupMember ncGroupMember = new NcGroupMember();
|
||||
String ncGroupBo = HandleEnum.NC_GROUP.getHandle(site, ncGroup);
|
||||
ncGroupMember.setNcGroupRef(ncGroupBo);
|
||||
ncCodeFullConfiguration.getNcGroupMemberList().add(ncGroupMember);
|
||||
|
||||
//不合格代码类型
|
||||
NCCategory ncCodeCategory = NCCategory.FAILURE;
|
||||
switch (category) {
|
||||
case "故障" :
|
||||
ncCodeCategory = NCCategory.FAILURE;
|
||||
break;
|
||||
case "缺陷" :
|
||||
ncCodeCategory = NCCategory.DEFECT;
|
||||
break;
|
||||
case "修复" :
|
||||
ncCodeCategory = NCCategory.REPAIR;
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
ncCodeFullConfiguration.setNcCategory(ncCodeCategory);
|
||||
|
||||
//不合格数据类型
|
||||
dataType = StringUtil.notBlank(dataType) ? dataType : "SIMPLE";
|
||||
String ncDataTypeRef = HandleEnum.DATA_TYPE.getHandle(site, "NC", dataType);
|
||||
ncCodeFullConfiguration.setNcDataTypeRef(ncDataTypeRef);
|
||||
|
||||
//需要关闭
|
||||
ncCodeFullConfiguration.setClosureRequired("是".equals(closureRequired) ? true : false);
|
||||
//是否可以是主要代码
|
||||
ncCodeFullConfiguration.setCanBePrimaryCode("是".equals(canBePrimaryCode) ? true : false);
|
||||
ncCodeFullConfiguration.setAutoClosePrimary("是".equals(autoClosePrimary) ? true : false);
|
||||
ncCodeFullConfiguration.setAutoCloseIncident("是".equals(autoCloseIncident) ? true : false);
|
||||
ncCodeFullConfiguration.setSecondaryRequiredForClose("是".equals(secondaryRequireForClose) ? true : false);
|
||||
|
||||
//次要不良项目
|
||||
String secondaryCodes = jsonObject.getString("secondaryCode");
|
||||
if (StringUtil.notBlank(secondaryCodes)) {
|
||||
List<NcSecondaryCode> ncSecondaryCodeList = new ArrayList<>();
|
||||
|
||||
if (!secondaryCodes.contains(":")) {
|
||||
NcSecondaryCode ncSecondaryCode = new NcSecondaryCode();
|
||||
String ncCodeRef = HandleEnum.NC_CODE.getHandle(site, secondaryCodes);
|
||||
ncSecondaryCode.setNcCodeRef(ncCodeRef);
|
||||
ncSecondaryCodeList.add(ncSecondaryCode);
|
||||
} else {
|
||||
String [] secondaryCodeArray = secondaryCodes.split(":");
|
||||
for (String secondaryCode: secondaryCodeArray) {
|
||||
NcSecondaryCode ncSecondaryCode = new NcSecondaryCode();
|
||||
String ncCodeRef = HandleEnum.NC_CODE.getHandle(site, secondaryCode);
|
||||
ncSecondaryCode.setNcCodeRef(ncCodeRef);
|
||||
ncSecondaryCodeList.add(ncSecondaryCode);
|
||||
}
|
||||
}
|
||||
|
||||
ncCodeFullConfiguration.setNcSecondaryCodeList(ncSecondaryCodeList);
|
||||
}
|
||||
|
||||
//NC最大限制值
|
||||
String maxNcLimit = jsonObject.getString("maxNcLimit");
|
||||
maxNcLimit = StringUtil.notBlank(maxNcLimit) ? maxNcLimit : "10";
|
||||
ncCodeFullConfiguration.setMaxNcLimit(new BigDecimal(maxNcLimit));
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
NcCodeConfigurationServiceInterface ncCodeConfigurationService = MEServices.create("com.sap.me.nonconformance", "NcCodeConfigurationService", site);
|
||||
ncCodeConfigurationService.updateNcCode(ncCodeFullConfiguration);
|
||||
} catch (Exception e) {
|
||||
return ExceptionUtil.getExceptionMsg(e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,135 @@
|
||||
package com.foreverwin.mesnac.dataimport.client;
|
||||
|
||||
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.meext.MEServices;
|
||||
import com.sap.me.common.ObjectReference;
|
||||
import com.sap.me.nonconformance.NcGroupConfigurationServiceInterface;
|
||||
import com.sap.me.nonconformance.NcGroupFullConfiguration;
|
||||
import com.sap.me.nonconformance.NcGroupValidOperation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 不良代码组操作类
|
||||
*
|
||||
* @author Leon
|
||||
* @date 2021/7/6
|
||||
*/
|
||||
public class NcGroupWSClient {
|
||||
|
||||
/**
|
||||
* 查询不合格代码组
|
||||
*
|
||||
* @param jsonObject
|
||||
* @return
|
||||
*/
|
||||
public static NcGroupFullConfiguration find(JSONObject jsonObject) {
|
||||
NcGroupFullConfiguration ncGroupFullConfiguration = null;
|
||||
try {
|
||||
String site = jsonObject.getString("site");
|
||||
String ncGroup = jsonObject.getString("ncGroup");
|
||||
String ncGroupBo = HandleEnum.NC_GROUP.getHandle(site, ncGroup);
|
||||
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
NcGroupConfigurationServiceInterface ncGroupConfigurationService = MEServices.create("com.sap.me.nonconformance", "NcGroupConfigurationService", site);
|
||||
ObjectReference objectReference = new ObjectReference(ncGroupBo);
|
||||
ncGroupFullConfiguration = ncGroupConfigurationService.readNcGroup(objectReference);
|
||||
} catch (Exception e) {
|
||||
//-------------------
|
||||
}
|
||||
|
||||
return ncGroupFullConfiguration;
|
||||
}
|
||||
|
||||
/**
|
||||
* 不良代码组创建
|
||||
*
|
||||
* @param jsonObject
|
||||
* @return
|
||||
*/
|
||||
public static String create(JSONObject jsonObject) {
|
||||
try {
|
||||
String site = jsonObject.getString("site");
|
||||
String ncGroup = jsonObject.getString("ncGroup");
|
||||
String description = jsonObject.getString("description");
|
||||
String applyAll = jsonObject.getString("applyAll");
|
||||
String applyOperation = jsonObject.getString("applyOperation");
|
||||
String ncGroupBo = HandleEnum.NC_GROUP.getHandle(site, ncGroup);
|
||||
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
NcGroupConfigurationServiceInterface ncGroupConfigurationService = MEServices.create("com.sap.me.nonconformance", "NcGroupConfigurationService", site);
|
||||
NcGroupFullConfiguration ncGroupFullConfiguration = new NcGroupFullConfiguration();
|
||||
ncGroupFullConfiguration.setRef(ncGroupBo);
|
||||
ncGroupFullConfiguration.setNcGroup(ncGroup);
|
||||
ncGroupFullConfiguration.setDescription(description);
|
||||
if ("true".equals(applyAll)) {
|
||||
ncGroupFullConfiguration.setValidAtAllOperations(true);
|
||||
} else {
|
||||
if (StringUtil.notBlank(applyOperation) && applyOperation.contains(";")) {
|
||||
List<NcGroupValidOperation> list = new ArrayList<>();
|
||||
String[] operationList = applyOperation.split(";");
|
||||
for (String operation: operationList) {
|
||||
NcGroupValidOperation ncGroupValidOperation = new NcGroupValidOperation();
|
||||
String operationBo = HandleEnum.OPERATION.getHandle(site, operation, "#");
|
||||
ncGroupValidOperation.setOperationRef(operationBo);
|
||||
list.add(ncGroupValidOperation);
|
||||
}
|
||||
|
||||
ncGroupFullConfiguration.setNcGroupValidOperationList(list);
|
||||
}
|
||||
}
|
||||
|
||||
ncGroupConfigurationService.createNcGroup(ncGroupFullConfiguration);
|
||||
} catch (Exception e) {
|
||||
return ExceptionUtil.getExceptionMsg(e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 不良代码组更新
|
||||
*
|
||||
* @param jsonObject
|
||||
* @param ncGroupFull
|
||||
* @return
|
||||
*/
|
||||
public static String update(JSONObject jsonObject, NcGroupFullConfiguration ncGroupFull) {
|
||||
try {
|
||||
String site = jsonObject.getString("site");
|
||||
String description = jsonObject.getString("description");
|
||||
String applyAll = jsonObject.getString("applyAll");
|
||||
String applyOperation = jsonObject.getString("applyOperation");
|
||||
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
NcGroupConfigurationServiceInterface ncGroupConfigurationService = MEServices.create("com.sap.me.nonconformance", "NcGroupConfigurationService", site);
|
||||
ncGroupFull.setDescription(description);
|
||||
if ("true".equals(applyAll)) {
|
||||
ncGroupFull.setValidAtAllOperations(true);
|
||||
} else {
|
||||
if (StringUtil.notBlank(applyOperation) && applyOperation.contains(";")) {
|
||||
List<NcGroupValidOperation> list = new ArrayList<>();
|
||||
String[] operationList = applyOperation.split(";");
|
||||
for (String operation: operationList) {
|
||||
NcGroupValidOperation ncGroupValidOperation = new NcGroupValidOperation();
|
||||
String operationBo = HandleEnum.OPERATION.getHandle(site, operation, "#");
|
||||
ncGroupValidOperation.setOperationRef(operationBo);
|
||||
list.add(ncGroupValidOperation);
|
||||
}
|
||||
|
||||
ncGroupFull.setNcGroupValidOperationList(list);
|
||||
}
|
||||
}
|
||||
|
||||
ncGroupConfigurationService.updateNcGroup(ncGroupFull);
|
||||
} catch (Exception e) {
|
||||
return ExceptionUtil.getExceptionMsg(e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package com.foreverwin.mesnac.dataimport.client;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.foreverwin.mesnac.common.enums.HandleEnum;
|
||||
import com.foreverwin.mesnac.common.util.ExceptionUtil;
|
||||
import com.foreverwin.modular.core.meext.MEServices;
|
||||
import com.sap.me.common.ObjectAliasEnum;
|
||||
import com.sap.me.plant.FindResourceTypeByKeyFieldsRequest;
|
||||
import com.sap.me.plant.ResourceTypeBasicConfiguration;
|
||||
import com.sap.me.plant.ResourceTypeConfiguration;
|
||||
import com.sap.me.plant.ResourceTypeConfigurationServiceInterface;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
/**
|
||||
* 资源类型主数据操作类
|
||||
*
|
||||
*
|
||||
* @author Leon
|
||||
* @date 2021/7/6
|
||||
*/
|
||||
public class ResourceTypeWSClient {
|
||||
|
||||
/**
|
||||
* 查询资源类型
|
||||
*
|
||||
* @param jsonObject
|
||||
* @return
|
||||
*/
|
||||
public static Collection<ResourceTypeBasicConfiguration> find(JSONObject jsonObject) {
|
||||
Collection<ResourceTypeBasicConfiguration> collection = null;
|
||||
|
||||
try {
|
||||
String site = jsonObject.getString("site");
|
||||
String resourceType = jsonObject.getString("resourceType");
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
ResourceTypeConfigurationServiceInterface resourceTypeService = MEServices.create("com.sap.me.plant", "ResourceTypeConfigurationService", site);
|
||||
FindResourceTypeByKeyFieldsRequest resourceTypeRequest = new FindResourceTypeByKeyFieldsRequest();
|
||||
resourceTypeRequest.setResourceType(resourceType);
|
||||
collection = resourceTypeService.findResourceTypeByKeyFields(resourceTypeRequest);
|
||||
} catch (Exception e) {
|
||||
//----------------
|
||||
}
|
||||
|
||||
return collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* 资源类型新增
|
||||
*
|
||||
* @param jsonObject
|
||||
* @return
|
||||
*/
|
||||
public static String insert(JSONObject jsonObject) {
|
||||
try {
|
||||
String site = jsonObject.getString("site");
|
||||
String resourceType = jsonObject.getString("resourceType");
|
||||
String description = jsonObject.getString("description");
|
||||
String resourceTypeBo = HandleEnum.RESOURCE_TYPE.getHandle(site, resourceType);
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
ResourceTypeConfigurationServiceInterface resourceTypeService = MEServices.create("com.sap.me.plant", "ResourceTypeConfigurationService", site);
|
||||
ResourceTypeConfiguration resourceTypeConfiguration = new ResourceTypeConfiguration();
|
||||
resourceTypeConfiguration.setRef(resourceTypeBo);
|
||||
resourceTypeConfiguration.setResourceType(resourceType);
|
||||
resourceTypeConfiguration.setDescription(description);
|
||||
resourceTypeService.createResourceType(resourceTypeConfiguration);
|
||||
|
||||
//自定义字段更新
|
||||
CustomDataWSClient.update(jsonObject, resourceTypeBo, ObjectAliasEnum.RESOURCE_TYPE.value());
|
||||
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
return ExceptionUtil.getExceptionMsg(e);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
package com.foreverwin.mesnac.dataimport.handler;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.foreverwin.mesnac.dataimport.client.ItemWSClient;
|
||||
import com.foreverwin.mesnac.dataimport.handler.base.BaseHandler;
|
||||
import com.foreverwin.mesnac.dataimport.reader.FileReader;
|
||||
import com.foreverwin.mesnac.dataimport.reader.FileReaderBuilder;
|
||||
import com.foreverwin.mesnac.dataimport.reader.RowVisitor;
|
||||
import com.foreverwin.mesnac.dataimport.service.MasterObjectDefine;
|
||||
import com.foreverwin.modular.core.exception.BusinessException;
|
||||
import com.foreverwin.modular.core.util.I18nUtil;
|
||||
import com.sap.me.productdefinition.ItemFullConfiguration;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Map;
|
||||
|
||||
public class ItemHandler extends BaseHandler {
|
||||
|
||||
|
||||
@Override
|
||||
public String importFile(String site, InputStream inputStream, String fileType, String mode) throws Exception {
|
||||
int row = 0;
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
Integer[] failedNumber = new Integer[]{0};
|
||||
|
||||
try {
|
||||
FileReader fileReader = new FileReaderBuilder().build(fileType);
|
||||
RowVisitor<JSONObject> visitor = getRowVisitor(site, mode, buffer, failedNumber);
|
||||
row = fileReader.visitor(visitor).read(inputStream, getHeaders());
|
||||
} catch (Exception e) {
|
||||
buffer.append(e.getMessage() + "\n");
|
||||
}
|
||||
|
||||
if (buffer.length() > 0) {
|
||||
buffer.insert(0, I18nUtil.getI18nText("MaterData.import.Summary", new Object[]{row + failedNumber[0], row, failedNumber[0]}) + "\n");
|
||||
throw BusinessException.build(buffer.toString());
|
||||
}
|
||||
buffer.insert(0, I18nUtil.getI18nText("MaterData.import.Summary", new Object[]{row + failedNumber[0], row, failedNumber[0]}) + "\n");
|
||||
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, String> getHeaders() {
|
||||
|
||||
return MasterObjectDefine.getHeadsMapping("ITEM");
|
||||
}
|
||||
|
||||
public RowVisitor<JSONObject> getRowVisitor(String site, String mode, StringBuffer buffer, Integer[] failedNumber) {
|
||||
|
||||
return new RowVisitor<JSONObject>() {
|
||||
@Override
|
||||
public int visit(long index, JSONObject jsonObject) {
|
||||
Object[] params = new Object[10];
|
||||
params[0] = index;
|
||||
params[1] = jsonObject.getString("item");
|
||||
|
||||
String resultMessage = null;
|
||||
try {
|
||||
if (jsonObject.containsKey("item") && jsonObject.getString("item").trim().length() > 0) {
|
||||
jsonObject.put("site", site);
|
||||
ItemFullConfiguration itemFull = ItemWSClient.find(jsonObject);
|
||||
if (itemFull == null) {
|
||||
resultMessage = "物料主数据不存在";
|
||||
}
|
||||
|
||||
ItemWSClient.update(jsonObject, itemFull);
|
||||
if (resultMessage != null) {
|
||||
params[2] = resultMessage;
|
||||
failedNumber[0]++;
|
||||
buffer.append("第" + index + "行:" + I18nUtil.getI18nText("MaterData.import.update.fail", params) + "\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
} catch (Exception e) {
|
||||
params[2] = e.getMessage();
|
||||
failedNumber[0]++;
|
||||
buffer.append("第" + index + "行:" + I18nUtil.getI18nText("MaterData.import.update.fail", params) + "\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getHeader() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,112 @@
|
||||
package com.foreverwin.mesnac.dataimport.handler;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.foreverwin.mesnac.dataimport.client.ItemWSClient;
|
||||
import com.foreverwin.mesnac.dataimport.client.NcCodeWSClient;
|
||||
import com.foreverwin.mesnac.dataimport.client.NcGroupWSClient;
|
||||
import com.foreverwin.mesnac.dataimport.handler.base.BaseHandler;
|
||||
import com.foreverwin.mesnac.dataimport.reader.FileReader;
|
||||
import com.foreverwin.mesnac.dataimport.reader.FileReaderBuilder;
|
||||
import com.foreverwin.mesnac.dataimport.reader.RowVisitor;
|
||||
import com.foreverwin.mesnac.dataimport.service.MasterObjectDefine;
|
||||
import com.foreverwin.mesnac.dataimport.util.AppUtil;
|
||||
import com.foreverwin.modular.core.exception.BusinessException;
|
||||
import com.foreverwin.modular.core.util.I18nUtil;
|
||||
import com.sap.me.common.ObjectAliasEnum;
|
||||
import com.sap.me.nonconformance.NcCodeFullConfiguration;
|
||||
import com.sap.me.nonconformance.NcGroupFullConfiguration;
|
||||
import com.sap.me.productdefinition.ItemFullConfiguration;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Map;
|
||||
|
||||
public class NCCodeHandler extends BaseHandler {
|
||||
|
||||
|
||||
@Override
|
||||
public String importFile(String site, InputStream inputStream, String fileType, String mode) throws Exception {
|
||||
int row = 0;
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
Integer[] failedNumber = new Integer[]{0};
|
||||
|
||||
try {
|
||||
FileReader fileReader = new FileReaderBuilder().build(fileType);
|
||||
RowVisitor<JSONObject> visitor = getRowVisitor(site, mode, buffer, failedNumber);
|
||||
row = fileReader.visitor(visitor).read(inputStream, getHeaders());
|
||||
} catch (Exception e) {
|
||||
buffer.append(e.getMessage() + "\n");
|
||||
}
|
||||
|
||||
if (buffer.length() > 0) {
|
||||
buffer.insert(0, I18nUtil.getI18nText("MaterData.import.Summary", new Object[]{row + failedNumber[0], row, failedNumber[0]}) + "\n");
|
||||
throw BusinessException.build(buffer.toString());
|
||||
}
|
||||
buffer.insert(0, I18nUtil.getI18nText("MaterData.import.Summary", new Object[]{row + failedNumber[0], row, failedNumber[0]}) + "\n");
|
||||
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getHeaders() {
|
||||
|
||||
return MasterObjectDefine.getHeadsMapping(ObjectAliasEnum.NC_CODE.value());
|
||||
}
|
||||
|
||||
|
||||
public RowVisitor<JSONObject> getRowVisitor(String site, String mode, StringBuffer buffer, Integer[] failedNumber) {
|
||||
|
||||
return new RowVisitor<JSONObject>() {
|
||||
@Override
|
||||
public int visit(long index, JSONObject jsonObject) {
|
||||
Object[] params = new Object[10];
|
||||
params[0] = index;
|
||||
params[1] = jsonObject.getString("ncCode");
|
||||
|
||||
boolean insert = false;
|
||||
String resultMessage = null;
|
||||
try {
|
||||
if (jsonObject.containsKey("ncGroup") && jsonObject.getString("ncGroup").trim().length() > 0) {
|
||||
jsonObject.put("site", site);
|
||||
NcCodeFullConfiguration ncCodeFull = NcCodeWSClient.find(jsonObject);
|
||||
if (ncCodeFull == null) {
|
||||
if (AppUtil.canInsert(mode)) {
|
||||
insert = true;
|
||||
NcGroupWSClient.create(jsonObject);
|
||||
}else if(AppUtil.canUpdate(mode)) {
|
||||
resultMessage = ("第" + index + "行:" + I18nUtil.getI18nText("MaterData.import.update.fail", params) + "\n");
|
||||
}
|
||||
} else {
|
||||
if (AppUtil.canUpdate(mode)) {
|
||||
NcCodeWSClient.update(jsonObject, ncCodeFull);
|
||||
}
|
||||
}
|
||||
|
||||
if (resultMessage != null) {
|
||||
params[2] = resultMessage;
|
||||
failedNumber[0]++;
|
||||
buffer.append("第" + index + "行:" + I18nUtil.getI18nText("MaterData.import.update.fail", params) + "\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
} catch (Exception e) {
|
||||
params[2] = e.getMessage();
|
||||
failedNumber[0]++;
|
||||
if (insert) {
|
||||
buffer.append("第" + index + "行:" + I18nUtil.getI18nText("MaterData.import.insert.fail", params) + "\n");
|
||||
} else {
|
||||
buffer.append("第" + index + "行:" + I18nUtil.getI18nText("MaterData.import.update.fail", params) + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getHeader() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,105 @@
|
||||
package com.foreverwin.mesnac.dataimport.handler;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.foreverwin.mesnac.dataimport.client.NcGroupWSClient;
|
||||
import com.foreverwin.mesnac.dataimport.handler.base.BaseHandler;
|
||||
import com.foreverwin.mesnac.dataimport.reader.FileReader;
|
||||
import com.foreverwin.mesnac.dataimport.reader.FileReaderBuilder;
|
||||
import com.foreverwin.mesnac.dataimport.reader.RowVisitor;
|
||||
import com.foreverwin.mesnac.dataimport.service.MasterObjectDefine;
|
||||
import com.foreverwin.mesnac.dataimport.util.AppUtil;
|
||||
import com.foreverwin.modular.core.exception.BusinessException;
|
||||
import com.foreverwin.modular.core.util.I18nUtil;
|
||||
import com.sap.me.nonconformance.NcGroupFullConfiguration;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Map;
|
||||
|
||||
public class NCGroupHandler extends BaseHandler {
|
||||
|
||||
@Override
|
||||
public String importFile(String site, InputStream inputStream, String fileType, String mode) throws Exception {
|
||||
int row = 0;
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
Integer[] failedNumber = new Integer[]{0};
|
||||
|
||||
try {
|
||||
FileReader fileReader = new FileReaderBuilder().build(fileType);
|
||||
RowVisitor<JSONObject> visitor = getRowVisitor(site, mode, buffer, failedNumber);
|
||||
row = fileReader.visitor(visitor).read(inputStream, getHeaders());
|
||||
} catch (Exception e) {
|
||||
buffer.append(e.getMessage() + "\n");
|
||||
}
|
||||
|
||||
if (buffer.length() > 0) {
|
||||
buffer.insert(0, I18nUtil.getI18nText("MaterData.import.Summary", new Object[]{row + failedNumber[0], row, failedNumber[0]}) + "\n");
|
||||
throw BusinessException.build(buffer.toString());
|
||||
}
|
||||
buffer.insert(0, I18nUtil.getI18nText("MaterData.import.Summary", new Object[]{row + failedNumber[0], row, failedNumber[0]}) + "\n");
|
||||
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getHeaders() {
|
||||
|
||||
return MasterObjectDefine.getHeadsMapping("NC_GROUP");
|
||||
}
|
||||
|
||||
public RowVisitor<JSONObject> getRowVisitor(String site, String mode, StringBuffer buffer, Integer[] failedNumber) {
|
||||
|
||||
return new RowVisitor<JSONObject>() {
|
||||
@Override
|
||||
public int visit(long index, JSONObject jsonObject) {
|
||||
Object[] params = new Object[10];
|
||||
params[0] = index;
|
||||
params[1] = jsonObject.getString("ncGroup");
|
||||
|
||||
boolean insert = false;
|
||||
String resultMessage = null;
|
||||
try {
|
||||
if (jsonObject.containsKey("ncGroup") && jsonObject.getString("ncGroup").trim().length() > 0) {
|
||||
jsonObject.put("site", site);
|
||||
NcGroupFullConfiguration ncGroupFull = NcGroupWSClient.find(jsonObject);
|
||||
if (ncGroupFull == null) {
|
||||
if (AppUtil.canInsert(mode)) {
|
||||
insert = true;
|
||||
NcGroupWSClient.create(jsonObject);
|
||||
}else if(AppUtil.canUpdate(mode)) {
|
||||
resultMessage = ("第" + index + "行:" + I18nUtil.getI18nText("MaterData.import.update.fail", params) + "\n");
|
||||
}
|
||||
} else {
|
||||
if (AppUtil.canUpdate(mode)) {
|
||||
NcGroupWSClient.update(jsonObject, ncGroupFull);
|
||||
}
|
||||
}
|
||||
|
||||
if (resultMessage != null) {
|
||||
params[2] = resultMessage;
|
||||
failedNumber[0]++;
|
||||
buffer.append("第" + index + "行:" + I18nUtil.getI18nText("MaterData.import.update.fail", params) + "\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
} catch (Exception e) {
|
||||
params[2] = e.getMessage();
|
||||
failedNumber[0]++;
|
||||
if (insert) {
|
||||
buffer.append("第" + index + "行:" + I18nUtil.getI18nText("MaterData.import.insert.fail", params) + "\n");
|
||||
} else {
|
||||
buffer.append("第" + index + "行:" + I18nUtil.getI18nText("MaterData.import.update.fail", params) + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getHeader() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
package com.foreverwin.mesnac.dataimport.handler;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.foreverwin.mesnac.dataimport.client.ResourceTypeWSClient;
|
||||
import com.foreverwin.mesnac.dataimport.handler.base.BaseHandler;
|
||||
import com.foreverwin.mesnac.dataimport.reader.FileReader;
|
||||
import com.foreverwin.mesnac.dataimport.reader.FileReaderBuilder;
|
||||
import com.foreverwin.mesnac.dataimport.reader.RowVisitor;
|
||||
import com.foreverwin.mesnac.dataimport.service.MasterObjectDefine;
|
||||
import com.foreverwin.modular.core.exception.BusinessException;
|
||||
import com.foreverwin.modular.core.util.I18nUtil;
|
||||
import com.sap.me.plant.ResourceTypeBasicConfiguration;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
public class ResourceTypeHandler extends BaseHandler {
|
||||
|
||||
@Override
|
||||
public String importFile(String site, InputStream inputStream, String fileType, String mode) throws Exception {
|
||||
int row = 0;
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
Integer[] failedNumber = new Integer[]{0};
|
||||
|
||||
try {
|
||||
FileReader fileReader = new FileReaderBuilder().build(fileType);
|
||||
RowVisitor<JSONObject> visitor = getRowVisitor(site, mode, buffer, failedNumber);
|
||||
row = fileReader.visitor(visitor).read(inputStream, getHeaders());
|
||||
} catch (Exception e) {
|
||||
buffer.append(e.getMessage() + "\n");
|
||||
}
|
||||
|
||||
if (buffer.length() > 0) {
|
||||
buffer.insert(0, I18nUtil.getI18nText("MaterData.import.Summary", new Object[]{row + failedNumber[0], row, failedNumber[0]}) + "\n");
|
||||
throw BusinessException.build(buffer.toString());
|
||||
}
|
||||
buffer.insert(0, I18nUtil.getI18nText("MaterData.import.Summary", new Object[]{row + failedNumber[0], row, failedNumber[0]}) + "\n");
|
||||
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getHeaders() {
|
||||
return MasterObjectDefine.getHeadsMapping("RESOURCE_TYPE");
|
||||
}
|
||||
|
||||
public RowVisitor<JSONObject> getRowVisitor(String site, String mode, StringBuffer buffer, Integer[] failedNumber) {
|
||||
|
||||
return new RowVisitor<JSONObject>() {
|
||||
@Override
|
||||
public int visit(long index, JSONObject jsonObject) {
|
||||
Object[] params = new Object[10];
|
||||
params[0] = index;
|
||||
params[1] = jsonObject.getString("resourceType");
|
||||
|
||||
String resultMessage = null;
|
||||
try {
|
||||
if (jsonObject.containsKey("resourceType") && jsonObject.getString("resourceType").trim().length() > 0) {
|
||||
jsonObject.put("site", site);
|
||||
Collection<ResourceTypeBasicConfiguration> collection = ResourceTypeWSClient.find(jsonObject);
|
||||
if (collection.size() > 0) {
|
||||
resultMessage = "资源类型主数据已经存在";
|
||||
} else {
|
||||
ResourceTypeWSClient.insert(jsonObject);
|
||||
}
|
||||
|
||||
if (resultMessage != null) {
|
||||
params[2] = resultMessage;
|
||||
failedNumber[0]++;
|
||||
buffer.append("第" + index + "行:" + I18nUtil.getI18nText("MaterData.import.insert.fail", params) + "\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
} catch (Exception e) {
|
||||
params[2] = e.getMessage();
|
||||
failedNumber[0]++;
|
||||
buffer.append("第" + index + "行:" + I18nUtil.getI18nText("MaterData.import.insert.fail", params) + "\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getHeader() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue