|
|
@@ -1091,7 +1091,7 @@ public class GxtOrderScoreServiceImpl implements IGxtOrderScoreService {
|
|
|
}
|
|
|
}
|
|
|
// 更新月度场站维修项目工单统计
|
|
|
- updateMonthRepairProject(monthScore, order);
|
|
|
+ //updateMonthRepairProject(monthScore, order);
|
|
|
|
|
|
// 更新用户评分统计
|
|
|
updateUserScores(monthScore, order);
|
|
|
@@ -1137,7 +1137,7 @@ public class GxtOrderScoreServiceImpl implements IGxtOrderScoreService {
|
|
|
}
|
|
|
}
|
|
|
// 更新月度场站风机类型工单统计
|
|
|
- updateMonthFanInspection(monthScore, order);
|
|
|
+ //updateMonthFanInspection(monthScore, order);
|
|
|
|
|
|
// 更新用户评分统计
|
|
|
updateUserScores(monthScore, order);
|
|
|
@@ -1156,10 +1156,13 @@ public class GxtOrderScoreServiceImpl implements IGxtOrderScoreService {
|
|
|
*/
|
|
|
private void updateMonthFanInspection(GxtMonthScore monthScore, GxtWorkOrder order) {
|
|
|
try {
|
|
|
- /*if (order.getItemCompletionFactorSum().compareTo(BigDecimal.ONE) < 0) {
|
|
|
- return;
|
|
|
- }*/
|
|
|
- // 创建查询条件,查找与当前工单相关的风机检查类型统计
|
|
|
+ // 拆分逗号分隔的检查类型
|
|
|
+ String[] inspectionTypes = {};
|
|
|
+ if (order.getInspectionType() != null && !order.getInspectionType().isEmpty()) {
|
|
|
+ inspectionTypes = order.getInspectionType().split(",");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 先查询该工单所属月度统计下的风机检查类型统计记录
|
|
|
GxtMonthFanInspection queryFanInspection = new GxtMonthFanInspection();
|
|
|
queryFanInspection.setMonthScoreId(monthScore.getId());
|
|
|
queryFanInspection.setDeptId(order.getPcsStationPid());
|
|
|
@@ -1167,56 +1170,75 @@ public class GxtOrderScoreServiceImpl implements IGxtOrderScoreService {
|
|
|
// 查询所有该月度统计下的风机检查类型统计记录
|
|
|
List<GxtMonthFanInspection> fanInspections = gxtMonthFanInspectionService.selectGxtMonthFanInspectionList(queryFanInspection);
|
|
|
|
|
|
- // 在结果中查找匹配当前工单model和inspectionType的记录
|
|
|
- GxtMonthFanInspection matchedRecord = null;
|
|
|
- for (GxtMonthFanInspection fanInspection : fanInspections) {
|
|
|
- if (order.getModel() != null && order.getModel().equals(fanInspection.getModel())
|
|
|
- && order.getInspectionType() != null && order.getInspectionType().equals(fanInspection.getInspectionTypeId())) {
|
|
|
- matchedRecord = fanInspection;
|
|
|
- break;
|
|
|
+ // 对每个检查类型进行处理
|
|
|
+ for (String inspectionType : inspectionTypes) {
|
|
|
+ if (inspectionType == null || inspectionType.trim().isEmpty()) {
|
|
|
+ continue;
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- if (matchedRecord != null) {
|
|
|
- // 如果存在记录,则更新设备数量和计算得分
|
|
|
- matchedRecord.setDeviceCount(matchedRecord.getDeviceCount() != null ? matchedRecord.getDeviceCount() + 1 : 1);
|
|
|
+ inspectionType = inspectionType.trim(); // 去除空格
|
|
|
|
|
|
- // 如果有项目分值,则重新计算得分
|
|
|
- if (matchedRecord.getFanInspectionScore() != null) {
|
|
|
- BigDecimal calculatedScore = matchedRecord.getFanInspectionScore()
|
|
|
- .multiply(new BigDecimal(matchedRecord.getDeviceCount()));
|
|
|
- matchedRecord.setCalculatedScore(calculatedScore);
|
|
|
+ // 在结果中查找匹配当前工单model和当前inspectionType的记录
|
|
|
+ GxtMonthFanInspection matchedRecord = null;
|
|
|
+ for (GxtMonthFanInspection fanInspection : fanInspections) {
|
|
|
+ if (order.getModel() != null && order.getModel().equals(fanInspection.getModel())
|
|
|
+ && inspectionType.equals(fanInspection.getInspectionTypeId())) {
|
|
|
+ matchedRecord = fanInspection;
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
- matchedRecord.setUpdateBy(SecurityUtils.getUsername());
|
|
|
- matchedRecord.setUpdateTime(new Date());
|
|
|
- gxtMonthFanInspectionService.updateGxtMonthFanInspection(matchedRecord);
|
|
|
- } else {
|
|
|
- // 如果不存在记录,则通过selectGxtMonthFanInspectionListByAdd获取初始化数据后插入
|
|
|
-
|
|
|
- // 构造查询条件以从数据库获取待插入的数据
|
|
|
- GxtMonthFanInspection templateQuery = new GxtMonthFanInspection();
|
|
|
- templateQuery.setDeptId(order.getPcsStationPid());
|
|
|
- templateQuery.setMonthPeriod(monthScore.getMonthPeriod());
|
|
|
|
|
|
- // 使用selectGxtMonthFanInspectionListByAdd方法获取模板数据
|
|
|
- List<GxtMonthFanInspection> templateList = gxtMonthFanInspectionService.selectGxtMonthFanInspectionListByAdd(templateQuery);
|
|
|
-
|
|
|
- // 在templateList中查找与当前工单匹配的记录
|
|
|
- for (GxtMonthFanInspection templateItem : templateList) {
|
|
|
- if (order.getModel() != null && order.getModel().equals(templateItem.getModel())
|
|
|
- && order.getInspectionType() != null && order.getInspectionType().equals(templateItem.getInspectionTypeId())) {
|
|
|
- SysDept dept = sysDeptMapper.selectDeptById(order.getPcsStationPid());
|
|
|
- // 设置关联的月度统计ID和其他必要字段
|
|
|
- templateItem.setMonthScoreId(monthScore.getId());
|
|
|
- templateItem.setDeptId(order.getPcsStationPid());
|
|
|
- templateItem.setDeptName(dept.getDeptName());
|
|
|
- templateItem.setMonthPeriod(monthScore.getMonthPeriod());
|
|
|
- templateItem.setStatus(0);
|
|
|
- templateItem.setCreateBy(SecurityUtils.getUsername());
|
|
|
- templateItem.setCreateTime(new Date());
|
|
|
- // 插入新记录
|
|
|
- gxtMonthFanInspectionService.insertGxtMonthFanInspection(templateItem);
|
|
|
- break;
|
|
|
+ if (matchedRecord != null) {
|
|
|
+ // 如果存在记录,则更新设备数量和计算得分
|
|
|
+ // 每种检查类型都要统计一次设备数量
|
|
|
+ matchedRecord.setDeviceCount(matchedRecord.getDeviceCount() != null ? matchedRecord.getDeviceCount() + 1 : 1);
|
|
|
+
|
|
|
+ // 如果有项目分值,则重新计算得分
|
|
|
+ if (matchedRecord.getFanInspectionScore() != null) {
|
|
|
+ BigDecimal calculatedScore = matchedRecord.getFanInspectionScore()
|
|
|
+ .multiply(new BigDecimal(matchedRecord.getDeviceCount()));
|
|
|
+ matchedRecord.setCalculatedScore(calculatedScore);
|
|
|
+ }
|
|
|
+ matchedRecord.setUpdateBy(SecurityUtils.getUsername());
|
|
|
+ matchedRecord.setUpdateTime(new Date());
|
|
|
+ gxtMonthFanInspectionService.updateGxtMonthFanInspection(matchedRecord);
|
|
|
+ } else {
|
|
|
+ // 如果不存在记录,则通过selectGxtMonthFanInspectionListByAdd获取初始化数据后插入
|
|
|
+
|
|
|
+ // 构造查询条件以从数据库获取待插入的数据
|
|
|
+ GxtMonthFanInspection templateQuery = new GxtMonthFanInspection();
|
|
|
+ templateQuery.setDeptId(order.getPcsStationPid());
|
|
|
+ templateQuery.setMonthPeriod(monthScore.getMonthPeriod());
|
|
|
+
|
|
|
+ // 使用selectGxtMonthFanInspectionListByAdd方法获取模板数据
|
|
|
+ List<GxtMonthFanInspection> templateList = gxtMonthFanInspectionService.selectGxtMonthFanInspectionListByAdd(templateQuery);
|
|
|
+
|
|
|
+ // 在templateList中查找与当前工单匹配的记录
|
|
|
+ for (GxtMonthFanInspection templateItem : templateList) {
|
|
|
+ if (order.getModel() != null && order.getModel().equals(templateItem.getModel())
|
|
|
+ && inspectionType.equals(templateItem.getInspectionTypeId())) {
|
|
|
+ SysDept dept = sysDeptMapper.selectDeptById(order.getPcsStationPid());
|
|
|
+ // 设置关联的月度统计ID和其他必要字段
|
|
|
+ templateItem.setMonthScoreId(monthScore.getId());
|
|
|
+ templateItem.setDeptId(order.getPcsStationPid());
|
|
|
+ templateItem.setDeptName(dept.getDeptName());
|
|
|
+ templateItem.setMonthPeriod(monthScore.getMonthPeriod());
|
|
|
+ templateItem.setStatus(0);
|
|
|
+ templateItem.setCreateBy(SecurityUtils.getUsername());
|
|
|
+ templateItem.setCreateTime(new Date());
|
|
|
+ /*// 设置初始设备数量为1(因为这是一个工单)
|
|
|
+ templateItem.setDeviceCount(1);
|
|
|
+ // 如果有项目分值,则设置初始计算得分
|
|
|
+ if (templateItem.getFanInspectionScore() != null) {
|
|
|
+ templateItem.setCalculatedScore(templateItem.getFanInspectionScore());
|
|
|
+ }else{
|
|
|
+ templateItem.setCalculatedScore(BigDecimal.ZERO);
|
|
|
+ }*/
|
|
|
+ // 插入新记录
|
|
|
+ gxtMonthFanInspectionService.insertGxtMonthFanInspection(templateItem);
|
|
|
+ // 将新插入的记录添加到fanInspections列表,防止重复插入
|
|
|
+ fanInspections.add(templateItem);
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|