| | |
| | | import org.sxkj.gd.common.GdMultipartFileUtil; |
| | | import org.sxkj.resource.entity.Attach; |
| | | import org.sxkj.resource.feign.IAttachClient; |
| | | import org.sxkj.system.cache.SysCache; |
| | | import org.sxkj.system.entity.Dept; |
| | | import org.sxkj.system.entity.User; |
| | | import org.sxkj.system.feign.ISysClient; |
| | |
| | | @Autowired |
| | | private IGdTaskResultService gdTaskResultService; |
| | | @Override |
| | | public IPage<GdPatrolTaskVO> selectGdPatrolTaskPage(IPage<GdPatrolTaskVO> page, GdPatrolTaskPageParam gdPatrolTask, List<Long> deptIdList) { |
| | | return page.setRecords(baseMapper.selectGdPatrolTaskPage(page, gdPatrolTask, deptIdList)); |
| | | public IPage<GdPatrolTaskVO> selectGdPatrolTaskPage(IPage<GdPatrolTaskVO> page, GdPatrolTaskPageParam gdPatrolTask) { |
| | | return page.setRecords(baseMapper.selectGdPatrolTaskPage(page, gdPatrolTask, SysCache.getDeptChildIds(Long.valueOf(AuthUtil.getDeptId())))); |
| | | } |
| | | |
| | | |
| | |
| | | GdWorkOrderFlowEntity gdWorkOrderFlowEntity = new GdWorkOrderFlowEntity(); |
| | | gdWorkOrderFlowEntity.setCreateUser(AuthUtil.getUserId()); |
| | | gdWorkOrderFlowEntity.setWorkOrderId(gdPatrolTaskEntity.getId()); |
| | | gdWorkOrderFlowEntity.setFlowName("任务发布"); |
| | | gdWorkOrderFlowEntity.setFlowName(PatrolTaskStatusEnum.PENDING_SIGNING.getStageDesc()); |
| | | gdWorkOrderFlowEntity.setFlowDesc(AuthUtil.getUserName() + " " + DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss") + " 发布任务,等待接单"); |
| | | gdWorkOrderFlowEntity.setOperator(AuthUtil.getUserName()); |
| | | gdWorkOrderFlowEntity.setType(WorkOrderTypeEnum.PATROL_TASK.getValue()); |
| | |
| | | boolean allSubTasksAudited = checkAllSubTasksStatus(subTasks, PatrolTaskStatusEnum.ACCEPTANCE_PASSED); |
| | | // 这里可以根据allSubTasksAudited的结果执行后续逻辑,比如更新工单状态等 |
| | | if (allSubTasksAudited) { |
| | | // 执行工单状态更新逻辑 |
| | | // 1.验收通过,生成报告 |
| | | exportPatrolReport(task.getWorkOrderId()); |
| | | // 2.执行工单状态更新逻辑 |
| | | return updateWorkOrderStatusAndFlow(task.getWorkOrderId(), |
| | | WorkOrderStatusEnum.ACCEPTED_TO_BE_SETTLED); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public File exportPatrolReport(Long patrolTaskId) { |
| | | public boolean exportPatrolReport(Long patrolTaskId) { |
| | | if (patrolTaskId == null) { |
| | | throw new RuntimeException("巡查任务主键不能为空"); |
| | | } |
| | |
| | | String deptName = getDeptName(taskEntity.getCreateDept()); |
| | | try { |
| | | File reportFile = GdPatrolReportWordUtil.generateReportFile(taskEntity, resultList, creatorName, deptName); |
| | | saveAttachFile(reportFile, taskEntity); |
| | | return reportFile; |
| | | return saveAttachFile(reportFile, taskEntity); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException("生成巡查报告失败", e); |
| | | } |
| | |
| | | GdWorkOrderFlowEntity flowEntity = new GdWorkOrderFlowEntity(); |
| | | flowEntity.setCreateUser(AuthUtil.getUserId()); |
| | | flowEntity.setWorkOrderId(workOrderId); |
| | | flowEntity.setFlowName(newStatus.getDesc()); |
| | | flowEntity.setFlowName(newStatus.getStageDesc()); |
| | | |
| | | // 构建流转描述 |
| | | String flowDesc = buildFlowDesc(newStatus, rejectReason); |
| | |
| | | return StringUtil.isBlank(realName) ? "/" : realName; |
| | | } |
| | | |
| | | private BladeFile saveAttachFile(File reportFile, GdPatrolTaskEntity taskEntity) throws IOException { |
| | | private boolean saveAttachFile(File reportFile, GdPatrolTaskEntity taskEntity) throws IOException { |
| | | if (reportFile == null || !reportFile.exists()) { |
| | | throw new RuntimeException("巡查报告文件不存在"); |
| | | } |
| | | String fileName = reportFile.getName(); |
| | | String desiredName = buildReportAttachName(taskEntity, reportFile.getName()); |
| | | BladeFile bladeFile = attachClient.putFile( |
| | | GdMultipartFileUtil.fromFile(reportFile, |
| | | "application/vnd.openxmlformats-officedocument.wordprocessingml.document"), |
| | | fileName |
| | | desiredName |
| | | ); |
| | | if (bladeFile == null || StringUtil.isBlank(bladeFile.getLink())) { |
| | | throw new RuntimeException("附件上传失败"); |
| | | } |
| | | Integer resultType = parseResultType(taskEntity != null ? taskEntity.getPatrolTaskType() : null); |
| | | Attach attach = buildAttachInfo(taskEntity, reportFile, bladeFile, resultType); |
| | | Attach attach = buildAttachInfo(taskEntity, reportFile, bladeFile, resultType, desiredName); |
| | | Boolean saved = attachClient.saveAttachInfo(attach); |
| | | if (!Boolean.TRUE.equals(saved)) { |
| | | log.error("附件信息保存失败,报告文件:"+fileName); |
| | | log.error("附件信息保存失败,报告文件:" + desiredName); |
| | | return false; |
| | | } |
| | | return bladeFile; |
| | | return true; |
| | | } |
| | | |
| | | private Attach buildAttachInfo(GdPatrolTaskEntity taskEntity, File reportFile, BladeFile bladeFile, Integer resultType) { |
| | | private Attach buildAttachInfo(GdPatrolTaskEntity taskEntity, File reportFile, BladeFile bladeFile, Integer resultType, String desiredName) { |
| | | Attach attach = new Attach(); |
| | | attach.setDomainUrl(bladeFile.getDomain()); |
| | | attach.setLink(bladeFile.getLink()); |
| | | attach.setName(bladeFile.getName()); |
| | | attach.setOriginalName(StringUtil.isBlank(bladeFile.getOriginalName()) ? reportFile.getName() : bladeFile.getOriginalName()); |
| | | attach.setName(desiredName); |
| | | attach.setOriginalName(desiredName); |
| | | attach.setAttachSize(reportFile.length()); |
| | | attach.setExtension(FileUtil.getFileExtension(reportFile.getName())); |
| | | attach.setResultType(resultType); |
| | | attach.setPatrolTaskId(String.valueOf(taskEntity != null ? taskEntity.getId() : null)); |
| | | Long createUser = taskEntity != null ? taskEntity.getCreateUser() : null; |
| | | Long updateUser = taskEntity != null ? taskEntity.getUpdateUser() : null; |
| | | Long createDept = taskEntity != null ? taskEntity.getCreateDept() : null; |
| | |
| | | return attach; |
| | | } |
| | | |
| | | private String buildReportAttachName(GdPatrolTaskEntity taskEntity, String fallbackName) { |
| | | String taskNo = taskEntity != null ? taskEntity.getTaskNo() : null; |
| | | if (StringUtil.isBlank(taskNo)) { |
| | | return fallbackName; |
| | | } |
| | | return taskNo + ".docx"; |
| | | } |
| | | |
| | | private Integer parseResultType(String patrolTaskType) { |
| | | if (StringUtil.isBlank(patrolTaskType)) { |
| | | return null; |