|
@@ -9,7 +9,9 @@ import com.rongwe.scentity.domian.AspSafetyProductObjective;
|
|
|
import com.rongwe.scentity.domian.AspSafetyProductObjectiveResult;
|
|
|
import com.rongwe.scentity.domian.AspSafetyProductObjectiveResultScoreDetail;
|
|
|
import com.rongwe.scentity.domian.AspSafetyProductObjectiveScoreDetail;
|
|
|
+import com.rongwe.scentity.vo.RoleIdAndUserIdsVo;
|
|
|
import com.rongwei.rwcommon.utils.SecurityUtil;
|
|
|
+import com.rongwei.safecommon.utils.CXCommonUtils;
|
|
|
import com.rongwei.sfcommon.sys.dao.AspSafetyProductObjectiveDao;
|
|
|
import com.rongwei.sfcommon.sys.service.AspSafetyProductObjectiveResultScoreDetailService;
|
|
|
import com.rongwei.sfcommon.sys.service.AspSafetyProductObjectiveResultService;
|
|
@@ -18,8 +20,7 @@ import com.rongwei.sfcommon.sys.service.AspSafetyProductObjectiveService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.LinkedList;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -54,7 +55,7 @@ public class AspSafetyProductObjectiveServiceImpl extends ServiceImpl<AspSafetyP
|
|
|
|
|
|
//遍历目标获取所有目标的ID集合
|
|
|
List<String> collectIds = aspSafetyProductObjectives.stream().map(AspSafetyProductObjective::getId).collect(Collectors.toList());
|
|
|
- if (ObjectUtil.isEmpty(collectIds)){
|
|
|
+ if (ObjectUtil.isEmpty(collectIds)) {
|
|
|
return;
|
|
|
}
|
|
|
//查询出所有目标的子表数据
|
|
@@ -105,5 +106,66 @@ public class AspSafetyProductObjectiveServiceImpl extends ServiceImpl<AspSafetyP
|
|
|
objectiveResultService.saveBatch(mainResList);
|
|
|
//插入考核子表
|
|
|
objectiveResultScoreDetailService.saveBatch(childResList);
|
|
|
+
|
|
|
+ //发送已生成考核的消息,按照工厂、指标级别,分别下发给对应角色的人
|
|
|
+ sendMessage(mainResList);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void sendMessage(List<AspSafetyProductObjectiveResult> mainResList) {
|
|
|
+ //维护指标级别对应的角色ID
|
|
|
+ //objectivelevel:指标级别。
|
|
|
+ // 10:工厂级,副总:e9133e738d67492aa4b3a641894f85c2
|
|
|
+ // 20:部门级,部门长:b104293d47e34df8847d1634c29ab031
|
|
|
+ // 30:车间级,车间主任:16963f62b94149d9ae16eabc9248999b
|
|
|
+ // 40:工段级,工段主管:104ac71c72704bbd953da6d7c167ed3a
|
|
|
+ // 50:班组级,班长:efed8df42bde46c9970c1476e74d6374
|
|
|
+ Map<String, String> levelMap = new HashMap<>();
|
|
|
+ levelMap.put("10", "e9133e738d67492aa4b3a641894f85c2");
|
|
|
+ levelMap.put("20", "b104293d47e34df8847d1634c29ab031");
|
|
|
+ levelMap.put("30", "16963f62b94149d9ae16eabc9248999b");
|
|
|
+ levelMap.put("40", "104ac71c72704bbd953da6d7c167ed3a");
|
|
|
+ levelMap.put("50", "efed8df42bde46c9970c1476e74d6374");
|
|
|
+ //获取需要发送消息的工厂
|
|
|
+ Set<String> tenantIds = mainResList.stream().map(AspSafetyProductObjectiveResult::getTenantid).collect(Collectors.toSet());
|
|
|
+ //整理工厂下、各个指标级别、对应的角色(职位)下的员工ID,:<工厂ID,<角色ID,用户IDs(英文逗号隔开)>>
|
|
|
+ Map<String, Map<String, String>> tenantManagerMap = new HashMap<>();
|
|
|
+ tenantIds.forEach(tenantId -> {
|
|
|
+ List<RoleIdAndUserIdsVo> roleIdAndUserIdsVos = this.baseMapper.selectManagerByTenantId(tenantId);
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ roleIdAndUserIdsVos.forEach(item -> {
|
|
|
+ if (ObjectUtil.isNotEmpty(item.getId())) {
|
|
|
+ map.put(item.getId(), item.getUserIds());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ tenantManagerMap.put(tenantId, map);
|
|
|
+ });
|
|
|
+ //处理考核主表,发送消息
|
|
|
+ mainResList.forEach(item -> {
|
|
|
+ //判断工厂ID是否存在
|
|
|
+ if (ObjectUtil.isEmpty(item.getTenantid())) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //判断指标级别是否存在
|
|
|
+ if (ObjectUtil.isEmpty(item.getObjectivelevel())) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //获取该工厂下的角色对应的USERIDs
|
|
|
+ Map<String, String> map = tenantManagerMap.get(item.getTenantid());
|
|
|
+ //获取该数据的指标级别对应的角色ID
|
|
|
+ String roleId = levelMap.get(item.getObjectivelevel());
|
|
|
+ //获取该消息对应的用户IDs
|
|
|
+ if (ObjectUtil.isEmpty(roleId)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<String> userIdList = Arrays.asList(map.get(roleId).split(","));
|
|
|
+ //发送消息
|
|
|
+ CXCommonUtils.sendNotify("目标考核",
|
|
|
+ "目标考核:【" + item.getYear().split("-")[0] + "】年,【" + item.getQuerter() + "】季度,【" + item.getDepartname() + "】单位的考核已生成,请及时完善",
|
|
|
+ null,
|
|
|
+ userIdList,
|
|
|
+ item.getId(),
|
|
|
+ "targetassessment");
|
|
|
+ });
|
|
|
}
|
|
|
}
|