定时任务自动评估
This commit is contained in:
parent
51dd32b5c3
commit
1b6d45c293
|
@ -0,0 +1,88 @@
|
||||||
|
package shkd.repc.task;
|
||||||
|
|
||||||
|
import kd.bos.context.RequestContext;
|
||||||
|
import kd.bos.dataentity.OperateOption;
|
||||||
|
import kd.bos.dataentity.entity.DynamicObject;
|
||||||
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||||
|
import kd.bos.entity.operate.OperateOptionConst;
|
||||||
|
import kd.bos.entity.operate.result.OperationResult;
|
||||||
|
import kd.bos.exception.KDException;
|
||||||
|
import kd.bos.form.IFormView;
|
||||||
|
import kd.bos.logging.Log;
|
||||||
|
import kd.bos.logging.LogFactory;
|
||||||
|
import kd.bos.orm.query.QCP;
|
||||||
|
import kd.bos.orm.query.QFilter;
|
||||||
|
import kd.bos.schedule.executor.AbstractTask;
|
||||||
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||||
|
import kd.bos.servicehelper.QueryServiceHelper;
|
||||||
|
import kd.bos.servicehelper.operation.OperationServiceHelper;
|
||||||
|
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||||
|
import kd.sdk.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class DobeAutoEvaluateTask extends AbstractTask implements Plugin {
|
||||||
|
|
||||||
|
private static Log log = LogFactory.getLog(DobeDWaccountTask.class);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自动评估超时的我的评估
|
||||||
|
* @param requestContext
|
||||||
|
* @param map
|
||||||
|
* @throws KDException
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
|
||||||
|
//todo:查询所有评估状态未完成,且已经超时的我的评估
|
||||||
|
QFilter eval_QF = new QFilter("billstatus", QCP.equals,"A");//提交评分状态为:未完成
|
||||||
|
// 德必集团-2024-三季度-定期评估任务【7】
|
||||||
|
// eval_QF.and("evaltask.name",QCP.equals,"德必集团-2024-三季度-定期评估任务【7】");
|
||||||
|
eval_QF.and("evalenddate",QCP.less_equals,new Date());//当前日期超过评估截止日期
|
||||||
|
|
||||||
|
|
||||||
|
DynamicObjectCollection queries = QueryServiceHelper.query("resm_myeval_new", "id", eval_QF.toArray());
|
||||||
|
for (DynamicObject query : queries) {
|
||||||
|
long evalId = query.getLong("id");//获取评估单主键
|
||||||
|
DynamicObject resm_myeval_new = BusinessDataServiceHelper.loadSingle(evalId, "resm_myeval_new");//加载评估单完整数据
|
||||||
|
String myevalname = resm_myeval_new.getDynamicObject("evaltask").getString("name");
|
||||||
|
DynamicObject evalscheme = resm_myeval_new.getDynamicObject("evalscheme");
|
||||||
|
DynamicObject resm_evalschemef7 = BusinessDataServiceHelper.loadSingle(evalscheme.getPkValue(), "resm_evalschemef7");
|
||||||
|
String scoremethod = resm_evalschemef7.getString("scoremethod");//计分方式
|
||||||
|
BigDecimal evalscore = new BigDecimal(80);//初始化评估得分
|
||||||
|
DynamicObjectCollection entry_stadardscore = resm_myeval_new.getDynamicObjectCollection("entry_stadardscore");//标准项
|
||||||
|
if ("weight".equals(scoremethod) || "share".equals(scoremethod)){//当评分制为权重制或者份额制时,评分为100分的80%,即固定为80分
|
||||||
|
for (DynamicObject dy : entry_stadardscore) {
|
||||||
|
dy.set("std_score", new BigDecimal(80));
|
||||||
|
}
|
||||||
|
}else if ("standard".equals(scoremethod)){//当评分制为标准分时,评分为标准分的80%
|
||||||
|
for (DynamicObject dy : entry_stadardscore) {
|
||||||
|
BigDecimal std_standardscore = dy.getBigDecimal("std_standardscore");//获取标准分
|
||||||
|
std_standardscore = std_standardscore.multiply(new BigDecimal(0.8));
|
||||||
|
dy.set("std_inputscore",std_standardscore);
|
||||||
|
dy.set("std_score",std_standardscore);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resm_myeval_new.set("evalscore",evalscore);
|
||||||
|
SaveServiceHelper.save(new DynamicObject[]{resm_myeval_new});
|
||||||
|
OperateOption option= OperateOption.create();
|
||||||
|
//已经验权,执行操作服务时,不需要再次验权
|
||||||
|
option.setVariableValue(OperateOptionConst.ISHASRIGHT, String.valueOf(true));
|
||||||
|
// 跳过系统默认的特殊数据权限
|
||||||
|
option.setVariableValue(OperateOptionConst.SKIPCHECKPERMISSION,String.valueOf(true));
|
||||||
|
OperationResult operationResult = OperationServiceHelper.executeOperate("submit", "resm_myeval_new", new DynamicObject[]{resm_myeval_new}, option);
|
||||||
|
|
||||||
|
boolean success = operationResult.isSuccess();
|
||||||
|
if (!success) {
|
||||||
|
String message = operationResult.getMessage();
|
||||||
|
String allErrorInfo = operationResult.getValidateResult().getValidateErrors().get(0).getAllErrorInfo().get(0).getMessage();
|
||||||
|
log.info("评估任务:" + myevalname +message +"-"+ allErrorInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue