| | |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.CalculateUtil; |
| | | import com.ruoyi.common.utils.CollUtils; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.system.domain.TbBasicData; |
| | | import com.ruoyi.system.domain.TbBasicDataConfig; |
| | | import com.ruoyi.system.domain.TbBasicDataConfigDetail; |
| | |
| | | this.tbScoreService = tbScoreService; |
| | | this.sysUserService = sysUserService; |
| | | this.quarter = quarter; |
| | | } |
| | | |
| | | private static String validateFields(Map.Entry<Integer, String> integerStringEntry, |
| | | Map<Integer, String> dataMap, TbField field) { |
| | | String value = dataMap.get(integerStringEntry.getKey()); |
| | | if (FieldTypeEnum.NUMBER.equals(field.getFieldType())) { |
| | | Integer numMin = field.getNumMin(); |
| | | Integer numMax = field.getNumMax(); |
| | | if (Objects.nonNull(numMin) && Objects.nonNull(numMax)) { |
| | | if (numMin > Integer.parseInt(value) || numMax < Integer.parseInt(value)) { |
| | | throw new ServiceException( |
| | | String.format("字段(%s)的内容不在%d~%d范围内", field.getFieldName(), |
| | | numMin, numMax)); |
| | | } |
| | | } |
| | | } |
| | | if (FieldInputTypeEnum.MANUAL_INPUT.equals(field.getTextInputType()) |
| | | && FieldTypeEnum.TEXT.equals(field.getFieldType())) { |
| | | Integer textMinNum = field.getTextMinNum(); |
| | | Integer textMaxNum = field.getTextMaxNum(); |
| | | if (Objects.nonNull(textMinNum) && Objects.nonNull(textMaxNum)) { |
| | | if (textMinNum > value.length() || textMaxNum < value.length()) { |
| | | throw new ServiceException( |
| | | String.format("字段(%s)的内容长度超出%d~%d的范围", |
| | | field.getFieldName(), |
| | | textMinNum, textMaxNum)); |
| | | } |
| | | } |
| | | } |
| | | if (FieldTypeEnum.PERCENTAGE.equals(field.getFieldType())) { |
| | | if (0 > Double.parseDouble(value) || 100 < Double.parseDouble(value)) { |
| | | throw new ServiceException( |
| | | String.format("字段(%s)的内容不在0~100范围内", field.getFieldName())); |
| | | } |
| | | } |
| | | return value; |
| | | } |
| | | |
| | | @Override |
| | |
| | | tbBasicData.setDeptAreaCode(areaCode); |
| | | tbBasicData.setRemark(dataMap.get(remarkIndex)); |
| | | tbBasicData.setStatus(ReportingStatusEnum.MISSING_DATA); |
| | | tbBasicData.setReportingTime(DateUtils.getQuarterDate(quarter)); |
| | | tbBasicDataService.saveOrUpdate(tbBasicData); |
| | | tbBasicDataFieldService.remove(Wrappers.<TbBasicDataField>lambdaQuery() |
| | | .eq(TbBasicDataField::getBasicDataId, tbBasicData.getId())); |
| | |
| | | return tbBasicDataList; |
| | | } |
| | | |
| | | /** |
| | | * 需要导入的数据 |
| | | * |
| | | * @return List<Map < Integer, String>> |
| | | */ |
| | | private List<Map<Integer, String>> getMapList() { |
| | | for (int i = 0; i < cachedDataList.size(); i++) { |
| | | if (cachedDataList.get(i).get(0).equals("栏号")) { |
| | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 表头 |
| | | * |
| | | * @return Map<Integer, String> |
| | | */ |
| | | private Map<Integer, String> getHeadMap() { |
| | | for (int i = 0; i < cachedDataList.size(); i++) { |
| | | if (cachedDataList.get(i).get(0).equals("栏号")) { |
| | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 校验字段内容 |
| | | * |
| | | * @param integerStringEntry 动态字段表头Entry |
| | | * @param dataMap 数据map |
| | | * @param field 字段 |
| | | * @return 值 |
| | | */ |
| | | private static String validateFields(Map.Entry<Integer, String> integerStringEntry, |
| | | Map<Integer, String> dataMap, TbField field) { |
| | | String value = dataMap.get(integerStringEntry.getKey()); |
| | | if (FieldTypeEnum.NUMBER.equals(field.getFieldType())) { |
| | | Integer numMin = field.getNumMin(); |
| | | Integer numMax = field.getNumMax(); |
| | | if (Objects.nonNull(numMin) && Objects.nonNull(numMax)) { |
| | | if (numMin > Integer.parseInt(value) || numMax < Integer.parseInt(value)) { |
| | | throw new ServiceException( |
| | | String.format("字段(%s)的内容不在%d~%d范围内", field.getFieldName(), |
| | | numMin, numMax)); |
| | | } |
| | | } |
| | | } |
| | | if (FieldInputTypeEnum.MANUAL_INPUT.equals(field.getTextInputType()) |
| | | && FieldTypeEnum.TEXT.equals(field.getFieldType())) { |
| | | Integer textMinNum = field.getTextMinNum(); |
| | | Integer textMaxNum = field.getTextMaxNum(); |
| | | if (Objects.nonNull(textMinNum) && Objects.nonNull(textMaxNum)) { |
| | | if (textMinNum > value.length() || textMaxNum < value.length()) { |
| | | throw new ServiceException( |
| | | String.format("字段(%s)的内容长度超出%d~%d的范围", |
| | | field.getFieldName(), |
| | | textMinNum, textMaxNum)); |
| | | } |
| | | } |
| | | } |
| | | if (FieldTypeEnum.PERCENTAGE.equals(field.getFieldType())) { |
| | | if (0 > Double.parseDouble(value) || 100 < Double.parseDouble(value)) { |
| | | throw new ServiceException( |
| | | String.format("字段(%s)的内容不在0~100范围内", field.getFieldName())); |
| | | } |
| | | } |
| | | return value; |
| | | } |
| | | |
| | | /** |
| | | * 计算得分 |
| | | * |
| | | * @param tbBasicDataList 基础数据集合 |
| | | */ |
| | | private void calculateScore(List<TbBasicData> tbBasicDataList) { |
| | | List<TbScore> scoreList = new ArrayList<>(); |
| | | for (TbBasicData tbBasicData : tbBasicDataList) { |
| | | List<TbScore> scoreList = new ArrayList<>(); |
| | | //计算得分 |
| | | List<TbBasicDataConfig> list = tbBasicDataConfigService.lambdaQuery() |
| | | .eq(TbBasicDataConfig::getStatus, ShowStatusEnum.SHOW).list(); |
| | |
| | | } |
| | | } |
| | | } |
| | | tbScoreService.saveBatch(scoreList); |
| | | } |
| | | tbScoreService.saveBatch(scoreList); |
| | | log.info(String.format("基础数据%s计算得分成功!", JSON.toJSONString(tbBasicDataList))); |
| | | } |
| | | } |