/** * 根据body和card对比出卡片的变化信息,并存到变动表里, * * @param body * @param card * @return liubeibei */ @SuppressWarnings("unchecked") public void compareCardVsBody(LcCardtemp body, Cardinfo card) { Map<String, Object> bodyMap = null; Map<String, Object> cardMap = null; try { bodyMap = BeanUtils.describe(body); cardMap = BeanUtils.describe(card); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } Set<String> keySet = cardMap.keySet(); Iterator ite = keySet.iterator(); while (ite.hasNext()) { String property = (String) ite.next(); if ("id".equals(property) || "class".equals(property) || "changereason".equals(property)) { continue; } Object valueAfter = bodyMap.get(property); Object valueBefore = cardMap.get(property); if (valueAfter == null && valueBefore == null) { continue; } else if ("null".equals(valueAfter) && "null".equals(valueBefore)) { continue; } else if ("".equals(valueAfter) && "".equals(valueBefore)) { continue; } else if (valueAfter != null && valueAfter.equals(valueBefore)) { continue; } else if ((valueAfter == null && valueBefore != null) || (valueAfter != null && !valueAfter.equals(valueBefore))) { // 对比时间类型的数据 add by lantianbo boolean d = false; if ("ksdate".equals(property) || "zxrq".equals(property) || "lrrq".equals(property) || "qydate".equals(property)) { d = true; } if (d) { Object[] dateCom = this.compareDate(body, card, valueAfter, valueBefore, property); boolean s1 = Boolean.parseBoolean(String.valueOf(dateCom[0])); if (s1) { continue; } valueAfter = dateCom[1]; valueBefore = dateCom[2]; } else { if (checkEmpty(String.valueOf(valueAfter)) .equals(checkEmpty(String.valueOf(valueBefore)))) { continue; } } Recordhistory record = new Recordhistory(); record.setBiaoming("LC_CARDTEMP"); // 变动的表名 record.setZcId(String.valueOf(body.getId())); // 变动记录的ID,card的主键 record.setName(property); // 改变的列名 if (valueBefore == null) { // 改变前值 record.setBefore(null); } else { record.setBefore(valueBefore.toString()); } record.setAfter(valueAfter == null ? "" : valueAfter.toString()); // 改变后值 // 查询head对象,获得拟稿人,拟稿日期 CaShead shead = this.findCaSheadById(body.getKpxzid().toString()); if (shead != null) { record.setChangedate(shead.getNgrq()); // 变动的日期 record.setChangeperson(shead.getNgrmc()); // 变动记录人 record.setWfCode(shead.getWfconfigCode()); // 流程 record.setPkId(shead.getId().toString()); } record.setZhuangTai("0"); // 设置审批状态为0:未审批 if (valueAfter != null) { this.saveRecord(record); // 保存变动信息到recordhistory } } } }
public static void QuerySpState( PublicDao dao, PTTodoBS ptBs, WorkflowBS workflowBS, IERPCommonUCC erpCommonUCC, ICardQueryUCC cardQueryUCCImpl, String erpNotice) { try { String sql = "select t.fbyz ,t.erpcode ,t.eamcode from erp_cardcfsend t where t.sfcode is null"; List list = dao.queryForList(sql, new ArrayList()); if (list.size() > 0) { for (int i = 0; i < list.size(); i++) { Map erp = (Map) list.get(i); StringBuffer erpxml = new StringBuffer(); String billid = (String) erp.get("fbyz"); String billcode = (String) erp.get("erpcode"); String eamcode = (String) erp.get("eamcode"); erpxml.append(Comment_SplitSpd.CardReduceHead()); erpxml.append(Comment_SplitSpd.ufdQueryhead()); erpxml.append(Comment_SplitSpd.QuerybillHead(billid, billcode)); // 得到发送xml的头信息 erpxml.append(Comment_SplitSpd.geterpcode(billid, billcode, dao)); // 得到erpcode erpxml.append(Comment_SplitSpd.Querybillend()); erpxml.append(Comment_SplitSpd.esbend()); String input = new Comment().sender(erpxml); // 拼装xml后返回信息 CaShead pojo1 = (CaShead) dao.findSingleResult( "from CaShead t where t.id = ?", new Object[] { Long.parseLong(eamcode) }); // add by lantianbo 2010-12-01根据表单号,得到表单信息, // 插入erp_history表,备份发送记录 if (pojo1 != null) { new OA_Database() .insertClob( pojo1.getId().toString(), String.valueOf(pojo1.getId()), pojo1.getNgrmc(), pojo1.getBdlx() // TODO 这个需要确认 , String.valueOf(erpxml), String.valueOf(input), dao); } Comment_SplitSpd.Queryspstate( Comment.geterp(input, "<ufinterface", "</ufinterface>"), dao, ptBs, workflowBS, erpCommonUCC, cardQueryUCCImpl, erpNotice); // 返回信息操作主方法 } } // session.close(); } catch (Exception ex) { ex.printStackTrace(); } }