|
|
@@ -7,13 +7,15 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
|
|
import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi;
|
|
|
-import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.qhse.accident.vo.IotAccidentReportPageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.qhse.accident.vo.IotAccidentReportSaveReqVO;
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.stat.DeptUtil;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.accident.IotAccidentReportDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.accident.IotAccidentReportProcessDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.qhse.accident.IotAccidentReportMapper;
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.qhse.accident.IotAccidentReportProcessMapper;
|
|
|
+import cn.iocoder.yudao.module.pms.message.PmsMessage;
|
|
|
+import cn.iocoder.yudao.module.pms.service.IotDeviceService;
|
|
|
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
|
|
import cn.iocoder.yudao.module.system.api.dept.PostApi;
|
|
|
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
|
|
@@ -22,6 +24,7 @@ import cn.iocoder.yudao.module.system.api.permission.RoleApi;
|
|
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
|
|
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
|
|
import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
|
|
+import com.google.common.collect.ImmutableList;
|
|
|
import com.google.common.collect.ImmutableSet;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -58,6 +61,12 @@ public class IotAccidentReportServiceImpl implements IotAccidentReportService {
|
|
|
private IotAccidentReportProcessMapper iotAccidentReportProcessMapper;
|
|
|
@Resource
|
|
|
private BpmProcessInstanceApi processInstanceApi;
|
|
|
+ @Autowired
|
|
|
+ private PmsMessage pmsMessage;
|
|
|
+ @Autowired
|
|
|
+ private IotDeviceService iotDeviceService;
|
|
|
+ @Autowired
|
|
|
+ private DeptUtil deptUtil;
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@@ -175,10 +184,10 @@ public class IotAccidentReportServiceImpl implements IotAccidentReportService {
|
|
|
iotAccidentReport.setDeptName(dept.getName());
|
|
|
}
|
|
|
//设置状态为上报中
|
|
|
- iotAccidentReport.setStatus("reporting");
|
|
|
+// iotAccidentReport.setStatus("reporting");
|
|
|
//查找上一级的项目主管
|
|
|
iotAccidentReport.setDeleted(false);
|
|
|
- iotAccidentReport.setFlowStatus("2");
|
|
|
+// iotAccidentReport.setFlowStatus("2");
|
|
|
//获取当前部门的上一级部门也就是项目部的项目经理
|
|
|
// Long parentId = dept.getParentId();
|
|
|
// List<AdminUserRespDTO> parentDeptUsers = adminUserApi.getUserListByDeptIdsNew(Collections.singleton(parentId));
|
|
|
@@ -202,11 +211,36 @@ public class IotAccidentReportServiceImpl implements IotAccidentReportService {
|
|
|
// processDO.setCreateTime(LocalDateTime.now());
|
|
|
// processDO.setStatus("提交上报");
|
|
|
// iotAccidentReportProcessMapper.insert(processDO);
|
|
|
- String processInstanceId;
|
|
|
- processInstanceId = processInstanceApi.createProcessInstance(SecurityFrameworkUtils.getLoginUserId(),
|
|
|
- new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey("qhse-accident").setBusinessKey(String.valueOf(iotAccidentReport.getId())));
|
|
|
-
|
|
|
- iotAccidentReportMapper.updateById(new IotAccidentReportDO().setId(iotAccidentReport.getId()).setProcessInstanceId(processInstanceId));
|
|
|
+// String processInstanceId;
|
|
|
+// processInstanceId = processInstanceApi.createProcessInstance(SecurityFrameworkUtils.getLoginUserId(),
|
|
|
+// new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey("qhse-accident").setBusinessKey(String.valueOf(iotAccidentReport.getId())));
|
|
|
+//
|
|
|
+// iotAccidentReportMapper.updateById(new IotAccidentReportDO().setId(iotAccidentReport.getId()).setProcessInstanceId(processInstanceId));
|
|
|
+ //发送钉钉消息
|
|
|
+ //pmsMessage.sendMessage(item.getId(), item.getCertName(), PmsConstants.GENERATE_QHSE_CERT, adminUserRespDTO.getId(), adminUserRespDTO.getMobile());
|
|
|
+ String deptName;
|
|
|
+ if (iotAccidentReport.getDeptName().contains("~~")) {
|
|
|
+ String[] split = iotAccidentReport.getDeptName().split("~~");
|
|
|
+ deptName = split[0];
|
|
|
+ } else {
|
|
|
+ deptName = iotAccidentReport.getDeptName();
|
|
|
+ }
|
|
|
+ //todo 发送公司总经理及QHSE总监、数智化首席运营及集团总裁
|
|
|
+ PostRespDTO zjl = postApi.getPostByName("总经理");
|
|
|
+ List<AdminUserRespDTO> userListByPostIds = adminUserApi.getUserListByPostIdsNoPermission(ImmutableList.of(zjl.getId()));
|
|
|
+ userListByPostIds.stream().filter(e -> e.getDeptId().equals(iotAccidentReport.getDeptId())).findFirst().ifPresent(f ->{
|
|
|
+ //总经理发送消息
|
|
|
+ System.out.println("---------");
|
|
|
+// pmsMessage.sendMessage(iotAccidentReport.getId(), deptName+iotAccidentReport.getAccidentAddress()+"事故事件上报",PmsConstants.QHSE_ACCIDENT,f.getId(), f.getMobile());
|
|
|
+ });
|
|
|
+ ImmutableList<String> strings = ImmutableList.of("安全副总监", "数智化首席运营", "集团总裁");
|
|
|
+ for (String string : strings) {
|
|
|
+ PostRespDTO fzj = postApi.getPostByName(string);
|
|
|
+ List<AdminUserRespDTO> fzjUsers = adminUserApi.getUserListByPostIdsNoPermission(ImmutableList.of(fzj.getId()));
|
|
|
+ if (CollUtil.isNotEmpty(fzjUsers)) {
|
|
|
+// pmsMessage.sendMessage(iotAccidentReport.getId(), deptName+iotAccidentReport.getAccidentAddress()+"事故事件上报",PmsConstants.QHSE_ACCIDENT,fzjUsers.get(0).getId(), fzjUsers.get(0).getMobile());
|
|
|
+ }
|
|
|
+ }
|
|
|
// 返回
|
|
|
return iotAccidentReport.getId();
|
|
|
}
|