关于NC开发中修改数据的问题
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了关于NC开发中修改数据的问题相关的知识,希望对你有一定的参考价值。
NC开发中,比如表单中有一条数据需要修改,第一次修改数据成功,紧接着对这条数据再次修改的时候就提示“该单据已被人修改,请刷新页面,或重新做业务”这个异常。我想是不是属于脏数据,如果是的,请问如何解决!拜谢
我曾经遇到过这个错误,自己找了很久的原因,后来想到nc.bs.pub.pflock.VOConsistenceCheck.checkConsistence 这个方法中比较的是ts字段,应该是操作时为避免并发所以对记录的时间戳进行比较,简单的说就是把界面上要改的记录与原记录的时间戳对比,如果不同,则系统会认为这条记录已经被别人修改过了,所以就会报这种错误, 我的解决方法是:在单据模板中,去掉ts字段,我现在做的单据基本上都是这样的,到现在也没出什么问题,同时也是可以避免并发的 参考技术A 你看看单据模板上是否放了ts字段,保存的时候会从模板上取ts字段,如果没有就会报错NC63 后端通过单据执行动作 修改单据详细解读
nc二次开发作为国内软件的短板 在此补充 给其他正在挠头的小伙伴
此次单据修改开发入坑一周 终于出坑
单据执行动作
Object processAction_update = iIplatFormEntry_a.processAction("WRITE", ic_transOutHVO.getVtrantypecode(), null, transOutVO_a,null, null);
一般修改的时候需要把vo的状态 status 设置为1
注意 单据类型
public String out(String operation,String orderform)
///4Y
JSONObject resultJson=new JSONObject();
JSONObject paramJson = JSON.parseObject(orderform);
String vbillcode = paramJson.getString("vbillcode");//出库单好
try
BaseDAO bd = new BaseDAO();
nc.vo.ic.m4y.entity.TransOutHeadVO ic_transOutHVO = new nc.vo.ic.m4y.entity.TransOutHeadVO();
//
ic_transOutHVO = (nc.vo.ic.m4y.entity.TransOutHeadVO) bd.executeQuery("select * from ic_transout_h where dr=0 and vbillcode ='"+vbillcode+"'", new BeanProcessor(nc.vo.ic.m4y.entity.TransOutHeadVO.class));
if (ic_transOutHVO != null)
JSONArray bjsonarr = new JSONArray();
String ic_transout_pk = ic_transOutHVO.getAttributeValue("cgeneralhid").toString();//主键
//SuperVO[] ic_transOutBVO = HYPubBO_Client.queryByCondition(nc.vo.ic.m4y.entity.TransOutBodyVO.class, " cgeneralhid = '"+ic_transout_pk+"'");
List<nc.vo.ic.m4y.entity.TransOutBodyVO> ic_transOutBList = (List<nc.vo.ic.m4y.entity.TransOutBodyVO>) bd.executeQuery("select * from ic_transout_b where dr=0 and cgeneralhid ='"+ic_transout_pk+"'", new BeanListProcessor(nc.vo.ic.m4y.entity.TransOutBodyVO.class));
//给交换平台数据准备
List<nc.vo.ic.m4y.entity.TransOutBodyVO> ic_transOutBList_new = new ArrayList<nc.vo.ic.m4y.entity.TransOutBodyVO>();
JSONArray body = (JSONArray) paramJson.get("body");
for (int j = 0;j<ic_transOutBList.size();j++)
nc.vo.ic.m4y.entity.TransOutBodyVO transOutBodyVO = ic_transOutBList.get(j);
for (int i = 0;i<body.size();i++)
JSONObject tmpb = body.getJSONObject(i);
String crowno = tmpb.getString("crowno") ==null ?"":tmpb.getString("crowno"); // 行号
if(transOutBodyVO.getCrowno().equals(crowno))
String nnum = tmpb.getString("nnum") ==null ?"":tmpb.getString("nnum"); //实发主数量
nc.vo.ic.m4y.entity.TransOutBodyVO transOut_new = new nc.vo.ic.m4y.entity.TransOutBodyVO();
transOut_new = transOutBodyVO;
if(StringUtils.isNotBlank(nnum))
UFDouble d_nnum = new UFDouble(Double.parseDouble(nnum));
transOut_new.setNnum(d_nnum);
transOut_new.setNassistnum(d_nnum);
transOut_new.setStatus(1);
transOut_new.setDbizdate(new UFDate());
//transOut_new.setTs(new UFDateTime());
ic_transOutBList_new.add(transOut_new);
try
IplatFormEntry iIplatFormEntry_a = (IplatFormEntry) NCLocator.getInstance().lookup(IplatFormEntry.class.getName());
InvocationInfoProxy.getInstance().setGroupId("00013910000000000N4S"); //这个字段很重要
InvocationInfoProxy.getInstance().setUserId(ic_transOutHVO.getCreator());//用户
nc.vo.ic.m4y.entity.TransOutBodyVO[] outsvo_a = new nc.vo.ic.m4y.entity.TransOutBodyVO[ic_transOutBList.size()];
AggregatedValueObject transOutVO_a = new nc.vo.ic.m4y.entity.TransOutVO();
ic_transOutHVO.setStatus(1);
transOutVO_a.setParentVO(ic_transOutHVO);
transOutVO_a.setChildrenVO(ic_transOutBList_new.toArray(outsvo_a));
//调拨出库单 执行动作 ,单据类型 , null ,billvo,null, 环境 , WRITE PUSHOUTSAVE 推式保存(实收) 4Y-Cxx-002 vtrantypecode
Object processAction_update = iIplatFormEntry_a.processAction("WRITE", ic_transOutHVO.getVtrantypecode(), null, transOutVO_a,null, null);
System.out.println(processAction_update);
catch (Exception e1)
e1.printStackTrace();
resultJson.put("$successful", "N");
resultJson.put("sendresult", e1.getMessage());
return resultJson.toString();
//开始签字
nc.vo.ic.m4y.entity.TransOutBodyVO[] insvo = new nc.vo.ic.m4y.entity.TransOutBodyVO[ic_transOutBList.size()];
List<nc.vo.ic.m4y.entity.TransOutBodyVO> ic_transInBList2 = (List<nc.vo.ic.m4y.entity.TransOutBodyVO>) bd.executeQuery("select * from ic_transout_b where dr=0 and cgeneralhid ='"+ic_transout_pk+"'", new BeanListProcessor(nc.vo.ic.m4y.entity.TransOutBodyVO.class));
IplatFormEntry iIplatFormEntry = (IplatFormEntry) NCLocator.getInstance().lookup(IplatFormEntry.class.getName());
//这是集团ID 一般每个表都有 随便找 pk_group 字段
InvocationInfoProxy.getInstance().setGroupId("00013910000000000N4S"); //这个字段很重要
AggregatedValueObject transOutVO= new nc.vo.ic.m4y.entity.TransOutVO();
transOutVO.setParentVO(ic_transOutHVO);
transOutVO.setChildrenVO(ic_transInBList2.toArray(insvo));
HashMap map = new HashMap();
map.put("notechecked", "notechecked");
//签字动作 ,签字单据类型 , null ,billvo,null, 环境 ,
Object processAction = iIplatFormEntry.processAction("SIGN", "4Y", null, transOutVO,null, map);
//head
resultJson.put("vbillcode",vbillcode);
//boyd
List<nc.vo.ic.m4y.entity.TransOutBodyVO> ic_transinBList = (List<nc.vo.ic.m4y.entity.TransOutBodyVO>) bd.executeQuery("select * from ic_transout_b where dr=0 and cgeneralhid ='"+ic_transout_pk+"'", new BeanListProcessor(nc.vo.ic.m4y.entity.TransOutBodyVO.class));
for (int i=0;i < ic_transinBList.size();i++)
String crowno = (String) ic_transinBList.get(i).getAttributeValue("crowno") == null?"": ic_transinBList.get(i).getAttributeValue("crowno").toString() ;//行号
//应收数量
String nshouldassistnum = ic_transinBList.get(i).getAttributeValue("nshouldassistnum") == null?"": String.valueOf((UFDouble) ic_transinBList.get(i).getAttributeValue("nshouldassistnum"));
//实收数量
String nassistnum = ic_transinBList.get(i).getAttributeValue("nassistnum") == null?"": String.valueOf((UFDouble) ic_transinBList.get(i).getAttributeValue("nassistnum"));
//body
JSONObject bjson = new JSONObject();
bjson.put("crowno",crowno);//行号
bjson.put("nshouldassistnum",nshouldassistnum);//应收数量
bjson.put("nassistnum",nassistnum);//实收数量
bjsonarr.add(bjson);
if(null != ic_transinBList && ic_transinBList.size() > 0 )
resultJson.put("$successful", "Y");
resultJson.put("sendresult", bjsonarr);
else
resultJson.put("$successful", "N");
resultJson.put("sendresult", "无调拨出库单");
祝你好运
以上是关于关于NC开发中修改数据的问题的主要内容,如果未能解决你的问题,请参考以下文章