去除离线生产配置

tags/yfai-pcn-ext-v2.3
王杰 6 months ago
parent c3d079fa83
commit 872f8e9413

@ -1,9 +0,0 @@
package cn.estsh.i3plus.ext.mes.pcn.api.job;
import cn.estsh.i3plus.pojo.mes.bean.MesPcnSyncOfflineLog;
public interface IMesOffLineDataSyncJobService {
String doOffLineDataSync(MesPcnSyncOfflineLog pcnSyncOfflineLog);
}

@ -1,21 +0,0 @@
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,57 +0,0 @@
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();
}
}
}

@ -1,72 +0,0 @@
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);
}
}
}

@ -1,78 +0,0 @@
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());
}
}
}

@ -67,12 +67,12 @@ public class MesAssemblyExtService implements IMesAssemblyExtService {
if (CollectionUtils.isEmpty(workOrderAssemblyList)) return null;
//获取排序FILE文件URL 【离线生产不需要获取文件】
Map<Long, String> fileMap = !prodRuleContext.getIsClosedCheck() ? getFileMap(prodRuleContext.getOrganizeCode(), filterSortFileIdList(workOrderAssemblyList)) : null;
//获取排序FILE文件URL
Map<Long, String> fileMap = getFileMap(prodRuleContext.getOrganizeCode(), filterSortFileIdList(workOrderAssemblyList));
List<MesProductionAssemblySortContext> productionAssemblySortContextList = new ArrayList<>();
workOrderAssemblyList.forEach(o -> productionAssemblySortContextList.add(new MesProductionAssemblySortContext().copy(o).fileUrl(fileMap).foreignKey(prodRuleContext.getForeignKey()).isClosedCheck(prodRuleContext.getIsClosedCheck())));
workOrderAssemblyList.forEach(o -> productionAssemblySortContextList.add(new MesProductionAssemblySortContext().copy(o).fileUrl(fileMap).foreignKey(prodRuleContext.getForeignKey())));
return productionAssemblySortContextList;
}
@ -101,17 +101,16 @@ public class MesAssemblyExtService implements IMesAssemblyExtService {
workOrderAssemblyList.forEach(o -> productionAssemblySortContextList.add(
new MesProductionAssemblySortContext()
.copy(o, getProductionAssembly(productionAssemblyMap, o.getId()), getIsCheckBindSeq(getWorkCell(workCellMap, o.getWorkCellCode()), prodRuleContext.getIsClosedCheck()))
.foreignKey(prodRuleContext.getForeignKey()).isClosedCheck(prodRuleContext.getIsClosedCheck())
.copy(o, getProductionAssembly(productionAssemblyMap, o.getId()), getIsCheckBindSeq(getWorkCell(workCellMap, o.getWorkCellCode())))
.foreignKey(prodRuleContext.getForeignKey())
)
);
return productionAssemblySortContextList;
}
//判断是否按序扫描【离线默认有序】
private Integer getIsCheckBindSeq(MesWorkCell workCell, Boolean isClosedCheck) {
if (isClosedCheck) return CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue();
//判断是否按序扫描
private Integer getIsCheckBindSeq(MesWorkCell workCell) {
return (null != workCell && !StringUtils.isEmpty(workCell.getIsSeqScan())) ? workCell.getIsSeqScan() : CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue();
}

@ -1,218 +0,0 @@
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);
}
}

@ -1,136 +0,0 @@
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);
}
}

@ -39,10 +39,6 @@ public class MesNumberRuleMatchAndUniqueService implements IMesNumberRuleMatchDi
return result;
}
//验证是否离线
MesProductionAssemblyContext context = (MesProductionAssemblyContext) params[0];
if (context.getIsClosedCheck()) return result;
List<MesProductionAssemblyUnique> productionAssemblyUniqueList = assemblyExtService.getProductionAssemblyUniqueList(organizeCode, sn);
Optional<MesProductionAssemblyUnique> optional = CollectionUtils.isEmpty(productionAssemblyUniqueList) ? null :

@ -39,9 +39,7 @@ public class MesNumberRuleMatchSnService implements IMesNumberRuleMatchDispatchS
return result;
}
//验证是否离线
MesProductionAssemblyContext context = (MesProductionAssemblyContext) params[0];
if (context.getIsClosedCheck()) return result;
List<MesProduceSn> produceSnList = produceSnExtService.getProduceSnList(organizeCode, sn);
if (CollectionUtils.isEmpty(produceSnList)) {

@ -58,9 +58,6 @@ public class MesNumberRuleMatchSortDoubleCheckService implements IMesNumberRuleM
if (!(Boolean) result.get(MesPcnExtConstWords.RESULT)) return result;
}
//验证是否离线
if (context.getIsClosedCheck()) return result;
result.put(MesPcnExtConstWords.RESULT, false);
//验证零件号

@ -40,10 +40,6 @@ public class MesNumberRuleMatchSortSnGmService implements IMesNumberRuleMatchDis
return result;
}
//验证是否离线
MesProductionAssemblyContext context = (MesProductionAssemblyContext) params[0];
if (context.getIsClosedCheck()) return result;
String productSn = customerSnTransformService.transformBarCodeGm(sn);
if (productSn.length() == sn.length()) {
result.put(MesPcnExtConstWords.MESSAGE, String.format("通用自制件条码固定长度为58位,零件条码[%s]长度[%s]位!", sn, sn.length()));

@ -1,6 +1,5 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.station.function;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesConfigService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseSwsService;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.function.IFsmModuleFunctionService;
@ -24,7 +23,6 @@ import org.springframework.util.CollectionUtils;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**

@ -248,7 +248,7 @@ public class MesAssemblyMatchSortStepService extends BaseStepService {
MesProductionAssemblySortContext filter = (MesProductionAssemblySortContext) result.get(MesPcnExtConstWords.DATA);
//前道防错
if (!filter.getIsClosedCheck() && !StringUtils.isEmpty(filter.getProductSnId()) && !StringUtils.isEmpty(productionAssemblySortContext.getPreCraftCode())) {
if (!StringUtils.isEmpty(filter.getProductSnId()) && !StringUtils.isEmpty(productionAssemblySortContext.getPreCraftCode())) {
if (CollectionUtils.isEmpty(productionRecordService.findProductionRecordList(reqBean.getOrganizeCode(), equipVariableCollectContext.getEquipVariableValue(), productionAssemblySortContext.getAssemblyPartNo(), productionAssemblySortContext.getPreCraftCode()))) {
stepResult.msg(String.format("%s%s", StringUtils.isEmpty(stepResult.getMsg()) ? MesPcnExtConstWords.EMPTY : stepResult.getMsg(),
String.format("零件条码[%s]前道防错零件号[%s]工艺[%s]验证失败,未查询到加工记录信息!", equipVariableCollectContext.getEquipVariableValue(), productionAssemblySortContext.getAssemblyPartNo(), productionAssemblySortContext.getPreCraftCode())));
@ -257,7 +257,7 @@ public class MesAssemblyMatchSortStepService extends BaseStepService {
}
//时效性验证
if (!filter.getIsClosedCheck() && !StringUtils.isEmpty(filter.getProductSnId())) {
if (!StringUtils.isEmpty(filter.getProductSnId())) {
result = timeEfficientCfgMatchService.checkSnTimeliness(reqBean.getOrganizeCode(), equipVariableCollectContext.getEquipVariableValue(), filter.getSourceId(), MesExtEnumUtil.TIME_DATA_SOURCE.DATA_SOURCE10.getValue());
if (!(Boolean)result.get(MesPcnExtConstWords.RESULT)) {

@ -63,9 +63,6 @@ public class MesAssemblyReadStepService extends BaseStepService {
@Override
public StepResult init(StationRequestBean reqBean) {
//离线生产
if (mesOffLineOpen) stepExpSendMsgAndThrowEx(reqBean, new StationResultBean().writeDbLog(), "离线生产当前设备不可用!");
StepResult stepResult = StepResult.getSuccessComplete();
String endlessLoopReadTimes = fsmCommonService.handleFsmWcpcMapDataForDoScan(reqBean).get(MesPcnExtConstWords.ENDLESS_LOOP_READ_TIMES);

@ -31,8 +31,7 @@ public class MesAssemblyShowSortPreCraftStepService extends MesAssemblyShowSortS
public MesProdRuleContext getProdRuleSortContext(StationRequestBean reqBean, MesProductionProcessContext productionProcessContext, MesCellEquipContext cellEquipContext, MesProductionPsInContext productionPsInContext) {
Map<String, MesWorkCell> workCellMap = productionProcessContextStepService.dispatchWorkCellMap(reqBean);
MesProdRuleContext prodRuleContext = new MesProdRuleContext(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), reqBean.getProcessCode(), productionProcessContext.getCraftCode())
.equipmentCode(cellEquipContext.getEquipmentCode()).workOrderNo(productionPsInContext.getWorkOrderNo()).productSn(productionPsInContext.getProductSn()).foreignKey(productionPsInContext.getForeignKey())
.isClosedCheck(mesOffLineOpen);
.equipmentCode(cellEquipContext.getEquipmentCode()).workOrderNo(productionPsInContext.getWorkOrderNo()).productSn(productionPsInContext.getProductSn()).foreignKey(productionPsInContext.getForeignKey());
return prodRuleCfgExtService.getProdRuleSortPreCraftContext(prodRuleContext, workCellMap);
}

@ -115,15 +115,13 @@ public class MesAssemblyShowSortStepService extends BaseStepService {
public MesProdRuleContext getProdRuleSortContext(StationRequestBean reqBean, MesProductionProcessContext productionProcessContext, MesCellEquipContext cellEquipContext, MesProductionPsInContext productionPsInContext) {
MesProdRuleContext prodRuleContext = new MesProdRuleContext(
reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), reqBean.getProcessCode(), productionProcessContext.getCraftCode()).isCheckBindSeq(getIsCheckBindSeq(productionProcessContext.getWorkCell()))
.equipmentCode(cellEquipContext.getEquipmentCode()).workOrderNo(productionPsInContext.getWorkOrderNo()).productSn(productionPsInContext.getProductSn()).foreignKey(productionPsInContext.getForeignKey())
.isClosedCheck(mesOffLineOpen);
.equipmentCode(cellEquipContext.getEquipmentCode()).workOrderNo(productionPsInContext.getWorkOrderNo()).productSn(productionPsInContext.getProductSn()).foreignKey(productionPsInContext.getForeignKey());
return prodRuleCfgExtService.getProdRuleSortContext(prodRuleContext);
}
//判断是否按序扫描【离线默认有序】
//判断是否按序扫描
private Integer getIsCheckBindSeq(MesWorkCell workCell) {
if (!mesOffLineOpen) return (null != workCell && !StringUtils.isEmpty(workCell.getIsSeqScan())) ? workCell.getIsSeqScan() : CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue();
return CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue();
return (null != workCell && !StringUtils.isEmpty(workCell.getIsSeqScan())) ? workCell.getIsSeqScan() : CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue();
}
//装配件清单列表标题

@ -8,7 +8,6 @@ import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesCellEquipContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesEquipLogDispatchContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionProcessContext;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentVariable;
import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentVariableCfg;
@ -20,7 +19,6 @@ import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.List;
@ -55,9 +53,6 @@ public class MesEquipByPassReadStepService extends BaseStepService {
MesProductionProcessContext productionProcessContext = productionProcessContextStepService.getProductionProcessContext(reqBean);
if (!productionProcessContext.getSuccess()) return stepResult.isCompleted(false);
//离线生产
if (mesOffLineOpen) return stepResult.isCompleted(false);
//当前工位使用的设备
MesCellEquipContext cellEquipContext = productionProcessContext.getCurCellEquip();
if (null == cellEquipContext) return stepResult.isCompleted(false);

@ -67,9 +67,6 @@ public class MesFirstMouldNoReadStepService extends BaseStepService {
@Override
public StepResult init(StationRequestBean reqBean) {
//离线生产
if (mesOffLineOpen) stepExpSendMsgAndThrowEx(reqBean, new StationResultBean().writeDbLog(), "离线生产当前设备不可用!");
//发送工步内容
productionCustomContextStepService.sendStepContextMessage(reqBean);

@ -55,9 +55,6 @@ public class MesMembraneSignalReadStepService extends BaseStepService {
@Override
public StepResult init(StationRequestBean reqBean) {
//离线生产
if (mesOffLineOpen) stepExpSendMsgAndThrowEx(reqBean, new StationResultBean().writeDbLog(), "离线生产当前设备不可用!");
//发送工步内容
productionCustomContextStepService.sendStepContextMessage(reqBean);

@ -69,9 +69,6 @@ public class MesMouldNoReadStepService extends BaseStepService {
StepResult stepResult = StepResult.getSuccessComplete();
//离线生产不读模具号
if (mesOffLineOpen) return stepResult;
StationResultBean resultBean = new StationResultBean();
//获取工步参数

@ -71,9 +71,6 @@ public class MesProductResultReadStepService extends BaseStepService {
StepResult stepResult = StepResult.getSuccessComplete();
//离线生产不读加工结果
if (mesOffLineOpen) return stepResult;
StationResultBean resultBean = new StationResultBean();
//获取工步参数

@ -65,9 +65,6 @@ public class MesProductSnReadStepService extends BaseStepService {
@Override
public StepResult init(StationRequestBean reqBean) {
//离线生产
if (mesOffLineOpen) stepExpSendMsgAndThrowEx(reqBean, new StationResultBean().writeDbLog(), "离线生产当前设备不可用!");
StepResult stepResult = StepResult.getSuccessComplete();
String endlessLoopReadTimes = fsmCommonService.handleFsmWcpcMapDataForDoScan(reqBean).get(MesPcnExtConstWords.ENDLESS_LOOP_READ_TIMES);

@ -55,9 +55,6 @@ public class MesReadySignalReadStepService extends BaseStepService {
@Override
public StepResult init(StationRequestBean reqBean) {
//离线生产
if (mesOffLineOpen) stepExpSendMsgAndThrowEx(reqBean, new StationResultBean().writeDbLog(), "离线生产当前设备不可用!");
//发送工步内容
productionCustomContextStepService.sendStepContextMessage(reqBean);

@ -66,9 +66,6 @@ public class MesRecyclablePackageReadStepService extends BaseStepService {
@Override
public StepResult init(StationRequestBean reqBean) {
//离线生产
if (mesOffLineOpen) stepExpSendMsgAndThrowEx(reqBean, new StationResultBean().writeDbLog(), "离线生产当前设备不可用!");
StepResult stepResult = StepResult.getSuccessComplete();
String endlessLoopReadTimes = fsmCommonService.handleFsmWcpcMapDataForDoScan(reqBean).get(MesPcnExtConstWords.ENDLESS_LOOP_READ_TIMES);

@ -62,9 +62,6 @@ public class MesSendEquipParamsCmdStepService extends BaseStepService {
StepResult stepResult = StepResult.getSuccessComplete();
//离线生产不发送设备加工参数
if (mesOffLineOpen) return stepResult;
StationResultBean resultBean = new StationResultBean();
//获取上下文加工规则数据信息集合

@ -62,9 +62,6 @@ public class MesSendEquipParamsCmdStepService2 extends BaseStepService {
StepResult stepResult = StepResult.getSuccessComplete();
//离线生产不发送设备加工参数
if (mesOffLineOpen) return stepResult;
StationResultBean resultBean = new StationResultBean();
//获取上下文加工规则数据信息集合

@ -49,9 +49,6 @@ public class MesSendInitializationCmdStepService extends BaseStepService {
StepResult stepResult = StepResult.getSuccessComplete();
//离线生产不发送初始化指令
if (mesOffLineOpen) return stepResult;
StationResultBean resultBean = new StationResultBean();
//获取工步参数

@ -49,9 +49,6 @@ public class MesSendProcessCmdStepService extends BaseStepService {
StepResult stepResult = StepResult.getSuccessComplete();
//离线生产不发送允许加工指令
if (mesOffLineOpen) return stepResult;
StationResultBean resultBean = new StationResultBean();
//获取工步参数

@ -59,9 +59,6 @@ public class MesVariableWhenFinishedReadStepService extends BaseStepService {
StepResult stepResult = StepResult.getSuccessComplete();
//离线生产不保存工艺参数
if (mesOffLineOpen) return stepResult;
StationResultBean resultBean = new StationResultBean();
// 获取上下文信息

@ -207,11 +207,11 @@ public class MesWorkOrderCheckSortStepService extends MesWorkOrderCheckStepServi
return stepResult.isCompleted(false).msg(String.format("请检查工单工位队列信息,加工单[%s]工位队列状态[%s]", workOrderNo, MesExtEnumUtil.QUEUE_ORDER_STATUS.valueOfDescription(queueOrder.getStatus())));
//封装产成零件
MesProductionPartContext productionPartContext = new MesProductionPartContext().copyPartNo(workOrder, equipVariableCollectContextList.get(0).getMessageSource()).isClosedCheck(mesOffLineOpen).isCheck(productionProcessContext.getWorkCell());
MesProductionPartContext productionPartContext = new MesProductionPartContext().copyPartNo(workOrder, equipVariableCollectContextList.get(0).getMessageSource()).isCheck(productionProcessContext.getWorkCell());
productionPartContextList.add(productionPartContext);
//封装产品条码
productionPsInContextList.add(new MesProductionPsInContext(produceSn).isClosedCheck(mesOffLineOpen).isCheck(productionProcessContext.getWorkCell()).messageSource(equipVariableCollectContextList.get(0).getMessageSource()).relateId(queueOrder.getId()));
productionPsInContextList.add(new MesProductionPsInContext(produceSn).isCheck(productionProcessContext.getWorkCell()).messageSource(equipVariableCollectContextList.get(0).getMessageSource()).relateId(queueOrder.getId()));
//封装产出条码
productionPsOutContextList.add(new MesProductionPsOutContext().copy(produceSn));

@ -62,9 +62,6 @@ public class MesWorkOrderReadStepService extends BaseStepService {
@Override
public StepResult init(StationRequestBean reqBean) {
//离线生产
if (mesOffLineOpen) stepExpSendMsgAndThrowEx(reqBean, new StationResultBean().writeDbLog(), "离线生产当前设备不可用!");
StepResult stepResult = StepResult.getSuccessComplete();
String endlessLoopReadTimes = fsmCommonService.handleFsmWcpcMapDataForDoScan(reqBean).get(MesPcnExtConstWords.ENDLESS_LOOP_READ_TIMES);

@ -10,7 +10,6 @@ import cn.estsh.i3plus.mes.pcn.api.iservice.base.IConfigService;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker;
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
import cn.estsh.i3plus.pojo.mes.bean.*;
import cn.estsh.i3plus.pojo.mes.model.StationKvBean;
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
@ -168,12 +167,6 @@ public class MesProductionProcessContextStepService extends BaseStepService impl
if (isCheckProcess && StringUtils.isEmpty(productionProcessContext.getProcessCode())) return productionProcessContext.message(String.format("请检查工序信息,生产线[%s]工位[%s]对应工序代码[%s]的有效性!", reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), reqBean.getProcessCode()));
if (mesOffLineOpen) {
//离线生产发送设备质量信息[BAD=Red]
this.sendMessage(reqBean, new StationResultBean().busiType(MesPcnEnumUtil.STATION_BUSI_TYPE.QUALITY_MODULE.getValue()).dataType(MesPcnEnumUtil.STATION_DATA_TYPE.COLOR.getValue()).resultObj(MesExtEnumUtil.COLOR.RED.getValue()));
if (productionProcessContext.getWorkCenter().getCenterType().compareTo(MesExtEnumUtil.WORK_CENTER_TYPE.NOSORT.getValue()) == 0) return productionProcessContext.message("离线生产仅支持排序生产线!");
}
return productionProcessContext;
}

@ -36,10 +36,8 @@ public class MesProductionProcessMonitorService extends BaseProcessMonitorServic
@Override
public Boolean doProcessComplete(StationRequestBean requestBean) {
//补DB日志 [获取开模ID赋值scanInfo] [获取上下文产出条码数据信息集合赋值resultList]
if (!mesOffLineOpen) {
writeDbLogService.doRestoreDbLog(requestBean, new StationResultBean()
.restoreDbLog().scanInfo(productionProcessContextStepService.getScanMonitorContextMouldRecordId(requestBean)).resultList(productionDispatchContextStepService.getProductionPsOutContext(requestBean)));
}
writeDbLogService.doRestoreDbLog(requestBean, new StationResultBean()
.restoreDbLog().scanInfo(productionProcessContextStepService.getScanMonitorContextMouldRecordId(requestBean)).resultList(productionDispatchContextStepService.getProductionPsOutContext(requestBean)));
//清除上下文中的所有业务数据
productionDispatchContextStepService.flushProductionDispatchContext(requestBean);
//父类发送工序完成音

@ -154,7 +154,6 @@ public class MesAssemblySaveSortStepService extends BaseStepService {
private void saveProductionAssemblyUnique(StationRequestBean reqBean, MesProductionAssemblySortContext productionAssemblySortContext) {
if (!MesExtEnumUtil.ASSEMBLY_MATCH_TYPE.checkUniqueRuleInDb(productionAssemblySortContext.getMatchType()) || StringUtils.isEmpty(productionAssemblySortContext.getAssemblySn())) return;
if (productionAssemblySortContext.getIsClosedCheck()) return;//离线生产不写[装配件规则唯一绑定记录表]
MesProductionAssemblyUnique productionAssemblyUnique = new MesProductionAssemblyUnique();
BeanUtils.copyProperties(productionAssemblySortContext, productionAssemblyUnique, MesPcnExtConstWords.ID);
productionAssemblyUnique.setPid(productionAssemblySortContext.getId());

@ -1,35 +0,0 @@
##\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 ;

@ -1,81 +0,0 @@
##\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 ;

@ -60,10 +60,6 @@ public class MesProdRuleContext implements Serializable {
@ApiParam(name = "是否验证装配件扫描顺序")
private Integer isCheckBindSeq;
//默认开启防错, true代表关闭防错
@ApiParam(name = "是否关闭防错")
private Boolean isClosedCheck = false;
//-------以下非排序属性-------------
@ApiParam("非排序产品加工规则ID")
@ -134,12 +130,6 @@ public class MesProdRuleContext implements Serializable {
return this;
}
//赋值系统配置【离线开关】
public MesProdRuleContext isClosedCheck(Boolean isClosedCheck) {
this.isClosedCheck = isClosedCheck;
return this;
}
//非排序无须使用工位的字段,直接使用非排序产品加工规则的字段;
//排序使用工位的字段, 如果是显示前道所有装配件场景下在装配件清单中单独标记各个工位的装配件是否需要顺序扫描
public MesProdRuleContext isCheckBindSeq(Integer isSeqScan) {

@ -124,10 +124,6 @@ public class MesProductionAssemblyContext implements Serializable {
@ApiParam("匹配时间")
public String matchDatetime;
//默认开启防错, true代表关闭防错
@ApiParam(name = "是否关闭防错")
public Boolean isClosedCheck = false;
public String repeatKeyToString() {
if (StringUtils.isEmpty(this.equipmentCode) || StringUtils.isEmpty(this.matchType) || (StringUtils.isEmpty(this.matchRule) && StringUtils.isEmpty(this.assemblyPartNo))) return null;
return String.format("%s:%s&%s:%s&%s:%s&%s:%s",

@ -247,10 +247,4 @@ public class MesProductionAssemblySortContext extends MesProductionAssemblyConte
private void matchDatetime() { this.matchDatetime = (new SimpleDateFormat(MesPcnExtConstWords.DATE_FORMAT_SSS)).format(new Date()); }
//赋值系统配置【离线开关】
public MesProductionAssemblySortContext isClosedCheck(Boolean isClosedCheck) {
this.isClosedCheck = isClosedCheck;
return this;
}
}

@ -106,10 +106,6 @@ public class MesProductionPartContext implements Serializable {
@ApiParam("工艺强过码")
private String craftJumpCode;
//默认开启防错, true代表关闭防错
@ApiParam(name = "是否关闭防错")
private Boolean isClosedCheck = false;
//默认否
@ApiParam("是否顺序防错")
private Integer isCheckSeq = CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue();
@ -188,14 +184,7 @@ public class MesProductionPartContext implements Serializable {
return this;
}
//赋值系统配置【离线开关】
public MesProductionPartContext isClosedCheck(Boolean isClosedCheck) {
this.isClosedCheck = isClosedCheck;
return this;
}
public MesProductionPartContext isCheck(MesWorkCell workCell) {
if (isClosedCheck) return this;
if(!StringUtils.isEmpty(workCell.getIsCheckSeq()) && workCell.getIsCheckSeq().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) == 0) this.isCheckSeq = workCell.getIsCheckSeq();
return this;
}

@ -80,10 +80,6 @@ public class MesProductionPsInContext implements Serializable {
@ApiParam("是否空腔")
private Integer isFinishCode = CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue();
//默认开启防错, true代表关闭防错
@ApiParam(name = "是否关闭防错")
private Boolean isClosedCheck = false;
//默认否
@ApiParam(name = "是否前道工艺防错")
private Integer isCheckCraft = CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue();
@ -115,14 +111,7 @@ public class MesProductionPsInContext implements Serializable {
return this;
}
//赋值系统配置【离线开关】
public MesProductionPsInContext isClosedCheck(Boolean isClosedCheck) {
this.isClosedCheck = isClosedCheck;
return this;
}
public MesProductionPsInContext isCheck(MesWorkCell workCell) {
if (isClosedCheck) return this;
if(!StringUtils.isEmpty(workCell.getIsCheckCraft()) && workCell.getIsCheckCraft().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) == 0) this.isCheckCraft = workCell.getIsCheckCraft();
return this;
}

Loading…
Cancel
Save