SaveServiceHelper的.save和.saveOperate原创
金蝶云社区-生态
生态
9人赞赏了该文章 8,781次浏览 未经作者许可,禁止转载编辑于2021年02月09日 10:32:18

解答:

  数据保存过程遇到的一些问题,如(1)数据保存成功,列表无数据,(2)代码调用saveOperate保存不成功(校验不通过检查)


1、SaveServiceHelper.save的调用过程

插件代码

String entityName = "kdec_pur_apply";
   DynamicObject obj = BusinessDataServiceHelper.newDynamicObject(entityName);
   CodeRuleInfo codeRule = CodeRuleServiceHelper.getCodeRule(obj.getDataEntityType().getName(), obj, null);
   String number = CodeRuleServiceHelper.getNumber(codeRule, obj);
   obj.set("billno", number);
   obj.set("kdec_billnofield", number);
   obj.set("billstatus", "A");
   obj.set("creator", RequestContext.get().getUserId());
   obj.set("kdec_applyorg", RequestContext.get().getOrgId());
   obj.set("kdec_textfield1", "可见1");
   DynamicObjectCollection col = obj.getDynamicObjectCollection("kdec_entryentity");
   DynamicObjectType type = col.getDynamicObjectType();
   DynamicObject item = new DynamicObject(type);
   String materPk = "931963022627307520";
   item.set("kdec_materielfield", materPk);
   item.set("kdec_pricefield", new BigDecimal("23.7"));
   col.add(item);
   obj.set("kdec_entryentity", col);
   if (obj != null) {
//    Object [] o = SaveServiceHelper.save(new DynamicObject[] {obj});
//    if(o.length>0) {
//    }
    OperationResult  result = SaveServiceHelper.saveOperate(entityName, new DynamicObject[] {obj},OperateOption.create());
    if(result.isSuccess()&&result.getAllErrorInfo()==null) {
    }
   }

(1)SaveServiceHelper.class

image.png

(2)BusinessDataWriter.class

image.png

(3)DataManagerImplement.class

image.png

image.png

image.png

(4)OrmDBTasks.class

image.png

image.png

(5)BatchInsertTask.class

image.png

(6)DBImpl.class查看传的参数和sql

image.png

image.png

在保存数据出现问题时,可以在这个类打断点,检查sql和参数是否正确等

2、SaveServiceHelper.saveOperate

(1)SaveServiceHelper.class

image.png

接下来的步骤参考https://club.kdcloud.com/article/136924752286676736 



图标赞 9
9人点赞
还没有人点赞,快来当第一个点赞的人吧!
图标打赏
0人打赏
还没有人打赏,快来当第一个打赏的人吧!