bug修复
This commit is contained in:
parent
40a0ca3db8
commit
45b24e9a73
|
|
@ -386,7 +386,11 @@ public class OutsourcerEvaluateServiceImpl implements OutsourcerEvaluateService
|
|||
BeanUtils.copyProperties(o, childBean);
|
||||
childBean.setJsonData(list.get(i).toString());
|
||||
childBean.setDeptId(deptId);
|
||||
childBean.setUserId(userId);
|
||||
if (!checkMapValuesAllEmpty(list.get(i), o.getTitleFiled())) {
|
||||
childBean.setUserId(userId);
|
||||
} else {
|
||||
childBean.setUserId(null);
|
||||
}
|
||||
childBean.setParentId(o.getId());
|
||||
childBean.setProId(list.get(i).get("proId").toString());
|
||||
childBean.setProName(list.get(i).get("proName").toString());
|
||||
|
|
@ -403,7 +407,11 @@ public class OutsourcerEvaluateServiceImpl implements OutsourcerEvaluateService
|
|||
detailsBean.setEvaluateId(o.getEvaluateId());
|
||||
detailsBean.setTemplateId(o.getTemplateId());
|
||||
detailsBean.setDeptId(deptId);
|
||||
detailsBean.setUserId(userId);
|
||||
if (!checkMapValuesAllEmpty(map, o.getTitleFiled())) {
|
||||
detailsBean.setUserId(userId);
|
||||
} else {
|
||||
detailsBean.setUserId(null);
|
||||
}
|
||||
detailsBean.setParentId(o.getId());
|
||||
detailsBean.setProId(map.get("proId").toString());
|
||||
detailsBean.setProName(map.get("proName").toString());
|
||||
|
|
@ -479,8 +487,10 @@ public class OutsourcerEvaluateServiceImpl implements OutsourcerEvaluateService
|
|||
BeanUtils.copyProperties(o, childBean);
|
||||
childBean.setJsonData(list.get(i).toString());
|
||||
childBean.setDeptId(deptId);
|
||||
if (!checkMapValuesAllEmpty(list.get(i))){
|
||||
if (!checkMapValuesAllEmpty(list.get(i), o.getTitleFiled())) {
|
||||
childBean.setUserId(userId);
|
||||
} else {
|
||||
childBean.setUserId(null);
|
||||
}
|
||||
childBean.setParentId(o.getId());
|
||||
childBean.setProId(list.get(i).get("proId").toString());
|
||||
|
|
@ -501,8 +511,10 @@ public class OutsourcerEvaluateServiceImpl implements OutsourcerEvaluateService
|
|||
detailsBean.setEvaluateId(o.getEvaluateId());
|
||||
detailsBean.setTemplateId(o.getTemplateId());
|
||||
detailsBean.setDeptId(deptId);
|
||||
if (!checkMapValuesAllEmpty(map)){
|
||||
if (!checkMapValuesAllEmpty(map, o.getTitleFiled())) {
|
||||
detailsBean.setUserId(userId);
|
||||
} else {
|
||||
detailsBean.setUserId(null);
|
||||
}
|
||||
detailsBean.setParentId(o.getId());
|
||||
detailsBean.setProId(map.get("proId").toString());
|
||||
|
|
@ -530,33 +542,37 @@ public class OutsourcerEvaluateServiceImpl implements OutsourcerEvaluateService
|
|||
return ar;
|
||||
}
|
||||
|
||||
public static boolean checkMapValuesAllEmpty(Map<String, Object> map) {
|
||||
public static boolean checkMapValuesAllEmpty(Map<String, Object> map, String titleFiled) {
|
||||
if (map == null || map.isEmpty()) {
|
||||
return true; // 空map认为所有值都是空
|
||||
return false; // 空map肯定不满足条件
|
||||
}
|
||||
|
||||
for (Object value : map.values()) {
|
||||
if (titleFiled == null || titleFiled.trim().isEmpty()) {
|
||||
return true; // 没有要检查的字段,默认满足条件
|
||||
}
|
||||
|
||||
String[] keys = titleFiled.split(",");
|
||||
for (String key : keys) {
|
||||
Object value = map.get(key.trim());
|
||||
|
||||
// 如果 key 不存在 或者 value 是 null
|
||||
if (value == null) {
|
||||
continue; // null 是空值,继续检查下一个
|
||||
continue;
|
||||
}
|
||||
|
||||
if (value instanceof String) {
|
||||
String strVal = (String) value;
|
||||
if (!strVal.trim().isEmpty()) {
|
||||
return false; // 发现非空字符串,立即返回 false
|
||||
if (!((String) value).trim().isEmpty()) {
|
||||
return false; // 不是空字符串
|
||||
}
|
||||
} else if (value instanceof Boolean) {
|
||||
return false; // boolean 类型(true/false),不为空
|
||||
} else if (value instanceof Number) {
|
||||
return false; // 数字类型(0 也是有效值)
|
||||
} else {
|
||||
// 其他对象只要不为null就认为是非空
|
||||
// 如果不是字符串类型,认为不是“空字符串”
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true; // 所有值都为空
|
||||
return true; // 所有指定字段的值都为空字符串或 null
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxRes getAuditBtn(EvaluateDataBean o) {
|
||||
AjaxRes ar = new AjaxRes();
|
||||
|
|
@ -1385,37 +1401,39 @@ public class OutsourcerEvaluateServiceImpl implements OutsourcerEvaluateService
|
|||
}
|
||||
}
|
||||
//计算平准值进行重新计算
|
||||
for (Map<String, Object> map:childDataList){
|
||||
BigDecimal bigDecimal=new BigDecimal("0");
|
||||
int num=0;
|
||||
for (String key : map.keySet()) {
|
||||
if(key.contains("-")){
|
||||
String[] year=key.split("-");
|
||||
if (year.length==2 && isNumeric(year[0]) && isNumeric(year[1]) ){
|
||||
BigDecimal pfnum=new BigDecimal(String.valueOf(map.get(key)));
|
||||
bigDecimal=bigDecimal.add(pfnum);
|
||||
num++;
|
||||
}
|
||||
for (Map<String, Object> map : childDataList) {
|
||||
BigDecimal bigDecimal = new BigDecimal("0");
|
||||
int num = 0;
|
||||
for (String key : map.keySet()) {
|
||||
if (key.contains("-")) {
|
||||
String[] year = key.split("-");
|
||||
if (year.length == 2 && isNumeric(year[0]) && isNumeric(year[1])) {
|
||||
BigDecimal pfnum = new BigDecimal(String.valueOf(map.get(key)));
|
||||
bigDecimal = bigDecimal.add(pfnum);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
BigDecimal nums=new BigDecimal(num);
|
||||
BigDecimal avg= bigDecimal.divide(nums);
|
||||
map.put("avgScore",avg.toString());
|
||||
}
|
||||
BigDecimal nums = new BigDecimal(num);
|
||||
BigDecimal avg = bigDecimal.divide(nums);
|
||||
map.put("avgScore", avg.toString());
|
||||
}
|
||||
|
||||
childDataList.sort((o1, o2) -> {
|
||||
Double one = Double.valueOf(o1.get("avgScore").toString());
|
||||
Double two = Double.valueOf(o2.get("avgScore").toString());
|
||||
return two.compareTo(one); //one.compareTo(two)为升序,two.compareTo(one)为降序
|
||||
});
|
||||
childDataList.sort((o1, o2) -> {
|
||||
Double one = Double.valueOf(o1.get("avgScore").toString());
|
||||
Double two = Double.valueOf(o2.get("avgScore").toString());
|
||||
return two.compareTo(one); //one.compareTo(two)为升序,two.compareTo(one)为降序
|
||||
});
|
||||
String resParams = JSONArray.toJSON(finalTitleList).toString();
|
||||
String childParams = JSONArray.toJSON(childDataList).toString();
|
||||
ar.setSucceed(resParams, childParams);
|
||||
return ar;
|
||||
}
|
||||
|
||||
public static boolean isNumeric(String str) {
|
||||
return str.matches("-?\\d+(\\.\\d+)?");
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxRes isCheckOneIsAudit(EvaluateDataBean o) {
|
||||
AjaxRes ar = new AjaxRes();
|
||||
|
|
@ -1439,6 +1457,7 @@ public class OutsourcerEvaluateServiceImpl implements OutsourcerEvaluateService
|
|||
}
|
||||
return ar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxRes isCheckThreeIsAudit(EvaluateDataBean o) {
|
||||
AjaxRes ar = new AjaxRes();
|
||||
|
|
|
|||
Loading…
Reference in New Issue