Commit 47a2fdefeb0b11cf27e750e870debd471be767a2
1 parent
535b6f62
派单及人机材功能迁移
Showing
40 changed files
with
1790 additions
and
387 deletions
urbanops-framework/urbanops-spring-boot-starter-excel/src/main/java/com/zteits/urbanops/framework/excel/core/util/ExcelUtils.java
| ... | ... | @@ -49,4 +49,10 @@ public class ExcelUtils { |
| 49 | 49 | .doReadAllSync(); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | + public static <T> List<T> read(MultipartFile file, Class<T> head, Integer startIndex) throws IOException { | |
| 53 | + return FastExcelFactory.read(file.getInputStream(), head, null) | |
| 54 | + .autoCloseStream(false) // 不要自动关闭,交给 Servlet 自己处理 | |
| 55 | + .headRowNumber(startIndex) | |
| 56 | + .doReadAllSync(); | |
| 57 | + } | |
| 52 | 58 | } | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/assigntasks/AssignTasksController.java
| ... | ... | @@ -33,7 +33,7 @@ import com.zteits.urbanops.module.garden.service.assigntasks.AssignTasksService; |
| 33 | 33 | |
| 34 | 34 | @Tag(name = "管理后台 - 派单任务主表(记录派单任务基本信息)") |
| 35 | 35 | @RestController |
| 36 | -@RequestMapping("/garden/assign-tasks") | |
| 36 | +@RequestMapping("/assign/tasks") | |
| 37 | 37 | @Validated |
| 38 | 38 | public class AssignTasksController { |
| 39 | 39 | |
| ... | ... | @@ -90,6 +90,14 @@ public class AssignTasksController { |
| 90 | 90 | return success(BeanUtils.toBean(pageResult, AssignTasksRespVO.class)); |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | + @GetMapping("/list") | |
| 94 | + @Operation(summary = "获得派单任务主表(记录派单任务基本信息)分页") | |
| 95 | + @PreAuthorize("@ss.hasPermission('garden:assign-tasks:query')") | |
| 96 | + public CommonResult<PageResult<AssignTasksRespVO>> list(@Valid AssignTasksPageReqVO pageReqVO) { | |
| 97 | + PageResult<AssignTasksDO> pageResult = assignTasksService.getAssignTasksPage(pageReqVO); | |
| 98 | + return success(BeanUtils.toBean(pageResult, AssignTasksRespVO.class)); | |
| 99 | + } | |
| 100 | + | |
| 93 | 101 | @GetMapping("/export-excel") |
| 94 | 102 | @Operation(summary = "导出派单任务主表(记录派单任务基本信息) Excel") |
| 95 | 103 | @PreAuthorize("@ss.hasPermission('garden:assign-tasks:export')") | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/assigntasksinfo/AssignTasksInfoController.java
| ... | ... | @@ -31,7 +31,7 @@ import com.zteits.urbanops.module.garden.service.assigntasksinfo.AssignTasksInfo |
| 31 | 31 | |
| 32 | 32 | @Tag(name = "管理后台 - 派单任务-单位关联表(记录单位接收派单后的执行详情)") |
| 33 | 33 | @RestController |
| 34 | -@RequestMapping("/garden/assign-tasks-info") | |
| 34 | +@RequestMapping("/assign/info") | |
| 35 | 35 | @Validated |
| 36 | 36 | public class AssignTasksInfoController { |
| 37 | 37 | |
| ... | ... | @@ -87,7 +87,13 @@ public class AssignTasksInfoController { |
| 87 | 87 | PageResult<AssignTasksInfoDO> pageResult = assignTasksInfoService.getAssignTasksInfoPage(pageReqVO); |
| 88 | 88 | return success(BeanUtils.toBean(pageResult, AssignTasksInfoRespVO.class)); |
| 89 | 89 | } |
| 90 | - | |
| 90 | + @GetMapping("/list") | |
| 91 | + @Operation(summary = "获得派单任务-单位关联表(记录单位接收派单后的执行详情)分页") | |
| 92 | + @PreAuthorize("@ss.hasPermission('garden:assign-tasks-info:query')") | |
| 93 | + public CommonResult<PageResult<AssignTasksInfoRespVO>> list(@Valid AssignTasksInfoPageReqVO pageReqVO) { | |
| 94 | + PageResult<AssignTasksInfoDO> pageResult = assignTasksInfoService.getAssignTasksInfoPage(pageReqVO); | |
| 95 | + return success(BeanUtils.toBean(pageResult, AssignTasksInfoRespVO.class)); | |
| 96 | + } | |
| 91 | 97 | @GetMapping("/export-excel") |
| 92 | 98 | @Operation(summary = "导出派单任务-单位关联表(记录单位接收派单后的执行详情) Excel") |
| 93 | 99 | @PreAuthorize("@ss.hasPermission('garden:assign-tasks-info:export')") |
| ... | ... | @@ -101,4 +107,4 @@ public class AssignTasksInfoController { |
| 101 | 107 | BeanUtils.toBean(list, AssignTasksInfoRespVO.class)); |
| 102 | 108 | } |
| 103 | 109 | |
| 104 | -} | |
| 105 | 110 | \ No newline at end of file |
| 111 | +} | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/costfee/CostFeeController.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.controller.admin.costfee; | |
| 2 | + | |
| 3 | +import com.zteits.urbanops.framework.common.pojo.CommonResult; | |
| 4 | +import com.zteits.urbanops.framework.excel.core.util.ExcelUtils; | |
| 5 | +import com.zteits.urbanops.module.garden.enums.TemplateEnum; | |
| 6 | +import com.zteits.urbanops.module.garden.service.costfee.CostFeeService; | |
| 7 | +import io.swagger.v3.oas.annotations.Operation; | |
| 8 | +import jakarta.servlet.http.HttpServletResponse; | |
| 9 | +import lombok.AllArgsConstructor; | |
| 10 | +import lombok.Data; | |
| 11 | +import lombok.extern.slf4j.Slf4j; | |
| 12 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 13 | +import org.springframework.beans.factory.annotation.Value; | |
| 14 | +import org.springframework.core.io.ClassPathResource; | |
| 15 | +import org.springframework.util.CollectionUtils; | |
| 16 | +import org.springframework.web.bind.annotation.*; | |
| 17 | +import org.springframework.web.multipart.MultipartFile; | |
| 18 | + | |
| 19 | +import java.io.IOException; | |
| 20 | +import java.io.InputStream; | |
| 21 | +import java.io.OutputStream; | |
| 22 | +import java.net.URLEncoder; | |
| 23 | +import java.nio.charset.StandardCharsets; | |
| 24 | +import java.util.*; | |
| 25 | + | |
| 26 | +import static com.zteits.urbanops.framework.common.exception.enums.GlobalErrorCodeConstants.BAD_REQUEST; | |
| 27 | +import static com.zteits.urbanops.framework.common.pojo.CommonResult.success; | |
| 28 | + | |
| 29 | +/** | |
| 30 | + * 人机材公共处理控制器 | |
| 31 | + * 处理Excel导入预览、提交等功能 | |
| 32 | + */ | |
| 33 | +@RestController | |
| 34 | +@RequestMapping("/costfee") | |
| 35 | +@Slf4j | |
| 36 | +public class CostFeeController{ | |
| 37 | + | |
| 38 | + @Autowired | |
| 39 | + private CostFeeService costFeeService; | |
| 40 | + | |
| 41 | + // 静态资源服务器基础URL(从配置文件读取) | |
| 42 | + @Value("${static.resource.server.url}") | |
| 43 | + private String staticResourceServerUrl; | |
| 44 | + | |
| 45 | + @Value("${static.resource.server.enable}") | |
| 46 | + private Boolean staticResourceServerenable; | |
| 47 | + | |
| 48 | + // Excel文件校验相关 | |
| 49 | + private static final List<String> ALLOWED_EXCEL_SUFFIX = Arrays.asList(".xlsx", ".xlsm"); | |
| 50 | + private static final String EXCEL_MIME_TYPE = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; | |
| 51 | + private static final String EXCEL_MIME_TYPE_XLS = "application/vnd.ms-excel"; | |
| 52 | + | |
| 53 | + /** | |
| 54 | + * 导入模板下载 | |
| 55 | + */ | |
| 56 | + @GetMapping("/get-import-template") | |
| 57 | + @Operation(summary = "获得导入用户模板") | |
| 58 | + public void importTemplate(HttpServletResponse response, | |
| 59 | + @RequestParam("templateName") String templateName) throws IOException { | |
| 60 | + // 参数校验 | |
| 61 | + if (templateName == null || templateName.trim().isEmpty()) { | |
| 62 | + response.sendError(HttpServletResponse.SC_BAD_REQUEST, "模板名称不能为空"); | |
| 63 | + return; | |
| 64 | + } | |
| 65 | + | |
| 66 | + // 模板类型校验 | |
| 67 | + TemplateEnum template = TemplateEnum.getByCode(templateName); | |
| 68 | + if (template == null) { | |
| 69 | + response.sendError(HttpServletResponse.SC_BAD_REQUEST, "未知的模板类型: " + templateName); | |
| 70 | + return; | |
| 71 | + } | |
| 72 | + | |
| 73 | + if (staticResourceServerenable) { | |
| 74 | + // 构建完整的静态服务器URL(确保路径正确) | |
| 75 | + String serverUrl = staticResourceServerUrl; | |
| 76 | + if (serverUrl != null && !serverUrl.endsWith("/")) { | |
| 77 | + serverUrl += "/"; // 确保URL以/结尾,避免拼接错误 | |
| 78 | + } | |
| 79 | + | |
| 80 | + String encodedFileName = URLEncoder.encode(template.getName().split("\\.")[0], StandardCharsets.UTF_8.name()); | |
| 81 | + | |
| 82 | + String templateFileName = encodedFileName + "." + template.getName().split("\\.")[1]; | |
| 83 | + | |
| 84 | + String templateUrl = serverUrl + templateFileName; // 包含templates目录 | |
| 85 | + | |
| 86 | + // 方式1:重定向到静态资源服务器 | |
| 87 | + response.sendRedirect(templateUrl); | |
| 88 | + } else { | |
| 89 | + String templateFileName = templateName + "." + template.getName().split("\\.")[1]; | |
| 90 | + | |
| 91 | + // 写入模板文件到响应 | |
| 92 | + writeTemplateToResponse(response, template.getName(), templateFileName); | |
| 93 | + } | |
| 94 | + } | |
| 95 | + | |
| 96 | + | |
| 97 | + /** | |
| 98 | + * Excel文件上传预览 | |
| 99 | + */ | |
| 100 | + @PostMapping("/preview") | |
| 101 | + public CommonResult previewExcel(@RequestParam("file") MultipartFile file, | |
| 102 | + @RequestParam("templateName") String templateName) { | |
| 103 | + // 基础参数校验 | |
| 104 | + if (templateName == null || templateName.trim().isEmpty()) { | |
| 105 | + return CommonResult.error(BAD_REQUEST, "模板名称不能为空"); | |
| 106 | + | |
| 107 | + } | |
| 108 | + // 模板类型校验 | |
| 109 | + TemplateEnum template = TemplateEnum.getByCode(templateName); | |
| 110 | + if (template == null) { | |
| 111 | + return CommonResult.error(BAD_REQUEST, "未知的模板类型"); | |
| 112 | + } | |
| 113 | + String suffix = template.getName().split("\\.")[1]; | |
| 114 | + // 文件有效性校验 | |
| 115 | + if (!isValidExcelFile(file)) { | |
| 116 | + return CommonResult.error(BAD_REQUEST, "请上传有效的Excel文件"); | |
| 117 | + } | |
| 118 | + //部门信息缓存,校验正确性使用 | |
| 119 | + | |
| 120 | + | |
| 121 | + // 解析Excel并获取数据 | |
| 122 | + ImportResult<?> result = parseExcelFile(file, template); | |
| 123 | + | |
| 124 | + // 需预览的数据存入Redis并返回批次ID | |
| 125 | + if (result.isNeedPreview()) { | |
| 126 | + if (CollectionUtils.isEmpty(result.getDataList())) { | |
| 127 | + return CommonResult.error(BAD_REQUEST, "导入的Excel文件不能为空"); | |
| 128 | + | |
| 129 | + } | |
| 130 | + String batchId = costFeeService.saveDataToRedis(result.getDataList(), templateName); | |
| 131 | + Map<String, Object> resultMap = new HashMap<>(2); | |
| 132 | + resultMap.put("batchId", batchId); | |
| 133 | + resultMap.put("totalCount", result.getDataList().size()); | |
| 134 | + resultMap.put("templateName",templateName); | |
| 135 | + return success(resultMap); | |
| 136 | + } | |
| 137 | + // 无需预览的直接返回数据 | |
| 138 | + return success(result.getDataList()); | |
| 139 | + } | |
| 140 | + | |
| 141 | + | |
| 142 | + /** | |
| 143 | + * 分页获取预览数据 | |
| 144 | + */ | |
| 145 | + @GetMapping("/preview-data") | |
| 146 | + public CommonResult getPreviewData(@RequestParam("batchId") String batchId, | |
| 147 | + @RequestParam("templateName") String templateName, | |
| 148 | + @RequestParam(value = "page", defaultValue = "1") int page, | |
| 149 | + @RequestParam(value = "size", defaultValue = "100000") int size) { | |
| 150 | + | |
| 151 | + | |
| 152 | + // 参数校验 | |
| 153 | + if (batchId == null || batchId.trim().isEmpty()) { | |
| 154 | + return CommonResult.error(BAD_REQUEST, "批次ID不能为空"); | |
| 155 | + } | |
| 156 | + if (templateName == null || templateName.trim().isEmpty()) { | |
| 157 | + return CommonResult.error(BAD_REQUEST, "模板名称不能为空"); | |
| 158 | + | |
| 159 | + } | |
| 160 | + if (TemplateEnum.getByCode(templateName) == null) { | |
| 161 | + return CommonResult.error(BAD_REQUEST, "未知的模板类型"); | |
| 162 | + | |
| 163 | + } | |
| 164 | + try { | |
| 165 | + //if (page < 1 || size < 1 || size > 100) { // 限制每页最大100条,避免过大 | |
| 166 | + // return AjaxResult.error("分页参数无效(page≥1,1≤size≤100)"); | |
| 167 | + //} | |
| 168 | + | |
| 169 | + // 模板类型校验 | |
| 170 | + TemplateEnum template = TemplateEnum.getByCode(templateName); | |
| 171 | + Class<?> importClass = template.getImportClass(); // 从枚举获取导入类,避免switch | |
| 172 | + | |
| 173 | + // 从Redis获取分页数据 | |
| 174 | + PageResult<?> pageResult = costFeeService.getPagedDataFromRedis(batchId, templateName, page, size, importClass); | |
| 175 | + return CommonResult.success(pageResult); | |
| 176 | + } catch (Exception e) { | |
| 177 | + log.error("获取预览数据失败", e); | |
| 178 | + throw new RuntimeException(e); | |
| 179 | + } | |
| 180 | + } | |
| 181 | + | |
| 182 | + | |
| 183 | + /** | |
| 184 | + * 提交导入数据到数据库 | |
| 185 | + */ | |
| 186 | + @PostMapping("/submit") | |
| 187 | + public CommonResult submitImport(@RequestParam("batchId") String batchId, | |
| 188 | + @RequestParam("templateName") String templateName, | |
| 189 | + @RequestParam("operator") String operator) { | |
| 190 | + // 参数校验 | |
| 191 | + if (batchId == null || batchId.trim().isEmpty()) { | |
| 192 | + return CommonResult.error(BAD_REQUEST, "批次ID不能为空"); | |
| 193 | + } | |
| 194 | + if (templateName == null || templateName.trim().isEmpty()) { | |
| 195 | + return CommonResult.error(BAD_REQUEST, "模板名称不能为空"); | |
| 196 | + | |
| 197 | + } | |
| 198 | + if (TemplateEnum.getByCode(templateName) == null) { | |
| 199 | + return CommonResult.error(BAD_REQUEST, "未知的模板类型"); | |
| 200 | + | |
| 201 | + } | |
| 202 | + if (operator == null || operator.trim().isEmpty()) { | |
| 203 | + return CommonResult.error(BAD_REQUEST, "操作人不能为空"); | |
| 204 | + } | |
| 205 | + int count = costFeeService.submitImport(batchId, templateName, operator); | |
| 206 | + return CommonResult.success("导入成功,共" + count + "条数据"); | |
| 207 | + } | |
| 208 | + | |
| 209 | + /** | |
| 210 | + * 写入模板文件到响应流 | |
| 211 | + */ | |
| 212 | + private void writeTemplateToResponse(HttpServletResponse response, String filename, String templatePath) throws IOException { | |
| 213 | + // 设置响应头 | |
| 214 | + response.setContentType(EXCEL_MIME_TYPE); | |
| 215 | + response.setCharacterEncoding("UTF-8"); | |
| 216 | + String encodedFileName = URLEncoder.encode(filename, "UTF-8").replaceAll("\\+", "%20"); | |
| 217 | + response.setHeader("Content-Disposition", "attachment;filename=" + encodedFileName); | |
| 218 | + response.setHeader("Cache-Control", "no-store"); // 禁止缓存 | |
| 219 | + | |
| 220 | + // 读取模板文件并写入响应 | |
| 221 | + try (InputStream in = new ClassPathResource("template/" + templatePath).getInputStream(); | |
| 222 | + OutputStream out = response.getOutputStream()) { | |
| 223 | + | |
| 224 | + byte[] buffer = new byte[4096]; | |
| 225 | + int bytesRead; | |
| 226 | + while ((bytesRead = in.read(buffer)) != -1) { | |
| 227 | + out.write(buffer, 0, bytesRead); | |
| 228 | + } | |
| 229 | + out.flush(); | |
| 230 | + } | |
| 231 | + } | |
| 232 | + | |
| 233 | + | |
| 234 | + /** | |
| 235 | + * 校验Excel文件有效性(后缀+MIME类型) | |
| 236 | + */ | |
| 237 | + private boolean isValidExcelFile(MultipartFile file) { | |
| 238 | + if (file == null || file.isEmpty()) { | |
| 239 | + return false; | |
| 240 | + } | |
| 241 | + String fileName = file.getOriginalFilename(); | |
| 242 | + if (fileName == null) { | |
| 243 | + return false; | |
| 244 | + } | |
| 245 | + | |
| 246 | + // 校验文件后缀 | |
| 247 | + boolean validSuffix = ALLOWED_EXCEL_SUFFIX.stream() | |
| 248 | + .anyMatch(suffix -> fileName.toLowerCase().endsWith(suffix)); | |
| 249 | + if (!validSuffix) { | |
| 250 | + return false; | |
| 251 | + } | |
| 252 | + | |
| 253 | + // 4. 校验MIME类型(兼容可能带参数的MIME类型,如charset) | |
| 254 | + String contentType = file.getContentType(); | |
| 255 | + if (contentType == null) { | |
| 256 | + return false; | |
| 257 | + } | |
| 258 | + // 处理MIME类型可能带参数的情况(如"application/xxx;charset=UTF-8") | |
| 259 | + String baseContentType = contentType.split(";")[0].trim(); | |
| 260 | + // 3. 匹配预设的Excel MIME类型(.xlsx/.xlsm或.xls) | |
| 261 | + return EXCEL_MIME_TYPE.equals(baseContentType) | |
| 262 | + || baseContentType.startsWith(EXCEL_MIME_TYPE_XLS); | |
| 263 | + } | |
| 264 | + | |
| 265 | + | |
| 266 | + /** | |
| 267 | + * 解析Excel文件并返回导入结果 | |
| 268 | + */ | |
| 269 | + @SuppressWarnings("unchecked") | |
| 270 | + private <T> ImportResult<T> parseExcelFile(MultipartFile file, TemplateEnum template){ | |
| 271 | + // 获取模板对应的导入类 | |
| 272 | + Class<T> importClass = (Class<T>) template.getImportClass(); | |
| 273 | + List<T> dataList = null; | |
| 274 | + try { | |
| 275 | + // 解析Excel(从指定行开始读取) | |
| 276 | + dataList = ExcelUtils.read(file, importClass, template.getStartIndex()); | |
| 277 | + if (dataList == null) { | |
| 278 | + dataList = Collections.emptyList(); | |
| 279 | + } | |
| 280 | + // 基础数据校验(非空、格式等) | |
| 281 | + costFeeService.validateImportData(dataList, template); | |
| 282 | + | |
| 283 | + } catch (IOException e) { | |
| 284 | + log.error(e.getMessage()); | |
| 285 | + } | |
| 286 | + return new ImportResult<>(dataList, template.isNeedPreview()); | |
| 287 | + } | |
| 288 | + | |
| 289 | + | |
| 290 | + /** | |
| 291 | + * 导入结果封装 | |
| 292 | + */ | |
| 293 | + @Data | |
| 294 | + @AllArgsConstructor | |
| 295 | + private static class ImportResult<T> { | |
| 296 | + private List<T> dataList; | |
| 297 | + private boolean needPreview; | |
| 298 | + } | |
| 299 | + | |
| 300 | + /** | |
| 301 | + * 分页结果封装 | |
| 302 | + */ | |
| 303 | + @Data | |
| 304 | + @AllArgsConstructor | |
| 305 | + public static class PageResult<T> { | |
| 306 | + private int page; | |
| 307 | + private int size; | |
| 308 | + private int total; | |
| 309 | + private List<T> data; | |
| 310 | + } | |
| 311 | +} | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/costfee/WaterFeeBridgeController.java deleted
| 1 | -package com.zteits.urbanops.module.garden.controller.admin.costfee; | |
| 2 | - | |
| 3 | -import com.zteits.urbanops.framework.common.pojo.CommonResult; | |
| 4 | -import com.zteits.urbanops.framework.common.pojo.PageResult; | |
| 5 | -import com.zteits.urbanops.module.garden.controller.admin.waterfee.vo.WaterFeePageReqVO; | |
| 6 | -import com.zteits.urbanops.module.garden.dal.dataobject.waterfee.WaterFeeDO; | |
| 7 | -import com.zteits.urbanops.module.garden.service.waterfee.WaterFeeService; | |
| 8 | -import io.swagger.v3.oas.annotations.Operation; | |
| 9 | -import io.swagger.v3.oas.annotations.tags.Tag; | |
| 10 | -import jakarta.annotation.Resource; | |
| 11 | -import org.springframework.web.bind.annotation.GetMapping; | |
| 12 | -import org.springframework.web.bind.annotation.RequestMapping; | |
| 13 | -import org.springframework.web.bind.annotation.RestController; | |
| 14 | - | |
| 15 | -import static com.zteits.urbanops.framework.common.pojo.CommonResult.success; | |
| 16 | - | |
| 17 | -@Tag(name = "管理后台 - 水费桥接") | |
| 18 | -@RestController | |
| 19 | -@RequestMapping("/costfee/waterfee") | |
| 20 | -public class WaterFeeBridgeController { | |
| 21 | - | |
| 22 | - @Resource | |
| 23 | - private WaterFeeService waterFeeService; | |
| 24 | - | |
| 25 | - @GetMapping("/list") | |
| 26 | - @Operation(summary = "水费录入-列表") | |
| 27 | - public CommonResult<PageResult<WaterFeeDO>> list(WaterFeePageReqVO reqVO) { | |
| 28 | - if (reqVO.getPageSize() == null || reqVO.getPageSize() <= 0) { | |
| 29 | - reqVO.setPageSize(10); | |
| 30 | - } | |
| 31 | - if (reqVO.getPageNo() == null || reqVO.getPageNo() <= 0) { | |
| 32 | - reqVO.setPageNo(1); | |
| 33 | - } | |
| 34 | - return success(waterFeeService.getWaterFeePage(reqVO)); | |
| 35 | - } | |
| 36 | -} | |
| 37 | 0 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/costfee/vo/DepartmentCostImport.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.controller.admin.costfee.vo; | |
| 2 | + | |
| 3 | +import cn.idev.excel.annotation.ExcelProperty; | |
| 4 | +import jakarta.validation.constraints.*; | |
| 5 | +import lombok.AllArgsConstructor; | |
| 6 | +import lombok.Builder; | |
| 7 | +import lombok.Data; | |
| 8 | +import lombok.NoArgsConstructor; | |
| 9 | + | |
| 10 | +import java.math.BigDecimal; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * 部门费用录入对象 td_department_cost | |
| 14 | + * | |
| 15 | + * @author wb | |
| 16 | + * @date 2025-07-14 | |
| 17 | + */ | |
| 18 | +@Data | |
| 19 | +@Builder | |
| 20 | +@AllArgsConstructor | |
| 21 | +@NoArgsConstructor | |
| 22 | +public class DepartmentCostImport { | |
| 23 | + | |
| 24 | + /** 工资年月(如202506) */ | |
| 25 | + @ExcelProperty(index = 0) | |
| 26 | + @NotEmpty(message = "工资年月不能为空") | |
| 27 | + @Pattern(regexp = "^\\d{4}(0[1-9]|1[0-2])$", message = "工资年月格式错误,必须为yyyyMM(如202301)") | |
| 28 | + private String salaryMonth; | |
| 29 | + | |
| 30 | + @ExcelProperty(index = 1) | |
| 31 | + @NotEmpty(message = "费用名称不能为空") | |
| 32 | + @Size(max = 50, message = "费用名称长度不能超过50位") | |
| 33 | + private String expenseName; | |
| 34 | + | |
| 35 | + /** 部门总额 */ | |
| 36 | + @ExcelProperty(index = 2) | |
| 37 | + @NotNull(message = "工资金额不能为空") | |
| 38 | + @Digits(integer = 7, fraction = 2, message = "工资金额格式应为两位小数,且整数部分不超过7位") | |
| 39 | + @DecimalMax(value = "9999999.99", message = "工资金额最大值为9999999.99") | |
| 40 | + private BigDecimal deptTotalCost; | |
| 41 | + | |
| 42 | + /** 人员数量 */ | |
| 43 | + @ExcelProperty(index = 3) | |
| 44 | + @NotNull(message = "部门人数不能为空") | |
| 45 | + @Positive(message = "部门人数必须为正数") | |
| 46 | + private Long personCount; | |
| 47 | + | |
| 48 | + /** 归属公司 */ | |
| 49 | + @ExcelProperty(index = 4) | |
| 50 | + @NotEmpty(message = "所属单位不能为空") | |
| 51 | + private String companyName; | |
| 52 | + | |
| 53 | + @ExcelProperty(index = 5) | |
| 54 | + @Size(max = 200, message = "备注长度不能超过200位") | |
| 55 | + private String remark; | |
| 56 | +} | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/costfee/vo/GardenWasteRecordImport.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.controller.admin.costfee.vo; | |
| 2 | + | |
| 3 | +import cn.idev.excel.annotation.ExcelProperty; | |
| 4 | +import com.fasterxml.jackson.annotation.JsonFormat; | |
| 5 | +import jakarta.validation.constraints.DecimalMax; | |
| 6 | +import jakarta.validation.constraints.DecimalMin; | |
| 7 | +import jakarta.validation.constraints.Digits; | |
| 8 | +import jakarta.validation.constraints.Max; | |
| 9 | +import jakarta.validation.constraints.NotEmpty; | |
| 10 | +import jakarta.validation.constraints.NotNull; | |
| 11 | +import jakarta.validation.constraints.Positive; | |
| 12 | +import jakarta.validation.constraints.Size; | |
| 13 | +import lombok.AllArgsConstructor; | |
| 14 | +import lombok.Builder; | |
| 15 | +import lombok.Data; | |
| 16 | +import lombok.NoArgsConstructor; | |
| 17 | + | |
| 18 | +import java.math.BigDecimal; | |
| 19 | +import java.util.Date; | |
| 20 | + | |
| 21 | +/** | |
| 22 | + * 园林废弃物录入对象 td_garden_waste_record | |
| 23 | + * | |
| 24 | + * @author wb | |
| 25 | + * @date 2025-07-14 | |
| 26 | + */ | |
| 27 | +@Data | |
| 28 | +@Builder | |
| 29 | +@AllArgsConstructor | |
| 30 | +@NoArgsConstructor | |
| 31 | +public class GardenWasteRecordImport { | |
| 32 | + /** 运输日期 */ | |
| 33 | + @ExcelProperty(index = 0) | |
| 34 | + @JsonFormat(pattern = "yyyy-MM-dd") | |
| 35 | + @NotNull(message = "运输日期不能为空") | |
| 36 | + private Date transportDate; | |
| 37 | + | |
| 38 | + /** 废弃物类型(如渣土、树枝等) */ | |
| 39 | + @ExcelProperty(index = 1) | |
| 40 | + @NotEmpty(message = "废弃物类型不能为空") | |
| 41 | + private String wasteType; | |
| 42 | + | |
| 43 | + /** 运输车辆(如小型渣土车等) */ | |
| 44 | + @ExcelProperty(index = 2) | |
| 45 | + @NotEmpty(message = "运输车辆不能为空") | |
| 46 | + private String transportVehicle; | |
| 47 | + | |
| 48 | + /** 车辆载重(吨) */ | |
| 49 | + @ExcelProperty(index = 3) | |
| 50 | + @NotNull(message = "车辆载重不能为空") | |
| 51 | + @Digits(integer = 3, fraction = 2, message = "车辆载重格式应为两位小数,且整数部分不超过3位") | |
| 52 | + @DecimalMin(value = "0.00", message = "车辆载重不能小于0") | |
| 53 | + @DecimalMax(value = "999.99", message = "车辆载重最大值为999.99") | |
| 54 | + private BigDecimal vehicleLoad; | |
| 55 | + | |
| 56 | + /** 运输次数 */ | |
| 57 | + @ExcelProperty(index = 4) | |
| 58 | + @NotNull(message = "运输次数不能为空") | |
| 59 | + @Positive(message = "运输次数必须为正整数") | |
| 60 | + @Max(value = 999, message = "运输次数最大值为999") | |
| 61 | + private Long transportTimes; | |
| 62 | + | |
| 63 | + /** 总费用(元) */ | |
| 64 | + @ExcelProperty(index = 5) | |
| 65 | + @NotNull(message = "总费用不能为空") | |
| 66 | + @Digits(integer = 6, fraction = 2, message = "总费用格式应为两位小数,且整数部分不超过6位") | |
| 67 | + @DecimalMin(value = "0.00", message = "总费用不能小于0") | |
| 68 | + @DecimalMax(value = "100000.00", message = "总费用最大值为100000.00") | |
| 69 | + private BigDecimal totalCost; | |
| 70 | + | |
| 71 | + @ExcelProperty(index = 6) | |
| 72 | + @NotEmpty(message = "归属公司不能为空") | |
| 73 | + private String companyName; | |
| 74 | + | |
| 75 | + @ExcelProperty(index = 7) | |
| 76 | + private String teamIds; | |
| 77 | + | |
| 78 | + @ExcelProperty(index = 8) | |
| 79 | + @Size(max = 200, message = "备注长度不能超过200位") | |
| 80 | + private String remark; | |
| 81 | +} | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/costfee/vo/MechanicalCostImport.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.controller.admin.costfee.vo; | |
| 2 | + | |
| 3 | +import cn.idev.excel.annotation.ExcelProperty; | |
| 4 | +import com.fasterxml.jackson.annotation.JsonFormat; | |
| 5 | +import jakarta.validation.constraints.DecimalMax; | |
| 6 | +import jakarta.validation.constraints.Digits; | |
| 7 | +import jakarta.validation.constraints.Max; | |
| 8 | +import jakarta.validation.constraints.Min; | |
| 9 | +import jakarta.validation.constraints.NotEmpty; | |
| 10 | +import jakarta.validation.constraints.NotNull; | |
| 11 | +import jakarta.validation.constraints.Pattern; | |
| 12 | +import jakarta.validation.constraints.Positive; | |
| 13 | +import jakarta.validation.constraints.Size; | |
| 14 | +import lombok.AllArgsConstructor; | |
| 15 | +import lombok.Builder; | |
| 16 | +import lombok.Data; | |
| 17 | +import lombok.NoArgsConstructor; | |
| 18 | + | |
| 19 | +import java.math.BigDecimal; | |
| 20 | +import java.util.Date; | |
| 21 | + | |
| 22 | +/** | |
| 23 | + * 自有机械费用录入对象 td_mechanical_cost | |
| 24 | + * | |
| 25 | + * @author ServiceManager | |
| 26 | + * @date 2025-07-14 | |
| 27 | + */ | |
| 28 | +@Data | |
| 29 | +@Builder | |
| 30 | +@AllArgsConstructor | |
| 31 | +@NoArgsConstructor | |
| 32 | +public class MechanicalCostImport { | |
| 33 | + | |
| 34 | + /** 机械编号 */ | |
| 35 | + @ExcelProperty(index = 0) | |
| 36 | + @NotEmpty(message = "机械编号不能为空") | |
| 37 | + @Pattern(regexp = "^[A-Za-z0-9_\\-.]+$", message = "机械编码格式:为字母、数字、-、_、.组合字符串") | |
| 38 | + private String mechCode; | |
| 39 | + | |
| 40 | + /** 机械名称 */ | |
| 41 | + @ExcelProperty(index = 1) | |
| 42 | + @NotEmpty(message = "机械名称不能为空") | |
| 43 | + @Size(max = 50, message = "机械名称长度不能超过50位") | |
| 44 | + private String mechName; | |
| 45 | + | |
| 46 | + /** 机械类别(如工具类) */ | |
| 47 | + @ExcelProperty(index = 2) | |
| 48 | + @NotEmpty(message = "机械类型不能为空") | |
| 49 | + private String mechType; | |
| 50 | + | |
| 51 | + /** 车牌号 */ | |
| 52 | + @ExcelProperty(index = 3) | |
| 53 | + private String licensePlate; | |
| 54 | + | |
| 55 | + /** 车辆类别(如汽油、纯电新能源等) */ | |
| 56 | + @ExcelProperty(index = 4) | |
| 57 | + private String vehicleCategory; | |
| 58 | + | |
| 59 | + /** 车辆类型(如大型客车、轻型栏板货车等) */ | |
| 60 | + @ExcelProperty(index = 5) | |
| 61 | + private String vehicleType; | |
| 62 | + | |
| 63 | + /** 单价 */ | |
| 64 | + @ExcelProperty(index = 6) | |
| 65 | + @NotNull(message = "单价不能为空") | |
| 66 | + @Digits(integer = 7, fraction = 2, message = "单价格式应为两位小数,且整数部分不超过7位") | |
| 67 | + @DecimalMax(value = "9999999.99", message = "单价最大值为9999999.99") | |
| 68 | + private BigDecimal unitPrice; | |
| 69 | + | |
| 70 | + /** 数量 */ | |
| 71 | + @ExcelProperty(index = 7) | |
| 72 | + @NotNull(message = "数量不能为空") | |
| 73 | + @Positive(message = "数量必须为正整数") | |
| 74 | + private Long quantity; | |
| 75 | + | |
| 76 | + /** 开始使用时间 */ | |
| 77 | + @ExcelProperty(index = 8) | |
| 78 | + @JsonFormat(pattern = "yyyy-MM-dd") | |
| 79 | + @NotNull(message = "开始使用时间不能为空") | |
| 80 | + private Date startUseTime; | |
| 81 | + | |
| 82 | + /** 使用年限 */ | |
| 83 | + @ExcelProperty(index = 9) | |
| 84 | + @NotNull(message = "使用年限不能为空") | |
| 85 | + @Positive(message = "使用年限必须为正整数") | |
| 86 | + private Long serviceLife; | |
| 87 | + | |
| 88 | + /** 状态(0正常 1停用) */ | |
| 89 | + @ExcelProperty(index = 10) | |
| 90 | + @NotNull(message = "当前状态不能为空") | |
| 91 | + @Min(value = 0, message = "状态只能为0(在用)或1(报废)") | |
| 92 | + @Max(value = 1, message = "状态只能为0(在用)或1(报废)") | |
| 93 | + private Long status; | |
| 94 | + | |
| 95 | + private String statusTxt; | |
| 96 | + | |
| 97 | + /** 归属公司 */ | |
| 98 | + @ExcelProperty(index = 11) | |
| 99 | + @NotEmpty(message = "归属公司不能为空") | |
| 100 | + private String companyName; | |
| 101 | + | |
| 102 | + /** 所属班组 */ | |
| 103 | + @ExcelProperty(index = 12) | |
| 104 | + @NotEmpty(message = "所属班组不能为空") | |
| 105 | + private String teamIds; | |
| 106 | + | |
| 107 | + /** 备注 */ | |
| 108 | + @ExcelProperty(index = 13) | |
| 109 | + @Size(max = 200, message = "备注长度不能超过200位") | |
| 110 | + private String remark; | |
| 111 | + | |
| 112 | + | |
| 113 | + // 设置status时自动更新statusTxt | |
| 114 | + public void setStatus(Long status) { | |
| 115 | + this.status = status; | |
| 116 | + updateStatusTxt(); | |
| 117 | + } | |
| 118 | + | |
| 119 | + private void updateStatusTxt() { | |
| 120 | + if (status == null) { | |
| 121 | + statusTxt = null; | |
| 122 | + return; | |
| 123 | + } | |
| 124 | + | |
| 125 | + switch (status.intValue()) { | |
| 126 | + case 0: | |
| 127 | + statusTxt = "在用"; | |
| 128 | + break; | |
| 129 | + case 1: | |
| 130 | + statusTxt = "报废"; | |
| 131 | + break; | |
| 132 | + default: | |
| 133 | + statusTxt = "未知状态"; | |
| 134 | + } | |
| 135 | + } | |
| 136 | +} | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/costfee/vo/PersonalCostImport.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.controller.admin.costfee.vo; | |
| 2 | + | |
| 3 | +import cn.idev.excel.annotation.ExcelProperty; | |
| 4 | +import jakarta.validation.constraints.DecimalMax; | |
| 5 | +import jakarta.validation.constraints.Digits; | |
| 6 | +import jakarta.validation.constraints.NotEmpty; | |
| 7 | +import jakarta.validation.constraints.NotNull; | |
| 8 | +import jakarta.validation.constraints.Pattern; | |
| 9 | +import jakarta.validation.constraints.Size; | |
| 10 | +import lombok.AllArgsConstructor; | |
| 11 | +import lombok.Builder; | |
| 12 | +import lombok.Data; | |
| 13 | +import lombok.NoArgsConstructor; | |
| 14 | + | |
| 15 | +import java.math.BigDecimal; | |
| 16 | + | |
| 17 | +/** | |
| 18 | + * 人员费用录入 - 个人费用对象 td_personal_cost | |
| 19 | + * | |
| 20 | + * @author wb | |
| 21 | + * @date 2025-07-14 | |
| 22 | + */ | |
| 23 | +@Data | |
| 24 | +@Builder | |
| 25 | +@AllArgsConstructor | |
| 26 | +@NoArgsConstructor | |
| 27 | +public class PersonalCostImport | |
| 28 | +{ | |
| 29 | + | |
| 30 | + /** 工资年月(如202506) */ | |
| 31 | + @ExcelProperty(index = 0) | |
| 32 | + @NotEmpty(message = "工资年月不能为空") | |
| 33 | + @Pattern(regexp = "^\\d{4}(0[1-9]|1[0-2])$", message = "工资年月格式错误,必须为yyyyMM(如202301)") | |
| 34 | + private String salaryMonth; | |
| 35 | + | |
| 36 | + /** 姓名 */ | |
| 37 | + @ExcelProperty(index = 1) | |
| 38 | + @NotEmpty(message = "姓名不能为空") | |
| 39 | + @Size(max = 50, message = "姓名长度不能超过50位") | |
| 40 | + @Pattern(regexp = "^[\u4e00-\u9fa5·]+$", message = "姓名只能包含汉字或点号(·)") | |
| 41 | + private String name; | |
| 42 | + | |
| 43 | + /** 工资金额 */ | |
| 44 | + @ExcelProperty(index = 2) | |
| 45 | + @NotNull(message = "工资金额不能为空") | |
| 46 | + @Digits(integer = 7, fraction = 2, message = "工资金额格式应为两位小数,且整数部分不超过7位") | |
| 47 | + @DecimalMax(value = "9999999.99", message = "工资金额最大值为9999999.99") | |
| 48 | + private BigDecimal salaryAmount; | |
| 49 | + | |
| 50 | + /** 岗位名称 */ | |
| 51 | + @ExcelProperty(index = 3) | |
| 52 | + @NotEmpty(message = "岗位名称不能为空") | |
| 53 | + @Size(max = 50, message = "岗位名称长度不能超过50位") | |
| 54 | + private String postName; | |
| 55 | + | |
| 56 | + /** 岗位类别(如正式员工、外包员工等) */ | |
| 57 | + @ExcelProperty(index = 4) | |
| 58 | + @NotEmpty(message = "岗位类别不能为空") | |
| 59 | + private String postCategory; | |
| 60 | + | |
| 61 | + @ExcelProperty(index = 5) | |
| 62 | + @NotEmpty(message = "所属单位不能为空") | |
| 63 | + private String companyName; | |
| 64 | + | |
| 65 | + @ExcelProperty(index = 6) | |
| 66 | + @NotEmpty(message = "所属班组不能为空") | |
| 67 | + private String teamIds; | |
| 68 | + | |
| 69 | + /** 备注 */ | |
| 70 | + @ExcelProperty(index = 7) | |
| 71 | + @Size(max = 200, message = "备注长度不能超过200位") | |
| 72 | + private String remark; | |
| 73 | +} | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/costfee/vo/RentalMechanicalCostImport.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.controller.admin.costfee.vo; | |
| 2 | + | |
| 3 | +import cn.idev.excel.annotation.ExcelProperty; | |
| 4 | +import com.fasterxml.jackson.annotation.JsonFormat; | |
| 5 | +import jakarta.validation.constraints.DecimalMax; | |
| 6 | +import jakarta.validation.constraints.Digits; | |
| 7 | +import jakarta.validation.constraints.Max; | |
| 8 | +import jakarta.validation.constraints.NotEmpty; | |
| 9 | +import jakarta.validation.constraints.NotNull; | |
| 10 | +import jakarta.validation.constraints.Pattern; | |
| 11 | +import jakarta.validation.constraints.Positive; | |
| 12 | +import jakarta.validation.constraints.Size; | |
| 13 | +import lombok.AllArgsConstructor; | |
| 14 | +import lombok.Builder; | |
| 15 | +import lombok.Data; | |
| 16 | +import lombok.NoArgsConstructor; | |
| 17 | + | |
| 18 | +import java.math.BigDecimal; | |
| 19 | +import java.util.Date; | |
| 20 | + | |
| 21 | +/** | |
| 22 | + * 租赁机械费用录入对象 td_rental_mechanical_cost | |
| 23 | + * | |
| 24 | + * @author wb | |
| 25 | + * @date 2025-07-14 | |
| 26 | + */ | |
| 27 | +@Data | |
| 28 | +@Builder | |
| 29 | +@AllArgsConstructor | |
| 30 | +@NoArgsConstructor | |
| 31 | +public class RentalMechanicalCostImport { | |
| 32 | + | |
| 33 | + /** 机械名称 */ | |
| 34 | + @ExcelProperty(index = 0) | |
| 35 | + @NotEmpty(message = "机械名称不能为空") | |
| 36 | + @Size(max = 50, message = "机械名称长度不能超过50位") | |
| 37 | + private String mechName; | |
| 38 | + | |
| 39 | + /** 机械类型 */ | |
| 40 | + @ExcelProperty(index = 1) | |
| 41 | + @NotEmpty(message = "机械类别不能为空") | |
| 42 | + private String mechType; | |
| 43 | + | |
| 44 | + /** 租赁总价格 */ | |
| 45 | + @ExcelProperty(index = 2) | |
| 46 | + @NotNull(message = "租赁总价格不能为空") | |
| 47 | + @Digits(integer = 7, fraction = 2, message = "租赁总价格格式应为两位小数,且整数部分不超过7位") | |
| 48 | + @DecimalMax(value = "9999999.99", message = "租赁总价格最大值为9999999.99") | |
| 49 | + private BigDecimal rentalTotalPrice; | |
| 50 | + | |
| 51 | + /** 车牌号 */ | |
| 52 | + @ExcelProperty(index = 3) | |
| 53 | + @Size(max = 50, message = "车牌号长度不能超过50位") | |
| 54 | + private String licensePlate; | |
| 55 | + | |
| 56 | + /** 车辆类别(如汽油、纯电新能源等) */ | |
| 57 | + @ExcelProperty(index = 4) | |
| 58 | + private String vehicleCategory; | |
| 59 | + | |
| 60 | + /** 车辆类型(如大型客车、轻型栏板货车等) */ | |
| 61 | + @ExcelProperty(index = 5) | |
| 62 | + private String vehicleType; | |
| 63 | + | |
| 64 | + /** 数量 */ | |
| 65 | + @ExcelProperty(index = 6) | |
| 66 | + @NotNull(message = "数量不能为空") | |
| 67 | + @Positive(message = "数量必须为正整数") | |
| 68 | + private Long quantity; | |
| 69 | + | |
| 70 | + /** 开始使用时间 */ | |
| 71 | + @ExcelProperty(index = 7) | |
| 72 | + @JsonFormat(pattern = "yyyy-MM-dd") | |
| 73 | + @NotNull(message = "开始使用时间不能为空") | |
| 74 | + private Date startUseTime; | |
| 75 | + | |
| 76 | + /** 使用时长(天) */ | |
| 77 | + @ExcelProperty(index = 8) | |
| 78 | + @NotNull(message = "使用时长不能为空") | |
| 79 | + @Positive(message = "使用时长必须为正整数") | |
| 80 | + @Max(value = 3650, message = "使用时长最大值为3650") | |
| 81 | + private Long useDuration; | |
| 82 | + | |
| 83 | + /** 归属公司 */ | |
| 84 | + @ExcelProperty(index = 9) | |
| 85 | + @NotEmpty(message = "归属公司不能为空") | |
| 86 | + private String companyName; | |
| 87 | + | |
| 88 | + /** 所属班组 */ | |
| 89 | + @ExcelProperty(index = 10) | |
| 90 | + @NotEmpty(message = "所属班组不能为空") | |
| 91 | + private String teamIds; | |
| 92 | + | |
| 93 | + /** 权重 */ | |
| 94 | + @ExcelProperty(index = 11) | |
| 95 | + @NotEmpty(message = "权重不能为空") | |
| 96 | + @Pattern(regexp = "^[1-9]\\d*(?:[,][1-9]\\d*)*$", message = "权重必须为正整数,多个时用逗号分隔") | |
| 97 | + private String weight; | |
| 98 | + | |
| 99 | + /** 备注 */ | |
| 100 | + @ExcelProperty(index = 12) | |
| 101 | + @Size(max = 200, message = "备注长度不能超过200位") | |
| 102 | + private String remark; | |
| 103 | + | |
| 104 | +} | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/costfee/vo/WaterFeeImport.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.controller.admin.costfee.vo; | |
| 2 | + | |
| 3 | +import jakarta.validation.constraints.DecimalMax; | |
| 4 | +import jakarta.validation.constraints.Digits; | |
| 5 | +import jakarta.validation.constraints.NotEmpty; | |
| 6 | +import jakarta.validation.constraints.NotNull; | |
| 7 | +import jakarta.validation.constraints.Pattern; | |
| 8 | +import lombok.AllArgsConstructor; | |
| 9 | +import lombok.Builder; | |
| 10 | +import lombok.Data; | |
| 11 | +import lombok.NoArgsConstructor; | |
| 12 | +import cn.idev.excel.annotation.ExcelProperty; | |
| 13 | + | |
| 14 | +import java.math.BigDecimal; | |
| 15 | + | |
| 16 | +/** | |
| 17 | + * 水费录入信息对象 td_water_fee | |
| 18 | + * | |
| 19 | + * @author wb | |
| 20 | + * @date 2025-07-14 | |
| 21 | + */ | |
| 22 | +@Data | |
| 23 | +@Builder | |
| 24 | +@AllArgsConstructor | |
| 25 | +@NoArgsConstructor | |
| 26 | +public class WaterFeeImport | |
| 27 | +{ | |
| 28 | + | |
| 29 | + /** 水费年月(String 类型:@NotEmpty+@Pattern 正常) */ | |
| 30 | + @ExcelProperty(index = 0) | |
| 31 | + @NotEmpty(message = "水费年月不能为空") | |
| 32 | + @Pattern(regexp = "^\\d{4}(0[1-9]|1[0-2])$", message = "水费年月格式错误,必须为yyyyMM(如202301)") | |
| 33 | + private String feeMonth; | |
| 34 | + | |
| 35 | + /** 水表编码(String 类型:@NotEmpty+@Pattern 正常) */ | |
| 36 | + @ExcelProperty(index = 1) | |
| 37 | + @NotEmpty(message = "水表编码不能为空") | |
| 38 | + @Pattern(regexp = "^\\d{9}$", message = "水表编码必须由9位数字组成") | |
| 39 | + private String meterCode; | |
| 40 | + | |
| 41 | + /** 水表地址(非必填,无注解冲突) */ | |
| 42 | + @ExcelProperty(index = 2) | |
| 43 | + private String meterAddress; | |
| 44 | + | |
| 45 | + /** 水表门牌号码(非必填,无注解冲突) */ | |
| 46 | + @ExcelProperty(index = 3) | |
| 47 | + private String meterDoorplate; | |
| 48 | + | |
| 49 | + /** | |
| 50 | + * 用水量(BigDecimal 类型:替换为数值专用注解) | |
| 51 | + * 需求:必填 + 两位小数 + 最大值9999999.99 + 总长度不超过16位(整数7位+小数2位=9位,满足≤16) | |
| 52 | + */ | |
| 53 | + @ExcelProperty(index = 4) | |
| 54 | + @NotNull(message = "用水量不能为空") // 数值类型非空用 @NotNull(替代 @NotEmpty) | |
| 55 | + @Digits(integer = 7, fraction = 2, message = "用水量格式应为两位小数,且整数部分不超过7位") // 替代 @Pattern | |
| 56 | + @DecimalMax(value = "9999999.99", message = "用水量最大值为9999999.99") // 替代 @Max(支持 BigDecimal) | |
| 57 | + private BigDecimal waterUsage; | |
| 58 | + | |
| 59 | + /** 总水费(BigDecimal 类型:同用水量注解逻辑) */ | |
| 60 | + @ExcelProperty(index = 5) | |
| 61 | + @NotNull(message = "总水费不能为空") | |
| 62 | + @Digits(integer = 7, fraction = 2, message = "总水费格式应为两位小数,且整数部分不超过7位") | |
| 63 | + @DecimalMax(value = "9999999.99", message = "总水费最大值为9999999.99") | |
| 64 | + private BigDecimal totalFee; | |
| 65 | +} | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/mechanicalcost/MechanicalCostController.java
| 1 | 1 | package com.zteits.urbanops.module.garden.controller.admin.mechanicalcost; |
| 2 | 2 | |
| 3 | -import com.zteits.urbanops.module.garden.controller.admin.personalcost.vo.PersonalCostRespVO; | |
| 4 | -import com.zteits.urbanops.module.garden.dal.dataobject.teambizdomainrel.TeamBizdomainRelDO; | |
| 5 | -import com.zteits.urbanops.module.garden.enums.CostFeeConstants; | |
| 6 | -import com.zteits.urbanops.module.garden.service.teambizdomainrel.TeamBizdomainRelService; | |
| 7 | -import org.springframework.web.bind.annotation.*; | |
| 8 | -import jakarta.annotation.Resource; | |
| 9 | -import org.springframework.validation.annotation.Validated; | |
| 10 | -import org.springframework.security.access.prepost.PreAuthorize; | |
| 11 | -import io.swagger.v3.oas.annotations.tags.Tag; | |
| 12 | -import io.swagger.v3.oas.annotations.Parameter; | |
| 13 | -import io.swagger.v3.oas.annotations.Operation; | |
| 14 | - | |
| 15 | -import jakarta.validation.constraints.*; | |
| 16 | -import jakarta.validation.*; | |
| 17 | -import jakarta.servlet.http.*; | |
| 18 | -import java.util.*; | |
| 19 | -import java.io.IOException; | |
| 20 | -import java.util.stream.Collectors; | |
| 21 | - | |
| 3 | +import com.zteits.urbanops.framework.apilog.core.annotation.ApiAccessLog; | |
| 4 | +import com.zteits.urbanops.framework.common.pojo.CommonResult; | |
| 22 | 5 | import com.zteits.urbanops.framework.common.pojo.PageParam; |
| 23 | 6 | import com.zteits.urbanops.framework.common.pojo.PageResult; |
| 24 | -import com.zteits.urbanops.framework.common.pojo.CommonResult; | |
| 25 | 7 | import com.zteits.urbanops.framework.common.util.object.BeanUtils; |
| 26 | -import static com.zteits.urbanops.framework.common.pojo.CommonResult.success; | |
| 27 | - | |
| 28 | 8 | import com.zteits.urbanops.framework.excel.core.util.ExcelUtils; |
| 29 | - | |
| 30 | -import com.zteits.urbanops.framework.apilog.core.annotation.ApiAccessLog; | |
| 31 | -import static com.zteits.urbanops.framework.apilog.core.enums.OperateTypeEnum.*; | |
| 32 | - | |
| 33 | -import com.zteits.urbanops.module.garden.controller.admin.mechanicalcost.vo.*; | |
| 9 | +import com.zteits.urbanops.module.garden.controller.admin.mechanicalcost.vo.MechanicalCostPageReqVO; | |
| 10 | +import com.zteits.urbanops.module.garden.controller.admin.mechanicalcost.vo.MechanicalCostRespVO; | |
| 11 | +import com.zteits.urbanops.module.garden.controller.admin.mechanicalcost.vo.MechanicalCostSaveReqVO; | |
| 34 | 12 | import com.zteits.urbanops.module.garden.dal.dataobject.mechanicalcost.MechanicalCostDO; |
| 35 | 13 | import com.zteits.urbanops.module.garden.service.mechanicalcost.MechanicalCostService; |
| 14 | +import io.swagger.v3.oas.annotations.Operation; | |
| 15 | +import io.swagger.v3.oas.annotations.Parameter; | |
| 16 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 17 | +import jakarta.annotation.Resource; | |
| 18 | +import jakarta.servlet.http.HttpServletResponse; | |
| 19 | +import jakarta.validation.Valid; | |
| 20 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 21 | +import org.springframework.validation.annotation.Validated; | |
| 22 | +import org.springframework.web.bind.annotation.*; | |
| 23 | + | |
| 24 | +import java.io.IOException; | |
| 25 | +import java.util.List; | |
| 26 | + | |
| 27 | +import static com.zteits.urbanops.framework.apilog.core.enums.OperateTypeEnum.EXPORT; | |
| 28 | +import static com.zteits.urbanops.framework.common.pojo.CommonResult.success; | |
| 36 | 29 | |
| 37 | 30 | @Tag(name = "管理后台 - 自有机械费用录入") |
| 38 | 31 | @RestController |
| ... | ... | @@ -43,8 +36,6 @@ public class MechanicalCostController { |
| 43 | 36 | @Resource |
| 44 | 37 | private MechanicalCostService mechanicalCostService; |
| 45 | 38 | |
| 46 | - @Resource | |
| 47 | - TeamBizdomainRelService teamBizdomainRelService; | |
| 48 | 39 | |
| 49 | 40 | @PostMapping("/create") |
| 50 | 41 | @Operation(summary = "创建自有机械费用录入") |
| ... | ... | @@ -85,23 +76,7 @@ public class MechanicalCostController { |
| 85 | 76 | @PreAuthorize("@ss.hasPermission('garden:mechanical-cost:query')") |
| 86 | 77 | public CommonResult<MechanicalCostRespVO> getMechanicalCost(@RequestParam("id") Long id) { |
| 87 | 78 | MechanicalCostDO mechanicalCost = mechanicalCostService.getMechanicalCost(id); |
| 88 | - | |
| 89 | - //add by wq 20251119 前端返回集合 | |
| 90 | - MechanicalCostRespVO mechanicalCostRespVO = null; | |
| 91 | - if (mechanicalCost != null) { | |
| 92 | - mechanicalCostRespVO = BeanUtils.toBean(mechanicalCost, MechanicalCostRespVO.class); | |
| 93 | - | |
| 94 | - List<TeamBizdomainRelDO> teamBizdomainRelList = teamBizdomainRelService.getTeamBizdomainRelList(mechanicalCost.getId(), CostFeeConstants.COSTFEE_MECHANICAL); | |
| 95 | - mechanicalCostRespVO.setTeamIds(teamBizdomainRelList); | |
| 96 | - // 提取团队ID列表(使用Stream简化循环) | |
| 97 | - List<String> teamIdList = teamBizdomainRelList.stream() | |
| 98 | - .map(TeamBizdomainRelDO::getTeamId) // 提取teamId | |
| 99 | - .filter(Objects::nonNull) // 过滤null值(可选,根据业务需要) | |
| 100 | - .collect(Collectors.toList()); | |
| 101 | - mechanicalCostRespVO.setTeamIdList(teamIdList); | |
| 102 | - } | |
| 103 | - //add by wq 20251119 前端返回集合 | |
| 104 | - return success(mechanicalCostRespVO); | |
| 79 | + return success(BeanUtils.toBean(mechanicalCost, MechanicalCostRespVO.class)); | |
| 105 | 80 | } |
| 106 | 81 | |
| 107 | 82 | @GetMapping("/page") | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/mechanicalcost/vo/MechanicalCostPageReqVO.java
| 1 | 1 | package com.zteits.urbanops.module.garden.controller.admin.mechanicalcost.vo; |
| 2 | 2 | |
| 3 | -import cn.idev.excel.annotation.ExcelProperty; | |
| 4 | -import com.zteits.urbanops.module.garden.dal.dataobject.teambizdomainrel.TeamBizdomainRelDO; | |
| 5 | -import lombok.*; | |
| 6 | - | |
| 7 | -import java.time.LocalDate; | |
| 8 | -import java.util.*; | |
| 9 | -import io.swagger.v3.oas.annotations.media.Schema; | |
| 10 | 3 | import com.zteits.urbanops.framework.common.pojo.PageParam; |
| 11 | -import java.math.BigDecimal; | |
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 5 | +import lombok.Data; | |
| 12 | 6 | import org.springframework.format.annotation.DateTimeFormat; |
| 7 | + | |
| 8 | +import java.math.BigDecimal; | |
| 9 | +import java.time.LocalDate; | |
| 13 | 10 | import java.time.LocalDateTime; |
| 11 | +import java.util.List; | |
| 14 | 12 | |
| 15 | 13 | import static com.zteits.urbanops.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
| 16 | 14 | |
| ... | ... | @@ -63,7 +61,7 @@ public class MechanicalCostPageReqVO extends PageParam { |
| 63 | 61 | private String companyId; |
| 64 | 62 | |
| 65 | 63 | @Schema(description = "部门id", example = "13645") |
| 66 | - private Long deptId; | |
| 64 | + private List<String> deptId; | |
| 67 | 65 | |
| 68 | 66 | @Schema(description = "备注", example = "随便") |
| 69 | 67 | private String remark; |
| ... | ... | @@ -71,10 +69,4 @@ public class MechanicalCostPageReqVO extends PageParam { |
| 71 | 69 | @Schema(description = "创建时间") |
| 72 | 70 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
| 73 | 71 | private LocalDateTime[] createTime; |
| 74 | - | |
| 75 | - @ExcelProperty("班组") | |
| 76 | - private List<TeamBizdomainRelDO> teamIds; | |
| 77 | - | |
| 78 | - private List teamIdList; | |
| 79 | - | |
| 80 | 72 | } | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/mechanicalcost/vo/MechanicalCostRespVO.java
| 1 | 1 | package com.zteits.urbanops.module.garden.controller.admin.mechanicalcost.vo; |
| 2 | 2 | |
| 3 | -import com.zteits.urbanops.module.garden.dal.dataobject.teambizdomainrel.TeamBizdomainRelDO; | |
| 3 | +import cn.hutool.core.annotation.Alias; | |
| 4 | +import cn.idev.excel.annotation.ExcelIgnoreUnannotated; | |
| 5 | +import cn.idev.excel.annotation.ExcelProperty; | |
| 4 | 6 | import io.swagger.v3.oas.annotations.media.Schema; |
| 5 | -import lombok.*; | |
| 7 | +import lombok.Data; | |
| 6 | 8 | |
| 7 | -import java.time.LocalDate; | |
| 8 | -import java.util.*; | |
| 9 | 9 | import java.math.BigDecimal; |
| 10 | -import org.springframework.format.annotation.DateTimeFormat; | |
| 10 | +import java.time.LocalDate; | |
| 11 | 11 | import java.time.LocalDateTime; |
| 12 | -import cn.idev.excel.annotation.*; | |
| 12 | +import java.util.List; | |
| 13 | 13 | |
| 14 | 14 | @Schema(description = "管理后台 - 自有机械费用录入 Response VO") |
| 15 | 15 | @Data |
| ... | ... | @@ -76,10 +76,6 @@ public class MechanicalCostRespVO { |
| 76 | 76 | @ExcelProperty("归属公司ID") |
| 77 | 77 | private String companyId; |
| 78 | 78 | |
| 79 | - @Schema(description = "部门id", example = "13645") | |
| 80 | - @ExcelProperty("部门id") | |
| 81 | - private Long deptId; | |
| 82 | - | |
| 83 | 79 | @Schema(description = "备注", example = "随便") |
| 84 | 80 | @ExcelProperty("备注") |
| 85 | 81 | private String remark; |
| ... | ... | @@ -88,9 +84,9 @@ public class MechanicalCostRespVO { |
| 88 | 84 | @ExcelProperty("创建时间") |
| 89 | 85 | private LocalDateTime createTime; |
| 90 | 86 | |
| 87 | + @Schema(description = "班组", example = "班组") | |
| 91 | 88 | @ExcelProperty("班组") |
| 92 | - private List<TeamBizdomainRelDO> teamIds; | |
| 93 | - | |
| 94 | - private List teamIdList; | |
| 89 | + @Alias("deptId") | |
| 90 | + private List<String> teamIdList; | |
| 95 | 91 | |
| 96 | 92 | } | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/mechanicalcost/vo/MechanicalCostSaveReqVO.java
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/personalcost/PersonalCostController.java
| ... | ... | @@ -34,14 +34,12 @@ import static com.zteits.urbanops.framework.common.pojo.CommonResult.success; |
| 34 | 34 | |
| 35 | 35 | @Tag(name = "管理后台 - 人员费用录入 - 个人费用") |
| 36 | 36 | @RestController |
| 37 | -@RequestMapping("/garden/personal-cost") | |
| 37 | +@RequestMapping({"/garden/personal-cost", "/costfee/personalcost"}) | |
| 38 | 38 | @Validated |
| 39 | 39 | public class PersonalCostController { |
| 40 | 40 | |
| 41 | 41 | @Resource |
| 42 | 42 | private PersonalCostService personalCostService; |
| 43 | - @Resource | |
| 44 | - TeamBizdomainRelService teamBizdomainRelService; | |
| 45 | 43 | |
| 46 | 44 | @PostMapping("/create") |
| 47 | 45 | @Operation(summary = "创建人员费用录入 - 个人费用") |
| ... | ... | @@ -82,22 +80,7 @@ public class PersonalCostController { |
| 82 | 80 | @PreAuthorize("@ss.hasPermission('garden:personal-cost:query')") |
| 83 | 81 | public CommonResult<PersonalCostRespVO> getPersonalCost(@RequestParam("id") Long id) { |
| 84 | 82 | PersonalCostDO personalCost = personalCostService.getPersonalCost(id); |
| 85 | - //add by wq 20251119 前端返回集合 | |
| 86 | - PersonalCostRespVO personalCostRespVO = null; | |
| 87 | - if (personalCost != null) { | |
| 88 | - personalCostRespVO = BeanUtils.toBean(personalCost, PersonalCostRespVO.class); | |
| 89 | - | |
| 90 | - List<TeamBizdomainRelDO> teamBizdomainRelList = teamBizdomainRelService.getTeamBizdomainRelList(personalCost.getId(), CostFeeConstants.COSTFEE_PERSONAL); | |
| 91 | - personalCostRespVO.setTeamIds(teamBizdomainRelList); | |
| 92 | - // 提取团队ID列表(使用Stream简化循环) | |
| 93 | - List<String> teamIdList = teamBizdomainRelList.stream() | |
| 94 | - .map(TeamBizdomainRelDO::getTeamId) // 提取teamId | |
| 95 | - .filter(Objects::nonNull) // 过滤null值(可选,根据业务需要) | |
| 96 | - .collect(Collectors.toList()); | |
| 97 | - personalCostRespVO.setTeamIdList(teamIdList); | |
| 98 | - } | |
| 99 | - //add by wq 20251119 前端返回集合 | |
| 100 | - return success(personalCostRespVO); | |
| 83 | + return success(BeanUtils.toBean(personalCost, PersonalCostRespVO.class)); | |
| 101 | 84 | } |
| 102 | 85 | |
| 103 | 86 | @GetMapping("/page") |
| ... | ... | @@ -108,6 +91,13 @@ public class PersonalCostController { |
| 108 | 91 | return success(BeanUtils.toBean(pageResult, PersonalCostRespVO.class)); |
| 109 | 92 | } |
| 110 | 93 | |
| 94 | + @GetMapping("/list") | |
| 95 | + @Operation(summary = "获得人员费用录入 - 个人费用分页") | |
| 96 | + @PreAuthorize("@ss.hasPermission('garden:personal-cost:query')") | |
| 97 | + public CommonResult<PageResult<PersonalCostRespVO>> list(@Valid PersonalCostPageReqVO pageReqVO) { | |
| 98 | + PageResult<PersonalCostDO> pageResult = personalCostService.getPersonalCostPage(pageReqVO); | |
| 99 | + return success(BeanUtils.toBean(pageResult, PersonalCostRespVO.class)); | |
| 100 | + } | |
| 111 | 101 | @GetMapping("/export-excel") |
| 112 | 102 | @Operation(summary = "导出人员费用录入 - 个人费用 Excel") |
| 113 | 103 | @PreAuthorize("@ss.hasPermission('garden:personal-cost:export')") | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/personalcost/vo/PersonalCostPageReqVO.java
| 1 | 1 | package com.zteits.urbanops.module.garden.controller.admin.personalcost.vo; |
| 2 | 2 | |
| 3 | -import lombok.*; | |
| 4 | -import java.util.*; | |
| 5 | -import io.swagger.v3.oas.annotations.media.Schema; | |
| 6 | 3 | import com.zteits.urbanops.framework.common.pojo.PageParam; |
| 7 | -import java.math.BigDecimal; | |
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 5 | +import lombok.Data; | |
| 8 | 6 | import org.springframework.format.annotation.DateTimeFormat; |
| 7 | + | |
| 8 | +import java.math.BigDecimal; | |
| 9 | 9 | import java.time.LocalDateTime; |
| 10 | +import java.util.List; | |
| 10 | 11 | |
| 11 | 12 | import static com.zteits.urbanops.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
| 12 | 13 | |
| ... | ... | @@ -36,7 +37,7 @@ public class PersonalCostPageReqVO extends PageParam { |
| 36 | 37 | private String companyId; |
| 37 | 38 | |
| 38 | 39 | @Schema(description = "部门id", example = "18461") |
| 39 | - private Long deptId; | |
| 40 | + private List<String> deptId; | |
| 40 | 41 | |
| 41 | 42 | @Schema(description = "备注", example = "随便") |
| 42 | 43 | private String remark; |
| ... | ... | @@ -45,4 +46,4 @@ public class PersonalCostPageReqVO extends PageParam { |
| 45 | 46 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
| 46 | 47 | private LocalDateTime[] createTime; |
| 47 | 48 | |
| 48 | -} | |
| 49 | 49 | \ No newline at end of file |
| 50 | +} | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/personalcost/vo/PersonalCostRespVO.java
| 1 | 1 | package com.zteits.urbanops.module.garden.controller.admin.personalcost.vo; |
| 2 | 2 | |
| 3 | -import com.zteits.urbanops.module.garden.dal.dataobject.teambizdomainrel.TeamBizdomainRelDO; | |
| 3 | +import cn.hutool.core.annotation.Alias; | |
| 4 | +import cn.idev.excel.annotation.ExcelIgnoreUnannotated; | |
| 5 | +import cn.idev.excel.annotation.ExcelProperty; | |
| 4 | 6 | import io.swagger.v3.oas.annotations.media.Schema; |
| 5 | -import lombok.*; | |
| 6 | -import java.util.*; | |
| 7 | +import lombok.Data; | |
| 8 | + | |
| 7 | 9 | import java.math.BigDecimal; |
| 8 | -import org.springframework.format.annotation.DateTimeFormat; | |
| 9 | 10 | import java.time.LocalDateTime; |
| 10 | -import cn.idev.excel.annotation.*; | |
| 11 | +import java.util.List; | |
| 11 | 12 | |
| 12 | 13 | @Schema(description = "管理后台 - 人员费用录入 - 个人费用 Response VO") |
| 13 | 14 | @Data |
| ... | ... | @@ -46,10 +47,6 @@ public class PersonalCostRespVO { |
| 46 | 47 | @ExcelProperty("归属公司ID") |
| 47 | 48 | private String companyId; |
| 48 | 49 | |
| 49 | - @Schema(description = "部门id", example = "18461") | |
| 50 | - @ExcelProperty("部门id") | |
| 51 | - private Long deptId; | |
| 52 | - | |
| 53 | 50 | @Schema(description = "备注", example = "随便") |
| 54 | 51 | @ExcelProperty("备注") |
| 55 | 52 | private String remark; |
| ... | ... | @@ -58,10 +55,8 @@ public class PersonalCostRespVO { |
| 58 | 55 | @ExcelProperty("创建时间") |
| 59 | 56 | private LocalDateTime createTime; |
| 60 | 57 | |
| 58 | + @Schema(description = "班组", example = "班组") | |
| 61 | 59 | @ExcelProperty("班组") |
| 62 | - private List<TeamBizdomainRelDO> teamIds; | |
| 63 | - | |
| 64 | - private List teamIdList; | |
| 65 | - | |
| 66 | - | |
| 60 | + @Alias("deptId") | |
| 61 | + private List<String> teamIdList; | |
| 67 | 62 | } | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/personalcost/vo/PersonalCostSaveReqVO.java
| ... | ... | @@ -41,12 +41,9 @@ public class PersonalCostSaveReqVO { |
| 41 | 41 | @NotEmpty(message = "归属公司ID不能为空") |
| 42 | 42 | private String companyId; |
| 43 | 43 | |
| 44 | - @Schema(description = "部门id", example = "18461") | |
| 45 | - private Long deptId; | |
| 46 | - | |
| 47 | 44 | @Schema(description = "备注", example = "随便") |
| 48 | 45 | private String remark; |
| 49 | - | |
| 50 | 46 | @ExcelProperty("班组") |
| 51 | 47 | private List<TeamBizdomainRelDO> teamIds; |
| 48 | + | |
| 52 | 49 | } | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/rentalmechanicalcost/RentalMechanicalCostController.java
| ... | ... | @@ -42,8 +42,7 @@ public class RentalMechanicalCostController { |
| 42 | 42 | |
| 43 | 43 | @Resource |
| 44 | 44 | private RentalMechanicalCostService rentalMechanicalCostService; |
| 45 | - @Resource | |
| 46 | - TeamBizdomainRelService teamBizdomainRelService; | |
| 45 | + | |
| 47 | 46 | @PostMapping("/create") |
| 48 | 47 | @Operation(summary = "创建租赁机械费用录入") |
| 49 | 48 | @PreAuthorize("@ss.hasPermission('garden:rental-mechanical-cost:create')") |
| ... | ... | @@ -83,17 +82,7 @@ public class RentalMechanicalCostController { |
| 83 | 82 | @PreAuthorize("@ss.hasPermission('garden:rental-mechanical-cost:query')") |
| 84 | 83 | public CommonResult<RentalMechanicalCostRespVO> getRentalMechanicalCost(@RequestParam("id") Long id) { |
| 85 | 84 | RentalMechanicalCostDO rentalMechanicalCost = rentalMechanicalCostService.getRentalMechanicalCost(id); |
| 86 | - | |
| 87 | - //add by wq 20251119 前端返回集合 | |
| 88 | - RentalMechanicalCostRespVO mechanicalCostRespVO = null; | |
| 89 | - if (rentalMechanicalCost != null) { | |
| 90 | - mechanicalCostRespVO = BeanUtils.toBean(rentalMechanicalCost, RentalMechanicalCostRespVO.class); | |
| 91 | - | |
| 92 | - List<TeamBizdomainRelDO> teamBizdomainRelList = teamBizdomainRelService.getTeamBizdomainRelList(rentalMechanicalCost.getId(), CostFeeConstants.COSTFEE_RENTALMECHANICAL); | |
| 93 | - mechanicalCostRespVO.setTeamIds(teamBizdomainRelList); | |
| 94 | - } | |
| 95 | - //add by wq 20251119 前端返回集合 | |
| 96 | - return success(mechanicalCostRespVO); | |
| 85 | + return success(BeanUtils.toBean(rentalMechanicalCost, RentalMechanicalCostRespVO.class)); | |
| 97 | 86 | } |
| 98 | 87 | |
| 99 | 88 | @GetMapping("/page") | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/rentalmechanicalcost/vo/RentalMechanicalCostPageReqVO.java
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/rentalmechanicalcost/vo/RentalMechanicalCostRespVO.java
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/rentalmechanicalcost/vo/RentalMechanicalCostSaveReqVO.java
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/rentalmechanicalcost/vo/TeamBizdomainRelVo.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.controller.admin.rentalmechanicalcost.vo; | |
| 2 | + | |
| 3 | +import lombok.Data; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * @Classname TeamBizdomainRelVo | |
| 7 | + * @Description | |
| 8 | + * @Date 2025/11/24 20:04 | |
| 9 | + * @Created by wangqian | |
| 10 | + */ | |
| 11 | +@Data | |
| 12 | +public class TeamBizdomainRelVo { | |
| 13 | + /** | |
| 14 | + * 班组编码 | |
| 15 | + */ | |
| 16 | + private String teamId; | |
| 17 | + /** | |
| 18 | + * 班组名称 | |
| 19 | + */ | |
| 20 | + private String teamName; | |
| 21 | + /** | |
| 22 | + * 班组名称 | |
| 23 | + */ | |
| 24 | + private Long weight; | |
| 25 | +} | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/wasterecord/vo/WasteRecordPageReqVO.java
| 1 | 1 | package com.zteits.urbanops.module.garden.controller.admin.wasterecord.vo; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.annotation.Alias; | |
| 3 | 4 | import cn.idev.excel.annotation.ExcelProperty; |
| 4 | -import com.zteits.urbanops.module.garden.dal.dataobject.teambizdomainrel.TeamBizdomainRelDO; | |
| 5 | -import lombok.*; | |
| 6 | - | |
| 7 | -import java.time.LocalDate; | |
| 8 | -import java.util.*; | |
| 9 | -import io.swagger.v3.oas.annotations.media.Schema; | |
| 10 | 5 | import com.zteits.urbanops.framework.common.pojo.PageParam; |
| 11 | -import java.math.BigDecimal; | |
| 6 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 7 | +import lombok.Data; | |
| 12 | 8 | import org.springframework.format.annotation.DateTimeFormat; |
| 9 | + | |
| 10 | +import java.math.BigDecimal; | |
| 11 | +import java.time.LocalDate; | |
| 13 | 12 | import java.time.LocalDateTime; |
| 13 | +import java.util.List; | |
| 14 | 14 | |
| 15 | 15 | import static com.zteits.urbanops.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
| 16 | 16 | |
| ... | ... | @@ -56,7 +56,9 @@ public class WasteRecordPageReqVO extends PageParam { |
| 56 | 56 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
| 57 | 57 | private LocalDateTime[] createTime; |
| 58 | 58 | |
| 59 | + @Schema(description = "班组", example = "班组") | |
| 59 | 60 | @ExcelProperty("班组") |
| 60 | - private List<TeamBizdomainRelDO> teamIds; | |
| 61 | + @Alias("deptId") | |
| 62 | + private List<String> teamIdList; | |
| 61 | 63 | |
| 62 | 64 | } | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/wasterecord/vo/WasteRecordRespVO.java
| 1 | 1 | package com.zteits.urbanops.module.garden.controller.admin.wasterecord.vo; |
| 2 | 2 | |
| 3 | -import com.zteits.urbanops.module.garden.dal.dataobject.teambizdomainrel.TeamBizdomainRelDO; | |
| 3 | +import cn.hutool.core.annotation.Alias; | |
| 4 | +import cn.idev.excel.annotation.ExcelIgnoreUnannotated; | |
| 5 | +import cn.idev.excel.annotation.ExcelProperty; | |
| 4 | 6 | import io.swagger.v3.oas.annotations.media.Schema; |
| 5 | -import lombok.*; | |
| 7 | +import lombok.Data; | |
| 6 | 8 | |
| 7 | -import java.time.LocalDate; | |
| 8 | -import java.util.*; | |
| 9 | 9 | import java.math.BigDecimal; |
| 10 | -import org.springframework.format.annotation.DateTimeFormat; | |
| 10 | +import java.time.LocalDate; | |
| 11 | 11 | import java.time.LocalDateTime; |
| 12 | -import cn.idev.excel.annotation.*; | |
| 12 | +import java.util.List; | |
| 13 | 13 | |
| 14 | 14 | @Schema(description = "管理后台 - 园林废弃物录入 Response VO") |
| 15 | 15 | @Data |
| ... | ... | @@ -56,10 +56,6 @@ public class WasteRecordRespVO { |
| 56 | 56 | @ExcelProperty("归属公司ID") |
| 57 | 57 | private String companyId; |
| 58 | 58 | |
| 59 | - @Schema(description = "部门id", example = "26656") | |
| 60 | - @ExcelProperty("部门id") | |
| 61 | - private Long deptId; | |
| 62 | - | |
| 63 | 59 | @Schema(description = "备注", example = "你说的对") |
| 64 | 60 | @ExcelProperty("备注") |
| 65 | 61 | private String remark; |
| ... | ... | @@ -68,7 +64,9 @@ public class WasteRecordRespVO { |
| 68 | 64 | @ExcelProperty("创建时间") |
| 69 | 65 | private LocalDateTime createTime; |
| 70 | 66 | |
| 67 | + @Schema(description = "班组", example = "班组") | |
| 71 | 68 | @ExcelProperty("班组") |
| 72 | - private List<TeamBizdomainRelDO> teamIds; | |
| 69 | + @Alias("deptId") | |
| 70 | + private List<String> teamIdList; | |
| 73 | 71 | |
| 74 | 72 | } | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/waterfee/WaterFeeController.java
| ... | ... | @@ -31,7 +31,7 @@ import com.zteits.urbanops.module.garden.service.waterfee.WaterFeeService; |
| 31 | 31 | |
| 32 | 32 | @Tag(name = "管理后台 - 水费录入信息") |
| 33 | 33 | @RestController |
| 34 | -@RequestMapping("/garden/water-fee") | |
| 34 | +@RequestMapping({"/costfee/waterfee", "/garden/water-fee"}) | |
| 35 | 35 | @Validated |
| 36 | 36 | public class WaterFeeController { |
| 37 | 37 | |
| ... | ... | @@ -87,6 +87,13 @@ public class WaterFeeController { |
| 87 | 87 | PageResult<WaterFeeDO> pageResult = waterFeeService.getWaterFeePage(pageReqVO); |
| 88 | 88 | return success(BeanUtils.toBean(pageResult, WaterFeeRespVO.class)); |
| 89 | 89 | } |
| 90 | + @GetMapping("/list") | |
| 91 | + @Operation(summary = "获得水费录入信息分页") | |
| 92 | + @PreAuthorize("@ss.hasPermission('garden:water-fee:query')") | |
| 93 | + public CommonResult<PageResult<WaterFeeRespVO>> list(@Valid WaterFeePageReqVO pageReqVO) { | |
| 94 | + PageResult<WaterFeeDO> pageResult = waterFeeService.getWaterFeePage(pageReqVO); | |
| 95 | + return success(BeanUtils.toBean(pageResult, WaterFeeRespVO.class)); | |
| 96 | + } | |
| 90 | 97 | |
| 91 | 98 | @GetMapping("/export-excel") |
| 92 | 99 | @Operation(summary = "导出水费录入信息 Excel") |
| ... | ... | @@ -101,4 +108,4 @@ public class WaterFeeController { |
| 101 | 108 | BeanUtils.toBean(list, WaterFeeRespVO.class)); |
| 102 | 109 | } |
| 103 | 110 | |
| 104 | -} | |
| 105 | 111 | \ No newline at end of file |
| 112 | +} | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/dataobject/mechanicalcost/MechanicalCostDO.java
| 1 | 1 | package com.zteits.urbanops.module.garden.dal.dataobject.mechanicalcost; |
| 2 | 2 | |
| 3 | +import com.baomidou.mybatisplus.annotation.KeySequence; | |
| 4 | +import com.baomidou.mybatisplus.annotation.TableField; | |
| 5 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 6 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 7 | +import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; | |
| 8 | +import com.zteits.urbanops.framework.mybatis.core.dataobject.BaseDO; | |
| 3 | 9 | import lombok.*; |
| 4 | 10 | |
| 5 | -import java.time.LocalDate; | |
| 6 | -import java.util.*; | |
| 7 | 11 | import java.math.BigDecimal; |
| 8 | -import java.time.LocalDateTime; | |
| 9 | -import java.time.LocalDateTime; | |
| 10 | -import com.baomidou.mybatisplus.annotation.*; | |
| 11 | -import com.zteits.urbanops.framework.mybatis.core.dataobject.BaseDO; | |
| 12 | +import java.time.LocalDate; | |
| 13 | +import java.util.List; | |
| 12 | 14 | |
| 13 | 15 | /** |
| 14 | 16 | * 自有机械费用录入 DO |
| 15 | 17 | * |
| 16 | 18 | * @author 超级管理员 |
| 17 | 19 | */ |
| 18 | -@TableName("garden_mechanical_cost") | |
| 20 | +@TableName( value = "garden_mechanical_cost", autoResultMap = true) | |
| 19 | 21 | @KeySequence("garden_mechanical_cost_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 |
| 20 | 22 | @Data |
| 21 | 23 | @EqualsAndHashCode(callSuper = true) |
| ... | ... | @@ -89,7 +91,8 @@ public class MechanicalCostDO extends BaseDO { |
| 89 | 91 | /** |
| 90 | 92 | * 部门id |
| 91 | 93 | */ |
| 92 | - private Long deptId; | |
| 94 | + @TableField(typeHandler = JacksonTypeHandler.class) | |
| 95 | + private List<String> deptId; | |
| 93 | 96 | /** |
| 94 | 97 | * 备注 |
| 95 | 98 | */ | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/dataobject/personalcost/PersonalCostDO.java
| 1 | -package com.zteits.urbanops.module.garden.dal.dataobject.personalcost; | |
| 2 | - | |
| 3 | -import lombok.*; | |
| 4 | -import java.util.*; | |
| 5 | -import java.math.BigDecimal; | |
| 6 | -import java.time.LocalDateTime; | |
| 7 | -import java.time.LocalDateTime; | |
| 8 | -import com.baomidou.mybatisplus.annotation.*; | |
| 9 | -import com.zteits.urbanops.framework.mybatis.core.dataobject.BaseDO; | |
| 10 | - | |
| 11 | -/** | |
| 12 | - * 人员费用录入 - 个人费用 DO | |
| 13 | - * | |
| 14 | - * @author 超级管理员 | |
| 15 | - */ | |
| 16 | -@TableName("garden_personal_cost") | |
| 17 | -@KeySequence("garden_personal_cost_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | |
| 18 | -@Data | |
| 19 | -@EqualsAndHashCode(callSuper = true) | |
| 20 | -@ToString(callSuper = true) | |
| 21 | -@Builder | |
| 22 | -@NoArgsConstructor | |
| 23 | -@AllArgsConstructor | |
| 24 | -public class PersonalCostDO extends BaseDO { | |
| 25 | - | |
| 26 | - /** | |
| 27 | - * 记录ID,自增主键 | |
| 28 | - */ | |
| 29 | - @TableId | |
| 30 | - private Long id; | |
| 31 | - /** | |
| 32 | - * 工资年月(如202506) | |
| 33 | - */ | |
| 34 | - private String salaryMonth; | |
| 35 | - /** | |
| 36 | - * 姓名 | |
| 37 | - */ | |
| 38 | - private String name; | |
| 39 | - /** | |
| 40 | - * 工资金额 | |
| 41 | - */ | |
| 42 | - private BigDecimal salaryAmount; | |
| 43 | - /** | |
| 44 | - * 岗位名称 | |
| 45 | - */ | |
| 46 | - private String postName; | |
| 47 | - /** | |
| 48 | - * 岗位类别(如正式员工、外包员工等) | |
| 49 | - */ | |
| 50 | - private String postCategory; | |
| 51 | - /** | |
| 52 | - * 归属公司 | |
| 53 | - */ | |
| 54 | - private String companyName; | |
| 55 | - /** | |
| 56 | - * 归属公司ID | |
| 57 | - */ | |
| 58 | - private String companyId; | |
| 59 | - /** | |
| 60 | - * 部门id | |
| 61 | - */ | |
| 62 | - private Long deptId; | |
| 63 | - /** | |
| 64 | - * 备注 | |
| 65 | - */ | |
| 66 | - private String remark; | |
| 67 | - | |
| 68 | - | |
| 69 | -} | |
| 70 | 1 | \ No newline at end of file |
| 2 | +package com.zteits.urbanops.module.garden.dal.dataobject.personalcost; | |
| 3 | + | |
| 4 | +import com.baomidou.mybatisplus.annotation.KeySequence; | |
| 5 | +import com.baomidou.mybatisplus.annotation.TableField; | |
| 6 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 7 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 8 | +import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; | |
| 9 | +import com.zteits.urbanops.framework.mybatis.core.dataobject.BaseDO; | |
| 10 | +import lombok.*; | |
| 11 | + | |
| 12 | +import java.math.BigDecimal; | |
| 13 | +import java.util.List; | |
| 14 | + | |
| 15 | +/** | |
| 16 | + * 人员费用录入 - 个人费用 DO | |
| 17 | + * | |
| 18 | + * @author 超级管理员 | |
| 19 | + */ | |
| 20 | +@TableName(value = "garden_personal_cost", autoResultMap = true) | |
| 21 | +@KeySequence("garden_personal_cost_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | |
| 22 | +@Data | |
| 23 | +@EqualsAndHashCode(callSuper = true) | |
| 24 | +@ToString(callSuper = true) | |
| 25 | +@Builder | |
| 26 | +@NoArgsConstructor | |
| 27 | +@AllArgsConstructor | |
| 28 | +public class PersonalCostDO extends BaseDO { | |
| 29 | + | |
| 30 | + /** | |
| 31 | + * 记录ID,自增主键 | |
| 32 | + */ | |
| 33 | + @TableId | |
| 34 | + private Long id; | |
| 35 | + /** | |
| 36 | + * 工资年月(如202506) | |
| 37 | + */ | |
| 38 | + private String salaryMonth; | |
| 39 | + /** | |
| 40 | + * 姓名 | |
| 41 | + */ | |
| 42 | + private String name; | |
| 43 | + /** | |
| 44 | + * 工资金额 | |
| 45 | + */ | |
| 46 | + private BigDecimal salaryAmount; | |
| 47 | + /** | |
| 48 | + * 岗位名称 | |
| 49 | + */ | |
| 50 | + private String postName; | |
| 51 | + /** | |
| 52 | + * 岗位类别(如正式员工、外包员工等) | |
| 53 | + */ | |
| 54 | + private String postCategory; | |
| 55 | + /** | |
| 56 | + * 归属公司 | |
| 57 | + */ | |
| 58 | + private String companyName; | |
| 59 | + /** | |
| 60 | + * 归属公司ID | |
| 61 | + */ | |
| 62 | + private String companyId; | |
| 63 | + /** | |
| 64 | + * 部门id | |
| 65 | + */ | |
| 66 | + @TableField(typeHandler = JacksonTypeHandler.class) | |
| 67 | + private List<String> deptId; | |
| 68 | + /** | |
| 69 | + * 备注 | |
| 70 | + */ | |
| 71 | + private String remark; | |
| 72 | + | |
| 73 | + | |
| 74 | +} | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/dataobject/rentalmechanicalcost/RentalMechanicalCostDO.java
| 1 | 1 | package com.zteits.urbanops.module.garden.dal.dataobject.rentalmechanicalcost; |
| 2 | 2 | |
| 3 | +import com.baomidou.mybatisplus.annotation.KeySequence; | |
| 4 | +import com.baomidou.mybatisplus.annotation.TableField; | |
| 5 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 6 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 7 | +import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; | |
| 8 | +import com.zteits.urbanops.framework.mybatis.core.dataobject.BaseDO; | |
| 9 | +import com.zteits.urbanops.module.garden.controller.admin.rentalmechanicalcost.vo.TeamBizdomainRelVo; | |
| 3 | 10 | import lombok.*; |
| 4 | 11 | |
| 5 | -import java.time.LocalDate; | |
| 6 | -import java.util.*; | |
| 7 | 12 | import java.math.BigDecimal; |
| 8 | -import java.time.LocalDateTime; | |
| 9 | -import java.time.LocalDateTime; | |
| 10 | -import com.baomidou.mybatisplus.annotation.*; | |
| 11 | -import com.zteits.urbanops.framework.mybatis.core.dataobject.BaseDO; | |
| 13 | +import java.time.LocalDate; | |
| 14 | +import java.util.List; | |
| 12 | 15 | |
| 13 | 16 | /** |
| 14 | 17 | * 租赁机械费用录入 DO |
| 15 | 18 | * |
| 16 | 19 | * @author 超级管理员 |
| 17 | 20 | */ |
| 18 | -@TableName("garden_rental_mechanical_cost") | |
| 21 | +@TableName(value = "garden_rental_mechanical_cost", autoResultMap = true) | |
| 19 | 22 | @KeySequence("garden_rental_mechanical_cost_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 |
| 20 | 23 | @Data |
| 21 | 24 | @EqualsAndHashCode(callSuper = true) |
| ... | ... | @@ -85,7 +88,8 @@ public class RentalMechanicalCostDO extends BaseDO { |
| 85 | 88 | /** |
| 86 | 89 | * 班组ID数组(多选) |
| 87 | 90 | */ |
| 88 | - private String teamIds; | |
| 91 | + @TableField(typeHandler = JacksonTypeHandler.class) | |
| 92 | + private List<TeamBizdomainRelVo> teamIds; | |
| 89 | 93 | /** |
| 90 | 94 | * 道路ID数组(多选) |
| 91 | 95 | */ | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/dataobject/wasterecord/WasteRecordDO.java
| 1 | 1 | package com.zteits.urbanops.module.garden.dal.dataobject.wasterecord; |
| 2 | 2 | |
| 3 | +import com.baomidou.mybatisplus.annotation.KeySequence; | |
| 4 | +import com.baomidou.mybatisplus.annotation.TableField; | |
| 5 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 6 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 7 | +import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; | |
| 8 | +import com.zteits.urbanops.framework.mybatis.core.dataobject.BaseDO; | |
| 3 | 9 | import lombok.*; |
| 4 | 10 | |
| 5 | -import java.time.LocalDate; | |
| 6 | -import java.util.*; | |
| 7 | -import java.math.BigDecimal; | |
| 8 | 11 | import java.math.BigDecimal; |
| 9 | -import java.math.BigDecimal; | |
| 10 | -import java.time.LocalDateTime; | |
| 11 | -import java.time.LocalDateTime; | |
| 12 | -import com.baomidou.mybatisplus.annotation.*; | |
| 13 | -import com.zteits.urbanops.framework.mybatis.core.dataobject.BaseDO; | |
| 12 | +import java.time.LocalDate; | |
| 13 | +import java.util.List; | |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * 园林废弃物录入 DO |
| ... | ... | @@ -71,7 +71,8 @@ public class WasteRecordDO extends BaseDO { |
| 71 | 71 | /** |
| 72 | 72 | * 部门id |
| 73 | 73 | */ |
| 74 | - private Long deptId; | |
| 74 | + @TableField(typeHandler = JacksonTypeHandler.class) | |
| 75 | + private List<String> deptId; | |
| 75 | 76 | /** |
| 76 | 77 | * 状态(0正常 1停用) |
| 77 | 78 | */ | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/enums/CostFeeConstants.java
| ... | ... | @@ -19,4 +19,8 @@ public class CostFeeConstants { |
| 19 | 19 | public static final String COSTFEE_MECHANICAL = "costFee_mechanical"; |
| 20 | 20 | |
| 21 | 21 | public static final String COSTFEE_RENTALMECHANICAL = "costFee_rentalmechanical"; |
| 22 | + | |
| 23 | + | |
| 24 | + public static final String MECH_TYPE = "车类"; | |
| 25 | + | |
| 22 | 26 | } | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/enums/ErrorCodeConstants.java
| ... | ... | @@ -27,6 +27,8 @@ public interface ErrorCodeConstants { |
| 27 | 27 | |
| 28 | 28 | ErrorCode COST_FEE_NOT_EXISTS = new ErrorCode(1-100-003-000, "费用已录入"); |
| 29 | 29 | |
| 30 | + ErrorCode COST_FEE_NOT_EXISTS_001 = new ErrorCode(1-100-003-001, "未找到对应的导入类"); | |
| 31 | + | |
| 30 | 32 | // ========== 部门费用费用 ========== |
| 31 | 33 | ErrorCode DEPARTMENT_COST_NOT_EXISTS_01 = new ErrorCode(1-100-003-001, "部门费用为空"); |
| 32 | 34 | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/enums/TemplateEnum.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.enums; | |
| 2 | + | |
| 3 | +import com.zteits.urbanops.module.garden.controller.admin.costfee.vo.*; | |
| 4 | +import lombok.AllArgsConstructor; | |
| 5 | +import lombok.Getter; | |
| 6 | + | |
| 7 | +import java.util.HashMap; | |
| 8 | +import java.util.Map; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * Excel导入模板枚举 | |
| 12 | + * 存储模板编码、名称、起始行索引及对应的数据导入类 | |
| 13 | + */ | |
| 14 | +@Getter | |
| 15 | +@AllArgsConstructor | |
| 16 | +public enum TemplateEnum { | |
| 17 | + | |
| 18 | + // 模板枚举值:编码、名称、起始行索引、导入数据类,是否需要预览 | |
| 19 | + COSTFEE_WATER( | |
| 20 | + "costFree_water", | |
| 21 | + "水表费用导入模板.xlsx", | |
| 22 | + 2, | |
| 23 | + WaterFeeImport.class, | |
| 24 | + true | |
| 25 | + ), | |
| 26 | + COSTFEE_PERSONAL( // 修正原枚举名拼写错误(PRESONAL → PERSONAL) | |
| 27 | + "costFree_presonal", | |
| 28 | + "人员费用导入模板.xlsx", | |
| 29 | + 2, | |
| 30 | + PersonalCostImport.class, | |
| 31 | + true // 新增默认值 | |
| 32 | + ); | |
| 33 | +// COSTFEE_DEPARTMENT( | |
| 34 | +// "costFee_department", | |
| 35 | +// "综合费用导入模板.xlsx", | |
| 36 | +// 1, | |
| 37 | +// DepartmentCostImport.class, | |
| 38 | +// true // 新增默认值 | |
| 39 | +// ), | |
| 40 | +// COSTFEE_GARDENWASTE( | |
| 41 | +// "costFee_gardenWaste", | |
| 42 | +// "园林废弃物费用导入模板.xlsx", | |
| 43 | +// 1, | |
| 44 | +// GardenWasteRecordImport.class, | |
| 45 | +// true // 新增默认值 | |
| 46 | +// ), | |
| 47 | +// COSTFEE_MECHANICAL( | |
| 48 | +// "costFee_mechanical", | |
| 49 | +// "自有机械费用导入模板.xlsx", | |
| 50 | +// 1, | |
| 51 | +// MechanicalCostImport.class, | |
| 52 | +// true // 新增默认值 | |
| 53 | +// ), | |
| 54 | +// COSTFEE_RENTALMECHANICAL( | |
| 55 | +// "costFee_rentalmechanical", | |
| 56 | +// "租赁机械费用导入模板.xlsx", | |
| 57 | +// 1, | |
| 58 | +// RentalMechanicalCostImport.class, | |
| 59 | +// true // 新增默认值 | |
| 60 | +// ); | |
| 61 | + | |
| 62 | + // 模板编码(前端传递的标识) | |
| 63 | + private final String code; | |
| 64 | + // 模板名称(用于下载时的文件名) | |
| 65 | + private final String name; | |
| 66 | + // 数据起始行索引(Excel中从第几行开始读取数据) | |
| 67 | + private final int startIndex; | |
| 68 | + // 导入数据对应的实体类(用于反射解析Excel) | |
| 69 | + private final Class<?> importClass; | |
| 70 | + // 是否需要预览功能 | |
| 71 | + private final boolean needPreview; | |
| 72 | + | |
| 73 | + // 缓存:code → 枚举映射(优化查询性能) | |
| 74 | + private static final Map<String, TemplateEnum> CODE_MAP = new HashMap<>(); | |
| 75 | + | |
| 76 | + // 静态块初始化缓存 | |
| 77 | + static { | |
| 78 | + for (TemplateEnum template : values()) { | |
| 79 | + CODE_MAP.put(template.code, template); | |
| 80 | + } | |
| 81 | + } | |
| 82 | + | |
| 83 | + /** | |
| 84 | + * 根据编码获取枚举(优化查询性能) | |
| 85 | + */ | |
| 86 | + public static TemplateEnum getByCode(String code) { | |
| 87 | + // 空值校验 | |
| 88 | + if (code == null || code.trim().isEmpty()) { | |
| 89 | + throw new RuntimeException("模板编码不能为空"); | |
| 90 | + } | |
| 91 | + // 从缓存获取,避免循环遍历 | |
| 92 | + TemplateEnum template = CODE_MAP.get(code); | |
| 93 | + if (template == null) { | |
| 94 | + throw new RuntimeException("无效的模板编码:" + code); | |
| 95 | + } | |
| 96 | + return template; | |
| 97 | + } | |
| 98 | + | |
| 99 | + /** | |
| 100 | + * 根据编码获取模板名称(简化调用) | |
| 101 | + */ | |
| 102 | + public static String getNameByCode(String code) { | |
| 103 | + return getByCode(code).name; | |
| 104 | + } | |
| 105 | + | |
| 106 | + /** | |
| 107 | + * 根据编码获取导入类(用于Controller层反射解析) | |
| 108 | + */ | |
| 109 | + public static Class<?> getImportClassByCode(String code) { | |
| 110 | + return getByCode(code).importClass; | |
| 111 | + } | |
| 112 | + | |
| 113 | + /** | |
| 114 | + * 根据编码获取是否需要预览 | |
| 115 | + */ | |
| 116 | + public static boolean isPreviewRequired(String code) { | |
| 117 | + return getByCode(code).needPreview; | |
| 118 | + } | |
| 119 | + | |
| 120 | + /** | |
| 121 | + * 检查编码是否存在(避免直接抛出异常的场景) | |
| 122 | + */ | |
| 123 | + public static boolean containsCode(String code) { | |
| 124 | + return code != null && CODE_MAP.containsKey(code); | |
| 125 | + } | |
| 126 | +} | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/costfee/CostFeeService.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.service.costfee; | |
| 2 | + | |
| 3 | +import com.fasterxml.jackson.core.JsonProcessingException; | |
| 4 | +import com.zteits.urbanops.module.garden.controller.admin.costfee.CostFeeController; | |
| 5 | +import com.zteits.urbanops.module.garden.enums.TemplateEnum; | |
| 6 | + | |
| 7 | +import java.io.IOException; | |
| 8 | +import java.util.List; | |
| 9 | +import java.util.Map; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * @Classname ICostFeeService | |
| 13 | + * @Description 模板导入公共接口 | |
| 14 | + * @Date 2025/7/20 15:10 | |
| 15 | + * @Created by wangqian | |
| 16 | + */ | |
| 17 | +public interface CostFeeService { | |
| 18 | + | |
| 19 | + /** | |
| 20 | + * @Author wangqian | |
| 21 | + * @Description 导入数据保存redis | |
| 22 | + * @Date 2025/7/20 15:36 | |
| 23 | + * @Param dataList | |
| 24 | + * @param templateName | |
| 25 | + * @Return java.lang.String | |
| 26 | + */ | |
| 27 | + public String saveDataToRedis(List<?> dataList, String templateName); | |
| 28 | + | |
| 29 | + /** | |
| 30 | + * @Author wangqian | |
| 31 | + * @Description 导入数据保存到数据库 | |
| 32 | + * @Date 2025/7/20 15:36 | |
| 33 | + * @Param batchId | |
| 34 | + * @param templateName | |
| 35 | + * @param operator | |
| 36 | + * @Return int | |
| 37 | + */ | |
| 38 | + public int submitImport(String batchId, String templateName, String operator); | |
| 39 | + | |
| 40 | + /** | |
| 41 | + * @Author wangqian | |
| 42 | + * @Description 预览分页查询 | |
| 43 | + * @Date 2025/7/20 15:36 | |
| 44 | + * @Param batchId | |
| 45 | + * @param templateName | |
| 46 | + * @param page | |
| 47 | + * @param size | |
| 48 | + * @param clazz | |
| 49 | + * @Return com.servicemanager.project.costfee.controller.CostFeeController.PageResult<T> | |
| 50 | + */ | |
| 51 | + public <T> CostFeeController.PageResult<T> getPagedDataFromRedis(String batchId, String templateName, | |
| 52 | + int page, int size, Class<T> clazz) throws IOException; | |
| 53 | + | |
| 54 | + /** | |
| 55 | + * @Author wangqian | |
| 56 | + * @Description 导入内容校验 | |
| 57 | + * @Date 2025/11/24 8:40 | |
| 58 | + * @Param dataList | |
| 59 | + * @param template | |
| 60 | + * @Return void | |
| 61 | + */ | |
| 62 | + public void validateImportData(List dataList, TemplateEnum template); | |
| 63 | + | |
| 64 | +} | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/costfee/CostFeeServiceImpl.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.service.costfee; | |
| 2 | + | |
| 3 | +import com.fasterxml.jackson.core.JsonProcessingException; | |
| 4 | +import com.fasterxml.jackson.databind.ObjectMapper; | |
| 5 | +import com.zteits.urbanops.framework.security.core.LoginUser; | |
| 6 | +import com.zteits.urbanops.module.garden.controller.admin.costfee.CostFeeController; | |
| 7 | +import com.zteits.urbanops.module.garden.controller.admin.costfee.vo.*; | |
| 8 | +import com.zteits.urbanops.module.garden.enums.TemplateEnum; | |
| 9 | +import jakarta.annotation.Resource; | |
| 10 | +import jakarta.validation.ConstraintViolation; | |
| 11 | +import jakarta.validation.ConstraintViolationException; | |
| 12 | +import jakarta.validation.Validator; | |
| 13 | +import lombok.extern.slf4j.Slf4j; | |
| 14 | +import org.apache.commons.lang3.StringUtils; | |
| 15 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 16 | +import org.springframework.data.redis.core.BoundHashOperations; | |
| 17 | +import org.springframework.data.redis.core.RedisTemplate; | |
| 18 | +import org.springframework.stereotype.Service; | |
| 19 | +import org.springframework.transaction.annotation.Transactional; | |
| 20 | +import org.springframework.util.CollectionUtils; | |
| 21 | + | |
| 22 | +import java.io.IOException; | |
| 23 | +import java.util.*; | |
| 24 | +import java.util.concurrent.TimeUnit; | |
| 25 | +import java.util.stream.Collectors; | |
| 26 | +import java.util.stream.IntStream; | |
| 27 | + | |
| 28 | +import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 29 | +import static com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils.getLoginUser; | |
| 30 | +import static com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils.getLoginUserDeptId; | |
| 31 | +import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.COST_FEE_NOT_EXISTS_001; | |
| 32 | + | |
| 33 | +/** | |
| 34 | + * @Classname CostFeeService | |
| 35 | + * @Description 模板导入公共实现 | |
| 36 | + * @Date 2025/7/20 15:12 | |
| 37 | + * @Created by wangqian | |
| 38 | + */ | |
| 39 | +@Service | |
| 40 | +@Slf4j | |
| 41 | +public class CostFeeServiceImpl implements CostFeeService { | |
| 42 | + | |
| 43 | + // Redis相关配置 | |
| 44 | + private static final String REDIS_KEY_PREFIX = "excel:import:"; | |
| 45 | + private static final long EXPIRE_TIME = 30; // 预览数据过期时间:30分钟 | |
| 46 | + private static final TimeUnit EXPIRE_UNIT = TimeUnit.MINUTES; | |
| 47 | + @Autowired | |
| 48 | + private RedisTemplate<String, String> redisTemplate; | |
| 49 | + @Autowired | |
| 50 | + private ObjectMapper objectMapper; | |
| 51 | + @Resource | |
| 52 | + private Validator validator; | |
| 53 | + | |
| 54 | + | |
| 55 | + @Override | |
| 56 | + /** | |
| 57 | + * 保存数据到Redis | |
| 58 | + */ | |
| 59 | + public String saveDataToRedis(List<?> dataList, String templateName){ | |
| 60 | + String batchId = UUID.randomUUID().toString().replace("-", ""); | |
| 61 | + String redisKey = REDIS_KEY_PREFIX + templateName + ":" + batchId; | |
| 62 | + | |
| 63 | + // 存储总记录数 | |
| 64 | + redisTemplate.opsForValue().set( | |
| 65 | + redisKey + ":total", | |
| 66 | + String.valueOf(dataList.size()), | |
| 67 | + EXPIRE_TIME, | |
| 68 | + EXPIRE_UNIT | |
| 69 | + ); | |
| 70 | + | |
| 71 | + // 使用Hash存储每条数据(key:索引,value:JSON字符串) | |
| 72 | + BoundHashOperations<String, String, String> hashOps = redisTemplate.boundHashOps(redisKey + ":items"); | |
| 73 | + try { | |
| 74 | + for (int i = 0; i < dataList.size(); i++) { | |
| 75 | + String jsonData = objectMapper.writeValueAsString(dataList.get(i)); | |
| 76 | + hashOps.put(String.valueOf(i), jsonData); | |
| 77 | + } | |
| 78 | + } catch (JsonProcessingException e) { | |
| 79 | + log.error(e.getMessage()); | |
| 80 | + } | |
| 81 | + // 设置Hash过期时间 | |
| 82 | + hashOps.expire(EXPIRE_TIME, EXPIRE_UNIT); | |
| 83 | + | |
| 84 | + log.info("数据保存到Redis成功,批次ID:{},记录数:{}", batchId, dataList.size()); | |
| 85 | + return batchId; | |
| 86 | + } | |
| 87 | + | |
| 88 | + @Override | |
| 89 | + @Transactional | |
| 90 | + public int submitImport(String batchId, String templateName, String operator){ | |
| 91 | + // 模板类型校验 | |
| 92 | + TemplateEnum template = TemplateEnum.getByCode(templateName); | |
| 93 | + Class<?> importClass = template.getImportClass(); | |
| 94 | + if (importClass == null) { | |
| 95 | + throw exception(COST_FEE_NOT_EXISTS_001); | |
| 96 | + } | |
| 97 | + | |
| 98 | + // 分页参数设置 | |
| 99 | + int pageNum = 1; | |
| 100 | + final int pageSize = 100000; // 每页处理条数,可根据实际情况调整 | |
| 101 | + int totalImported = 0; // 总导入数量累计 | |
| 102 | + | |
| 103 | + try { | |
| 104 | + while (true) { | |
| 105 | + // 分页从Redis获取数据 | |
| 106 | + CostFeeController.PageResult<?> pageResult = getPagedDataFromRedis( | |
| 107 | + batchId, templateName, pageNum, pageSize, importClass); | |
| 108 | + List<?> dataList = pageResult.getData(); | |
| 109 | + | |
| 110 | + // 如果当前页无数据,说明已处理完毕 | |
| 111 | + if (dataList == null || dataList.isEmpty()) { | |
| 112 | + // 首次分页就无数据,抛出异常 | |
| 113 | + if (pageNum == 1) { | |
| 114 | + throw new IllegalArgumentException("没有可导入的数据或数据已过期"); | |
| 115 | + } | |
| 116 | + break; | |
| 117 | + } | |
| 118 | + | |
| 119 | + // 业务校验(每页单独校验) | |
| 120 | + //validateBusinessData(dataList, template); | |
| 121 | + | |
| 122 | + // 调用业务服务执行本页数据导入 | |
| 123 | + int currentPageCount = dataList.size(); | |
| 124 | + //insertData(template, dataList, operator); | |
| 125 | + totalImported += currentPageCount; | |
| 126 | + | |
| 127 | + // 打印分页处理日志(可选) | |
| 128 | + log.info("批次[{}]第{}页导入完成,本页{}条,累计{}条", | |
| 129 | + batchId, pageNum, currentPageCount, totalImported); | |
| 130 | + | |
| 131 | + // 准备下一页 | |
| 132 | + pageNum++; | |
| 133 | + | |
| 134 | + // 如果当前页数据小于页大小,说明已到最后一页 | |
| 135 | + if (dataList.size() < pageSize) { | |
| 136 | + break; | |
| 137 | + } | |
| 138 | + } | |
| 139 | + } catch (IOException e) { | |
| 140 | + log.error(e.getMessage()); | |
| 141 | + } finally { | |
| 142 | + // 无论导入成功与否,都清理Redis临时数据 | |
| 143 | + deleteRedisTempData(batchId, templateName); | |
| 144 | + } | |
| 145 | + | |
| 146 | + return totalImported; | |
| 147 | + } | |
| 148 | + | |
| 149 | + /** | |
| 150 | + * 从Redis获取分页数据 | |
| 151 | + */ | |
| 152 | + @Override | |
| 153 | + public <T > CostFeeController.PageResult < T > getPagedDataFromRedis(String batchId, String templateName, | |
| 154 | + int page, int size, Class<T > clazz) throws IOException { | |
| 155 | + String redisKey = REDIS_KEY_PREFIX + templateName + ":" + batchId; | |
| 156 | + | |
| 157 | + // 获取总记录数 | |
| 158 | + String totalStr = redisTemplate.opsForValue().get(redisKey + ":total"); | |
| 159 | + int total = totalStr != null ? Integer.parseInt(totalStr) : 0; | |
| 160 | + | |
| 161 | + // 计算分页范围 | |
| 162 | + int start = (page - 1) * size; | |
| 163 | + int end = Math.min(start + size - 1, total - 1); | |
| 164 | + | |
| 165 | + // 分页查询数据 | |
| 166 | + List<T> pageData = new ArrayList<>(); | |
| 167 | + if (start <= end && total > 0) { | |
| 168 | + BoundHashOperations<String, String, String> hashOps = redisTemplate.boundHashOps(redisKey + ":items"); | |
| 169 | + | |
| 170 | + // 批量获取指定范围的索引对应的数据 | |
| 171 | + List<String> indexes = IntStream.rangeClosed(start, end) | |
| 172 | + .mapToObj(String::valueOf) | |
| 173 | + .collect(Collectors.toList()); | |
| 174 | + List<String> jsonList = hashOps.multiGet(indexes); | |
| 175 | + | |
| 176 | + // 反序列化为对象 | |
| 177 | + for (String json : jsonList) { | |
| 178 | + if (json != null) { | |
| 179 | + pageData.add(objectMapper.readValue(json, clazz)); | |
| 180 | + } | |
| 181 | + } | |
| 182 | + } | |
| 183 | + | |
| 184 | + return new CostFeeController.PageResult<>(page, size, total, pageData); | |
| 185 | + } | |
| 186 | + | |
| 187 | + | |
| 188 | + /** | |
| 189 | + * 从Redis获取全部数据 | |
| 190 | + */ | |
| 191 | + private <T > List < T > getAllDataFromRedis(String batchId, String templateName, Class < T > clazz) throws | |
| 192 | + IOException { | |
| 193 | + String redisKey = REDIS_KEY_PREFIX + templateName + ":" + batchId; | |
| 194 | + BoundHashOperations<String, String, String> hashOps = redisTemplate.boundHashOps(redisKey + ":items"); | |
| 195 | + | |
| 196 | + // 获取所有数据的JSON字符串 | |
| 197 | + List<String> jsonList = hashOps.values(); | |
| 198 | + List<T> dataList = new ArrayList<>(jsonList.size()); | |
| 199 | + | |
| 200 | + // 反序列化为对象 | |
| 201 | + for (String json : jsonList) { | |
| 202 | + if (json != null) { | |
| 203 | + dataList.add(objectMapper.readValue(json, clazz)); | |
| 204 | + } | |
| 205 | + } | |
| 206 | + | |
| 207 | + return dataList; | |
| 208 | + } | |
| 209 | + | |
| 210 | + | |
| 211 | + /** | |
| 212 | + * 删除Redis临时数据 | |
| 213 | + */ | |
| 214 | + private void deleteRedisTempData (String batchId, String templateName){ | |
| 215 | + String redisKey = REDIS_KEY_PREFIX + templateName + ":" + batchId; | |
| 216 | + redisTemplate.delete(redisKey + ":total"); | |
| 217 | + redisTemplate.delete(redisKey + ":items"); | |
| 218 | + log.info("Redis临时数据已删除,批次ID:{}", batchId); | |
| 219 | + } | |
| 220 | + /** | |
| 221 | + * @Author wangqian | |
| 222 | + * @Description 导入内容校验 | |
| 223 | + * @Date 2025/11/24 8:40 | |
| 224 | + * @Param dataList | |
| 225 | + * @param template | |
| 226 | + * @Return void | |
| 227 | + */ | |
| 228 | + public void validateImportData(List dataList, TemplateEnum template) { | |
| 229 | + if (CollectionUtils.isEmpty(dataList)) { | |
| 230 | + return; // 空列表无需校验 | |
| 231 | + } | |
| 232 | + LoginUser user = getLoginUser(); | |
| 233 | + Long deptId = getLoginUserDeptId(); | |
| 234 | + // 模板类型校验 | |
| 235 | + Class<?> importClass = template.getImportClass(); // 从枚举获取导入类,避免switch | |
| 236 | + // 根据不同模板类型执行不同的处理逻辑 | |
| 237 | + if (WaterFeeImport.class.isAssignableFrom(importClass)) { | |
| 238 | + | |
| 239 | + List<WaterFeeImport> importList = (List<WaterFeeImport>) dataList; | |
| 240 | + // 2. 遍历,逐个创建 | |
| 241 | + for (int i = 0; i < importList.size(); i++) { | |
| 242 | + int rowNum = i + 1; // 第i条数据 → 第rowNum行(对应Excel导入的行号逻辑) | |
| 243 | + WaterFeeImport importBean = importList.get(i); | |
| 244 | + | |
| 245 | + try { | |
| 246 | + // 2.1 执行校验(替换原 ValidationUtils,直接用 Validator 校验,确保抛出 ConstraintViolationException) | |
| 247 | + Set<ConstraintViolation<WaterFeeImport>> violations = validator.validate(importBean); | |
| 248 | + if (!violations.isEmpty()) { | |
| 249 | + // 收集所有校验错误信息(比如“用水量不能为空”“格式应为两位小数”) | |
| 250 | + StringBuilder errorMsg = new StringBuilder(); | |
| 251 | + for (ConstraintViolation<WaterFeeImport> violation : violations) { | |
| 252 | + errorMsg.append(violation.getMessage()).append(";"); | |
| 253 | + } | |
| 254 | + // 抛出包含行号和所有错误的异常 | |
| 255 | + throw new ConstraintViolationException(errorMsg.toString().trim(), violations); | |
| 256 | + } | |
| 257 | + | |
| 258 | + | |
| 259 | + } catch (ConstraintViolationException ex) { | |
| 260 | + // 5. 包装异常,明确行号 + 真实校验错误( | |
| 261 | + throw new RuntimeException(String.format("第%d条数据校验失败:%s", rowNum, ex.getMessage()), ex); | |
| 262 | + } | |
| 263 | + } | |
| 264 | + } | |
| 265 | + else if (PersonalCostImport.class.isAssignableFrom(importClass)) { | |
| 266 | + | |
| 267 | + List<PersonalCostImport> importList = (List<PersonalCostImport>) dataList; | |
| 268 | + // 2. 遍历,逐个创建 | |
| 269 | + for (int i = 0; i < importList.size(); i++) { | |
| 270 | + int rowNum = i + 1; // 第i条数据 → 第rowNum行(对应Excel导入的行号逻辑) | |
| 271 | + PersonalCostImport importBean = importList.get(i); | |
| 272 | + | |
| 273 | + try { | |
| 274 | + // 2.1 执行校验(替换原 ValidationUtils,直接用 Validator 校验,确保抛出 ConstraintViolationException) | |
| 275 | + Set<ConstraintViolation<PersonalCostImport>> violations = validator.validate(importBean); | |
| 276 | + if (!violations.isEmpty()) { | |
| 277 | + // 收集所有校验错误信息(比如“用水量不能为空”“格式应为两位小数”) | |
| 278 | + StringBuilder errorMsg = new StringBuilder(); | |
| 279 | + for (ConstraintViolation<PersonalCostImport> violation : violations) { | |
| 280 | + errorMsg.append(violation.getMessage()).append(";"); | |
| 281 | + } | |
| 282 | + // 抛出包含行号和所有错误的异常 | |
| 283 | + throw new ConstraintViolationException(errorMsg.toString().trim(), violations); | |
| 284 | + } | |
| 285 | + | |
| 286 | + } catch (ConstraintViolationException ex) { | |
| 287 | + // 5. 包装异常,明确行号 + 真实校验错误( | |
| 288 | + throw new RuntimeException(String.format("第%d条数据校验失败:%s", rowNum, ex.getMessage()), ex); | |
| 289 | + } | |
| 290 | + } | |
| 291 | + } | |
| 292 | + else if (GardenWasteRecordImport.class.isAssignableFrom(importClass)) { | |
| 293 | + | |
| 294 | + List<GardenWasteRecordImport> importList = (List<GardenWasteRecordImport>) dataList; | |
| 295 | + // 2. 遍历,逐个创建 | |
| 296 | + for (int i = 0; i < importList.size(); i++) { | |
| 297 | + int rowNum = i + 1; // 第i条数据 → 第rowNum行(对应Excel导入的行号逻辑) | |
| 298 | + GardenWasteRecordImport importBean = importList.get(i); | |
| 299 | + | |
| 300 | + try { | |
| 301 | + // 2.1 执行校验(替换原 ValidationUtils,直接用 Validator 校验,确保抛出 ConstraintViolationException) | |
| 302 | + Set<ConstraintViolation<GardenWasteRecordImport>> violations = validator.validate(importBean); | |
| 303 | + if (!violations.isEmpty()) { | |
| 304 | + // 收集所有校验错误信息(比如“用水量不能为空”“格式应为两位小数”) | |
| 305 | + StringBuilder errorMsg = new StringBuilder(); | |
| 306 | + for (ConstraintViolation<GardenWasteRecordImport> violation : violations) { | |
| 307 | + errorMsg.append(violation.getMessage()).append(";"); | |
| 308 | + } | |
| 309 | + // 抛出包含行号和所有错误的异常 | |
| 310 | + throw new ConstraintViolationException(errorMsg.toString().trim(), violations); | |
| 311 | + } | |
| 312 | + | |
| 313 | + | |
| 314 | + } catch (ConstraintViolationException ex) { | |
| 315 | + // 5. 包装异常,明确行号 + 真实校验错误( | |
| 316 | + throw new RuntimeException(String.format("第%d条数据校验失败:%s", rowNum, ex.getMessage()), ex); | |
| 317 | + } | |
| 318 | + } | |
| 319 | + } | |
| 320 | + else if (MechanicalCostImport.class.isAssignableFrom(importClass)) { | |
| 321 | + | |
| 322 | + List<MechanicalCostImport> importList = (List<MechanicalCostImport>) dataList; | |
| 323 | + // 2. 遍历,逐个创建 | |
| 324 | + for (int i = 0; i < importList.size(); i++) { | |
| 325 | + int rowNum = i + 1; // 第i条数据 → 第rowNum行(对应Excel导入的行号逻辑) | |
| 326 | + MechanicalCostImport importBean = importList.get(i); | |
| 327 | + | |
| 328 | + try { | |
| 329 | + // 2.1 执行校验(替换原 ValidationUtils,直接用 Validator 校验,确保抛出 ConstraintViolationException) | |
| 330 | + Set<ConstraintViolation<MechanicalCostImport>> violations = validator.validate(importBean); | |
| 331 | + if (!violations.isEmpty()) { | |
| 332 | + // 收集所有校验错误信息(比如“用水量不能为空”“格式应为两位小数”) | |
| 333 | + StringBuilder errorMsg = new StringBuilder(); | |
| 334 | + for (ConstraintViolation<MechanicalCostImport> violation : violations) { | |
| 335 | + errorMsg.append(violation.getMessage()).append(";"); | |
| 336 | + } | |
| 337 | + // 抛出包含行号和所有错误的异常 | |
| 338 | + throw new ConstraintViolationException(errorMsg.toString().trim(), violations); | |
| 339 | + } | |
| 340 | + | |
| 341 | + | |
| 342 | + } catch (ConstraintViolationException ex) { | |
| 343 | + // 5. 包装异常,明确行号 + 真实校验错误( | |
| 344 | + throw new RuntimeException(String.format("第%d条数据校验失败:%s", rowNum, ex.getMessage()), ex); | |
| 345 | + } | |
| 346 | + } | |
| 347 | + } | |
| 348 | + else if (RentalMechanicalCostImport.class.isAssignableFrom(importClass)) { | |
| 349 | + | |
| 350 | + List<RentalMechanicalCostImport> importList = (List<RentalMechanicalCostImport>) dataList; | |
| 351 | + // 2. 遍历,逐个创建 | |
| 352 | + for (int i = 0; i < importList.size(); i++) { | |
| 353 | + int rowNum = i + 1; // 第i条数据 → 第rowNum行(对应Excel导入的行号逻辑) | |
| 354 | + RentalMechanicalCostImport importBean = importList.get(i); | |
| 355 | + | |
| 356 | + try { | |
| 357 | + // 2.1 执行校验(替换原 ValidationUtils,直接用 Validator 校验,确保抛出 ConstraintViolationException) | |
| 358 | + Set<ConstraintViolation<RentalMechanicalCostImport>> violations = validator.validate(importBean); | |
| 359 | + if (!violations.isEmpty()) { | |
| 360 | + // 收集所有校验错误信息(比如“用水量不能为空”“格式应为两位小数”) | |
| 361 | + StringBuilder errorMsg = new StringBuilder(); | |
| 362 | + for (ConstraintViolation<RentalMechanicalCostImport> violation : violations) { | |
| 363 | + errorMsg.append(violation.getMessage()).append(";"); | |
| 364 | + } | |
| 365 | + // 抛出包含行号和所有错误的异常 | |
| 366 | + throw new ConstraintViolationException(errorMsg.toString().trim(), violations); | |
| 367 | + } | |
| 368 | + // 处理可能的空值 | |
| 369 | + String teamIdsStr = StringUtils.defaultString(importBean.getTeamIds()); | |
| 370 | + String weightsStr = StringUtils.defaultString(importBean.getWeight()); | |
| 371 | + | |
| 372 | + // 统一替换中文逗号并分割 | |
| 373 | + String[] teamIds = teamIdsStr.replace(",", ",").split(","); | |
| 374 | + String[] weights = weightsStr.replace(",", ",").split(","); | |
| 375 | + | |
| 376 | + // 校验数组长度是否一致 | |
| 377 | + if (teamIds.length != weights.length) { | |
| 378 | + throw new IllegalArgumentException(String.format( | |
| 379 | + "第%d条数据:权重值和所选班组数量不符(班组:%d个,权重:%d个)", | |
| 380 | + rowNum, teamIds.length, weights.length | |
| 381 | + )); | |
| 382 | + } | |
| 383 | + | |
| 384 | + //单位校验 | |
| 385 | + // validatecompany(rowNum, importBean.getCompanyName(), deptId); | |
| 386 | + //部门名称校验 | |
| 387 | + //validateTeams(rowNum, depts.get(data.getCompanyName()), data.getTeamIds()); | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + } catch (ConstraintViolationException ex) { | |
| 392 | + // 5. 包装异常,明确行号 + 真实校验错误( | |
| 393 | + throw new RuntimeException(String.format("第%d条数据校验失败:%s", rowNum, ex.getMessage()), ex); | |
| 394 | + } | |
| 395 | + } | |
| 396 | + } | |
| 397 | + else if (DepartmentCostImport.class.isAssignableFrom(importClass)) { | |
| 398 | + | |
| 399 | + List<DepartmentCostImport> importList = (List<DepartmentCostImport>) dataList; | |
| 400 | + // 2. 遍历,逐个创建 | |
| 401 | + for (int i = 0; i < importList.size(); i++) { | |
| 402 | + int rowNum = i + 1; // 第i条数据 → 第rowNum行(对应Excel导入的行号逻辑) | |
| 403 | + DepartmentCostImport importBean = importList.get(i); | |
| 404 | + | |
| 405 | + try { | |
| 406 | + // 2.1 执行校验(替换原 ValidationUtils,直接用 Validator 校验,确保抛出 ConstraintViolationException) | |
| 407 | + Set<ConstraintViolation<DepartmentCostImport>> violations = validator.validate(importBean); | |
| 408 | + if (!violations.isEmpty()) { | |
| 409 | + // 收集所有校验错误信息(比如“用水量不能为空”“格式应为两位小数”) | |
| 410 | + StringBuilder errorMsg = new StringBuilder(); | |
| 411 | + for (ConstraintViolation<DepartmentCostImport> violation : violations) { | |
| 412 | + errorMsg.append(violation.getMessage()).append(";"); | |
| 413 | + } | |
| 414 | + // 抛出包含行号和所有错误的异常 | |
| 415 | + throw new ConstraintViolationException(errorMsg.toString().trim(), violations); | |
| 416 | + } | |
| 417 | + | |
| 418 | + | |
| 419 | + } catch (ConstraintViolationException ex) { | |
| 420 | + // 5. 包装异常,明确行号 + 真实校验错误( | |
| 421 | + throw new RuntimeException(String.format("第%d条数据校验失败:%s", rowNum, ex.getMessage()), ex); | |
| 422 | + } | |
| 423 | + } | |
| 424 | + } | |
| 425 | + } | |
| 426 | + | |
| 427 | + private void validatecompany(int rowNum, String companyName, Long deptId){ | |
| 428 | + //根据单位名称获取单位id | |
| 429 | + Long companyId = null ; | |
| 430 | + // 校验数组长度是否一致 | |
| 431 | + if (companyId == null) { | |
| 432 | + throw new IllegalArgumentException(String.format( | |
| 433 | + "第%d条数据:单位名称不正确(%s)", | |
| 434 | + rowNum, companyName | |
| 435 | + )); | |
| 436 | + } | |
| 437 | + // 校验导入单位 | |
| 438 | + if (deptId != 100 && !companyId.equals(deptId)) { | |
| 439 | + throw new IllegalArgumentException(String.format( | |
| 440 | + "第%d条数据:导入单位%s与当前操作员单位不一致", | |
| 441 | + rowNum, companyName | |
| 442 | + )); | |
| 443 | + } | |
| 444 | + } | |
| 445 | + private void validateTeams(int rowNum, List<String> dept, String teamIds) { | |
| 446 | + String[] teamNames = teamIds.split(","); | |
| 447 | + Set<String> checkedTeams = new HashSet<>(); // 用于存储已校验的团队名称,检测重复 | |
| 448 | + | |
| 449 | + for (String teamName : teamNames) { | |
| 450 | + String trimmedTeamName = teamName.trim(); // 处理前后空格 | |
| 451 | + | |
| 452 | + // 重复校验:如果Set中已存在该团队名称,说明重复 | |
| 453 | + if (checkedTeams.contains(trimmedTeamName)) { | |
| 454 | + throw new IllegalArgumentException(String.format( | |
| 455 | + "第%d条数据:%s名称重复", | |
| 456 | + rowNum, teamName | |
| 457 | + )); | |
| 458 | + } | |
| 459 | + | |
| 460 | + // 存在性校验:检查团队是否在dept中存在 | |
| 461 | + if (!dept.contains(trimmedTeamName)) { | |
| 462 | + throw new IllegalArgumentException(String.format( | |
| 463 | + "第%d条数据:%s名称不正确", | |
| 464 | + rowNum, teamName | |
| 465 | + )); | |
| 466 | + } | |
| 467 | + | |
| 468 | + // 将校验通过的团队名称加入Set,用于后续重复判断 | |
| 469 | + checkedTeams.add(trimmedTeamName); | |
| 470 | + } | |
| 471 | + } | |
| 472 | +} | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/mechanicalcost/MechanicalCostServiceImpl.java
| ... | ... | @@ -5,6 +5,7 @@ import com.zteits.urbanops.framework.common.util.object.BeanUtils; |
| 5 | 5 | import com.zteits.urbanops.module.garden.controller.admin.mechanicalcost.vo.MechanicalCostPageReqVO; |
| 6 | 6 | import com.zteits.urbanops.module.garden.controller.admin.mechanicalcost.vo.MechanicalCostSaveReqVO; |
| 7 | 7 | import com.zteits.urbanops.module.garden.dal.dataobject.mechanicalcost.MechanicalCostDO; |
| 8 | +import com.zteits.urbanops.module.garden.dal.dataobject.teambizdomainrel.TeamBizdomainRelDO; | |
| 8 | 9 | import com.zteits.urbanops.module.garden.dal.mysql.mechanicalcost.MechanicalCostMapper; |
| 9 | 10 | import com.zteits.urbanops.module.garden.enums.CostFeeConstants; |
| 10 | 11 | import com.zteits.urbanops.module.garden.service.mechanicaldepreciation.MechanicalDepreciationService; |
| ... | ... | @@ -16,6 +17,7 @@ import org.springframework.transaction.annotation.Transactional; |
| 16 | 17 | import org.springframework.validation.annotation.Validated; |
| 17 | 18 | |
| 18 | 19 | import java.util.List; |
| 20 | +import java.util.stream.Collectors; | |
| 19 | 21 | |
| 20 | 22 | import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 21 | 23 | import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.MECHANICAL_COST_NOT_EXISTS; |
| ... | ... | @@ -33,19 +35,19 @@ public class MechanicalCostServiceImpl implements MechanicalCostService { |
| 33 | 35 | @Resource |
| 34 | 36 | private MechanicalCostMapper mechanicalCostMapper; |
| 35 | 37 | @Resource |
| 36 | - private TeamBizdomainRelService teamBizdomainRelService; | |
| 37 | - @Resource | |
| 38 | 38 | private MechanicalDepreciationService mechanicalDepreciationService; |
| 39 | 39 | |
| 40 | 40 | @Override |
| 41 | 41 | public Long createMechanicalCost(MechanicalCostSaveReqVO createReqVO) { |
| 42 | 42 | // 插入 |
| 43 | 43 | MechanicalCostDO mechanicalCost = BeanUtils.toBean(createReqVO, MechanicalCostDO.class); |
| 44 | - mechanicalCostMapper.insert(mechanicalCost); | |
| 45 | - //add by wq 保存班组信息关联表 | |
| 46 | - teamBizdomainRelService.saveTeamBizdomainRel(createReqVO.getTeamIds(), mechanicalCost.getId(), mechanicalCost.getCompanyId(), mechanicalCost.getCompanyName(), CostFeeConstants.COSTFEE_MECHANICAL); | |
| 47 | - //add by wq 保存班组信息关联表 | |
| 48 | 44 | |
| 45 | + List<String> deptIds = createReqVO.getTeamIds().stream() | |
| 46 | + .map(TeamBizdomainRelDO::getTeamId) | |
| 47 | + .collect(Collectors.toList()); | |
| 48 | + mechanicalCost.setDeptId(deptIds); | |
| 49 | + | |
| 50 | + mechanicalCostMapper.insert(mechanicalCost); | |
| 49 | 51 | // 返回 |
| 50 | 52 | return mechanicalCost.getId(); |
| 51 | 53 | } |
| ... | ... | @@ -56,12 +58,13 @@ public class MechanicalCostServiceImpl implements MechanicalCostService { |
| 56 | 58 | validateMechanicalCostExists(updateReqVO.getId()); |
| 57 | 59 | // 更新 |
| 58 | 60 | MechanicalCostDO updateObj = BeanUtils.toBean(updateReqVO, MechanicalCostDO.class); |
| 59 | - mechanicalCostMapper.updateById(updateObj); | |
| 60 | 61 | |
| 61 | - //add by wq 保存班组信息关联表 | |
| 62 | - teamBizdomainRelService.deleteTeamBizdomainRel(updateObj.getId(), CostFeeConstants.COSTFEE_MECHANICAL); | |
| 63 | - teamBizdomainRelService.saveTeamBizdomainRel(updateReqVO.getTeamIds(), updateObj.getId(), updateObj.getCompanyId(), updateObj.getCompanyName(), CostFeeConstants.COSTFEE_MECHANICAL); | |
| 64 | - //add by wq 保存班组信息关联表 | |
| 62 | + List<String> deptIds = updateReqVO.getTeamIds().stream() | |
| 63 | + .map(TeamBizdomainRelDO::getTeamId) | |
| 64 | + .collect(Collectors.toList()); | |
| 65 | + updateObj.setDeptId(deptIds); | |
| 66 | + | |
| 67 | + mechanicalCostMapper.updateById(updateObj); | |
| 65 | 68 | } |
| 66 | 69 | |
| 67 | 70 | @Override |
| ... | ... | @@ -73,7 +76,6 @@ public class MechanicalCostServiceImpl implements MechanicalCostService { |
| 73 | 76 | mechanicalCostMapper.deleteById(id); |
| 74 | 77 | |
| 75 | 78 | //add by wq 删除班组信息关联表 |
| 76 | - teamBizdomainRelService.deleteTeamBizdomainRel(id, CostFeeConstants.COSTFEE_MECHANICAL); | |
| 77 | 79 | // //删除折旧 |
| 78 | 80 | mechanicalDepreciationService.deleteMechanicalDepreciationByMechId(id); |
| 79 | 81 | //add by wq 删除班组信息关联表 |
| ... | ... | @@ -86,8 +88,6 @@ public class MechanicalCostServiceImpl implements MechanicalCostService { |
| 86 | 88 | //add by wq 删除班组信息关联表 |
| 87 | 89 | if(CollectionUtils.isNotEmpty(ids)) { |
| 88 | 90 | for (Long id : ids) { |
| 89 | - //批量删除 | |
| 90 | - teamBizdomainRelService.deleteTeamBizdomainRel(id, CostFeeConstants.COSTFEE_MECHANICAL); | |
| 91 | 91 | //删除折旧 |
| 92 | 92 | mechanicalDepreciationService.deleteMechanicalDepreciationByMechId(id); |
| 93 | 93 | } | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/personalcost/PersonalCostServiceImpl.java
| 1 | 1 | package com.zteits.urbanops.module.garden.service.personalcost; |
| 2 | 2 | |
| 3 | -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |
| 4 | -import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |
| 5 | 3 | import com.zteits.urbanops.framework.common.pojo.PageResult; |
| 6 | 4 | import com.zteits.urbanops.framework.common.util.object.BeanUtils; |
| 7 | 5 | import com.zteits.urbanops.module.garden.controller.admin.personalcost.vo.PersonalCostPageReqVO; |
| 8 | 6 | import com.zteits.urbanops.module.garden.controller.admin.personalcost.vo.PersonalCostSaveReqVO; |
| 9 | -import com.zteits.urbanops.module.garden.dal.dataobject.departmentcost.DepartmentCostDO; | |
| 10 | 7 | import com.zteits.urbanops.module.garden.dal.dataobject.personalcost.PersonalCostDO; |
| 11 | 8 | import com.zteits.urbanops.module.garden.dal.dataobject.teambizdomainrel.TeamBizdomainRelDO; |
| 12 | 9 | import com.zteits.urbanops.module.garden.dal.mysql.personalcost.PersonalCostMapper; |
| 13 | -import com.zteits.urbanops.module.garden.dal.mysql.teambizdomainrel.TeamBizdomainRelMapper; | |
| 14 | -import com.zteits.urbanops.module.garden.enums.CostFeeConstants; | |
| 15 | -import com.zteits.urbanops.module.garden.service.teambizdomainrel.TeamBizdomainRelService; | |
| 16 | 10 | import jakarta.annotation.Resource; |
| 17 | -import org.apache.commons.collections4.CollectionUtils; | |
| 18 | -import org.apache.commons.lang3.StringUtils; | |
| 19 | 11 | import org.springframework.stereotype.Service; |
| 20 | 12 | import org.springframework.transaction.annotation.Transactional; |
| 21 | 13 | import org.springframework.validation.annotation.Validated; |
| 22 | 14 | |
| 23 | 15 | import java.util.List; |
| 16 | +import java.util.stream.Collectors; | |
| 24 | 17 | |
| 25 | 18 | import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 26 | 19 | import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.PERSONAL_COST_NOT_EXISTS; |
| 27 | -import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.PERSONAL_COST_NOT_EXISTS_001; | |
| 28 | 20 | |
| 29 | 21 | /** |
| 30 | 22 | * 人员费用录入 - 个人费用 Service 实现类 |
| ... | ... | @@ -37,20 +29,17 @@ public class PersonalCostServiceImpl implements PersonalCostService { |
| 37 | 29 | |
| 38 | 30 | @Resource |
| 39 | 31 | private PersonalCostMapper personalCostMapper; |
| 40 | - @Resource | |
| 41 | - TeamBizdomainRelService teamBizdomainRelService; | |
| 42 | 32 | |
| 43 | 33 | @Override |
| 44 | 34 | @Transactional |
| 45 | 35 | public Long createPersonalCost(PersonalCostSaveReqVO createReqVO) { |
| 46 | 36 | // 插入 |
| 47 | 37 | PersonalCostDO personalCost = BeanUtils.toBean(createReqVO, PersonalCostDO.class); |
| 38 | + List<String> deptIds = createReqVO.getTeamIds().stream() | |
| 39 | + .map(TeamBizdomainRelDO::getTeamId) | |
| 40 | + .collect(Collectors.toList()); | |
| 41 | + personalCost.setDeptId(deptIds); | |
| 48 | 42 | personalCostMapper.insert(personalCost); |
| 49 | - | |
| 50 | - //add by wq 保存班组信息关联表 | |
| 51 | - teamBizdomainRelService.saveTeamBizdomainRel(createReqVO.getTeamIds(), personalCost.getId(), personalCost.getCompanyId(), personalCost.getCompanyName(), CostFeeConstants.COSTFEE_PERSONAL); | |
| 52 | - //add by wq 保存班组信息关联表 | |
| 53 | - | |
| 54 | 43 | // 返回 |
| 55 | 44 | return personalCost.getId(); |
| 56 | 45 | } |
| ... | ... | @@ -62,13 +51,11 @@ public class PersonalCostServiceImpl implements PersonalCostService { |
| 62 | 51 | validatePersonalCostExists(updateReqVO.getId()); |
| 63 | 52 | // 更新 |
| 64 | 53 | PersonalCostDO updateObj = BeanUtils.toBean(updateReqVO, PersonalCostDO.class); |
| 54 | + List<String> deptIds = updateReqVO.getTeamIds().stream() | |
| 55 | + .map(TeamBizdomainRelDO::getTeamId) | |
| 56 | + .collect(Collectors.toList()); | |
| 57 | + updateObj.setDeptId(deptIds); | |
| 65 | 58 | personalCostMapper.updateById(updateObj); |
| 66 | - | |
| 67 | - //add by wq 保存班组信息关联表 | |
| 68 | - teamBizdomainRelService.deleteTeamBizdomainRel(updateObj.getId(), CostFeeConstants.COSTFEE_PERSONAL); | |
| 69 | - teamBizdomainRelService.saveTeamBizdomainRel(updateReqVO.getTeamIds(), updateObj.getId(), updateObj.getCompanyId(), updateObj.getCompanyName(), CostFeeConstants.COSTFEE_PERSONAL); | |
| 70 | - | |
| 71 | - //add by wq 保存班组信息关联表 | |
| 72 | 59 | } |
| 73 | 60 | |
| 74 | 61 | @Override |
| ... | ... | @@ -77,22 +64,12 @@ public class PersonalCostServiceImpl implements PersonalCostService { |
| 77 | 64 | validatePersonalCostExists(id); |
| 78 | 65 | // 删除 |
| 79 | 66 | personalCostMapper.deleteById(id); |
| 80 | - // add by wq 删除 | |
| 81 | - teamBizdomainRelService.deleteTeamBizdomainRel(id, CostFeeConstants.COSTFEE_PERSONAL); | |
| 82 | - // add by wq 删除 | |
| 83 | 67 | } |
| 84 | 68 | |
| 85 | 69 | @Override |
| 86 | 70 | public void deletePersonalCostListByIds(List<Long> ids) { |
| 87 | 71 | // 删除 |
| 88 | 72 | personalCostMapper.deleteByIds(ids); |
| 89 | - // add by wq 删除 | |
| 90 | - if(ids.size() > 0) { | |
| 91 | - for (Long id : ids) { | |
| 92 | - teamBizdomainRelService.deleteTeamBizdomainRel(id, CostFeeConstants.COSTFEE_PERSONAL); | |
| 93 | - } | |
| 94 | - } | |
| 95 | - // add by wq 删除 | |
| 96 | 73 | } |
| 97 | 74 | |
| 98 | 75 | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/rentalmechanicalcost/RentalMechanicalCostServiceImpl.java
| ... | ... | @@ -40,9 +40,6 @@ public class RentalMechanicalCostServiceImpl implements RentalMechanicalCostServ |
| 40 | 40 | RentalMechanicalCostDO rentalMechanicalCost = BeanUtils.toBean(createReqVO, RentalMechanicalCostDO.class); |
| 41 | 41 | rentalMechanicalCostMapper.insert(rentalMechanicalCost); |
| 42 | 42 | |
| 43 | - //add by wq 保存班组信息关联表 | |
| 44 | - teamBizdomainRelService.saveTeamBizdomainRel(createReqVO.getTeamIds(), rentalMechanicalCost.getId(), rentalMechanicalCost.getCompanyId(), rentalMechanicalCost.getCompanyName(), CostFeeConstants.COSTFEE_RENTALMECHANICAL); | |
| 45 | - //add by wq 保存班组信息关联表 | |
| 46 | 43 | // 返回 |
| 47 | 44 | return rentalMechanicalCost.getId(); |
| 48 | 45 | } |
| ... | ... | @@ -57,7 +54,6 @@ public class RentalMechanicalCostServiceImpl implements RentalMechanicalCostServ |
| 57 | 54 | |
| 58 | 55 | //add by wq 保存班组信息关联表 |
| 59 | 56 | teamBizdomainRelService.deleteTeamBizdomainRel(updateObj.getId(), CostFeeConstants.COSTFEE_RENTALMECHANICAL); |
| 60 | - teamBizdomainRelService.saveTeamBizdomainRel(updateReqVO.getTeamIds(), updateObj.getId(), updateObj.getCompanyId(), updateObj.getCompanyName(), CostFeeConstants.COSTFEE_RENTALMECHANICAL); | |
| 61 | 57 | //add by wq 保存班组信息关联表 |
| 62 | 58 | } |
| 63 | 59 | |
| ... | ... | @@ -67,25 +63,12 @@ public class RentalMechanicalCostServiceImpl implements RentalMechanicalCostServ |
| 67 | 63 | validateRentalMechanicalCostExists(id); |
| 68 | 64 | // 删除 |
| 69 | 65 | rentalMechanicalCostMapper.deleteById(id); |
| 70 | - | |
| 71 | - //add by wq 删除班组信息关联表 | |
| 72 | - teamBizdomainRelService.deleteTeamBizdomainRel(id, CostFeeConstants.COSTFEE_RENTALMECHANICAL); | |
| 73 | - //add by wq 删除班组信息关联表 | |
| 74 | 66 | } |
| 75 | 67 | |
| 76 | 68 | @Override |
| 77 | 69 | public void deleteRentalMechanicalCostListByIds(List<Long> ids) { |
| 78 | 70 | // 删除 |
| 79 | 71 | rentalMechanicalCostMapper.deleteByIds(ids); |
| 80 | - | |
| 81 | - //add by wq 删除班组信息关联表 | |
| 82 | - if(CollectionUtils.isNotEmpty(ids)) { | |
| 83 | - for (Long id : ids) { | |
| 84 | - //批量删除 | |
| 85 | - teamBizdomainRelService.deleteTeamBizdomainRel(id, CostFeeConstants.COSTFEE_MECHANICAL); | |
| 86 | - } | |
| 87 | - } | |
| 88 | - //add by wq 删除班组信息关联表 | |
| 89 | 72 | } |
| 90 | 73 | |
| 91 | 74 | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/wasterecord/WasteRecordServiceImpl.java
| 1 | 1 | package com.zteits.urbanops.module.garden.service.wasterecord; |
| 2 | 2 | |
| 3 | -import cn.hutool.core.collection.CollUtil; | |
| 4 | -import com.zteits.urbanops.module.garden.enums.CostFeeConstants; | |
| 3 | +import com.zteits.urbanops.framework.common.pojo.PageResult; | |
| 4 | +import com.zteits.urbanops.framework.common.util.object.BeanUtils; | |
| 5 | +import com.zteits.urbanops.module.garden.controller.admin.wasterecord.vo.WasteRecordPageReqVO; | |
| 6 | +import com.zteits.urbanops.module.garden.controller.admin.wasterecord.vo.WasteRecordSaveReqVO; | |
| 7 | +import com.zteits.urbanops.module.garden.dal.dataobject.teambizdomainrel.TeamBizdomainRelDO; | |
| 8 | +import com.zteits.urbanops.module.garden.dal.dataobject.wasterecord.WasteRecordDO; | |
| 9 | +import com.zteits.urbanops.module.garden.dal.mysql.wasterecord.WasteRecordMapper; | |
| 5 | 10 | import com.zteits.urbanops.module.garden.service.teambizdomainrel.TeamBizdomainRelService; |
| 6 | -import org.springframework.stereotype.Service; | |
| 7 | 11 | import jakarta.annotation.Resource; |
| 8 | -import org.springframework.validation.annotation.Validated; | |
| 12 | +import org.springframework.stereotype.Service; | |
| 9 | 13 | import org.springframework.transaction.annotation.Transactional; |
| 14 | +import org.springframework.validation.annotation.Validated; | |
| 10 | 15 | |
| 11 | -import java.util.*; | |
| 12 | -import com.zteits.urbanops.module.garden.controller.admin.wasterecord.vo.*; | |
| 13 | -import com.zteits.urbanops.module.garden.dal.dataobject.wasterecord.WasteRecordDO; | |
| 14 | -import com.zteits.urbanops.framework.common.pojo.PageResult; | |
| 15 | -import com.zteits.urbanops.framework.common.pojo.PageParam; | |
| 16 | -import com.zteits.urbanops.framework.common.util.object.BeanUtils; | |
| 17 | - | |
| 18 | -import com.zteits.urbanops.module.garden.dal.mysql.wasterecord.WasteRecordMapper; | |
| 16 | +import java.util.List; | |
| 17 | +import java.util.stream.Collectors; | |
| 19 | 18 | |
| 20 | 19 | import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 21 | -import static com.zteits.urbanops.framework.common.util.collection.CollectionUtils.convertList; | |
| 22 | -import static com.zteits.urbanops.framework.common.util.collection.CollectionUtils.diffList; | |
| 23 | -import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.*; | |
| 20 | +import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.WASTE_RECORD_NOT_EXISTS; | |
| 24 | 21 | |
| 25 | 22 | /** |
| 26 | 23 | * 园林废弃物录入 Service 实现类 |
| ... | ... | @@ -41,12 +38,11 @@ public class WasteRecordServiceImpl implements WasteRecordService { |
| 41 | 38 | public Long createWasteRecord(WasteRecordSaveReqVO createReqVO) { |
| 42 | 39 | // 插入 |
| 43 | 40 | WasteRecordDO wasteRecord = BeanUtils.toBean(createReqVO, WasteRecordDO.class); |
| 41 | + List<String> deptIds = createReqVO.getTeamIds().stream() | |
| 42 | + .map(TeamBizdomainRelDO::getTeamId) | |
| 43 | + .collect(Collectors.toList()); | |
| 44 | + wasteRecord.setDeptId(deptIds); | |
| 44 | 45 | wasteRecordMapper.insert(wasteRecord); |
| 45 | - | |
| 46 | - | |
| 47 | - //add by wq 保存班组信息关联表 | |
| 48 | - teamBizdomainRelService.saveTeamBizdomainRel(createReqVO.getTeamIds(), wasteRecord.getId(), wasteRecord.getCompanyId(), wasteRecord.getCompanyName(), CostFeeConstants.COSTFEE_GARDENWASTE); | |
| 49 | - //add by wq 保存班组信息关联表 | |
| 50 | 46 | // 返回 |
| 51 | 47 | return wasteRecord.getId(); |
| 52 | 48 | } |
| ... | ... | @@ -58,11 +54,13 @@ public class WasteRecordServiceImpl implements WasteRecordService { |
| 58 | 54 | validateWasteRecordExists(updateReqVO.getId()); |
| 59 | 55 | // 更新 |
| 60 | 56 | WasteRecordDO updateObj = BeanUtils.toBean(updateReqVO, WasteRecordDO.class); |
| 57 | + | |
| 58 | + List<String> deptIds = updateReqVO.getTeamIds().stream() | |
| 59 | + .map(TeamBizdomainRelDO::getTeamId) | |
| 60 | + .collect(Collectors.toList()); | |
| 61 | + updateObj.setDeptId(deptIds); | |
| 62 | + | |
| 61 | 63 | wasteRecordMapper.updateById(updateObj); |
| 62 | - //add by wq 保存班组信息关联表 | |
| 63 | - teamBizdomainRelService.deleteTeamBizdomainRel(updateObj.getId(), CostFeeConstants.COSTFEE_GARDENWASTE); | |
| 64 | - teamBizdomainRelService.saveTeamBizdomainRel(updateReqVO.getTeamIds(), updateObj.getId(), updateObj.getCompanyId(), updateObj.getCompanyName(), CostFeeConstants.COSTFEE_GARDENWASTE); | |
| 65 | - //add by wq 保存班组信息关联表 | |
| 66 | 64 | } |
| 67 | 65 | |
| 68 | 66 | @Override |
| ... | ... | @@ -72,22 +70,12 @@ public class WasteRecordServiceImpl implements WasteRecordService { |
| 72 | 70 | // 删除 |
| 73 | 71 | wasteRecordMapper.deleteById(id); |
| 74 | 72 | |
| 75 | - // add by wq 删除 | |
| 76 | - teamBizdomainRelService.deleteTeamBizdomainRel(id, CostFeeConstants.COSTFEE_GARDENWASTE); | |
| 77 | - // add by wq 删除 | |
| 78 | 73 | } |
| 79 | 74 | |
| 80 | 75 | @Override |
| 81 | 76 | public void deleteWasteRecordListByIds(List<Long> ids) { |
| 82 | 77 | // 删除 |
| 83 | 78 | wasteRecordMapper.deleteByIds(ids); |
| 84 | - // add by wq 删除 | |
| 85 | - if(ids.size() > 0) { | |
| 86 | - for (Long id : ids) { | |
| 87 | - teamBizdomainRelService.deleteTeamBizdomainRel(id, CostFeeConstants.COSTFEE_GARDENWASTE); | |
| 88 | - } | |
| 89 | - } | |
| 90 | - // add by wq 删除 | |
| 91 | 79 | } |
| 92 | 80 | |
| 93 | 81 | ... | ... |