工单回传

highway
zhaoxiaolin 1 year ago
parent 45f0745fae
commit 5ddc72024f

@ -32,5 +32,4 @@ public interface RemoteMesService {
/**获取领料单**/ /**获取领料单**/
@PostMapping("/prepare/getMesPrepare") @PostMapping("/prepare/getMesPrepare")
public R getMesPrepare(); public R getMesPrepare();
} }

@ -2,6 +2,7 @@ package com.op.system.api;
import com.op.common.core.constant.ServiceNameConstants; import com.op.common.core.constant.ServiceNameConstants;
import com.op.common.core.domain.R; import com.op.common.core.domain.R;
import com.op.system.api.domain.sap.SapCreateOrder;
import com.op.system.api.domain.sap.SapMaterialPreparation; import com.op.system.api.domain.sap.SapMaterialPreparation;
import com.op.system.api.factory.RemoteSapFallbackFactory; import com.op.system.api.factory.RemoteSapFallbackFactory;
import com.op.system.api.model.SapProOrder; import com.op.system.api.model.SapProOrder;
@ -28,4 +29,8 @@ public interface RemoteSapService {
public R<Boolean> sapProRouteProcess(); public R<Boolean> sapProRouteProcess();
@PostMapping("/sap/materialPreparation") @PostMapping("/sap/materialPreparation")
public R<List<SapMaterialPreparation>>materialPreparation(@RequestParam("shopOrder") String shopOrder); public R<List<SapMaterialPreparation>>materialPreparation(@RequestParam("shopOrder") String shopOrder);
/**回传sap母工单**/
@PostMapping("/sap/SapCreateOrder")
public R SapCreateOrder(@RequestBody List<SapCreateOrder> sapCreateOrderList);
} }

@ -0,0 +1,124 @@
package com.op.system.api.domain.sap;
public class SapCreateOrder {
private String werks;//工厂编码
private String aufpar;//订单类型
private String matnr;//物料编号
private String quantity;//数量
private String dates;//开始时间
private String datee;//完成时间
public String getWerks() {
return werks;
}
public void setWerks(String werks) {
this.werks = werks;
}
public String getAufpar() {
return aufpar;
}
public void setAufpar(String aufpar) {
this.aufpar = aufpar;
}
public String getMatnr() {
return matnr;
}
public void setMatnr(String matnr) {
this.matnr = matnr;
}
public String getQuantity() {
return quantity;
}
public void setQuantity(String quantity) {
this.quantity = quantity;
}
public String getDates() {
return dates;
}
public void setDates(String dates) {
this.dates = dates;
}
public String getDatee() {
return datee;
}
public void setDatee(String datee) {
this.datee = datee;
}
// @NotNull(message = "计划工厂不能为空")
// @NotBlank(message = "计划工厂不能为空")
// @Size(min = 0, max = 4, message = "计划工厂长度不能超过4个字符")
// public String getP_WERKS() {
// return P_WERKS;
// }
//
// public void setP_WERKS(String p_WERKS) {
// P_WERKS = p_WERKS;
// }
// @NotNull
// @NotBlank(message = "订单类型不能为空")
// @Size(min = 0, max = 4, message = "订单类型长度不能超过64个字符")
// public String getP_AUFPAR() {
// return P_AUFPAR;
// }
//
// public void setP_AUFPAR(String p_AUFPAR) {
// P_AUFPAR = p_AUFPAR;
// }
// @NotNull
// @NotBlank(message = "物料编号不能为空")
// @Size(min = 0, max = 18, message = "物料编号长度不能超过18个字符")
// public String getP_MATNR() {
// return P_MATNR;
// }
//
// public void setP_MATNR(String p_MATNR) {
// P_MATNR = p_MATNR;
// }
// @NotNull
// @NotBlank(message = "数量不能为空")
// public String getP_QUANTITY() {
// return P_QUANTITY;
// }
//
// public void setP_QUANTITY(String p_QUANTITY) {
// P_QUANTITY = p_QUANTITY;
// }
// @NotNull
// @NotBlank(message = "开始时间不能为空")
// @Size(min = 0, max = 8, message = "开始时间长度不能超过8个字符")
// public String getP_DATES() {
// return P_DATES;
// }
//
// public void setP_DATES(String p_DATES) {
// P_DATES = p_DATES;
// }
// @NotNull
// @NotBlank(message = "完成时间不能为空")
// @Size(min = 0, max = 8, message = "完成时间长度不能超过8个字符")
// public String getP_DATEE() {
// return P_DATEE;
// }
//
// public void setP_DATEE(String p_DATEE) {
// P_DATEE = p_DATEE;
// }
}

@ -2,6 +2,7 @@ package com.op.system.api.factory;
import com.op.common.core.domain.R; import com.op.common.core.domain.R;
import com.op.system.api.RemoteSapService; import com.op.system.api.RemoteSapService;
import com.op.system.api.domain.sap.SapCreateOrder;
import com.op.system.api.domain.sap.SapMaterialPreparation; import com.op.system.api.domain.sap.SapMaterialPreparation;
import com.op.system.api.model.SapProOrder; import com.op.system.api.model.SapProOrder;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -36,6 +37,11 @@ public class RemoteSapFallbackFactory implements FallbackFactory<RemoteSapServic
public R<List<SapMaterialPreparation>> materialPreparation(String shopOrder) { public R<List<SapMaterialPreparation>> materialPreparation(String shopOrder) {
return R.fail("SAP服务获取SAP领料单失败:" + throwable.getMessage()); return R.fail("SAP服务获取SAP领料单失败:" + throwable.getMessage());
} }
@Override
public R SapCreateOrder(List<SapCreateOrder> sapCreateOrderList) {
return R.fail("回传sap工单失败:" + throwable.getMessage());
}
}; };
} }
} }

@ -26,7 +26,6 @@ public interface ProOrderWorkorderMapper {
* @return * @return
*/ */
public ProOrderWorkorder selectProOrderWorkorderByWorkorderId(String workorderId); public ProOrderWorkorder selectProOrderWorkorderByWorkorderId(String workorderId);
public ProOrderWorkorder selectWhiteOrderWorkorderById(ProOrderWorkorder proOrderWorkorder);
/** /**
* *
* *

@ -2,6 +2,7 @@ package com.op.plan.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.dynamic.datasource.annotation.DS;
import com.op.common.core.context.SecurityContextHolder; import com.op.common.core.context.SecurityContextHolder;
import com.op.common.core.domain.R;
import com.op.common.core.utils.DateUtils; import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.bean.BeanUtils; import com.op.common.core.utils.bean.BeanUtils;
import com.op.common.core.utils.uuid.IdUtils; import com.op.common.core.utils.uuid.IdUtils;
@ -12,10 +13,14 @@ import com.op.plan.domain.dto.ProOrderDTO;
import com.op.plan.domain.dto.SplitOrderDTO; import com.op.plan.domain.dto.SplitOrderDTO;
import com.op.plan.mapper.*; import com.op.plan.mapper.*;
import com.op.plan.service.IProOrderWorkorderService; import com.op.plan.service.IProOrderWorkorderService;
import com.op.system.api.RemoteSapService;
import com.op.system.api.domain.dto.MesPrepareDTO; import com.op.system.api.domain.dto.MesPrepareDTO;
import com.op.system.api.domain.dto.MesPrepareDetailDTO; import com.op.system.api.domain.dto.MesPrepareDetailDTO;
import com.op.system.api.domain.sap.SapCreateOrder;
import net.bytebuddy.matcher.FilterableList; import net.bytebuddy.matcher.FilterableList;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -35,6 +40,7 @@ import static com.op.common.core.web.domain.AjaxResult.success;
*/ */
@Service @Service
public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService { public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
protected Logger logger = LoggerFactory.getLogger(getClass());
@Autowired @Autowired
private ProOrderWorkorderMapper proOrderWorkorderMapper; private ProOrderWorkorderMapper proOrderWorkorderMapper;
@Autowired @Autowired
@ -45,8 +51,8 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
private ProWorkorderProcessDetailMapper proWorkorderProcessDetailMapper; private ProWorkorderProcessDetailMapper proWorkorderProcessDetailMapper;
@Autowired @Autowired
private ProWetMaterialPlanDetailMapper proWetMaterialPlanDetailMapper; private ProWetMaterialPlanDetailMapper proWetMaterialPlanDetailMapper;
@Autowired
private RemoteSapService remoteSapService;
/** /**
* *
* *
@ -195,10 +201,11 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
} }
} }
} }
List<SapCreateOrder> sapList = new ArrayList<>();//回传给sap的工单
//如果是白坯生成备料单 //如果是白坯生成备料单
for(String workorderId:workorderIds){ for(String workorderId:workorderIds){
ProOrderWorkorder whiteOrder = proOrderWorkorderMapper.selectProOrderWorkorderByWorkorderId(workorderId); ProOrderWorkorder whiteOrder = proOrderWorkorderMapper.selectProOrderWorkorderByWorkorderId(workorderId);
if(whiteOrder!=null){//是白坯订单,自主生成领料单; if(whiteOrder!=null&&"white".equals(whiteOrder.getProdType())){//是白坯订单,自主生成领料单;
//备(领)料主单 //备(领)料主单
MesPrepareDTO mesPrepare = new MesPrepareDTO(); MesPrepareDTO mesPrepare = new MesPrepareDTO();
BeanUtils.copyBeanProp(mesPrepare,whiteOrder); BeanUtils.copyBeanProp(mesPrepare,whiteOrder);
@ -225,8 +232,22 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
} }
details.add(detail); details.add(detail);
proOrderWorkorderMapper.createPrepareDetails(details); proOrderWorkorderMapper.createPrepareDetails(details);
}else if(whiteOrder!=null){//成品的母工单回传sap
SapCreateOrder sap = new SapCreateOrder();
sap.setWerks(whiteOrder.getFactoryCode());//工厂编码
sap.setAufpar(whiteOrder.getProdType());//订单类型
sap.setMatnr(whiteOrder.getProductCode());//物料编号
sap.setQuantity(whiteOrder.getQuantitySplit()+"");//数量
sap.setDates(DateUtils.parseDateToStr("yyyy-MM-dd",whiteOrder.getProductDate()));//开始时间
sap.setDatee(DateUtils.parseDateToStr("yyyy-MM-dd",whiteOrder.getProductDate()));//完成时间
sapList.add(sap);
} }
} }
if(!CollectionUtils.isEmpty(sapList)){
R r = remoteSapService.SapCreateOrder(sapList);
logger.info("sap工单回传"+r.getMsg());
}
//下达工单 //下达工单
return proOrderWorkorderMapper.downProOrderWorkorderByWorkorderIds(workorderIds); return proOrderWorkorderMapper.downProOrderWorkorderByWorkorderIds(workorderIds);
} }

@ -82,10 +82,9 @@
<select id="selectProOrderWorkorderByWorkorderId" parameterType="String" resultMap="ProOrderWorkorderResult"> <select id="selectProOrderWorkorderByWorkorderId" parameterType="String" resultMap="ProOrderWorkorderResult">
<include refid="selectProOrderWorkorderVo"/> <include refid="selectProOrderWorkorderVo"/>
where workorder_id = #{workorderId} where workorder_id = #{workorderId}
</select> <if test="prodType != null and prodType != ''">
<select id="selectWhiteOrderWorkorderById" resultMap="ProOrderWorkorderResult"> and prod_type = #{prodType}
<include refid="selectProOrderWorkorderVo"/> </if>
where workorder_id = #{workorderId} and prod_type = #{prodType}
</select> </select>
<select id="selectFirWorkOrder" parameterType="String" resultMap="ProOrderWorkorderResult"> <select id="selectFirWorkOrder" parameterType="String" resultMap="ProOrderWorkorderResult">
<include refid="selectProOrderWorkorderVo"/> <include refid="selectProOrderWorkorderVo"/>

@ -12,6 +12,7 @@ import com.op.sap.domain.SapBom;
import com.op.sap.service.SapMaterialPreparationService; import com.op.sap.service.SapMaterialPreparationService;
import com.op.sap.service.SapOrderService; import com.op.sap.service.SapOrderService;
import com.op.sap.service.SapService; import com.op.sap.service.SapService;
import com.op.system.api.domain.sap.SapCreateOrder;
import com.op.system.api.domain.sap.SapMaterialPreparation; import com.op.system.api.domain.sap.SapMaterialPreparation;
import com.op.system.api.model.SapProOrder; import com.op.system.api.model.SapProOrder;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -75,21 +76,15 @@ public class SapController extends BaseController {
return sapMaterialPreparationService.MaterialPreparation(shopOrder); return sapMaterialPreparationService.MaterialPreparation(shopOrder);
} }
// @PostMapping("saveItem")
// public R<Boolean> saveItem(){
// return sapService.sapItem();
// }
// @PostMapping("saveProRoute")
// public R<Boolean> saveProRoute(){return sapService.sapProRoute();}
// @PostMapping("/sapProRouteProduct")
// public R<Boolean> sapProRouteProduct(){
// return sapService.sapProRouteProduct();
// }
@PostMapping("/sapProRouteProcess") @PostMapping("/sapProRouteProcess")
public R<Boolean> sapProRouteProcess() { public R<Boolean> sapProRouteProcess() {
return sapService.sapProRouteProcess(); return sapService.sapProRouteProcess();
} }
@PostMapping("/SapCreateOrder")
@Log(title = "生产订单创建接口", businessType = BusinessType.SAP)
public R SapCreateOrder(@RequestBody List<SapCreateOrder> sapCreateOrderList){
return sapOrderService.SapCreateOrder(sapCreateOrderList);
}
} }

@ -2,7 +2,7 @@ package com.op.sap.service;
import com.op.common.core.domain.R; import com.op.common.core.domain.R;
import com.op.common.core.web.domain.AjaxResult; import com.op.common.core.web.domain.AjaxResult;
import com.op.sap.domain.SapBom; import com.op.system.api.domain.sap.SapCreateOrder;
import com.op.system.api.model.SapProOrder; import com.op.system.api.model.SapProOrder;
import java.util.List; import java.util.List;
@ -10,4 +10,6 @@ import java.util.List;
public interface SapOrderService { public interface SapOrderService {
R<List<SapProOrder>> shopOrderSync(SapProOrder sapProOrder); R<List<SapProOrder>> shopOrderSync(SapProOrder sapProOrder);
R SapCreateOrder(List<SapCreateOrder> sapCreateOrderList);
} }

@ -4,23 +4,12 @@ import com.op.common.core.domain.R;
import com.op.common.core.utils.DateUtils; import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.uuid.IdUtils; import com.op.common.core.utils.uuid.IdUtils;
import com.op.common.core.web.domain.AjaxResult; import com.op.common.core.web.domain.AjaxResult;
import com.op.sap.domain.SapConn;
import com.op.sap.service.SapOrderService; import com.op.sap.service.SapOrderService;
import com.op.sap.util.JCoUtils;
import com.op.sap.util.SAPConnUtils; import com.op.sap.util.SAPConnUtils;
import com.op.system.api.RemotePlanService; import com.op.system.api.domain.sap.SapCreateOrder;
import com.op.sap.domain.SapBom;
import com.op.system.api.model.SapProOrder; import com.op.system.api.model.SapProOrder;
import com.sap.conn.jco.*; import com.sap.conn.jco.*;
import org.jcp.xml.dsig.internal.dom.Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -100,6 +89,39 @@ public class SapOrderServiceImpl implements SapOrderService {
return null; return null;
} }
} }
@Override
public R SapCreateOrder(List<SapCreateOrder> sapCreateOrderList) {
try {
//获取连接
JCoDestination dest = SAPConnUtils.connect();
JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZPPR_MES_PRODORD_CREATE");
if (func == null) {
throw new RuntimeException("Function does not exist in SAP");
}
// 配置传入参数
JCoParameterList jCoParameterList = func.getImportParameterList();
if (sapCreateOrderList != null && sapCreateOrderList.size() > 0) {
for (SapCreateOrder sapCreateOrder : sapCreateOrderList) {
jCoParameterList.setValue("P_WERKS", sapCreateOrder.getWerks());
jCoParameterList.setValue("P_AUFPAR", sapCreateOrder.getAufpar());
jCoParameterList.setValue("P_MATNR", sapCreateOrder.getMatnr());
jCoParameterList.setValue("P_QUANTITY", sapCreateOrder.getQuantity());
jCoParameterList.setValue("P_DATES", sapCreateOrder.getDates());
jCoParameterList.setValue("P_DATEE", sapCreateOrder.getDatee());
func.execute(dest);//执行调用函数
JCoParameterList RES = func.getExportParameterList();
System.out.println(RES);
}
}
return R.ok();
} catch (Exception e) {
return R.fail();
}
}
} }

Loading…
Cancel
Save