|
|
@ -15,10 +15,12 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.text.NumberFormat; |
|
|
|
import java.text.ParseException; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.*; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Calendar; |
|
|
|
import java.util.LinkedList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.regex.Pattern; |
|
|
|
|
|
|
|
/** |
|
|
@ -57,9 +59,10 @@ public class FactIndexServiceImpl implements FactIndexService { |
|
|
|
@Override |
|
|
|
public List<AblityIndexResultDTO> ablityIndex(AblityIndexFormDTO formDTO) { |
|
|
|
LinkedList<AblityIndexResultDTO> resultList = new LinkedList<>(); |
|
|
|
LinkedList<AblityIndexResultDTO.ScoreListResultDTO> djList = null; |
|
|
|
LinkedList<AblityIndexResultDTO.ScoreListResultDTO> zlList = null; |
|
|
|
LinkedList<AblityIndexResultDTO.ScoreListResultDTO> fwList = null; |
|
|
|
LinkedList<AblityIndexResultDTO.ScoreListResultDTO> list = new LinkedList<>(); |
|
|
|
LinkedList<AblityIndexResultDTO.ScoreListResultDTO> djList = new LinkedList<>(); |
|
|
|
LinkedList<AblityIndexResultDTO.ScoreListResultDTO> zlList = new LinkedList<>(); |
|
|
|
LinkedList<AblityIndexResultDTO.ScoreListResultDTO> fwList = new LinkedList<>(); |
|
|
|
//1.计算所查月份前12个月的monthId
|
|
|
|
formDTO.setStartMonthId(getDate(formDTO.getMonthId())); |
|
|
|
//2.根据类型判断是查询组织数据还是网格数据
|
|
|
@ -73,60 +76,59 @@ public class FactIndexServiceImpl implements FactIndexService { |
|
|
|
//4.根据组织级别判断查询哪类数据表
|
|
|
|
//区县级、乡镇街道级
|
|
|
|
if ("district".equals(agency.getLevel()) || "street".equals(agency.getLevel())) { |
|
|
|
//4-1.查询过去12个月党建能力每月总分、本级得分、下级得分数据(不想写union)
|
|
|
|
formDTO.setIndexCode(FactConstant.DJNL); |
|
|
|
djList = factIndexAgencyScoreDao.selectAblityIndex(formDTO); |
|
|
|
//4-2.查询过去12个月治理能力每月总分、本级得分、下级得分数据
|
|
|
|
formDTO.setIndexCode(FactConstant.ZLNL); |
|
|
|
zlList = factIndexAgencyScoreDao.selectAblityIndex(formDTO); |
|
|
|
//4-3.查询过去12个月服务能力每月总分、本级得分、下级得分数据
|
|
|
|
formDTO.setIndexCode(FactConstant.FWNL); |
|
|
|
fwList = factIndexAgencyScoreDao.selectAblityIndex(formDTO); |
|
|
|
//4-1.查询过去12个月党建能力、治理能力、服务能力每月总分数据
|
|
|
|
list = factIndexAgencyScoreDao.selectAblityIndex(formDTO); |
|
|
|
|
|
|
|
//社区级
|
|
|
|
} else if ("community".equals(agency.getLevel())) { |
|
|
|
//4-1.查询过去12个月党建能力每月总分、本级得分、下级得分数据
|
|
|
|
formDTO.setIndexCode(FactConstant.DJNL); |
|
|
|
djList = factIndexCommunityScoreDao.selectCommunityAblityIndex(formDTO); |
|
|
|
//4-2.查询过去12个月治理能力每月总分、本级得分、下级得分数据
|
|
|
|
formDTO.setIndexCode(FactConstant.ZLNL); |
|
|
|
zlList = factIndexCommunityScoreDao.selectCommunityAblityIndex(formDTO); |
|
|
|
//4-3.查询过去12个月服务能力每月总分、本级得分、下级得分数据
|
|
|
|
formDTO.setIndexCode(FactConstant.FWNL); |
|
|
|
fwList = factIndexCommunityScoreDao.selectCommunityAblityIndex(formDTO); |
|
|
|
//4-1.查询过去12个月党建能力、治理能力、服务能力每月总分、本级得分、下级得分数据
|
|
|
|
list = factIndexCommunityScoreDao.selectCommunityAblityIndex(formDTO); |
|
|
|
} else { |
|
|
|
throw new RenException(String.format("根据组织Id查询到的组织级别信息错误,组织Id:%s", formDTO.getOrgId())); |
|
|
|
} |
|
|
|
//网格层级数据
|
|
|
|
} else if (FactConstant.GRID.equals(formDTO.getOrgType())) { |
|
|
|
//5.查询过去12个月网格层级各项能力对应的各项得分数据
|
|
|
|
//5-1.查询网格过去12个月党建能力每月总分、本级得分、下级得分数据(不想写union)
|
|
|
|
formDTO.setIndexCode(FactConstant.DJNL); |
|
|
|
djList = factIndexGridScoreDao.selectGridAblityIndex(formDTO); |
|
|
|
//5-2.查询网格过去12个月治理能力每月总分、本级得分、下级得分数据
|
|
|
|
formDTO.setIndexCode(FactConstant.ZLNL); |
|
|
|
zlList = factIndexGridScoreDao.selectGridAblityIndex(formDTO); |
|
|
|
//5-3.查询网格过去12个月服务能力每月总分、本级得分、下级得分数据
|
|
|
|
formDTO.setIndexCode(FactConstant.FWNL); |
|
|
|
fwList = factIndexGridScoreDao.selectGridAblityIndex(formDTO); |
|
|
|
//5.查询网格过去12个月党建能力、治理能力、服务能力每月总分数据
|
|
|
|
list = factIndexGridScoreDao.selectGridAblityIndex(formDTO); |
|
|
|
} else { |
|
|
|
throw new RenException(String.format("能力指数查询,orgType类型错误,组织Id:%s,类型Type:%s", formDTO.getOrgId(), formDTO.getOrgType())); |
|
|
|
} |
|
|
|
|
|
|
|
if(djList.size()!=zlList.size()||djList.size()!=fwList.size()){ |
|
|
|
throw new RenException(String.format("能力指数查询,查询出来的三大能力数据条数不一致,orgId:%s,orgType:%s,monthId:%s", formDTO.getOrgId(), formDTO.getOrgType(), formDTO.getMonthId())); |
|
|
|
if (list.size() < NumConstant.ONE) { |
|
|
|
return resultList; |
|
|
|
} |
|
|
|
|
|
|
|
//6.遍历计算每个月能力指数
|
|
|
|
LinkedList<AblityIndexResultDTO.ScoreListResultDTO> nlList = new LinkedList<>(); |
|
|
|
for (int i = 0; i < djList.size(); i++) { |
|
|
|
String monthId = list.get(0).getMonthId(); |
|
|
|
Double dl = 0.0; |
|
|
|
for (AblityIndexResultDTO.ScoreListResultDTO l : list) { |
|
|
|
if (l.getMonthId().equals(monthId)) { |
|
|
|
dl += l.getIndexTotal(); |
|
|
|
} else { |
|
|
|
AblityIndexResultDTO.ScoreListResultDTO nldto = new AblityIndexResultDTO.ScoreListResultDTO(); |
|
|
|
double num1 = new BigDecimal((djList.get(i).getIndexTotal() + zlList.get(i).getIndexTotal() + fwList.get(i).getIndexTotal())).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|
|
|
double num1 = new BigDecimal(dl).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|
|
|
nldto.setIndexTotal(num1); |
|
|
|
nldto.setMonthId(djList.get(i).getMonthId()); |
|
|
|
nldto.setMonthId(monthId); |
|
|
|
nlList.add(nldto); |
|
|
|
monthId = l.getMonthId(); |
|
|
|
dl = l.getIndexTotal(); |
|
|
|
} |
|
|
|
//5.封装数据并返回
|
|
|
|
if (FactConstant.DJNL.equals(l.getIndexCode())) { |
|
|
|
djList.add(l); |
|
|
|
} else if (FactConstant.ZLNL.equals(l.getIndexCode())) { |
|
|
|
zlList.add(l); |
|
|
|
} else if (FactConstant.FWNL.equals(l.getIndexCode())) { |
|
|
|
fwList.add(l); |
|
|
|
} |
|
|
|
} |
|
|
|
//把最后一个月的能力指标数据放入集合
|
|
|
|
AblityIndexResultDTO.ScoreListResultDTO nldto = new AblityIndexResultDTO.ScoreListResultDTO(); |
|
|
|
double num1 = new BigDecimal(dl).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|
|
|
nldto.setIndexTotal(num1); |
|
|
|
nldto.setMonthId(monthId); |
|
|
|
nlList.add(nldto); |
|
|
|
|
|
|
|
//7.封装数据并返回
|
|
|
|
AblityIndexResultDTO nl = new AblityIndexResultDTO(); |
|
|
|
nl.setIndexCode(FactConstant.NLZB); |
|
|
|
nl.setScoreList(nlList); |
|
|
@ -162,10 +164,7 @@ public class FactIndexServiceImpl implements FactIndexService { |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<ScoreListResultDTO> scoreList(ScoreListFormDTO formDTO) { |
|
|
|
LinkedList<ScoreListResultDTO> resultList = new LinkedList<>(); |
|
|
|
ScoreListResultDTO dj = new ScoreListResultDTO(); |
|
|
|
ScoreListResultDTO zl = new ScoreListResultDTO(); |
|
|
|
ScoreListResultDTO fw = new ScoreListResultDTO(); |
|
|
|
List<ScoreListResultDTO> resultList = new LinkedList<>(); |
|
|
|
//1.根据类型判断是查询组织数据还是网格数据
|
|
|
|
//组织层级数据
|
|
|
|
if (FactConstant.AGENCY.equals(formDTO.getOrgType())) { |
|
|
@ -177,54 +176,23 @@ public class FactIndexServiceImpl implements FactIndexService { |
|
|
|
//3.根据组织级别判断查询哪类数据表
|
|
|
|
//区县级、乡镇街道级
|
|
|
|
if ("district".equals(agency.getLevel()) || "street".equals(agency.getLevel())) { |
|
|
|
//3-1.查询当前组织某一月份党建能力对应的总分、本级分、下级分
|
|
|
|
formDTO.setIndexCode(FactConstant.DJNL); |
|
|
|
dj = factIndexAgencyScoreDao.selectScoreList(formDTO); |
|
|
|
//3-2.查询当前组织某一月份治理能力对应的总分、本级分、下级分
|
|
|
|
formDTO.setIndexCode(FactConstant.ZLNL); |
|
|
|
zl = factIndexAgencyScoreDao.selectScoreList(formDTO); |
|
|
|
//3-3.查询当前组织某一月份服务能力对应的总分、本级分、下级分
|
|
|
|
formDTO.setIndexCode(FactConstant.FWNL); |
|
|
|
fw = factIndexAgencyScoreDao.selectScoreList(formDTO); |
|
|
|
//3-1.查询当前组织某一月份党建能力、治理能力、服务能力对应的总分、本级分、下级分
|
|
|
|
resultList = factIndexAgencyScoreDao.selectScoreList(formDTO); |
|
|
|
//社区级
|
|
|
|
} else if ("community".equals(agency.getLevel())) { |
|
|
|
//3-1.查询当前组织某一月份党建能力对应的总分、本级分、下级分
|
|
|
|
formDTO.setIndexCode(FactConstant.DJNL); |
|
|
|
dj = factIndexCommunityScoreDao.selectCommunityScoreList(formDTO); |
|
|
|
//3-2.查询当前组织某一月份治理能力对应的总分、本级分、下级分
|
|
|
|
formDTO.setIndexCode(FactConstant.ZLNL); |
|
|
|
zl = factIndexCommunityScoreDao.selectCommunityScoreList(formDTO); |
|
|
|
//3-3.查询当前组织某一月份服务能力对应的总分、本级分、下级分
|
|
|
|
formDTO.setIndexCode(FactConstant.FWNL); |
|
|
|
fw = factIndexCommunityScoreDao.selectCommunityScoreList(formDTO); |
|
|
|
//3-1.查询当前组织某一月份党建能力、治理能力、服务能力对应的总分、本级分、下级分
|
|
|
|
resultList = factIndexCommunityScoreDao.selectCommunityScoreList(formDTO); |
|
|
|
} else { |
|
|
|
throw new RenException(String.format("根据组织Id查询到的组织级别信息错误,组织Id:%s", formDTO.getOrgId())); |
|
|
|
} |
|
|
|
|
|
|
|
//4.网格层级数据
|
|
|
|
} else if (FactConstant.GRID.equals(formDTO.getOrgType())) { |
|
|
|
//4-1.查询当前组织某一月份党建能力对应的总分、本级分、下级分
|
|
|
|
formDTO.setIndexCode(FactConstant.DJNL); |
|
|
|
dj = factIndexGridScoreDao.selectGridScoreList(formDTO); |
|
|
|
//4-2.查询当前组织某一月份治理能力对应的总分、本级分、下级分
|
|
|
|
formDTO.setIndexCode(FactConstant.ZLNL); |
|
|
|
zl = factIndexGridScoreDao.selectGridScoreList(formDTO); |
|
|
|
//4-3.查询当前组织某一月份服务能力对应的总分、本级分、下级分
|
|
|
|
formDTO.setIndexCode(FactConstant.FWNL); |
|
|
|
fw = factIndexGridScoreDao.selectGridScoreList(formDTO); |
|
|
|
//4-1.查询当前组织某一月份党建能力、治理能力、服务能力对应的总分、本级分、下级分
|
|
|
|
resultList = factIndexGridScoreDao.selectGridScoreList(formDTO); |
|
|
|
} else { |
|
|
|
throw new RenException(String.format("按月份查询各项能力分数,orgType类型错误,组织Id:%s,类型Type:%s", formDTO.getOrgId(), formDTO.getOrgType())); |
|
|
|
} |
|
|
|
//5.封装数据并返回
|
|
|
|
if (null != dj) { |
|
|
|
resultList.add(dj); |
|
|
|
} |
|
|
|
if (null != zl) { |
|
|
|
resultList.add(zl); |
|
|
|
} |
|
|
|
if (null != fw) { |
|
|
|
resultList.add(fw); |
|
|
|
} |
|
|
|
|
|
|
|
return resultList; |
|
|
|
} |
|
|
@ -237,6 +205,7 @@ public class FactIndexServiceImpl implements FactIndexService { |
|
|
|
@Override |
|
|
|
public List<MonthScoreListResultDTO> monthScoreList(MonthScoreListFormDTO formDTO) { |
|
|
|
LinkedList<MonthScoreListResultDTO> resultList = new LinkedList<>(); |
|
|
|
LinkedList<MonthScoreListResultDTO.ScoreListResultDTO> list = new LinkedList<>(); |
|
|
|
LinkedList<MonthScoreListResultDTO.ScoreListResultDTO> djList = new LinkedList<>(); |
|
|
|
LinkedList<MonthScoreListResultDTO.ScoreListResultDTO> zlList = new LinkedList<>(); |
|
|
|
LinkedList<MonthScoreListResultDTO.ScoreListResultDTO> fwList = new LinkedList<>(); |
|
|
@ -253,47 +222,34 @@ public class FactIndexServiceImpl implements FactIndexService { |
|
|
|
//4.根据组织级别判断查询哪类数据表
|
|
|
|
//区县级、乡镇街道级
|
|
|
|
if ("district".equals(agency.getLevel()) || "street".equals(agency.getLevel())) { |
|
|
|
//4-1.查询过去12个月党建能力每月总分、本级得分、下级得分数据
|
|
|
|
formDTO.setIndexCode(FactConstant.DJNL); |
|
|
|
djList = factIndexAgencyScoreDao.selectMonthScoreList(formDTO); |
|
|
|
//4-2.查询过去12个月治理能力每月总分、本级得分、下级得分数据
|
|
|
|
formDTO.setIndexCode(FactConstant.ZLNL); |
|
|
|
zlList = factIndexAgencyScoreDao.selectMonthScoreList(formDTO); |
|
|
|
//4-3.查询过去12个月服务能力每月总分、本级得分、下级得分数据
|
|
|
|
formDTO.setIndexCode(FactConstant.FWNL); |
|
|
|
fwList = factIndexAgencyScoreDao.selectMonthScoreList(formDTO); |
|
|
|
//4-1.查询过去12个月党建能力、治理能力、服务能力每月总分、本级得分、下级得分数据
|
|
|
|
list = factIndexAgencyScoreDao.selectMonthScoreList(formDTO); |
|
|
|
|
|
|
|
//社区级
|
|
|
|
} else if ("community".equals(agency.getLevel())) { |
|
|
|
//4-1.查询过去12个月党建能力每月总分、本级得分、下级得分数据
|
|
|
|
formDTO.setIndexCode(FactConstant.DJNL); |
|
|
|
djList = factIndexCommunityScoreDao.selectCommunityMonthScoreList(formDTO); |
|
|
|
//4-2.查询过去12个月治理能力每月总分、本级得分、下级得分数据
|
|
|
|
formDTO.setIndexCode(FactConstant.ZLNL); |
|
|
|
zlList = factIndexCommunityScoreDao.selectCommunityMonthScoreList(formDTO); |
|
|
|
//4-3.查询过去12个月服务能力每月总分、本级得分、下级得分数据
|
|
|
|
formDTO.setIndexCode(FactConstant.FWNL); |
|
|
|
fwList = factIndexCommunityScoreDao.selectCommunityMonthScoreList(formDTO); |
|
|
|
//4-1.查询过去12个月党建能力、治理能力、服务能力每月总分、本级得分、下级得分数据
|
|
|
|
list = factIndexCommunityScoreDao.selectCommunityMonthScoreList(formDTO); |
|
|
|
} else { |
|
|
|
throw new RenException(String.format("根据组织Id查询到的组织级别信息错误,组织Id:%s", formDTO.getOrgId())); |
|
|
|
} |
|
|
|
//网格层级数据
|
|
|
|
} else if (FactConstant.GRID.equals(formDTO.getOrgType())) { |
|
|
|
//5.查询过去12个月网格层级各项能力对应的各项得分数据
|
|
|
|
//5-1.查询网格过去12个月党建能力每月总分、本级得分、下级得分数据
|
|
|
|
formDTO.setIndexCode(FactConstant.DJNL); |
|
|
|
djList = factIndexGridScoreDao.selectGridMonthScoreList(formDTO); |
|
|
|
//5-2.查询网格过去12个月治理能力每月总分、本级得分、下级得分数据
|
|
|
|
formDTO.setIndexCode(FactConstant.ZLNL); |
|
|
|
zlList = factIndexGridScoreDao.selectGridMonthScoreList(formDTO); |
|
|
|
//5-3.查询网格过去12个月服务能力每月总分、本级得分、下级得分数据
|
|
|
|
formDTO.setIndexCode(FactConstant.FWNL); |
|
|
|
fwList = factIndexGridScoreDao.selectGridMonthScoreList(formDTO); |
|
|
|
//5.查询网格过去12个月党建能力、治理能力、服务能力每月总分、本级得分、下级得分数据
|
|
|
|
list = factIndexGridScoreDao.selectGridMonthScoreList(formDTO); |
|
|
|
} else { |
|
|
|
throw new RenException(String.format("能力指数查询,orgType类型错误,组织Id:%s,类型Type:%s", formDTO.getOrgId(), formDTO.getOrgType())); |
|
|
|
} |
|
|
|
|
|
|
|
//5.封装数据并返回
|
|
|
|
for (MonthScoreListResultDTO.ScoreListResultDTO l : list) { |
|
|
|
if (FactConstant.DJNL.equals(l.getIndexCode())) { |
|
|
|
djList.add(l); |
|
|
|
} else if (FactConstant.ZLNL.equals(l.getIndexCode())) { |
|
|
|
zlList.add(l); |
|
|
|
} else if (FactConstant.FWNL.equals(l.getIndexCode())) { |
|
|
|
fwList.add(l); |
|
|
|
} |
|
|
|
} |
|
|
|
MonthScoreListResultDTO dj = new MonthScoreListResultDTO(); |
|
|
|
dj.setIndexCode(FactConstant.DJNL); |
|
|
|
dj.setScoreList(djList); |
|
|
|