@@ -68,8 +68,17 @@ public interface ISysCityService extends IService<SysCity> { | |||
/** | |||
* 获取父级城市数据 | |||
* | |||
* @param cityId | |||
* @return | |||
*/ | |||
List<SysCity> getParentCityList(BigInteger cityId); | |||
/** | |||
* 根据城市ID获取子级城市列表 | |||
* | |||
* @param pid 父级ID | |||
* @return | |||
*/ | |||
List<BigInteger> getChildCityIds(BigInteger pid); | |||
} |
@@ -188,4 +188,34 @@ public class SysCityServiceImpl extends ServiceImpl<SysCityMapper, SysCity> impl | |||
} | |||
return parentList; | |||
} | |||
/** | |||
* 获取子级城市ID | |||
* | |||
* @param pid 上级城市 | |||
* @return | |||
*/ | |||
@Override | |||
public List<BigInteger> getChildCityIds(BigInteger pid) { | |||
QueryWrapper<SysCity> queryWrapper = new QueryWrapper<>(); | |||
queryWrapper.eq("pid", pid); | |||
queryWrapper.eq("mark", 1); | |||
List<BigInteger> cityIdsList = new ArrayList<>(); | |||
List<SysCity> cityList = sysCityMapper.selectList(queryWrapper); | |||
if (!cityList.isEmpty()) { | |||
cityList.forEach(item -> { | |||
// 获取子级 | |||
if (item.getLevel() <= 4) { | |||
List<BigInteger> itemList = this.getChildCityIds(item.getId()); | |||
if (!itemList.isEmpty()) { | |||
itemList.forEach(subItem -> { | |||
cityIdsList.add(subItem); | |||
}); | |||
} | |||
} | |||
cityIdsList.add(item.getId()); | |||
}); | |||
} | |||
return cityIdsList; | |||
} | |||
} |
@@ -0,0 +1,26 @@ | |||
package com.taauav.front.constant; | |||
import java.util.HashMap; | |||
import java.util.Map; | |||
/** | |||
* <p> | |||
* 巡检问题 模块常量 | |||
* </p> | |||
* | |||
* @author 鲲鹏 | |||
* @since 2020-05-14 | |||
*/ | |||
public class TauvInspectQuestionConstant { | |||
/** | |||
* 处理状态:1待指派 2待处理 3已完成 | |||
*/ | |||
public static Map<Integer, String> INSPECT_QUESTION_STATUS_LIST = new HashMap<Integer, String>() { | |||
{ | |||
put(1, "待指派"); | |||
put(2, "待处理"); | |||
put(3, "已完成"); | |||
} | |||
}; | |||
} |
@@ -1,6 +1,12 @@ | |||
package com.taauav.front.controller; | |||
import com.taauav.common.bean.Response; | |||
import com.taauav.front.query.TauvInspectQuestionQuery; | |||
import com.taauav.front.service.ITauvInspectQuestionService; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.PostMapping; | |||
import org.springframework.web.bind.annotation.RequestBody; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
@@ -15,7 +21,21 @@ import com.taauav.front.controller.FrontBaseController; | |||
* @since 2020-05-14 | |||
*/ | |||
@RestController | |||
@RequestMapping("/tauv-inspect-question") | |||
@RequestMapping("/front/inspectquestion") | |||
public class TauvInspectQuestionController extends FrontBaseController { | |||
@Autowired | |||
private ITauvInspectQuestionService inspectQuestionService; | |||
/** | |||
* 获取巡检问题列表 | |||
* | |||
* @param query 查询条件 | |||
* @return | |||
*/ | |||
@PostMapping("/index") | |||
public Response index(@RequestBody TauvInspectQuestionQuery query) { | |||
return inspectQuestionService.getList(query); | |||
} | |||
} |
@@ -1,7 +1,15 @@ | |||
package com.taauav.front.mapper; | |||
import com.baomidou.mybatisplus.core.metadata.IPage; | |||
import com.taauav.admin.dto.TauvReportDTO; | |||
import com.taauav.front.entity.TauvInspectQuestion; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import com.taauav.front.query.TauvInspectQuestionQuery; | |||
import com.taauav.front.vo.TauvInspectQuestionListVo; | |||
import org.apache.ibatis.annotations.Param; | |||
import org.springframework.web.bind.annotation.RequestParam; | |||
import java.util.List; | |||
/** | |||
* <p> | |||
@@ -13,4 +21,12 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
*/ | |||
public interface TauvInspectQuestionMapper extends BaseMapper<TauvInspectQuestion> { | |||
/** | |||
* 获取巡检问题列表 | |||
* | |||
* @param query 查询条件 | |||
* @return | |||
*/ | |||
List<TauvInspectQuestionListVo> getInspectQuestionList(IPage<TauvInspectQuestionListVo> page, @RequestParam("query") TauvInspectQuestionQuery query); | |||
} |
@@ -2,4 +2,34 @@ | |||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||
<mapper namespace="com.taauav.front.mapper.TauvInspectQuestionMapper"> | |||
<!-- 获取巡检问题列表 --> | |||
<select id="getInspectQuestionList" parameterType="com.taauav.front.query.TauvInspectQuestionQuery" resultType="com.taauav.front.vo.TauvInspectQuestionListVo"> | |||
SELECT q.id,q.question_no,q.`status`,f.src as file_src,o.content as question_type,f.description,d.driver_id,d.driver_name,d.driver_area,c.name as driver_area_name,i.inspect_time | |||
FROM tauv_inspect_file f | |||
INNER JOIN tauv_inspect_question q ON f.id=q.inspect_file_id | |||
INNER JOIN tauv_inspect_driver d ON d.id=f.inspect_driver_id | |||
INNER JOIN tauv_inspect i ON f.inspect_id=i.id | |||
INNER JOIN sys_city c ON c.id=d.driver_area | |||
INNER JOIN tauv_question_options o ON o.id=f.question_id | |||
WHERE q.mark=1 AND f.is_review=1 AND f.is_effective=1 AND f.`status`=1 AND f.mark=1 AND d.mark=1 AND i.mark=1 | |||
<if test="query.questionNo != null"> | |||
and q.question_no like concat('%', #{query.questionNo}, '%') | |||
</if> | |||
<if test="query.driverArea != null and query.driverArea !=''"> and d.driver_area in | |||
<foreach collection="query.driverArea" item="area" open="(" close=")" separator=","> | |||
#{area} | |||
</foreach> | |||
</if> | |||
<if test="query.driverName != null"> | |||
and d.driver_name like concat('%', #{query.driverName}, '%') | |||
</if> | |||
<if test="query.status != null and query.status > 0"> | |||
and q.status = #{query.status} | |||
</if> | |||
<if test="query.inspectTime != null and query.inspectTime !=''"> | |||
and i.inspect_time between #{query.inspectStartTime} and #{query.inspectEndTime} | |||
</if> | |||
ORDER BY q.id DESC | |||
</select> | |||
</mapper> |
@@ -0,0 +1,54 @@ | |||
package com.taauav.front.query; | |||
import com.taauav.common.core.mps.BaseQuery; | |||
import lombok.Data; | |||
import java.math.BigInteger; | |||
import java.util.List; | |||
/** | |||
* 巡检问题查询 | |||
*/ | |||
@Data | |||
public class TauvInspectQuestionQuery extends BaseQuery { | |||
/** | |||
* 问题编号 | |||
*/ | |||
private String questionNo; | |||
/** | |||
* 区划ID | |||
*/ | |||
private BigInteger driverAreaId; | |||
/** | |||
* 区划ID集合 | |||
*/ | |||
private BigInteger[] driverArea; | |||
/** | |||
* 河湖名称 | |||
*/ | |||
private String driverName; | |||
/** | |||
* 状态 | |||
*/ | |||
private String status; | |||
/** | |||
* 巡检时间 | |||
*/ | |||
private String inspectTime; | |||
/** | |||
* 巡检开始时间 | |||
*/ | |||
private String inspectStartTime; | |||
/** | |||
* 巡检结束时间 | |||
*/ | |||
private String inspectEndTime; | |||
} |
@@ -1,7 +1,9 @@ | |||
package com.taauav.front.service; | |||
import com.taauav.common.bean.Response; | |||
import com.taauav.front.entity.TauvInspectQuestion; | |||
import com.baomidou.mybatisplus.extension.service.IService; | |||
import com.taauav.front.query.TauvInspectQuestionQuery; | |||
/** | |||
* <p> | |||
@@ -13,4 +15,12 @@ import com.baomidou.mybatisplus.extension.service.IService; | |||
*/ | |||
public interface ITauvInspectQuestionService extends IService<TauvInspectQuestion> { | |||
/** | |||
* 获取巡检问题列表 | |||
* | |||
* @param query 查询条件 | |||
* @return | |||
*/ | |||
Response getList(TauvInspectQuestionQuery query); | |||
} |
@@ -1,10 +1,24 @@ | |||
package com.taauav.front.service.impl; | |||
import com.baomidou.mybatisplus.core.metadata.IPage; | |||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
import com.taauav.admin.service.ISysCityService; | |||
import com.taauav.common.bean.Response; | |||
import com.taauav.common.util.FunctionUtils; | |||
import com.taauav.front.constant.TauvInspectQuestionConstant; | |||
import com.taauav.front.entity.TauvInspectQuestion; | |||
import com.taauav.front.mapper.TauvInspectQuestionMapper; | |||
import com.taauav.front.query.TauvInspectQuestionQuery; | |||
import com.taauav.front.service.ITauvInspectQuestionService; | |||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |||
import com.taauav.front.vo.TauvInspectQuestionListVo; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import org.springframework.util.StringUtils; | |||
import java.math.BigInteger; | |||
import java.util.Arrays; | |||
import java.util.List; | |||
/** | |||
* <p> | |||
@@ -17,4 +31,47 @@ import org.springframework.stereotype.Service; | |||
@Service | |||
public class TauvInspectQuestionServiceImpl extends ServiceImpl<TauvInspectQuestionMapper, TauvInspectQuestion> implements ITauvInspectQuestionService { | |||
@Autowired | |||
private TauvInspectQuestionMapper inspectQuestionMapper; | |||
@Autowired | |||
private Response response; | |||
@Autowired | |||
private ISysCityService sysCityService; | |||
/** | |||
* 获取巡检问题列表 | |||
* | |||
* @param query 查询条件 | |||
* @return | |||
*/ | |||
@Override | |||
public Response getList(TauvInspectQuestionQuery query) { | |||
// 区划ID处理 | |||
if (query.getDriverAreaId() != null) { | |||
List<BigInteger> cityIds = sysCityService.getChildCityIds(query.getDriverAreaId()); | |||
// 加入当前选中的区划 | |||
cityIds.add(query.getDriverAreaId()); | |||
BigInteger[] integers = cityIds.toArray(new BigInteger[cityIds.size()]); | |||
query.setDriverArea(integers); | |||
} | |||
// 巡检时间处理 | |||
if (!StringUtils.isEmpty(query.getInspectTime())) { | |||
String startTime = FunctionUtils.formatTime(Integer.valueOf(query.getInspectTime()), "yyyy-MM-dd") + " 0:00:00"; | |||
String endTime = FunctionUtils.formatTime(Integer.valueOf(query.getInspectTime()), "yyyy-MM-dd") + " 23:59:59"; | |||
query.setInspectStartTime(startTime); | |||
query.setInspectEndTime(endTime); | |||
} | |||
IPage<TauvInspectQuestionListVo> page = new Page<>(query.getPage(), query.getPage()); | |||
List<TauvInspectQuestionListVo> inspectQuestionList = inspectQuestionMapper.getInspectQuestionList(page, query); | |||
if (!inspectQuestionList.isEmpty()) { | |||
inspectQuestionList.forEach(item -> { | |||
// 状态描述 | |||
item.setStatusName(TauvInspectQuestionConstant.INSPECT_QUESTION_STATUS_LIST.get(item.getStatus())); | |||
}); | |||
} | |||
page.setRecords(inspectQuestionList); | |||
return response.success(page); | |||
} | |||
} |
@@ -0,0 +1,75 @@ | |||
package com.taauav.front.vo; | |||
import com.fasterxml.jackson.annotation.JsonFormat; | |||
import lombok.Data; | |||
import org.springframework.format.annotation.DateTimeFormat; | |||
import java.math.BigInteger; | |||
import java.util.Date; | |||
@Data | |||
public class TauvInspectQuestionListVo { | |||
/** | |||
* 问题ID | |||
*/ | |||
private Integer id; | |||
/** | |||
* 问题编号 | |||
*/ | |||
private String questionNo; | |||
/** | |||
* 问题处理状态 | |||
*/ | |||
private Integer status; | |||
/** | |||
* 状态描述 | |||
*/ | |||
private String statusName; | |||
/** | |||
* 问题图片地址 | |||
*/ | |||
private String fileSrc; | |||
/** | |||
* 问题描述内容 | |||
*/ | |||
private String questionType; | |||
/** | |||
* 问题描述 | |||
*/ | |||
private String description; | |||
/** | |||
* 河湖ID | |||
*/ | |||
private Integer driverId; | |||
/** | |||
* 河湖名称 | |||
*/ | |||
private String driverName; | |||
/** | |||
* 区划ID | |||
*/ | |||
private BigInteger driverArea; | |||
/** | |||
* 区划名称 | |||
*/ | |||
private String driverAreaName; | |||
/** | |||
* 巡检时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
private Date inspectTime; | |||
} |