Exemplo n.º 1
0
  /**
   * 根据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 "";
  }
Exemplo n.º 2
0
  /**
   * /根据所选的卡片合并,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;
  }