sap接口调整

highway
zhaoxiaolin 12 months ago
parent e8f155136d
commit 1f31239adb

@ -40,7 +40,7 @@ public interface RemoteSapService {
/**关闭订单**/
@PostMapping("/sap/sapCloseOrder")
public R sapCloseOrder(@RequestParam("shopOrder") String shopOrder);
public R sapCloseOrder(@RequestBody SapCloseOrderQuery sapCloseOrderQuery);
/**报工**/
@PostMapping("/sap/sapRFWOrder")

@ -0,0 +1,197 @@
package com.op.system.api.domain.mes;
import com.op.common.core.annotation.Excel;
import com.op.common.core.web.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* mes_report_work_consume
*
* @author Open Platform
* @date 2023-08-24
*/
public class MesReportWorkConsumeDTO extends BaseEntity {
private static final long serialVersionUID = 1L;
/** id */
private String recordId;
/** 工单编码 */
@Excel(name = "工单编码")
private String workorderCode;
/** 物料编号 */
@Excel(name = "物料编号")
private String materialCode;
/** 物料名称 */
@Excel(name = "物料名称")
private String materialName;
/** 物料规格型号 */
@Excel(name = "物料规格型号")
private String materialSpc;
/** 数量 */
@Excel(name = "数量")
private Long quantity;
/** 单位 */
@Excel(name = "单位")
private String unit;
/** 预留字段1 */
@Excel(name = "预留字段1")
private String attr1;
/** 预留字段2 */
@Excel(name = "预留字段2")
private String attr2;
/** 预留字段3 */
@Excel(name = "预留字段3")
private String attr3;
/** 预留字段4 */
@Excel(name = "预留字段4")
private String attr4;
/** 工厂编码 */
@Excel(name = "工厂编码")
private String factoryCode;
/** 工厂编码 */
@Excel(name = "报工编码")
private String reportCode;
//虚拟字段
private String id;
public void setRecordId(String recordId) {
this.recordId = recordId;
}
public String getRecordId() {
return recordId;
}
public void setWorkorderCode(String workorderCode) {
this.workorderCode = workorderCode;
}
public String getWorkorderCode() {
return workorderCode;
}
public void setReportCode(String reportCode) {
this.reportCode = reportCode;
}
public String getReportCode() {
return reportCode;
}
public void setMaterialCode(String materialCode) {
this.materialCode = materialCode;
}
public String getMaterialCode() {
return materialCode;
}
public void setMaterialName(String materialName) {
this.materialName = materialName;
}
public String getMaterialName() {
return materialName;
}
public void setMaterialSpc(String materialSpc) {
this.materialSpc = materialSpc;
}
public String getMaterialSpc() {
return materialSpc;
}
public void setQuantity(Long quantity) {
this.quantity = quantity;
}
public Long getQuantity() {
return quantity;
}
public void setUnit(String unit) {
this.unit = unit;
}
public String getUnit() {
return unit;
}
public void setAttr1(String attr1) {
this.attr1 = attr1;
}
public String getAttr1() {
return attr1;
}
public void setAttr2(String attr2) {
this.attr2 = attr2;
}
public String getAttr2() {
return attr2;
}
public void setAttr3(String attr3) {
this.attr3 = attr3;
}
public String getAttr3() {
return attr3;
}
public void setAttr4(String attr4) {
this.attr4 = attr4;
}
public String getAttr4() {
return attr4;
}
public void setFactoryCode(String factoryCode) {
this.factoryCode = factoryCode;
}
public String getFactoryCode() {
return factoryCode;
}
//虚拟字段
public void setId(String factoryCode) {
this.id = id;
}
public String getId() {
return id;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("recordId", getRecordId())
.append("id", getId())
.append("reportCode", getReportCode())
.append("workorderCode", getWorkorderCode())
.append("materialCode", getMaterialCode())
.append("materialName", getMaterialName())
.append("materialSpc", getMaterialSpc())
.append("quantity", getQuantity())
.append("unit", getUnit())
.append("remark", getRemark())
.append("attr1", getAttr1())
.append("attr2", getAttr2())
.append("attr3", getAttr3())
.append("attr4", getAttr4())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("factoryCode", getFactoryCode())
.toString();
}
}

@ -40,7 +40,7 @@ public class RemoteSapFallbackFactory implements FallbackFactory<RemoteSapServic
}
@Override
public R sapCloseOrder(String shopOrder) {
public R sapCloseOrder(SapCloseOrderQuery sapCloseOrderQuery) {
return R.fail("关闭订单失败:" + throwable.getMessage());
}

@ -9,13 +9,11 @@ import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.bean.BeanUtils;
import com.op.common.core.utils.http.HttpUtils;
import com.op.common.core.utils.uuid.IdUtils;
import com.op.mes.domain.BufferInfoParam;
import com.op.mes.domain.MesReportWork;
import com.op.mes.domain.MesShift;
import com.op.mes.domain.ProOrderWorkorder;
import com.op.mes.domain.*;
import com.op.mes.domain.buffer.JsonRootBean;
import com.op.mes.domain.dto.LGInfoDto;
import com.op.mes.mapper.MesMapper;
import com.op.mes.mapper.MesReportWorkConsumeMapper;
import com.op.mes.mapper.MesReportWorkMapper;
import com.op.mes.mapper.ProRfidProcessDetailMapper;
import com.op.mes.service.IWCSInterfaceService;
@ -28,6 +26,7 @@ import com.op.system.api.domain.dto.BoardDTO;
import com.op.system.api.domain.dto.WCSDTO;
import com.op.system.api.domain.dto.WCSDataDTO;
import com.op.system.api.domain.mes.ProRfidProcessDetail;
import com.op.system.api.domain.sap.SapCloseOrderQuery;
import com.op.system.api.domain.sap.SapRFW;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
@ -69,6 +68,9 @@ public class IWCInterfaceServiceImpl implements IWCSInterfaceService {
@Autowired
private RemoteSapService remoteSapService;
@Autowired
private MesReportWorkConsumeMapper mesReportWorkConsumeMapper;
/**
* JSON
* {
@ -305,21 +307,27 @@ public class IWCInterfaceServiceImpl implements IWCSInterfaceService {
ltgs.setConf_activity6(work.getSac6());
sapRFW.setLt_gs(ltgs);
List<SapRFW.lt_hw> lt_hwList =new ArrayList<>();
SapRFW.lt_hw lthw = sapRFW.new lt_hw();//MES生产订单报工货物移动修改
lthw.setEntry_qnt(work.getQuantityFeedback().toString());//TODO;
lthw.setMaterial(work.getProcessCode());
lt_hwList.add(lthw);
logger.info(work.getWorkorderCodeSap()+"母sap工单报工报工数量"+sapRFW.getGamng());
MesReportWorkConsume consumeqo = new MesReportWorkConsume();
consumeqo.setWorkorderCode(work.getWorkorderCode());
List<MesReportWorkConsume> consumes = mesReportWorkConsumeMapper.selectMesReportWorkConsumeList(consumeqo);
if(!CollectionUtils.isEmpty(consumes)){
for(MesReportWorkConsume consume:consumes){
logger.info(work.getWorkorderCodeSap()+"母sap工单报工【原料损耗】"+
consume.getMaterialCode()+"|"+consume.getQuantity());
SapRFW.lt_hw lthw = sapRFW.new lt_hw();//MES生产订单报工货物移动修改
lthw.setEntry_qnt(consume.getQuantity()+"");//数量
lthw.setMaterial(consume.getMaterialCode());//物料编码
lt_hwList.add(lthw);
}
}else{
logger.info(work.getWorkorderCodeSap()+"母sap工单报工工单"+work.getWorkorderCode()+"mes_report_work_consume没有数据");
return R.fail("mes_report_work_consume没有数据");
}
sapRFW.setLt_hwList(lt_hwList);
//添加调用sap日志
SysSapLog sysSapLog = new SysSapLog();
sysSapLog.setId(IdUtils.fastSimpleUUID());
sysSapLog.setMesssge(sapRFW.toString());
sysSapLog.setMethod("reportWork");
sysSapLog.setReqcode("请求");
sysSapLog.setCreateTime(DateUtils.getNowDate());
mesMapper.addSapLog(sysSapLog);
R r = remoteSapService.sapRFWOrder(sapRFW);
logger.info(work.getWorkorderCodeSap()+"母sap工单报工结果"+r.getCode()+","+r.getData()+","+r.getMsg());
//上传成功更改mes_report_work状态
if (r.getCode() == 200) {
work.setUploadStatus("1");
@ -339,10 +347,16 @@ public class IWCInterfaceServiceImpl implements IWCSInterfaceService {
logger.info("工单请求关闭调用remoteSapService.sapCloseOrder,参数:"+work.getWorkorderCodeSap());
//工单完成,关闭工单
List<String> sapWorkOrders = mesReportWorkMapper.getSapWorkOrder(work.getWorkorderCode());//根据belong_work_order找到所有要关闭的虚拟工单
for(String sapWorkOrder:sapWorkOrders){
R r2= remoteSapService.sapCloseOrder(sapWorkOrder);
logger.info("工单"+work.getWorkorderCode()+",sapworkorder:"+sapWorkOrder+",sap关闭"+r2.getCode()+",返回信息:"+r2.getMsg());
}
//关闭母子订单//订单的订单编码
SapCloseOrderQuery sapCloseOrderQuery = new SapCloseOrderQuery();
sapCloseOrderQuery.setLeadOrder(sapWorkOrders.get(0));
sapCloseOrderQuery.setOrder(sapWorkOrders.get(1));
R closeR = remoteSapService.sapCloseOrder(sapCloseOrderQuery);
logger.info(work.getWorkorderCodeSap()+"报工后关闭母子工单"+sapCloseOrderQuery.getLeadOrder()+":"+
sapCloseOrderQuery.getOrder()+":"+
closeR.getCode()+","+
closeR.getMsg()+","+
closeR.getData());
work.setStatus("w3");
work.setUpdateTime(DateUtils.getNowDate());

@ -2,6 +2,7 @@ package com.op.open.mapper;
import com.op.system.api.domain.SysSapLog;
import com.op.system.api.domain.dto.WCSDTO;
import com.op.system.api.domain.mes.MesReportWorkConsumeDTO;
import com.op.system.api.domain.mes.MesReportWorkDTO;
import com.op.system.api.domain.mes.ProOrderWorkorderDTO;
import com.op.system.api.domain.mes.ProRfidProcessDetail;
@ -43,5 +44,7 @@ public interface OpenMapper {
List<WCSDTO> getLGInfo(WCSDTO wcsDTO);
List<String> getSapWorkOrder(String workorderCode);
List<MesReportWorkConsumeDTO> selectMesReportWorkConsumeList(MesReportWorkConsumeDTO consumeqo);
}

@ -12,9 +12,11 @@ import com.op.system.api.RemoteSapService;
import com.op.system.api.domain.SysSapLog;
import com.op.system.api.domain.dto.WCSDTO;
import com.op.system.api.domain.dto.WCSDataDTO;
import com.op.system.api.domain.mes.MesReportWorkConsumeDTO;
import com.op.system.api.domain.mes.MesReportWorkDTO;
import com.op.system.api.domain.mes.ProOrderWorkorderDTO;
import com.op.system.api.domain.mes.ProRfidProcessDetail;
import com.op.system.api.domain.sap.SapCloseOrderQuery;
import com.op.system.api.domain.sap.SapRFW;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
@ -173,20 +175,28 @@ public class OpenServiceImpl implements OpenService {
ltgs.setConf_activity5(work.getSac5());//折旧
ltgs.setConf_activity6(work.getSac6());
sapRFW.setLt_gs(ltgs);
SapRFW.lt_hw lthw = sapRFW.new lt_hw();//MES生产订单报工货物移动修改
lthw.setEntry_qnt(work.getQuantityFeedback().toString());//TODO;
lthw.setMaterial(work.getProcessCode());
sapRFW.setLt_hw(lthw);
//添加调用sap日志
SysSapLog sysSapLog = new SysSapLog();
sysSapLog.setId(IdUtils.fastSimpleUUID());
sysSapLog.setMesssge(sapRFW.toString());
sysSapLog.setMethod("reportWork");
sysSapLog.setReqcode("请求");
sysSapLog.setCreateTime(DateUtils.getNowDate());
openMapper.addSapLog(sysSapLog);
List<SapRFW.lt_hw> lt_hwList =new ArrayList<>();
logger.info(work.getWorkorderCodeSap()+"母sap工单报工报工数量"+sapRFW.getGamng());
MesReportWorkConsumeDTO consumeqo = new MesReportWorkConsumeDTO();
consumeqo.setWorkorderCode(work.getWorkorderCode());
List<MesReportWorkConsumeDTO> consumes = openMapper.selectMesReportWorkConsumeList(consumeqo);
if(!CollectionUtils.isEmpty(consumes)){
for(MesReportWorkConsumeDTO consume:consumes){
logger.info(work.getWorkorderCodeSap()+"母sap工单报工【原料损耗】"+
consume.getMaterialCode()+"|"+consume.getQuantity());
SapRFW.lt_hw lthw = sapRFW.new lt_hw();//MES生产订单报工货物移动修改
lthw.setEntry_qnt(consume.getQuantity()+"");//数量
lthw.setMaterial(consume.getMaterialCode());//物料编码
lt_hwList.add(lthw);
}
}else{
logger.info(work.getWorkorderCodeSap()+"母sap工单报工工单"+work.getWorkorderCode()+"mes_report_work_consume没有数据");
return R.fail("mes_report_work_consume没有数据");
}
sapRFW.setLt_hwList(lt_hwList);
R r = remoteSapService.sapRFWOrder(sapRFW);
logger.info(work.getWorkorderCodeSap()+"母sap工单报工结果"+r.getCode()+","+r.getData()+","+r.getMsg());
//上传成功更改mes_report_work状态
if (r.getCode() == 200) {
work.setUploadStatus("1");
@ -207,10 +217,16 @@ public class OpenServiceImpl implements OpenService {
//工单完成,关闭母工单
List<String> sapWorkOrders = openMapper.getSapWorkOrder(work.getWorkorderCode());//根据belong_work_order找到所有要关闭的虚拟工单
for(String sapWorkOrder:sapWorkOrders){
R rclose = remoteSapService.sapCloseOrder(sapWorkOrder);
logger.info("工单"+work.getWorkorderCode()+",sapworkorder:"+sapWorkOrder+",sap关闭"+rclose.getCode()+",返回信息:"+rclose.getMsg());
}
//关闭母子订单//订单的订单编码
SapCloseOrderQuery sapCloseOrderQuery = new SapCloseOrderQuery();
sapCloseOrderQuery.setLeadOrder(sapWorkOrders.get(0));
sapCloseOrderQuery.setOrder(sapWorkOrders.get(1));
R closeR = remoteSapService.sapCloseOrder(sapCloseOrderQuery);
logger.info(work.getWorkorderCodeSap()+"下发工单后关闭母子工单"+sapCloseOrderQuery.getLeadOrder()+":"+
sapCloseOrderQuery.getOrder()+":"+
closeR.getCode()+","+
closeR.getMsg()+","+
closeR.getData());
work.setStatus("w3");
work.setUpdateTime(DateUtils.getNowDate());
//pro_work_order status->w3报工--belong_work_order

@ -126,5 +126,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select workorder_code_sap from pro_order_workorder
where belong_work_order = #{workorderCode} and del_flag = '0'
</select>
<select id="selectMesReportWorkConsumeList"
resultType="com.op.system.api.domain.mes.MesReportWorkConsumeDTO">
select
material_code materialCode,
quantity
from mes_report_work_consume
where
workorder_code = #{workorderCode} and del_flag = '0'
</select>
</mapper>

@ -21,6 +21,7 @@ import com.op.system.api.RemoteSapService;
import com.op.system.api.domain.SysSapLog;
import com.op.system.api.domain.dto.MesPrepareDTO;
import com.op.system.api.domain.dto.MesPrepareDetailDTO;
import com.op.system.api.domain.sap.SapCloseOrderQuery;
import com.op.system.api.domain.sap.SapCreateOrder;
import com.op.system.api.domain.sap.SapMaterialPreparation;
import com.op.system.api.domain.sap.SapShopOrderQuery;
@ -306,14 +307,14 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
sapList.add(sap);
//添加调用sap日志
SysSapLog sysSapLog = new SysSapLog();
sysSapLog.setId(IdUtils.fastSimpleUUID());
sysSapLog.setMesssge(Arrays.asList(sapList).toString());
sysSapLog.setMethod("downProOrderWorkorderByWorkorderIds");
sysSapLog.setReqcode("请求");
sysSapLog.setCreateTime(DateUtils.getNowDate());
proOrderMapper.addSapLog(sysSapLog);
// SysSapLog sysSapLog = new SysSapLog();
// sysSapLog.setId(IdUtils.fastSimpleUUID());
// sysSapLog.setMesssge(Arrays.asList(sapList).toString());
// sysSapLog.setMethod("downProOrderWorkorderByWorkorderIds");
// sysSapLog.setReqcode("请求");
// sysSapLog.setCreateTime(DateUtils.getNowDate());
// proOrderMapper.addSapLog(sysSapLog);
logger.info(whiteOrder.getWorkorderCode()+"sap工单回传sap虚拟工单号开始"+Arrays.asList(sapList).toString());
R<List<Map<String, String>>> r = remoteSapService.SapCreateOrder(sapList);
logger.info("sap工单回传" + r.getMsg());
if (500 == r.getCode()) {
@ -328,7 +329,7 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
}
Date updateTime = DateUtils.getNowDate();
if (!CollectionUtils.isEmpty(returnCodes)) {
logger.info("sap工单回传sap虚拟工单号" + StringUtils.join(returnCodes, ","));
logger.info("sap工单回传sap虚拟工单号结束" + StringUtils.join(returnCodes, ","));
//按照母子顺序进行更新
for (int m=0;m<returnCodes.size();m++) {
ProOrderWorkorder oworkSap = new ProOrderWorkorder();
@ -348,16 +349,18 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
this.getMesPrepare(returnCodes,wcodes);
//关闭母子订单//订单的订单编码
R closeR = null;
for(String orderCode:ordercodes){
closeR= remoteSapService.sapCloseOrder(orderCode);
logger.info(workorderId+"下发工单后关闭母订单"+orderCode+":"+closeR.getCode()+","+closeR.getMsg());
}
if(closeR.getCode()==200){
//下达工单
String[] idsArrayAll = (String[])wids.toArray(new String[wids.size()]);
proOrderWorkorderMapper.downWorkorders(idsArrayAll);
}
SapCloseOrderQuery sapCloseOrderQuery = new SapCloseOrderQuery();
sapCloseOrderQuery.setLeadOrder(ordercodes.get(0));
sapCloseOrderQuery.setOrder(ordercodes.get(1));
R closeR= remoteSapService.sapCloseOrder(sapCloseOrderQuery);
logger.info(whiteOrder.getWorkorderCode()+"下发工单后关闭母订单"+sapCloseOrderQuery.getLeadOrder()+":"+
sapCloseOrderQuery.getOrder()+":"+
closeR.getCode()+","+
closeR.getMsg()+","+
closeR.getData());
//下达工单
String[] idsArrayAll = (String[])wids.toArray(new String[wids.size()]);
proOrderWorkorderMapper.downWorkorders(idsArrayAll);
}
}
return 1;

@ -2,8 +2,8 @@ package com.op.sap.service;
import com.op.common.core.domain.R;
import com.op.sap.domain.vo.SapCloseOrderQuery;
import com.op.sap.domain.vo.SapPurchaseOrderQuery;
import com.op.system.api.domain.sap.SapCloseOrderQuery;
import com.op.system.api.domain.sap.SapCreateOrder;
import com.op.system.api.domain.sap.SapRFW;
import com.op.system.api.domain.sap.SapShopOrderQuery;

@ -6,11 +6,11 @@ import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.StringUtils;
import com.op.common.core.utils.uuid.IdUtils;
import com.op.sap.domain.vo.SapCloseOrderQuery;
import com.op.sap.domain.vo.SapPurchaseOrderQuery;
import com.op.sap.service.SapOrderService;
import com.op.sap.util.SAPConnUtils;
import com.op.system.api.domain.sap.SapCloseOrderQuery;
import com.op.system.api.domain.sap.SapCreateOrder;
import com.op.system.api.domain.sap.SapRFW;
import com.op.system.api.domain.sap.SapShopOrderQuery;

Loading…
Cancel
Save