|
|
@@ -1,5 +1,6 @@
|
|
|
package org.springblade.app.controller;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.plugins.Page;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.apache.commons.io.FilenameUtils;
|
|
|
@@ -7,13 +8,18 @@ import org.apache.commons.lang.StringUtils;
|
|
|
import org.springblade.community.entity.Residential;
|
|
|
import org.springblade.community.feign.IResidentialClient;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
+import org.springblade.core.tool.utils.Func;
|
|
|
+import org.springblade.core.tool.utils.StringUtil;
|
|
|
import org.springblade.estate.dto.RepairDTO;
|
|
|
import org.springblade.estate.entity.Repair;
|
|
|
+import org.springblade.estate.feign.ICarClient;
|
|
|
import org.springblade.estate.feign.IRepairClient;
|
|
|
import org.springblade.estate.vo.RepairVO;
|
|
|
import org.springblade.person.entity.HouseUser;
|
|
|
import org.springblade.person.feign.IHouseUserClient;
|
|
|
import org.springblade.person.vo.HouseUserVO;
|
|
|
+import org.springblade.system.expand.feign.IConfClient;
|
|
|
+import org.springframework.util.Assert;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
@@ -24,10 +30,7 @@ import java.io.IOException;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.ZoneId;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
|
/**
|
|
|
@@ -41,63 +44,45 @@ public class EstateRepairController {
|
|
|
private final IRepairClient repairClient;
|
|
|
private final IResidentialClient residentialClient;
|
|
|
private final IHouseUserClient houseUserClient;
|
|
|
+ private final IConfClient confClient;
|
|
|
|
|
|
@PostMapping(value = "/estateRepairList")
|
|
|
- public Map<String,Object> getEstateRepairList(@RequestBody RepairDTO estateRepairDto){
|
|
|
- Map<String,Object> map = new HashMap<>();
|
|
|
-// EstateRepairDto
|
|
|
- R<Page<Repair>> page = this.repairClient.page(estateRepairDto);
|
|
|
- if(page != null &&page.getData()!=null){
|
|
|
- map.put("estateRepairList",page.getData());
|
|
|
- }
|
|
|
- return map;
|
|
|
+ public R<IPage<RepairVO>> getEstateRepairList(@RequestBody RepairDTO repairDTO){
|
|
|
+ R<IPage<RepairVO>> page = this.repairClient.page(repairDTO);
|
|
|
+ return page;
|
|
|
}
|
|
|
|
|
|
@PostMapping(value = "/addEstateRepair")
|
|
|
- public Map<String,Object> addEstateRepair(@RequestBody RepairDTO estateRepairDto){
|
|
|
- Map<String,Object> map = new HashMap<>();
|
|
|
- estateRepairDto.setRepairNo(generateRepairNO());
|
|
|
+ public R addEstateRepair(@RequestBody RepairDTO repairDTO){
|
|
|
+ repairDTO.setRepairNo(generateRepairNO());
|
|
|
Residential searchResidential = new Residential();
|
|
|
- Residential residentialById = residentialClient.detail(searchResidential);
|
|
|
- if(residentialById != null){
|
|
|
- estateRepairDto.setTenantId(residentialById.getTenantId());
|
|
|
- }else{
|
|
|
- map.put("add_result", "小区不存在");
|
|
|
- }
|
|
|
+ Residential residential = residentialClient.detail(searchResidential);
|
|
|
+ Assert.notNull(residential, "小区不存在");
|
|
|
+ repairDTO.setTenantId(residential.getTenantId());
|
|
|
HouseUser searchHouseUser = new HouseUser();
|
|
|
HouseUserVO houseUserVO = houseUserClient.detail(searchHouseUser);
|
|
|
if(houseUserVO != null){
|
|
|
- estateRepairDto.setReportor(houseUserVO.getName());
|
|
|
- estateRepairDto.setReportorPhone(houseUserVO.getPhone());
|
|
|
- }
|
|
|
- //处理图片
|
|
|
- Object pic = map.get("pic");
|
|
|
- if(pic != null){
|
|
|
-
|
|
|
+ repairDTO.setReportor(houseUserVO.getName());
|
|
|
+ repairDTO.setReportorPhone(houseUserVO.getPhone());
|
|
|
}
|
|
|
- boolean submit = this.repairClient.submit(estateRepairDto);
|
|
|
- if(submit){
|
|
|
- map.put("add_result",submit);
|
|
|
- }else{
|
|
|
- map.put("add_result", "后台程序异常");
|
|
|
+ if(StringUtil.isNotBlank(repairDTO.getPic())){
|
|
|
+ List<String> picList = Func.toStrList(repairDTO.getPic());
|
|
|
+ List<String> savePicList = new ArrayList<>();
|
|
|
+ for(String pic : picList){
|
|
|
+ savePicList.add(confClient.removePrefix(pic));
|
|
|
+ }
|
|
|
+ repairDTO.setPic(StringUtil.join(savePicList));
|
|
|
}
|
|
|
- return map;
|
|
|
+ boolean submit = this.repairClient.submit(repairDTO);
|
|
|
+ return R.status(submit);
|
|
|
}
|
|
|
|
|
|
@PostMapping(value = "/estateRepairDetail")
|
|
|
- public Map<String,Object> estateDetail(@RequestBody Repair estateRepair1){
|
|
|
- Map<String,Object> map = new HashMap<>();
|
|
|
+ public R<RepairVO> estateDetail(@RequestBody RepairDTO repairDTO){
|
|
|
Repair searchRepair = new Repair();
|
|
|
- searchRepair.setId(estateRepair1.getId());
|
|
|
- RepairVO detail = this.repairClient.detail(searchRepair);
|
|
|
- if(detail != null){
|
|
|
-
|
|
|
- map.put("estateRepairDetail",detail);
|
|
|
- }else{
|
|
|
- map.put("estateRepairDetail", "报修记录不存在");
|
|
|
- }
|
|
|
-
|
|
|
- return map;
|
|
|
+ searchRepair.setId(repairDTO.getId());
|
|
|
+ RepairVO repairVO = this.repairClient.detail(searchRepair);
|
|
|
+ return R.data(repairVO);
|
|
|
}
|
|
|
|
|
|
|