| | |
| | | package cn.gistack.sm.sjztmd.service.impl; |
| | | |
| | | import cn.gistack.sm.sjztmd.entity.TbDykeInvestigation; |
| | | import cn.gistack.sm.sjztmd.entity.TbDykeInvestigationState; |
| | | import cn.gistack.sm.sjztmd.entity.TbResGeneralInvestigation; |
| | | import cn.gistack.sm.sjztmd.entity.TbResGeneralInvestigationState; |
| | | import cn.gistack.sm.sjztmd.entity.*; |
| | | import cn.gistack.sm.sjztmd.mapper.TbDykeInvestigationMapper; |
| | | import cn.gistack.sm.sjztmd.mapper.TbResDykeMapper; |
| | | import cn.gistack.sm.sjztmd.mapper.TbResGeneralInvestigationMapper; |
| | | import cn.gistack.sm.sjztmd.service.*; |
| | | import cn.gistack.sm.sjztmd.vo.TbDykeInvestigationParam; |
| | | import cn.gistack.sm.sjztmd.vo.TbResGeneralInvestigationParam; |
| | | import cn.gistack.sm.sjztmd.statisticsVO.StatisticsBar; |
| | | import cn.gistack.sm.sjztmd.statisticsVO.StatisticsParams; |
| | | import cn.gistack.sm.sjztmd.statisticsVO.StatisticsPie; |
| | | import cn.gistack.sm.sjztmd.util.DownloadZipUtils; |
| | | import cn.gistack.sm.sjztmd.vo.*; |
| | | import com.alibaba.nacos.shaded.com.google.gson.Gson; |
| | | import com.alibaba.nacos.shaded.com.google.gson.JsonArray; |
| | | import com.alibaba.nacos.shaded.com.google.gson.JsonElement; |
| | | import com.alibaba.nacos.shaded.com.google.gson.JsonObject; |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import lombok.val; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.DateUtil; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.text.DecimalFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @PROJECT_NAME: skjcmanager |
| | |
| | | |
| | | @Autowired |
| | | private ITbDykeInvestigationStateService tbDykeInvestigationStateService; |
| | | |
| | | @Autowired |
| | | private IAttAdBaseService attAdBaseService; |
| | | |
| | | @Autowired |
| | | private TbResDykeMapper tbResDykeMapper; |
| | | |
| | | @Autowired |
| | | private HttpServletRequest request; |
| | | |
| | | // @Autowired |
| | | // private HttpServletResponse response; |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | tbDykeInvestigationStateService.saveOrUpdate(state); |
| | | |
| | | entity.setTbStateId(state.getGuid()); |
| | | return R.status(this.saveOrUpdate(entity)); |
| | | // return R.status(this.saveOrUpdate(entity)); |
| | | |
| | | // 如果有危害,设置危害长度只留一个 |
| | | if (entity.getHazardRating().equals("有危害")) { |
| | | QueryWrapper qw = new QueryWrapper(); |
| | | qw.eq("\"dyke_guid\"",entity.getDykeGuid()); |
| | | qw.eq("\"unit\"",entity.getUnit()); |
| | | long count = count(qw); |
| | | if (count > 0) { |
| | | entity.setDangerLength(0D); |
| | | } |
| | | } |
| | | |
| | | this.saveOrUpdate(entity); |
| | | return R.data(entity); |
| | | } |
| | | |
| | | @Override |
| | |
| | | // delete.eq("\"tb_state_id\"",state.getGuid()); |
| | | // boolean remove = remove(delete); |
| | | |
| | | String lengStr = "";//处理危害长度问题 |
| | | for (int i = 0; i < list.size(); i++) { |
| | | TbDykeInvestigation tbDykeInvestigation = list.get(i); |
| | | //id清空方便批量新增 |
| | |
| | | |
| | | //设置状态表id |
| | | tbDykeInvestigation.setTbStateId(state.getGuid()); |
| | | |
| | | |
| | | //处理危害长度 |
| | | if (tbDykeInvestigation.getHazardRating().equals("有危害")) { |
| | | if (lengStr.indexOf(tbDykeInvestigation.getUnit()) > -1) { |
| | | tbDykeInvestigation.setDangerLength(0D); |
| | | } |
| | | } |
| | | |
| | | lengStr = lengStr + tbDykeInvestigation.getUnit(); |
| | | |
| | | } |
| | | |
| | | return R.status(saveOrUpdateBatch(list)); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public StatisticsPie statisticsPie(StatisticsParams statisticsParams) { |
| | | if (StringUtil.isNotBlank(statisticsParams.getAdCode())){ |
| | | //若行政区划不为空 |
| | | String adCode =statisticsParams.getAdCode(); |
| | | |
| | | if (adCode.substring(0,4).indexOf("00") > -1) { |
| | | //前四位包含00说明是湖北省 4200/00000000 |
| | | adCode =StringUtil.format("%{}%",adCode.substring(0,2)); |
| | | } else if (adCode.substring(0,6).indexOf("00") > -1) { |
| | | //前六位包含00说明是市级 420100/000000 |
| | | // adCode = paramAd.substring(0,4); |
| | | adCode =StringUtil.format("%{}%",adCode.substring(0,4)); |
| | | }else if (adCode.substring(0,8).indexOf("00") > -1){ |
| | | //前8位包含00 说明是区级 42011700/0000 |
| | | // adCode = paramAd.substring(0,6); |
| | | adCode =StringUtil.format("%{}%",adCode.substring(0,6)); |
| | | } |
| | | statisticsParams.setAdCode(adCode); |
| | | } |
| | | |
| | | return baseMapper.statisticsPie(statisticsParams); |
| | | } |
| | | |
| | | @Override |
| | | public List<StatisticsBar> statisticsBar(StatisticsParams statisticsParams) { |
| | | // String adCode = statisticsParams.getAdCode(); |
| | | // String adGuid = ""; |
| | | // //默认省 |
| | | // String adGrad = "1"; |
| | | // |
| | | // //若行政区划不为空 |
| | | // if (StringUtil.isNotBlank(adCode)){ |
| | | // if (adCode.substring(0,4).indexOf("00") > -1) { |
| | | // //前四位包含00说明是湖北省 4200/00000000 |
| | | // adGrad = "1"; |
| | | // adGuid =StringUtil.format("%{}%",adCode.substring(0,2)); |
| | | // statisticsParams.setAdGuid(adGuid); |
| | | // } else if (adCode.substring(0,6).indexOf("00") > -1) { |
| | | // //前六位包含00说明是市级 420100/000000 |
| | | // adGrad = "2"; |
| | | // adGuid =StringUtil.format("%{}%",adCode.substring(0,4)); |
| | | // statisticsParams.setAdGuid(adGuid); |
| | | // }else if (adCode.substring(0,8).indexOf("00") > -1){ |
| | | // //前8位包含00 说明是区级 42011700/0000 |
| | | // adGrad = "3"; |
| | | // } |
| | | // } |
| | | // |
| | | // List<StatisticsBar> list = new ArrayList<>(); |
| | | // |
| | | // if (adGrad.equals("3")){ |
| | | // //区级展示自己 |
| | | // list = baseMapper.getCountyStatisticsBar(statisticsParams); |
| | | // }else if (adGrad.equals("2")){ |
| | | // //市级展示区 |
| | | // list = baseMapper.getCityStatisticsBar(statisticsParams); |
| | | // }else if (adGrad.equals("1")){ |
| | | // //省级展示市 |
| | | // list = baseMapper.getProvinceStatisticsBar(statisticsParams); |
| | | // } |
| | | |
| | | |
| | | AttAdBase attAdBase = attAdBaseService.getYwxtAdDetail(statisticsParams.getAdCode()); |
| | | statisticsParams.setAdGrad(attAdBase.getAdGrad()); |
| | | List list = baseMapper.getStatisticsBar(statisticsParams); |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @param page |
| | | * @return 操作状态 |
| | | */ |
| | | @Override |
| | | public List<String> downZip(IPage<ImageAndVideoVO> page,String type) throws IOException { |
| | | List<ImageAndVideoVO> iamgeAndVideoUrls; |
| | | if (type.equals("1")) { |
| | | iamgeAndVideoUrls = baseMapper.getIamgeAndVideoUrl(page); |
| | | }else { |
| | | iamgeAndVideoUrls = baseMapper.getIamgeAndVideoUrl(null); |
| | | } |
| | | |
| | | List<String> urls = new ArrayList<>(); |
| | | for (ImageAndVideoVO iamgeAndVideoUrl : iamgeAndVideoUrls) { |
| | | urls.add(iamgeAndVideoUrl.getImagesUrl()); |
| | | urls.add(iamgeAndVideoUrl.getVideosUrl()); |
| | | } |
| | | List<String> urlss = DownloadZipUtils.getUrls(urls); |
| | | if (urlss.isEmpty()) { |
| | | return null; |
| | | } |
| | | // }else { |
| | | // // 打印提取的URLs |
| | | // for (String url1 : urlss) { |
| | | // DownloadZipUtils.downloadFile(url1); |
| | | // } |
| | | // DownloadZipUtils.downloadZip(request, response,0); |
| | | return urlss; |
| | | } |
| | | |
| | | @Override |
| | | public List<DyketionVO> downloadZipCopy(IPage<TbResDykeVO> page,String type,TbResDykeVO tbResDykeVO) { |
| | | //获取已审批的数据 |
| | | List<DyketionVO> iamgeAndVideoUrlcopy = baseMapper.getIamgeAndVideoUrlcopy(); |
| | | |
| | | |
| | | for (DyketionVO dyketionVO : iamgeAndVideoUrlcopy) { |
| | | List<String> urls = new ArrayList<>(); |
| | | List<DyketionallVO> dyketionallVOS = new ArrayList<>(); |
| | | if(dyketionVO.getImagesUrl() != null){ |
| | | urls.add(dyketionVO.getImagesUrl()); |
| | | } |
| | | if(dyketionVO.getVideosUrl() != null) { |
| | | urls.add(dyketionVO.getVideosUrl()); |
| | | } |
| | | |
| | | //解析json中url 放入list集合中 |
| | | List<String> urlss = DownloadZipUtils.getUrls(urls); |
| | | |
| | | int counter=1; |
| | | for (String s : urlss) { |
| | | DyketionallVO dyketionallVO = new DyketionallVO(); |
| | | dyketionallVO.setUrlname(dyketionVO.getDname()+"+"+dyketionVO.getRn()+String.format("%02d", counter++)+s.substring(s.length() - 4)); |
| | | dyketionallVO.setUrl(s); |
| | | dyketionallVOS.add(dyketionallVO); |
| | | } |
| | | dyketionVO.setDyketionallVOS(dyketionallVOS); |
| | | } |
| | | //分页情况下 |
| | | if(type.equals("1")){ |
| | | //获取分页信息 |
| | | // TbResDykeVO tbResDykeVO = new TbResDykeVO(); |
| | | // tbResDykeVO.setTbYear(2024); |
| | | List<TbResDykeVO> tbResDykeVOIPage = tbResDykeMapper.findTbResDykePcBy(page, tbResDykeVO); |
| | | |
| | | List<String> dykeCode = new ArrayList<>(); |
| | | for (TbResDykeVO imageAndVideoVO : tbResDykeVOIPage) { |
| | | dykeCode.add(imageAndVideoVO.getGuid()); |
| | | } |
| | | List<DyketionVO> iamgeAndVideoUrls = iamgeAndVideoUrlcopy.stream() |
| | | .filter(dyketionVO -> dykeCode.contains(dyketionVO.getCode())) |
| | | .collect(Collectors.toList()); |
| | | |
| | | return iamgeAndVideoUrls; |
| | | } |
| | | |
| | | |
| | | return iamgeAndVideoUrlcopy; |
| | | } |
| | | |
| | | } |