|
|
@ -18,6 +18,7 @@ import cn.estsh.i3plus.pojo.mes.repository.*;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.wh.MesCimGmGepicsRepository;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.wh.MesCimGmGepicsRepository;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
|
|
|
|
|
|
|
|
import com.xxl.job.core.util.DateUtil;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@ -61,6 +62,10 @@ public class IMesYfBoardServiceImpl implements IMesYfBoardService {
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private MesCimGmGepicsRepository mesCimGmGepicsRepository;
|
|
|
|
private MesCimGmGepicsRepository mesCimGmGepicsRepository;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private MesDowntimeRecordRepository mesDowntimeRecordRDao;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final String START_TIME = "START_TIME";
|
|
|
|
private static final String START_TIME = "START_TIME";
|
|
|
|
|
|
|
|
|
|
|
|
private static final String END_TIME = "END_TIME";
|
|
|
|
private static final String END_TIME = "END_TIME";
|
|
|
@ -339,9 +344,47 @@ public class IMesYfBoardServiceImpl implements IMesYfBoardService {
|
|
|
|
public MesWorkCenterBoardResultModel queryAbnormalDowntime(MesWorkCenterBoardConditionModel conditionModel) {
|
|
|
|
public MesWorkCenterBoardResultModel queryAbnormalDowntime(MesWorkCenterBoardConditionModel conditionModel) {
|
|
|
|
MesWorkCenterBoardResultModel resultModel = new MesWorkCenterBoardResultModel();
|
|
|
|
MesWorkCenterBoardResultModel resultModel = new MesWorkCenterBoardResultModel();
|
|
|
|
//获取查询时间区间(需求未明确,暂时注释,返回固定值)
|
|
|
|
//获取查询时间区间(需求未明确,暂时注释,返回固定值)
|
|
|
|
// Map<String, Map<String, String>> timeZoneMap = getTimeZoneMap(conditionModel.getWorkCenterCodeList(),
|
|
|
|
Map<String, Map<String, String>> timeZoneMap = getTimeZoneMap(conditionModel.getWorkCenterCodeList(),
|
|
|
|
// conditionModel.getTimeRangeIdentification(), conditionModel.getOrganizeCode());
|
|
|
|
conditionModel.getTimeRangeIdentification(), conditionModel.getOrganizeCode());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!timeZoneMap.isEmpty()){
|
|
|
|
|
|
|
|
Set<String> keySet = timeZoneMap.keySet();
|
|
|
|
|
|
|
|
for (String key : keySet) {
|
|
|
|
|
|
|
|
Map<String, String> map = timeZoneMap.get(key);
|
|
|
|
|
|
|
|
String startTime = map.get("START_TIME");
|
|
|
|
|
|
|
|
String endTime = map.get("END_TIME");
|
|
|
|
|
|
|
|
//根据产线查询停机记录表汇总
|
|
|
|
|
|
|
|
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(conditionModel.getOrganizeCode());
|
|
|
|
|
|
|
|
DdlPreparedPack.getStringBiggerPack(startTime,"createDatetime",ddlPackBean);
|
|
|
|
|
|
|
|
DdlPreparedPack.getStringSmallerPack(endTime,"createDatetime",ddlPackBean);
|
|
|
|
|
|
|
|
DdlPreparedPack.getInPackList(conditionModel.getWorkCenterCodeList(), "workCenterCode", ddlPackBean);
|
|
|
|
|
|
|
|
List<MesDowntimeRecord> recordList = mesDowntimeRecordRDao.findByHqlWhere(ddlPackBean);
|
|
|
|
|
|
|
|
//遍历recordList,汇总停机时间
|
|
|
|
|
|
|
|
long total = 0L;
|
|
|
|
|
|
|
|
for (MesDowntimeRecord record : recordList) {
|
|
|
|
|
|
|
|
// 如果停机结束时间还在,则需要补充动态停机时间,否则需要有停机时间
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(record.getModifyDatetime())) {
|
|
|
|
|
|
|
|
Date startTDateTime = DateUtil.parseDateTime(record.getCreateDatetime());
|
|
|
|
|
|
|
|
Date currentTime = new Date();
|
|
|
|
|
|
|
|
total += (currentTime.getTime() - startTDateTime.getTime())/(1000 * 60);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Date startTDateTime = DateUtil.parseDateTime(record.getCreateDatetime());
|
|
|
|
|
|
|
|
Date endDateTime = DateUtil.parseDateTime(record.getModifyDatetime());
|
|
|
|
|
|
|
|
total += (endDateTime.getTime() - startTDateTime.getTime())/(1000 * 60);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (total > 0){
|
|
|
|
|
|
|
|
//转换成小时分钟
|
|
|
|
|
|
|
|
long minutes = total % 60;
|
|
|
|
|
|
|
|
long hours = total / 60;
|
|
|
|
|
|
|
|
resultModel.setAbnormalDowntime(String.format("%02d",hours)+":"+String.format("%02d",minutes));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}else {
|
|
|
|
resultModel.setAbnormalDowntime("00:00");
|
|
|
|
resultModel.setAbnormalDowntime("00:00");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return resultModel;
|
|
|
|
return resultModel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|