Merge remote-tracking branch 'origin/master'

highway
chj 1 year ago
commit 828462b93d

@ -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

@ -219,7 +219,7 @@ public class ProOrderServiceImpl implements IProOrderService {
wetDetail.setPlanTime(splitOrderDTO.getProductDate());
wetDetail.setCreateBy(SecurityUtils.getUsername());
wetDetail.setCreateTime(DateUtils.getNowDate());
wetDetail.setStatus("N");
wetDetail.setStatus("N");//Y接料完成N未接料O送料完成
//获取当前所选工厂
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String key = "#header.poolName";

@ -196,14 +196,14 @@
id, factory_code, workorder_id,
create_by, create_time, bucket_code,
material_code,material_name, shift_id,
plan_time,sync_flag
plan_time,sync_flag,status
)values
<foreach collection="list" item="item" index="index" separator=",">
(
#{item.id},#{item.factoryCode},#{item.workorderId},
#{item.createBy},#{item.createTime},#{item.bucketCode},
#{item.materialCode},#{item.materialName},#{item.shiftId},
#{item.planTime}, 'N'
#{item.planTime}, 'N',#{item.status}
)
</foreach>
</insert>

@ -94,7 +94,7 @@ public class QcProCheckServiceImpl implements QcProCheckService {
@Override
public List<QcProCheck> getDictList(QcProCheck qcProCheck) {
DynamicDataSourceContextHolder.push("master");
qcProCheck.setEquipmentTypeCode("equ_type");
//qcProCheck.setEquipmentTypeCode("equ_type");
return qcProCheckMapper.getDictList(qcProCheck);
}
}

@ -91,11 +91,10 @@
<!-- SAP JOC 3 -->
<dependency>
<groupId>com.sap</groupId>
<artifactId>sapjco3</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/lib/sapjco3.jar</systemPath>
<artifactId>sapjco</artifactId>
<version>3.0.8</version>
<!-- <scope>system</scope>-->
<!-- <systemPath>${project.basedir}/src/main/lib/sapjco3.jar</systemPath>-->
</dependency>
<dependency>
<groupId>junit</groupId>
@ -118,35 +117,35 @@
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<compilerArguments>
<extdirs>${project.basedir}/lib</extdirs>
</compilerArguments>
</configuration>
</plugin>
<!-- <plugin>-->
<!-- <artifactId>maven-compiler-plugin</artifactId>-->
<!-- <configuration>-->
<!-- <source>1.8</source>-->
<!-- <target>1.8</target>-->
<!-- <encoding>UTF-8</encoding>-->
<!-- <compilerArguments>-->
<!-- <extdirs>${project.basedir}/lib</extdirs>-->
<!-- </compilerArguments>-->
<!-- </configuration>-->
<!-- </plugin>-->
</plugins>
<resources>
<resource>
<directory>${project.basedir}/src/main/lib</directory>
<targetPath>BOOT-INF/lib/</targetPath>
<includes>
<include>**/*.jar</include>
</includes>
</resource>
<resource>
<directory>${project.basedir}/src/main/lib</directory>
<targetPath>BOOT-INF</targetPath>
<includes>
<include>**/*.so</include>
<include>**/*.dll</include>
</includes>
</resource>
</resources>
<!-- <resources>-->
<!-- <resource>-->
<!-- <directory>${project.basedir}/src/main/lib</directory>-->
<!-- <targetPath>BOOT-INF/lib/</targetPath>-->
<!-- <includes>-->
<!-- <include>**/*.jar</include>-->
<!-- </includes>-->
<!-- </resource>-->
<!-- <resource>-->
<!-- <directory>${project.basedir}/src/main/lib</directory>-->
<!-- <targetPath>BOOT-INF</targetPath>-->
<!-- <includes>-->
<!-- <include>**/*.so</include>-->
<!-- <include>**/*.dll</include>-->
<!-- </includes>-->
<!-- </resource>-->
<!-- </resources>-->
</build>
</project>

@ -20,6 +20,7 @@ echo
echo --------------------------------mvn package...--------------------------------
::call mvn clean package -Dmaven.test.skip=true
copy .\libsapjco3.so .\target\libsapjco3.so
copy .\sapjco3.jar .\target\sapjco3.jar
cd .\target
SET df=Dockerfile
if exist %df% (
@ -27,9 +28,10 @@ if exist %df% (
)
echo --------------------------------´´½¨Dockerfile--------------------------------
echo FROM 192.168.202.36:30002/library/openjdk:8u131-jdk-alpine >> Dockerfile
echo ADD libsapjco3.so /home/sap/libsapjco3.so >> Dockerfile
echo ADD sapjco3.jar /home/sap/sapjco3.jar >> Dockerfile
echo ENV LD_LIBRARY_PATH /home/sap >> Dockerfile
echo ADD libsapjco3.so /usr/lib/libsapjco3.so >> Dockerfile
echo ADD sapjco3.jar /usr/lib/sapjco3.jar >> Dockerfile
echo RUN chmod a+x -R /usr/lib/libsapjco3.so >> Dockerfile
echo ENV LD_LIBRARY_PATH /usr/lib >> Dockerfile
echo COPY %jarName% /application.jar >> Dockerfile
echo RUN echo "Asia/Shanghai" ^> /etc/timezone >> Dockerfile
echo CMD ["java", "-jar", "-Dspring.profiles.active=%profile%", "application.jar"] >> Dockerfile

@ -18,6 +18,7 @@ import com.op.system.api.domain.sap.SapSupplier;
import com.op.system.api.model.SapProOrder;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
@ -130,13 +131,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();
}
/**
@ -211,7 +235,9 @@ public class SapController extends BaseController {
R r = sapWorkCenterService.sapWorkCenterSync(qo);
if(r.getCode()==200){
List<SapWorkCenter> dtos = (List<SapWorkCenter>) r.getData();
sapWorkCenterService.syncWorkCenter(dtos);
if(!CollectionUtils.isEmpty(dtos)) {
sapWorkCenterService.syncWorkCenter(dtos);
}
}else{
logger.error("++++++++++++" + dateSource.get("poolName")+"错误信息:"+ r.getMsg());
}
@ -245,7 +271,10 @@ public class SapController extends BaseController {
R r = sapWorkCenterService.sapSupplierSync(sapSupplierQuery);
if(r.getCode()==200){
List<SapSupplier> dtos = (List<SapSupplier>) r.getData();
sapWorkCenterService.syncSupplier(dtos);
if(!CollectionUtils.isEmpty(dtos)){
sapWorkCenterService.syncSupplier(dtos);
}
}else{
logger.error("++++++++++++" + dateSource.get("poolName")+"错误信息:"+ r.getMsg());
}
@ -280,7 +309,9 @@ public class SapController extends BaseController {
R r = sapWorkCenterService.sapCustomSync(sapCustom);
if(r.getCode()==200){
List<SapCustom> dtos = (List<SapCustom>) r.getData();
sapWorkCenterService.syncCustom(dtos);
if(!CollectionUtils.isEmpty(dtos)) {
sapWorkCenterService.syncCustom(dtos);
}
}else{
logger.error("++++++++++++" + dateSource.get("poolName")+"错误信息:"+ r.getMsg());
}

@ -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);

@ -360,7 +360,8 @@ public class SapWorkCenterServiceImpl implements SapWorkCenterService {
List<SapCustom> updates = new ArrayList<>();
for(String exsitCode:exsitCodes){
updates = dtos.stream().filter(dto -> dto.getKunnr().equals(exsitCode)).collect(Collectors.toList());
List<SapCustom> updates0 = dtos.stream().filter(dto -> dto.getKunnr().equals(exsitCode)).collect(Collectors.toList());
updates.addAll(updates0);
}
if(!CollectionUtils.isEmpty(updates)){
int m = sapBomMapper.updateCustomBatchs(updates);

@ -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>

@ -82,9 +82,9 @@ public class SysDatasourceServiceImpl implements ISysDatasourceService {
+mysqlAffter+sysDatasource.getIpPort().split("/")[1]);
}
if(sysDatasource.getDeptId()!=null){
if(StringUtils.isNotEmpty(sysDatasource.getSystemType())){
sysDatasource.setPoolName(poolNamePrev+"_"+sysDatasource.getDeptId());
}
}
return sysDatasourceMapper.insertSysDatasource(sysDatasource);

@ -37,4 +37,4 @@ sqlserve:
driver: com.microsoft.sqlserver.jdbc.SQLServerDriver
#数据标识前缀
poolName:
prev: factory
prev: ds

@ -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("手动同步失败");

@ -54,7 +54,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="address != null and address != ''"> and address = #{address}</if>
<if test="postcode != null and postcode != ''"> and postcode = #{postcode}</if>
<if test="contact != null and contact != ''"> and contact like concat('%', #{contact}, '%')</if>
<if test="contactPhone != null and contactPhone != ''"> and contact_phone = #{contactPhone}</if>
<if test="contactPhone != null and contactPhone != ''"> and contact_phone like concat('%', #{contactPhone}, '%')</if>
<if test="contactPosition != null and contactPosition != ''"> and contact_position = #{contactPosition}</if>
<if test="contactEmail != null and contactEmail != ''"> and contact_email = #{contactEmail}</if>
<if test="activeFlag != null and activeFlag != ''"> and active_flag = #{activeFlag}</if>

Loading…
Cancel
Save