| | |
| | | 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, desiredName); |
| | | // Integer resultType = parseResultType(taskEntity != null ? taskEntity.getPatrolTaskType() : null); |
| | | Attach attach = buildAttachInfo(taskEntity, reportFile, bladeFile, taskEntity.getPatrolTaskType(), desiredName); |
| | | Boolean saved = attachClient.saveAttachInfo(attach); |
| | | if (!Boolean.TRUE.equals(saved)) { |
| | | log.error("附件信息保存失败,报告文件:" + desiredName); |
| | |
| | | * @param desiredName 期望文件名 |
| | | * @return 附件信息 |
| | | */ |
| | | private Attach buildAttachInfo(GdPatrolTaskEntity taskEntity, File reportFile, BladeFile bladeFile, Integer resultType, String desiredName) { |
| | | private Attach buildAttachInfo(GdPatrolTaskEntity taskEntity, File reportFile, BladeFile bladeFile, List<List<String>> resultType, String desiredName) { |
| | | Attach attach = new Attach(); |
| | | attach.setDomainUrl(bladeFile.getDomain()); |
| | | attach.setLink(bladeFile.getLink()); |
| | |
| | | attach.setOriginalName(bladeFile.getOriginalName()); |
| | | attach.setAttachSize(reportFile.length()); |
| | | attach.setExtension(FileUtil.getFileExtension(reportFile.getName())); |
| | | attach.setResultType(resultType); |
| | | attach.setResultType(JSON.toJSONString(resultType)); |
| | | attach.setPatrolTaskId(String.valueOf(taskEntity != null ? taskEntity.getId() : null)); |
| | | Long createUser = taskEntity != null ? taskEntity.getCreateUser() : null; |
| | | Long updateUser = taskEntity != null ? taskEntity.getUpdateUser() : null; |
| | |
| | | } else if (StringUtil.isNotBlank(gdPatrolTaskVO.getTaskNo())) { |
| | | param.setName(gdPatrolTaskVO.getTaskNo()); |
| | | } |
| | | if (StringUtil.isNotBlank(gdPatrolTaskVO.getPatrolTaskType())) { |
| | | param.setInspectionType(gdPatrolTaskVO.getPatrolTaskType()); |
| | | } |
| | | // if (StringUtil.isNotBlank(gdPatrolTaskVO.getPatrolTaskType())) { |
| | | // param.setInspectionType(gdPatrolTaskVO.getPatrolTaskType()); |
| | | // } |
| | | if ((gdPatrolTaskVO.getId() != null)) { |
| | | param.setPatrolTaskId(String.valueOf(gdPatrolTaskVO.getId())); |
| | | } |
| | |
| | | param.setSingleTime(DateUtil.format(gdPatrolTaskVO.getExecuteTime(), "yyyy-MM-dd HH:mm:ss")); |
| | | } |
| | | if (StringUtil.isNotBlank(gdPatrolTaskVO.getAreaCode())) { |
| | | param.setRegionCode(gdPatrolTaskVO.getAreaCode()); |
| | | // regionCode : "3600,3608,360802" |
| | | String regionCode = convertAreaCodeToRegionCode(gdPatrolTaskVO.getAreaCode()); |
| | | param.setRegionCode(regionCode); |
| | | } |
| | | if (StringUtil.isNotBlank(gdPatrolTaskVO.getAirportId())) { |
| | | param.setAirportId(gdPatrolTaskVO.getAirportId()); |
| | |
| | | // 机构 |
| | | param.setDeptId(gdPatrolTaskVO.getCreateDept()); |
| | | // 巡检类型 |
| | | // param.setInspectionTypeArr(gdPatrolTaskVO.getPatrolTaskType()); |
| | | param.setInspectionType(gdPatrolTaskVO.getPatrolTaskType()); |
| | | param.setInspectionTypeArr(gdPatrolTaskVO.getPatrolTaskType()); |
| | | // param.setInspectionType(gdPatrolTaskVO.getPatrolTaskType()); |
| | | // 机巢名称 |
| | | param.setAirportName(gdPatrolTaskVO.getDeviceName()); |
| | | param.setStatus("待执行"); |
| | |
| | | return baseMapper.selectListByWorkOrderId(workOrderId); |
| | | } |
| | | |
| | | /** |
| | | * 将区域编码转换为多级行政区划编码格式 |
| | | * |
| | | * @param areaCode 区域编码(如:360802) |
| | | * @return 多级行政区划编码,格式为 "省编码,市编码,区编码"(如:"3600,3608,360802") |
| | | */ |
| | | private String convertAreaCodeToRegionCode(String areaCode) { |
| | | if (StringUtil.isBlank(areaCode)) { |
| | | return null; |
| | | } |
| | | |
| | | // 如果已经是逗号分隔的格式,直接返回 |
| | | if (areaCode.contains(",")) { |
| | | return areaCode; |
| | | } |
| | | |
| | | // 去除空格并确保长度为6位 |
| | | String cleanCode = areaCode.trim(); |
| | | if (cleanCode.length() != 6) { |
| | | log.warn("区域编码格式不正确,期望6位数字,实际为: {}", cleanCode); |
| | | return cleanCode; |
| | | } |
| | | |
| | | try { |
| | | // 提取省、市、区三级编码 |
| | | String provinceCode = cleanCode.substring(0, 2) + "00"; // 省级编码(如:3600) |
| | | String cityCode = cleanCode.substring(0, 4) + "0"; // 市级编码(如:3608) |
| | | String districtCode = cleanCode; // 区级编码(如:360802) |
| | | |
| | | return provinceCode + "," + cityCode + "," + districtCode; |
| | | } catch (Exception e) { |
| | | log.error("区域编码转换失败: {}", e.getMessage()); |
| | | return areaCode; |
| | | } |
| | | } |
| | | |
| | | } |