sap 定时任务

highway
zhaoxiaolin 1 year ago
parent f329c7c39b
commit 852bff3af6

@ -23,7 +23,7 @@ public interface RemoteSapService {
public R<List<SapProOrder>> shopOrderSync(@RequestBody SapShopOrderQuery sapProOrder);
@PostMapping("/sap/sapRouterSync")
public R<Boolean> sapRouterSync();
public R<Boolean> sapRouterSync(@RequestBody SapRouterQuery sapRouterQuery);
@PostMapping("/sap/materialPreparation")
public R<List<SapMaterialPreparation>>materialPreparation(@RequestParam("shopOrder") String shopOrder);

@ -1,4 +1,4 @@
package com.op.sap.domain.vo;
package com.op.system.api.domain.sap;
public class SapRouterQuery {
/* MATNR

@ -23,7 +23,7 @@ public class RemoteSapFallbackFactory implements FallbackFactory<RemoteSapServic
}
@Override
public R<Boolean> sapRouterSync() {
public R<Boolean> sapRouterSync(SapRouterQuery sapRouterQuery) {
return R.fail("SAP服务同步工艺失败:" + throwable.getMessage());
}

@ -3,6 +3,7 @@ package com.op.job.task;
import com.op.system.api.RemoteMesService;
import com.op.system.api.RemotePlanService;
import com.op.system.api.RemoteSapService;
import com.op.system.api.domain.sap.SapRouterQuery;
import com.op.system.api.domain.sap.SapShopOrderQuery;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -58,7 +59,8 @@ public class RyTask {
*/
public void getRouteTask(){
logger.info("++同步工艺+开始++getRouteTask+++++");
remoteSapService.sapRouterSync();
SapRouterQuery qo = new SapRouterQuery();
remoteSapService.sapRouterSync(qo);
}
/**2

@ -130,13 +130,36 @@ public class SapController extends BaseController {
/**
* 线
* @param sapRouterQuery
* @param SapRouterQuery qo
* @return
*/
@PostMapping("/sapRouterSync")
@Log(title = "工艺路线同步接口", businessType = BusinessType.SAP)
public R sapRouerSync(@RequestBody SapRouterQuery sapRouterQuery) {
return sapRouterService.sapRouterSync(sapRouterQuery);
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 -> {
logger.info("++++++++++++" + dateSource.get("poolName") + "++++工艺同步开始++++++++++");
DynamicDataSourceContextHolder.push(dateSource.get("poolName"));// 这是数据源的key
Date maxTime = sapBomMapper.getRouteMaxTime();
if(maxTime != null){
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();
}
/**

@ -45,4 +45,6 @@ public interface SapBomMapper {
String getParentId(String factoryCode);
Date getProductMaxTime();
Date getRouteMaxTime();
}

@ -2,7 +2,8 @@ package com.op.sap.service;
import com.op.common.core.domain.R;
import com.op.common.core.web.domain.AjaxResult;
import com.op.sap.domain.vo.SapRouterQuery;
import com.op.system.api.domain.sap.SapRouterQuery;
public interface SapRouterService {

@ -8,9 +8,6 @@ import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.StringUtils;
import com.op.common.core.utils.bean.BeanValidators;
import com.op.common.core.utils.uuid.IdUtils;
import com.op.common.core.utils.uuid.UUID;
import com.op.common.core.web.domain.AjaxResult;
import com.op.sap.domain.vo.SapRouterQuery;
import com.op.sap.mapper.*;
import com.op.sap.service.SapRouterService;
import com.op.sap.util.SAPConnUtils;
@ -18,8 +15,6 @@ import com.op.system.api.domain.sap.*;
import com.sap.conn.jco.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.server.ServerErrorException;
import javax.validation.Validator;
import java.rmi.ServerException;
import java.util.ArrayList;
@ -77,7 +72,7 @@ public class SapRouterServiceImpl implements SapRouterService {
S_MATNR.setValue("OPTION", "EQ");
S_MATNR.setValue("LOW", sapRouterQuery.getMatnr());
}
if (!StringUtils.isNull(sapRouterQuery.getMatnr())){
if (!StringUtils.isNull(sapRouterQuery.getWerks())){
JCoTable S_WERKS = func.getTableParameterList().getTable("S_WERKS");
S_WERKS.appendRow();
S_WERKS.setValue("SIGN", "I");
@ -85,14 +80,14 @@ public class SapRouterServiceImpl implements SapRouterService {
S_WERKS.setValue("LOW", sapRouterQuery.getWerks());
}
if (!StringUtils.isNull(sapRouterQuery.getMatnr())){
if (!StringUtils.isNull(sapRouterQuery.getArbpl())){
JCoTable S_ARBPL = func.getTableParameterList().getTable("S_ARBPL");
S_ARBPL.appendRow();
S_ARBPL.setValue("SIGN", "I");
S_ARBPL.setValue("OPTION", "EQ");
S_ARBPL.setValue("LOW", sapRouterQuery.getArbpl());
}
if (!StringUtils.isNull(sapRouterQuery.getMatnr())){
if (!StringUtils.isNull(sapRouterQuery.getAndat())){
JCoTable S_ANDAT = func.getTableParameterList().getTable("S_ANDAT");
S_ANDAT.appendRow();
S_ANDAT.setValue("SIGN", "I");
@ -101,7 +96,7 @@ public class SapRouterServiceImpl implements SapRouterService {
S_ANDAT.setValue("HIGH", END_DATE);
}
if (!StringUtils.isNull(sapRouterQuery.getMatnr())){
if (!StringUtils.isNull(sapRouterQuery.getAedat())){
JCoTable S_AEDAT = func.getTableParameterList().getTable("S_AEDAT");
S_AEDAT.appendRow();
S_AEDAT.setValue("SIGN", "I");
@ -120,7 +115,7 @@ public class SapRouterServiceImpl implements SapRouterService {
JCoRecordMetaData metaData = maraTable.getRecordMetaData();
System.out.println("###" + metaData.toString());
List<SapProRoute> sapProRouteList=new ArrayList<>();
DynamicDataSourceContextHolder.push("ds_1000");
//DynamicDataSourceContextHolder.push("ds_1000");//controller已经完成切换
for (int i = 0; i <maraTable.getNumRows(); i++) {
SapProProcess sapProProcess=new SapProProcess();
maraTable.setRow(i);
@ -236,6 +231,7 @@ public class SapRouterServiceImpl implements SapRouterService {
sapProRoute.setRouteDesc(KTEXT);
sapProRoute.setEnableFlag("Y");
sapProRoute.setCreateBy(ANNAM);
sapProRoute.setAttr1("job");//说明是来自定时任务
sapProRoute.setCreateTime(DateUtils.dateTime("yyyy-MM-dd", ANDAT));
sapProRoute.setRouteVersion("1.0");
sapProRouteMapper.insertProRoute(sapProRoute);

@ -230,7 +230,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateFactoryBatchs">
<foreach collection="list" item="item" separator=";">
update sys_factory
set factory_name = #{item.ktext}
set factory_name = #{item.ktext},
create_time = #{item.aedat_grnd},
update_time = #{item.aedat_grnd}
where
factory_code = #{item.arbpl}
</foreach>
@ -279,6 +281,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{code}
</foreach>
</select>
<select id="getRouteMaxTime" resultType="java.util.Date">
select max(create_time) from pro_route where attr1 = 'job'
</select>
<!--批量更新供应商建模表-->
<update id="updateSupplierBatchs">
@ -288,7 +293,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
zh_desc = #{item.name1},
contact_phone = #{item.telf1},
address = #{item.stras},
factory_code = #{item.bukrs}
factory_code = #{item.bukrs},
create_time= #{item.erdat},
update_time = #{item.erdat}
where
supplier_code = #{item.lifnr}
</foreach>
@ -316,7 +323,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
client_name = #{item.name1},
contact1_tel = #{item.telf1},
address = #{item.stras},
factory_code = #{item.bukrs}
factory_code = #{item.bukrs},
create_time = #{item.erdat},
update_time = #{item.erdat}
where
client_code = #{item.kunnr}
</foreach>

@ -13,6 +13,7 @@ import com.op.common.log.annotation.Log;
import com.op.common.log.enums.BusinessType;
import com.op.common.security.annotation.RequiresPermissions;
import com.op.system.api.RemoteSapService;
import com.op.system.api.domain.sap.SapRouterQuery;
import com.op.technology.domain.ProRoute;
import com.op.technology.service.IProRouteProcessService;
import com.op.technology.service.IProRouteService;
@ -139,8 +140,9 @@ public class ProRouteController extends BaseController {
@RequiresPermissions("mes:pro:proroute:add")
@PostMapping("/sapProRouteProcess")
public AjaxResult sapProRouteProcess() {
R r = remoteSapService.sapRouterSync();
if((Boolean) r.getData()){
SapRouterQuery qo = new SapRouterQuery();
R r = remoteSapService.sapRouterSync(qo);
if(r.getCode() == 200){
return AjaxResult.success();
}
return AjaxResult.error("手动同步失败");

Loading…
Cancel
Save