Commit 183ddd5f7d60bf299255904e95a66992a9e1f29d

Authored by wangqian
1 parent 19d36e00

工单管理分页图片名称转换

urbanops-module-workorder/src/main/java/com/zteits/urbanops/module/workorder/controller/admin/maininfo/MainInfoController.java
1 package com.zteits.urbanops.module.workorder.controller.admin.maininfo; 1 package com.zteits.urbanops.module.workorder.controller.admin.maininfo;
2 2
3 -import org.springframework.web.bind.annotation.*;  
4 -import jakarta.annotation.Resource;  
5 -import org.springframework.validation.annotation.Validated;  
6 -import org.springframework.security.access.prepost.PreAuthorize;  
7 -import io.swagger.v3.oas.annotations.tags.Tag;  
8 -import io.swagger.v3.oas.annotations.Parameter;  
9 -import io.swagger.v3.oas.annotations.Operation;  
10 -  
11 -import jakarta.validation.constraints.*;  
12 -import jakarta.validation.*;  
13 -import jakarta.servlet.http.*;  
14 -import java.util.*;  
15 -import java.io.IOException;  
16 - 3 +import com.zteits.urbanops.framework.apilog.core.annotation.ApiAccessLog;
  4 +import com.zteits.urbanops.framework.common.pojo.CommonResult;
17 import com.zteits.urbanops.framework.common.pojo.PageParam; 5 import com.zteits.urbanops.framework.common.pojo.PageParam;
18 import com.zteits.urbanops.framework.common.pojo.PageResult; 6 import com.zteits.urbanops.framework.common.pojo.PageResult;
19 -import com.zteits.urbanops.framework.common.pojo.CommonResult;  
20 import com.zteits.urbanops.framework.common.util.object.BeanUtils; 7 import com.zteits.urbanops.framework.common.util.object.BeanUtils;
21 -import static com.zteits.urbanops.framework.common.pojo.CommonResult.success;  
22 -  
23 import com.zteits.urbanops.framework.excel.core.util.ExcelUtils; 8 import com.zteits.urbanops.framework.excel.core.util.ExcelUtils;
24 -  
25 -import com.zteits.urbanops.framework.apilog.core.annotation.ApiAccessLog;  
26 -import static com.zteits.urbanops.framework.apilog.core.enums.OperateTypeEnum.*;  
27 -  
28 -import com.zteits.urbanops.module.workorder.controller.admin.maininfo.vo.*; 9 +import com.zteits.urbanops.module.workorder.controller.admin.attachment.vo.AttachmentReqVO;
  10 +import com.zteits.urbanops.module.workorder.controller.admin.maininfo.vo.MainInfoPageReqVO;
  11 +import com.zteits.urbanops.module.workorder.controller.admin.maininfo.vo.MainInfoRespVO;
  12 +import com.zteits.urbanops.module.workorder.controller.admin.maininfo.vo.MainInfoSaveReqVO;
  13 +import com.zteits.urbanops.module.workorder.convert.maininfo.MainInfoConvert;
  14 +import com.zteits.urbanops.module.workorder.dal.dataobject.attachment.AttachmentDO;
29 import com.zteits.urbanops.module.workorder.dal.dataobject.maininfo.MainInfoDO; 15 import com.zteits.urbanops.module.workorder.dal.dataobject.maininfo.MainInfoDO;
  16 +import com.zteits.urbanops.module.workorder.service.attachment.AttachmentService;
30 import com.zteits.urbanops.module.workorder.service.maininfo.MainInfoService; 17 import com.zteits.urbanops.module.workorder.service.maininfo.MainInfoService;
  18 +import io.swagger.v3.oas.annotations.Operation;
  19 +import io.swagger.v3.oas.annotations.Parameter;
  20 +import io.swagger.v3.oas.annotations.tags.Tag;
  21 +import jakarta.annotation.Resource;
  22 +import jakarta.servlet.http.HttpServletResponse;
  23 +import jakarta.validation.Valid;
  24 +import org.apache.commons.collections4.CollectionUtils;
  25 +import org.springframework.security.access.prepost.PreAuthorize;
  26 +import org.springframework.validation.annotation.Validated;
  27 +import org.springframework.web.bind.annotation.*;
  28 +
  29 +import java.io.IOException;
  30 +import java.util.Collections;
  31 +import java.util.List;
  32 +import java.util.Map;
  33 +import java.util.stream.Collectors;
  34 +
  35 +import static com.zteits.urbanops.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
  36 +import static com.zteits.urbanops.framework.common.pojo.CommonResult.success;
31 37
32 @Tag(name = "管理后台 - 工单信息") 38 @Tag(name = "管理后台 - 工单信息")
33 @RestController 39 @RestController
@@ -38,6 +44,9 @@ public class MainInfoController { @@ -38,6 +44,9 @@ public class MainInfoController {
38 @Resource 44 @Resource
39 private MainInfoService mainInfoService; 45 private MainInfoService mainInfoService;
40 46
  47 + @Resource
  48 + private AttachmentService attachmentService;
  49 +
41 @PostMapping("/create") 50 @PostMapping("/create")
42 @Operation(summary = "创建工单信息") 51 @Operation(summary = "创建工单信息")
43 @PreAuthorize("@ss.hasPermission('workorder:main-info:create')") 52 @PreAuthorize("@ss.hasPermission('workorder:main-info:create')")
@@ -85,7 +94,34 @@ public class MainInfoController { @@ -85,7 +94,34 @@ public class MainInfoController {
85 @PreAuthorize("@ss.hasPermission('workorder:main-info:query')") 94 @PreAuthorize("@ss.hasPermission('workorder:main-info:query')")
86 public CommonResult<PageResult<MainInfoRespVO>> getMainInfoPage(@Valid MainInfoPageReqVO pageReqVO) { 95 public CommonResult<PageResult<MainInfoRespVO>> getMainInfoPage(@Valid MainInfoPageReqVO pageReqVO) {
87 PageResult<MainInfoDO> pageResult = mainInfoService.getMainInfoPage(pageReqVO); 96 PageResult<MainInfoDO> pageResult = mainInfoService.getMainInfoPage(pageReqVO);
88 - return success(BeanUtils.toBean(pageResult, MainInfoRespVO.class)); 97 + // 2. 初始化附件映射(默认空Map,避免后续空指针)
  98 + Map<String, AttachmentDO> attachmentMap = Collections.emptyMap();
  99 +
  100 + // 3. 空值防护:分页结果非空且列表非空时,才查询附件
  101 + if (pageResult != null && !CollectionUtils.isEmpty(pageResult.getList())) {
  102 + // 提取订单号列表
  103 + List<String> orderNoList = pageResult.getList().stream()
  104 + .map(MainInfoDO::getOrderNo)
  105 + .filter(orderNo -> orderNo != null && !orderNo.isBlank())
  106 + .collect(Collectors.toList());
  107 +
  108 + // 若订单号列表非空,查询附件;否则跳过
  109 + if (!CollectionUtils.isEmpty(orderNoList)) {
  110 + List<AttachmentDO> attachmentDOList = attachmentService.getAttachmentByOrderNo(orderNoList);
  111 + // 构建订单号→附件对象的映射(处理重复key,取第一个对象)
  112 + if (!CollectionUtils.isEmpty(attachmentDOList)) {
  113 + attachmentMap = attachmentDOList.stream()
  114 + .filter(attachmentDO -> "01".equals(attachmentDO.getBusiType()))
  115 + .collect(Collectors.toMap(
  116 + AttachmentDO::getOrderNo, // key:订单号
  117 + attachmentDO -> attachmentDO, // value:附件对象
  118 + (existing, replacement) -> existing // 重复key时保留已有值
  119 + ));
  120 + }
  121 + }
  122 + }
  123 + // 4. 转换并返回结果
  124 + return success(MainInfoConvert.INSTANCE.buildMainInfoPage(pageResult, attachmentMap));
89 } 125 }
90 126
91 @GetMapping("/export-excel") 127 @GetMapping("/export-excel")
@@ -101,4 +137,4 @@ public class MainInfoController { @@ -101,4 +137,4 @@ public class MainInfoController {
101 BeanUtils.toBean(list, MainInfoRespVO.class)); 137 BeanUtils.toBean(list, MainInfoRespVO.class));
102 } 138 }
103 139
104 -}  
105 \ No newline at end of file 140 \ No newline at end of file
  141 +}
urbanops-module-workorder/src/main/java/com/zteits/urbanops/module/workorder/controller/admin/maininfo/vo/MainInfoRespVO.java
@@ -32,7 +32,7 @@ public class MainInfoRespVO { @@ -32,7 +32,7 @@ public class MainInfoRespVO {
32 private String orderName; 32 private String orderName;
33 33
34 @Schema(description = "来源ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1828") 34 @Schema(description = "来源ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1828")
35 - @ExcelProperty("来源ID") 35 + @ExcelProperty("来源ID 问题来源 1、巡查,2、游客居民,3、12345,4、网格 5、大区经理")
36 private Integer sourceId; 36 private Integer sourceId;
37 37
38 @Schema(description = "来源名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") 38 @Schema(description = "来源名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
@@ -135,4 +135,6 @@ public class MainInfoRespVO { @@ -135,4 +135,6 @@ public class MainInfoRespVO {
135 @ExcelProperty("创建时间") 135 @ExcelProperty("创建时间")
136 private LocalDateTime createTime; 136 private LocalDateTime createTime;
137 137
138 -}  
139 \ No newline at end of file 138 \ No newline at end of file
  139 + @Schema(description = "文件名称")
  140 + private String fileNames;
  141 +}
urbanops-module-workorder/src/main/java/com/zteits/urbanops/module/workorder/convert/maininfo/MainInfoConvert.java 0 → 100644
  1 +package com.zteits.urbanops.module.workorder.convert.maininfo;
  2 +
  3 +import com.zteits.urbanops.framework.common.pojo.PageResult;
  4 +import com.zteits.urbanops.framework.common.util.collection.CollectionUtils;
  5 +import com.zteits.urbanops.framework.common.util.object.BeanUtils;
  6 +import com.zteits.urbanops.module.workorder.controller.admin.maininfo.vo.MainInfoRespVO;
  7 +import com.zteits.urbanops.module.workorder.dal.dataobject.attachment.AttachmentDO;
  8 +import com.zteits.urbanops.module.workorder.dal.dataobject.maininfo.MainInfoDO;
  9 +import org.mapstruct.Mapper;
  10 +import org.mapstruct.factory.Mappers;
  11 +
  12 +import java.util.List;
  13 +import java.util.Map;
  14 +
  15 +/**
  16 + * @Classname MainInfoConvert
  17 + * @Description 工单转换
  18 + * @Date 2025/12/16 22:57
  19 + * @Created by wangqian
  20 + */
  21 +@Mapper
  22 +public interface MainInfoConvert {
  23 +
  24 + MainInfoConvert INSTANCE = Mappers.getMapper(MainInfoConvert.class);
  25 +
  26 + default PageResult<MainInfoRespVO> buildMainInfoPage(PageResult<MainInfoDO> pageResult, Map<String, AttachmentDO> attachmentMap) {
  27 + List<MainInfoRespVO> mainInfoVOList = CollectionUtils.convertList(pageResult.getList(), mainInfoDO -> {
  28 + MainInfoRespVO mainInfoVo = BeanUtils.toBean(mainInfoDO, MainInfoRespVO.class);
  29 + AttachmentDO attachmentDO = attachmentMap.get(mainInfoDO.getOrderNo());
  30 + mainInfoVo.setFileNames(attachmentDO.getFileNames());
  31 + return mainInfoVo;
  32 + });
  33 + return new PageResult<>(mainInfoVOList, pageResult.getTotal());
  34 + }
  35 +}
urbanops-module-workorder/src/main/java/com/zteits/urbanops/module/workorder/service/attachment/AttachmentService.java
@@ -66,5 +66,11 @@ public interface AttachmentService { @@ -66,5 +66,11 @@ public interface AttachmentService {
66 * @return 工单附件信息 66 * @return 工单附件信息
67 */ 67 */
68 List<AttachmentDO> getAttachmentByCondition(AttachmentReqVO reqVO); 68 List<AttachmentDO> getAttachmentByCondition(AttachmentReqVO reqVO);
69 - 69 + /**
  70 + * 获得工单附件信息
  71 + *
  72 + * @param orderNolist 编号
  73 + * @return 工单附件信息
  74 + */
  75 + List<AttachmentDO> getAttachmentByOrderNo(List<String> orderNolist);
70 } 76 }
urbanops-module-workorder/src/main/java/com/zteits/urbanops/module/workorder/service/attachment/AttachmentServiceImpl.java
@@ -3,6 +3,7 @@ package com.zteits.urbanops.module.workorder.service.attachment; @@ -3,6 +3,7 @@ package com.zteits.urbanops.module.workorder.service.attachment;
3 import cn.hutool.core.collection.CollUtil; 3 import cn.hutool.core.collection.CollUtil;
4 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 4 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
5 import com.baomidou.mybatisplus.core.toolkit.StringUtils; 5 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
  6 +import org.apache.commons.collections4.CollectionUtils;
6 import org.springframework.stereotype.Service; 7 import org.springframework.stereotype.Service;
7 import jakarta.annotation.Resource; 8 import jakarta.annotation.Resource;
8 import org.springframework.validation.annotation.Validated; 9 import org.springframework.validation.annotation.Validated;
@@ -98,4 +99,14 @@ public class AttachmentServiceImpl implements AttachmentService { @@ -98,4 +99,14 @@ public class AttachmentServiceImpl implements AttachmentService {
98 } 99 }
99 return attachmentMapper.selectList(queryWrapper); 100 return attachmentMapper.selectList(queryWrapper);
100 } 101 }
  102 +
  103 + @Override
  104 + public List<AttachmentDO> getAttachmentByOrderNo(List<String> orderNolist) {
  105 + if (CollectionUtils.isEmpty(orderNolist)) {
  106 + throw exception0(BAD_REQUEST.getCode(),"工单号不能为空");
  107 + }
  108 + LambdaQueryWrapper<AttachmentDO> queryWrapper = new LambdaQueryWrapper<>();
  109 + queryWrapper.in(AttachmentDO::getOrderNo, orderNolist);
  110 + return attachmentMapper.selectList(queryWrapper);
  111 + }
101 } 112 }
urbanops-module-workorder/src/main/java/com/zteits/urbanops/module/workorder/service/materialdetail/MaterialDetailServiceImpl.java
@@ -119,6 +119,13 @@ public class MaterialDetailServiceImpl implements MaterialDetailService { @@ -119,6 +119,13 @@ public class MaterialDetailServiceImpl implements MaterialDetailService {
119 throw exception0(BAD_REQUEST.getCode(),"订单号"+materialDetailDO.getOrderNo()+"不存在"); 119 throw exception0(BAD_REQUEST.getCode(),"订单号"+materialDetailDO.getOrderNo()+"不存在");
120 } 120 }
121 } 121 }
  122 + //已登记
  123 + for (MaterialDetailDO materialDetailDO : materialDetailList) {
  124 + MaterialDetailDO materialDetailDO1 = materialDetailMapper.selectOne(MaterialDetailDO::getMaterialId, materialDetailDO.getMaterialId());
  125 + if (materialDetailDO1 != null) {
  126 + throw exception0(BAD_REQUEST.getCode(),materialDetailDO.getMaterialName()+"已登记");
  127 + }
  128 + }
122 //耗材出库 129 //耗材出库
123 for (MaterialDetailDO materialDetailDO : materialDetailList) { 130 for (MaterialDetailDO materialDetailDO : materialDetailList) {
124 MaterialInventoryOutDto outDto = new MaterialInventoryOutDto(); 131 MaterialInventoryOutDto outDto = new MaterialInventoryOutDto();