| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368 |
- package cn.com.goldenwater.dcproj.utils;
- import cn.com.goldenwater.dcproj.enums.GrwSttpEnum;
- import cn.com.goldenwater.dcproj.enums.NormalEnum;
- import cn.com.goldenwater.dcproj.model.BisInspGrw;
- import com.alibaba.fastjson.JSONObject;
- import org.apache.commons.lang3.StringUtils;
- import org.apache.commons.lang3.math.NumberUtils;
- /**
- * 地下水监测站督查评分规则
- */
- public class GrwScoreRule {
- private final int flagSign = 10; //是否有标志牌
- private final int flagMark = 5;//是否有水准点
- private final int flagExact = 5;//基本信息是否准确(
- private final int flagSafeguard = 5;//有无简易保护措施
- private final int flagTool = 5;//是否配备检测工具
- private final int flagTrain = 5;//委托观测人员是否经过培训
- private final int repeatability = 2;//现场比测精度误差(cm) 临界值
- private final Long repeatabilityScore = 40L;//现场比测精度误差得分
- private final int[] percentage = {80, 90, 95};//单站月统计到报率(%)
- private final Long toolProfScore = 10L;//观测人员操作规范、熟练
- private final Long[] percentageScore = {0L, 5L, 10L, 15L}; //单站月统计到报率得分
- private final Long toolTsoScore = 5L;//测具是否符合有关技术要求
- private final Long wellProtScore = 5L;//保护筒外管是否完好无损
- private final Long handScore = 15L;//人工监测数据报送是否及时
- private final String ruleStr = "{\n" +
- "\t\"data\": {\n" +
- "\t\t\"essentialInfo\": [{\n" +
- "\t\t\t\"key\": \"0\",\n" +
- "\t\t\t\"value\": \"0\"\n" +
- "\t\t}, {\n" +
- "\t\t\t\"key\": \"1\",\n" +
- "\t\t\t\"value\": \"5\"\n" +
- "\t\t}],\n" +
- "\t\t\"protectfacility\": [{\n" +
- "\t\t\t\"key\": \"0\",\n" +
- "\t\t\t\"value\": \"0\"\n" +
- "\t\t}, {\n" +
- "\t\t\t\"key\": \"1\",\n" +
- "\t\t\t\"value\": \"5\"\n" +
- "\t\t}],\n" +
- "\t\t\"detectionTool\": [{\n" +
- "\t\t\t\"key\": \"0\",\n" +
- "\t\t\t\"value\": \"0\"\n" +
- "\t\t}, {\n" +
- "\t\t\t\"key\": \"1\",\n" +
- "\t\t\t\"value\": \"0\"\n" +
- "\t\t}],\n" +
- "\t\t\"cylinderoutertube\": [{\n" +
- "\t\t\t\"key\": \"scoring\",\n" +
- "\t\t\t\"value\": \"[0,5]\"\n" +
- "\t\t}],\n" +
- "\t\t\"fieldcomparisontest\": [{\n" +
- "\t\t\t\"key\": \"[0,2]\",\n" +
- "\t\t\t\"value\": \"40\"\n" +
- "\t\t}, {\n" +
- "\t\t\t\"key\": \"(2,100]\",\n" +
- "\t\t\t\"value\": \"0\"\n" +
- "\t\t}],\n" +
- "\t\t\"monthlySingleStation\": [{\n" +
- "\t\t\t\"key\": \"[0,80)\",\n" +
- "\t\t\t\"value\": \"0\"\n" +
- "\t\t}, {\n" +
- "\t\t\t\"key\": \"[80,90)\",\n" +
- "\t\t\t\"value\": \"5\"\n" +
- "\t\t}, {\n" +
- "\t\t\t\"key\": \"[90,95)\",\n" +
- "\t\t\t\"value\": \"10\"\n" +
- "\t\t}, {\n" +
- "\t\t\t\"key\": \"[95,100]\",\n" +
- "\t\t\t\"value\": \"15\"\n" +
- "\t\t}],\n" +
- "\t\t\"techrequire\": [{\n" +
- "\t\t\t\"key\": \"scoring\",\n" +
- "\t\t\t\"value\": \"[0,5]\"\n" +
- "\t\t}],\n" +
- "\t\t\"standproficiency\": [{\n" +
- "\t\t\t\"key\": \"scoring\",\n" +
- "\t\t\t\"value\": \"[0,10]\"\n" +
- "\t\t}],\n" +
- "\t\t\"manualmonitorReport\": [{\n" +
- "\t\t\t\"key\": \"scoring\",\n" +
- "\t\t\t\"value\": \"[0,15]\"\n" +
- "\t\t}],\n" +
- "\t\t\"benchmark\": [{\n" +
- "\t\t\t\"key\": \"0\",\n" +
- "\t\t\t\"value\": \"0\"\n" +
- "\t\t}, {\n" +
- "\t\t\t\"key\": \"1\",\n" +
- "\t\t\t\"value\": \"5\"\n" +
- "\t\t}],\n" +
- "\t\t\"signBoard\": [{\n" +
- "\t\t\t\"key\": \"0\",\n" +
- "\t\t\t\"value\": \"0\"\n" +
- "\t\t}, {\n" +
- "\t\t\t\"key\": \"1\",\n" +
- "\t\t\t\"value\": \"10\"\n" +
- "\t\t}],\n" +
- "\t\t\"train\": [{\n" +
- "\t\t\t\"key\": \"0\",\n" +
- "\t\t\t\"value\": \"0\"\n" +
- "\t\t}, {\n" +
- "\t\t\t\"key\": \"1\",\n" +
- "\t\t\t\"value\": \"5\"\n" +
- "\t\t}]\n" +
- "\t}\n" +
- "}\n";
- public JSONObject getRuleJson() {
- JSONObject rule = new JSONObject();
- rule = JSONObject.parseObject(this.ruleStr);
- return rule;
- }
- /**
- * 计算监测数据质量和到报率小计得分
- *
- * @param bisInspGrw
- * @return
- * @throws Exception
- */
- public static Long calDataQuality(BisInspGrw bisInspGrw) throws Exception {
- Long score = 0L;
- if (bisInspGrw.getRepeatabilityScore() != null) {//现场比测经度误差
- score += bisInspGrw.getRepeatabilityScore();
- }
- if (GrwSttpEnum.PROVHAND.getValue().equals(bisInspGrw.getSttp()) || GrwSttpEnum.PROV.getValue().equals(bisInspGrw.getSttp())) {
- if (bisInspGrw.getHandScore() != null) {//人工监测数据报送是否及时
- score += bisInspGrw.getHandScore();
- }
- } else if (GrwSttpEnum.NATIONAL.getValue().equals(bisInspGrw.getSttp()) || GrwSttpEnum.PROVAUTO.getValue().equals(bisInspGrw.getSttp())) {
- if (bisInspGrw.getPercentageScore() != null) {//单站月统计到报率
- score += bisInspGrw.getPercentageScore();
- }
- } else {
- throw new Exception("测站类型错误:" + bisInspGrw.getSttp());
- }
- return score;
- }
- /**
- * 计算测站维护管理信息小计得分
- *
- * @param bisInspGrw
- * @return
- * @throws Exception
- */
- public static Long calMainTainScore(BisInspGrw bisInspGrw) throws Exception {
- Long score = 0L;
- if (NormalEnum.YES.getValue().equals(bisInspGrw.getFlagSign()) && bisInspGrw.getSignScore() != null) {//是否有标志牌
- score += bisInspGrw.getSignScore();
- }
- if (NormalEnum.YES.getValue().equals(bisInspGrw.getFlagExact()) && bisInspGrw.getExactScore() != null) {//基本信息是否准确
- score += bisInspGrw.getExactScore();
- }
- if (NormalEnum.YES.getValue().equals(bisInspGrw.getFlagSafeguard()) && bisInspGrw.getSafeguardScore() != null) {//有无简易保护措施
- score += bisInspGrw.getSafeguardScore();
- }
- if (GrwSttpEnum.PROVHAND.getValue().equals(bisInspGrw.getSttp()) || GrwSttpEnum.PROV.getValue().equals(bisInspGrw.getSttp())) {
- if (NormalEnum.YES.getValue().equals(bisInspGrw.getFlagTool())) {//是否配备检测工具
- if (bisInspGrw.getToolScore() != null) {//是否配备检测工具得分
- score += bisInspGrw.getToolScore();
- }
- if (bisInspGrw.getToolTsoScore() != null) {//测具是否符合有关技术要求
- score += bisInspGrw.getToolTsoScore();
- }
- }
- if (NormalEnum.YES.getValue().equals(bisInspGrw.getFlagTrain())) {//委托观测人员是否经过培训
- if (bisInspGrw.getTrainScore() != null) {
- score += bisInspGrw.getTrainScore();
- }
- }
- if (bisInspGrw.getToolProfScore() != null) {//测量人员操作规范、熟练
- score += bisInspGrw.getToolProfScore();
- }
- } else if (GrwSttpEnum.NATIONAL.getValue().equals(bisInspGrw.getSttp()) || GrwSttpEnum.PROVAUTO.getValue().equals(bisInspGrw.getSttp())) {
- if (NormalEnum.YES.getValue().equals(bisInspGrw.getFlagMark()) && bisInspGrw.getMarkScore() != null) {//是否有水准点
- score += bisInspGrw.getMarkScore();
- }
- if (NormalEnum.YES.getValue().equals(bisInspGrw.getFlagTool())) {//是否配备检测工具
- if (bisInspGrw.getToolTsoScore() != null) {//测具是否符合有关技术要求
- score += bisInspGrw.getToolTsoScore();
- }
- if (bisInspGrw.getToolProfScore() != null) {//测量人员操作规范、熟练
- score += bisInspGrw.getToolProfScore();
- }
- }
- if (bisInspGrw.getWellProtScore() != null) {//保护筒外管是否完好无损
- score += bisInspGrw.getWellProtScore();
- }
- } else {
- throw new Exception("测站类型错误:" + bisInspGrw.getSttp());
- }
- return score;
- }
- /**
- * 根据数据库中数据相加计算总得分
- *
- * @param bisInspGrw
- * @return
- * @throws Exception
- */
- public static Long calTotalScore(BisInspGrw bisInspGrw) throws Exception {
- Long score = 0L;
- score = calMainTainScore(bisInspGrw);
- score += calDataQuality(bisInspGrw);
- bisInspGrw.setAllScore(score);
- return score;
- }
- /**
- * 根据规则实时计算总分
- *
- * @param p
- * @return
- * @throws Exception
- */
- public Long CalScoreByRule(BisInspGrw p) throws Exception {
- Long score = 0L;
- if (StringUtils.isNotBlank(p.getFlagSign())) {//是否有标志牌
- Long signScore = NumberUtils.toLong(p.getFlagSign()) * flagSign;
- p.setSignScore(signScore);
- score += signScore;
- }
- if (StringUtils.isNotBlank(p.getFlagMark())) {//是否有水准点
- Long markScore = NumberUtils.toLong(p.getFlagMark()) * flagMark;
- p.setMarkScore(markScore);
- score += markScore;
- }
- if (StringUtils.isNotBlank(p.getFlagExact())) {//基本信息是否准确
- Long exactScore = NumberUtils.toLong(p.getFlagExact()) * flagExact;
- p.setExactScore(exactScore);
- score += exactScore;
- }
- if (StringUtils.isNotBlank(p.getFlagSafeguard())) {//有无简易保护措施
- Long safeguardScore = NumberUtils.toLong(p.getFlagSafeguard()) * flagSafeguard;
- p.setSafeguardScore(safeguardScore);
- score += safeguardScore;
- }
- if (GrwSttpEnum.PROVHAND.getValue().equals(p.getSttp()) && StringUtils.isNotBlank(p.getFlagTool())) {//是否配备检测工具
- Long toolScore = NumberUtils.toLong(p.getFlagTool()) * flagTool;
- p.setToolScore(toolScore);
- score += toolScore;
- }
- if (p.getToolTsoScore() != null) {//测具是否符合有关技术要求 5分
- if (p.getToolTsoScore() >= 0 && p.getToolTsoScore() <= toolTsoScore) {
- score += p.getToolTsoScore();
- } else {
- throw new Exception("测具是否符合有关技术要求得分范围为[0," + toolTsoScore + "]");
- }
- }
- if (p.getToolProfScore() != null) {//测量人员操作规范、熟练 10分
- if (p.getToolProfScore() >= 0 && p.getToolProfScore() <= toolProfScore) {
- score += p.getToolProfScore();
- } else {
- throw new Exception("测量人员操作规范、熟练得分范围为[0," + toolProfScore + "]");
- }
- }
- if (StringUtils.isNotBlank(p.getFlagTrain())) {//委托观测人员是否经过培训
- Long trainScore = NumberUtils.toLong(p.getFlagTrain()) * flagTrain;
- p.setTrainScore(trainScore);
- score += trainScore;
- }
- if (p.getWellProtScore() != null) {//保护筒外管是否完好无损
- if (p.getWellProtScore() >= 0 && p.getWellProtScore() <= wellProtScore) {
- score += p.getWellProtScore();
- } else {
- throw new Exception("保护筒外管是否完好无损得分范围为[0," + wellProtScore + "]");
- }
- }
- if (p.getRepeatability() != null && p.getRepeatability() <= repeatability) { //现场比测精度误差
- p.setRepeatabilityScore(repeatabilityScore);
- score += repeatabilityScore;
- }
- if (p.getPercentage() != null) { //单站月统计到报率(%)
- if (p.getPercentage() < percentage[0]) {
- score += percentageScore[0];
- p.setRepeatabilityScore(percentageScore[0]);
- } else if (p.getPercentage() >= percentage[percentage.length - 1]) {
- score += percentageScore[percentage.length - 1];
- p.setRepeatabilityScore(percentageScore[percentage.length - 1]);
- } else {
- for (int i = 0; i < percentage.length - 1; i++) {
- if (p.getPercentage() >= percentage[i] && p.getPercentage() < percentage[i + 1]) {
- p.setRepeatabilityScore(percentageScore[i + 1]);
- score += percentageScore[i + 1];
- break;
- }
- }
- }
- }
- if (GrwSttpEnum.PROVHAND.getValue().equals(p.getSttp()) && p.getHandScore() != null) {
- if (p.getHandScore() >= 0 && p.getHandScore() <= handScore) {
- score += p.getHandScore();
- } else {
- throw new Exception("人工监测数据报送是否及时得分范围为[0," + handScore + "]");
- }
- }
- return score;
- }
- public String getRuleStr() {
- return ruleStr;
- }
- public int getFlagSign() {
- return flagSign;
- }
- public int getFlagMark() {
- return flagMark;
- }
- public int getFlagExact() {
- return flagExact;
- }
- public int getFlagSafeguard() {
- return flagSafeguard;
- }
- public int getFlagTool() {
- return flagTool;
- }
- public int getFlagTrain() {
- return flagTrain;
- }
- public int getRepeatability() {
- return repeatability;
- }
- public Long getRepeatabilityScore() {
- return repeatabilityScore;
- }
- public int[] getPercentage() {
- return percentage;
- }
- public Long[] getPercentageScore() {
- return percentageScore;
- }
- public Long getToolTsoScore() {
- return toolTsoScore;
- }
- public Long getToolProfScore() {
- return toolProfScore;
- }
- public Long getWellProtScore() {
- return wellProtScore;
- }
- public Long getHandScore() {
- return handScore;
- }
- }
|