/** * 批量选择卡片减少 * * @return * @throws IOException */ public String chooseReduceBatch() 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++) { 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 ("1".equals(zc.getZlzt()) || "3".equals(zc.getCZczc()) || "4".equals(zc.getCZczc()) || "5".equals(zc.getCZczc())) { reduceCheck = reduceCheck + card.getId() + ","; } else { cardCommonUCCImpl.save(body); } } else { cardCommonUCCImpl.save(body); } } else { ZyZc zc = new ZyZc(); zc = cardCommonUCCImpl.findZyZcById(body.getZcid()); if (zc != null) { if ("1".equals(zc.getZczt()) || "3".equals(zc.getZczt()) || "4".equals(zc.getZczt()) || "5".equals(zc.getZczt())) { reduceCheck = reduceCheck + card.getId() + ","; } else { cardCommonUCCImpl.save(body); } } else { cardCommonUCCImpl.save(body); } } } if (!"".equals(reduceCheck)) { reduceCheck = "编号为" + reduceCheck + "的卡片无法减少或修改"; } response.setCharacterEncoding("UTF-8"); response.getWriter().write(reduceCheck + "=OK"); return null; }
/** * 对比时间格式的数据 * * @param body * @param htzl * @param valueAfter * @param valueBefore * @param property */ private Object[] compareDate( LcCardtemp body, Cardinfo head, Object valueAfter, Object valueBefore, String property) { Object[] s = new Object[3]; if ("ksdate".equals(property)) { if (body.getKsdate() != null) { valueAfter = DateUtils.formatDate(body.getKsdate()); } if (head.getKsdate() != null) { valueBefore = DateUtils.formatDate(head.getKsdate()); } } if ("zxrq".equals(property)) { if (body.getZxrq() != null) { valueAfter = DateUtils.formatDate(body.getZxrq()); } if (head.getZxrq() != null) { valueBefore = DateUtils.formatDate(head.getZxrq()); } } if ("lrrq".equals(property)) { if (body.getLrrq() != null) { valueAfter = DateUtils.formatDate(body.getLrrq()); } if (head.getLrrq() != null) { valueBefore = DateUtils.formatDate(head.getLrrq()); } } if ("qydate".equals(property)) { if (body.getQydate() != null) { valueAfter = "".equals(checkEmpty(body.getQydate())) ? "" : DateUtils.formatDate(DateUtils.parseDate(body.getQydate())); } if (head.getKsdate() != null) { valueBefore = "".equals(checkEmpty(body.getQydate())) ? "" : DateUtils.formatDate(DateUtils.parseDate(head.getQydate())); } } if (checkEmpty(String.valueOf(valueAfter)).equals(checkEmpty(String.valueOf(valueBefore)))) { s[0] = true; return s; } else { s[0] = false; s[1] = String.valueOf(valueAfter); s[2] = String.valueOf(valueBefore); return s; } }
/** * 批量减少操作 * * @return * @throws IOException */ public String operateReduceBatch() throws IOException { String dealmethod = request.getParameter("dealmethod"); String changereason = request.getParameter("changereason"); String bodyIds = request.getParameter("bodyIds"); String[] Ids = bodyIds.split(","); for (int i = 0; i < Ids.length; i++) { body = cardCommonUCCImpl.findLcCardtempById(Ids[i]); body.setChangereason(changereason); body.setDealmethod(dealmethod); cardCommonUCCImpl.update(body); } response.setCharacterEncoding("UTF-8"); response.getWriter().write("修改成功"); return null; }
/** * 删除多条新增卡片表体 * * @param LcCardtempIds */ public void delete(String[] LcCardtempIds) { LcCardtemp LcCardtemp = null; for (int i = 0; i < LcCardtempIds.length; i++) { if (StringUtils.isNotEmpty(LcCardtempIds[i])) { LcCardtemp = this.findLcCardtempById(LcCardtempIds[i]); // new LcCardtemp(); // LcCardtemp.setId(Long.parseLong(LcCardtempIds[i])); try { this.delete(LcCardtemp); String sql = "delete from Lc_Cardtemp t where t.cardcode is null and t.kpxzid = '" + LcCardtemp.getKpxzid() + "'"; this.publicDao.getJdbcTemplate().update(sql); } catch (Exception e) { e.printStackTrace(); } } } }
private boolean compareZcTypeByHeadId(List<LcCardtemp> list) { boolean is = false; long type1 = 0l; long type2 = 0l; if (list != null && list.size() > 0) { LcCardtemp body1 = null; LcCardtemp body2 = null; for (int i = 0; i < list.size(); i++) { body1 = list.get(i); type1 = body1.getParentid(); for (int j = 0; j < list.size(); j++) { body2 = list.get(j); type2 = body2.getParentid(); if (type1 != type2) { return is; } } } is = true; } return is; }
/** * 卡片变动批量操作 * * @param headId * @param cardIds */ public String chooseChangeBatch(String headId, String cardIds) { if (cardIds != null && cardIds.length() > 0) { if (cardIds.startsWith(",")) { cardIds = cardIds.substring(1); } String[] ids = cardIds.split(","); Cardinfo card = null; for (int i = 0; i < ids.length; i++) { card = this.findCardinfoByCardId(ids[i]); if ("03".equals(card.getState())) { return "退役卡片不能选择"; } if (card != null) { LcCardtemp body = this.card2Body(card); body.setKpxzid(Long.parseLong(headId)); body.setCardinfoid(String.valueOf(card.getId())); body.setId(null); this.save(body); } } } return "操作成功"; }
/** * 根据ids取得cardinfo信息,并保存到lccardtemp表中 * * @param ids */ public String saveCard4Merge(String[] ids, String headId) { String zcId = ""; String kplx = ""; boolean isAdded = false; // 已添加的数据 for (int i = 0; i < ids.length; i++) { String id = ids[i]; Cardinfo cardinfo = this.publicDao.findById(Cardinfo.class, Long.valueOf(id)); if ("03".equals(cardinfo.getState())) { return "退役的卡片不能选择"; } List<LcCardtemp> list = this.findLcCardtempsBySheadId(headId); if (list != null) { for (int m = 0; m < list.size(); m++) { LcCardtemp temp = list.get(m); if (temp.getCardcode().equals(cardinfo.getCardcode())) { isAdded = true; } } } if (!isAdded) { zcId = cardinfo.getZcid(); kplx = String.valueOf(cardinfo.getParentid()); for (int j = 0; j < ids.length; j++) { String id2 = ids[j]; Cardinfo cardinfo1 = this.publicDao.findById(Cardinfo.class, Long.valueOf(id2)); if (zcId != null && !zcId.equals(cardinfo1.getZcid())) { return "资产不相同"; } if (kplx != null && !kplx.equals(String.valueOf(cardinfo1.getParentid()))) { return "卡片不相同"; } } LcCardtemp lcCardtemp = new LcCardtemp(); lcCardtemp.copyProperties(cardinfo); lcCardtemp.setKpxzid(Long.parseLong(headId)); lcCardtemp.setCardinfoid(cardinfo.getId().toString()); this.publicDao.save(lcCardtemp); isAdded = false; } isAdded = false; } return ""; }
/** * 批量变动 * * @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); } } }
/** * /根据所选的卡片合并,ids为合并的卡片id数组,baseCardId为基础卡片,headId为表单id,ybyz,ljzj,jvalue,jevalue * * <p>拆分后新卡片 拆分前表体 CARDCODE 空 为cardinfo表的cardCode CARDINFOID 空 表体里为cardinfo的id BOXID 表体里为该表体的id * 表体里为新卡片表体的id ID YBYZ(原币原值) LJZJ(累计折旧)JVALUE (净值) JEVALUE(净额)CARDINFOID BOXID LRRQ 10056642 * 57816974.41 15287963.29 42529011.12 42529011.12 10056642 2010/11/21 这个是合并后的卡片 10056641 * 57269974.41 15108477.09 42161497.32 42161497.32 125362 10056642 下面3个合并前卡片 10056640 400000 * 113335.09 286664.91 286664.91 125337 10056642 10056639 147000 66151.11 80848.89 80848.89 124335 * 10056642 2010/3/24 * * @param ids 这个未用到 * @param baseCardId * @param headId */ public boolean mergeBody(String[] ids, String baseCardId, String headId) { // 先查出已合并的卡片,然后删除 List list1 = this.findLcCardtempsBySheadId(headId, "false"); if (list1 != null && list1.size() > 0) { for (int i = 0; i < list1.size(); i++) { LcCardtemp temp = new LcCardtemp(); temp = (LcCardtemp) list1.get(i); this.delete(temp); } } // 根据ids在Cardinfo表中查询出要合并的卡片 List<LcCardtemp> list = this.findLcCardtempsBySheadId(headId); boolean tongyileixingkapian = this.compareZcTypeByHeadId(list); if (tongyileixingkapian) { // 合并后的卡片 LcCardtemp newLcCardtemp = new LcCardtemp(); Double ybyz = new Double(0); Double jvalue = new Double(0); Double jevalue = new Double(0); Double ljzj = new Double(0); Double jzzb = new Double(0); String oldCode = null; // 把Cardinfo对象转化为LcCardtemp对象 for (int i = 0; i < list.size(); i++) { LcCardtemp body = list.get(i); if (String.valueOf(body.getId()).equals(baseCardId)) { try { BeanUtils.copyProperties(newLcCardtemp, body); } catch (IllegalAccessException e1) { e1.printStackTrace(); } catch (InvocationTargetException e1) { e1.printStackTrace(); } newLcCardtemp.setCardcode(null); newLcCardtemp.setOldcode(body.getCardcode()); // 设置录入日期为当前日期 Date date = new Date(); SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd"); String dateStr = sf.format(date); Date formatDate = null; try { formatDate = sf.parse(dateStr); } catch (ParseException e) { e.printStackTrace(); } newLcCardtemp.setLrrq(formatDate); // 设置卡片的增加方式为合并增加0113 newLcCardtemp.setAddtype("0113"); } else { // 设置卡片状态为退役 body.setState("03"); // 设置卡片的减少方式为0212合并减少 body.setChangeway("0212"); if (body.getCardcode() != null) { this.update(body); } } // 原币原值,累计折旧,净值,净额,信息合并前卡片进行累加 ybyz += body.getYbyz(); ljzj += body.getLjzj(); jvalue += body.getJvalue(); jevalue += body.getJevalue(); jzzb += body.getJzzb(); } newLcCardtemp.setYbyz(ybyz); newLcCardtemp.setLjzj(ljzj); newLcCardtemp.setJvalue(jvalue); newLcCardtemp.setJevalue(jevalue); newLcCardtemp.setJzzb(jzzb); newLcCardtemp.setState("02"); String newBodyId = this.saveBody(newLcCardtemp); // LcCardtemp newBody = this.findLcCardtempById(newBodyId); newLcCardtemp.setBoxid(newBodyId); newLcCardtemp.setCardinfoid(newBodyId); this.update(newLcCardtemp); // for(int i = 0;i<list.size();i++){ // LcCardtemp body = list.get(i); // body.setBoxid(newBodyId); // this.update(body); // } } return tongyileixingkapian; }
/** * 根据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 } } } }
/** * 把card的信息 复制到LcCardtemp里 * * @param card * @return liubeibei */ public LcCardtemp card2Body(Cardinfo cardinfo) { LcCardtemp cardTemp = new LcCardtemp(); cardTemp.copyProperties(cardinfo); return cardTemp; }
/** * 批量选择要减值的卡片 * * @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; }