1. servlet后端传输数据接收方法
String reqstr = GetRequestJsonUtils.getRequestJsonString(request);
2. servlet AJAX前端传输数据接收方法
String reqstr = request.getParameter(参数);
3. 数据处理方法
//一条数据
JSONObject www = JSONObject.fromObject(reqstr);//转JSON 数据类型 为{}
Map<String, String> map = (Map) www;//转化成MAP类型数据解析
//多条数据
JSONArray corsParam = JSONArray.fromObject(reqstr);//转数组 数 据类型为[]
for(int i=0;i<corsParam.size();i++){
JSONObject jsonObject = JSONObject.fromObject(corsParam.get(i));//转JSON
Map<String, String> map = (Map) jsonObject;//转化成MAP类型数据解析
}
4. 查询字段的方法
IUAPQueryBS bs = NCLocator.getInstance().lookup(IUAPQueryBS.class);
String sql = "select pk_corp from bd_corp where 1=1 and unitname = '"+参数+"'";//SQL语句
List<Map> lms8 = (List<Map>) bs.executeQuery(sql.toString(), new MapListProcessor());//将SQL语句放到方法中得到List集合结果
String pk_corp = "";
if (lms8 != null && lms8.size() > 0) {
pk_corp = lms8.get(0) == null ? "" : lms8.get(0).get("pk_corp").toString();//得到对应参数值
}
//
IUifService ius = NCLocator.getInstance().lookup(IUifService.class);
String orgcode = (String) ius.findColValue("表名", "字段名"," 已知字段名 = '"+已知字段名值+"' ");
5. 保存方法
//走正规的保存流程
IplatFormEntry ife = NCLocator.getInstance().lookup(IplatFormEntry.class);//引用保存方法
UFDateTime now = new UFDateTime();//当前时间
ife.processAction("SAVE", "D1", now.toString(), null, vo, null, null); 单据动作 单据类型 当前时间 聚合VO
//直接对应数据库的保存方式
IArapBillPrivate ii = NCLocator.getInstance().lookup(IArapBillPrivate.class);
ii.saveDj(vo);
//批量保存
IArapBillPublic service = NCLocator.getInstance().lookup(IArapBillPublic.class);
service.saveArapBills(newdjzbvos);
//数组VO
service.saveArapBill(vo);
//聚合VO
6. 审批方法
//走正规的审批流程
IplatFormEntry ife = NCLocator.getInstance().lookup(IplatFormEntry.class);//引用保存方法
UFDateTime now = new UFDateTime();//当前时间
ife.processAction("APPROVE", "D1", now.toString(), null, vo, null, null);单据动作 单据类型 当前时间 聚合VO
//批量审批
IArapBillPublic service = NCLocator.getInstance().lookup(IArapBillPublic.class);
nc.vo.ep.dj.DJZBVO[] savevos=service.saveArapBills(newdjzbvos);
//数组VO
for(nc.vo.ep.dj.DJZBVO savevo:savevos)
{
ResMessage rmessage=service.auditArapBill(savevo);
//判断rmesssage返回值是什么样的
//审批
ResMessage rmessage =service.auditOneArapBill(newvo);
}
//反审 多一个审核人传参
DJZBVO aggvo = new DJZBVO();
aggvo.setParentVO(hvo);
aggvo.setChildrenVO(bvos.toArray(new DJZBItemVO[bvos.size()]));
DJZBVO[] arrAggvo = new DJZBVO[1];
arrAggvo[0] = aggvo;
Logger.error("UNAPPROVE拼聚合VO完成,下面调用动作");
ArrayList[] arrStr = new ArrayList[1];
ArrayList list = new ArrayList();
ArrayList list2 = new ArrayList();
list2.add(hvo.getShr());
list.add(list2);
arrStr[0] = list;
ife.processBatch("UNAPPROVE", "F1", new UFDate().toString(), null, arrAggvo, arrStr, null);
//查询VO进行审批
//登录
InvocationInfoProxy.getInstance().setGroupId("0001A110000000000FGV");
InvocationInfoProxy.getInstance().setUserCode("limeng");
InvocationInfoProxy.getInstance().setUserDataSource("design");
ISecurityTokenCallback sc = (ISecurityTokenCallback) NCLocator.getInstance().lookup(ISecurityTokenCallback.class);
sc.token("limeng".getBytes(), "li123456".getBytes());
//查询主子VO
//主体VO
SaleOrderHVO hvo1 = (SaleOrderHVO) iuapq.executeQuery("select * from so_saleorder where csaleorderid='"+csaleorderid1+"'", new BeanProcessor(SaleOrderHVO.class));
//表体VO
ArrayList<SaleOrderBVO> bvos2 = (ArrayList<SaleOrderBVO>)iuapq.executeQuery("select * from so_saleorder_b where csaleorderbid='"+csaleorderbid1+"'", new BeanListProcessor(SaleOrderBVO.class));
//list转[]
SaleOrderBVO[] bvoss = new SaleOrderBVO[bvos2.size()];
for(int arr=0; arr<bvos2.size(); arr++){
bvoss[arr]=bvos2.get(arr);
}
SaleOrderVO order = new SaleOrderVO();
order.setParentVO(hvo1);
order.setChildrenVO(bvoss);
//审批
IPFBusiAction ipf = (IPFBusiAction)NCLocator.getInstance().lookup(IPFBusiAction.class);
ipf.processAction("APPROVE", "46", null,order, null, null);
7. 聚合VO的生成
DJZBVO vo=new DJZBVO();//聚合VO
DJZBHeaderVO hvo=new DJZBHeaderVO();//表头VO
DJZBItemVO bvo=new DJZBItemVO();//表体VO
DJZBItemVO[] bvos = new DJZBItemVO[1];//表体VO数组
vo.setParentVO(hvo);
vo.setChildVO(bvo);
bvos[0] = bvo;
*vo.setChildrenVO(bvos);
*vo.setChildrenVO(bvos.toArray(new DJZBItemVO[bvos.size()]));
8. 获取表头表体VO
PlanpdpHVO hvo = (PlanpdpHVO)aggvo.getParent(); //表头VO;
CircularlyAccessibleValueObject[] bvos = aggvo.getAllChildrenVO(); //表体VO;
9. 修改方法
PlanpdpHVO hvo = (PlanpdpHVO)aggvo.getParent(); //表头VO;
hvo.setAttributeValue("vdef16",new UFDate(System.currentTimeMillis()) );
hvo.setAttributeValue("dr",0 );
HYPubBO bo = new HYPubBO();
bo.update(hvo);
10. 通过SQL语句查询出VO
IUAPQueryBS iuapq = NCLocator.getInstance().lookup(IUAPQueryBS.class);
//主体VO
DJZBHeaderVO hvo = (DJZBHeaderVO) iuapq.executeQuery("select * from ARAP_djzb where vouchid = '"+primary+"'", new BeanProcessor(DJZBHeaderVO.class));
//表体VO
ArrayList<DJZBItemVO> bvos = (ArrayList<DJZBItemVO>) iuapq.executeQuery("select * from arap_djfb where vouchid = '"+primary+"'", new BeanListProcessor(DJZBItemVO.class));
11. 服务端doPost请求代码
String flag = HttpUtil.getInstance().doPost("http://172.20.249.46:9083/service/YtnsarapSync", json.toString());
12. 代码弹窗报错
ExceptionUtils.wrappBusinessException(result);
13. 设置链接的数据源
InvocationInfoProxy.getInstance().setUserDataSource("ytg");
14.直接执行update语句
private static BaseDAO bd = null;
private static BaseDAO getBasedao(){
if(bd == null){
bd = new BaseDAO();
}
return bd;
}
getBasedao().executeUpdate("UPDATE fhjy_listmaintainb SET kpsqhx ='N' WHERE nvl(dr,0)=0 and ")
15.SQL语句中添加 in的语句
import nc.ui.bd.ref.RefPubUtil;
RefPubUtil.getInSubSql("Pk_sample",codeList.toArray(new String[0]))+ " and nvl(dr,0) = 0 ");
16.查询一个值(两个值)的方法
import nc.jdbc.framework.processor.ColumnProcessor;
dept = getString(iq.executeQuery(sql, new ColumnProcessor()),null);
ArrayList<TaskVO> result = (ArrayList<TaskVO>) iq.executeQuery(sql, new BeanListProcessor(TaskVO.class));
17.查询多个值的方法
import nc.jdbc.framework.processor.ArrayListProcessor;
public Object[] queryMateiralMes(String pk_material) throws BusinessException {
String sql = "select a.pk_material,a.pk_source,a.pk_measdoc, b.pk_taxcode,c.taxrate from bd_material a,bd_taxcode b ,bd_taxrate c where a.pk_mattaxes = b.mattaxes and b.pk_taxcode = c.pk_taxcode and a.pk_material='"+pk_material+ "' and a.latest='Y' and a.enablestate=2 and nvl(a.dr,0)=0 and nvl(b.dr,0)=0 and nvl(c.dr,0)=0";
try {
ArrayList list = (ArrayList) iq.executeQuery(sql, new ArrayListProcessor());
if (list != null && list.size() > 0) {
Object[] obj = (Object[]) list.get(0);
return obj;
}else{
throw new BusinessException("未找到"+ pk_material +"对应的物料信息!");
}
} catch (DAOException e) {
throw new BusinessException("查找物料信息出错!"+e.getMessage());
}
}
18.流程平台动作处理接口(实现新增,删除,签字,审批,弃审)
//流程平台动作处理 服务接口
IPFBusiAction ifbaction = null;
private IPFBusiAction getIPFBsiAction(){
if(ifbaction == null){
ifbaction = NCLocator.getInstance().lookup(IPFBusiAction.class);
}
return ifbaction;
}
//destBill是aggvo
SapplyBillVO[] obj= (SapplyBillVO[]) getIPFBsiAction().processAction("WRITE", "4455", null, destBill, null, null);
19.判空代码
public static String getString(Object value, String str) {
if (value == null || value.toString().trim().length() == 0) {
return str;
}
return value.toString().trim();
}
20.StringUtils 判断字符串是否为空
StringUtils.isNotEmpty(materialVOs[0].getPk_fac());
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/111711.html