forked from I3-YF/i3plus-mes-pcn-yfai
Merge remote-tracking branch 'origin/dev-wuhan-temp' into dev-wuhan-temp
commit
0e2fb59a96
@ -0,0 +1,9 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.pcn.api.job;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.pojo.mes.bean.MesPcnSyncOfflineLog;
|
||||||
|
|
||||||
|
public interface IMesOffLineDataSyncJobService {
|
||||||
|
|
||||||
|
String doOffLineDataSync(MesPcnSyncOfflineLog pcnSyncOfflineLog);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.pcn.api.job;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.pojo.mes.bean.MesDatasource;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.bean.MesPcnSyncOfflineLog;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public interface IMesOffLineDataSyncService {
|
||||||
|
|
||||||
|
List<MesPcnSyncOfflineLog> getPcnSyncOfflineLogList(String organizeCode);
|
||||||
|
|
||||||
|
List<String> filterPcnSyncOfflineLogList(List<MesPcnSyncOfflineLog> pcnSyncOfflineLogList, Boolean flag);
|
||||||
|
|
||||||
|
Map<String, String> filterFaulurePcnSyncOfflineLog(List<MesPcnSyncOfflineLog> pcnSyncOfflineLogList);
|
||||||
|
|
||||||
|
MesPcnSyncOfflineLog insertPcnSyncOfflineLog(MesPcnSyncOfflineLog pcnSyncOfflineLog, String tableName);
|
||||||
|
|
||||||
|
void insertBaseBeanData(MesPcnSyncOfflineLog pcnSyncOfflineLog, List<Map<String, Object>> resultList, String objectCode, String tableName) throws Exception;
|
||||||
|
|
||||||
|
}
|
@ -1,4 +0,0 @@
|
|||||||
package cn.estsh.i3plus.ext.mes.pcn.api.job;
|
|
||||||
|
|
||||||
public class TestJobApi {
|
|
||||||
}
|
|
@ -0,0 +1,57 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.pcn.apiservice.config;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.bean.MesDatasource;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.bean.MesPcnTask;
|
||||||
|
import io.swagger.annotations.ApiParam;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ConditionalOnExpression("'${mes.offline.sync.open:false}' == 'true'")
|
||||||
|
@Data
|
||||||
|
@Configuration
|
||||||
|
@ConfigurationProperties(prefix = "mes.offline.sync")
|
||||||
|
public class MesOffLineConfig {
|
||||||
|
|
||||||
|
//离线数据源配置
|
||||||
|
private MesDatasourceModel dataSource = new MesDatasourceModel();
|
||||||
|
|
||||||
|
//离线数据同步JOB配置
|
||||||
|
private MesPcnTaskModel pcnTask = new MesPcnTaskModel();
|
||||||
|
|
||||||
|
//sql参数注入值
|
||||||
|
private Map<String, String> sqlParameter = new HashMap<>();
|
||||||
|
|
||||||
|
//同步sql
|
||||||
|
private Map<String, String> sql = new HashMap<>();
|
||||||
|
|
||||||
|
public class MesDatasourceModel extends MesDatasource implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 7825562788566047534L;
|
||||||
|
|
||||||
|
@ApiParam("主机端口")
|
||||||
|
private String dsHostPort;
|
||||||
|
|
||||||
|
public void setDsHostPort(String dsHostPort) {
|
||||||
|
this.dsHostPort = dsHostPort;
|
||||||
|
if (!StringUtils.isEmpty(this.dsHostPort)) setDsPort(Integer.valueOf(this.dsHostPort));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MesPcnTaskModel extends MesPcnTask implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -521750700257233487L;
|
||||||
|
|
||||||
|
public MesPcnTaskModel() {
|
||||||
|
this.isDeleted = CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue();
|
||||||
|
this.isValid = CommonEnumUtil.IS_VAILD.VAILD.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,72 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.pcn.apiservice.controller.busi;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.api.job.IMesOffLineDataSyncJobService;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.apiservice.config.MesOffLineConfig;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.bean.MesPcnSyncOfflineLog;
|
||||||
|
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
|
||||||
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
|
||||||
|
import cn.estsh.impp.framework.boot.util.ResultBean;
|
||||||
|
import cn.estsh.impp.framework.boot.util.SpringContextsUtil;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(MesCommonConstant.MES_YANFEN + "/offline-data-sync")
|
||||||
|
public class MesOffLineDataSyncController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IMesOffLineDataSyncJobService offLineDataSyncJobService;
|
||||||
|
|
||||||
|
@GetMapping("/cfg/get")
|
||||||
|
@ApiOperation(value = "获取离线配置")
|
||||||
|
public ResultBean getOffLineCfg() {
|
||||||
|
try {
|
||||||
|
MesOffLineConfig offLineConfig = (MesOffLineConfig) SpringContextsUtil.getBean("mesOffLineConfig");
|
||||||
|
Map<String, Object> resultMap = new HashMap<>();
|
||||||
|
resultMap.put("dataSource", offLineConfig.getDataSource());
|
||||||
|
resultMap.put("pcnTask", offLineConfig.getPcnTask());
|
||||||
|
resultMap.put("sqlParameter", offLineConfig.getSqlParameter());
|
||||||
|
resultMap.put("sql", offLineConfig.getSql());
|
||||||
|
return ResultBean.success("查询成功").setResultMap(resultMap);
|
||||||
|
} catch (ImppBusiException imppException) {
|
||||||
|
return ResultBean.fail(imppException);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/do")
|
||||||
|
@ApiOperation(value = "执行离线同步")
|
||||||
|
public ResultBean doOffLineDataSync() {
|
||||||
|
try {
|
||||||
|
|
||||||
|
MesOffLineConfig offLineConfig = (MesOffLineConfig) SpringContextsUtil.getBean("mesOffLineConfig");
|
||||||
|
|
||||||
|
String param = offLineConfig.getPcnTask().getTaskParam();
|
||||||
|
|
||||||
|
String[] params = StringUtils.isEmpty(param) ? null : param.split(MesPcnExtConstWords.COLON);
|
||||||
|
|
||||||
|
if (null == params || params.length != 4) return ResultBean.fail("参数配置错误,参数正确格式[ mes.offline.sync.pcnTask.taskParam = 工厂:区域:生产线:工位 ]");
|
||||||
|
|
||||||
|
MesPcnSyncOfflineLog pcnSyncOfflineLog = new MesPcnSyncOfflineLog(params[0], params[1], params[2], params[3]);
|
||||||
|
pcnSyncOfflineLog.setSyncTarget(InetAddress.getLocalHost().getHostAddress());
|
||||||
|
|
||||||
|
return ResultBean.success(offLineDataSyncJobService.doOffLineDataSync(pcnSyncOfflineLog));
|
||||||
|
} catch (ImppBusiException imppException) {
|
||||||
|
return ResultBean.fail(imppException);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,78 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.pcn.apiservice.schedulejob;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.api.job.IMesOffLineDataSyncJobService;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.bean.MesPcnSyncOfflineLog;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.quartz.DisallowConcurrentExecution;
|
||||||
|
import org.quartz.Job;
|
||||||
|
import org.quartz.JobExecutionContext;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.util.StopWatch;
|
||||||
|
|
||||||
|
import java.net.InetAddress;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: Wynne.Lu
|
||||||
|
* @CreateDate: 2019/12/17 1:18 下午
|
||||||
|
* @Description:
|
||||||
|
**/
|
||||||
|
@Slf4j
|
||||||
|
@ApiOperation("MES同步离线数据JOB")
|
||||||
|
@DisallowConcurrentExecution
|
||||||
|
public class MesOffLineDataSyncJob implements Job {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IMesOffLineDataSyncJobService offLineDataSyncJobService;
|
||||||
|
|
||||||
|
public MesOffLineDataSyncJob() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(JobExecutionContext jobExecutionContext) {
|
||||||
|
|
||||||
|
log.info("MES同步离线数据JOB --- START ---");
|
||||||
|
|
||||||
|
StopWatch stopWatch = new StopWatch();
|
||||||
|
|
||||||
|
stopWatch.start();
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
Object param = jobExecutionContext.getJobDetail().getJobDataMap().get("param");
|
||||||
|
|
||||||
|
if (null == param) {
|
||||||
|
log.info("MES同步离线数据JOB --- ERROR --- 未配置参数 ---");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] params = param.toString().split(MesPcnExtConstWords.COLON);
|
||||||
|
|
||||||
|
if (null == params || params.length != 4) {
|
||||||
|
log.info("MES同步离线数据JOB --- ERROR --- 参数配置错误,参数正确格式[ mes.offline.sync.pcnTask.taskParam = 工厂:区域:生产线:工位 ] ---");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MesPcnSyncOfflineLog pcnSyncOfflineLog = new MesPcnSyncOfflineLog(params[0], params[1], params[2], params[3]);
|
||||||
|
pcnSyncOfflineLog.setSyncTarget(InetAddress.getLocalHost().getHostAddress());
|
||||||
|
|
||||||
|
String success = offLineDataSyncJobService.doOffLineDataSync(pcnSyncOfflineLog);
|
||||||
|
|
||||||
|
log.info("MES同步离线数据JOB --- EXEC --- {} ---", success);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
log.info("MES同步离线数据JOB --- ERROR --- {} ---", JSONObject.toJSONString(e));
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
|
||||||
|
stopWatch.stop();
|
||||||
|
|
||||||
|
log.info("MES同步离线数据JOB --- END --- 耗时:{} ms ---", stopWatch.getTotalTimeMillis());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,218 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.job;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.api.job.IMesOffLineDataSyncJobService;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.api.job.IMesOffLineDataSyncService;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.apiservice.config.MesOffLineConfig;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
|
||||||
|
import cn.estsh.i3plus.mes.pcn.serviceimpl.base.PcnJobService;
|
||||||
|
import cn.estsh.i3plus.mes.pcn.util.BsJdbcTemplate;
|
||||||
|
import cn.estsh.i3plus.mes.pcn.util.BsJdbcTemplateConfig;
|
||||||
|
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
||||||
|
import cn.estsh.i3plus.platform.common.tool.TimeTool;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.bean.MesDatasource;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.bean.MesPcnSyncOfflineLog;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.bean.MesPcnTask;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
|
||||||
|
import cn.estsh.impp.framework.boot.util.SpringContextsUtil;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Primary;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Primary
|
||||||
|
@Service
|
||||||
|
public class MesOffLineDataSyncJobService extends PcnJobService implements IMesOffLineDataSyncJobService {
|
||||||
|
|
||||||
|
private MesOffLineConfig offLineConfig;
|
||||||
|
|
||||||
|
private BsJdbcTemplateConfig jdbcTemplateConfig;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IMesOffLineDataSyncService offLineDataSyncService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MesPcnTask> loadJobs(Boolean pcnScheduleJob, Boolean mesOffLineSyncOpen) {
|
||||||
|
List<MesPcnTask> list = super.loadJobs(pcnScheduleJob, mesOffLineSyncOpen);
|
||||||
|
if (!mesOffLineSyncOpen) return list;
|
||||||
|
try {
|
||||||
|
offLineConfig = (MesOffLineConfig) SpringContextsUtil.getBean("mesOffLineConfig");
|
||||||
|
jdbcTemplateConfig = (BsJdbcTemplateConfig) SpringContextsUtil.getBean("bsJdbcTemplateConfig");
|
||||||
|
list.add(offLineConfig.getPcnTask());
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String doOffLineDataSync(MesPcnSyncOfflineLog pcnSyncOfflineLog) {
|
||||||
|
|
||||||
|
if (null == offLineConfig) offLineConfig = (MesOffLineConfig) SpringContextsUtil.getBean("mesOffLineConfig");
|
||||||
|
|
||||||
|
if (null == offLineConfig) return "MesOffLineConfig IS NULL";
|
||||||
|
|
||||||
|
MesDatasource datasource = offLineConfig.getDataSource();
|
||||||
|
pcnSyncOfflineLog.setSyncSource(String.format("mysql://%s:%s/%s", datasource.getDsHost(), datasource.getDsPort(), datasource.getDsDbName()));
|
||||||
|
pcnSyncOfflineLog.setSyncPattern("全量同步");
|
||||||
|
pcnSyncOfflineLog.setSyncDate(TimeTool.getToday());
|
||||||
|
ConvertBean.serviceModelInitialize(pcnSyncOfflineLog, MesPcnExtConstWords.JOB);
|
||||||
|
pcnSyncOfflineLog.setSystemSyncDatetime(pcnSyncOfflineLog.getModifyDatetime());
|
||||||
|
|
||||||
|
String error = checkDataSourceIsValid(datasource);
|
||||||
|
if (!StringUtils.isEmpty(error)) return error;
|
||||||
|
|
||||||
|
Map<String, String> sqlMap = offLineConfig.getSql();
|
||||||
|
Map<String, String> sqlParameterMap = offLineConfig.getSqlParameter();
|
||||||
|
|
||||||
|
if (CollectionUtils.isEmpty(sqlMap) || CollectionUtils.isEmpty(sqlParameterMap)) return "SQL CFG IS NULL";
|
||||||
|
|
||||||
|
List<MesPcnSyncOfflineLog> pcnSyncOfflineLogList = offLineDataSyncService.getPcnSyncOfflineLogList(pcnSyncOfflineLog.getOrganizeCode());
|
||||||
|
|
||||||
|
List<String> successedList = offLineDataSyncService.filterPcnSyncOfflineLogList(pcnSyncOfflineLogList, true);
|
||||||
|
|
||||||
|
if (!CollectionUtils.isEmpty(successedList) && successedList.containsAll(sqlMap.keySet())) return String.format("%s已同步成功,无需重复执行!", sqlMap.keySet().toString());
|
||||||
|
|
||||||
|
Map<String, String> failuredMap = offLineDataSyncService.filterFaulurePcnSyncOfflineLog(pcnSyncOfflineLogList);
|
||||||
|
|
||||||
|
if (null == jdbcTemplateConfig) jdbcTemplateConfig = (BsJdbcTemplateConfig) SpringContextsUtil.getBean("bsJdbcTemplateConfig");
|
||||||
|
|
||||||
|
BsJdbcTemplate bsJdbcTemplate = null != jdbcTemplateConfig ? jdbcTemplateConfig.getJdbcTemplate(datasource) : null;
|
||||||
|
|
||||||
|
Boolean isConn = null != jdbcTemplateConfig ? jdbcTemplateConfig.checkDbConn(datasource) : false;
|
||||||
|
|
||||||
|
String tableName;
|
||||||
|
Boolean success = true;
|
||||||
|
List<String> successTableNameList = new ArrayList<>();
|
||||||
|
List<String> failureTableNameList = new ArrayList<>();
|
||||||
|
|
||||||
|
for (String objectCode : sqlMap.keySet()) {
|
||||||
|
|
||||||
|
if (StringUtils.isEmpty(objectCode)) continue;
|
||||||
|
|
||||||
|
if (!objectCode.contains(MesPcnExtConstWords.DECIMAL_POINT)) {
|
||||||
|
tableName = objectCode;
|
||||||
|
} else {
|
||||||
|
//如果pojo在 DEFAULT_POJO_ROUTE 下面还有包, 配置的时候需带上除去 DEFAULT_POJO_ROUTE 以外的包
|
||||||
|
String[] suffix = objectCode.split(MesPcnExtConstWords.DECIMAL_POINT_ESCAPE);
|
||||||
|
tableName = suffix[suffix.length - 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!CollectionUtils.isEmpty(successedList) && successedList.contains(tableName)) continue;
|
||||||
|
|
||||||
|
Boolean status = false;
|
||||||
|
String remark = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
String sql = sqlMap.get(objectCode);
|
||||||
|
if (StringUtils.isEmpty(sql)) {
|
||||||
|
remark = "SQL IS NULL";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (null == jdbcTemplateConfig) {
|
||||||
|
remark = "BsJdbcTemplateConfig IS NULL";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (null == bsJdbcTemplate) {
|
||||||
|
remark = "BsJdbcTemplate IS NULL";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!isConn) {
|
||||||
|
remark = "checkDbConn IS FALSE";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Object> paramMap = new HashMap<>();
|
||||||
|
|
||||||
|
for (Map.Entry<String, String> sqlParameter : sqlParameterMap.entrySet()) {
|
||||||
|
|
||||||
|
if (null == sqlParameter || StringUtils.isEmpty(sqlParameter.getValue())) continue;
|
||||||
|
|
||||||
|
if (!sql.contains(MesPcnExtConstWords.COLON + sqlParameter.getKey())) continue;
|
||||||
|
|
||||||
|
if (sqlParameter.getKey().contains("_int")) paramMap.put(sqlParameter.getKey(), Integer.valueOf(sqlParameter.getValue()));
|
||||||
|
else if (sqlParameter.getKey().contains("_list")) paramMap.put(sqlParameter.getKey(), Arrays.asList(sqlParameter.getValue().split(MesPcnExtConstWords.COMMA)));
|
||||||
|
// TODO else if
|
||||||
|
else paramMap.put(sqlParameter.getKey(), sqlParameter.getValue());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Map<String, Object>> resultList = bsJdbcTemplate.getJdbcTemplate().queryForList(sql, paramMap);
|
||||||
|
|
||||||
|
if (CollectionUtils.isEmpty(resultList)) remark = "未查询到数据";
|
||||||
|
else {
|
||||||
|
offLineDataSyncService.insertBaseBeanData(pcnSyncOfflineLog, resultList, objectCode, tableName);
|
||||||
|
successTableNameList.add(tableName);
|
||||||
|
status = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
remark = e.toString();
|
||||||
|
|
||||||
|
success = false;
|
||||||
|
|
||||||
|
log.info("MES同步离线数据JOB --- ERROR --- {} ---", JSONObject.toJSONString(e));
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
if (!status) {
|
||||||
|
insertPcnSyncOfflineLog2Failure(pcnSyncOfflineLog, tableName, failuredMap, remark);
|
||||||
|
failureTableNameList.add(String.format("[%s]同步失败原因[%s]", tableName, remark));
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!CollectionUtils.isEmpty(successTableNameList) && success) {
|
||||||
|
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append(" insert into mes_pcn_sync_offline_log ");
|
||||||
|
builder.append("( id, organize_code, is_valid, is_deleted, create_user, create_date_time, modify_user, modify_date_time, system_sync_date_time, system_sync_status,");
|
||||||
|
builder.append(" area_code, work_center_code, work_cell_code, object_code, effect_num, sync_date, sync_pattern, sync_source, sync_target, sync_result )");
|
||||||
|
builder.append(" values ( :id , :organizeCode , :isValid , :isDeleted , :createUser , :createDatetime , :modifyUser , :modifyDatetime , :systemSyncDatetime , :systemSyncStatus ,");
|
||||||
|
builder.append(" :areaCode , :workCenterCode , :workCellCode , :objectCode , :effectNum , :syncDate , :syncPattern , :syncSource , :syncTarget , :syncResult ); ");
|
||||||
|
|
||||||
|
Map<String, Object> paramMap = JSONObject.parseObject(JSONObject.toJSONString(pcnSyncOfflineLog), Map.class);
|
||||||
|
paramMap.put(MesPcnExtConstWords.OBJECT_CODE, sqlMap.keySet().toString());
|
||||||
|
paramMap.put(MesPcnExtConstWords.EFFECT_NUM, MesPcnExtConstWords.ZERO);
|
||||||
|
|
||||||
|
bsJdbcTemplate.getJdbcTemplate().update(builder.toString(), paramMap);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return (CollectionUtils.isEmpty(successTableNameList) ? MesPcnExtConstWords.EMPTY : String.format("%s同步成功!", successTableNameList.toString())) +
|
||||||
|
(CollectionUtils.isEmpty(failureTableNameList) ? MesPcnExtConstWords.EMPTY : failureTableNameList.toString());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private String checkDataSourceIsValid(MesDatasource datasource) {
|
||||||
|
|
||||||
|
if (null == datasource) return "MesDatasource IS NULL";
|
||||||
|
|
||||||
|
if (StringUtils.isEmpty(datasource.getDsCode())) return "离线边端数据库[dsCode]未配置!";
|
||||||
|
if (StringUtils.isEmpty(datasource.getDsName())) return "离线边端数据库[dsName]未配置!";
|
||||||
|
if (StringUtils.isEmpty(datasource.getDsType())) return "离线边端数据库[dsType]未配置!";
|
||||||
|
if (StringUtils.isEmpty(datasource.getDsHost())) return "离线边端数据库[dsHost]未配置!";
|
||||||
|
if (StringUtils.isEmpty(datasource.getDsPort())) return "离线边端数据库[dsHostPort]未配置!";
|
||||||
|
if (StringUtils.isEmpty(datasource.getDsUser())) return "离线边端数据库[dsUser]未配置!";
|
||||||
|
if (StringUtils.isEmpty(datasource.getDsPassword())) return "离线边端数据库[dsPassword]未配置!";
|
||||||
|
if (StringUtils.isEmpty(datasource.getDsDbName())) return "离线边端数据库[dsDbName]未配置!";
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void insertPcnSyncOfflineLog2Failure(MesPcnSyncOfflineLog pcnSyncOfflineLog, String objectCode, Map<String, String> failuredMap, String remark) {
|
||||||
|
|
||||||
|
if (!CollectionUtils.isEmpty(failuredMap) && failuredMap.containsKey(objectCode) && failuredMap.get(objectCode).equals(remark)) return;
|
||||||
|
|
||||||
|
offLineDataSyncService.insertPcnSyncOfflineLog(pcnSyncOfflineLog.syncResult(MesExtEnumUtil.MES_LOG_DEAL_STATUS.DEAL_FAILURE.getValue()).remark(remark), objectCode);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,136 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.job;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.api.job.IMesOffLineDataSyncService;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
|
||||||
|
import cn.estsh.i3plus.mes.pcn.util.StringUtil;
|
||||||
|
import cn.estsh.i3plus.platform.common.tool.ReflectTool;
|
||||||
|
import cn.estsh.i3plus.platform.common.tool.TimeTool;
|
||||||
|
import cn.estsh.i3plus.pojo.base.bean.BaseBean;
|
||||||
|
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
|
||||||
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
||||||
|
import cn.estsh.i3plus.pojo.base.jpa.dao.BaseRepository;
|
||||||
|
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.bean.MesPcnSyncOfflineLog;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.repository.MesPcnSyncOfflineLogRepository;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
|
||||||
|
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
|
||||||
|
import cn.estsh.impp.framework.boot.util.SpringContextsUtil;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class MesOffLineDataSyncService implements IMesOffLineDataSyncService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MesPcnSyncOfflineLogRepository pcnSyncOfflineLogRepository;
|
||||||
|
|
||||||
|
private static String DEFAULT_POJO_ROUTE = "cn.estsh.i3plus.pojo.mes.bean.";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MesPcnSyncOfflineLog> getPcnSyncOfflineLogList(String organizeCode) {
|
||||||
|
return pcnSyncOfflineLogRepository.findByProperty(
|
||||||
|
new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, MesPcnExtConstWords.SYNC_DATE},
|
||||||
|
new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), TimeTool.getToday()});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> filterPcnSyncOfflineLogList(List<MesPcnSyncOfflineLog> pcnSyncOfflineLogList, Boolean flag) {
|
||||||
|
return CollectionUtils.isEmpty(pcnSyncOfflineLogList) ? null : pcnSyncOfflineLogList.stream().filter(o -> (
|
||||||
|
null != o && o.getSyncResult().compareTo(MesExtEnumUtil.MES_LOG_DEAL_STATUS.getValueByFlag(flag)) == 0)).map(MesPcnSyncOfflineLog::getObjectCode).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, String> filterFaulurePcnSyncOfflineLog(List<MesPcnSyncOfflineLog> pcnSyncOfflineLogList) {
|
||||||
|
List<MesPcnSyncOfflineLog> filterList = CollectionUtils.isEmpty(pcnSyncOfflineLogList) ? null :
|
||||||
|
pcnSyncOfflineLogList.stream().filter(o -> (null != o && o.getSyncResult().compareTo(MesExtEnumUtil.MES_LOG_DEAL_STATUS.DEAL_FAILURE.getValue()) == 0)).collect(Collectors.toList());
|
||||||
|
if (CollectionUtils.isEmpty(filterList)) return null;
|
||||||
|
filterList = filterList.stream().filter(o -> null != o).sorted(Comparator.comparing(MesPcnSyncOfflineLog::getCreateDatetime).reversed()).collect(Collectors.toList());
|
||||||
|
filterList = filterList.stream().filter(o -> null != o).distinct().collect(Collectors.collectingAndThen(
|
||||||
|
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(MesPcnSyncOfflineLog::getObjectCode))), ArrayList::new));
|
||||||
|
return filterList.stream().filter(o -> null != o).collect(Collectors.toMap(MesPcnSyncOfflineLog::getObjectCode, MesPcnSyncOfflineLog::getRemark));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(propagation = Propagation.REQUIRES_NEW, noRollbackFor = {ImppBusiException.class, Exception.class})
|
||||||
|
public MesPcnSyncOfflineLog insertPcnSyncOfflineLog(MesPcnSyncOfflineLog pcnSyncOfflineLog, String tableName) {
|
||||||
|
pcnSyncOfflineLog.setObjectCode(tableName);
|
||||||
|
pcnSyncOfflineLog.setId(null);
|
||||||
|
pcnSyncOfflineLog = pcnSyncOfflineLogRepository.insert(pcnSyncOfflineLog);
|
||||||
|
log.info("MES同步离线数据JOB --- EXEC --- TABLE_NAME: {} --- {} ---", tableName, JSONObject.toJSONString(pcnSyncOfflineLog));
|
||||||
|
return pcnSyncOfflineLog;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(propagation = Propagation.REQUIRES_NEW, noRollbackFor = {ImppBusiException.class, Exception.class})
|
||||||
|
public void insertBaseBeanData(MesPcnSyncOfflineLog pcnSyncOfflineLog, List<Map<String, Object>> resultList, String objectCode, String tableName) throws Exception {
|
||||||
|
|
||||||
|
String daoName = StringUtil.lineToHump(tableName);
|
||||||
|
String pojoName = StringUtil.toUpperCaseFirst(daoName);
|
||||||
|
String pojoRoute = DEFAULT_POJO_ROUTE + (!objectCode.contains(MesPcnExtConstWords.DECIMAL_POINT) ? pojoName : objectCode.replace(tableName, pojoName));
|
||||||
|
|
||||||
|
BaseRepository baseRepository = (BaseRepository) SpringContextsUtil.getBean(daoName + MesPcnExtConstWords.Repository);
|
||||||
|
|
||||||
|
List<BaseBean> historyList = baseRepository.findAll();
|
||||||
|
Map<Long, BaseBean> historyMap = CollectionUtils.isEmpty(historyList) ? null : historyList.stream().filter(o -> null != o).collect(Collectors.toMap(BaseBean::getId, o -> o));
|
||||||
|
|
||||||
|
Class clazz = Class.forName(pojoRoute);
|
||||||
|
|
||||||
|
Field[] fields = ArrayUtils.addAll(clazz.getFields(), clazz.getDeclaredFields());
|
||||||
|
|
||||||
|
String fieldName;
|
||||||
|
for (Map<String, Object> map : resultList) {
|
||||||
|
|
||||||
|
BaseBean baseBean = (BaseBean) clazz.newInstance();
|
||||||
|
|
||||||
|
for (Field field : fields) {
|
||||||
|
|
||||||
|
if (null == field) continue;
|
||||||
|
|
||||||
|
Column column = field.getAnnotation(Column.class);
|
||||||
|
|
||||||
|
if (null == column) continue;
|
||||||
|
|
||||||
|
fieldName = column.name().toLowerCase();
|
||||||
|
|
||||||
|
if (!map.containsKey(fieldName)) continue;
|
||||||
|
|
||||||
|
ReflectTool.setFieldValue(baseBean, field, map.get(fieldName));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
baseBean.setSystemSyncDatetime(pcnSyncOfflineLog.getSystemSyncDatetime());
|
||||||
|
if (!CollectionUtils.isEmpty(historyMap) && historyMap.containsKey(baseBean.getId())) {
|
||||||
|
baseRepository.updateNoSync(baseBean);
|
||||||
|
historyMap.remove(baseBean.getId());
|
||||||
|
} else {
|
||||||
|
baseRepository.insert(baseBean);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
historyList = CollectionUtils.isEmpty(historyMap) ? null :
|
||||||
|
historyMap.values().stream().filter(o -> (null != o && o.getIsDeleted().compareTo(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()) == 0)).collect(Collectors.toList());
|
||||||
|
|
||||||
|
if (!CollectionUtils.isEmpty(historyList)) {
|
||||||
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(pcnSyncOfflineLog.getOrganizeCode());
|
||||||
|
DdlPreparedPack.getInPackList(historyList.stream().filter(o -> null != o).map(BaseBean::getId).collect(Collectors.toList()), MesPcnExtConstWords.ID, packBean);
|
||||||
|
baseRepository.updateByProperties(MesPcnExtConstWords.IS_DELETED, CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue(), packBean);
|
||||||
|
}
|
||||||
|
|
||||||
|
insertPcnSyncOfflineLog(pcnSyncOfflineLog.syncResult(MesExtEnumUtil.MES_LOG_DEAL_STATUS.DEAL_SUCCESS.getValue()).effectNum(CollectionUtils.isEmpty(resultList) ? 0 : resultList.size()).remark(null), tableName);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
##\u79BB\u7EBF\u5F00\u5173
|
||||||
|
mes.offline.open = false
|
||||||
|
##\u79BB\u7EBF\u540C\u6B65\u5F00\u5173
|
||||||
|
mes.offline.sync.open = true
|
||||||
|
|
||||||
|
##\u79BB\u7EBF\u540C\u6B65\u8FB9\u7AEF\u6570\u636E\u5E93JOB
|
||||||
|
mes.offline.sync.pcnTask.taskCode = OFFLINE_DATA_SYNC_JOB
|
||||||
|
mes.offline.sync.pcnTask.taskName = OFFLINE_DATA_SYNC_JOB
|
||||||
|
mes.offline.sync.pcnTask.taskGroupName = OFFLINE_DATA_SYNC_JOB
|
||||||
|
mes.offline.sync.pcnTask.taskDescription = OFFLINE_DATA_SYNC_JOB
|
||||||
|
mes.offline.sync.pcnTask.taskClass = MesOffLineDataSyncJob
|
||||||
|
mes.offline.sync.pcnTask.taskPackage = cn.estsh.i3plus.ext.mes.pcn.apiservice.schedulejob
|
||||||
|
mes.offline.sync.pcnTask.pcnCode = PCN001
|
||||||
|
mes.offline.sync.pcnTask.taskCycleExps = 0 0/2 * * * ?
|
||||||
|
mes.offline.sync.pcnTask.taskCycleDescription = \u6BCF2\u5206\u949F\u6267\u884C\u4E00\u6B21
|
||||||
|
mes.offline.sync.pcnTask.taskParam = CR01:CH218:CH218-B
|
||||||
|
|
||||||
|
##\u79BB\u7EBF\u8FB9\u7AEF\u6570\u636E\u5E93\u914D\u7F6E
|
||||||
|
mes.offline.sync.dataSource.dsCode = impp_i3_mes_offline
|
||||||
|
mes.offline.sync.dataSource.dsName = impp_i3_mes_offline
|
||||||
|
mes.offline.sync.dataSource.dsType = SOURCE_MARIA_DB
|
||||||
|
mes.offline.sync.dataSource.dsHost = 10.193.30.20
|
||||||
|
mes.offline.sync.dataSource.dsHostPort = 3306
|
||||||
|
mes.offline.sync.dataSource.dsUser = root
|
||||||
|
mes.offline.sync.dataSource.dsPassword = (mfLEu7@9kmfdsTy
|
||||||
|
mes.offline.sync.dataSource.dsDbName = impp_i3_mes_offline
|
||||||
|
|
||||||
|
##\u79BB\u7EBF\u8BBF\u95EE\u8FB9\u7AEF\u6570\u636E\u5E93SQL\u8BED\u53E5\u5360\u4F4D\u7B26\u5BF9\u5E94\u503C
|
||||||
|
mes.offline.sync.sqlParameter.organize_code = CR01
|
||||||
|
|
||||||
|
|
||||||
|
##\u79BB\u7EBF\u8BBF\u95EE\u8FB9\u7AEF\u6570\u636E\u5E93SQL\u8BED\u53E5
|
||||||
|
##\u7EC4\u7EC7\u6A21\u578B
|
||||||
|
mes.offline.sync.sql.mes_datasource = select * from mes_datasource where organize_code = :organize_code ;
|
||||||
|
|
@ -0,0 +1,81 @@
|
|||||||
|
##\u79BB\u7EBF\u5F00\u5173
|
||||||
|
mes.offline.open = false
|
||||||
|
##\u79BB\u7EBF\u540C\u6B65\u5F00\u5173
|
||||||
|
mes.offline.sync.open = true
|
||||||
|
|
||||||
|
##\u79BB\u7EBF\u540C\u6B65\u8FB9\u7AEF\u6570\u636E\u5E93JOB
|
||||||
|
mes.offline.sync.pcnTask.taskCode = OFFLINE_DATA_SYNC_JOB
|
||||||
|
mes.offline.sync.pcnTask.taskName = OFFLINE_DATA_SYNC_JOB
|
||||||
|
mes.offline.sync.pcnTask.taskGroupName = OFFLINE_DATA_SYNC_JOB
|
||||||
|
mes.offline.sync.pcnTask.taskDescription = OFFLINE_DATA_SYNC_JOB
|
||||||
|
mes.offline.sync.pcnTask.taskClass = MesOffLineDataSyncJob
|
||||||
|
mes.offline.sync.pcnTask.taskPackage = cn.estsh.i3plus.ext.mes.pcn.apiservice.schedulejob
|
||||||
|
mes.offline.sync.pcnTask.pcnCode = PCN001
|
||||||
|
#mes.offline.sync.pcnTask.taskCycleExps = 0 0 */1 * * ?
|
||||||
|
mes.offline.sync.pcnTask.taskCycleExps = 0 0/10 * * * ?
|
||||||
|
mes.offline.sync.pcnTask.taskCycleDescription = \u6BCF\u5C0F\u65F6\u6267\u884C\u4E00\u6B21
|
||||||
|
mes.offline.sync.pcnTask.taskParam = CR01:CH218:CH218-B
|
||||||
|
|
||||||
|
##\u79BB\u7EBF\u8FB9\u7AEF\u6570\u636E\u5E93\u914D\u7F6E
|
||||||
|
mes.offline.sync.dataSource.dsCode = impp_i3_mes
|
||||||
|
mes.offline.sync.dataSource.dsName = impp_i3_mes
|
||||||
|
mes.offline.sync.dataSource.dsType = SOURCE_MARIA_DB
|
||||||
|
mes.offline.sync.dataSource.dsHost = 10.193.30.20
|
||||||
|
mes.offline.sync.dataSource.dsHostPort = 3306
|
||||||
|
mes.offline.sync.dataSource.dsUser = root
|
||||||
|
mes.offline.sync.dataSource.dsPassword = (mfLEu7@9kmfdsTy
|
||||||
|
mes.offline.sync.dataSource.dsDbName = impp_i3_mes
|
||||||
|
|
||||||
|
##\u79BB\u7EBF\u8BBF\u95EE\u8FB9\u7AEF\u6570\u636E\u5E93SQL\u8BED\u53E5\u5360\u4F4D\u7B26\u5BF9\u5E94\u503C
|
||||||
|
mes.offline.sync.sqlParameter.organize_code = CR01
|
||||||
|
mes.offline.sync.sqlParameter.work_center_code = CH218
|
||||||
|
mes.offline.sync.sqlParameter.work_cell_code = CH218-B
|
||||||
|
##mes.offline.sync.sqlParameter.part_no_list = abc,def,ghi...
|
||||||
|
##mes.offline.sync.sqlParameter.field_int = 10
|
||||||
|
|
||||||
|
##\u79BB\u7EBF\u8BBF\u95EE\u8FB9\u7AEF\u6570\u636E\u5E93SQL\u8BED\u53E5
|
||||||
|
##\u7EC4\u7EC7\u6A21\u578B
|
||||||
|
mes.offline.sync.sql.mes_area = select * from mes_area where organize_code = :organize_code ;
|
||||||
|
mes.offline.sync.sql.mes_work_center = select * from mes_work_center where organize_code = :organize_code and work_center_code = :work_center_code ;
|
||||||
|
mes.offline.sync.sql.mes_work_cell = select * from mes_work_cell where organize_code = :organize_code and work_center_code = :work_center_code ;
|
||||||
|
|
||||||
|
##\u5DE5\u827A\u6D41\u7A0B
|
||||||
|
mes.offline.sync.sql.mes_state_machine = select * from mes_state_machine where organize_code = :organize_code and is_deleted = 2 and sm_code in (select sm_code from mes_route_process where organize_code = :organize_code and is_deleted = 2 and route_code in (select route_code from mes_route_process_cell where organize_code = :organize_code and is_deleted = 2 and work_center_code = :work_center_code and work_cell_code = :work_cell_code) and process_code in (select process_code from mes_route_process_cell where organize_code = :organize_code and is_deleted = 2 and work_center_code = :work_center_code and work_cell_code = :work_cell_code )) ;
|
||||||
|
mes.offline.sync.sql.mes_state_machine_status = select * from mes_state_machine_status where organize_code = :organize_code and is_deleted = 2 and sm_code in (select sm_code from mes_route_process where organize_code = :organize_code and is_deleted = 2 and route_code in (select route_code from mes_route_process_cell where organize_code = :organize_code and is_deleted = 2 and work_center_code = :work_center_code and work_cell_code = :work_cell_code) and process_code in (select process_code from mes_route_process_cell where organize_code = :organize_code and is_deleted = 2 and work_center_code = :work_center_code and work_cell_code = :work_cell_code )) ;
|
||||||
|
mes.offline.sync.sql.mes_step_group = select * from mes_step_group where organize_code = :organize_code and amg_id in (select trigger_amg_id from mes_state_machine_status where organize_code = :organize_code and is_deleted = 2 and sm_code in (select sm_code from mes_route_process where organize_code = :organize_code and is_deleted = 2 and route_code in (select route_code from mes_route_process_cell where organize_code = :organize_code and is_deleted = 2 and work_center_code = :work_center_code and work_cell_code = :work_cell_code) and process_code in (select process_code from mes_route_process_cell where organize_code = :organize_code and is_deleted = 2 and work_center_code = :work_center_code and work_cell_code = :work_cell_code ))) ;
|
||||||
|
mes.offline.sync.sql.mes_step = select * from mes_step where organize_code = :organize_code ;
|
||||||
|
mes.offline.sync.sql.mes_step_param = select * from mes_step_param where organize_code = :organize_code ;
|
||||||
|
mes.offline.sync.sql.mes_route = select * from mes_route where organize_code = :organize_code and is_deleted = 2 and route_code in (select route_code from mes_route_process_cell where organize_code = :organize_code and is_deleted = 2 and work_center_code = :work_center_code and work_cell_code = :work_cell_code ) ;
|
||||||
|
mes.offline.sync.sql.mes_route_process = select * from mes_route_process where organize_code = :organize_code and is_deleted = 2 and route_code in (select route_code from mes_route_process_cell where organize_code = :organize_code and is_deleted = 2 and work_center_code = :work_center_code and work_cell_code = :work_cell_code ) ;
|
||||||
|
mes.offline.sync.sql.mes_route_process_cell = select * from mes_route_process_cell where organize_code = :organize_code and is_deleted = 2 and work_center_code = :work_center_code and work_cell_code = :work_cell_code ;
|
||||||
|
mes.offline.sync.sql.mes_prod_route_cfg = select * from mes_prod_route_cfg where organize_code = :organize_code and is_deleted = 2 and work_center_code = :work_center_code ;
|
||||||
|
mes.offline.sync.sql.mes_prod_route_opt_param = select * from mes_prod_route_opt_param where organize_code = :organize_code and is_deleted = 2 and prod_route_cfg_id in (select id from mes_prod_route_cfg where organize_code = :organize_code and is_deleted = 2 and work_center_code = :work_center_code ) ;
|
||||||
|
mes.offline.sync.sql.mes_process = select * from mes_process where organize_code = :organize_code and is_deleted = 2 and process_code in (select process_code from mes_route_process_cell where organize_code = :organize_code and is_deleted = 2 and work_center_code = :work_center_code and work_cell_code = :work_cell_code ) ;
|
||||||
|
mes.offline.sync.sql.mes_craft = select * from mes_craft where organize_code = :organize_code and is_deleted = 2 and craft_code in (select craft_code from mes_process_craft_cfg where organize_code = :organize_code and is_deleted = 2 and process_code in (select process_code from mes_process where organize_code = :organize_code and is_deleted = 2 and process_code in (select process_code from mes_route_process_cell where organize_code = :organize_code and is_deleted = 2 and work_center_code = :work_center_code and work_cell_code = :work_cell_code ))) ;
|
||||||
|
mes.offline.sync.sql.mes_process_craft_cfg = select * from mes_process_craft_cfg where organize_code = :organize_code and is_deleted = 2 and process_code in (select process_code from mes_process where organize_code = :organize_code and is_deleted = 2 and process_code in (select process_code from mes_route_process_cell where organize_code = :organize_code and is_deleted = 2 and work_center_code = :work_center_code and work_cell_code = :work_cell_code )) ;
|
||||||
|
|
||||||
|
##\u7CFB\u7EDF\u914D\u7F6E
|
||||||
|
mes.offline.sync.sql.mes_config = select * from mes_config ;
|
||||||
|
|
||||||
|
##\u5DE5\u4F4D\u6309\u94AE
|
||||||
|
mes.offline.sync.sql.mes_window = select * from mes_window where organize_code = :organize_code ;
|
||||||
|
mes.offline.sync.sql.mes_window_module = select * from mes_window_module where organize_code = :organize_code ;
|
||||||
|
mes.offline.sync.sql.mes_window_module_param = select * from mes_window_module_param where organize_code = :organize_code ;
|
||||||
|
mes.offline.sync.sql.mes_work_module = select * from mes_work_module where organize_code = :organize_code ;
|
||||||
|
mes.offline.sync.sql.mes_work_module_param = select * from mes_work_module_param where organize_code = :organize_code ;
|
||||||
|
mes.offline.sync.sql.mes_work_cell_module = select * from mes_work_cell_module where organize_code = :organize_code and is_deleted = 2 and is_valid = 1 and work_center_code = :work_center_code and work_cell_code = :work_cell_code ;
|
||||||
|
|
||||||
|
##\u7269\u6599\u4FE1\u606F
|
||||||
|
mes.offline.sync.sql.mes_part = select * from mes_part where organize_code = :organize_code ;
|
||||||
|
mes.offline.sync.sql.mes_part_sap = select * from mes_part_sap where organize_code = :organize_code ;
|
||||||
|
mes.offline.sync.sql.mes_customer_part = select * from mes_customer_part where organize_code = :organize_code ;
|
||||||
|
|
||||||
|
##\u6253\u5370\u6A21\u7248
|
||||||
|
mes.offline.sync.sql.mes_label_template = select * from mes_label_template where organize_code = :organize_code and is_deleted = 2 and is_valid = 1 ;
|
||||||
|
mes.offline.sync.sql.mes_label_template_param = select * from mes_label_template_param where organize_code = :organize_code and is_deleted = 2 and is_valid = 1 ;
|
||||||
|
|
||||||
|
##\u7F16\u7801\u89C4\u5219
|
||||||
|
mes.offline.sync.sql.mes_number_rule = select * from mes_number_rule where organize_code = :organize_code and is_deleted = 2 and is_valid = 1 ;
|
||||||
|
|
||||||
|
##\u6392\u5E8F\u4EA7\u54C1\u52A0\u5DE5\u89C4\u5219
|
||||||
|
mes.offline.sync.sql.mes_prod_rule_sort_cfg = select * from mes_prod_rule_sort_cfg where organize_code = :organize_code and work_center_code = :work_center_code and work_cell_code = :work_cell_code ;
|
Loading…
Reference in New Issue