| | |
| | | package com.panzhihua.service_community.service.impl; |
| | | |
| | | import java.net.URL; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.xml.bind.DatatypeConverter; |
| | | |
| | | import com.panzhihua.common.model.vos.community.reserve.HomeQuarantineRegisterExportVO; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | @Override |
| | | public R exportRegisterAdmin(PageReserveRegisterDetailedAdminDTO pageReserveRegisterDetailedAdminDTO){ |
| | | QuestnaireAnswersDTO result = new QuestnaireAnswersDTO(); |
| | | |
| | | //查询题目 |
| | | List<ComActReserveSubDO> list = comActReserveSubMapper.selectList(new QueryWrapper<ComActReserveSubDO>().lambda() |
| | | .eq(ComActReserveSubDO::getReserveId, pageReserveRegisterDetailedAdminDTO.getReserveId()).orderByAsc(ComActReserveSubDO::getCreateAt).orderByAsc(ComActReserveSubDO::getId)); |
| | | List<ComActQuestnaireSubVO> listSubVo = new ArrayList<>(); |
| | | list.forEach(subDo -> { |
| | | if(!subDo.getType().equals(5)){ |
| | | ComActQuestnaireSubVO comActQuestnaireSubVO = new ComActQuestnaireSubVO(); |
| | | BeanUtils.copyProperties(subDo, comActQuestnaireSubVO); |
| | | listSubVo.add(comActQuestnaireSubVO); |
| | | } |
| | | }); |
| | | result.setSubs(listSubVo); |
| | | result.setSubs(retrieveQuestnaireSub(pageReserveRegisterDetailedAdminDTO)); |
| | | |
| | | //查询用户回答 |
| | | List<ComActQuestnaireAnswerContentVO> vos = this.baseMapper.export(pageReserveRegisterDetailedAdminDTO); |
| | |
| | | map.put("nub", nub + ""); |
| | | List<HomeQuarantineRegisterStatisticsVO> statisticsList = this.baseMapper.selectStatistics(detailedAdminDTO.getReserveId(), record); |
| | | StringBuffer conditions = new StringBuffer(); |
| | | //渲染首次登记时间 |
| | | map.put("time", DateUtils.format(statisticsList.get(0).getCreateAt(), DateUtils.ymdhms_format)); |
| | | statisticsList.forEach(e -> { |
| | | //渲染登记时间 |
| | | map.put("time", DateUtils.format(e.getCreateAt(), DateUtils.ymdhms_format)); |
| | | String reserveSubContent = e.getReserveSubContent(); |
| | | String dateString = dateFormat.format(e.getCreateAt()); |
| | | if (reserveSubContent.contains("上午体温")) { |
| | | if (conditions.indexOf(dateString + " " + "上午体温") == -1) { |
| | | int index = conditions.indexOf(dateString + " " + "上午体温"); |
| | | if (index == -1) { |
| | | conditions.append(dateString + " " + "上午体温:" + e.getAnswerContent() + "℃" + "\n"); |
| | | } else { |
| | | conditions.replace(index, conditions.indexOf("℃", index), |
| | | dateString + " " + "上午体温:" + e.getAnswerContent()); |
| | | } |
| | | } else if (reserveSubContent.contains("下午体温")) { |
| | | if (conditions.indexOf(dateString + " " + "下午体温") == -1) { |
| | | int index = conditions.indexOf(dateString + " " + "下午体温"); |
| | | if (index == -1) { |
| | | conditions.append(dateString + " " + "下午体温:" + e.getAnswerContent() + "℃" + "\n"); |
| | | } else { |
| | | conditions.replace(index, conditions.indexOf("℃", index), |
| | | dateString + " " + "下午体温:" + e.getAnswerContent()); |
| | | } |
| | | } else if (reserveSubContent.contains("隔离情况")) { |
| | | if (conditions.indexOf(dateString + " " + "当日隔离情况") == -1) { |
| | | int index = conditions.indexOf(dateString + " " + "当日隔离情况"); |
| | | if (index == -1) { |
| | | conditions.append(dateString + " " + "当日隔离情况:" + e.getAnswerContent() + "\n"); |
| | | conditions.append("————————" + "\n"); |
| | | } else { |
| | | conditions.replace(index, conditions.indexOf("\n", index), |
| | | dateString + " " + "当日隔离情况:" + e.getAnswerContent()); |
| | | } |
| | | } else { |
| | | map.put(e.getReserveSubId() + "", e.getAnswerContent()); |
| | |
| | | resultPage.setRecords(resultMapList); |
| | | return R.ok(resultPage); |
| | | } |
| | | |
| | | /** |
| | | * 居家隔离导出 |
| | | * @param detailedAdminDTO |
| | | * @return |
| | | */ |
| | | @Override |
| | | public R exportHomeQuarantine(PageReserveRegisterDetailedAdminDTO detailedAdminDTO) { |
| | | HomeQuarantineRegisterExportVO exportVO = new HomeQuarantineRegisterExportVO(); |
| | | //题目 |
| | | exportVO.setSubs(retrieveQuestnaireSub(detailedAdminDTO)); |
| | | //结果数据集合 |
| | | List<List<Object>> resultList = new ArrayList<>(); |
| | | List<String> idCards = this.baseMapper.exportHomeQuarantine(detailedAdminDTO); |
| | | if (!idCards.isEmpty()) { |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
| | | for (String idCard : idCards) { |
| | | //构建单个用户数据 |
| | | List<Object> userData = new ArrayList<>(); |
| | | List<HomeQuarantineRegisterStatisticsVO> statisticsList = this.baseMapper.selectStatistics(detailedAdminDTO.getReserveId(), idCard); |
| | | HomeQuarantineRegisterStatisticsVO firstStatisticsVO = statisticsList.get(0); |
| | | userData.add(firstStatisticsVO.getNickName()); |
| | | userData.add(DateUtils.format(firstStatisticsVO.getCreateAt(), DateUtils.ymdhms_format)); |
| | | int size = statisticsList.size(); |
| | | List<HomeQuarantineRegisterStatisticsVO> lastStatisticsVOList = statisticsList.subList(size - 13, size); |
| | | for (HomeQuarantineRegisterStatisticsVO statisticsVO : lastStatisticsVOList) { |
| | | //判断当前的组件类型是否是图片上传,导出时需要导出图片 |
| | | if (statisticsVO.getOptionType().equals(11)) { |
| | | try { |
| | | userData.add(new URL(statisticsVO.getAnswerContent())); |
| | | } catch (Exception e) { |
| | | userData.add(" "); |
| | | log.error("导出转换图片失败!"); |
| | | } |
| | | continue; |
| | | } |
| | | //判断当前组件类型是否签名 |
| | | if (statisticsVO.getOptionType().equals(12)) { |
| | | try { |
| | | userData.add(DatatypeConverter.parseBase64Binary(statisticsVO.getAnswerContent().substring(statisticsVO.getAnswerContent().indexOf(",") + 1))); |
| | | } catch (Exception e) { |
| | | userData.add(" "); |
| | | log.error("导出转换图片失败!"); |
| | | } |
| | | continue; |
| | | } |
| | | userData.add(statisticsVO.getAnswerContent()); |
| | | } |
| | | StringBuffer conditions = new StringBuffer(); |
| | | statisticsList.forEach(e -> { |
| | | String reserveSubContent = e.getReserveSubContent(); |
| | | String dateString = dateFormat.format(e.getCreateAt()); |
| | | if (reserveSubContent.contains("上午体温")) { |
| | | int index = conditions.indexOf(dateString + " " + "上午体温"); |
| | | if (index == -1) { |
| | | conditions.append(dateString + " " + "上午体温:" + e.getAnswerContent() + "℃" + "\n"); |
| | | } else { |
| | | conditions.replace(index, conditions.indexOf("℃", index), |
| | | dateString + " " + "上午体温:" + e.getAnswerContent()); |
| | | } |
| | | } else if (reserveSubContent.contains("下午体温")) { |
| | | int index = conditions.indexOf(dateString + " " + "下午体温"); |
| | | if (index == -1) { |
| | | conditions.append(dateString + " " + "下午体温:" + e.getAnswerContent() + "℃" + "\n"); |
| | | } else { |
| | | conditions.replace(index, conditions.indexOf("℃", index), |
| | | dateString + " " + "下午体温:" + e.getAnswerContent()); |
| | | } |
| | | } else if (reserveSubContent.contains("隔离情况")) { |
| | | int index = conditions.indexOf(dateString + " " + "当日隔离情况"); |
| | | if (index == -1) { |
| | | conditions.append(dateString + " " + "当日隔离情况:" + e.getAnswerContent() + "\n"); |
| | | conditions.append("————————" + "\n"); |
| | | } else { |
| | | conditions.replace(index, conditions.indexOf("\n", index), |
| | | dateString + " " + "当日隔离情况:" + e.getAnswerContent()); |
| | | } |
| | | } |
| | | }); |
| | | userData.add(conditions.toString()); |
| | | resultList.add(userData); |
| | | } |
| | | } |
| | | exportVO.setDataList(resultList); |
| | | return R.ok(exportVO); |
| | | } |
| | | |
| | | private List<ComActQuestnaireSubVO> retrieveQuestnaireSub(PageReserveRegisterDetailedAdminDTO detailedAdminDTO) { |
| | | //查询题目 |
| | | List<ComActReserveSubDO> list = comActReserveSubMapper.selectList(new QueryWrapper<ComActReserveSubDO>().lambda() |
| | | .eq(ComActReserveSubDO::getReserveId, detailedAdminDTO.getReserveId()).orderByAsc(ComActReserveSubDO::getCreateAt).orderByAsc(ComActReserveSubDO::getId)); |
| | | List<ComActQuestnaireSubVO> listSubVo = new ArrayList<>(); |
| | | list.forEach(subDo -> { |
| | | if(!subDo.getType().equals(5)){ |
| | | ComActQuestnaireSubVO comActQuestnaireSubVO = new ComActQuestnaireSubVO(); |
| | | BeanUtils.copyProperties(subDo, comActQuestnaireSubVO); |
| | | listSubVo.add(comActQuestnaireSubVO); |
| | | } |
| | | }); |
| | | return listSubVo; |
| | | } |
| | | } |