|
|
|
@ -18,7 +18,10 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
@ -69,19 +72,61 @@ public class MesQmsSuspiciousService extends BaseMesService<MesQmsSuspicious> im
|
|
|
|
|
for (MesPartInspection partInspection : mesPartInspectionsList) {
|
|
|
|
|
MesPartInspection partInspectionNew = new MesPartInspection();
|
|
|
|
|
BeanUtils.copyProperties(partInspection, partInspectionNew);
|
|
|
|
|
//去创建日期换算整点2024-07-25 10:00:00
|
|
|
|
|
DdlPackBean packBeanNew = DdlPackBean.getDdlPackBean(organizeCode);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(partInspection.getPartNo(), "partNo", packBeanNew);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(partInspection.getSn(), "sn", packBeanNew);
|
|
|
|
|
packBeanNew.setOrderByStr(" order by createDatetime ");
|
|
|
|
|
MesPartInspection partInspectionDao = partInspectionRepository.getByProperty(packBeanNew);
|
|
|
|
|
//检验日期年月日可以根据创建日期截取,批次的不用取最早出现的
|
|
|
|
|
String qmsTime = partInspection.getCreateDatetime().substring(0, 13) + ":00:00";
|
|
|
|
|
if (!StringUtil.isEmpty(partInspectionDao) && partInspection.getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()) {
|
|
|
|
|
qmsTime = partInspectionDao.getCreateDatetime().substring(0, 13) + ":00:00";
|
|
|
|
|
if (partInspection.getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.LOT.getValue()) {
|
|
|
|
|
partInspectionNew.setInspectionDate(qmsTime);
|
|
|
|
|
mesPartInspectionsListTime.add(partInspectionNew);
|
|
|
|
|
} else {
|
|
|
|
|
//检验日期年月日可以根据创建日期截取,批次的不用取最早出现的
|
|
|
|
|
//去创建日期换算整点2024-07-25 10:00:00
|
|
|
|
|
DdlPackBean packBeanNew = DdlPackBean.getDdlPackBean(organizeCode);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(partInspection.getSn(), "sn", packBeanNew);
|
|
|
|
|
packBeanNew.setOrderByStr(" order by createDatetime ");
|
|
|
|
|
MesPartInspection partInspectionDao = partInspectionRepository.getByProperty(packBeanNew);
|
|
|
|
|
//如果是最新的
|
|
|
|
|
if (!StringUtil.isEmpty(partInspectionDao) && partInspectionDao.getCreateDatetime().substring(0, 13).equals(partInspection.getCreateDatetime().substring(0, 13))) {
|
|
|
|
|
qmsTime = partInspectionDao.getCreateDatetime().substring(0, 13) + ":00:00";
|
|
|
|
|
partInspectionNew.setInspectionDate(qmsTime);
|
|
|
|
|
mesPartInspectionsListTime.add(partInspectionNew);
|
|
|
|
|
} else {
|
|
|
|
|
qmsTime = partInspectionDao.getCreateDatetime().substring(0, 13) + ":00:00";
|
|
|
|
|
partInspectionNew.setInspectionDate(qmsTime);
|
|
|
|
|
mesPartInspectionsListTime.add(partInspectionNew);
|
|
|
|
|
//如果第二次出现 找条码最早时间区间内 的非该条码 的 物料 集合
|
|
|
|
|
//获取最早条码创建时间 后一小时的时间
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
LocalDateTime nextHourDateTime = LocalDateTime.parse(partInspectionDao.getCreateDatetime(), formatter).plusHours(1);
|
|
|
|
|
String afterQmsTime = nextHourDateTime.format(formatter);
|
|
|
|
|
DdlPackBean packBeanPart = DdlPackBean.getDdlPackBean(organizeCode);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(partInspectionDao.getPartNo(), "partNo", packBeanPart);
|
|
|
|
|
DdlPreparedPack.getNotInPack(partInspectionDao.getSn(), "sn", packBeanPart);
|
|
|
|
|
DdlPreparedPack.timeBuilder(partInspectionDao.getCreateDatetime(), afterQmsTime, "createDatetime", packBeanPart, true);
|
|
|
|
|
List<MesPartInspection> mesPartInspections = partInspectionRepository.findByHqlWhere(packBeanPart);
|
|
|
|
|
if (!CollectionUtils.isEmpty(mesPartInspections)) {
|
|
|
|
|
//排除其他非最早出现的条码
|
|
|
|
|
for (MesPartInspection mesPartInspection : mesPartInspections) {
|
|
|
|
|
MesPartInspection partInspectionNew2 = new MesPartInspection();
|
|
|
|
|
BeanUtils.copyProperties(mesPartInspection, partInspectionNew2);
|
|
|
|
|
qmsTime = mesPartInspection.getCreateDatetime().substring(0, 13) + ":00:00";
|
|
|
|
|
partInspectionNew2.setInspectionDate(qmsTime);
|
|
|
|
|
if (mesPartInspection.getSourceType()==10){
|
|
|
|
|
//如果条码重复出现时,对应最早时间段的零件不是最早,则不统计在汇总数据中
|
|
|
|
|
DdlPackBean packBeanSn = DdlPackBean.getDdlPackBean(organizeCode);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(mesPartInspection.getSn(), "sn", packBeanSn);
|
|
|
|
|
packBeanSn.setOrderByStr(" order by createDatetime ");
|
|
|
|
|
MesPartInspection partInspectionSn = partInspectionRepository.getByProperty(packBeanSn);
|
|
|
|
|
if (!StringUtil.isEmpty(partInspectionSn)&& partInspectionSn.getCreateDatetime().substring(0, 13).equals(mesPartInspection.getCreateDatetime().substring(0, 13))){
|
|
|
|
|
mesPartInspectionsListTime.add(partInspectionNew2);
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
mesPartInspectionsListTime.add(partInspectionNew2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
partInspectionNew.setInspectionDate(qmsTime);
|
|
|
|
|
mesPartInspectionsListTime.add(partInspectionNew);
|
|
|
|
|
}
|
|
|
|
|
//根据时间分组发送
|
|
|
|
|
// 批次的:
|
|
|
|
|