/** * 批量变动 * * @return */ public void operateChanageBatch( String changeway, String changereason, String changeValue, String bodyIds, String headId, String isProportion) { if (bodyIds != null && bodyIds.length() > 0) { if (bodyIds.startsWith(",")) { bodyIds = bodyIds.substring(1); } String ids[] = bodyIds.split(","); this.deleteRecord(ids); for (int i = 0; i < ids.length; i++) { LcCardtemp body = this.findLcCardtempById(ids[i]); String cardId = body.getCardinfoid(); Cardinfo card = this.findCardinfoByCardId(cardId); Individualtree tree = this.getIndividualtreeById(changeway); String nodevalue = ""; if (tree != null) { nodevalue = tree.getNodevalue(); } Recordhistory record = new Recordhistory(); if ("1".equals(nodevalue.trim())) { // 原币原值增加 if ("true".equals(isProportion)) { double d = card.getYbyz() * Double.valueOf(changeValue) / 100.0 + card.getYbyz(); body.setYbyz(d); } else { body.setYbyz(card.getYbyz() + Double.parseDouble(changeValue)); } body.setJvalue(body.getYbyz() - card.getLjzj()); body.setJevalue(body.getYbyz() - card.getLjzj()); record.setName("ybyz"); record.setBefore(String.valueOf(card.getYbyz())); } else if ("2".equals(nodevalue.trim())) { // 原币原值减少 if ("true".equals(isProportion)) { double d = card.getYbyz() - card.getYbyz() * Double.valueOf(changeValue) / 100.0; body.setYbyz(d); } else { body.setYbyz(card.getYbyz() - Double.parseDouble(changeValue)); } body.setJvalue(body.getYbyz() - card.getLjzj()); body.setJevalue(body.getYbyz() - card.getLjzj()); record.setName("ybyz"); record.setBefore(String.valueOf(card.getYbyz())); } else if ("3".equals(nodevalue.trim())) { // 管理部门 body.setGlbm(changeValue); record.setName("glbm"); record.setBefore(String.valueOf(card.getGlbm())); } else if ("4".equals(nodevalue.trim())) { // 使用部门 body.setUsepartment(changeValue); record.setName("usepartment"); record.setBefore(String.valueOf(card.getUsepartment())); } else if ("5".equals(nodevalue.trim())) { // 使用状况 body.setUsestatus(changeValue); record.setName("usestatus"); record.setBefore(String.valueOf(card.getUsestatus())); } else if ("6".equals(nodevalue.trim())) { // 折旧类型 body.setZjtype(changeValue); record.setName("zjtype"); record.setBefore(String.valueOf(card.getZjtype())); } else if ("7".equals(nodevalue.trim())) { // 使用月限 Long yueTotal = Long.parseLong(changeValue); Long nian = yueTotal / 12l; Long yue = yueTotal % 12l; body.setSynx(nian); body.setSyyx(yue); record.setName("syyx"); record.setBefore(String.valueOf(card.getSyyx() + card.getSynx() * 12)); } else if ("9".equals(nodevalue.trim())) { // 净残值 double bianhua = Double.parseDouble(changeValue); body.setJcz(bianhua); body.setJczl(bianhua / card.getYbyz() * 100); // 净残值率 record.setName("jcz"); record.setBefore(String.valueOf(card.getJcz())); } else if ("10".equals(nodevalue.trim())) { // 累计折旧 body.setLjzj(Double.parseDouble(changeValue)); body.setJvalue(card.getYbyz() - Double.parseDouble(changeValue)); body.setJevalue(card.getYbyz() - Double.parseDouble(changeValue)); record.setName("ljzj"); record.setBefore(String.valueOf(card.getLjzj())); } else if ("11".equals(nodevalue.trim())) { // 卡片类别, body.setTypecode(changeValue); body.setChildid(changeValue); record.setName("typecode"); record.setBefore(String.valueOf(card.getTypecode())); } else if ("12".equals(nodevalue.trim())) { // 增加方式 body.setAddtype(changeValue); record.setName("addtype"); record.setBefore(String.valueOf(card.getAddtype())); } else if ("13".equals(nodevalue.trim())) { // 折旧承担部门 body.setZjcdbm(changeValue); record.setName("zjcdbm"); record.setBefore(String.valueOf(card.getZjcdbm())); } else if ("14".equals(nodevalue.trim())) { // 使用人 body.setUsername(changeValue); record.setName("username"); record.setBefore(String.valueOf(card.getUsername())); } body.setChangeway(nodevalue); body.setChangereason(changereason); this.update(body); record.setPkId(headId.toString()); record.setChangetype("卡片变动"); record.setZcType("card"); record.setChangeinfoid(cardId); record.setAfter(changeValue); record.setZcId(String.valueOf(body.getId())); record.setChangedate(new Date()); IUser user = UserThreadLocal.get(); record.setChangeperson(user.getUsername()); record.setChangepersonId(user.getUserTidChar()); record.setChangeinfoid(String.valueOf(card.getId())); // 流程 CaShead head = this.findCaSheadById(headId); record.setWfCode(head.getWfconfigCode()); // 设置审批状态为0:未审批 record.setZhuangTai("0"); record.setBiaoming("lccardtemp"); this.saveRecord(record); } } }
/** * 批量选择要减值的卡片 * * @return * @throws IOException */ public String chooseDevalueBatch() throws IOException { String reduceCheck = ""; String cardIds = request.getParameter("cardIds"); String headId = request.getParameter("headId"); if (cardIds.startsWith(",")) { cardIds = cardIds.substring(1); } String[] Ids = cardIds.split(","); for (int i = 0; i < Ids.length; i++) { String bodyId = ""; card = cardCommonUCCImpl.findCardinfoByCardId(Ids[i]); if ("03".equals(card.getState())) { response.setCharacterEncoding("UTF-8"); response.getWriter().write("退役卡片不能选择"); return null; } body = cardCommonUCCImpl.card2Body(card); body.setKpxzid(Long.parseLong(headId)); body.setCardinfoid(String.valueOf(card.getId())); if ("0".equals(body.getSfzy().trim())) { JyzcXx zc = new JyzcXx(); zc = cardCommonUCCImpl.findJyzcXxByZcId(body.getZcid()); if (zc != null) { if ("3".equals(zc.getCZczc()) || "4".equals(zc.getCZczc()) || "5".equals(zc.getCZczc())) { reduceCheck = reduceCheck + body.getCardinfoid() + ","; } else { bodyId = cardCommonUCCImpl.saveBody(body).toString(); } } else { bodyId = cardCommonUCCImpl.saveBody(body).toString(); } if (!"".equals(bodyId)) { head = cardCommonUCCImpl.findCaSheadById(headId); record = new Recordhistory(); record.setZcId(bodyId); record.setPkId(body.getKpxzid().toString()); record.setBefore(String.valueOf(body.getJzzb() - body.getBcjt())); record.setAfter(body.getJzzb().toString()); record.setChangetype("卡片减值"); record.setZcType("card"); record.setName("减值准备"); record.setChangeinfoid(body.getCardinfoid()); record.setChangestate("01"); record.setWfCode(head.getWfconfigCode()); // 流程 record.setChangedate(head.getNgrq()); cardCommonUCCImpl.saveRecord(record); } } else { reduceCheck = "自用资产卡片不能减值!"; response.setCharacterEncoding("UTF-8"); response.getWriter().write(reduceCheck); return null; } } if (!"".equals(reduceCheck)) { reduceCheck = "编号为" + reduceCheck + "的卡片无法减值"; response.setCharacterEncoding("UTF-8"); response.getWriter().write(reduceCheck); return null; } response.setCharacterEncoding("UTF-8"); response.getWriter().write(reduceCheck + "保存成功"); return null; }
/** * 根据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(); } }