Commit 81a8fe8cae629b9a4e349dd9cb731c9101eb4a34
1 parent
8969241f
抢险任务提交
Showing
2 changed files
with
48 additions
and
0 deletions
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/emergencytask/vo/EmergencyTaskRespVO.java
| ... | ... | @@ -132,4 +132,13 @@ public class EmergencyTaskRespVO { |
| 132 | 132 | |
| 133 | 133 | private List<EmergencyMachineryDO> emergencyMachineryList; |
| 134 | 134 | |
| 135 | + @Schema(description = "归属(一级部门id)", requiredMode = Schema.RequiredMode.REQUIRED, example = "20800") | |
| 136 | + @ExcelProperty("归属(一级部门id)") | |
| 137 | + private String companyName; | |
| 138 | + | |
| 139 | + | |
| 140 | + @Schema(description = "部门(道路负责部门id)", requiredMode = Schema.RequiredMode.REQUIRED, example = "12055") | |
| 141 | + @ExcelProperty("部门") | |
| 142 | + private String deptName; | |
| 143 | + | |
| 135 | 144 | } |
| 136 | 145 | \ No newline at end of file | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/emergencytask/EmergencyTaskServiceImpl.java
| ... | ... | @@ -8,16 +8,22 @@ import com.alibaba.fastjson.JSONObject; |
| 8 | 8 | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| 9 | 9 | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| 10 | 10 | import com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils; |
| 11 | +import com.zteits.urbanops.module.garden.controller.admin.road.vo.RoadRespVO; | |
| 11 | 12 | import com.zteits.urbanops.module.garden.dal.dataobject.emergencytask.EmergencyMachineryDO; |
| 12 | 13 | import com.zteits.urbanops.module.garden.dal.mysql.emergencytask.EmergencyMachineryMapper; |
| 14 | +import com.zteits.urbanops.module.system.api.dept.DeptApi; | |
| 15 | +import com.zteits.urbanops.module.system.api.dept.dto.DeptRespDTO; | |
| 13 | 16 | import jodd.util.StringUtil; |
| 14 | 17 | import org.springframework.stereotype.Service; |
| 15 | 18 | import jakarta.annotation.Resource; |
| 19 | +import org.springframework.util.CollectionUtils; | |
| 16 | 20 | import org.springframework.util.StringUtils; |
| 17 | 21 | import org.springframework.validation.annotation.Validated; |
| 18 | 22 | import org.springframework.transaction.annotation.Transactional; |
| 19 | 23 | |
| 20 | 24 | import java.util.*; |
| 25 | +import java.util.stream.Collectors; | |
| 26 | + | |
| 21 | 27 | import com.zteits.urbanops.module.garden.controller.admin.emergencytask.vo.*; |
| 22 | 28 | import com.zteits.urbanops.module.garden.dal.dataobject.emergencytask.EmergencyTaskDO; |
| 23 | 29 | import com.zteits.urbanops.framework.common.pojo.PageResult; |
| ... | ... | @@ -46,6 +52,9 @@ public class EmergencyTaskServiceImpl implements EmergencyTaskService { |
| 46 | 52 | @Resource |
| 47 | 53 | private EmergencyMachineryMapper emergencyMachineryMapper; |
| 48 | 54 | |
| 55 | + @Resource | |
| 56 | + protected DeptApi deptApi; | |
| 57 | + | |
| 49 | 58 | @Transactional(rollbackFor = Exception.class) |
| 50 | 59 | @Override |
| 51 | 60 | public Long createEmergencyTask(EmergencyTaskSaveReqVO createReqVO) { |
| ... | ... | @@ -193,11 +202,41 @@ public class EmergencyTaskServiceImpl implements EmergencyTaskService { |
| 193 | 202 | emergencyTaskRespVO.setEmergencyMachineryList(detailList); |
| 194 | 203 | } |
| 195 | 204 | }); |
| 205 | + addDataInspectionPlan(listTwo); | |
| 196 | 206 | |
| 197 | 207 | // 转换返回 |
| 198 | 208 | return new PageResult<>(listTwo, page.getTotal()); |
| 199 | 209 | |
| 200 | 210 | } |
| 201 | 211 | |
| 212 | + /** | |
| 213 | + * 回填部门/公司/角色 | |
| 214 | + * @param list 分页对象 | |
| 215 | + */ | |
| 216 | + private void addDataInspectionPlan(List<EmergencyTaskRespVO> list ){ | |
| 217 | + if(CollectionUtils.isEmpty(list)){ | |
| 218 | + return ; | |
| 219 | + } | |
| 220 | + //公司 | |
| 221 | + Set<Long> companyIds = list.stream().map(EmergencyTaskRespVO::getCompanyId).collect(Collectors.toSet()); | |
| 222 | + //部门 | |
| 223 | + Set<Long> deptIds = list.stream().map(EmergencyTaskRespVO::getDeptId).collect(Collectors.toSet()); | |
| 224 | + deptIds.addAll(companyIds); | |
| 225 | + /*1.获取部门*/ | |
| 226 | + Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(deptIds); | |
| 227 | + | |
| 228 | + list.forEach(plan -> { | |
| 229 | + DeptRespDTO dept = deptMap.get(plan.getDeptId()); | |
| 230 | + if (dept != null) { | |
| 231 | + plan.setDeptName(dept.getName()); | |
| 232 | + | |
| 233 | + } | |
| 234 | + DeptRespDTO company = deptMap.get(plan.getCompanyId()); | |
| 235 | + if(company != null){ | |
| 236 | + plan.setCompanyName(company.getName()); | |
| 237 | + } | |
| 238 | + }); | |
| 239 | + } | |
| 240 | + | |
| 202 | 241 | |
| 203 | 242 | } |
| 204 | 243 | \ No newline at end of file | ... | ... |