工艺路线同步接口优化

master
Yangwl 9 months ago
parent 783dc284f9
commit 78229d7662

@ -30,6 +30,10 @@ public class SapProRoute extends BaseEntity
@Excel(name = "工艺路线名称")
private String routeName;
/**产品编号*/
@Excel(name = "产品编号")
private String productCode;
/** 工艺路线说明 */
@Excel(name = "工艺路线说明")
private String routeDesc;
@ -42,6 +46,7 @@ public class SapProRoute extends BaseEntity
@Excel(name = "是否需要首检")
private String needCheck;
/** 预留字段1 */
private String attr1;
@ -71,6 +76,14 @@ public class SapProRoute extends BaseEntity
private String routeVersion;
public String getProductCode() {
return productCode;
}
public void setProductCode(String productCode) {
this.productCode = productCode;
}
public String getRouteId() {
return routeId;
}

@ -1,5 +1,7 @@
package com.op.system.api.domain.sap;
import java.util.List;
public class SapRouterQuery {
/* MATNR
WERKS
@ -7,17 +9,17 @@ public class SapRouterQuery {
ANDAT
AEDAT */
private String matnr;
private List<String> matnr;
private String werks;
private String arbpl;
private String andat;
private String aedat;
public String getMatnr() {
public List<String> getMatnr() {
return matnr;
}
public void setMatnr(String matnr) {
public void setMatnr(List<String> matnr) {
this.matnr = matnr;
}

@ -119,7 +119,7 @@ public class OpenController extends BaseController {
* ===============ZL0010- :"workflowId": 26235=============
* <p>
* <p>
* CQ OEMCM LLLB 01MATNR MAKTX suppliernum
* SQR CQ OEMCM LLLB 01MATNR MAKTX suppliernum
* supplier CHARG comeQty testDate JYBH
* BJY OEMWLLY ZCF ZCOEMCM OEM
* memo PZGLBZG QC
@ -205,4 +205,5 @@ public class OpenController extends BaseController {
dynamicRoutingDataSource.removeDataSource(dataSourceProperty.getPoolName());
return R.ok();
}
}

@ -19,6 +19,12 @@ import com.op.system.api.domain.dto.WCSDataDTO;
import com.op.system.api.domain.mes.ProRfidProcessDetail;
import com.op.system.api.domain.quality.*;
import org.apache.commons.lang.StringUtils;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.time.LocalDateTime;
import java.time.Duration;
import org.slf4j.Logger;
@ -422,7 +428,11 @@ public class OpenServiceImpl implements OpenService {
String requestName = paramMap.get("requestName").toString();
String workflowId = paramMap.get("workflowId").toString();
String mainObject = paramMap.get("mainObject").toString();
// String postData = "user=" + user +
// "&requestLevel=" + requestLevel +
// "&requestName=" + requestName +
// "&workflowId=" + workflowId +
// "&mainObject=" + mainObject;
// Building the postData string using StringBuilder
StringBuilder postDataBuilder = new StringBuilder();
@ -433,10 +443,11 @@ public class OpenServiceImpl implements OpenService {
.append("&mainObject=").append(URLEncoder.encode(mainObject, StandardCharsets.UTF_8.toString()));
if (Constants.WORKFLOWID_ZL0020.equals(workflowId)) {
String details = paramMap.get("details").toString();
// postData += "&details=" + details;
postDataBuilder.append("&details=").append(URLEncoder.encode(details, StandardCharsets.UTF_8.toString()));
}
String postData = postDataBuilder.toString();
String result = HttpUtils.sendPostOA(oa_url, postData);
String result=HttpUtils.sendPostOA(oa_url,postData);
logger.info(result);
//返回示例{"result":"0","info":"成功","requestid":"2193799"}
Map resultMap=JSONObject.parseObject(result);
@ -504,4 +515,5 @@ public class OpenServiceImpl implements OpenService {
return error(e.getMessage());
}
}
}

@ -159,35 +159,7 @@ public class SapController extends BaseController {
@PostMapping("/sapRouterSync")
@Log(title = "工艺路线同步接口", businessType = BusinessType.SAP)
public R sapRouerSync(@RequestBody SapRouterQuery qo) {
// 加载sf-cloud库的sys_datasource
SysUser sysUser = new SysUser();
sysUser.setUserId(1L);
R<List<Map<String, String>>> dateSources0 = remoteUserService.getPoolNameList(sysUser);
List<Map<String, String>> dateSources = dateSources0.getData();
dateSources.forEach(dateSource -> {
if (!"ds_999".equals(dateSource.get("poolName"))) {
logger.info("++++++++++++" + dateSource.get("poolName") + "++++工艺同步开始++++++++++");
DynamicDataSourceContextHolder.push(dateSource.get("poolName"));// 这是数据源的key
Date maxTime0 = sapBomMapper.getRouteMaxTime();
if (maxTime0 != null) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(maxTime0);
calendar.add(Calendar.DAY_OF_YEAR, 1);
Date maxTime = calendar.getTime();
// qo.setAedat(DateFormatUtils.format(maxTime, "yyyyMMdd"));//修改日期20230923
}
qo.setWerks(dateSource.get("poolName").replace("ds_", ""));//工厂
R r = sapRouterService.sapRouterSync(qo);
if (r.getCode() != 200) {
logger.error("++++++++++++" + dateSource.get("poolName") + "同步工艺失败,错误信息:" + r.getMsg());
}
logger.error("++++++++++++" + dateSource.get("poolName") + "++++工艺同步结束++++++++++");
}
});
return R.ok();
return sapRouterService.sapRouterSync(qo);
}
/**

@ -85,12 +85,12 @@ public class SapItemSyncImpl implements SapItemSyncService {
S_MATNR.setValue(Constants.LOW, sapItemQuery.getMatnr());
}
if (!StringUtils.isNull(sapItemQuery.getMatnr())) {
JCoTable S_MATNR = func.getTableParameterList().getTable("S_MATNR");
S_MATNR.appendRow();
S_MATNR.setValue(Constants.SIGN, "I");
S_MATNR.setValue(Constants.OPTION, "EQ");
S_MATNR.setValue(Constants.LOW, sapItemQuery.getMatnr());
if (!StringUtils.isNull(sapItemQuery.getMatkl())) {
JCoTable S_MATKL = func.getTableParameterList().getTable("S_MATKL");
S_MATKL.appendRow();
S_MATKL.setValue(Constants.SIGN, "I");
S_MATKL.setValue(Constants.OPTION, "EQ");
S_MATKL.setValue(Constants.LOW, sapItemQuery.getMatkl());
}
if (!StringUtils.isNull(sapItemQuery.getMatkl())) {
@ -463,12 +463,17 @@ public class SapItemSyncImpl implements SapItemSyncService {
log.info("成品备货单参数-------" + mapList.toString());
JCoTable S_TDDAT = func.getTableParameterList().getTable("S_TDDAT");
JCoTable S_MATNR = func.getTableParameterList().getTable("S_MATNR");
System.out.println(S_TDDAT);
System.out.println(S_MATNR);
JCoTable S_VBELN = func.getTableParameterList().getTable("S_VBELN");
if (mapList==null || mapList.size()==0)
{
return R.fail("参数不能为空");
}
if (StringUtils.isNotEmpty(mapList.get("S_VBELN").toString())){
S_TDDAT.appendRow();
S_TDDAT.setValue(Constants.SIGN, "I");
S_TDDAT.setValue(Constants.OPTION, "BT");
S_TDDAT.setValue(Constants.LOW, mapList.get("S_VBELN").toString());
}
if (StringUtils.isNotEmpty(mapList.get("S_MATNR").toString())){
S_TDDAT.appendRow();
S_TDDAT.setValue(Constants.SIGN, "I");
@ -480,7 +485,7 @@ public class SapItemSyncImpl implements SapItemSyncService {
S_TDDAT.setValue(Constants.SIGN, "I");
S_TDDAT.setValue(Constants.OPTION, "BT");
S_TDDAT.setValue(Constants.LOW, mapList.get("S_TDDAT").toString());
S_TDDAT.setValue(Constants.HIGH, END_DATE);
S_TDDAT.setValue(Constants.HIGH, mapList.get("S_TDDAT").toString());
}
func.execute(dest);//执行调用函数
String RETCODE=func.getExportParameterList().getString("RETCODE");
@ -494,8 +499,8 @@ public class SapItemSyncImpl implements SapItemSyncService {
String MAKTX=maraTable.getString("MAKTX");//物料描述
String VBELN=maraTable.getString("VBELN");//交货单
String VBELN_VA=maraTable.getString("VBELN_VA");//销售单
String AUART=maraTable.getString("AUART");//销售凭证类型
String BEZEI=maraTable.getString("BEZEI");//销售凭证类型描述
// String AUART=maraTable.getString("AUART");//销售凭证类型
// String BEZEI=maraTable.getString("BEZEI");//销售凭证类型描述
String MENGE=maraTable.getString("MENGE");//数量
String MEINS=maraTable.getString("MEINS");//单位
String TDDAT=maraTable.getString("TDDAT");//计划日期
@ -505,15 +510,15 @@ public class SapItemSyncImpl implements SapItemSyncService {
String LIFNR_NM=maraTable.getString("LIFNR_NM");//货运代理描述
String ZSAREA=maraTable.getString("ZSAREA");//销售大区
String BZTXT1=maraTable.getString("BZTXT1");//销售大区描述
log.info("物料号"+MATNR+"物料描述"+MAKTX+"交货单"+VBELN+"销售单"+VBELN_VA+"销售凭证类型"+AUART+"销售凭证类型描述"+BEZEI+
"数量"+MENGE+"单位"+MEINS+"计划日期"+TDDAT+"送达方"+KUNNR+"送达方描述"+KUNNR_NM+"货运代理"+LIFNR+
"货运代理描述"+LIFNR_NM+"销售大区"+ZSAREA+"销售大区描述"+BZTXT1);
log.info("物料号:"+MATNR+"物料描述:"+MAKTX+"交货单:"+VBELN+"销售单:"+VBELN_VA+
"数量:"+MENGE+"单位:"+MEINS+"计划日期:"+TDDAT+"送达方:"+KUNNR+"送达方描述:"+KUNNR_NM+"货运代理:"+LIFNR+
"货运代理描述:"+LIFNR_NM+"销售大区:"+ZSAREA+"销售大区描述:"+BZTXT1);
map.put("MATNR",MATNR);
map.put("MAKTX",MAKTX);
map.put("VBELN",VBELN);
map.put("VBELN_VA",VBELN_VA);
map.put("AUART",AUART);
map.put("BEZEI",BEZEI);
// map.put("AUART",AUART);
// map.put("BEZEI",BEZEI);
map.put("MENGE",MENGE);
map.put("MEINS",MEINS);
map.put("TDDAT",TDDAT);

@ -75,12 +75,14 @@ public class SapRouterServiceImpl implements SapRouterService {
*/
log.info("工艺路线同步入参-------" + sapRouterQuery.toString());
if (!StringUtils.isNull(sapRouterQuery.getMatnr())) {
if (sapRouterQuery.getMatnr()!=null&&sapRouterQuery.getMatnr().size()>0) {
JCoTable S_MATNR = func.getTableParameterList().getTable("S_MATNR");
S_MATNR.appendRow();
S_MATNR.setValue("SIGN", "I");
S_MATNR.setValue("OPTION", "EQ");
S_MATNR.setValue("LOW", sapRouterQuery.getMatnr());
for (String matnr:sapRouterQuery.getMatnr()){
S_MATNR.appendRow();
S_MATNR.setValue("SIGN", "I");
S_MATNR.setValue("OPTION", "EQ");
S_MATNR.setValue("LOW", matnr);
}
}
if (!StringUtils.isNull(sapRouterQuery.getWerks())) {
JCoTable S_WERKS = func.getTableParameterList().getTable("S_WERKS");
@ -114,15 +116,14 @@ public class SapRouterServiceImpl implements SapRouterService {
S_AEDAT.setValue("LOW", sapRouterQuery.getAedat());
S_AEDAT.setValue("HIGH", END_DATE);
}
System.out.println(func.getTableParameterList().getTable("S_MATNR"));
func.execute(dest);//执行调用函数
// 获取 内表 - ZMES_PRO
JCoTable maraTable = func.getTableParameterList().getTable("LT_ROUTING");
JCoRecordMetaData metaData = maraTable.getRecordMetaData();
// System.out.println("###" + metaData.toString());
List<SapProRoute> sapProRouteList = new ArrayList<>();
//DynamicDataSourceContextHolder.push("ds_1000");//controller已经完成切换
DynamicDataSourceContextHolder.push("ds_"+sapRouterQuery.getWerks());
for (int i = 0; i < maraTable.getNumRows(); i++) {
SapProProcess sapProProcess = new SapProProcess();
maraTable.setRow(i);
@ -200,7 +201,7 @@ public class SapRouterServiceImpl implements SapRouterService {
"计量单位03" + VGE03 +
"标准值04其它" + VGW04 +
" 计量单位04" + VGE04);
//工艺路线下的工序
// 工艺路线下的工序
if (StringUtil.isBlank(PLNNR)) {
throw new ServiceException("任务清单组码不能为空");
}
@ -229,6 +230,7 @@ public class SapRouterServiceImpl implements SapRouterService {
String routerid = IdUtils.fastSimpleUUID();
sapProRoute.setRouteId(routerid);
sapProRoute.setRouteCode(PLNNR);
sapProRoute.setProductCode(MATNR);
sapProRoute.setRouteName(KTEXT);
sapProRoute.setRouteDesc(KTEXT);
sapProRoute.setEnableFlag("Y");
@ -277,9 +279,9 @@ public class SapRouterServiceImpl implements SapRouterService {
//更新工艺路线
else {
sapProRoute.setRouteName(KTEXT);
sapProRoute.setProductCode(MATNR);
sapProRoute.setRouteDesc(KTEXT);
sapProRoute.setEnableFlag("Y");
//机器
sapProRoute.setTecMachine(VGW01);
sapProRoute.setTecMachineUnit(VGE01);
@ -296,59 +298,6 @@ public class SapRouterServiceImpl implements SapRouterService {
sapProRoute.setUpdateTime(DateUtils.getNowDate());
sapProRouteMapper.updateProRoute(sapProRoute);
}
// else{
// //验证是否存在工序
// sapProProcess.setProcessName(LTXA1);
// SapProProcess operation = sapProProcessMapper.selectProProcessByProcessName(sapProProcess);
// //验证产品是否存在
// SapBaseProduct sapBaseProduct=new SapBaseProduct();
// sapBaseProduct.setProductCode(MATNR);
// sapBaseProduct = sapBaseProductMapper.selectBaseProductByProductCode(sapBaseProduct);
// if (StringUtils.isNull(operation)){
// failureNum++;
// failureMsg.append(failureNum+"、工艺路线【" + PLNNR + "】下的工序【" + LTXA1 + "】不存在!");
// }
// else if (StringUtils.isNull(sapBaseProduct)){
// failureNum++;
// failureMsg.append(failureNum+"、工艺路线【" + PLNNR + "】下的物料【" + MATNR + "】不存在!");
// }
// else if(!StringUtils.isNull(operation) && !StringUtils.isNull(sapBaseProduct)) {
// //验证是否存在工艺路线和工序的关系
// SapProRouteProcess sapProRouteProcess = new SapProRouteProcess();
// sapProRouteProcess.setRouteId(sapProRoute.getRouteId());
// sapProRouteProcess.setProcessId(operation.getProcessId());
// List<SapProRouteProcess> sapProRouteProcessList = sapProRouteProcessMapper.selectProRouteProcessList(sapProRouteProcess);
// if (sapProRouteProcessList .size()==0) {
// //增加工艺路线和工序的关系
// sapProRouteProcess.setRecordId(IdUtils.fastSimpleUUID());
// sapProRouteProcess.setRouteId(sapProRoute.getRouteId());
// sapProRouteProcess.setProcessId(operation.getProcessId());
// sapProRouteProcess.setProcessCode(operation.getProcessCode());
// sapProRouteProcess.setProcessName(operation.getProcessName());
// sapProRouteProcess.setOrderNum(1);
// sapProRouteProcess.setCreateTime(DateUtils.dateTime("yyyy-MM-dd", ANDAT));
// sapProRouteProcess.setCreateBy(ANNAM);
// sapProRouteProcessMapper.insertProRouteProcess(sapProRouteProcess);
// }
// //验证是否存在工艺路线和物料的关系
// SapProRouteProduct sapProRouteProduct = new SapProRouteProduct();
// sapProRouteProduct.setRouteId(sapProRoute.getRouteId());
// sapProRouteProduct.setItemCode(MATNR);
// List<SapProRouteProduct> sapProRouteProductList = sapProRouteProductMapper.selectProRouteProductList(sapProRouteProduct);
// if (sapProRouteProductList .size()==0) {
// sapProRouteProduct.setRecordId(IdUtils.fastSimpleUUID());
// sapProRouteProduct.setRouteId(sapProRoute.getRouteId());
// sapProRouteProduct.setItemId(sapBaseProduct.getProductId());
// sapProRouteProduct.setItemCode(MATNR);
// sapProRouteProduct.setItemName(sapBaseProduct.getProductDescZh());
// sapProRouteProduct.setCreateBy(ANNAM);
// sapProRouteProduct.setCreateTime(DateUtils.dateTime("yyyy-MM-dd", ANDAT));
// sapProRouteProductMapper.insertProRouteProduct(sapProRouteProduct);
// }
// }
// }
}
if (failureNum > 0) {

Loading…
Cancel
Save