Newer
Older
huludao / src / main / java / com / newfiber / api / pc / controller / app / AppAllRequestController.java
package com.newfiber.api.pc.controller.app;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.plugins.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.google.common.base.Strings;
import com.newfiber.api.config.FileVisitProperty;
import com.newfiber.api.core.annotation.SysLog;
import com.newfiber.api.core.base.BaseUrl;
import com.newfiber.api.core.bean.ReqBodyObj;
import com.newfiber.api.core.bean.RespBodyObj;
import com.newfiber.api.core.support.HttpCode;
import com.newfiber.api.core.utils.InstanceUtil;
import com.newfiber.api.core.utils.JsonTools;
import com.newfiber.api.mobile.dao.ProcessProblemDao;
import com.newfiber.api.mobile.dao.RiverBusinessPicsDao;
import com.newfiber.api.mobile.model.domain.PatrolProblem;
import com.newfiber.api.mobile.model.domain.ProcessProblem;
import com.newfiber.api.mobile.model.domain.RiverBusinessPics;
import com.newfiber.api.mobile.service.NewsService;
import com.newfiber.api.mobile.service.PatrolProblemService;
import com.newfiber.api.mobile.service.RiverPatrolService;
import com.newfiber.api.pc.dao.EventsManage.ComplainPicDao;
import com.newfiber.api.pc.dao.EventsManage.ComplaintDao;
import com.newfiber.api.pc.dao.RiverManage.RiverPicsDao;
import com.newfiber.api.pc.model.EventsManage.*;
import com.newfiber.api.pc.model.River.PatrolManageProblemDto;
import com.newfiber.api.pc.model.River.PatrolManageRecordDto;
import com.newfiber.api.pc.model.River.RiverPatrol;
import com.newfiber.api.pc.model.River.RiverPics;
import com.newfiber.api.pc.model.UserManager.SysOrganization;
import com.newfiber.api.pc.service.PatrolManageProblemService;
import com.newfiber.api.pc.service.PatrolManageRecordService;
import com.newfiber.api.pc.service.RestTemplateService;
import com.newfiber.api.pc.service.impl.ComplaintService;
import com.newfiber.api.pc.service.impl.ComplaintdetailsService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @ClassName AppAllRequestController
 * @Description TODO
 * @Author 张鸿志
 * @Date 2021年5月20日10:19:02 10:19
 * Version 1.0
 **/
@RestController
@RequestMapping("/app")
public class AppAllRequestController {

    @Autowired
    private ComplaintService complaintService;

    @Autowired
    private FileVisitProperty fileVisitProperty;

    @Autowired
    private RiverPatrolService riverPatrolService;

    @Autowired
    private RiverBusinessPicsDao riverBusinessPicsDao;

    @Autowired
    private PatrolProblemService patrolProblemService;

    @Autowired
    private ProcessProblemDao processProblemDao;

    @Autowired
    private RestTemplateService restTemplateService;

    @Autowired
    private ComplaintDao complaintDao;

    @Autowired
    private ComplaintdetailsService complaintdetailsService;

    @Autowired
    private ComplainPicDao complainPicDao;
    @Autowired
    private NewsService newsService;

    @Autowired
    private RiverPicsDao riverPicsDao;

    @Autowired
    private PatrolManageRecordService patrolManageRecordService;

    @Autowired
    private PatrolManageProblemService patrolManageProblemService;

    /** 节点文件保存路径 */
    @Value("${xnFile.path}")
    private String xnFilePath;

    /** 节点文件保存路径 */
    @Value("${xnFile.pic}")
    private String xnPicPath;

    @PostMapping("/complaint"+BaseUrl.QUERY_LIST)
    @SysLog(actionType = "4",value = "查询事件列表")
    public RespBodyObj<List<Complaint>> list(@RequestBody ReqBodyObj<Complaint> params) {
        Map<String, Object> map = InstanceUtil.transBean2Map(params.getData());
        String divisionNo = (String) map.get("divisionNo");
        Integer pageNo = params.getCurrent();
        Integer pageSize = params.getSize();
        List<Complaint> complaintList = complaintService.getComplainListByDivisionNo(divisionNo, pageNo, pageSize);
        if(!complaintList.isEmpty()){
            for (Complaint complaint : complaintList) {
                List<ComplainPic> picList = complaint.getPicList();
                if(complaint!=null && !picList.isEmpty()){
                    for (ComplainPic complainPic : picList) {
                        if(complainPic!=null && !StringUtils.isEmpty(complainPic.getPicPath())){
                            complainPic.setPicRealPath(fileVisitProperty.getAppFile()+complainPic.getPicPath());
                        }
                    }
                }
            }
        }
        return RespBodyObj.ok(complaintList);
    }

    @PostMapping("/riverpatrol"+BaseUrl.QUERY_BY_PARAM)
    @SysLog(value="河道巡查记录",actionType="4")
    public RespBodyObj<RiverPatrol> selectInfoByPatrolNo(@RequestBody ReqBodyObj<RiverPatrol> param,HttpServletRequest request){
        if(param == null){
            return RespBodyObj.error(HttpCode.BAD_REQUEST);
        }

        RiverPatrol riverPatrol = riverPatrolService.queryInfoByPatrolNo(request.getHeader("userNo"),param.getData().getPatrolNo());
        if(riverPatrol != null){
            if(riverPatrol.getPatrolPicsNo() != null && !riverPatrol.getPatrolPicsNo().equals("")){
                String riverPicsNo = riverPatrol.getPatrolPicsNo();
                List<RiverBusinessPics> picsList = riverBusinessPicsDao.queryListByPicsNo(riverPicsNo);
                if(!picsList.isEmpty()){
                    for (RiverBusinessPics riverBusinessPics : picsList) {
                        riverBusinessPics.setRealPath(fileVisitProperty.getAppFile()+riverBusinessPics.getRiverPicsAddress());
                    }
                }
                riverPatrol.setPicsList(picsList);
            }
        }
        return RespBodyObj.ok(riverPatrol);
    }


    @PostMapping("/patrolproblem"+BaseUrl.QUERY_BY_PARAM)
    @SysLog(value="河道巡查问题",actionType="4")
    public RespBodyObj<List<PatrolProblem>> queryListByPatrolNo(@RequestBody ReqBodyObj<PatrolProblem> param,HttpServletRequest request){
        if( param == null ){
            return RespBodyObj.error(HttpCode.BAD_REQUEST);
        }
        Map<String,Object> map = JsonTools.transBean2Map(param.getData());
        map.put("userNo",request.getHeader("userNo"));
        List<PatrolProblem> patrolProblemList = patrolProblemService.queryListByPatrolNo(map);

        if(CollectionUtil.isEmpty(patrolProblemList)){
            return RespBodyObj.ok(patrolProblemList);
        }
        for (PatrolProblem patrolProblem : patrolProblemList) {
            if(!Strings.isNullOrEmpty(patrolProblem.getProblemPicsNo())){
                //放入巡查问题图片
                String riverPicsNo = patrolProblem.getProblemPicsNo();
                List<RiverBusinessPics> picsList = riverBusinessPicsDao.queryListByPicsNo(riverPicsNo);
                if(!picsList.isEmpty()){
                    for (RiverBusinessPics pics : picsList) {
                        if(!StringUtils.isEmpty(pics.getRiverPicsAddress())){
                            pics.setRealPath(fileVisitProperty.getAppFile()+pics.getRiverPicsAddress());
                        }
                    }
                }
                patrolProblem.setPicsList(picsList);
            }
            //查询问题处理流程
            List<ProcessProblem> processProblemList = processProblemDao.queryListByProcessNo(patrolProblem.getProblemProcessNo());

            //获取流程所有图片
            List<String> riverPicsList = processProblemList.stream()
                    .map(ProcessProblem::getProcessPicsNo)
                    .collect(Collectors.toList());
            if(!CollectionUtil.isEmpty(riverPicsList)){
                //查询所有问题流程图片
                List<RiverBusinessPics> picsList = riverBusinessPicsDao.queryListByPicsNoList(riverPicsList);
                if(!picsList.isEmpty()){
                    for (RiverBusinessPics pics : picsList) {
                        if(!StringUtils.isEmpty(pics.getRiverPicsAddress())){
                            pics.setRealPath(fileVisitProperty.getAppFile()+pics.getRiverPicsAddress());
                        }
                    }
                }
                //拼接图片
                Map<String, List<RiverBusinessPics>> listMap = picsList.stream().collect(Collectors.groupingBy(RiverBusinessPics::getRiverPicsNo));
                for (ProcessProblem processProblem : processProblemList) {
                    if(listMap.get(processProblem.getProcessPicsNo()) != null){
                        processProblem.setProcessPicsList(listMap.get(processProblem.getProcessPicsNo()));
                    }
                }
            }
            patrolProblem.setProcessList(processProblemList);
        }
        return RespBodyObj.ok(patrolProblemList);
    }

    /**
     * 根据用户编号查询待办事件的详情
     *
     * @param param
     * @return
     */
    @PostMapping("/complaint/getComplaint")
    @SysLog(actionType = "4",value = "根据用户编号查询待办事件的详情")
    public RespBodyObj<Complaint> getComplaint(@RequestBody ReqBodyObj<Map<String, Object>> param, HttpServletRequest request) {
        if (param == null) {
            return RespBodyObj.error(HttpCode.BAD_REQUEST);
        }
        String userNo = request.getHeader("userNo");//用户编号
        String eventNo = String.valueOf(param.getData().get("eventNo"));
        //根据用户编号查询用户所属机构
        SysOrganization org = restTemplateService.getOrgByUserNo(userNo);

        try {
            if(org == null) return RespBodyObj.ok();
            Complaint complaint = complaintDao.getComplaint(eventNo);
            //设置图片长路径
            if(complaint!=null && !complaint.getPicList().isEmpty()){
                List<ComplainPic> picList = complaint.getPicList();
                for (ComplainPic pic : picList) {
                    if(!StringUtils.isEmpty(pic.getPicPath())){
                        pic.setPicRealPath(fileVisitProperty.getAppFile()+pic.getPicPath());
                    }
                }

            }
            return RespBodyObj.ok(complaint);
        }catch (Exception e){
            e.printStackTrace();
            return RespBodyObj.error();
        }
    }

    @PostMapping("/complaint"+BaseUrl.QUERY_ONE)
    @SysLog(actionType = "4",value = "查询事件")
    public RespBodyObj<Complaint> info(@RequestBody ReqBodyObj<Complaint> param) {
        if (param == null) {
            return RespBodyObj.error(HttpCode.BAD_REQUEST);
        }
        Complaint complaint = complaintService.getInfo(param.getData().getEventNo());
        if(complaint!=null){
            List<ComplainPic> picList = complaint.getPicList();
            if(!picList.isEmpty()){
                for (ComplainPic complainPic : picList) {
                    if(complainPic!=null && !StringUtils.isEmpty(complainPic.getPicPath())){
                        complainPic.setPicRealPath(fileVisitProperty.getAppFile()+complainPic.getPicPath());
                    }
                }
            }

        }
        int state = complaint.getEventStatusId();

        //已处理的投诉需要显示投诉处理情况
        Complaintdetails complaintdetails = new Complaintdetails();
        complaintdetails = complaintdetailsService.getByEventNo(param.getData().getEventNo());
        if (complaintdetails == null){
            complaintdetails = new Complaintdetails();
            complaintdetails.setSysOrganization(new SysOrganization());
            complaint.setComplaintdetails(complaintdetails);
        }else {
            complaint.setComplaintdetails(complaintdetails);
        }
        return RespBodyObj.ok(complaint);
    }

    /**
     * 查看我的举报
     * @param request
     * @return
     */
    @PostMapping(value = {"events/selectMyReport", "complaint/events/selectMyReport"},produces = "application/json;cahrset=UTF-8")
    @ResponseBody
    @SysLog(actionType = "4",value = "查看我的举报")
    public RespBodyObj selectMyReport(HttpServletRequest request,@RequestBody ReqBodyObj<Map<String,Object>> param) throws UnsupportedEncodingException, ParseException {
        Map<String,Object> map = param.getData();
        Integer eventSource = (map.get("eventSource")!= null&&map.get("eventSource")!= "")?(Integer)map.get("eventSource"):null;
        Integer eventUrgency = (map.get("eventUrgency")!= null&&map.get("eventUrgency")!= "")?(Integer)map.get("eventUrgency"):null;
        String startTime = (String) map.get("startTime");
        String endTime = (String) map.get("endTime");
        String eventType = (String) map.get("eventType");
        String str = (String) map.get("str");
        String divisionNo = (String) map.get("divisionNo");
        Integer eventStatus = (map.get("eventStatus")!= null&&map.get("eventStatus")!= "")?(Integer)map.get("eventStatus"):null;
        String tel = (String) map.get("tel");
        Integer page = param.getCurrent();
        Integer rows = param.getSize();
        String userNo = request.getHeader("userNo");
        ComplaintQuery query = new ComplaintQuery();
        ComplaintQuery.Criteria criteria = query.createCriteria();
        criteria.andComplainUserNoEqualTo(userNo);
        if (eventSource != null){
            criteria.andEventSourceEqualTo(eventSource);
        }

        if (eventUrgency != null){
            criteria.andComplainUrgencyEqualTo(eventUrgency);
        }
        if (eventStatus != null){
            criteria.andEventStatusIdEqualTo(eventStatus);
        }

        if (str != null && str != ""){

            String str1 = URLDecoder.decode(str,"UTF-8");
            criteria.andEventContentLike("%"+str1+"%");
        }
        if (tel != null && tel != ""){
            criteria.andComplainPersonTelLike("%"+tel+"%");
        }
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date time1 = null;
        Date time2 = null;
        if (startTime != null && endTime != null){
            time1 = sdf.parse(startTime);
            time2 = sdf.parse(endTime);
            criteria.andComplainTimeBetween(time1,time2);
        }
        if (eventType != null && eventType !=""){
            criteria.andComplainTypeEqualTo(eventType);
        }
        if (divisionNo != null && divisionNo !=""){
            criteria.andDivisionNoEqualTo(divisionNo);
        }



        if (page != null){
            query.setPageNo(page);
            query.setPageSize(rows);
        }

        if (page != null && rows != null){
            query.setPageNo(page);
            query.setPageSize(rows);
        }

        Page page1 = new Page();
        try {
            List<Complaint> list = complaintDao.selectByExample(query);
            for (Complaint c : list){
                String eventNo = c.getEventNo();//事件编号
                EventsPicQuery example = new EventsPicQuery();
                example.createCriteria().andEventsNoEqualTo(eventNo);
                List<ComplainPic> picList = complainPicDao.selectByExample(example);
                for (ComplainPic complainPic : picList) {
                    if(complainPic!=null && !StringUtils.isEmpty(complainPic.getPicPath())){
                        complainPic.setPicRealPath(fileVisitProperty.getAppFile()+complainPic.getPicPath());
                    }
                }
                c.setPicList(picList);

            }
            int count = complaintDao.countByExample(query);
            page1.setRecords(list);
            page1.setTotal(count);
            return RespBodyObj.ok(page1);
        }catch (Exception e){
            e.printStackTrace();
            return RespBodyObj.error();
        }


    }


    @PostMapping("/news/queryImportantNews")
    @SysLog(value="查询重要新闻列表",actionType="4")
    public RespBodyObj getImportantNews(@RequestBody ReqBodyObj<Map<String,Object>> param){
        PageHelper.startPage(0, 5);
        List<News> newsList = newsService.selectAll();
        PageInfo<News> result = new PageInfo<>();
        if(!newsList.isEmpty()){
            for (News news : newsList) {
                if(news!=null && !StringUtils.isEmpty(news.getTitleImg())){
                    news.setTitleImgPath(fileVisitProperty.getAppFile()+news.getTitleImg());
                }
                result = new PageInfo<News>(newsList);
            }
        }
        return RespBodyObj.ok(result);
    }

    @PostMapping("/news"+BaseUrl.QUERY_LIST)
    @SysLog(value="查询新闻列表",actionType="4")
    public RespBodyObj sslist(@RequestBody ReqBodyObj<Map<String,Object>> param){
        Integer page = param.getCurrent();
        Integer rows = param.getSize();
        PageHelper.startPage(page, rows);
        List<News> newsList = newsService.selectAll();
        PageInfo<News> result = new PageInfo<>();
        if(!newsList.isEmpty()){
            for (News news : newsList) {
                if(news!=null && !StringUtils.isEmpty(news.getTitleImg())){
                    news.setTitleImgPath(fileVisitProperty.getAppFile()+news.getTitleImg());
                }
            }
            result = new PageInfo<News>(newsList);
        }
        return RespBodyObj.ok(result);
    }

    @SysLog(value = "app查询区域新闻快报",actionType = "4")
    @PostMapping("/news/queryListByDiviseNo")
    public RespBodyObj queryListByDiviseNo(@RequestBody ReqBodyObj<Map<String, Object>> params){
        Integer pageSize = params.getSize();
        Integer pageNo = params.getCurrent();
        String divisionNo = String.valueOf(params.getData().get("divisionNo"));
        PageInfo<News> newsPageInfo = newsService.queryListByDiviseNo(divisionNo, pageSize, pageNo);
        if(!newsPageInfo.getList().isEmpty()){
            for (News news1 : newsPageInfo.getList()) {
                if(!StringUtils.isEmpty(news1.getTitleImg())){
                    news1.setTitleImgPath(fileVisitProperty.getAppFile()+news1.getTitleImg());
                }
            }
        }
        return RespBodyObj.ok(newsPageInfo);
    }

    @PostMapping("/cloud/uploadBatch")
    @SysLog(actionType = "1",value = "上传图片")
    public RespBodyObj upload(@RequestParam("file") MultipartFile[] file, HttpServletRequest request) throws Exception {
        StringBuilder strBD = new StringBuilder();
        strBD.append("|upload");
        String userNo = request.getHeader("userNo");
        List<String> imagePath = new ArrayList<>();
        List<RiverPics> result = new ArrayList<>();
        if (file != null) {
            for (int i = 0; i < file.length; i++) {
                MultipartFile file1 = file[i];
                String path = "";
                try {
                    String filename = file1.getOriginalFilename();
                    String suffix = filename.substring(filename.lastIndexOf("."));
                    Calendar instance = Calendar.getInstance();
                    //String filePath = instance.get(Calendar.YEAR)  + File.separator +(instance.get(Calendar.MARCH) + 1) + File.separator + filename;
                    StringBuffer sb = new StringBuffer();
                    sb.append(instance.get(Calendar.YEAR))
                            .append(File.separator)
                            .append(instance.get(Calendar.MARCH) + 1).
                            append(File.separator)
                            .append(System.currentTimeMillis()).append(suffix);
                    File fileName = new File(xnFilePath ,  sb.toString());
                    path = sb.toString();
                    if(!fileName.getParentFile().exists()){
                        fileName.mkdirs();
                    }
                    try{
                        file1.transferTo(fileName);
                    }catch (IOException e){
                        return RespBodyObj.error("上传失败");
                    }
                } catch (Exception ex) {
                    strBD.append("|ex:").append(ex.toString());
                } finally {
                }
                imagePath.add(path);
            }
            result = batchInsertImg(userNo, imagePath);
        }
        return RespBodyObj.ok(result);
    }

    private List<RiverPics> batchInsertImg(String userNo, List<String> imagePath) {
        List<RiverPics> result = new ArrayList<>();
        try {
            if(!imagePath.isEmpty()){
                for (String e : imagePath) {
                    RiverPics riverPics = new RiverPics();
                    riverPics.setRiverPicsName(e);
                    riverPics.setRiverPicsAddress(e);
                    riverPics.setRealPath(fileVisitProperty.getAppFile()+e);
                    riverPics.setCreateUserNo(userNo);
                    riverPicsDao.insert(riverPics);
                    result.add(riverPics);
                }
            }
        }catch (Exception e){
        }
        return result;
    }



    /**
     * 上传事件图片
     * @param file
     * @param request
     * @return
     * @throws Exception
     */
    @PostMapping("/cloud/uploadComplaintFile")
    @SysLog(actionType = "1",value = "上传事件图片")
    public RespBodyObj uploadComplaintFile(@RequestParam("file") MultipartFile[] file, HttpServletRequest request) throws Exception {
        StringBuilder strBD = new StringBuilder();
        strBD.append("|upload");
        String userNo = request.getHeader("userNo");
        List<String> imagePath = new ArrayList<>();
        List<ComplainPic> result = new ArrayList<>();
        if (file != null) {
            for (int i = 0; i < file.length; i++) {
                MultipartFile file1 = file[i];
                String path = "";
                String officeName = "";
                try {
                    String filename = file1.getOriginalFilename();
                    String suffix = filename.substring(filename.lastIndexOf("."));
                    officeName = filename;
                    Calendar instance = Calendar.getInstance();
                    //String filePath = instance.get(Calendar.YEAR)  + File.separator +(instance.get(Calendar.MARCH) + 1) + File.separator + filename;
                    StringBuffer sb = new StringBuffer();
                    sb.append(instance.get(Calendar.YEAR))
                            .append(File.separator)
                            .append(instance.get(Calendar.MARCH) + 1).
                            append(File.separator)
                            .append(System.currentTimeMillis()).append(suffix);
                    File fileName = new File(xnPicPath ,  sb.toString());
                    path = sb.toString();
                    if(!fileName.getParentFile().exists()){
                        fileName.mkdirs();
                    }
                    try{
                        file1.transferTo(fileName);
                    }catch (IOException e){
                        return RespBodyObj.error("上传失败");
                    }
                } catch (Exception ex) {
                    strBD.append("|ex:").append(ex.toString());
                } finally {
                }
                ComplainPic filePath = new ComplainPic();
                filePath.setPicPath(path);
                filePath.setPicRealPath(fileVisitProperty.getAppPic()+path);
                filePath.setPicName(officeName);
                result.add(filePath);
            }
        }
        return RespBodyObj.ok(result);
    }

    @PostMapping("/cloud/uploadRiverBussinessFile")
    @SysLog(actionType = "1",value = "上传河道相关的图片")
    public RespBodyObj uploadRiverBussinessFile(@RequestParam("file") MultipartFile[] file, HttpServletRequest request) throws Exception {
        StringBuilder strBD = new StringBuilder();
        strBD.append("|upload");
        String userNo = request.getHeader("userNo");
        List<String> imagePath = new ArrayList<>();
        List<RiverBusinessPics> result = new ArrayList<>();
        if (file != null) {
            for (int i = 0; i < file.length; i++) {
                MultipartFile file1 = file[i];
                String path = "";
                String officeName = "";
                try {
                    String filename = file1.getOriginalFilename();
                    String suffix = filename.substring(filename.lastIndexOf("."));
                    officeName = filename;
                    Calendar instance = Calendar.getInstance();
                    //String filePath = instance.get(Calendar.YEAR)  + File.separator +(instance.get(Calendar.MARCH) + 1) + File.separator + filename;
                    StringBuffer sb = new StringBuffer();
                    sb.append(instance.get(Calendar.YEAR))
                            .append(File.separator)
                            .append(instance.get(Calendar.MARCH) + 1).
                            append(File.separator)
                            .append(System.currentTimeMillis()).append(suffix);
                    File fileName = new File(xnFilePath ,  sb.toString());
                    path = sb.toString();
                    if(!fileName.getParentFile().exists()){
                        fileName.mkdirs();
                    }
                    try{
                        file1.transferTo(fileName);
                    }catch (IOException e){
                        return RespBodyObj.error("上传失败");
                    }
                } catch (Exception ex) {
                    strBD.append("|ex:").append(ex.toString());
                } finally {
                }
                RiverBusinessPics filePath = new RiverBusinessPics();
                filePath.setRiverPicsAddress(path);
                filePath.setRealPath(fileVisitProperty.getAppFile()+path);
                filePath.setRiverPicsName(officeName);
                result.add(filePath);
            }
        }
        return RespBodyObj.ok(result);
    }


   /* @ApiOperation(value = "app河道和管网列表")
    @ResponseBody
    @PostMapping("/patrol/list")
    public RespBodyObj hedaoupload(@RequestBody ReqBodyObj<Map<String, String>> params,HttpServletRequest request)  {
        try {
            Integer pageSize = params.getSize();
            Integer pageNo = params.getCurrent();
            String patrolName = String.valueOf(params.getData().get("patrolName"));
            String type = String.valueOf(params.getData().get("type"));
            String userNo = request.getHeader("userNo");
            PageHelper.startPage(pageNo,pageSize);
            List<PatrolManage> list = patrolManageDao.listAll(patrolName,type,userNo);
            if(list.isEmpty()){
                Page page1 = new Page();
                page1.setTotal(0);
                page1.setRecords(new ArrayList());
                return RespBodyObj.ok(page1);
            }
            PageInfo<PatrolManage> result = new PageInfo<>();
            if (!list.isEmpty()) {
                for (PatrolManage patrolManage : list) {
                    List<PartolManagePic> pics = patrolManage.getPartolManagePics();
                    if(!pics.isEmpty()){
                        for (PartolManagePic pic : pics) {
                            if(pic!=null && !org.apache.commons.lang3.StringUtils.isEmpty(pic.getPicAddress())){
                                pic.setRealPath(fileVisitProperty.getAppFile()+pic.getPicAddress());
                            }
                        }
                    }
                }
                result = new PageInfo<PatrolManage>(list);
            }
            Page page1 = new Page();
            page1.setRecords(result.getList());
            page1.setTotal(result.getTotal());
            return RespBodyObj.ok(page1);
        }catch (Exception e){
            System.out.println(e);
            return RespBodyObj.error();
        }

    }

    @ApiOperation(value = "app河道和管网列表")
    @ResponseBody
    @PostMapping("/patrol/getById")
    public RespBodyObj getById(@RequestBody ReqBodyObj<Map<String, String>> params,HttpServletRequest request)  {
        try {
            String id = String.valueOf(params.getData().get("id"));
            PatrolManage list = patrolManageDao.getById(id);
            if (list!=null) {
                List<PartolManagePic> pics = list.getPartolManagePics();
                if(!pics.isEmpty()){
                    for (PartolManagePic pic : pics) {
                        if(pic!=null && !org.apache.commons.lang3.StringUtils.isEmpty(pic.getPicAddress())){
                            pic.setRealPath(fileVisitProperty.getAppFile()+pic.getPicAddress());
                        }
                    }
                }
            }
            return RespBodyObj.ok(list);
        }catch (Exception e){
            return RespBodyObj.error();
        }

    }*/

    @PostMapping("/complaint/getPendingComplaintList")
    @SysLog(actionType = "4",value = "查询事件列表")
    public RespBodyObj<List<Complaint>> pendingTodo(@RequestBody ReqBodyObj<Map<String, Object>> param,HttpServletRequest request) {
        if (param == null) {
            return RespBodyObj.error(HttpCode.BAD_REQUEST);
        }
        RespBodyObj<List<Complaint>> pendingComplaint = complaintService.getPendingComplaint(param, request);
        setRealPath(pendingComplaint.getData());
        return pendingComplaint;
    }

    /**
     * 巡查记录列表
     * @param params
     * @param request
     * @return
     */
    @PostMapping("appPartList")
    @ApiOperation(value = "获取patrol_manage_record列表",notes="")
    @SysLog(actionType = "4",value = "巡查记录列表")
    public RespBodyObj<PageInfo<PatrolManageRecordDto>> appList(@RequestBody ReqBodyObj<Map<String, Object>> params, HttpServletRequest request) {
        Integer pageNo = params.getCurrent();
        Integer pageSize = params.getSize();
        String userNo = request.getHeader("userNo");
        String highest = request.getHeader("highest");
        String patrolType = String.valueOf(params.getData().get("patrolType"));
        PageInfo<PatrolManageRecordDto> patrolManageRecord =patrolManageRecordService.appPartList(userNo,highest,patrolType, pageNo, pageSize);
        return RespBodyObj.ok(patrolManageRecord);
    }

    /**
     * app巡查记录详情
     * @param params
     * @param request
     * @return
     */
    @PostMapping("appPatrolDetail")
    @ApiOperation(value = "获取patrol_manage_record列表",notes="")
    @SysLog(actionType = "4",value = "app巡查记录详情")
    public RespBodyObj<PatrolManageRecordDto> appPatrolDetail(@RequestBody ReqBodyObj<Map<String, Object>> params, HttpServletRequest request) {
        String userNo = request.getHeader("userNo");
        String highest = request.getHeader("highest");
        String patrolType = String.valueOf(params.getData().get("patrolType"));
        Integer patrolNo = Integer.valueOf(params.getData().get("patrolNo").toString());
        PatrolManageRecordDto patrolManageRecord =patrolManageRecordService.appPatrolDetail(userNo,highest, patrolType,patrolNo);
        return RespBodyObj.ok(patrolManageRecord);
    }

    /**
     * app 问题列表
     * @param params
     * @param request
     * @return
     */
    @PostMapping("appProblemList")
    @ApiOperation(value = "获取patrol_manage_problem列表",notes="")
    @SysLog(actionType = "4",value = "app问题列表")
    public RespBodyObj<List<PatrolManageProblemDto>> problemAppList(@RequestBody ReqBodyObj<Map<String, Object>> params, HttpServletRequest request) {
        Long patrolNo = Long.valueOf(params.getData().get("patrolNo").toString());
        List<PatrolManageProblemDto> patrolManageProblem =patrolManageProblemService.appProblemList(patrolNo);
        return RespBodyObj.ok(patrolManageProblem);
    }

    /**
     * app问题详情
     * @param params
     * @param request
     * @return
     */
    @PostMapping("appDetail")
    @ApiOperation(value = "获取patrol_manage_problem列表",notes="")
    @SysLog(actionType = "4",value = "app问题详情")
    public RespBodyObj<PatrolManageProblemDto> appDetail(@RequestBody ReqBodyObj<Map<String, Object>> params,HttpServletRequest request) {
        Long problemId = Long.valueOf(params.getData().get("problemId").toString());
        PatrolManageProblemDto patrolManageProblem =patrolManageProblemService.appProblemDetail(problemId,request.getHeader("userNo"),request.getHeader("highest"));
        return RespBodyObj.ok(patrolManageProblem);
    }

    private void setRealPath(List<Complaint> dataList) {
        if(!dataList.isEmpty()){
            for (Complaint complaint : dataList) {
                List<ComplainPic> picList = complaint.getPicList();
                if(!picList.isEmpty()){
                    for (ComplainPic pic : picList) {
                        if(!StringUtils.isEmpty(pic.getPicPath())){
                            pic.setPicRealPath(fileVisitProperty.getAppFile()+pic.getPicPath());
                        }
                    }
                }
            }
        }
    }


    public String getXnFilePath() {
        return xnFilePath;
    }

    public void setXnFilePath(String xnFilePath) {
        this.xnFilePath = xnFilePath;
    }
}