Merge remote-tracking branch 'origin/dev' into dev

tags/yfai-mes-ext-v1.7
jun 8 months ago
commit 3c22ae0461

@ -6,13 +6,16 @@ import cn.estsh.i3plus.ext.mes.pojo.model.MaximoParamModel;
import cn.estsh.i3plus.ext.mes.pojo.util.MesExtConstWords; import cn.estsh.i3plus.ext.mes.pojo.util.MesExtConstWords;
import cn.estsh.i3plus.platform.common.convert.ConvertBean; import cn.estsh.i3plus.platform.common.convert.ConvertBean;
import cn.estsh.i3plus.platform.common.tool.TimeTool; import cn.estsh.i3plus.platform.common.tool.TimeTool;
import cn.estsh.i3plus.platform.common.util.MesConstWords;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean; import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil; import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack; import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.mes.bean.MesEquipment;
import cn.estsh.i3plus.pojo.mes.bean.MesProductionRecord; import cn.estsh.i3plus.pojo.mes.bean.MesProductionRecord;
import cn.estsh.i3plus.pojo.mes.bean.MesShift; import cn.estsh.i3plus.pojo.mes.bean.MesShift;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkOrder; import cn.estsh.i3plus.pojo.mes.bean.MesWorkOrder;
import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspection; import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspection;
import cn.estsh.i3plus.pojo.mes.repository.MesEquipmentRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesPartInspectionRepository; import cn.estsh.i3plus.pojo.mes.repository.MesPartInspectionRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesProductionRecordRepository; import cn.estsh.i3plus.pojo.mes.repository.MesProductionRecordRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesShiftRepository; import cn.estsh.i3plus.pojo.mes.repository.MesShiftRepository;
@ -69,6 +72,11 @@ public class MesWhiteListController extends MesBaseController {
@Autowired @Autowired
private IMesCrossOrganizeCfgService mesCrossOrganizeCfgService; private IMesCrossOrganizeCfgService mesCrossOrganizeCfgService;
@Autowired
private MesEquipmentRepository mesEquipmentRDao;
@Autowired
private IMesDowntimeRecordService downtimeRecordService;
@PostMapping(value = "/meter/main-data") @PostMapping(value = "/meter/main-data")
@ApiOperation(value = "Maximo仪表主数据", notes = "Maximo仪表主数据") @ApiOperation(value = "Maximo仪表主数据", notes = "Maximo仪表主数据")
public Map doMeterMainData(@RequestBody MaximoParamModel paramModel) { public Map doMeterMainData(@RequestBody MaximoParamModel paramModel) {
@ -250,4 +258,23 @@ public class MesWhiteListController extends MesBaseController {
} }
return ResultBean.success().setSuccess(true); return ResultBean.success().setSuccess(true);
} }
@GetMapping(value = "/doMesDowntimeRecord")
@ApiOperation(value = "设备停机记录")
public ResultBean doMesDowntimeRecordJob(String organizeCode, String equ) {
//统计数据
try {
List<MesEquipment> mesEquipmentList = mesEquipmentRDao.findByProperty(
new String[]{MesConstWords.ORGANIZE_CODE,"equipmentCode", MesConstWords.IS_DELETED, MesConstWords.IS_VALID},
new Object[]{organizeCode, equ,CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(),
CommonEnumUtil.IS_VAILD.VAILD.getValue()});
if (!CollectionUtils.isEmpty(mesEquipmentList)){
downtimeRecordService.doMesDowntimeRecordJob(organizeCode,mesEquipmentList);
}
} catch (ImppBusiException imppException) {
return ResultBean.fail(imppException);
} catch (Exception e) {
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
return ResultBean.success("执行成功");
}
} }

@ -70,8 +70,9 @@ public class MesDowntimeRecordJob extends BaseMesScheduleJob {
for (String organizeCode : organizeCodeList) { for (String organizeCode : organizeCodeList) {
List<MesEquipment> mesEquipmentList = mesEquipmentRDao.findByProperty( List<MesEquipment> mesEquipmentList = mesEquipmentRDao.findByProperty(
new String[]{MesConstWords.ORGANIZE_CODE, MesConstWords.IS_DELETED, MesConstWords.IS_VALID}, new String[]{MesConstWords.ORGANIZE_CODE,"monitorDown", MesConstWords.IS_DELETED, MesConstWords.IS_VALID},
new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), new Object[]{organizeCode,CommonEnumUtil.IS_VAILD.VAILD.getValue(),
CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(),
CommonEnumUtil.IS_VAILD.VAILD.getValue()}); CommonEnumUtil.IS_VAILD.VAILD.getValue()});
if (!CollectionUtils.isEmpty(mesEquipmentList)){ if (!CollectionUtils.isEmpty(mesEquipmentList)){
downtimeRecordService.doMesDowntimeRecordJob(organizeCode,mesEquipmentList); downtimeRecordService.doMesDowntimeRecordJob(organizeCode,mesEquipmentList);

@ -1,26 +1,32 @@
package cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.base; package cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.base;
import cn.estsh.i3plus.ext.mes.api.base.IMesConfigService;
import cn.estsh.i3plus.ext.mes.api.base.IMesDowntimeRecordService; import cn.estsh.i3plus.ext.mes.api.base.IMesDowntimeRecordService;
import cn.estsh.i3plus.ext.mes.pojo.util.MesExtConstWords;
import cn.estsh.i3plus.platform.common.convert.ConvertBean; import cn.estsh.i3plus.platform.common.convert.ConvertBean;
import cn.estsh.i3plus.platform.common.exception.ImppExceptionEnum; import cn.estsh.i3plus.platform.common.exception.ImppExceptionEnum;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
import cn.estsh.i3plus.platform.common.util.MesConstWords;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean; import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil; import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack; import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.mes.bean.MesDowntimeRecord; import cn.estsh.i3plus.pojo.base.util.StringUtil;
import cn.estsh.i3plus.pojo.mes.bean.MesEquipment; import cn.estsh.i3plus.pojo.mes.bean.*;
import cn.estsh.i3plus.pojo.mes.bean.MesProductionRecord;
import cn.estsh.i3plus.pojo.mes.repository.MesDowntimeRecordRepository; import cn.estsh.i3plus.pojo.mes.repository.MesDowntimeRecordRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesProductionRecordRepository; import cn.estsh.i3plus.pojo.mes.repository.MesProductionRecordRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesWcEquipmentRepository;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder; import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
import cn.estsh.impp.framework.boot.util.ValidatorBean; import cn.estsh.impp.framework.boot.util.ValidatorBean;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Objects;
/** /**
@ -39,6 +45,11 @@ public class MesDowntimeRecordServiceImpl extends BaseMesService<MesDowntimeReco
@Autowired @Autowired
private MesDowntimeRecordRepository mesDowntimeRecordRDao; private MesDowntimeRecordRepository mesDowntimeRecordRDao;
@Autowired
private IMesConfigService mesConfigService;
@Autowired
private MesWcEquipmentRepository wcEquipmentRepository;
@Override @Override
protected void setPackQueryBean(MesDowntimeRecord bean, DdlPackBean packBean) { protected void setPackQueryBean(MesDowntimeRecord bean, DdlPackBean packBean) {
DdlPreparedPack.getStringEqualPack(bean.getWorkCenterCode(), "workCenterCode", packBean); DdlPreparedPack.getStringEqualPack(bean.getWorkCenterCode(), "workCenterCode", packBean);
@ -74,28 +85,71 @@ public class MesDowntimeRecordServiceImpl extends BaseMesService<MesDowntimeReco
@Override @Override
public void doMesDowntimeRecordJob(String organizeCode, List<MesEquipment> mesEquipmentList) { public void doMesDowntimeRecordJob(String organizeCode, List<MesEquipment> mesEquipmentList) {
MesConfig reasonCfg = mesConfigService.getCfgValueByCode(organizeCode, MesExtConstWords.MES_DOWNTIME_RECORD_JOB_REASON);
String reason = "";
if (!Objects.isNull(reasonCfg) && !StringUtils.isEmpty(reasonCfg.getCfgValue())) {
reason = reasonCfg.getCfgValue();
}
MesConfig typeCfg = mesConfigService.getCfgValueByCode(organizeCode, MesExtConstWords.MES_DOWNTIME_RECORD_JOB_TYPE);
String type = "";
if (!Objects.isNull(typeCfg) && !StringUtils.isEmpty(typeCfg.getCfgValue())) {
type = typeCfg.getCfgValue();
}
for (MesEquipment mesEquipment : mesEquipmentList) { for (MesEquipment mesEquipment : mesEquipmentList) {
Integer monitorDownTime = Integer.parseInt(mesEquipment.getMonitorDownTime());//todo //字段是否为“是” 且监控停机时间不等于空和0 才继续
if (mesEquipment.getMonitorDown() != 1 || StringUtil.isEmpty(mesEquipment.getMonitorDownTime()) || Integer.parseInt(mesEquipment.getMonitorDownTime()) == 0) {
continue;
}
Integer monitorDownTime = Integer.parseInt(mesEquipment.getMonitorDownTime());
String previousDay = getPreviousDay(new Date(), monitorDownTime); String previousDay = getPreviousDay(new Date(), monitorDownTime);
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(organizeCode); DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(mesEquipment.getEquipmentCode(), "equipmentCode", ddlPackBean); DdlPreparedPack.getStringEqualPack(mesEquipment.getEquipmentCode(), "equipmentCode", ddlPackBean);
DdlPreparedPack.getNumberBiggerEqualPack(previousDay, "createDatetime", ddlPackBean); DdlPreparedPack.getStringBiggerPack(previousDay, "completeDateTime", ddlPackBean);//todo
// DdlPreparedPack.getNumberSmallerEqualPack(mesEquipment.getCreateDateTimeEnd(), "createDatetime", ddlPackBean); // DdlPreparedPack.getNumberSmallerEqualPack(mesEquipment.getCreateDateTimeEnd(), "createDatetime", ddlPackBean);
int byHqlWhereCount = mesProductionRecordRDao.findByHqlWhereCount(ddlPackBean); MesProductionRecord mesProductionRecord = mesProductionRecordRDao.getByProperty(ddlPackBean);
if (byHqlWhereCount < 1) { if (StringUtil.isEmpty(mesProductionRecord)) {
//新增设备停机记录 DdlPackBean ddlPackBeanDowntime = DdlPackBean.getDdlPackBean(organizeCode);
MesDowntimeRecord mesDowntimeRecord=new MesDowntimeRecord(); DdlPreparedPack.getStringEqualPack(mesEquipment.getEquipmentCode(), "equipmentCode", ddlPackBeanDowntime);
mesDowntimeRecord.setOrganizeCode(organizeCode); if(!StringUtil.isEmpty(reason)){
mesDowntimeRecord.setEquipId(mesEquipment.getEquipId()); DdlPreparedPack.getStringEqualPack(reason, "reasonCode", ddlPackBeanDowntime);
mesDowntimeRecord.setEquipmentCode(mesEquipment.getEquipmentCode()); }
mesDowntimeRecord.setAreaCode(mesEquipment.getAreaCode()); if(!StringUtil.isEmpty(type)){
mesDowntimeRecord.setWorkCenterCode(mesEquipment.getWorkCenterCode()); DdlPreparedPack.getStringEqualPack(type, "reasonTypeCode", ddlPackBeanDowntime);
mesDowntimeRecord.setWorkCellCode(mesEquipment.getWorkCellCode()); }
mesDowntimeRecord.setReasonCode("未选择停机原因"); MesDowntimeRecord mesDowntimeRecordDao = mesDowntimeRecordRDao.getByProperty(ddlPackBeanDowntime);
mesDowntimeRecord.setReasonTypeCode("未选择停机类型原因");//todo if (StringUtil.isEmpty(mesDowntimeRecordDao)) {
ConvertBean.serviceModelInitialize(mesDowntimeRecord, "MesDowntimeRecordJob"); MesWcEquipment wcEquipmentDbList = wcEquipmentRepository.getByProperty(
new String[]{MesConstWords.ORGANIZE_CODE, MesConstWords.IS_DELETED, MesConstWords.IS_VALID,""},
new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(),
mesEquipment.getEquipmentCode()});
//新增设备停机记录
MesDowntimeRecord mesDowntimeRecord = new MesDowntimeRecord();
mesDowntimeRecord.setOrganizeCode(organizeCode);
mesDowntimeRecord.setEquipId(mesEquipment.getEquipId());
mesDowntimeRecord.setEquipmentCode(mesEquipment.getEquipmentCode());
mesDowntimeRecord.setAreaCode(StringUtil.isEmpty(wcEquipmentDbList)?"":wcEquipmentDbList.getAreaCode());
mesDowntimeRecord.setWorkCenterCode(StringUtil.isEmpty(wcEquipmentDbList)?"":wcEquipmentDbList.getWorkCenterCode());
mesDowntimeRecord.setWorkCellCode(StringUtil.isEmpty(wcEquipmentDbList)?"":wcEquipmentDbList.getWorkCellCode());
mesDowntimeRecord.setReasonCode(StringUtil.isEmpty(reason)?"21":reason);
mesDowntimeRecord.setReasonTypeCode(StringUtil.isEmpty(type)?"6":type);
ConvertBean.serviceModelInitialize(mesDowntimeRecord, "MesDowntimeRecordJob");
//将当前新增数据的create_date_time时间些到上一条记录的modify_date_time字段
DdlPackBean ddlPackBeanOt = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(mesEquipment.getEquipmentCode(), "equipmentCode", ddlPackBeanOt);
ddlPackBeanOt.setWhereAppend(ddlPackBeanOt.getWhereAppend() + " order by createDatetime desc ");
MesDowntimeRecord mesDowntimeRecordOt = mesDowntimeRecordRDao.getByProperty(ddlPackBeanOt);
if (!StringUtil.isEmpty(mesDowntimeRecordOt)){
mesDowntimeRecordOt.setModifyDatetime(mesDowntimeRecord.getCreateDatetime());
mesDowntimeRecordOt.setModifyUser("MesDowntimeRecordJob");
mesDowntimeRecordRDao.update(mesDowntimeRecordOt);
}
mesDowntimeRecordRDao.insert(mesDowntimeRecord);
mesDowntimeRecordRDao.insert(mesDowntimeRecord); }else {
ConvertBean.serviceModelUpdate(mesDowntimeRecordDao, "MesDowntimeRecordJob");
mesDowntimeRecordRDao.update(mesDowntimeRecordDao);
}
} }
} }

@ -55,6 +55,9 @@ public class MesWorkOrderLogService extends BaseMesService<MesWorkOrderLog> impl
" wol.work_order_type as workOrderType," + " wol.work_order_type as workOrderType," +
" wol.work_order_seq as workOrderSeq," + " wol.work_order_seq as workOrderSeq," +
" wol.cust_part_no as custPartNo," + " wol.cust_part_no as custPartNo," +
" wol.part_no as partNo," +
" wol.part_name as partName," +
" wol.type as type," +
" wol.qty as qty,"+ " wol.qty as qty,"+
" wol.area_code as areaCode," + " wol.area_code as areaCode," +
" wol.work_center_code as workCenterCode," + " wol.work_center_code as workCenterCode," +
@ -89,6 +92,11 @@ public class MesWorkOrderLogService extends BaseMesService<MesWorkOrderLog> impl
if (!StringUtil.isEmpty(mesWorkOrderLog.getWorkCenterCode())) { if (!StringUtil.isEmpty(mesWorkOrderLog.getWorkCenterCode())) {
sql += " and wol.work_center_code ='" + mesWorkOrderLog.getWorkCenterCode() + "' "; sql += " and wol.work_center_code ='" + mesWorkOrderLog.getWorkCenterCode() + "' ";
} }
if (!StringUtil.isEmpty(mesWorkOrderLog.getType())) {
sql += " and wol.type ='" + mesWorkOrderLog.getType() + "' ";
}else {
sql += " and wol.type in ('30','40') ";
}
sql += " ORDER BY wol.modify_date_time desc,work_order_no "; sql += " ORDER BY wol.modify_date_time desc,work_order_no ";
Query queryObject = entityManager.createNativeQuery(commHql + sql); Query queryObject = entityManager.createNativeQuery(commHql + sql);

@ -212,7 +212,7 @@ spring.shardingsphere.datasource.names=master,slave
##?? ##??
spring.shardingsphere.datasource.master.type=com.zaxxer.hikari.HikariDataSource spring.shardingsphere.datasource.master.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.master.driver-class-name= com.mysql.jdbc.Driver spring.shardingsphere.datasource.master.driver-class-name= com.mysql.jdbc.Driver
spring.shardingsphere.datasource.master.JdbcUrl=jdbc:mysql://10.195.88.71:3316/impp_i3_mes?autoReconnect=true&useSSL=false&characterEncoding=utf-8 spring.shardingsphere.datasource.master.JdbcUrl=jdbc:mysql://10.195.88.71:3306/impp_i3_mes?autoReconnect=true&useSSL=false&characterEncoding=utf-8
spring.shardingsphere.datasource.master.username=root spring.shardingsphere.datasource.master.username=root
spring.shardingsphere.datasource.master.password=estsh123 spring.shardingsphere.datasource.master.password=estsh123
@ -228,7 +228,7 @@ spring.shardingsphere.datasource.master.keep-alive-time=3500000
##?? ##??
spring.shardingsphere.datasource.slave.type=com.zaxxer.hikari.HikariDataSource spring.shardingsphere.datasource.slave.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.slave.driver-class-name= com.mysql.jdbc.Driver spring.shardingsphere.datasource.slave.driver-class-name= com.mysql.jdbc.Driver
spring.shardingsphere.datasource.slave.JdbcUrl=jdbc:mysql://10.195.88.71:3316/impp_i3_mes?autoReconnect=true&useSSL=false&characterEncoding=utf-8 spring.shardingsphere.datasource.slave.JdbcUrl=jdbc:mysql://10.195.88.71:3306/impp_i3_mes?autoReconnect=true&useSSL=false&characterEncoding=utf-8
spring.shardingsphere.datasource.slave.username=root spring.shardingsphere.datasource.slave.username=root
spring.shardingsphere.datasource.slave.password=estsh123 spring.shardingsphere.datasource.slave.password=estsh123

@ -5,7 +5,7 @@ impp.mes.datasource.isopen=true
#\u6570\u636E\u6E90\u7684\u522B\u540D #\u6570\u636E\u6E90\u7684\u522B\u540D
impp.mes.datasource.alias=mesDataSource impp.mes.datasource.alias=mesDataSource
impp.mes.datasource.driver-class-name=com.mysql.jdbc.Driver impp.mes.datasource.driver-class-name=com.mysql.jdbc.Driver
impp.mes.datasource.jdbc-url=jdbc:mysql://10.195.88.71:3316/impp_i3_mes?autoReconnect=true&useSSL=false&characterEncoding=utf-8&allowPublicKeyRetrieval=true impp.mes.datasource.jdbc-url=jdbc:mysql://10.195.88.71:3306/impp_i3_mes?autoReconnect=true&useSSL=false&characterEncoding=utf-8&allowPublicKeyRetrieval=true
#impp.mes.datasource.jdbc-url=jdbc:sqlserver://139.224.200.147:20037;DatabaseName=impp_i3_mes; #impp.mes.datasource.jdbc-url=jdbc:sqlserver://139.224.200.147:20037;DatabaseName=impp_i3_mes;
impp.mes.datasource.username=root impp.mes.datasource.username=root
#impp.mes.datasource.password=Test123! #impp.mes.datasource.password=Test123!
@ -43,4 +43,12 @@ impp.pisces.datasource.alias=piscesDataSource
impp.pisces.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver impp.pisces.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver
impp.pisces.datasource.jdbc-url=jdbc:sqlserver://172.28.239.113:1433;SelectMethod=cursor;DatabaseName=PiscesTest;applicationIntent=schemaOnly;selectedSchema=MES impp.pisces.datasource.jdbc-url=jdbc:sqlserver://172.28.239.113:1433;SelectMethod=cursor;DatabaseName=PiscesTest;applicationIntent=schemaOnly;selectedSchema=MES
impp.pisces.datasource.username=sa impp.pisces.datasource.username=sa
impp.pisces.datasource.password=sahasnopassword impp.pisces.datasource.password=sahasnopassword
#Pisces中间表数据源
impp.pisces1.datasource.isopen=true
impp.pisces1.datasource.alias=pisces1DataSource
impp.pisces1.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver
impp.pisces1.datasource.jdbc-url=jdbc:sqlserver://172.28.16.73:1433;SelectMethod=cursor;DatabaseName=YFMES_DATACENTER;applicationIntent=schemaOnly;selectedSchema=MES
impp.pisces1.datasource.username=sa
impp.pisces1.datasource.password=sahasnopassword

@ -237,4 +237,9 @@ public class MesExtConstWords {
public static final String CONDITION_U = "CONDITION"; public static final String CONDITION_U = "CONDITION";
public static final String DATA_U = "DATA"; public static final String DATA_U = "DATA";
//JOB停机原因代码
public static final String MES_DOWNTIME_RECORD_JOB_REASON = "MES_DOWNTIME_RECORD_JOB_REASON";
//JOB停机类型代码
public static final String MES_DOWNTIME_RECORD_JOB_TYPE = "MES_DOWNTIME_RECORD_JOB_TYPE";
} }

Loading…
Cancel
Save