修复动态考察结果汇总考察计划为空异常

This commit is contained in:
zengweihai 2024-12-03 10:14:28 +08:00
parent a3d3130d0b
commit e9b47fae67
1 changed files with 77 additions and 74 deletions

View File

@ -45,92 +45,95 @@ public class ExamTaskSummaryListPlugin extends AbstractListPlugin implements Plu
long evalTaskId = evaltask.getLong("id"); long evalTaskId = evaltask.getLong("id");
QFilter qFilter = new QFilter("plandetails.evaltask.id", QCP.equals, evalTaskId); QFilter qFilter = new QFilter("plandetails.evaltask.id", QCP.equals, evalTaskId);
DynamicObject examPlan = BusinessDataServiceHelper.loadSingle("resm_investigationplan", qFilter.toArray()); DynamicObject examPlan = BusinessDataServiceHelper.loadSingle("resm_investigationplan", qFilter.toArray());
DynamicObject qeug_project = examPlan.getDynamicObject("qeug_project");//考察计划的项目 if (examPlan != null){
if (qeug_project != null){ DynamicObject qeug_project = examPlan.getDynamicObject("qeug_project");//考察计划的项目
projectName = qeug_project.getString("name"); if (qeug_project != null){
} projectName = qeug_project.getString("name");
DynamicObjectCollection plandetails = examPlan.getDynamicObjectCollection("plandetails");//计划详情-分为多个考察任务 }
HashMap<String, HashMap<String, BigDecimal>> supOfUserGrade = new HashMap<String, HashMap<String, BigDecimal>>();//供应商对应人员评分key为供应商名称value为对应供应商考察成绩情况 DynamicObjectCollection plandetails = examPlan.getDynamicObjectCollection("plandetails");//计划详情-分为多个考察任务
HashMap<String,HashMap<String,String>> userNames = new HashMap<String, HashMap<String,String>>();//人员及属性集合用于构建单据字段 HashMap<String, HashMap<String, BigDecimal>> supOfUserGrade = new HashMap<String, HashMap<String, BigDecimal>>();//供应商对应人员评分key为供应商名称value为对应供应商考察成绩情况
for (DynamicObject plandetail : plandetails) {//循环多条考察任务 HashMap<String,HashMap<String,String>> userNames = new HashMap<String, HashMap<String,String>>();//人员及属性集合用于构建单据字段
String suppliersource = plandetail.getString("suppliersource");//供应商来源区分正式供应商和潜在供应商 for (DynamicObject plandetail : plandetails) {//循环多条考察任务
HashSet<Long> userNamesNow = new HashSet<Long>();//当前任务人员主键集合 String suppliersource = plandetail.getString("suppliersource");//供应商来源区分正式供应商和潜在供应商
ArrayList<DynamicObject> userDys = new ArrayList<>();//当前任务人员对象集合存放当前考察任务对应的考察人员对象 HashSet<Long> userNamesNow = new HashSet<Long>();//当前任务人员主键集合
DynamicObject suppliername = plandetail.getDynamicObject("suppliername");//供应商对象 ArrayList<DynamicObject> userDys = new ArrayList<>();//当前任务人员对象集合存放当前考察任务对应的考察人员对象
Object sup_pkValue = suppliername.getPkValue();//供应商主键 DynamicObject suppliername = plandetail.getDynamicObject("suppliername");//供应商对象
String supName = suppliername.getString("name"); Object sup_pkValue = suppliername.getPkValue();//供应商主键
DynamicObject evaltask_l = plandetail.getDynamicObject("evaltask");//考察任务 String supName = suppliername.getString("name");
long evaltask_lPk = evaltask_l.getLong("id");//考察任务主键 DynamicObject evaltask_l = plandetail.getDynamicObject("evaltask");//考察任务
DynamicObject resm_exam_task = BusinessDataServiceHelper.loadSingle(evaltask_lPk, "resm_exam_task");//完整考察任务数据 long evaltask_lPk = evaltask_l.getLong("id");//考察任务主键
String evaloObject = resm_exam_task.getString("evalobject");//考察对象区分角色或者人员 DynamicObject resm_exam_task = BusinessDataServiceHelper.loadSingle(evaltask_lPk, "resm_exam_task");//完整考察任务数据
boolean isRoleEval = StringUtils.equals("roleeval", evaloObject); String evaloObject = resm_exam_task.getString("evalobject");//考察对象区分角色或者人员
DynamicObjectCollection entry_evaldetail = resm_exam_task.getDynamicObjectCollection("entry_evaldetail"); boolean isRoleEval = StringUtils.equals("roleeval", evaloObject);
DynamicObject evalDetailRow = entry_evaldetail.get(0); DynamicObjectCollection entry_evaldetail = resm_exam_task.getDynamicObjectCollection("entry_evaldetail");
//todo:查询对应任务人员权重配置 DynamicObject evalDetailRow = entry_evaldetail.get(0);
DynamicObject myEval = BusinessDataServiceHelper.loadSingle("resm_evaluator", "evalentryid,entry_evaluator.user,entry_evaluator.role", new QFilter[]{new QFilter("evalentryid", "=", String.valueOf(evalDetailRow.getPkValue()))}); //todo:查询对应任务人员权重配置
if (myEval != null) { DynamicObject myEval = BusinessDataServiceHelper.loadSingle("resm_evaluator", "evalentryid,entry_evaluator.user,entry_evaluator.role", new QFilter[]{new QFilter("evalentryid", "=", String.valueOf(evalDetailRow.getPkValue()))});
DynamicObjectCollection entryentity = myEval.getDynamicObjectCollection("entry_evaluator"); if (myEval != null) {
for(int k = 0; k < entryentity.size(); k++) { DynamicObjectCollection entryentity = myEval.getDynamicObjectCollection("entry_evaluator");
DynamicObject evaluatorEntryRow = (DynamicObject)entryentity.get(k); for(int k = 0; k < entryentity.size(); k++) {
if (isRoleEval) { DynamicObject evaluatorEntryRow = (DynamicObject)entryentity.get(k);
if (isRoleEval) {
// evaluatorSet.add((Long)evaluatorEntryRow.getDynamicObject("role").getPkValue()); // evaluatorSet.add((Long)evaluatorEntryRow.getDynamicObject("role").getPkValue());
// evaluatorTempSet.add((Long)evaluatorEntryRow.getDynamicObject("role").getPkValue()); // evaluatorTempSet.add((Long)evaluatorEntryRow.getDynamicObject("role").getPkValue());
} else { } else {
Long userPk = (Long) evaluatorEntryRow.getDynamicObject("user").getPkValue(); Long userPk = (Long) evaluatorEntryRow.getDynamicObject("user").getPkValue();
DynamicObject bos_user = BusinessDataServiceHelper.loadSingle(userPk, "bos_user"); DynamicObject bos_user = BusinessDataServiceHelper.loadSingle(userPk, "bos_user");
if (bos_user != null){ if (bos_user != null){
String name = bos_user.getString("name"); String name = bos_user.getString("name");
String username = bos_user.getString("username"); String username = bos_user.getString("username");
HashMap<String, String> userProperty = new HashMap<>(); HashMap<String, String> userProperty = new HashMap<>();
userProperty.put("name",name); userProperty.put("name",name);
userProperty.put("username",username); userProperty.put("username",username);
userNames.put(username,userProperty);//添加进入人员属性中 userNames.put(username,userProperty);//添加进入人员属性中
userNamesNow.add(userPk);//添加进入当前人员主键集合 userNamesNow.add(userPk);//添加进入当前人员主键集合
userDys.add(bos_user);//添加进入当前人员对象集合 userDys.add(bos_user);//添加进入当前人员对象集合
}
} }
} }
} }
} QFilter myexam_QF = new QFilter("evaltask.id",QCP.equals,evaltask_lPk);//考察任务id
QFilter myexam_QF = new QFilter("evaltask.id",QCP.equals,evaltask_lPk);//考察任务id myexam_QF.and("creator.id",QCP.in,userNamesNow);//当前考察人
myexam_QF.and("creator.id",QCP.in,userNamesNow);//当前考察人 if ("resm_regsupplier".equals(suppliersource)){//潜在供应商
if ("resm_regsupplier".equals(suppliersource)){//潜在供应商 myexam_QF.and("evalsupplier.id",QCP.equals,sup_pkValue);
myexam_QF.and("evalsupplier.id",QCP.equals,sup_pkValue); }else {//正式供应商
}else {//正式供应商 myexam_QF.and("evaloffsupplier.id",QCP.equals,sup_pkValue);
myexam_QF.and("evaloffsupplier.id",QCP.equals,sup_pkValue);
}
//查询出该考察任务关联的我的考察
DynamicObject[] resm_myexams = BusinessDataServiceHelper.load("resm_myexam", "creator,evalscore", myexam_QF.toArray());
//todo:开始构建供应商对应人员评分
HashMap<String, BigDecimal> userGrades = new HashMap<String, BigDecimal>();//人员成绩key为人员用户名value为人员分数
if (resm_myexams.length > 0){
for (DynamicObject resm_myexam : resm_myexams) {
DynamicObject creator = resm_myexam.getDynamicObject("creator");//当前考察人
BigDecimal evalscore = resm_myexam.getBigDecimal("evalscore");//考察得分
String username = creator.getString("username");//人员用户名
userGrades.put(username,evalscore);
} }
}else { //查询出该考察任务关联的我的考察
//我的考察还未下达时,先赋值0 DynamicObject[] resm_myexams = BusinessDataServiceHelper.load("resm_myexam", "creator,evalscore", myexam_QF.toArray());
for (DynamicObject userDy : userDys) { //todo:开始构建供应商对应人员评分
String username = userDy.getString("username"); HashMap<String, BigDecimal> userGrades = new HashMap<String, BigDecimal>();//人员成绩key为人员用户名value为人员分数
userGrades.put(username,BigDecimal.ZERO); if (resm_myexams.length > 0){
for (DynamicObject resm_myexam : resm_myexams) {
DynamicObject creator = resm_myexam.getDynamicObject("creator");//当前考察人
BigDecimal evalscore = resm_myexam.getBigDecimal("evalscore");//考察得分
String username = creator.getString("username");//人员用户名
userGrades.put(username,evalscore);
}
}else {
//我的考察还未下达时,先赋值0
for (DynamicObject userDy : userDys) {
String username = userDy.getString("username");
userGrades.put(username,BigDecimal.ZERO);
}
} }
supOfUserGrade.put(supName,userGrades);
} }
supOfUserGrade.put(supName,userGrades); //todo: 构建传参
} FormShowParameter formShowParameter = new FormShowParameter();
//todo: 构建传参 formShowParameter.setFormId("qeug_dynamicexampage");
FormShowParameter formShowParameter = new FormShowParameter(); formShowParameter.setCaption(projectName+"供应商评分汇总表");
formShowParameter.setFormId("qeug_dynamicexampage"); formShowParameter.setCustomParam("supOfUserGrade",supOfUserGrade);
formShowParameter.setCaption(projectName+"供应商评分汇总表"); formShowParameter.setCustomParam("userNames",userNames);
formShowParameter.setCustomParam("supOfUserGrade",supOfUserGrade); formShowParameter.getOpenStyle().setShowType(ShowType.Modal);
formShowParameter.setCustomParam("userNames",userNames);
formShowParameter.getOpenStyle().setShowType(ShowType.Modal);
// StyleCss inlineStyleCss = new StyleCss(); // StyleCss inlineStyleCss = new StyleCss();
// inlineStyleCss.setHeight("600"); // inlineStyleCss.setHeight("600");
// inlineStyleCss.setWidth("1000"); // inlineStyleCss.setWidth("1000");
// formShowParameter.getOpenStyle().setInlineStyleCss(inlineStyleCss); // formShowParameter.getOpenStyle().setInlineStyleCss(inlineStyleCss);
getView().showForm(formShowParameter); getView().showForm(formShowParameter);
}else {
this.getView().showTipNotification("对应考察计划数据异常,请联系管理员");
}
} }
} }
} }