CAPP接口功能开发

Leon 4 years ago
parent 44798dd703
commit bbb377436c

@ -44,5 +44,14 @@ public class CustomFieldConstant {
public static final String SFC_DATA_LOCATION = "LOCATION";
//**************************************************************************************
public static final String ITEM_ACCESSORY_TYPE = "ACCESSORY_TYPE";
public static final String ITEM_WEIGHT = "MAT_WEIGHT";
public static final String ITEM_MAT_SPEC = "MAT_SPEC";
public static final String ITEM_MODEL = "MODEL";
public static final String ITEM_TEXTURE = "TEXTURE";
public static final String ITEM_DRAWING = "DRAWING";
public static final String ITEM_DRAWING_REVISION = "DRAWING_REVISION";
}

@ -12,6 +12,7 @@ public class IntegrationTypeConstant {
public static final String ITEM = "ITEM";
public static final String BOM = "BOM";
public static final String ROUTER = "ROUTER";
public static final String DIS_ROUTER = "DIS_ROUTER";
public static final String SHOP_ORDER = "SHOP_ORDER";
public static final String ITEM_BATCH_RECEIVE = "ITEM_BATCH_RECEIVE";
}

@ -0,0 +1,103 @@
package com.foreverwin.mesnac.integration.dto;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
@XmlAccessorType( XmlAccessType.FIELD )
@XmlType(name = "RouterStepDto", propOrder = {
"STEP_ID",
"OPERATION",
"OPERATION_DESCRIPTION",
"REVISION",
"RESRCE",
"PROD_TIME",
"OUT_SOURCE"
})
public class DisRouterStepDto {
@XmlElement(name = "STEP_ID")
private String STEP_ID;
@XmlElement(name = "OPERATION")
private String OPERATION;
@XmlElement(name = "OPERATION_DESCRIPTION")
private String OPERATION_DESCRIPTION;
@XmlElement(name = "REVISION")
private String REVISION;
@XmlElement(name = "RESRCE")
private String RESRCE;
@XmlElement(name = "PROD_TIME")
private String PROD_TIME;
@XmlElement(name = "OUT_SOURCE")
private String OUT_SOURCE;
public String getSTEP_ID() {
return STEP_ID;
}
public void setSTEP_ID(String STEP_ID) {
this.STEP_ID = STEP_ID;
}
public String getOPERATION() {
return OPERATION;
}
public void setOPERATION(String OPERATION) {
this.OPERATION = OPERATION;
}
public String getOPERATION_DESCRIPTION() {
return OPERATION_DESCRIPTION;
}
public void setOPERATION_DESCRIPTION(String OPERATION_DESCRIPTION) {
this.OPERATION_DESCRIPTION = OPERATION_DESCRIPTION;
}
public String getREVISION() {
return REVISION;
}
public void setREVISION(String REVISION) {
this.REVISION = REVISION;
}
public String getRESRCE() {
return RESRCE;
}
public void setRESRCE(String RESRCE) {
this.RESRCE = RESRCE;
}
public String getPROD_TIME() {
return PROD_TIME;
}
public void setPROD_TIME(String PROD_TIME) {
this.PROD_TIME = PROD_TIME;
}
public String getOUT_SOURCE() {
return OUT_SOURCE;
}
public void setOUT_SOURCE(String OUT_SOURCE) {
this.OUT_SOURCE = OUT_SOURCE;
}
@Override
public String toString() {
return "DisRouterStepDto{" +
"STEP_ID='" + STEP_ID + '\'' +
", OPERATION='" + OPERATION + '\'' +
", OPERATION_DESCRIPTION='" + OPERATION_DESCRIPTION + '\'' +
", REVISION='" + REVISION + '\'' +
", RESRCE='" + RESRCE + '\'' +
", PROD_TIME='" + PROD_TIME + '\'' +
", OUT_SOURCE='" + OUT_SOURCE + '\'' +
'}';
}
}

@ -0,0 +1,98 @@
package com.foreverwin.mesnac.integration.dto;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import java.util.List;
/**
* 线
*
* @author Leon
* @date 2021-6-24
*/
@XmlAccessorType( XmlAccessType.FIELD )
@XmlType(name = "DisRouterSyncRequest", propOrder = {
"TRANID",
"DATE_TIME",
"SITE",
"FACTORY",
"ROUTER",
"OPERATION_LIST"
})
public class DisRouterSyncRequest {
@XmlElement(name = "TRANID")
private String TRANID;
@XmlElement(name = "DATE_TIME")
private String DATE_TIME;
@XmlElement(name = "SITE")
private String SITE;
@XmlElement(name = "FACTORY")
private String FACTORY;
@XmlElement(name = "ROUTER")
private String ROUTER;
@XmlElement(name = "OPERATION_LIST")
private List<DisRouterStepDto> OPERATION_LIST;
public String getTRANID() {
return TRANID;
}
public void setTRANID(String TRANID) {
this.TRANID = TRANID;
}
public String getDATE_TIME() {
return DATE_TIME;
}
public void setDATE_TIME(String DATE_TIME) {
this.DATE_TIME = DATE_TIME;
}
public String getSITE() {
return SITE;
}
public void setSITE(String SITE) {
this.SITE = SITE;
}
public String getFACTORY() {
return FACTORY;
}
public void setFACTORY(String FACTORY) {
this.FACTORY = FACTORY;
}
public String getROUTER() {
return ROUTER;
}
public void setROUTER(String ROUTER) {
this.ROUTER = ROUTER;
}
public List<DisRouterStepDto> getOPERATION_LIST() {
return OPERATION_LIST;
}
public void setOPERATION_LIST(List<DisRouterStepDto> OPERATION_LIST) {
this.OPERATION_LIST = OPERATION_LIST;
}
@Override
public String toString() {
return "DisRouterSyncRequest{" +
"TRANID='" + TRANID + '\'' +
", DATE_TIME='" + DATE_TIME + '\'' +
", SITE='" + SITE + '\'' +
", FACTORY='" + FACTORY + '\'' +
", ROUTER='" + ROUTER + '\'' +
", OPERATION_LIST=" + OPERATION_LIST +
'}';
}
}

@ -1,12 +1,16 @@
package com.foreverwin.mesnac.integration.dto;
import com.sap.me.common.ItemType;
import com.sap.me.common.MaterialType;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
@XmlAccessorType( XmlAccessType.FIELD )
@XmlType(name = "ItemRequest", propOrder = {
@XmlType(name = "ItemSyncRequest", propOrder = {
"TRANID",
"DATE_TIME",
"SITE",
@ -22,13 +26,13 @@ import javax.xml.bind.annotation.XmlType;
"INV_ASSY_DATA_TYPE",
"INGRED_TYPE",
"WEIGHT",
"SPEC",
"MAT_SPEC",
"MODEL",
"TEXTURE",
"DRAWING",
"DRAWING_REVISION"
})
public class ItemRequest {
public class ItemSyncRequest {
@XmlElement(name = "TRANID")
private String TRANID;
@ -38,28 +42,28 @@ public class ItemRequest {
@XmlElement(name = "SITE")
private String SITE;
//物料编号
@XmlElement(name = "ITEM")
private String ITEM;
//物料版本默认为A
@XmlElement(name = "REVISION")
private String REVISION;
//物料描述
@XmlElement(name = "MAKTX")
private String MAKTX;
//状态
@XmlElement(name = "STATUS")
private String STATUS;
//物料类型
@XmlElement(name = "ITEM_TYPE")
private String ITEM_TYPE;
//采购类型
@XmlElement(name = "PROCUREMENT_TYPE")
private String PROCUREMENT_TYPE;
//批次大小
@XmlElement(name = "LOT_SIZE")
private String LOT_SIZE;
//单位
@XmlElement(name = "UNIT_OF_MEASURE")
private String UNIT_OF_MEASURE;
@ -68,26 +72,26 @@ public class ItemRequest {
@XmlElement(name = "INV_ASSY_DATA_TYPE")
private String INV_ASSY_DATA_TYPE;
//辅料类型0或者空则不是辅料刀具-1其他-9
@XmlElement(name = "INGRED_TYPE")
private String INGRED_TYPE;
//重量
@XmlElement(name = "WEIGHT")
private String WEIGHT;
@XmlElement(name = "SPEC")
private String SPEC;
//规格
@XmlElement(name = "MAT_SPEC")
private String MAT_SPEC;
//型号
@XmlElement(name = "MODEL")
private String MODEL;
//材质
@XmlElement(name = "TEXTURE")
private String TEXTURE;
//图号
@XmlElement(name = "DRAWING")
private String DRAWING;
@XmlElement(name = "TEXTURE")
//图号版本
@XmlElement(name = "DRAWING_REVISION")
private String DRAWING_REVISION;
public String getTRANID() {
@ -210,12 +214,12 @@ public class ItemRequest {
this.WEIGHT = WEIGHT;
}
public String getSPEC() {
return SPEC;
public String getMAT_SPEC() {
return MAT_SPEC;
}
public void setSPEC(String SPEC) {
this.SPEC = SPEC;
public void setMAT_SPEC(String MAT_SPEC) {
this.MAT_SPEC = MAT_SPEC;
}
public String getMODEL() {
@ -252,7 +256,7 @@ public class ItemRequest {
@Override
public String toString() {
return "ItemRequest{" +
return "ItemSyncRequest{" +
"TRANID='" + TRANID + '\'' +
", DATE_TIME='" + DATE_TIME + '\'' +
", SITE='" + SITE + '\'' +
@ -268,7 +272,7 @@ public class ItemRequest {
", INV_ASSY_DATA_TYPE='" + INV_ASSY_DATA_TYPE + '\'' +
", INGRED_TYPE='" + INGRED_TYPE + '\'' +
", WEIGHT='" + WEIGHT + '\'' +
", SPEC='" + SPEC + '\'' +
", MAT_SPEC='" + MAT_SPEC + '\'' +
", MODEL='" + MODEL + '\'' +
", TEXTURE='" + TEXTURE + '\'' +
", DRAWING='" + DRAWING + '\'' +

@ -16,9 +16,9 @@ import java.math.BigDecimal;
})
public class RouterStepDto {
@XmlElement(name = "STEP_ID", required = true)
@XmlElement(name = "STEP_ID")
private String STEP_ID;
@XmlElement(name = "OPERATION", required = true)
@XmlElement(name = "OPERATION")
private String OPERATION;
@XmlElement(name = "REVISION")
private String REVISION;

@ -1,6 +1,8 @@
package com.foreverwin.mesnac.integration.service;
import com.foreverwin.mesnac.integration.dto.BomSyncRequest;
import com.foreverwin.mesnac.integration.dto.DisRouterSyncRequest;
import com.foreverwin.mesnac.integration.dto.ItemSyncRequest;
import com.foreverwin.mesnac.integration.dto.RouterSyncRequest;
import com.foreverwin.mesnac.integration.dto.WebServiceResponse;
import javax.jws.WebMethod;
@ -13,9 +15,18 @@ public interface CAPPAPIWebService {
/**
*
*
* @param bomSyncRequest
* @param itemSyncRequest
* @return
*/
@WebMethod(action = "http://service.integration.mesnac.com/itemSync")
WebServiceResponse itemSync(@WebParam(name = "itemSyncRequest") BomSyncRequest bomSyncRequest);
WebServiceResponse itemSync(@WebParam(name = "itemSyncRequest") ItemSyncRequest itemSyncRequest);
/**
* 线
*
* @param disRouterSyncRequest
* @return
*/
@WebMethod(action = "http://service.integration.mesnac.com/disRouterSync")
WebServiceResponse disRouterSync(@WebParam(name = "disRouterSyncRequest") DisRouterSyncRequest disRouterSyncRequest);
}

@ -1,20 +1,26 @@
package com.foreverwin.mesnac.integration.service;
import com.alibaba.fastjson.JSONObject;
import com.foreverwin.mesnac.integration.dto.BomSyncRequest;
import com.foreverwin.mesnac.integration.dto.ItemBatchReceiveRequest;
import com.foreverwin.mesnac.integration.dto.RouterSyncRequest;
import com.foreverwin.mesnac.integration.dto.ShopOrderSyncRequest;
import com.foreverwin.mesnac.integration.dto.*;
public interface InterfaceService {
/**
*
*
* @param jsonObject
* @param itemSyncRequest
* @throws Exception
*/
void createOrUpdateItem(JSONObject jsonObject) throws Exception;
void itemSync(String site, ItemSyncRequest itemSyncRequest) throws Exception;
/**
* 线
*
* @param site
* @param disRouterSyncRequest
* @throws Exception
*/
void disRouterSync(String site, DisRouterSyncRequest disRouterSyncRequest) throws Exception;
/**
*

@ -3,7 +3,9 @@ package com.foreverwin.mesnac.integration.service.impl;
import com.foreverwin.mesnac.common.constant.IntegrationTypeConstant;
import com.foreverwin.mesnac.common.util.ExceptionUtil;
import com.foreverwin.mesnac.common.util.StringUtil;
import com.foreverwin.mesnac.integration.dto.BomSyncRequest;
import com.foreverwin.mesnac.integration.dto.DisRouterSyncRequest;
import com.foreverwin.mesnac.integration.dto.ItemSyncRequest;
import com.foreverwin.mesnac.integration.dto.RouterSyncRequest;
import com.foreverwin.mesnac.integration.dto.WebServiceResponse;
import com.foreverwin.mesnac.integration.model.IntegrationLog;
import com.foreverwin.mesnac.integration.service.CAPPAPIWebService;
@ -30,32 +32,92 @@ public class CAPPAPIWebServiceImpl implements CAPPAPIWebService {
private IntegrationLogService integrationLogService;
@Override
public WebServiceResponse itemSync(BomSyncRequest bomSyncRequest) {
public WebServiceResponse itemSync(ItemSyncRequest itemSyncRequest) {
WebServiceResponse response = new WebServiceResponse();
String site = null;
try {
if (bomSyncRequest == null) {
if (itemSyncRequest == null) {
throw BusinessException.build("传递的参数格式不正确,或者为空");
}
if (StringUtil.isBlank(bomSyncRequest.getTRANID())) {
if (StringUtil.isBlank(itemSyncRequest.getTRANID())) {
throw BusinessException.build("参数【TRANID】不能为空");
}
if (StringUtil.isBlank(bomSyncRequest.getDATE_TIME())) {
if (StringUtil.isBlank(itemSyncRequest.getDATE_TIME())) {
throw BusinessException.build("参数【DATE_TIME】不能为空");
}
response.setHANDLE(bomSyncRequest.getTRANID());
response.setHANDLE(itemSyncRequest.getTRANID());
response.setSTATUS("S");
site = bomSyncRequest.getSITE();
String shopOrder = bomSyncRequest.getSHOP_ORDER();
site = itemSyncRequest.getSITE();
String item = itemSyncRequest.getITEM();
if (StringUtil.isBlank(site)) {
throw BusinessException.build("参数【SITE】不能为空");
}
if (StringUtil.isBlank(item)) {
throw BusinessException.build("参数【ITEM】不能为空");
}
//调用业务接口
interfaceService.itemSync(site, itemSyncRequest);
response.setMESSAGE("物料【" + item + "】数据同步成功");
} catch (Exception e) {
response.setSTATUS("E");
response.setMESSAGE(ExceptionUtil.getExceptionMsg(e));
} finally {
//记录接口日志
IntegrationLog log = new IntegrationLog();
log.setHandle(UUID.randomUUID().toString());
log.setSite(site);
log.setIntegrationType(IntegrationTypeConstant.ITEM);
log.setCategory("RESPONSE");
log.setIntegrationWay("CAPP");
log.setIntegrationMethod("InterfaceService.itemSync");
log.setParam(itemSyncRequest.toString());
log.setStatus(response.getSTATUS());
log.setResultMessage(response.getMESSAGE());
log.setTransactionId(itemSyncRequest.getTRANID());
log.setRequestDateTime(LocalDateTime.parse(itemSyncRequest.getDATE_TIME(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
log.setCreatedDateTime(LocalDateTime.now());
integrationLogService.saveIntegrationLog(log);
}
//接口返回
return response;
}
@Override
public WebServiceResponse disRouterSync(DisRouterSyncRequest disRouterSyncRequest) {
WebServiceResponse response = new WebServiceResponse();
String site = null;
try {
if (disRouterSyncRequest == null) {
throw BusinessException.build("传递的参数格式不正确,或者为空");
}
if (StringUtil.isBlank(disRouterSyncRequest.getTRANID())) {
throw BusinessException.build("参数【TRANID】不能为空");
}
if (StringUtil.isBlank(disRouterSyncRequest.getDATE_TIME())) {
throw BusinessException.build("参数【DATE_TIME】不能为空");
}
response.setHANDLE(disRouterSyncRequest.getTRANID());
response.setSTATUS("S");
site = disRouterSyncRequest.getSITE();
String router = disRouterSyncRequest.getROUTER();
if (StringUtil.isBlank(site)) {
throw BusinessException.build("参数【SITE】不能为空");
}
if (StringUtil.isBlank(router)) {
throw BusinessException.build("参数【ROUTER】不能为空");
}
//调用业务接口
interfaceService.bomSync(site, bomSyncRequest);
response.setMESSAGE("工单【" + shopOrder + "】BOM数据同步成功");
interfaceService.disRouterSync(site, disRouterSyncRequest);
response.setMESSAGE("返工工艺路线【" + router + "】同步成功");
} catch (Exception e) {
response.setSTATUS("E");
@ -66,15 +128,15 @@ public class CAPPAPIWebServiceImpl implements CAPPAPIWebService {
IntegrationLog log = new IntegrationLog();
log.setHandle(UUID.randomUUID().toString());
log.setSite(site);
log.setIntegrationType(IntegrationTypeConstant.BOM);
log.setIntegrationType(IntegrationTypeConstant.DIS_ROUTER);
log.setCategory("RESPONSE");
log.setIntegrationWay("ERP");
log.setIntegrationMethod("InterfaceService.shopOrderSync");
log.setParam(bomSyncRequest.toString());
log.setIntegrationWay("CAPP");
log.setIntegrationMethod("InterfaceService.disRouterSync");
log.setParam(disRouterSyncRequest.toString());
log.setStatus(response.getSTATUS());
log.setResultMessage(response.getMESSAGE());
log.setTransactionId(bomSyncRequest.getTRANID());
log.setRequestDateTime(LocalDateTime.parse(bomSyncRequest.getDATE_TIME(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
log.setTransactionId(disRouterSyncRequest.getTRANID());
log.setRequestDateTime(LocalDateTime.parse(disRouterSyncRequest.getDATE_TIME(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
log.setCreatedDateTime(LocalDateTime.now());
integrationLogService.saveIntegrationLog(log);
}

@ -1,8 +1,8 @@
package com.foreverwin.mesnac.integration.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.foreverwin.mesnac.common.constant.Constants;
import com.foreverwin.mesnac.common.constant.CustomFieldConstant;
import com.foreverwin.mesnac.common.constant.DataImportConstant;
import com.foreverwin.mesnac.common.enums.HandleEnum;
import com.foreverwin.mesnac.common.util.StringUtil;
import com.foreverwin.mesnac.dispatch.model.ItemBatch;
@ -19,13 +19,9 @@ import com.sap.me.common.ObjectReference;
import com.sap.me.common.ProcurementType;
import com.sap.me.demand.*;
import com.sap.me.productdefinition.*;
import com.sap.me.production.ChangeProductionContext;
import com.sap.me.production.ChangeProductionRequest;
import com.sap.me.production.ChangeProductionServiceInterface;
import com.sap.me.production.OperationPlacementTypeEnum;
import com.visiprise.globalization.DateGlobalizationServiceInterface;
import com.visiprise.globalization.GlobalizationService;
import com.visiprise.globalization.util.DateTimeInterface;
import com.visiprise.model.BOMType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.i18n.LocaleContextHolder;
@ -52,12 +48,12 @@ public class InterfaceServiceImpl implements InterfaceService {
@Autowired
private BomService bomService;
@Autowired
private SfcService sfcService;
@Autowired
private ItemService itemService;
@Autowired
private RouterService routerService;
@Autowired
private ResrceService resrceService;
@Autowired
private ShopOrderService shopOrderService;
@Autowired
private ItemBatchService itemBatchService;
@ -68,37 +64,38 @@ public class InterfaceServiceImpl implements InterfaceService {
@Override
public void createOrUpdateItem(JSONObject jsonObject) throws Exception{
//数据主键
String site = jsonObject.getString("SITE");
public void itemSync(String site, ItemSyncRequest itemSyncRequest) throws Exception{
//物料
String item = jsonObject.getString("ITEM");
String item = itemSyncRequest.getITEM();
//版本:默认值A
String revision = jsonObject.getString("REVISION");
String revision = itemSyncRequest.getREVISION();
revision = StringUtil.notBlank(revision) ? revision : "A";
//物料描述
String itemDescription = jsonObject.getString("MAKTX");
String itemDescription = itemSyncRequest.getMAKTX();
//状态
String status = jsonObject.getString("STATUS");
String status = itemSyncRequest.getSTATUS();
String statusBo = HandleEnum.STATUS.getHandle(site, status);
//物料类型(FERT(已完成)/ROH(原始)/HALB(半成品)/KMAT(可配置)/INST(安装)/VERP(包装)/FHMI(生产资源/工具)/CSTM(自定义))
String itemType = jsonObject.getString("ITEM_TYPE");
String itemType = itemSyncRequest.getITEM_TYPE();
//采购类型(M(制造)/P(采购)/B(制造/采购))
String procurementType = jsonObject.getString("PROCUREMENT_TYPE");
String procurementType = itemSyncRequest.getPROCUREMENT_TYPE();
if (!"M".equals(procurementType) && !"P".equals(procurementType) && !"B".equals(procurementType)) {
throw BusinessException.build("参数【PROCUREMENT_TYPE】支持的值为【M、P、B】");
}
//批次大小
String lotSize = jsonObject.getString("LOT_SIZE");
String lotSize = itemSyncRequest.getLOT_SIZE();
lotSize = StringUtil.notBlank(lotSize) ? lotSize : "999999";
//装配时要收集的数据
String assyDataType = jsonObject.getString(" ASSY_DATA_TYPE");
String assyDataType = itemSyncRequest.getASSY_DATA_TYPE();
//库存接收数据类型
String invAssyDataType = jsonObject.getString("INV_ASSY_DATA_TYPE");
String invAssyDataType = itemSyncRequest.getINV_ASSY_DATA_TYPE();
//计量单位
String unitOfMeasure = jsonObject.getString("UNIT_OF_MEASURE");
String unitOfMeasure = itemSyncRequest.getUNIT_OF_MEASURE();
//物料标准API
ItemConfigurationServiceInterface itemServiceInterFace = MEServices.create("com.sap.me.productdefinition", "ItemConfigurationService", site);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//物料是否存在
String itemBo = HandleEnum.ITEM.getHandle(site, item, revision);
Item itemModel = itemService.getById(itemBo);
@ -154,6 +151,222 @@ public class InterfaceServiceImpl implements InterfaceService {
//更新物料
itemServiceInterFace.updateItem(updateItem);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
List<CustomFields> customFieldsList = new ArrayList<>();
CustomFields customFields = null;
//辅料类型ACCESSORY_TYPE
String ingredType = itemSyncRequest.getINGRED_TYPE();
if (StringUtil.notBlank(ingredType)) {
customFields = new CustomFields();
customFields.setHandle(itemBo);
customFields.setAttribute(CustomFieldConstant.ITEM_ACCESSORY_TYPE);
customFields.setValue(ingredType);
customFieldsList.add(customFields);
}
//重量
String weight = itemSyncRequest.getWEIGHT();
if (StringUtil.notBlank(ingredType)) {
customFields = new CustomFields();
customFields.setHandle(itemBo);
customFields.setAttribute(CustomFieldConstant.ITEM_WEIGHT);
customFields.setValue(weight);
customFieldsList.add(customFields);
}
//规格
String spec = itemSyncRequest.getMAT_SPEC();
if (StringUtil.notBlank(ingredType)) {
customFields = new CustomFields();
customFields.setHandle(itemBo);
customFields.setAttribute(CustomFieldConstant.ITEM_MAT_SPEC);
customFields.setValue(spec);
customFieldsList.add(customFields);
}
//型号
String model = itemSyncRequest.getMODEL();
if (StringUtil.notBlank(ingredType)) {
customFields = new CustomFields();
customFields.setHandle(itemBo);
customFields.setAttribute(CustomFieldConstant.ITEM_MODEL);
customFields.setValue(model);
customFieldsList.add(customFields);
}
//材质
String texture = itemSyncRequest.getTEXTURE();
if (StringUtil.notBlank(ingredType)) {
customFields = new CustomFields();
customFields.setHandle(itemBo);
customFields.setAttribute(CustomFieldConstant.ITEM_TEXTURE);
customFields.setValue(texture);
customFieldsList.add(customFields);
}
//图号
String drawing = itemSyncRequest.getDRAWING();
if (StringUtil.notBlank(ingredType)) {
customFields = new CustomFields();
customFields.setHandle(itemBo);
customFields.setAttribute(CustomFieldConstant.ITEM_DRAWING);
customFields.setValue(drawing);
customFieldsList.add(customFields);
}
//图号版本
String drawingRevision = itemSyncRequest.getDRAWING_REVISION();
if (StringUtil.notBlank(ingredType)) {
customFields = new CustomFields();
customFields.setHandle(itemBo);
customFields.setAttribute(CustomFieldConstant.ITEM_DRAWING_REVISION);
customFields.setValue(drawingRevision);
customFieldsList.add(customFields);
}
//自定义数据保存
if (customFieldsList != null && customFieldsList.size() > 0) {
customFieldsService.saveOrUpdateCustomFields(customFieldsList);
}
}
@Override
public void disRouterSync(String site, DisRouterSyncRequest disRouterSyncRequest) throws Exception {
//获取工艺路线标准服务
RouterConfigurationServiceInterface routerConfigurationService = MEServices.create("com.sap.me.productdefinition", "RouterConfigurationService", site);
//工单编号作为工艺路线编号
String router = disRouterSyncRequest.getROUTER();
if (StringUtil.isBlank(router)) {
throw BusinessException.build("工艺路线编号不能为空");
}
//工艺路线步骤是否有值
List<DisRouterStepDto> routerStepDtoList = disRouterSyncRequest.getOPERATION_LIST();
if (routerStepDtoList == null || routerStepDtoList.size() <= 0) {
throw BusinessException.build("工艺路线步骤不能为空");
}
//工艺路线BO
Float revision = new Float(1.0);
String routerType = RouterType.SHOPORDER_SPECIFIC.value();
String routerBo = HandleEnum.ROUTER.getHandle(site, router, routerType, revision.toString());
//查询工艺路线是否存在, 不存在版本默认为1.0,存在最大版本+1最为当前版本
Router routerModel = routerService.getMaxRevisionRouter(site, router);
if (routerModel != null) {
Float currentRevision = new Float(routerModel.getRevision());
revision = currentRevision + 1;
routerBo = HandleEnum.ROUTER.getHandle(site, router, routerType, revision.toString());
}
//工艺路线参数组装
RouterConfiguration routerConfiguration = new RouterConfiguration();
routerConfiguration.setRef(routerBo);
routerConfiguration.setRouter(router);
routerConfiguration.setDescription(router);
routerConfiguration.setRevision(revision.toString());
routerConfiguration.setRouterType(com.sap.me.common.RouterType.SHOPORDER_SPECIFIC);
routerConfiguration.setCurrentRevision(true);
routerConfiguration.setStatus(RouterStatus.Releasable);
//入口步骤
String entryRouterStep = null;
//工艺路线步骤集合
List<RouterStep> routerStepList = new ArrayList<>();
//自定义字段集合
List<CustomFields> customFieldsList = new ArrayList<>();
//工艺路线步骤
for (int i = 0; i < routerStepDtoList.size(); i++) {
DisRouterStepDto routerStepDto = routerStepDtoList.get(i);
String stepId = "90" + routerStepDto.getSTEP_ID();
if (StringUtil.isBlank(entryRouterStep)) {
entryRouterStep = stepId;
}
//上一步骤添加当前步骤为下一步骤
if (i > 0) {
RouterNextStep routerNextStep = new RouterNextStep();
routerNextStep.setNextStepId(stepId);
routerStepList.get(i-1).getRouterNextStepList().add(routerNextStep);
}
String resource = routerStepDto.getRESRCE();
String operation = routerStepDto.getOPERATION();
String _revision = routerStepDto.getREVISION();
_revision = StringUtil.notBlank(_revision) ? _revision : "1.0";
String description = routerStepDto.getOPERATION_DESCRIPTION();
//工序创建
Operation operationModel = this.createResourceOfOperation(site, resource, operation, description, _revision);
String operationBo = operationModel.getHandle();
//工艺路线步骤
RouterStep routerStep = new RouterStep();
routerStep.setSequence(new BigDecimal(i+1));
routerStep.setStepId(stepId);
routerStep.setDescription(operation);
routerStep.setRework(true);
routerStep.setQueueDecisionType(QueueDecisionType.COMPLETING_OPERATOR);
//工艺路线步骤工序 RouterComponentContext
RouterComponentContext routerComponentContext = new RouterComponentContext();
RouterOperation routerOperation = new RouterOperation();
//工艺路线步骤工序默认当前版本
routerOperation.setOperationRef(operationBo);
routerOperation.setStepType(RouterStepType.NORMAL);
routerComponentContext.setRouterOperation(routerOperation);
routerStep.setRouterComponentContext(routerComponentContext);
//步骤入仓
routerStepList.add(routerStep);
//自定义字段
String routerOperationBO = HandleEnum.ROUTER_OPERATION.getHandle(routerBo, stepId);
CustomFields customFields = new CustomFields();
customFields.setHandle(routerOperationBO);
customFields.setAttribute(CustomFieldConstant.ROUTER_OP_PROD_TIME);
customFields.setValue(routerStepDto.getPROD_TIME());
customFieldsList.add(customFields);
customFields = new CustomFields();
customFields.setHandle(routerOperationBO);
customFields.setAttribute(CustomFieldConstant.ROUTER_OP_OUT_SOURCE);
customFields.setValue(routerStepDto.getOUT_SOURCE());
customFieldsList.add(customFields);
}//end for
//添加返回原始工序步骤
String returnStepId = "9099";
RouterStep routerStep = new RouterStep();
routerStep.setSequence(new BigDecimal(returnStepId));
RouterComponentContext routerComponentContext = new RouterComponentContext();
RouterReturnStep routerReturnStep = new RouterReturnStep();
routerReturnStep.setReturnType(ReturnType.ORIGINAL_OPERATION);
routerReturnStep.setCompleteOriginal(true);
routerComponentContext.setRouterReturnStep(routerReturnStep);
routerStep.setRouterComponentContext(routerComponentContext);
routerStep.setStepId(returnStepId);
routerStepList.add(routerStep);
//完成工序添加到下一步骤
RouterNextStep routerNextStep = new RouterNextStep();
routerNextStep.setNextStepId(returnStepId);
routerStepList.get(routerStepList.size()-2).getRouterNextStepList().add(routerNextStep);
routerConfiguration.setEntryRouterStep(entryRouterStep);
routerConfiguration.setRouterStepList(routerStepList);
//工艺路线创建
routerConfigurationService.createRouter(routerConfiguration);
//自定义数据保存
if (customFieldsList != null && customFieldsList.size() > 0) {
customFieldsService.saveOrUpdateCustomFields(customFieldsList);
}
}
@Override
@ -604,4 +817,57 @@ public class InterfaceServiceImpl implements InterfaceService {
}
}
}
/**
*
*
*/
Operation createResourceOfOperation(String site, String resource, String operation, String description, String revision) {
String resourceBo = HandleEnum.RESOURCE.getHandle(site, resource);
Resrce resourceModel = resrceService.getById(resourceBo);
if (resourceModel == null) {
throw BusinessException.build("资源【" +resource+ "】不存在!");
}
String operationBo = HandleEnum.OPERATION.getHandle(site, operation, revision);
//查询设备所属类型以及对应工序
List<Map<String, Object>> mapList = resrceService.getResourceOperation(resourceBo);
if (mapList == null || mapList.size() <= 0) {
throw BusinessException.build("资源【" +resource+ "】不存在!");
}
Map<String, Object> map = mapList.get(0);
String _operationBo = (String) map.get("OPERATION_BO");
String resourceType = (String) map.get("RESOURCE_TYPE");
if (StringUtil.isBlank(resourceType)) {
throw BusinessException.build("设备【" +resource+ "】没有维护设备类型!");
}
//查询工序是否存在
Operation queryOperation = operationService.getById(operationBo);
if (queryOperation != null) {
if (operationBo.equals(_operationBo)) {
return queryOperation;
} else {
throw BusinessException.build("工序【" + operation + " 】已经存在!");
}
}
String status201Bo = HandleEnum.STATUS.getHandle(site, "201");
String resourceTypeBo = HandleEnum.RESOURCE_TYPE.getHandle(site, resourceType);
//创建工序
Operation operationModel = new Operation();
operationModel.setHandle(operationBo);
operationModel.setSite(site);
operationModel.setOperation(operation);
operationModel.setRevision(revision);
operationModel.setDescription(description);
operationModel.setCurrentRevision("true");
operationModel.setStatusBo(status201Bo);
operationModel.setType("N");
operationModel.setResourceTypeBo(resourceTypeBo);
operationModel.setCreatedDateTime(LocalDateTime.now());
operationService.save(operationModel);
return operationModel;
}
}

@ -35,4 +35,5 @@ public interface ResrceMapper extends BaseMapper<Resrce> {
List<Resrce> findResourceListByResourceType(@Param("site")String site,@Param("resourceTypeBo")String resourceTypeBo);
List<Map<String, Object>> selectResourceOperation(@Param("resourceBo") String resourceBo);
}

@ -61,4 +61,12 @@ public interface ResrceService extends IService<Resrce> {
*/
List<Resrce> findResourceListByResourceType(String site,String resourceTypeBo);
/**
*
*
* @param resourceBo
* @return
*/
List<Map<String, Object>> getResourceOperation(String resourceBo);
}

@ -84,5 +84,10 @@ public class ResrceServiceImpl extends ServiceImpl<ResrceMapper, Resrce> impleme
return resrceMapper.findResourceListByResourceType(site,resourceTypeBo);
}
@Override
public List<Map<String, Object>> getResourceOperation(String resourceBo) {
return resrceMapper.selectResourceOperation(resourceBo);
}
}

@ -578,5 +578,12 @@
</select>
<select id="selectResourceOperation" resultType="java.util.HashMap">
SELECT RS.SITE, RS.RESRCE, OP.HANDLE OPERATION_BO,OP.OPERATION, RT.RESOURCE_TYPE
FROM RESRCE RS
LEFT JOIN RESOURCE_TYPE_RESOURCE RR ON RS.HANDLE = RR.RESOURCE_BO
LEFT JOIN OPERATION OP ON OP.RESOURCE_TYPE_BO = RR.RESOURCE_TYPE_BO
LEFT JOIN RESOURCE_TYPE RT ON RT.HANDLE = RR.RESOURCE_TYPE_BO
WHERE RS.HANDLE = #{resourceBo}
</select>
</mapper>

@ -7,15 +7,15 @@ import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.foreverwin.mesnac.common.constant.Constants;
import com.foreverwin.mesnac.common.enums.HandleEnum;
import com.foreverwin.mesnac.common.model.Tool;
import com.foreverwin.mesnac.common.service.CommonService;
import com.foreverwin.mesnac.common.service.ToolService;
import com.foreverwin.mesnac.common.util.StringUtil;
import com.foreverwin.mesnac.meapi.dto.SfcDto;
import com.foreverwin.mesnac.production.mapper.CutterLogMapper;
import com.foreverwin.mesnac.production.mapper.SfcCrossMapper;
import com.foreverwin.mesnac.production.model.CutterLog;
import com.foreverwin.mesnac.production.model.Tool;
import com.foreverwin.mesnac.production.service.CutterLogService;
import com.foreverwin.mesnac.production.service.ToolService;
import com.foreverwin.modular.core.exception.BaseException;
import com.foreverwin.modular.core.util.CommonMethods;
import com.foreverwin.modular.core.util.FrontPage;
@ -50,6 +50,7 @@ public class CutterLogServiceImpl extends ServiceImpl<CutterLogMapper, CutterLog
private CommonService commonService;
@Autowired
private ToolService toolService;
@Override
public IPage<CutterLog> selectPage(FrontPage<CutterLog> frontPage, CutterLog cutterLog) {
QueryWrapper<CutterLog> queryWrapper = new QueryWrapper<>();

Loading…
Cancel
Save