| | |
| | | import com.ruoyi.system.domain.TbField; |
| | | import com.ruoyi.system.domain.TbScore; |
| | | import com.ruoyi.system.dto.BasicDataDTO; |
| | | import com.ruoyi.system.handler.CustomerHandler; |
| | | import com.ruoyi.system.handler.CustomCellWriteHandler; |
| | | import com.ruoyi.system.listener.BasicDataListener; |
| | | import com.ruoyi.system.listener.HistoryDataListener; |
| | | import com.ruoyi.system.mapper.TbBasicDataMapper; |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void saveBasicData(BasicDataDTO dto) { |
| | | public void saveBasicData(BasicDataDTO dto) throws Exception { |
| | | LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | String areaCode = loginUser.getUser().getAreaCode(); |
| | | // 数据校验 |
| | | if (Objects.isNull(dto) || CollUtils.isEmpty(dto.getFields())) { |
| | | return; |
| | | } |
| | | String nowQuarter = DateUtils.getNowQuarter(); |
| | | TbBasicData tbBasicData = BeanUtils.copyBean(dto, TbBasicData.class); |
| | | tbBasicData.setDeptAreaCode(areaCode); |
| | | tbBasicData.setStatus(ReportingStatusEnum.MISSING_DATA); |
| | | tbBasicData.setQuarter(nowQuarter); |
| | | tbBasicData.setReportingTime(DateUtils.getQuarterDate(nowQuarter)); |
| | | this.saveOrUpdate(tbBasicData); |
| | | // 保存基础数据动态字段数据 |
| | | List<TbBasicDataField> tbBasicDataFields = |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void importData(MultipartFile file, String quarter) throws IOException { |
| | | //校验季度 |
| | | Date quarterDate = DateUtils.getQuarterDate(quarter); |
| | | |
| | | Map<String, Date> quarterMap = DateUtils.getQuarterDate(new Date()); |
| | | Date date = quarterMap.get("first"); |
| | | LocalDate quarterLocalDate = DateUtils.dateToLocalDate(quarterDate); |
| | | LocalDate dateLocalDate = DateUtils.dateToLocalDate(date); |
| | | if (quarterLocalDate.isAfter(dateLocalDate) || quarterLocalDate.equals(dateLocalDate)) { |
| | | throw new ServiceException("请导入过去季度的数据。"); |
| | | } |
| | | |
| | | EasyExcel.read( |
| | | file.getInputStream(), |
| | | new HistoryDataListener( |
| | |
| | | .list(); |
| | | //构建Excel写对象 |
| | | try (ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()) |
| | | .registerWriteHandler(new CustomerHandler()) |
| | | .registerWriteHandler(new CustomCellWriteHandler()) |
| | | .registerWriteHandler(EasyExcelUtil.getStyleStrategy()).build()) { |
| | | WriteSheet writeSheet; |
| | | //遍历季度基础数据 |
| | |
| | | TbBasicDataField transferPaymentScale = basicDataFieldMap.get(-1L); |
| | | valueList.add( |
| | | Objects.nonNull(transferPaymentScale) |
| | | ? FieldBuildUtil.formatNumberWithCommas( |
| | | transferPaymentScale.getFieldValue()) |
| | | ? transferPaymentScale.getFieldValue() |
| | | : ""); |
| | | TbBasicDataField currentGdp = basicDataFieldMap.get(-2L); |
| | | valueList.add( |
| | | Objects.nonNull(currentGdp) |
| | | ? FieldBuildUtil.formatNumberWithCommas( |
| | | currentGdp.getFieldValue()) |
| | | ? currentGdp.getFieldValue() |
| | | : ""); |
| | | for (TbField tbField : fieldList) { |
| | | TbBasicDataField tbBasicDataField = basicDataFieldMap.get(tbField.getId()); |
| | | valueList.add( |
| | | Objects.nonNull(tbBasicDataField) |
| | | ? FieldBuildUtil.formatNumberWithCommas( |
| | | tbBasicDataField.getFieldValue()) |
| | | ? tbBasicDataField.getFieldValue() |
| | | : ""); |
| | | } |
| | | excellist.add(valueList); |