package com.newfiber.api.mobile.controller; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.date.DateUnit; import cn.hutool.core.date.DateUtil; 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.BaseController; 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.DateUtils; 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.ProblemStatistical; import com.newfiber.api.mobile.model.domain.ProcessProblem; import com.newfiber.api.mobile.model.domain.RiverBusinessPics; import com.newfiber.api.mobile.service.PatrolProblemService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.StringUtils; 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; import javax.servlet.http.HttpServletRequest; import java.util.List; import java.util.Map; import java.util.stream.Collectors; /** * Controller * @author xcc * @date 2018-12-04 16:39:34 */ @RestController @RequestMapping("/patrolproblem") public class PatrolProblemController extends BaseController{ @Autowired private PatrolProblemService patrolProblemService; @Autowired private ProcessProblemDao processProblemDao; @Autowired private FileVisitProperty fileVisitProperty; @Autowired private RiverBusinessPicsDao riverBusinessPicsDao; /** * @Description: 按照巡查编号查询巡查问题 * @param param * @return: com.newfiber.api.core.bean.RespBodyObj<com.newfiber.api.mobile.model.domain.PatrolProblem> * @Author: Wmj * @Date: 2018/12/7 10:50 */ @PostMapping(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.getWebFile()+pics.getRiverPicsAddress()); } } } patrolProblem.setPicsList(picsList); } //查询问题处理流程 List<ProcessProblem> processProblemList = processProblemDao.queryListByProcessNo(patrolProblem.getProblemProcessNo()); patrolProblem.setProcessList(processProblemList); //获取流程所有图片 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.getWebFile()+pics.getRiverPicsAddress()); } } } patrolProblem.setProcessPicsList(picsList); } //当前巡查问题状态 int problemState = patrolProblem.getProblemState(); //已完结(查询办结部门,办结时间,办结历时以及最终处理结果) if(problemState == 2){ //办结部门(最后一条处理结果的用户User_No) if(!Strings.isNullOrEmpty(processProblemList.get(processProblemList.size() - 1).getOrgName())){ patrolProblem.setProcessResultDept(processProblemList.get(processProblemList.size() - 1).getOrgName()); } //办结时间(最后一条处理结果的时间Process_Time) patrolProblem.setProcessTime(processProblemList.get(processProblemList.size() - 1).getProcessTime()); //办结历时(最后一条处理结果的时间Process_Time 减去 第一条处理结果的时间Process_Time) long betweenDay = DateUtil.between(processProblemList.get(0).getProcessTime(), processProblemList.get(processProblemList.size() - 1).getProcessTime(), DateUnit.SECOND); patrolProblem.setDuration(DateUtils.formatSeconds(betweenDay)); //最终处理结果(最后一条处理结果的Process_Option) patrolProblem.setProcessResult(processProblemList.get(processProblemList.size() - 1).getProcessOption()); } } return RespBodyObj.ok(patrolProblemList); } /** * @Description: 查询所有巡河问题(警示栏用--无权限) * @param param * @return: com.newfiber.api.core.bean.RespBodyObj<com.newfiber.api.mobile.model.domain.PatrolProblem> * @Author: Wmj * @Date: 2018/12/7 10:50 */ @PostMapping("searchAllProblemList") @SysLog(value="查询所有巡河问题",actionType="4") public RespBodyObj<List<Map<String,Object>>> searchAllProblemList(@RequestBody ReqBodyObj<PatrolProblem> param){ if( param == null ){ return RespBodyObj.error(HttpCode.BAD_REQUEST); } List<Map<String,Object>> patrolProblemList = patrolProblemService.selectAllProblemList(); return RespBodyObj.ok(patrolProblemList); } /** * @Description: 按照巡查编号查询巡查问题(巡查问题分类) * @param param * @return: com.newfiber.api.core.bean.RespBodyObj<com.newfiber.api.mobile.model.domain.PatrolProblem> * @Author: Wmj * @Date: 2018/12/7 10:50 */ @PostMapping("searchProblemListByUserNo") @SysLog(value="按照巡查编号查询巡查问题(巡查问题分类)",actionType="4") public RespBodyObj<List<PatrolProblem>> queryProblemListByUserNo(@RequestBody ReqBodyObj<PatrolProblem> param){ if( param == null ){ return RespBodyObj.error(HttpCode.BAD_REQUEST); } Map<String,Object> map = JsonTools.transBean2Map(param.getData()); List<PatrolProblem> patrolProblemList = patrolProblemService.queryProblemListByUserNo(map); return RespBodyObj.ok(patrolProblemList); } /** * @Description: 按照巡查编号查询巡查问题(巡查问题分类待处理) * @param param * @return: com.newfiber.api.core.bean.RespBodyObj<com.newfiber.api.mobile.model.domain.PatrolProblem> * @Author: Wmj * @Date: 2018/12/7 10:50 */ @PostMapping("searchProblemListByUserNoToBeProcessed") @SysLog(value="按照巡查编号查询巡查问题(巡查问题分类待处理)",actionType="4") public RespBodyObj<List<PatrolProblem>> queryProblemListByUserNoToBeProcessed(@RequestBody ReqBodyObj<PatrolProblem> param,HttpServletRequest request){ if( param == null ){ return RespBodyObj.error(HttpCode.BAD_REQUEST); } List<PatrolProblem> patrolProblemList = patrolProblemService.queryProblemListByUserNoToBeProcessed(request.getHeader("userNo")); return RespBodyObj.ok(patrolProblemList); } /** * @Description: 按照巡查编号查询巡查问题(巡查问题分类已处理) * @param param * @return: com.newfiber.api.core.bean.RespBodyObj<com.newfiber.api.mobile.model.domain.PatrolProblem> * @Author: Wmj * @Date: 2018/12/7 10:50 */ @PostMapping("problemNew") @SysLog(value="按照巡查编号查询巡查问题(巡查问题分类已处理)",actionType="4") public RespBodyObj problemNew(@RequestBody ReqBodyObj<Map<String,String>> param,HttpServletRequest request){ if( param == null ){ return RespBodyObj.error(HttpCode.BAD_REQUEST); } String problemState = String.valueOf(param.getData().get("problemState")); Integer pageNo = param.getCurrent(); Integer size = param.getSize(); PageInfo<PatrolProblem> patrolProblemList = patrolProblemService.problemNew(request.getHeader("userNo"),problemState,pageNo,size); return RespBodyObj.ok(patrolProblemList); } /** * @Description: 按照巡查编号查询巡查问题(巡查问题分类已处理) * @param param * @return: com.newfiber.api.core.bean.RespBodyObj<com.newfiber.api.mobile.model.domain.PatrolProblem> * @Author: Wmj * @Date: 2018/12/7 10:50 */ @PostMapping("searchProblemListByUserNoProcessed") @SysLog(value="照巡查编号查询巡查问题(巡查问题分类已处理)",actionType="4") public RespBodyObj<List<PatrolProblem>> queryProblemListByUserNoProcessed(@RequestBody ReqBodyObj<PatrolProblem> param,HttpServletRequest request){ if( param == null ){ return RespBodyObj.error(HttpCode.BAD_REQUEST); } List<PatrolProblem> patrolProblemList = patrolProblemService.queryProblemListByUserNoProcessed(request.getHeader("userNo")); return RespBodyObj.ok(patrolProblemList); } /** * @Description: 按照巡查编号查询巡查问题(巡查问题分类已结案) * @param param * @return: com.newfiber.api.core.bean.RespBodyObj<com.newfiber.api.mobile.model.domain.PatrolProblem> * @Author: Wmj * @Date: 2018/12/7 10:50 */ @PostMapping("searchProblemListByUserNoClosed") @SysLog(value="按照巡查编号查询巡查问题(巡查问题分类已结案)",actionType="4") public RespBodyObj<List<PatrolProblem>> queryProblemListByUserNoClosed(@RequestBody ReqBodyObj<PatrolProblem> param,HttpServletRequest request){ if( param == null ){ return RespBodyObj.error(HttpCode.BAD_REQUEST); } List<PatrolProblem> patrolProblemList = patrolProblemService.queryProblemListByUserNoClosed(request.getHeader("userNo")); return RespBodyObj.ok(patrolProblemList); } /** 修改*/ @PostMapping(BaseUrl.UPDATE) @SysLog(value="修改巡查问题状态",actionType="3") public RespBodyObj<PatrolProblem> update(@RequestBody ReqBodyObj<PatrolProblem> param,HttpServletRequest request){ if(param == null){ return RespBodyObj.error(HttpCode.BAD_REQUEST); } Map<String,Object> map = JsonTools.transBean2Map(param.getData()); patrolProblemService.updateData(map,request); return RespBodyObj.ok(); } /** * 统计本级河湖对应时间段的巡查问题 * @author chenhonggang * @date 2018-12-06 * @param params * @return */ @PostMapping("problemStatistics") @SysLog(value="统计本级河湖对应时间段的巡查问题",actionType="4") public RespBodyObj<List<ProblemStatistical>> problemStatistics(@RequestBody ReqBodyObj<Map<String,Object>> params,HttpServletRequest request){ Map<String,Object> map = params.getData(); map.put("sid",request.getHeader("sid")); List<ProblemStatistical> result = patrolProblemService.problemStatistics(map); return RespBodyObj.ok(result); } /** * 统计下级河湖对应时间段的巡查问题 * @author chenhonggang * @date 2018-12-06 * @param params * @return */ @PostMapping("problenStatisticsSubordinate") @SysLog(value="统计下级河湖对应时间段的巡查问题",actionType="4") public RespBodyObj<List<ProblemStatistical>> problenStatisticsSubordinate(@RequestBody ReqBodyObj<Map<String,Object>> params,HttpServletRequest request){ Map<String,Object> map = params.getData(); map.put("sid",request.getHeader("sid")); List<ProblemStatistical> result = patrolProblemService.problenStatisticsSubordinate(map); return RespBodyObj.ok(result); } /** * 本级河长巡查事件统计 * @author chenhonggang * @date 2018-12-07 * @param params * @return */ @PostMapping("EventStatisticsThisLevel") @SysLog(value="本级河长巡查事件统计",actionType="4") public RespBodyObj<Map<String,Object>> EventStatisticsThisLevel(@RequestBody ReqBodyObj<Map<String,Object>> params,HttpServletRequest request){ Map<String,Object> map = params.getData(); map.put("sid",request.getHeader("sid")); Map<String,Object> result = patrolProblemService.InspectEvent(map); return RespBodyObj.ok(result); } /** * 对应下级区域巡查事件统计 * @author chenhonggang * @date 2018-12-07 * @param params * @return */ @PostMapping("EventStatisticsNextLevel") @SysLog(value="对应下级区域巡查事件统计",actionType="4") public RespBodyObj<Map<String,Object>> EventStatisticsNextLevel(@RequestBody ReqBodyObj<Map<String,Object>> params,HttpServletRequest request){ Map<String,Object> map = params.getData(); map.put("sid",request.getHeader("sid")); Map<String,Object> result = patrolProblemService.InspectEventSubordinate(map); return RespBodyObj.ok(result); } /** * 查询河流的巡查事件列表 * @author chenhonggang * @param params 起始时间 河流编号 * @return */ @PostMapping("queryByRiver") @SysLog(value="查询河流的巡查事件列表",actionType="4") public RespBodyObj<List<PatrolProblem>> queryByRiver(@RequestBody ReqBodyObj<Map<String,Object>> params){ Map<String,Object> map = params.getData(); List<PatrolProblem> reuslt = patrolProblemService.queryListByRiver(map); return RespBodyObj.ok(reuslt); } /** * 查询河流的巡查事件列表 * @author chenhonggang * @param params 起始时间 区域编号 * @return */ @PostMapping("problemTotalOfArea") @SysLog(value="查询河流的巡查事件列表",actionType="4") public RespBodyObj<List<ProblemStatistical>> problemTotalOfArea(@RequestBody ReqBodyObj<Map<String,Object>> params){ Map<String,Object> map = params.getData(); try { List<ProblemStatistical> reuslt = patrolProblemService.problemTotalOfArea(map); return RespBodyObj.ok(reuslt); }catch (Exception e){ e.printStackTrace(); return RespBodyObj.error("请求失败,日期格式问题"); } } /** 指派*/ @SysLog(value="指派",actionType="3") @PostMapping("/appoint") public RespBodyObj appoint(@RequestBody ReqBodyObj<PatrolProblem> param,HttpServletRequest request){ if(param == null){ return RespBodyObj.error(HttpCode.BAD_REQUEST); } patrolProblemService.appoint(param.getData(),request); return RespBodyObj.ok(); } /** 巡查*/ @SysLog(value="巡河检查",actionType="3") @PostMapping("/check") public RespBodyObj check(@RequestBody ReqBodyObj<PatrolProblem> param,HttpServletRequest request){ if(param == null){ return RespBodyObj.error(HttpCode.BAD_REQUEST); } patrolProblemService.check(param.getData(),request); return RespBodyObj.ok(); } /** 巡河人员处理*/ @SysLog(value="巡河人员处理",actionType="3") @PostMapping("/chiefCheck") public RespBodyObj chiefCheck(@RequestBody ReqBodyObj<PatrolProblem> param,HttpServletRequest request){ if(param == null){ return RespBodyObj.error(HttpCode.BAD_REQUEST); } patrolProblemService.chiefCheck(param.getData(),request); return RespBodyObj.ok(); } /** 处理人处理*/ @SysLog(value="处理人处理",actionType="3") @PostMapping("/handlerCheck") public RespBodyObj handlerCheck(@RequestBody ReqBodyObj<PatrolProblem> param,HttpServletRequest request){ if(param == null){ return RespBodyObj.error(HttpCode.BAD_REQUEST); } patrolProblemService.handlerCheck(param.getData(),request); return RespBodyObj.ok(); } /** 处理人驳回*/ @SysLog(value="处理人驳回",actionType="3") @PostMapping("/handlerRefuse") public RespBodyObj handlerRefuse(@RequestBody ReqBodyObj<PatrolProblem> param,HttpServletRequest request){ if(param == null){ return RespBodyObj.error(HttpCode.BAD_REQUEST); } patrolProblemService.handlerRefuse(param.getData(),request); return RespBodyObj.ok(); } /** 领导处理*/ @SysLog(value="领导处理",actionType="3") @PostMapping("/leaderCheck") public RespBodyObj leaderCheck(@RequestBody ReqBodyObj<PatrolProblem> param,HttpServletRequest request){ if(param == null){ return RespBodyObj.error(HttpCode.BAD_REQUEST); } patrolProblemService.leaderCheck(param.getData(),request); return RespBodyObj.ok(); } /** 领导驳回*/ @SysLog(value="领导驳回",actionType="3") @PostMapping("/leaderRefuse") public RespBodyObj leaderRefuse(@RequestBody ReqBodyObj<PatrolProblem> param,HttpServletRequest request){ if(param == null){ return RespBodyObj.error(HttpCode.BAD_REQUEST); } patrolProblemService.leaderRefuse(param.getData(),request); return RespBodyObj.ok(); } }