From d8c173c1f1aa9de62debbe810932a3e260444b4c Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Mon, 28 Sep 2020 10:44:32 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=A4=A7=E5=B1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/dao/project/ProjectDao.java | 9 +++ .../impl/ProjectExtractServiceImpl.java | 69 ++++++++++++------- .../impl/ScreenExtractServiceImpl.java | 17 +++-- .../epmet/service/project/ProjectService.java | 9 +++ .../project/impl/ProjectServiceImpl.java | 5 ++ .../resources/mapper/project/ProjectDao.xml | 9 +++ 6 files changed, 89 insertions(+), 29 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/project/ProjectDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/project/ProjectDao.java index d676531771..df6da92b0b 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/project/ProjectDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/project/ProjectDao.java @@ -94,4 +94,13 @@ public interface ProjectDao extends BaseDao { * @return java.util.List */ List selectProjectInfo(@Param("customerId") String customerId, @Param("date") String date); + + /** + * 获取用户可滞留天数 + * @author zhaoqifeng + * @date 2020/9/28 10:16 + * @param customerId + * @return java.lang.String + */ + String selectParameterValueByKey(@Param("customerId") String customerId); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/ProjectExtractServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/ProjectExtractServiceImpl.java index a9552ed3b8..3753b69c31 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/ProjectExtractServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/ProjectExtractServiceImpl.java @@ -1,6 +1,7 @@ package com.epmet.service.evaluationindex.extract.todata.impl; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.Result; @@ -71,6 +72,8 @@ public class ProjectExtractServiceImpl implements ProjectExtractService { @Autowired private FactOriginProjectOrgPeriodDailyDao factOriginProjectOrgPeriodDailyDao; + private final static String ONE_DAY = "<1"; + @Override public void saveOriginProjectDaily(ExtractOriginFormDTO extractOriginFormDTO) { String dateString = extractOriginFormDTO.getDateId(); @@ -80,7 +83,7 @@ public class ProjectExtractServiceImpl implements ProjectExtractService { List closedList = projectProcessService.getClosedProjectList(customerId, dateString); List pendingList = factOriginProjectMainDailyService.getPendingList(customerId); List finishOrgList = projectProcessService.getFinishOrg(customerId, dateString); - if (null != closedList && !closedList.isEmpty()) { + if (CollectionUtils.isEmpty(closedList)) { List closeProjects = pendingList.stream().flatMap(pending -> closedList.stream().filter(closed -> pending.getId().equals(closed.getProjectId())).map(process -> { FactOriginProjectMainDailyEntity entity = new FactOriginProjectMainDailyEntity(); @@ -92,9 +95,9 @@ public class ProjectExtractServiceImpl implements ProjectExtractService { return entity; })).collect(Collectors.toList()); - if (null != finishOrgList && !finishOrgList.isEmpty()) { + if (CollectionUtils.isEmpty(finishOrgList)) { closeProjects.forEach(close -> finishOrgList.stream().filter(finish -> close.getId().equals(finish.getProjectId())).forEach(dto -> { - String[] orgIds = dto.getPIdPath().split(":"); + String[] orgIds = dto.getPIdPath().split(StrConstant.COLON); if (orgIds.length > NumConstant.ONE) { close.setFinishOrgIds(orgIds[orgIds.length - 1]); } else { @@ -109,7 +112,7 @@ public class ProjectExtractServiceImpl implements ProjectExtractService { } //获取项目信息 List projectList = projectService.getProjectInfo(customerId, dateString); - if (null != projectList && !projectList.isEmpty()) { + if (CollectionUtils.isEmpty(projectList)) { //提取议题ID List issueIds = projectList.stream().map(ProjectDTO::getOriginId).collect(Collectors.toList()); //获取议题信息 @@ -139,7 +142,7 @@ public class ProjectExtractServiceImpl implements ProjectExtractService { entity.setCreatedTime(project.getCreatedTime()); entity.setUpdatedTime(project.getUpdatedTime()); entity.setPids(project.getOrgIdPath()); - String[] pIds = project.getOrgIdPath().split(":"); + String[] pIds = project.getOrgIdPath().split(StrConstant.COLON); if (pIds.length > 1) { entity.setPid(pIds[pIds.length - 2]); } else if(pIds.length == 1){ @@ -163,7 +166,7 @@ public class ProjectExtractServiceImpl implements ProjectExtractService { entity.setIsParty(NumConstant.ONE_STR); })); list.forEach(entity -> finishOrgList.stream().filter(finish -> entity.getId().equals(finish.getProjectId())).forEach(dto -> { - String[] orgIds = dto.getPIdPath().split(":"); + String[] orgIds = dto.getPIdPath().split(StrConstant.COLON); if (orgIds.length > NumConstant.ONE) { entity.setFinishOrgIds(orgIds[orgIds.length - 1]); } else { @@ -179,7 +182,7 @@ public class ProjectExtractServiceImpl implements ProjectExtractService { final List mainList = list; //节点发起人 List processList = projectProcessService.getProcessListByCustomer(customerId, dateString); - if (null != processList && !processList.isEmpty()) { + if (CollectionUtils.isEmpty(processList)) { List logList = processList.stream().map(process -> { //获取日期相关维度 DimIdGenerator.DimIdBean dimId = DimIdGenerator.getDimIdBean(process.getCreatedTime()); @@ -204,15 +207,15 @@ public class ProjectExtractServiceImpl implements ProjectExtractService { entity.setOrgId(process.getGridId()); entity.setPid(process.getAgencyId()); }else{ - if(!process.getPids().contains(":")){ + if(!process.getPids().contains(StrConstant.COLON)){ entity.setPids(""); entity.setPid(NumConstant.ZERO_STR); }else{ - String[] orgArray = process.getPids().split(":"); - if(null != orgArray && orgArray.length > NumConstant.ONE){ + String[] orgArray = process.getPids().split(StrConstant.COLON); + if(orgArray.length > NumConstant.ONE){ entity.setPid(orgArray[orgArray.length - NumConstant.TWO]); String path = process.getPids().replaceAll(process.getAgencyId(),""); - if(path.endsWith(":")){ + if(path.endsWith(StrConstant.COLON)){ path =path.substring(NumConstant.ZERO,path.length() - NumConstant.ONE); } entity.setPids(path); @@ -283,15 +286,15 @@ public class ProjectExtractServiceImpl implements ProjectExtractService { entity.setOrgId(process.getGridId()); entity.setPid(process.getAgencyId()); }else{ - if(!process.getPids().contains(":")){ + if(!process.getPids().contains(StrConstant.COLON)){ entity.setPids(""); entity.setPid(NumConstant.ZERO_STR); }else{ - String[] orgArray = process.getPids().split(":"); - if(null != orgArray && orgArray.length > NumConstant.ONE){ + String[] orgArray = process.getPids().split(StrConstant.COLON); + if(orgArray.length > NumConstant.ONE){ entity.setPid(orgArray[orgArray.length - NumConstant.TWO]); String path = process.getPids().replaceAll(process.getAgencyId(),""); - if(path.endsWith(":")){ + if(path.endsWith(StrConstant.COLON)){ path =path.substring(NumConstant.ZERO,path.length() - NumConstant.ONE); } entity.setPids(path); @@ -322,7 +325,7 @@ public class ProjectExtractServiceImpl implements ProjectExtractService { @Override public void extractProjectPeriodData(ExtractOriginFormDTO param) { int trace = factOriginProjectOrgPeriodDailyDao.selectIfExisted(param.getCustomerId()); - Boolean isFirst = trace <= NumConstant.ZERO ? true : false; + Boolean isFirst = trace <= NumConstant.ZERO; if (StringUtils.isBlank(param.getDateId())) { Date yesterday = new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24); SimpleDateFormat format = new SimpleDateFormat(DateUtils.DATE_PATTERN_YYYYMMDD); @@ -345,23 +348,23 @@ public class ProjectExtractServiceImpl implements ProjectExtractService { }else{ dest.setOrgType("agency"); dest.setPids(""); - String[] array = original.getOrgIdPath().split(":"); - if(null == array || array.length <= NumConstant.ZERO){ + String[] array = original.getOrgIdPath().split(StrConstant.COLON); + if(array.length <= NumConstant.ZERO){ dest.setPid(NumConstant.ZERO_STR); } - if(array[NumConstant.ZERO] == original.getOrgId() && array.length == NumConstant.ONE){ + if(array[NumConstant.ZERO].equals(original.getOrgId()) && array.length == NumConstant.ONE){ dest.setPid(NumConstant.ZERO_STR); } - if(array.length > NumConstant.ONE && original.getOrgId() == array[array.length - NumConstant.ONE]){ + if(array.length > NumConstant.ONE && original.getOrgId().equals(array[array.length - NumConstant.ONE])){ dest.setPid(array[array.length - NumConstant.TWO]); dest.setPids(original.getOrgIdPath().replace(original.getOrgId(),"")); } if(StringUtils.isNotBlank(dest.getPids())){ - while(dest.getPids().endsWith(":")){ + while(dest.getPids().endsWith(StrConstant.COLON)){ dest.setPids(dest.getPids().substring(NumConstant.ZERO,dest.getPids().length() - NumConstant.ONE)); } - while(dest.getPids().startsWith(":")){ - dest.setPids(dest.getPids().replaceFirst(":","")); + while(dest.getPids().startsWith(StrConstant.COLON)){ + dest.setPids(dest.getPids().replaceFirst(StrConstant.COLON,"")); } } dest.setPids(dest.getPids().replaceAll(" ","")); @@ -400,13 +403,29 @@ public class ProjectExtractServiceImpl implements ProjectExtractService { list.add(workDayFormDTO); Result> detentionDays = epmetCommonServiceOpenFeignClient.detentionDays(list); String days = detentionDays.getData().get(NumConstant.ZERO).getDetentionDays(); - if (("<1").equals(days)) { - result = 1; + if (ONE_DAY.equals(days)) { + result = NumConstant.ONE; } else { result = Integer.parseInt(days); } return result; } + /** + * 客户配置的可滞留时间,没有的话默认5天 + * @author zhaoqifeng + * @date 2020/9/28 10:27 + * @param customerId + * @return java.lang.Integer + */ + private Integer getDays(String customerId) { + String value = projectService.getParameterValueByKey(customerId); + Integer days = NumConstant.FIVE; + if (StringUtils.isNotBlank(value)) { + days = Integer.valueOf(value); + } + return days; + } + } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java index acbb43dcbf..86e1eef6e3 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java @@ -4,10 +4,7 @@ import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.utils.DateUtils; import com.epmet.dto.extract.form.ExtractOriginFormDTO; import com.epmet.dto.extract.form.ExtractScreenFormDTO; -import com.epmet.service.evaluationindex.extract.toscreen.PartyBaseInfoService; -import com.epmet.service.evaluationindex.extract.toscreen.PioneerDataExtractService; -import com.epmet.service.evaluationindex.extract.toscreen.PublicPartExtractService; -import com.epmet.service.evaluationindex.extract.toscreen.ScreenExtractService; +import com.epmet.service.evaluationindex.extract.toscreen.*; import com.epmet.service.stats.DimCustomerService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -35,6 +32,10 @@ public class ScreenExtractServiceImpl implements ScreenExtractService { private PioneerDataExtractService pioneerDataExtractService; @Autowired private PublicPartExtractService publicPartExtractService; + @Autowired + private OrgRankExtractService orgRankExtractService; + @Autowired + private GovernRankDataExtractService governRankDataExtractService; /** * @param extractOriginFormDTO @@ -124,5 +125,13 @@ public class ScreenExtractServiceImpl implements ScreenExtractService { formDTO.setMonthId(monthId); publicPartExtractService.extractTotalDataMonthly(formDTO); + //治理能力排行 + governRankDataExtractService.extractGridData(customerId, monthId); + governRankDataExtractService.extractCommunityData(customerId, monthId); + governRankDataExtractService.extractStreetData(customerId, monthId); + //先进排行 + orgRankExtractService.extractGridData(customerId, monthId); + orgRankExtractService.extractCommunityData(customerId, monthId); + orgRankExtractService.extractStreetData(customerId, monthId); } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/ProjectService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/ProjectService.java index de95867ded..0b0692ba21 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/ProjectService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/ProjectService.java @@ -90,4 +90,13 @@ public interface ProjectService extends BaseService { * @return java.util.List */ List getProjectInfo(String customerId, String date); + + /** + * 获取用户可滞留天数 + * @author zhaoqifeng + * @date 2020/9/28 10:15 + * @param customerId + * @return java.lang.String + */ + String getParameterValueByKey(String customerId); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/impl/ProjectServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/impl/ProjectServiceImpl.java index d1f5e88b1d..fa22e2090e 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/impl/ProjectServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/impl/ProjectServiceImpl.java @@ -77,4 +77,9 @@ public class ProjectServiceImpl extends BaseServiceImpl + \ No newline at end of file From e53b4a27c77b0f4755c184e423b56bb009560cf6 Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Mon, 28 Sep 2020 11:02:44 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=85=A5=E5=8F=82?= =?UTF-8?q?=E5=8E=BB=E6=8E=89token?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/fact/FactIndexController.java | 28 ++++++++--------- .../controller/screen/IndexController.java | 4 +-- .../screen/ScreenUserController.java | 8 ++--- .../fact/impl/FactIndexServiceImpl.java | 30 +++++++++++++++++++ 4 files changed, 50 insertions(+), 20 deletions(-) diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/fact/FactIndexController.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/fact/FactIndexController.java index fbf0e78748..5780a6e4c3 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/fact/FactIndexController.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/fact/FactIndexController.java @@ -28,78 +28,78 @@ public class FactIndexController { private FactIndexService factIndexService; /** - * @param tokenDTO + * @param formDTO * @Description 能力指数 * @author sun */ @PostMapping("index/ablityindex") - public Result> ablityIndex(@LoginUser TokenDto tokenDTO, @RequestBody AblityIndexFormDTO formDTO) { + public Result> ablityIndex(@RequestBody AblityIndexFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO, AblityIndexFormDTO.AddUserInternalGroup.class); return new Result>().ok(factIndexService.ablityIndex(formDTO)); } /** - * @param tokenDTO + * @param formDTO * @Description 按月份查询各项能力分数 * @author sun */ @PostMapping("index/scorelist") - public Result> scoreList(@LoginUser TokenDto tokenDTO, @RequestBody ScoreListFormDTO formDTO) { + public Result> scoreList(@RequestBody ScoreListFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO, ScoreListFormDTO.AddUserInternalGroup.class); return new Result>().ok(factIndexService.scoreList(formDTO)); } /** - * @param tokenDTO + * @param formDTO * @Description 按月份查询各项能力最近12个月得分 * @author sun */ @PostMapping("index/monthscorelist") - public Result> monthScoreList(@LoginUser TokenDto tokenDTO, @RequestBody MonthScoreListFormDTO formDTO) { + public Result> monthScoreList(@RequestBody MonthScoreListFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO, MonthScoreListFormDTO.AddUserInternalGroup.class); return new Result>().ok(factIndexService.monthScoreList(formDTO)); } /** - * @param tokenDTO + * @param formDTO * @Description 按月查询各项指标数据 * @author sun */ @PostMapping("index/ablitylist") - public Result> ablityList(@LoginUser TokenDto tokenDTO, @RequestBody AblityListFormDTO formDTO) { + public Result> ablityList(@RequestBody AblityListFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO, AblityListFormDTO.AddUserInternalGroup.class); return new Result>().ok(factIndexService.ablityList(formDTO)); } /** - * @param tokenDTO + * @param formDTO * @Description 按月查询各项指标最近12个月数据 * @author sun */ @PostMapping("index/monthablitylist") - public Result> monthAblityList(@LoginUser TokenDto tokenDTO, @RequestBody MonthAblityListFormDTO formDTO) { + public Result> monthAblityList(@RequestBody MonthAblityListFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO, MonthAblityListFormDTO.AddUserInternalGroup.class); return new Result>().ok(factIndexService.monthAblityList(formDTO)); } /** - * @param tokenDTO + * @param formDTO * @Description 同级对比各项数据查询 * @author sun */ @PostMapping("index/peercomparison") - public Result> peerComparison(@LoginUser TokenDto tokenDTO, @RequestBody PeerComparisonFormDTO formDTO) { + public Result> peerComparison(@RequestBody PeerComparisonFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO, PeerComparisonFormDTO.AddUserInternalGroup.class); return new Result>().ok(factIndexService.peerComparison(formDTO)); } /** - * @param tokenDTO + * @param formDTO * @Description 是否根组织 * @author sun */ @PostMapping("index/rootagency") - public Result rootAgency(@LoginUser TokenDto tokenDTO, @RequestBody RootAgencyFormDTO formDTO) { + public Result rootAgency(@RequestBody RootAgencyFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO, RootAgencyFormDTO.AddUserInternalGroup.class); return new Result().ok(factIndexService.rootAgency(formDTO)); } diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/IndexController.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/IndexController.java index 98e2207514..79b839ea10 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/IndexController.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/IndexController.java @@ -103,12 +103,12 @@ public class IndexController { } /** - * @param tokenDTO + * @param formDTO * @Description 组织月度指数得分 * @author sun */ @PostMapping("month/indexscore") - public Result indexScore(@LoginUser TokenDto tokenDTO, @RequestBody IndexScoreFormDTO formDTO) { + public Result indexScore(@RequestBody IndexScoreFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO, IndexScoreFormDTO.AddUserInternalGroup.class); return new Result().ok(indexService.indexScore(formDTO)); } diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/ScreenUserController.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/ScreenUserController.java index bc6997d45f..84d586306f 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/ScreenUserController.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/ScreenUserController.java @@ -30,23 +30,23 @@ public class ScreenUserController { private ScreenUserService screenUserService; /** - * @param tokenDTO + * @param formDTO * @Description 热心市民积分排行列表 * @author sun */ @PostMapping("userpointrank") - public Result> userPointRank(@LoginUser TokenDto tokenDTO, @RequestBody UserPointRankFormDTO formDTO) { + public Result> userPointRank(@RequestBody UserPointRankFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO, UserPointRankFormDTO.AddUserInternalGroup.class); return new Result>().ok(screenUserService.userPointRank(formDTO)); } /** - * @param tokenDTO + * @param formDTO * @Description 党员(指标得分)排行 * @author sun */ @PostMapping("partindexscroerank") - public Result> partIndexScroeRank(@LoginUser TokenDto tokenDTO, @RequestBody PartIndexScroeRankFormDTO formDTO) { + public Result> partIndexScroeRank(@RequestBody PartIndexScroeRankFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO, PartIndexScroeRankFormDTO.AddUserInternalGroup.class); return new Result>().ok(screenUserService.partIndexScroeRank(formDTO)); } diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/fact/impl/FactIndexServiceImpl.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/fact/impl/FactIndexServiceImpl.java index 68b3fd1f60..24efaa35c1 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/fact/impl/FactIndexServiceImpl.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/fact/impl/FactIndexServiceImpl.java @@ -19,6 +19,7 @@ import java.text.NumberFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; +import java.util.regex.Pattern; /** * 数据改版api @@ -447,6 +448,9 @@ public class FactIndexServiceImpl implements FactIndexService { * @author sun */ public String getDate(String newDate) { + if (!validDateEffecitive(newDate)) { + throw new RenException(String.format("monthId格式错误,monthId:%s", newDate)); + } String date = ""; SimpleDateFormat sdf = new SimpleDateFormat("yyyymm"); try { @@ -460,6 +464,32 @@ public class FactIndexServiceImpl implements FactIndexService { return date; } + /** + * @param newDate + * @Description 校验日期格式是否正确 + * @author sun + */ + public boolean validDateEffecitive(String newDate) { + //yyyy-MM-dd格式 + //String DATE_REGEX = "^([1-9]\\d{3}-)(([0]{0,1}[1-9]-)|([1][0-2]-))(([0-3]{0,1}[0-9]))$"; + //yyyymm格式 + String DATE_REGEX = "^([1-9]\\d{3})(([0]{0,1}[1-9])|([1][0-2]))$"; + boolean matches = Pattern.matches(DATE_REGEX, newDate); + if (!matches) { + return matches; + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyymm"); + //设置日期格式转的严谨性 + sdf.setLenient(false); + try { + sdf.parse(newDate); + } catch (ParseException e) { + e.printStackTrace(); + return false; + } + return matches; + } + /** * @param formDTO * @Description 同级对比各项数据查询 From 88cde1891586b5f5d6a8b91ffd711d6ff0bcb151 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Mon, 28 Sep 2020 11:02:56 +0800 Subject: [PATCH 3/3] =?UTF-8?q?monthId=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dataToIndex/impl/IndexOriginExtractServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexOriginExtractServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexOriginExtractServiceImpl.java index 23a4de5128..60d592a1b6 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexOriginExtractServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexOriginExtractServiceImpl.java @@ -14,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; +import java.time.LocalDate; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -52,7 +53,7 @@ public class IndexOriginExtractServiceImpl implements IndexOriginExtractService String monthId = formDTO.getMonthId(); String customerId = formDTO.getCustomerId(); if (StringUtils.isBlank(monthId)) { - monthId = DimIdGenerator.getDateDimId(DateUtils.addDateMonths(new Date(), -1)); + monthId = LocalDate.now().minusMonths(NumConstant.ONE).toString().replace("-","").substring(NumConstant.ZERO,NumConstant.SIX); } List customerIds = new ArrayList<>(); if (StringUtils.isNotBlank(customerId)) {