aix
2024-09-25 2f10ca63b173d7abfa5dba60609ca3128d25582a
skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sjztmd/service/impl/TbResGeneralInvestigationServiceImpl.java
@@ -1,5 +1,6 @@
package cn.gistack.sm.sjztmd.service.impl;
import cn.gistack.sm.sjztmd.mapper.AttResBaseMapper;
import cn.gistack.sm.sjztmd.util.DownloadZipUtils;
import cn.gistack.sm.sjztmd.entity.TbResGeneralInvestigation;
import cn.gistack.sm.sjztmd.entity.TbResGeneralInvestigationState;
@@ -12,9 +13,7 @@
import cn.gistack.sm.sjztmd.statisticsVO.StatisticsTable;
import cn.gistack.sm.sjztmd.util.CalculateUtils;
import cn.gistack.sm.sjztmd.util.DownloadZipUtils;
import cn.gistack.sm.sjztmd.vo.AttResBaseGeneralInvestigationVO;
import cn.gistack.sm.sjztmd.vo.ImageAndVideoVO;
import cn.gistack.sm.sjztmd.vo.TbResGeneralInvestigationParam;
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;
@@ -38,6 +37,7 @@
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
 * @PROJECT_NAME: skjcmanager
@@ -54,9 +54,12 @@
   private ITbResGeneralInvestigationStateService tbResGeneralInvestigationStateService;
   @Autowired
   private HttpServletRequest request;
   private AttResBaseMapper attResBaseMapper;
   @Autowired
   private HttpServletResponse response;
   private HttpServletRequest request;
//   @Autowired
//   private HttpServletResponse response;
   @Override
   @Transactional
@@ -65,7 +68,7 @@
      QueryWrapper queryWrapper = new QueryWrapper();
      queryWrapper.eq("\"res_guid\"", entity.getResGuid());
      queryWrapper.eq("\"tb_year\"", entity.getTbYear());
//      queryWrapper.eq("\"tb_quarter\"",entity.getTbQuarter());
      queryWrapper.eq("\"tb_quarter\"",entity.getTbQuarter());
      TbResGeneralInvestigationState state = tbResGeneralInvestigationStateService.getOne(queryWrapper);
      if (null == state) {
         state = new TbResGeneralInvestigationState();
@@ -75,7 +78,7 @@
         state.setCreateTime(entity.getCreateTime());
         state.setCreateUser(entity.getCreateUser());
      } else {
         if (state.getCheckState() == 1 || state.getCheckState() == 2) {
         if (state.getCheckState() > 1) {
            return R.fail(entity.getResName() + "本年度已经普查完成,不能在提交了。");
         }
      }
@@ -105,6 +108,7 @@
      QueryWrapper queryWrapper = new QueryWrapper();
      queryWrapper.eq("\"res_guid\"", entity.getResGuid());
      queryWrapper.eq("\"tb_year\"", entity.getTbYear());
      queryWrapper.eq("\"tb_quarter\"",entity.getTbQuarter());
      TbResGeneralInvestigationState state = tbResGeneralInvestigationStateService.getOne(queryWrapper);
      if (null == state) {
         //无填报状态记录则新建
@@ -116,7 +120,7 @@
         state.setCreateUser(entity.getCreateUser());
      } else {
         //查看填报状态,只有0填报中才可以一直填报
         if (state.getCheckState() == 1 || state.getCheckState() == 2) {
         if (state.getCheckState() <= 3) {
            return R.fail(entity.getResName() + "本年度已经普查完成,不能在提交了。");
         }
      }
@@ -207,5 +211,52 @@
      }
   }
   @Override
   public List<ResGentionVO> downZipCopy(IPage<AttResBaseGeneralInvestigationVO> page,String type,AttResBaseGeneralInvestigationVO attResBase) {
      //获取已审批的数据
      List<ResGentionVO> iamgeAndVideoUrlcopy = baseMapper.getIamgeAndVideoUrlcopy();
      for (ResGentionVO resGentionVO : iamgeAndVideoUrlcopy) {
         List<String> urls = new ArrayList<>();
         List<DyketionallVO> dyketionallVOS = new ArrayList<>();
         if(resGentionVO.getImagesUrls() != null){
            urls.add(resGentionVO.getImagesUrls());
         }
         if(resGentionVO.getVideoUrls() != null) {
            urls.add(resGentionVO.getVideoUrls());
         }
         //解析json中url 放入list集合中
         List<String> urlss = DownloadZipUtils.getUrls(urls);
         int counter=1;
         for (String s : urlss) {
            DyketionallVO dyketionallVO = new DyketionallVO();
            dyketionallVO.setUrlname(resGentionVO.getResname()+"+"+resGentionVO.getPpname()+"+"+resGentionVO.getRn()+String.format("%02d", counter++)+s.substring(s.length() - 4));
            dyketionallVO.setUrl(s);
            dyketionallVOS.add(dyketionallVO);
         }
         resGentionVO.setDyketionallVOS(dyketionallVOS);
      }
      //分页情况下
      if(type.equals("1")){
         //获取分页信息
//         AttResBaseGeneralInvestigationVO attResBaseGeneralInvestigationVO = new AttResBaseGeneralInvestigationVO();
//         attResBaseGeneralInvestigationVO.setTbYear(2024);
         List<AttResBaseGeneralInvestigationVO> attResBaseGeneralInvestigationVOS = attResBaseMapper.selectAttResBaseGeneralInvestigation(page, attResBase);
         List<String> resCode = new ArrayList<>();
         for (AttResBaseGeneralInvestigationVO imageAndVideoVO : attResBaseGeneralInvestigationVOS) {
            resCode.add(imageAndVideoVO.getCode());
         }
         List<ResGentionVO> iamgeAndVideoUrls = iamgeAndVideoUrlcopy.stream()
            .filter(resGentionVO -> resCode.contains(resGentionVO.getCode()))
            .collect(Collectors.toList());
         return iamgeAndVideoUrls;
      }
      return iamgeAndVideoUrlcopy;
   }
}