|
|
|
@ -21,9 +21,8 @@ import org.springframework.util.CollectionUtils;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Description : MES可疑品汇总
|
|
|
|
@ -83,25 +82,31 @@ public class MesQmsSuspiciousJob extends BaseMesScheduleJob {
|
|
|
|
|
String formattedNow = now.format(formatter);
|
|
|
|
|
String formattedOneHourAgo = oneHourAgo.format(formatter);
|
|
|
|
|
|
|
|
|
|
DdlPreparedPack.timeBuilder(formattedOneHourAgo ,formattedNow, "createDatetime", packBean, true);
|
|
|
|
|
DdlPreparedPack.timeBuilder(formattedOneHourAgo, formattedNow, "createDatetime", packBean, true);
|
|
|
|
|
|
|
|
|
|
List<MesPartInspection> mesPartInspectionList = partInspectionRepository.findByHqlWhere(packBean);
|
|
|
|
|
if (!CollectionUtils.isEmpty(mesPartInspectionList)) {
|
|
|
|
|
//过滤掉已经汇总的
|
|
|
|
|
List<MesPartInspection> partInspectionList = new ArrayList<>();
|
|
|
|
|
for (MesPartInspection mesPartInspection : mesPartInspectionList) {
|
|
|
|
|
//排序取未同步的一条最早的
|
|
|
|
|
Map<String, List<MesPartInspection>> partMap = mesPartInspectionList.stream().collect(Collectors.groupingBy(p -> p.getSn() + "-" + p.getPartNo()));
|
|
|
|
|
for (Map.Entry<String, List<MesPartInspection>> stringListEntry : partMap.entrySet()) {
|
|
|
|
|
List<MesPartInspection> value = stringListEntry.getValue();
|
|
|
|
|
MesPartInspection next = value.stream().sorted(Comparator.comparing(MesPartInspection::getCreateDatetime)).iterator().next();
|
|
|
|
|
DdlPackBean packBeanNew = DdlPackBean.getDdlPackBean(organizeCode);
|
|
|
|
|
DdlPreparedPack.getStringLikerPack(mesPartInspection.getPartNo(), "partNo", packBeanNew);
|
|
|
|
|
DdlPreparedPack.getStringLikerPack(mesPartInspection.getSn(), "sn", packBeanNew);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(next.getPartNo(), "partNo", packBeanNew);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(next.getSn(), "sn", packBeanNew);
|
|
|
|
|
DdlPreparedPack.getNumEqualPack(1, "qmsSync", packBeanNew);
|
|
|
|
|
boolean flg = partInspectionRepository.isExitByHql(packBeanNew);
|
|
|
|
|
if (!flg) {
|
|
|
|
|
partInspectionList.add(mesPartInspection);
|
|
|
|
|
partInspectionList.add(next);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
qmsSuspiciousService.doQmsSuspiciousByPartInspection(partInspectionList,organizeCode);
|
|
|
|
|
|
|
|
|
|
qmsSuspiciousService.doQmsSuspiciousByPartInspection(partInspectionList, organizeCode);
|
|
|
|
|
|
|
|
|
|
for (MesPartInspection mesPartInspection : mesPartInspectionList) {
|
|
|
|
|
mesPartInspection.setSystemSyncStatus(1);
|
|
|
|
|
mesPartInspection.setQmsSync(1);
|
|
|
|
|
mesPartInspection.setSystemSyncDatetime(TimeTool.getNowTime(true));
|
|
|
|
|
}
|
|
|
|
|
partInspectionRepository.saveAll(mesPartInspectionList);
|
|
|
|
|