|
@@ -1,12 +1,15 @@
|
|
|
package com.ygtx.gxt.service.impl;
|
|
package com.ygtx.gxt.service.impl;
|
|
|
|
|
|
|
|
import com.ygtx.common.constant.Constants;
|
|
import com.ygtx.common.constant.Constants;
|
|
|
|
|
+import com.ygtx.common.core.domain.entity.SysDept;
|
|
|
import com.ygtx.common.utils.DateUtils;
|
|
import com.ygtx.common.utils.DateUtils;
|
|
|
import com.ygtx.common.utils.SecurityUtils;
|
|
import com.ygtx.common.utils.SecurityUtils;
|
|
|
import com.ygtx.common.utils.StringUtils;
|
|
import com.ygtx.common.utils.StringUtils;
|
|
|
|
|
+import com.ygtx.common.utils.spring.SpringUtils;
|
|
|
import com.ygtx.gxt.domain.*;
|
|
import com.ygtx.gxt.domain.*;
|
|
|
import com.ygtx.gxt.mapper.GxtOrderScoreMapper;
|
|
import com.ygtx.gxt.mapper.GxtOrderScoreMapper;
|
|
|
import com.ygtx.gxt.service.*;
|
|
import com.ygtx.gxt.service.*;
|
|
|
|
|
+import com.ygtx.system.mapper.SysDeptMapper;
|
|
|
import com.ygtx.system.service.ISysConfigService;
|
|
import com.ygtx.system.service.ISysConfigService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -18,6 +21,7 @@ import com.ygtx.system.mapper.SysUserMapper;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -52,8 +56,23 @@ public class GxtOrderScoreServiceImpl implements IGxtOrderScoreService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IGxtRepairOrderFlowService repairOrderFlowService;
|
|
private IGxtRepairOrderFlowService repairOrderFlowService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IGxtMonthRepairProjectService gxtMonthRepairProjectService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IGxtMonthFanInspectionService gxtMonthFanInspectionService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IGxtUserScoreService gxtUserScoreService;
|
|
|
|
|
+
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IGxtWorkOrderFlowService gxtWorkOrderFlowService;
|
|
private IGxtWorkOrderFlowService gxtWorkOrderFlowService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IGxtMonthScoreService gxtMonthScoreService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private SysDeptMapper sysDeptMapper;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 查询合并的工单列表(维修工单和维保工单)
|
|
* 查询合并的工单列表(维修工单和维保工单)
|
|
@@ -654,7 +673,8 @@ public class GxtOrderScoreServiceImpl implements IGxtOrderScoreService {
|
|
|
flow.setActionRemark("系统自动归档工单");
|
|
flow.setActionRemark("系统自动归档工单");
|
|
|
repairOrderFlowService.insertGxtRepairOrderFlow(flow);
|
|
repairOrderFlowService.insertGxtRepairOrderFlow(flow);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ // 更新月度统计数据
|
|
|
|
|
+ updateMonthlyScoreData(orderScoreInfo);
|
|
|
return result;
|
|
return result;
|
|
|
} else if (orderScoreInfo.getOrderType() == 2) {
|
|
} else if (orderScoreInfo.getOrderType() == 2) {
|
|
|
// 维保工单复评
|
|
// 维保工单复评
|
|
@@ -792,6 +812,10 @@ public class GxtOrderScoreServiceImpl implements IGxtOrderScoreService {
|
|
|
flow.setActionRemark("系统自动归档工单");
|
|
flow.setActionRemark("系统自动归档工单");
|
|
|
repairOrderFlowService.insertGxtRepairOrderFlow(flow);
|
|
repairOrderFlowService.insertGxtRepairOrderFlow(flow);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 更新月度统计数据(仅更新用户得分)
|
|
|
|
|
+ updateMonthlyScoreDataForFinalEval(orderScoreInfo);
|
|
|
|
|
+
|
|
|
return 1;
|
|
return 1;
|
|
|
} else if (orderScoreInfo.getOrderType() == 2) {
|
|
} else if (orderScoreInfo.getOrderType() == 2) {
|
|
|
// 维保工单终评
|
|
// 维保工单终评
|
|
@@ -859,6 +883,10 @@ public class GxtOrderScoreServiceImpl implements IGxtOrderScoreService {
|
|
|
flow.setActionRemark("系统自动归档工单");
|
|
flow.setActionRemark("系统自动归档工单");
|
|
|
gxtWorkOrderFlowService.insertGxtWorkOrderFlow(flow);
|
|
gxtWorkOrderFlowService.insertGxtWorkOrderFlow(flow);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 更新月度统计数据
|
|
|
|
|
+ updateMonthlyScoreData(orderScoreInfo);
|
|
|
|
|
+
|
|
|
return 1;
|
|
return 1;
|
|
|
}
|
|
}
|
|
|
return 0;
|
|
return 0;
|
|
@@ -867,6 +895,494 @@ public class GxtOrderScoreServiceImpl implements IGxtOrderScoreService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 更新月度统计数据
|
|
|
|
|
+ * @param orderScoreInfo 工单对象
|
|
|
|
|
+ */
|
|
|
|
|
+ private void updateMonthlyScoreData(OrderScoreInfo orderScoreInfo) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ if (orderScoreInfo.getOrderType() == 1) {
|
|
|
|
|
+ // 维修工单
|
|
|
|
|
+ GxtRepairOrder order = gxtRepairOrderService.selectGxtRepairOrderById(orderScoreInfo.getId());
|
|
|
|
|
+ // 获取工单完成时间所在的月份
|
|
|
|
|
+ if (order.getOccurTime() != null) {
|
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
|
|
|
|
|
+ String monthPeriod = sdf.format(order.getOccurTime());
|
|
|
|
|
+
|
|
|
|
|
+ // 获取场站ID
|
|
|
|
|
+ Long deptId = order.getPcsStationPid();
|
|
|
|
|
+
|
|
|
|
|
+ // 获取月度统计信息 - 使用简单查询替代复杂的 getGxtMonthScoreByParams 方法
|
|
|
|
|
+ GxtMonthScore queryScore = new GxtMonthScore();
|
|
|
|
|
+ queryScore.setDeptId(deptId);
|
|
|
|
|
+ queryScore.setMonthPeriod(monthPeriod);
|
|
|
|
|
+ List<GxtMonthScore> scoreList = gxtMonthScoreService.selectGxtMonthScoreList(queryScore);
|
|
|
|
|
+ GxtMonthScore monthScore = null;
|
|
|
|
|
+ if (!scoreList.isEmpty()) {
|
|
|
|
|
+ monthScore = scoreList.get(0);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (monthScore == null) {
|
|
|
|
|
+ // 新增monthScore
|
|
|
|
|
+ monthScore = new GxtMonthScore();
|
|
|
|
|
+ monthScore.setDeptId(deptId);
|
|
|
|
|
+ monthScore.setMonthPeriod(monthPeriod);
|
|
|
|
|
+ monthScore.setStatus(0); // 初始状态
|
|
|
|
|
+ monthScore.setPersionId(SecurityUtils.getUserId());
|
|
|
|
|
+ monthScore.setCreateBy(SecurityUtils.getUsername());
|
|
|
|
|
+ monthScore.setCreateTime(new Date());
|
|
|
|
|
+ gxtMonthScoreService.insertGxtMonthScore(monthScore);
|
|
|
|
|
+ // 直接查询刚插入的记录
|
|
|
|
|
+ queryScore = new GxtMonthScore();
|
|
|
|
|
+ queryScore.setDeptId(deptId);
|
|
|
|
|
+ queryScore.setMonthPeriod(monthPeriod);
|
|
|
|
|
+ scoreList = gxtMonthScoreService.selectGxtMonthScoreList(queryScore);
|
|
|
|
|
+ if (!scoreList.isEmpty()) {
|
|
|
|
|
+ monthScore = scoreList.get(0);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ // 更新月度场站维修项目工单统计
|
|
|
|
|
+ updateMonthRepairProject(monthScore, order);
|
|
|
|
|
+
|
|
|
|
|
+ // 更新用户评分统计
|
|
|
|
|
+ updateUserScores(monthScore, order);
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (orderScoreInfo.getOrderType() == 2) {
|
|
|
|
|
+ // 维保工单
|
|
|
|
|
+ GxtWorkOrder order = gxtWorkOrderService.selectGxtWorkOrderById(orderScoreInfo.getId());
|
|
|
|
|
+ // 获取工单完成时间所在的月份
|
|
|
|
|
+ if (order.getCreateTime() != null) {
|
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
|
|
|
|
|
+ String monthPeriod = sdf.format(order.getCreateTime());
|
|
|
|
|
+
|
|
|
|
|
+ // 获取场站ID
|
|
|
|
|
+ Long deptId = order.getPcsStationPid();
|
|
|
|
|
+
|
|
|
|
|
+ // 获取月度统计信息 - 使用简单查询替代复杂的 getGxtMonthScoreByParams 方法
|
|
|
|
|
+ GxtMonthScore queryScore = new GxtMonthScore();
|
|
|
|
|
+ queryScore.setDeptId(deptId);
|
|
|
|
|
+ queryScore.setMonthPeriod(monthPeriod);
|
|
|
|
|
+ List<GxtMonthScore> scoreList = gxtMonthScoreService.selectGxtMonthScoreList(queryScore);
|
|
|
|
|
+ GxtMonthScore monthScore = null;
|
|
|
|
|
+ if (!scoreList.isEmpty()) {
|
|
|
|
|
+ monthScore = scoreList.get(0);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (monthScore == null) {
|
|
|
|
|
+ // 新增monthScore
|
|
|
|
|
+ monthScore = new GxtMonthScore();
|
|
|
|
|
+ monthScore.setDeptId(deptId);
|
|
|
|
|
+ monthScore.setMonthPeriod(monthPeriod);
|
|
|
|
|
+ monthScore.setStatus(0); // 初始状态
|
|
|
|
|
+ monthScore.setPersionId(SecurityUtils.getUserId());
|
|
|
|
|
+ monthScore.setCreateBy(SecurityUtils.getUsername());
|
|
|
|
|
+ monthScore.setCreateTime(new Date());
|
|
|
|
|
+ gxtMonthScoreService.insertGxtMonthScore(monthScore);
|
|
|
|
|
+ // 直接查询刚插入的记录
|
|
|
|
|
+ queryScore = new GxtMonthScore();
|
|
|
|
|
+ queryScore.setDeptId(deptId);
|
|
|
|
|
+ queryScore.setMonthPeriod(monthPeriod);
|
|
|
|
|
+ scoreList = gxtMonthScoreService.selectGxtMonthScoreList(queryScore);
|
|
|
|
|
+ if (!scoreList.isEmpty()) {
|
|
|
|
|
+ monthScore = scoreList.get(0);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ // 更新月度场站风机类型工单统计
|
|
|
|
|
+ updateMonthFanInspection(monthScore, order);
|
|
|
|
|
+
|
|
|
|
|
+ // 更新用户评分统计
|
|
|
|
|
+ updateUserScores(monthScore, order);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 更新月度场站风机类型工单统计
|
|
|
|
|
+ * @param monthScore 月度统计信息
|
|
|
|
|
+ * @param order 工单对象
|
|
|
|
|
+ */
|
|
|
|
|
+ private void updateMonthFanInspection(GxtMonthScore monthScore, GxtWorkOrder order) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ /*if (order.getItemCompletionFactorSum().compareTo(BigDecimal.ONE) < 0) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }*/
|
|
|
|
|
+ // 创建查询条件,查找与当前工单相关的风机检查类型统计
|
|
|
|
|
+ GxtMonthFanInspection queryFanInspection = new GxtMonthFanInspection();
|
|
|
|
|
+ queryFanInspection.setMonthScoreId(monthScore.getId());
|
|
|
|
|
+ queryFanInspection.setDeptId(order.getPcsStationPid());
|
|
|
|
|
+ queryFanInspection.setMonthPeriod(monthScore.getMonthPeriod());
|
|
|
|
|
+ // 查询所有该月度统计下的风机检查类型统计记录
|
|
|
|
|
+ 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;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ 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())
|
|
|
|
|
+ && 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;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 更新月度场站维修项目工单统计
|
|
|
|
|
+ * @param monthScore 月度统计信息
|
|
|
|
|
+ * @param order 工单对象
|
|
|
|
|
+ */
|
|
|
|
|
+ private void updateMonthRepairProject(GxtMonthScore monthScore, GxtRepairOrder order) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 创建查询条件,查找与当前工单相关的维修项目统计
|
|
|
|
|
+ GxtMonthRepairProject queryRepairProject = new GxtMonthRepairProject();
|
|
|
|
|
+ queryRepairProject.setMonthScoreId(monthScore.getId());
|
|
|
|
|
+ queryRepairProject.setDeptId(order.getPcsStationPid());
|
|
|
|
|
+ queryRepairProject.setMaintenanceType(order.getMaintenanceType());
|
|
|
|
|
+ queryRepairProject.setMonthPeriod(monthScore.getMonthPeriod());
|
|
|
|
|
+ // 查询所有该月度统计下的维修项目统计记录
|
|
|
|
|
+ List<GxtMonthRepairProject> repairProjects = gxtMonthRepairProjectService.selectGxtMonthRepairProjectList(queryRepairProject);
|
|
|
|
|
+
|
|
|
|
|
+ GxtMonthRepairProject matchedRecord = null;
|
|
|
|
|
+
|
|
|
|
|
+ if (repairProjects != null && !repairProjects.isEmpty()) {
|
|
|
|
|
+ matchedRecord = repairProjects.get(0);
|
|
|
|
|
+ // 如果存在记录,则更新工单数量和计算得分
|
|
|
|
|
+ matchedRecord.setOrderCount(matchedRecord.getOrderCount() != null ? matchedRecord.getOrderCount() + 1 : 1);
|
|
|
|
|
+
|
|
|
|
|
+ // 如果有项目分值,则重新计算得分
|
|
|
|
|
+ if (matchedRecord.getProjectScore() != null) {
|
|
|
|
|
+ BigDecimal calculatedScore = matchedRecord.getProjectScore()
|
|
|
|
|
+ .multiply(new BigDecimal(matchedRecord.getOrderCount()));
|
|
|
|
|
+ matchedRecord.setCalculatedScore(calculatedScore);
|
|
|
|
|
+ }
|
|
|
|
|
+ matchedRecord.setUpdateBy(SecurityUtils.getUsername());
|
|
|
|
|
+ matchedRecord.setUpdateTime(new Date());
|
|
|
|
|
+ gxtMonthRepairProjectService.updateGxtMonthRepairProject(matchedRecord);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 如果不存在记录,则通过selectGxtMonthRepairProjectListByAdd获取初始化数据后插入
|
|
|
|
|
+
|
|
|
|
|
+ // 构造查询条件以从数据库获取待插入的数据
|
|
|
|
|
+ GxtMonthRepairProject templateQuery = new GxtMonthRepairProject();
|
|
|
|
|
+ templateQuery.setDeptId(order.getPcsStationPid());
|
|
|
|
|
+ templateQuery.setMonthPeriod(monthScore.getMonthPeriod());
|
|
|
|
|
+
|
|
|
|
|
+ // 使用selectGxtMonthRepairProjectListByAdd方法获取模板数据
|
|
|
|
|
+ List<GxtMonthRepairProject> templateList = gxtMonthRepairProjectService.selectGxtMonthRepairProjectListByAdd(templateQuery);
|
|
|
|
|
+
|
|
|
|
|
+ // 在templateList中查找与当前工单匹配的记录
|
|
|
|
|
+ for (GxtMonthRepairProject templateItem : templateList) {
|
|
|
|
|
+ if (order.getMaintenanceType() != null && order.getMaintenanceType().equals(templateItem.getMaintenanceType())) {
|
|
|
|
|
+ SysDept dept = sysDeptMapper.selectDeptById(order.getPcsStationPid());
|
|
|
|
|
+ // 设置关联的月度统计ID和其他必要字段
|
|
|
|
|
+ templateItem.setMonthScoreId(monthScore.getId());
|
|
|
|
|
+ templateItem.setDeptId(order.getPcsStationPid());
|
|
|
|
|
+ templateItem.setDeptName(dept.getDeptName());
|
|
|
|
|
+ templateItem.setMonthPeriod(monthScore.getMonthPeriod());
|
|
|
|
|
+ templateItem.setCreateBy(SecurityUtils.getUsername());
|
|
|
|
|
+ templateItem.setCreateTime(new Date());
|
|
|
|
|
+ // 插入新记录
|
|
|
|
|
+ gxtMonthRepairProjectService.insertGxtMonthRepairProject(templateItem);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 更新用户评分统计(维修工单)
|
|
|
|
|
+ * @param monthScore 月度统计信息
|
|
|
|
|
+ * @param order 工单对象
|
|
|
|
|
+ */
|
|
|
|
|
+ private void updateUserScores(GxtMonthScore monthScore, GxtRepairOrder order) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 获取参与该工单的所有人员
|
|
|
|
|
+ List<GxtRepairOrderPerson> orderPersons = gxtRepairOrderService.selectRepairOrderPersonListByOrderId(order.getId());
|
|
|
|
|
+
|
|
|
|
|
+ // 获取现有的用户评分统计列表
|
|
|
|
|
+ GxtUserScore queryUserScore = new GxtUserScore();
|
|
|
|
|
+ queryUserScore.setMonthScoreId(monthScore.getId());
|
|
|
|
|
+ List<GxtUserScore> userScores = gxtUserScoreService.selectGxtUserScoreList(queryUserScore);
|
|
|
|
|
+
|
|
|
|
|
+ if (userScores != null && !orderPersons.isEmpty()) {
|
|
|
|
|
+ // 遍历工单中的每个人员
|
|
|
|
|
+ for (GxtRepairOrderPerson orderPerson : orderPersons) {
|
|
|
|
|
+ boolean found = false;
|
|
|
|
|
+ // 在月度统计中查找该用户
|
|
|
|
|
+ for (GxtUserScore userScore : userScores) {
|
|
|
|
|
+ // 使用userName进行匹配
|
|
|
|
|
+ if (orderPerson.getNickName() != null && orderPerson.getNickName().equals(userScore.getUserName())) {
|
|
|
|
|
+ // 更新维修工单总分
|
|
|
|
|
+ BigDecimal repairScore = (orderPerson.getScore() != null) ?
|
|
|
|
|
+ orderPerson.getScore(): BigDecimal.ZERO;
|
|
|
|
|
+
|
|
|
|
|
+ BigDecimal currentRepairTotal = (userScore.getRepairTotalScore() != null) ?
|
|
|
|
|
+ userScore.getRepairTotalScore() : BigDecimal.ZERO;
|
|
|
|
|
+
|
|
|
|
|
+ userScore.setRepairTotalScore(currentRepairTotal.add(repairScore));
|
|
|
|
|
+
|
|
|
|
|
+ // 更新最终评分
|
|
|
|
|
+ BigDecimal maintenanceScore = (userScore.getMaintenanceTotalScore() != null) ?
|
|
|
|
|
+ userScore.getMaintenanceTotalScore() : BigDecimal.ZERO;
|
|
|
|
|
+
|
|
|
|
|
+ BigDecimal finalScore = maintenanceScore.add(currentRepairTotal.add(repairScore));
|
|
|
|
|
+ userScore.setFinalScore(finalScore);
|
|
|
|
|
+ userScore.setUpdateBy(SecurityUtils.getUsername());
|
|
|
|
|
+ userScore.setUpdateTime(new Date());
|
|
|
|
|
+ gxtUserScoreService.updateGxtUserScore(userScore);
|
|
|
|
|
+ found = true;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 如果没找到用户记录,则创建新记录
|
|
|
|
|
+ if (!found) {
|
|
|
|
|
+ GxtUserScore newUserScore = new GxtUserScore();
|
|
|
|
|
+ newUserScore.setMonthScoreId(monthScore.getId());
|
|
|
|
|
+ newUserScore.setUserName(orderPerson.getNickName());
|
|
|
|
|
+ newUserScore.setMonthPeriod(monthScore.getMonthPeriod());
|
|
|
|
|
+
|
|
|
|
|
+ // 设置维修工单得分
|
|
|
|
|
+ BigDecimal repairScore = (orderPerson.getScore() != null) ?
|
|
|
|
|
+ orderPerson.getScore() : BigDecimal.ZERO;
|
|
|
|
|
+ newUserScore.setRepairTotalScore(repairScore);
|
|
|
|
|
+
|
|
|
|
|
+ // 维保得分默认为0
|
|
|
|
|
+ newUserScore.setMaintenanceTotalScore(BigDecimal.ZERO);
|
|
|
|
|
+ newUserScore.setFinalScore(repairScore);
|
|
|
|
|
+ newUserScore.setStatus(0);
|
|
|
|
|
+ newUserScore.setCreateBy(SecurityUtils.getUsername());
|
|
|
|
|
+ newUserScore.setCreateTime(new Date());
|
|
|
|
|
+ // 插入新记录
|
|
|
|
|
+ gxtUserScoreService.insertGxtUserScore(newUserScore);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 更新用户评分统计(维保工单)
|
|
|
|
|
+ * @param monthScore 月度统计信息
|
|
|
|
|
+ * @param order 工单对象
|
|
|
|
|
+ */
|
|
|
|
|
+ private void updateUserScores(GxtMonthScore monthScore, GxtWorkOrder order) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 获取参与该工单的所有人员
|
|
|
|
|
+ List<GxtWorkOrderPerson> orderPersons = gxtWorkOrderService.selectWorkOrderPersonListByOrderId(order.getId());
|
|
|
|
|
+
|
|
|
|
|
+ // 获取现有的用户评分统计列表
|
|
|
|
|
+ GxtUserScore queryUserScore = new GxtUserScore();
|
|
|
|
|
+ queryUserScore.setMonthScoreId(monthScore.getId());
|
|
|
|
|
+ List<GxtUserScore> userScores = gxtUserScoreService.selectGxtUserScoreList(queryUserScore);
|
|
|
|
|
+
|
|
|
|
|
+ if (userScores != null && !orderPersons.isEmpty()) {
|
|
|
|
|
+ // 遍历工单中的每个人员
|
|
|
|
|
+ for (GxtWorkOrderPerson orderPerson : orderPersons) {
|
|
|
|
|
+ boolean found = false;
|
|
|
|
|
+ // 在月度统计中查找该用户
|
|
|
|
|
+ for (GxtUserScore userScore : userScores) {
|
|
|
|
|
+ // 使用userName进行匹配
|
|
|
|
|
+ if (orderPerson.getNickName() != null && orderPerson.getNickName().equals(userScore.getUserName())) {
|
|
|
|
|
+ // 更新维保工单总分
|
|
|
|
|
+ BigDecimal maintenanceScore = (orderPerson.getScore() != null) ?
|
|
|
|
|
+ orderPerson.getScore() : BigDecimal.ZERO;
|
|
|
|
|
+
|
|
|
|
|
+ BigDecimal currentMaintenanceTotal = (userScore.getMaintenanceTotalScore() != null) ?
|
|
|
|
|
+ userScore.getMaintenanceTotalScore() : BigDecimal.ZERO;
|
|
|
|
|
+
|
|
|
|
|
+ userScore.setMaintenanceTotalScore(currentMaintenanceTotal.add(maintenanceScore));
|
|
|
|
|
+
|
|
|
|
|
+ // 更新最终评分
|
|
|
|
|
+ BigDecimal repairScore = (userScore.getRepairTotalScore() != null) ?
|
|
|
|
|
+ userScore.getRepairTotalScore() : BigDecimal.ZERO;
|
|
|
|
|
+
|
|
|
|
|
+ BigDecimal finalScore = repairScore.add(currentMaintenanceTotal.add(maintenanceScore));
|
|
|
|
|
+ userScore.setFinalScore(finalScore);
|
|
|
|
|
+ userScore.setUpdateBy(SecurityUtils.getUsername());
|
|
|
|
|
+ userScore.setUpdateTime(new Date());
|
|
|
|
|
+ gxtUserScoreService.updateGxtUserScore(userScore);
|
|
|
|
|
+ found = true;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 如果没找到用户记录,则创建新记录
|
|
|
|
|
+ if (!found) {
|
|
|
|
|
+ GxtUserScore newUserScore = new GxtUserScore();
|
|
|
|
|
+ newUserScore.setMonthScoreId(monthScore.getId());
|
|
|
|
|
+ newUserScore.setUserName(orderPerson.getNickName());
|
|
|
|
|
+ newUserScore.setMonthPeriod(monthScore.getMonthPeriod());
|
|
|
|
|
+
|
|
|
|
|
+ // 设置维保工单得分
|
|
|
|
|
+ BigDecimal maintenanceScore = (orderPerson.getScore() != null) ?
|
|
|
|
|
+ orderPerson.getScore() : BigDecimal.ZERO;
|
|
|
|
|
+ newUserScore.setMaintenanceTotalScore(maintenanceScore);
|
|
|
|
|
+
|
|
|
|
|
+ // 维修得分默认为0
|
|
|
|
|
+ newUserScore.setRepairTotalScore(BigDecimal.ZERO);
|
|
|
|
|
+ newUserScore.setFinalScore(maintenanceScore);
|
|
|
|
|
+ newUserScore.setStatus(0);
|
|
|
|
|
+ newUserScore.setCreateBy(SecurityUtils.getUsername());
|
|
|
|
|
+ newUserScore.setCreateTime(new Date());
|
|
|
|
|
+ // 插入新记录
|
|
|
|
|
+ gxtUserScoreService.insertGxtUserScore(newUserScore);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 更新月度统计数据(终评专用版本,仅更新用户得分)
|
|
|
|
|
+ * @param orderScoreInfo 工单对象
|
|
|
|
|
+ */
|
|
|
|
|
+ private void updateMonthlyScoreDataForFinalEval(OrderScoreInfo orderScoreInfo) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ if (orderScoreInfo.getOrderType() == 1) {
|
|
|
|
|
+ // 维修工单
|
|
|
|
|
+ GxtRepairOrder order = gxtRepairOrderService.selectGxtRepairOrderById(orderScoreInfo.getId());
|
|
|
|
|
+ // 获取工单完成时间所在的月份
|
|
|
|
|
+ if (order.getOccurTime() != null) {
|
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
|
|
|
|
|
+ String monthPeriod = sdf.format(order.getOccurTime());
|
|
|
|
|
+
|
|
|
|
|
+ // 获取场站ID
|
|
|
|
|
+ Long deptId = order.getPcsStationPid();
|
|
|
|
|
+
|
|
|
|
|
+ // 获取月度统计信息
|
|
|
|
|
+ GxtMonthScore queryScore = new GxtMonthScore();
|
|
|
|
|
+ queryScore.setDeptId(deptId);
|
|
|
|
|
+ queryScore.setMonthPeriod(monthPeriod);
|
|
|
|
|
+ List<GxtMonthScore> scoreList = gxtMonthScoreService.selectGxtMonthScoreList(queryScore);
|
|
|
|
|
+ GxtMonthScore monthScore = null;
|
|
|
|
|
+ if (!scoreList.isEmpty()) {
|
|
|
|
|
+ monthScore = scoreList.get(0);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (monthScore != null) {
|
|
|
|
|
+ // 仅更新用户评分统计(基于reviewScore和finalScore的差值)
|
|
|
|
|
+ updateUserScoresForFinalEval(monthScore, order);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (orderScoreInfo.getOrderType() == 2) {
|
|
|
|
|
+ // 维保工单保持不变
|
|
|
|
|
+ updateMonthlyScoreData(orderScoreInfo);
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 更新用户评分统计(终评专用版本,基于reviewScore和finalScore的差值)
|
|
|
|
|
+ * @param monthScore 月度统计信息
|
|
|
|
|
+ * @param order 工单对象
|
|
|
|
|
+ */
|
|
|
|
|
+ private void updateUserScoresForFinalEval(GxtMonthScore monthScore, GxtRepairOrder order) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 获取参与该工单的所有人员(当前数据库中的最新数据)
|
|
|
|
|
+ List<GxtRepairOrderPerson> orderPersons = gxtRepairOrderService.selectRepairOrderPersonListByOrderId(order.getId());
|
|
|
|
|
+
|
|
|
|
|
+ // 获取现有的用户评分统计列表
|
|
|
|
|
+ GxtUserScore queryUserScore = new GxtUserScore();
|
|
|
|
|
+ queryUserScore.setMonthScoreId(monthScore.getId());
|
|
|
|
|
+ List<GxtUserScore> userScores = gxtUserScoreService.selectGxtUserScoreList(queryUserScore);
|
|
|
|
|
+
|
|
|
|
|
+ if (userScores != null && !orderPersons.isEmpty()) {
|
|
|
|
|
+ // 遍历工单中的每个人员
|
|
|
|
|
+ for (GxtRepairOrderPerson orderPerson : orderPersons) {
|
|
|
|
|
+ // 计算差值:finalScore - reviewScore
|
|
|
|
|
+ Double reviewScore = orderPerson.getReviewScore() != null ? orderPerson.getReviewScore() : 0.0;
|
|
|
|
|
+ Double finalScore = orderPerson.getFinalScore() != null ? orderPerson.getFinalScore() : 0.0;
|
|
|
|
|
+ BigDecimal scoreDiff = new BigDecimal(String.valueOf(finalScore - reviewScore));
|
|
|
|
|
+
|
|
|
|
|
+ // 在月度统计中查找该用户
|
|
|
|
|
+ for (GxtUserScore userScore : userScores) {
|
|
|
|
|
+ // 使用userName进行匹配
|
|
|
|
|
+ if (orderPerson.getNickName() != null && orderPerson.getNickName().equals(userScore.getUserName())) {
|
|
|
|
|
+ // 更新维修工单总分(应用差值)
|
|
|
|
|
+ BigDecimal currentRepairTotal = (userScore.getRepairTotalScore() != null) ?
|
|
|
|
|
+ userScore.getRepairTotalScore() : BigDecimal.ZERO;
|
|
|
|
|
+
|
|
|
|
|
+ userScore.setRepairTotalScore(currentRepairTotal.add(scoreDiff));
|
|
|
|
|
+
|
|
|
|
|
+ // 更新最终评分
|
|
|
|
|
+ BigDecimal maintenanceScore = (userScore.getMaintenanceTotalScore() != null) ?
|
|
|
|
|
+ userScore.getMaintenanceTotalScore() : BigDecimal.ZERO;
|
|
|
|
|
+
|
|
|
|
|
+ BigDecimal finalScoreTotal = maintenanceScore.add(currentRepairTotal).add(scoreDiff);
|
|
|
|
|
+ userScore.setFinalScore(finalScoreTotal);
|
|
|
|
|
+ userScore.setUpdateBy(SecurityUtils.getUsername());
|
|
|
|
|
+ userScore.setUpdateTime(new Date());
|
|
|
|
|
+ gxtUserScoreService.updateGxtUserScore(userScore);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 保存确认信息
|
|
* 保存确认信息
|
|
|
*
|
|
*
|