|
@@ -6,6 +6,8 @@ import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
|
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.IotAccidentReportPageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.qhse.accident.vo.IotAccidentReportSaveReqVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.qhse.accident.vo.IotAccidentReportSaveReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.accident.IotAccidentReportDO;
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.accident.IotAccidentReportDO;
|
|
@@ -27,12 +29,10 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
-import java.time.LocalDateTime;
|
|
|
|
|
import java.util.Collections;
|
|
import java.util.Collections;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
|
import java.util.Set;
|
|
import java.util.Set;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
|
|
|
|
@@ -59,6 +59,8 @@ public class IotAccidentReportServiceImpl implements IotAccidentReportService {
|
|
|
private PostApi postApi;
|
|
private PostApi postApi;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IotAccidentReportProcessMapper iotAccidentReportProcessMapper;
|
|
private IotAccidentReportProcessMapper iotAccidentReportProcessMapper;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private BpmProcessInstanceApi processInstanceApi;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -114,10 +116,23 @@ public class IotAccidentReportServiceImpl implements IotAccidentReportService {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
iotAccidentReportProcessMapper.insert(processDO);
|
|
iotAccidentReportProcessMapper.insert(processDO);
|
|
|
|
|
+
|
|
|
iotAccidentReportMapper.updateById(iotAccidentReportDO);
|
|
iotAccidentReportMapper.updateById(iotAccidentReportDO);
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public void approvalAccidentFlow(Long id, Integer bpmResult) {
|
|
|
|
|
+// IotAccidentReportDO iotAccidentReportDO = iotAccidentReportMapper.selectById(id);
|
|
|
|
|
+// if (iotAccidentReportDO == null) {throw new ServiceException(new ErrorCode(111,"不存在事故上报信息"));}
|
|
|
|
|
+// if(bpmResult ==2 ){
|
|
|
|
|
+// iotAccidentReportDO.setStatus("finished");
|
|
|
|
|
+// iotAccidentReportMapper.updateById(iotAccidentReportDO);
|
|
|
|
|
+// }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public Set<Long> getDeptIdCompany(Long deviceDept) {
|
|
public Set<Long> getDeptIdCompany(Long deviceDept) {
|
|
|
List<DeptRespDTO> rhdept = deptApi.getDeptByNamePermission("瑞恒兴域");
|
|
List<DeptRespDTO> rhdept = deptApi.getDeptByNamePermission("瑞恒兴域");
|
|
|
Set<Long> rhDeptIds = Collections.emptySet();
|
|
Set<Long> rhDeptIds = Collections.emptySet();
|
|
@@ -168,28 +183,33 @@ public class IotAccidentReportServiceImpl implements IotAccidentReportService {
|
|
|
iotAccidentReport.setDeleted(false);
|
|
iotAccidentReport.setDeleted(false);
|
|
|
iotAccidentReport.setFlowStatus("2");
|
|
iotAccidentReport.setFlowStatus("2");
|
|
|
//获取当前部门的上一级部门也就是项目部的项目经理
|
|
//获取当前部门的上一级部门也就是项目部的项目经理
|
|
|
- Long parentId = dept.getParentId();
|
|
|
|
|
- List<AdminUserRespDTO> parentDeptUsers = adminUserApi.getUserListByDeptIdsNew(Collections.singleton(parentId));
|
|
|
|
|
- List<Long> projectUserIds = roleApi.getRoleUserIds("项目经理");
|
|
|
|
|
- Set<Long> currentUserIds = parentDeptUsers.stream().map(AdminUserRespDTO::getId)
|
|
|
|
|
- .filter(projectUserIds::contains)
|
|
|
|
|
- .collect(Collectors.toSet());
|
|
|
|
|
- if (CollUtil.isEmpty(currentUserIds)){
|
|
|
|
|
- throw new ServiceException(new ErrorCode(22,"未找到项目经理,无法完成事故上报"));
|
|
|
|
|
- }
|
|
|
|
|
- iotAccidentReport.setCurrentPerson(Collections.singleton(currentUserIds.stream().findFirst().get()));
|
|
|
|
|
|
|
+// Long parentId = dept.getParentId();
|
|
|
|
|
+// List<AdminUserRespDTO> parentDeptUsers = adminUserApi.getUserListByDeptIdsNew(Collections.singleton(parentId));
|
|
|
|
|
+// List<Long> projectUserIds = roleApi.getRoleUserIds("项目经理");
|
|
|
|
|
+// Set<Long> currentUserIds = parentDeptUsers.stream().map(AdminUserRespDTO::getId)
|
|
|
|
|
+// .filter(projectUserIds::contains)
|
|
|
|
|
+// .collect(Collectors.toSet());
|
|
|
|
|
+// if (CollUtil.isEmpty(currentUserIds)){
|
|
|
|
|
+// throw new ServiceException(new ErrorCode(22,"未找到项目经理,无法完成事故上报"));
|
|
|
|
|
+// }
|
|
|
|
|
+// iotAccidentReport.setCurrentPerson(Collections.singleton(currentUserIds.stream().findFirst().get()));
|
|
|
iotAccidentReportMapper.insert(iotAccidentReport);
|
|
iotAccidentReportMapper.insert(iotAccidentReport);
|
|
|
- //插入流程明细表
|
|
|
|
|
- IotAccidentReportProcessDO processDO = new IotAccidentReportProcessDO();
|
|
|
|
|
- processDO.setAccidentId(iotAccidentReport.getId());
|
|
|
|
|
- String loginUserNickname = SecurityFrameworkUtils.getLoginUserNickname();
|
|
|
|
|
- processDO.setOperator(loginUserNickname);
|
|
|
|
|
- processDO.setDescription("发起事故事件上报");
|
|
|
|
|
- processDO.setNodeName("发起人");
|
|
|
|
|
- processDO.setDeleted(false);
|
|
|
|
|
- processDO.setCreateTime(LocalDateTime.now());
|
|
|
|
|
- processDO.setStatus("提交上报");
|
|
|
|
|
- iotAccidentReportProcessMapper.insert(processDO);
|
|
|
|
|
|
|
+// //插入流程明细表
|
|
|
|
|
+// IotAccidentReportProcessDO processDO = new IotAccidentReportProcessDO();
|
|
|
|
|
+// processDO.setAccidentId(iotAccidentReport.getId());
|
|
|
|
|
+// String loginUserNickname = SecurityFrameworkUtils.getLoginUserNickname();
|
|
|
|
|
+// processDO.setOperator(loginUserNickname);
|
|
|
|
|
+// processDO.setDescription("发起事故事件上报");
|
|
|
|
|
+// processDO.setNodeName("发起人");
|
|
|
|
|
+// processDO.setDeleted(false);
|
|
|
|
|
+// 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));
|
|
|
// 返回
|
|
// 返回
|
|
|
return iotAccidentReport.getId();
|
|
return iotAccidentReport.getId();
|
|
|
}
|
|
}
|