|
@ -303,7 +303,7 @@ public class StatisticsAllService extends BaseService {
|
|
|
public JSONObject getSignTaskRate(String endDate, String area, int level) throws Exception {
|
|
|
JSONObject json = new JSONObject();
|
|
|
long signAmount = getIndexTotal(endDate, area, level, "13");
|
|
|
PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(area,Integer.valueOf( Constant.getNowYear()));
|
|
|
PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(area, Integer.valueOf(Constant.getNowYear()));
|
|
|
DecimalFormat df = new DecimalFormat("0.0000");
|
|
|
|
|
|
if (peopleNum != null && peopleNum.getTaskNum() > 0) {
|
|
@ -400,7 +400,7 @@ public class StatisticsAllService extends BaseService {
|
|
|
redisNum = "";
|
|
|
}
|
|
|
if (StringUtils.isEmpty(redisNum)) {
|
|
|
PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(area,Integer.valueOf( Constant.getNowYear()));
|
|
|
PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(area, Integer.valueOf(Constant.getNowYear()));
|
|
|
if (peopleNum != null) {
|
|
|
if (lowCode.equals("3")) {
|
|
|
num = peopleNum.getSixFiveNum();
|
|
@ -491,7 +491,7 @@ public class StatisticsAllService extends BaseService {
|
|
|
redisNum = "";
|
|
|
}
|
|
|
if (StringUtils.isEmpty(redisNum)) {
|
|
|
PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(map.get("code").toString(), Integer.valueOf( Constant.getNowYear()));
|
|
|
PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(map.get("code").toString(), Integer.valueOf(Constant.getNowYear()));
|
|
|
if (peopleNum != null) {
|
|
|
int num = 0;
|
|
|
int taskNum = 0;
|
|
@ -610,7 +610,7 @@ public class StatisticsAllService extends BaseService {
|
|
|
redisNum = "";
|
|
|
}
|
|
|
if (StringUtils.isEmpty(redisNum)) {
|
|
|
PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(map.get("code").toString(),Integer.valueOf( Constant.getNowYear()));
|
|
|
PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(map.get("code").toString(), Integer.valueOf(Constant.getNowYear()));
|
|
|
if (peopleNum != null) {
|
|
|
map.put("rate", df.format(((long) map.get("amount") * 1.0000) / peopleNum.getNum() * 100));
|
|
|
map.put("taskRate", df.format(((long) map.get("amount") * 1.0000) / peopleNum.getTaskNum() * 100));
|
|
@ -704,7 +704,7 @@ public class StatisticsAllService extends BaseService {
|
|
|
redisNum = "";
|
|
|
}
|
|
|
if (StringUtils.isEmpty(redisNum)) {
|
|
|
PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(map.get("code").toString(),Integer.valueOf( Constant.getNowYear()));
|
|
|
PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(map.get("code").toString(), Integer.valueOf(Constant.getNowYear()));
|
|
|
if (peopleNum != null) {
|
|
|
map.put("rate", df.format(((long) map.get("amount") * 1.0000) / peopleNum.getNum() * 100));
|
|
|
map.put("taskRate", df.format(((long) map.get("amount") * 1.0000) / peopleNum.getTaskNum() * 100));
|
|
@ -1879,7 +1879,7 @@ public class StatisticsAllService extends BaseService {
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isEmpty(redisNum)) {
|
|
|
PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(area,Integer.valueOf( Constant.getNowYear()));
|
|
|
PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(area, Integer.valueOf(Constant.getNowYear()));
|
|
|
if (peopleNum != null) {
|
|
|
taskNum = peopleNum.getTaskNum();
|
|
|
}
|
|
@ -1898,7 +1898,7 @@ public class StatisticsAllService extends BaseService {
|
|
|
redisNum = "";
|
|
|
}
|
|
|
if (StringUtils.isEmpty(redisNum)) {
|
|
|
PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(area, Integer.valueOf( Constant.getNowYear()));
|
|
|
PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(area, Integer.valueOf(Constant.getNowYear()));
|
|
|
if (peopleNum != null) {
|
|
|
if (lowCode.equals("3")) {
|
|
|
taskNum = peopleNum.getSixFiveTaskNum();
|
|
@ -2515,7 +2515,7 @@ public class StatisticsAllService extends BaseService {
|
|
|
redisNum = "";
|
|
|
}
|
|
|
if (StringUtils.isEmpty(redisNum)) {
|
|
|
PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(map.get("code").toString(), Integer.valueOf( Constant.getNowYear()));
|
|
|
PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(map.get("code").toString(), Integer.valueOf(Constant.getNowYear()));
|
|
|
if (peopleNum != null) {
|
|
|
map.put("rate", df.format(((long) map.get("amount") * 1.0000) / peopleNum.getNum() * 100));
|
|
|
map.put("taskRate", df.format(((long) map.get("amount") * 1.0000) / peopleNum.getTaskNum() * 100));
|
|
@ -2775,7 +2775,7 @@ public class StatisticsAllService extends BaseService {
|
|
|
redisNum = "";
|
|
|
}
|
|
|
if (StringUtils.isEmpty(redisNum)) {
|
|
|
PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(map.get("code").toString(), Integer.valueOf( Constant.getNowYear()));
|
|
|
PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(map.get("code").toString(), Integer.valueOf(Constant.getNowYear()));
|
|
|
if (peopleNum != null) {
|
|
|
int num = 0;
|
|
|
int taskNum = 0;
|
|
@ -2870,11 +2870,13 @@ public class StatisticsAllService extends BaseService {
|
|
|
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
String lastDate = year + "-06-30";
|
|
|
String timeKey = redisTemplate.opsForValue().get("quota:timeKey");
|
|
|
|
|
|
String low_level = String.valueOf(StringUtils.isEmpty(lowLevel) ? (level - 1) : lowLevel);
|
|
|
List<Map<String, Object>> resultList = new ArrayList<>();//续签量
|
|
|
List<Map<String, Object>> resultListSignIn = new ArrayList<>();//签入量
|
|
|
resultList = getLevelTwoTodayLowLevelTotal(area, level, index, sort, lowLevel, lowCode);
|
|
|
//获取续签量
|
|
|
JSONArray renewJA = getLevel2ListForRedis("29", level + "", lowLevel, area, timeKey);
|
|
|
//获取续入量
|
|
|
String indexTemp = "";
|
|
|
if ("1".equals(lowLevel)) {
|
|
|
indexTemp = "34";//团队的签入指标
|
|
@ -2883,32 +2885,42 @@ public class StatisticsAllService extends BaseService {
|
|
|
} else {
|
|
|
indexTemp = "40";//区的签入指标
|
|
|
}
|
|
|
//根据等级得到签入量
|
|
|
resultListSignIn = getLevelTwoTodayLowLevelTotal(area, level, indexTemp, sort, lowLevel, lowCode);
|
|
|
JSONArray signInJA = getLevel2ListForRedis(indexTemp, level + "", lowLevel, area, timeKey);
|
|
|
|
|
|
//签入的列表转map
|
|
|
Map<String, Integer> signInMap = new HashMap<>();
|
|
|
if (resultListSignIn != null && resultListSignIn.size() > 0) {
|
|
|
resultListSignIn.stream().forEach(one -> {
|
|
|
signInMap.put(one.get("code").toString(), Integer.valueOf(one.get("amount").toString()));
|
|
|
});
|
|
|
if (signInJA != null && signInJA.length() > 0) {
|
|
|
for (int i = 0; i < signInJA.length(); i++) {
|
|
|
JSONObject jo = signInJA.getJSONObject(i);
|
|
|
signInMap.put(jo.getString("code"), jo.getInt("num"));
|
|
|
}
|
|
|
}
|
|
|
// 结果为空时,自建结果集
|
|
|
if (resultList == null || resultList.size() < 1) {
|
|
|
resultList = getLowLevelMapKey(level, low_level, area);
|
|
|
|
|
|
//续签的的列表转map
|
|
|
Map<String, Integer> renewMap = new HashMap<>();
|
|
|
if (renewJA != null && renewJA.length() > 0) {
|
|
|
for (int i = 0; i < renewJA.length(); i++) {
|
|
|
JSONObject jo = renewJA.getJSONObject(i);
|
|
|
renewMap.put(jo.getString("code"), jo.getInt("num"));
|
|
|
}
|
|
|
}
|
|
|
//自建结果集
|
|
|
resultList = getLowLevelMapKey(level, low_level, area);
|
|
|
|
|
|
|
|
|
if (resultList != null) {
|
|
|
DecimalFormat df = new DecimalFormat("0.0000");
|
|
|
for (Map<String, Object> map : resultList) {
|
|
|
map.put("amount", map.get("amount") != null ? Long.valueOf(map.get("amount").toString()) : 0L);
|
|
|
|
|
|
//获取去年签约的人数 默认是上个年度的最后一天
|
|
|
WlyyQuotaResult redisNum = findOneQuotaResult(lastDate, Integer.valueOf(low_level), "1", map.get("code").toString());
|
|
|
Integer signId = signInMap.get(map.get("code").toString()) == null ? 0 : signInMap.get(map.get("code").toString());
|
|
|
if (redisNum == null) {
|
|
|
int signNum = 0;
|
|
|
int renewNum = 0;
|
|
|
int renewNum =renewMap.get(map.get("code").toString());
|
|
|
int signInNum=signInMap.get(map.get("code").toString());
|
|
|
signNum = Integer.valueOf(0);
|
|
|
renewNum = Integer.valueOf(map.get("amount").toString()) - signId; //续签量等于 续签量-签入量
|
|
|
renewNum = renewNum-signInNum; //续签量等于 续签量-签入量
|
|
|
map.put("rate", getRange(renewNum, signNum, 2));
|
|
|
map.put("signNum", 0);
|
|
|
map.put("renewNum", renewNum);
|
|
@ -2916,10 +2928,11 @@ public class StatisticsAllService extends BaseService {
|
|
|
JSONObject peopleNum = new JSONObject(redisNum);
|
|
|
if (peopleNum != null) {
|
|
|
int signNum = 0;
|
|
|
int renewNum = 0;
|
|
|
int renewNum =renewMap.get(map.get("code").toString());
|
|
|
int signInNum=signInMap.get(map.get("code").toString());
|
|
|
|
|
|
signNum = Integer.valueOf(redisNum.getResult());
|
|
|
renewNum = Integer.valueOf(map.get("amount").toString()) - signId; //续签量等于 续签量-签入量
|
|
|
renewNum = renewNum-signInNum; //续签量等于 续签量-签入量
|
|
|
map.put("rate", getRange(renewNum, signNum, 2));
|
|
|
map.put("signNum", signNum);
|
|
|
map.put("renewNum", renewNum);
|
|
@ -2982,4 +2995,22 @@ public class StatisticsAllService extends BaseService {
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
//================================通用接口=============================
|
|
|
|
|
|
/**
|
|
|
* 查询redis中父子表是level 的某个level2的列表
|
|
|
*
|
|
|
* @param index
|
|
|
* @param level
|
|
|
* @param level2
|
|
|
* @param code
|
|
|
* @param timeKey
|
|
|
* @return
|
|
|
*/
|
|
|
private JSONArray getLevel2ListForRedis(String index, String level, String level2, String code, String timeKey) {
|
|
|
String key37 = "quota:" + index + ":" + level + ":" + code + ":" + level2 + ":" + timeKey;
|
|
|
JSONArray switchJo = new JSONArray(redisTemplate.opsForValue().get(key37));
|
|
|
return switchJo;
|
|
|
}
|
|
|
}
|