Esempio n. 1
0
 /**
  * 批量变动
  *
  * @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);
     }
   }
 }
Esempio n. 2
0
 /**
  * 根据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
       }
     }
   }
 }