Example #1
0
  public UFDouble getThreeParameters(String ccustmanid, String corp) throws DAOException {
    String sql1 =
        " select sum(f.dfybje) from arap_djzb z join arap_djfb f on z.vouchid = f.vouchid "
            + " where z.djlxbm in ('D1','2348') and isnull(z.dr, 0) = 0 and isnull(f.dr, 0) = 0 "
            + " and f.jsfsbm ='25'  and z.dwbm='"
            + corp
            + "' and z.zgyf=0 and f.hbbm= '"
            + ccustmanid
            + "' ";
    UFDouble d1 =
        PuPubVO.getUFDouble_NullAsZero(
            getBaseDao().executeQuery(sql1, HgBsPubTool.COLUMNPROCESSOR));

    String sql2 =
        " select sum(z.bbje) from arap_djzb z join arap_djfb f on z.vouchid = f.vouchid "
            + " where z.djlxbm in ('D3','2346') and isnull(z.dr, 0) = 0 and isnull(f.dr, 0) = 0 "
            + " and z.dwbm='"
            + corp
            + "' and z.prepay = 'Y' and f.hbbm= '"
            + ccustmanid
            + "' ";
    UFDouble d2 =
        PuPubVO.getUFDouble_NullAsZero(
            getBaseDao().executeQuery(sql2, HgBsPubTool.COLUMNPROCESSOR));

    UFDouble d3 = UFDouble.ZERO_DBL;

    if (d2.sub(d1).compareTo(d3) > 0) {
      d3 = d2.sub(d1);
    }
    return d3;
  }
Example #2
0
  // 维护持票单位内部账户余额
  private int doHoldUnitAccont(PfParameterVO vo) throws BusinessException {
    AggregatedValueObject billvo = vo.m_preValueVo;
    ReckonVO reckvo = (ReckonVO) billvo.getParentVO();
    String accont = reckvo.getInacc();
    UFDouble reckmoney = reckvo.getReckonmoneysum();
    BaseDAO basebo = new BaseDAO();
    String sql = null;
    if (reckmoney.compareTo(new UFDouble(0)) > 0) {
      sql =
          "update bd_accid set currmny = currmny + "
              + reckmoney
              + " where pk_accid = '"
              + accont
              + "'";
    } else if (reckmoney.compareTo(new UFDouble(0)) < 0) {
      sql =
          "update bd_accid set currmny = currmny + "
              + reckmoney
              + " where pk_accid = '"
              + accont
              + "' and currmny >= "
              + reckmoney.abs();
    }
    int ret = 0;

    if (sql != null) {
      ret = basebo.executeUpdate(sql);
    }
    return ret;
  }
Example #3
0
  /**
   * 合并票据金额 moneytype 0 原币 1 辅币 2 本币
   *
   * @param items
   * @return
   */
  private static Map<String, UFDouble> sumMoney(
      SettlementBodyVO[] items, String djdl, int moneytype) throws BusinessException {
    Map<String, UFDouble> map = new HashMap<String, UFDouble>();
    Set<String> billnoSet = new HashSet<String>();
    String billno = null;
    UFDouble money = null;

    for (int i = 0; i < items.length; i++) {

      if (items[i].getNotenumber() != null) {
        billno = items[i].getNotenumber().trim();
      } else {
        continue;
      }

      if (CMPConstant.BILLTYPE_SK.equals(djdl) || CMPConstant.BILLTYPE_SJ.equals(djdl)) {
        switch (moneytype) {
          case YB:
            money = items[i].getReceive(); // 付款原币金额
            break;
          case FB:
            money = items[i].getReceivefrac(); // 辅币金额
            break;
          case BB:
            money = items[i].getReceivelocal(); // 本币
            break;
        }
      }
      if (CMPConstant.BILLTYPE_FK.equals(djdl) || CMPConstant.BILLTYPE_FJ.equals(djdl)) {
        switch (moneytype) {
          case YB:
            money = items[i].getPay();
            break;
          case FB:
            money = items[i].getPayfrac();
            break;
          case BB:
            money = items[i].getPaylocal();
            break;
        }
      }
      if (money == null) {
        money = new UFDouble(0);
      }

      if (billnoSet.contains(billno)) {
        UFDouble tmpMoney = map.get(billno);
        map.put(billno, tmpMoney.add(money));
      } else {
        map.put(billno, money);
      }
      billnoSet.add(billno);
    }
    return map;
  }
Example #4
0
  // 复写父类的保存方法,解决了修改时子表中主表外键丢失的问题
  // 添加了当合同为普通合同时,合同金额为必输项的数据项检查
  public NCObject write(NCObject billVO, Object userObject) throws BusinessException {
    // 子表修改记录时插入主表主键
    // 获取AggVO
    AggContractVO aggContractVO = (AggContractVO) billVO.getContainmentObject();
    if (null != aggContractVO) {
      // 获取主表VO
      ContractVO ContractVO = (ContractVO) aggContractVO.getParentVO();
      String message[] = DzcgMainAuthority.queryXDeptAndPsnByCon(ContractVO);

      if (ContractVO.getXq_dept() == null) ContractVO.setXq_dept(message[0]);
      if (ContractVO.getXreq_psn() == null) ContractVO.setXreq_psn(message[1]);
      if (ContractVO.getXreq_no() == null) ContractVO.setXreq_no(message[4]);

      if (ContractVO.getXreq_name() == null) ContractVO.setXreq_name(message[5]);

      // lifeic修改把合同金额校验去掉,使用自动计算合同金额
      // 获取用户输入的合同类型,当合同类型为普通合同时做合同金额的必输项检查
      /*
      if(ContractVO.getCt_type().intValue() == EbsOperaitonConst.OPERATION_STOCK_TYPE_COMMON_CONTRACT){
      	if (ContractVO.getCt_amount() == null){
      		throw new LfwRuntimeException(null,"请输入合同金额!",null);
      	}
      }else{
      	//当合同类型为框架协议时将合同金额设置为空
      	ContractVO.setCt_amount(null);
      }
      */
      // 检查合同生效日期和合同结束日期的合法性
      // 合同生效日期
      //			UFDate dtBeginDay = ContractVO.getCt_validate_date();
      //			//合同结束日期
      //			UFDate dtEndDay = ContractVO.getCt_closed_date();
      //			//合同结束日期不早于合同生效日期
      //			if(dtBeginDay.compareTo(dtEndDay) > 0){
      //				throw new LfwRuntimeException("合同结束日期不能早于合同生效日期!");
      //			}

      UFDouble total = new UFDouble(0);
      // 获取主表VO属性
      String pk_ht_contract = ContractVO.getPk_ht_contract();
      if (null != pk_ht_contract && !"".equals(pk_ht_contract)) {
        // 修改保存时设置修改人和修改时间
        // 修改人为当前登录者
        ContractVO.setModifyid(LfwRuntimeEnvironment.getUserVO().getPrimaryKey());
        // 修改日期为当前系统日期
        ContractVO.setModifydate(new UFDate(System.currentTimeMillis()));
        // 获取所有字表VO,以数组形式返回
      }

      ProdPriceRepoVO[] cavo =
          (ProdPriceRepoVO[]) aggContractVO.getTableVO("prod_price_item_array");
      if (cavo != null) {
        int count = 0;
        for (int i = 0; i < cavo.length; i++) {
          if (cavo[i].getStatus() != VOStatus.DELETED) {
            // 判断行数据中产品分类、产品名称、生效日期和失效日期单位是否输入
            if (null == cavo[i].getPk_da_prod_cate() || "".equals(cavo[i].getPk_da_prod())) {
              throw new LfwRuntimeException("表体第" + (i + 1) + "行:请选择产品分类!");
            }
            /*
            if (null == cavo[i].getPk_da_prod() || "".equals(cavo[i].getPk_da_prod())){
            	throw new LfwRuntimeException(null,"表体第"+(i+1)+"行:请选择产品!",null);
            }
            */
            if (null == cavo[i].getProd_unit() || "".equals(cavo[i].getProd_unit())) {
              throw new LfwRuntimeException("表体第" + (i + 1) + "行:请选择单位!");
            }

            /*
            if (null == cavo[i].getEffective_date() || "".equals(cavo[i].getEffective_date())){
            	throw new LfwRuntimeException(null,"表体第"+(i+1)+"行:请选择生效日期!",null);
            }
            if (null == cavo[i].getIneffective_date() || "".equals(cavo[i].getIneffective_date())){
            	throw new LfwRuntimeException(null,"表体第"+(i+1)+"行:请选择失效日期!",null);
            }
            */
            // 更改VO状态,重新插入页面输入的行数据信息
            if (cavo[i].getStatus() != VOStatus.DELETED) {
              cavo[i].setStatus(VOStatus.NEW);
            }
            // 为子表VO中的属性set主表主键
            cavo[i].setAttributeValue("pk_ht_contract", pk_ht_contract);

            total = total.add(cavo[i].getDiscounted_amount());

          } else {
            cavo[i] = null;
            count++;
          }
        }

        // 修改删除行项目之后保存还出现该行项目问题,在获取之后删除保存
        // 创建一个存放删除记录后的容器
        ProdPriceRepoVO[] cavonew = new ProdPriceRepoVO[cavo.length - count];
        // 为存放数组声明的一个下标
        int Index = 0;
        // 为删除记录后的容器赋值
        for (int i = 0; i < cavo.length; i++) {
          if (null == cavo[i]) {

          } else {
            cavonew[Index] = cavo[i];
            Index++;
          }
        }

        aggContractVO.setTableVO("prod_price_item_array", cavonew);

        ConstratMoneyPlanVO[] cavo1 =
            (ConstratMoneyPlanVO[]) aggContractVO.getTableVO("moeny_plan_item_array");
        if (cavo1 != null) {
          for (int i = 0; i < cavo1.length; i++) {

            if (cavo1[i].getAttributeValue("pk_ht_money_plan") == null
                || cavo1[i].getAttributeValue("pk_ht_money_plan").equals("")) {

              cavo1[i].setStatus(VOStatus.NEW);
              cavo1[i].setAttributeValue("pk_ht_contract", pk_ht_contract);
            }
          }
        }
      }

      ContractVO.setCt_amount(total);

      // 普通自动生成编码的处理  wangyea  2010-12-31
      String contract_no = null;
      if (ContractVO.getContract_no() == null || ContractVO.getContract_no().length() == 0) {

        if (ContractVO.getR_pk_ht_contract() != null
            && ContractVO.getR_pk_ht_contract().length() > 0) {
          // 关联合同编号
          contract_no =
              CodPlatformService.billCodeGlContract(
                  ContractVO.getPk_corp(), ContractVO.getR_pk_ht_contract());
        } else {
          // 普通合同编号
          contract_no = CodPlatformService.billCodeContract(ContractVO.getPk_corp());
        }

      } else {
        if (ContractVO.getPk_ht_contract() != null) {
          // 查询数据库中的关联合同主键,判断关联合同是否修改
          String ora_r_pk =
              CodPlatformService.queryLinkContractByPk(ContractVO.getPk_ht_contract());

          // 修改关联合同时,重新生成关联合同编码
          if (ContractVO.getR_pk_ht_contract() != null && ora_r_pk != null) {
            // 如果去掉了关联合同
            if (!ContractVO.getR_pk_ht_contract().equals(ora_r_pk)) {
              // 关联合同编号   如果关联合同变化则重新生成编码
              contract_no =
                  CodPlatformService.billCodeGlContract(
                      ContractVO.getPk_corp(), ContractVO.getR_pk_ht_contract());
            } else {
              // 合同编号不变
              contract_no = ContractVO.getContract_no();
            }
          } else {
            if (ora_r_pk != null && ContractVO.getR_pk_ht_contract() == null) {
              // 普通合同编号
              contract_no = CodPlatformService.billCodeContract(ContractVO.getPk_corp());
            } else if (ora_r_pk == null && ContractVO.getR_pk_ht_contract() == null) {
              // 合同编号不变
              contract_no = ContractVO.getContract_no();
            } else if (ora_r_pk == null && ContractVO.getR_pk_ht_contract() != null) {
              // 关联合同编号   如果关联合同变化则重新生成编码
              contract_no =
                  CodPlatformService.billCodeGlContract(
                      ContractVO.getPk_corp(), ContractVO.getR_pk_ht_contract());
            } else {
              // 合同编号不变
              contract_no = ContractVO.getContract_no();
            }
          }
        }
      }
      ContractVO.setContract_no(contract_no);
      // 编码判断处理完成

    }
    IContractService service =
        (IContractService) NCLocator.getInstance().lookup(IContractService.class);
    return service.doWrite(billVO, userObject);
  }
Example #5
0
  /**
   * 更新需求填报子表VO的方法
   *
   * @param planVO 计划填报的主表VO
   * @param planItemProdVO 计划填报的子表VO
   * @param keyPlanItemList 要插入主键列表
   * @return ReqItemProdVO 需求填报的子表VO
   * @author liweiqiang 2009-11-16
   */
  private ReqItemProdVO setReqItemProdVO(
      PlanVO planVO, PlanItemProdVO planItemProdVO, String[] keyPlanItemList) {

    ReqItemProdVO reqItemProdVO = new ReqItemProdVO();

    // 计划类型
    reqItemProdVO.setPlan_type(planVO.getPlan_type());
    // 计划方式
    reqItemProdVO.setPlan_mode(planVO.getPlan_mode());
    // 采购品种类型
    reqItemProdVO.setStock_type(planVO.getStock_type());
    // 产品ID
    reqItemProdVO.setPk_da_prod_id(planItemProdVO.getPk_prod_id());
    // 产品编码
    reqItemProdVO.setProd_code(planItemProdVO.getProd_code());
    // 产品名称
    reqItemProdVO.setProd_name(planItemProdVO.getProd_name());
    // 产品分类ID
    reqItemProdVO.setPk_prod_cate(planItemProdVO.getProd_type());
    // // 产品分类名称
    // reqItemProdVO.setProd_cate_name();
    // 产品规格
    reqItemProdVO.setProd_module(planItemProdVO.getProd_spec());
    // 项目名称
    reqItemProdVO.setProj_name(planItemProdVO.getProj_name());
    // 需求说明
    reqItemProdVO.setProj_req_desc(planItemProdVO.getReq_desc());
    // 数量
    UFDouble quantity = planItemProdVO.getAftermod_quantity();

    if (quantity != null) {
      if (quantity.getDouble() > 0) {
        reqItemProdVO.setQuantity(quantity);
      } else {
        reqItemProdVO.setQuantity(planItemProdVO.getQuantity());
      }
    } else {
      reqItemProdVO.setQuantity(planItemProdVO.getQuantity());
    }

    // 单价
    reqItemProdVO.setUnit_price(planItemProdVO.getUnit_price());
    // 单位
    reqItemProdVO.setPk_unit(planItemProdVO.getPk_unit());
    // 金额
    reqItemProdVO.setAmount(planItemProdVO.getAmount());
    // 来源单据主表ID(计划单ID)
    reqItemProdVO.setPk_bill_src(planItemProdVO.getPk_jh_plan_main());
    // 来源单据子表ID
    reqItemProdVO.setPk_bill_item_src(planItemProdVO.getPk_jh_plan_item_prod());
    // 来源单据类型
    reqItemProdVO.setBill_type_src(planVO.getBill_type());

    // 单据状态
    reqItemProdVO.setStatus(VOStatus.NEW);

    // 需求变更增加有关说明 2009-12-23 lwq
    reqItemProdVO.setReq_say(planItemProdVO.getReq_say());

    return reqItemProdVO;
  }
Example #6
0
  /** 王磊2011-3-26改动,判断为空的问题 */
  public NCObject write(NCObject billVO, Object userObject) throws BusinessException {
    // 子表修改记录时插入主表主键
    // 获取AggVO

    BaseDAO dao = new BaseDAO();
    AggReqVO aggReqVO = (AggReqVO) billVO.getContainmentObject();
    if (null != aggReqVO) {
      // 获取主表VO
      ReqMainVO reqMainVO = (ReqMainVO) aggReqVO.getParentVO();

      // 修改不给复制建议人的问题
      String operid = reqMainVO.getPk_oper_person();
      String dept = reqMainVO.getPk_dept_sug();
      try {
        String sql =
            " select * from bd_psndoc where pk_deptdoc = '"
                + dept
                + "' and  pk_psndoc ='"
                + operid
                + "' ";

        List<PsndocVO> list =
            (List<PsndocVO>) dao.executeQuery(sql, new BeanListProcessor(PsndocVO.class));

        //				psnvo = (PsndocVO)dao.retrieveByPK(PsndocVO.class, operid);
        if (list != null && list.size() > 0) {

        } else {
          throw new LfwRuntimeException("请不要手动填写采购经办人,你选择的建议采购部门与填写的采购经办人部门不对应,请重新选择!");
        }

      } catch (Exception e) {
        throw new LfwRuntimeException("请不要手动填写采购经办人,你选择的建议采购部门与填写的采购经办人部门不对应,请重新选择!");
        //				Logger.error("请选择建议采购人,不要手动填写!");
        //				Logger.error(e.getMessage());
      }

      String bill_code = reqMainVO.getBill_code();

      if (bill_code == null || bill_code.trim().length() == 0) {

        bill_code = CodPlatformService.billCodeXqRep(LfwRuntimeEnvironment.getPkCorp());
        reqMainVO.setBill_code(bill_code);
      }
      // 获取主表VO属性
      String pk_xq_req_main = reqMainVO.getPk_xq_req_main();
      if (null != pk_xq_req_main && !"".equals(pk_xq_req_main)) {

        // 修改保存时设置修改人和修改时间
        // 修改人
        reqMainVO.setModifier(LfwRuntimeEnvironment.getUserVO().getPrimaryKey());
        // 修改时间为当前的系统时间
        reqMainVO.setModifydate(new UFDate(System.currentTimeMillis()));

        // 获取所有子表VO,以数组形式返回
        CircularlyAccessibleValueObject[] cavo = aggReqVO.getChildrenVO();

        if (cavo != null && cavo.length > 0) {
          // 现在可以导入数据,导入数据时是需要把单据保存后才能进行处理,因此去掉了表体不能为空的限制
          // throw new LfwRuntimeException("表体行不能为空");

          for (int i = 0; i < cavo.length; i++) {
            // 为子表VO中的属性set主表主键

            cavo[i].setAttributeValue("pk_xq_req_main", pk_xq_req_main);
          }
        }
      }

      UFDouble ufd = reqMainVO.getBuget_amount();

      //	boolean flag=true;

      CircularlyAccessibleValueObject[] cavo = aggReqVO.getChildrenVO();

      UFDouble amount = new UFDouble(0);

      if (cavo != null && cavo.length > 0) {

        for (CircularlyAccessibleValueObject cav : cavo) {

          if (cav instanceof ReqItemProdVO) {

            ReqItemProdVO pvo = (ReqItemProdVO) cav;

            if (pvo != null) {

              if (pvo.getStatus() != 3) {
                UFDouble tAmount = pvo.getAmount();

                if (tAmount != null) {

                  amount = amount.add(tAmount);
                }
                if (tAmount.toDouble() <= 0) {
                  throw new LfwRuntimeException("预算单价必须大于0");
                }
                //	flag= false;
              }
            }
          }
        }
      }

      /*
      if(flag)
      {
      	throw new LfwRuntimeException("表体行不能为空");
      }
      */
      reqMainVO.setBuget_amount(amount);
    }

    return super.write(billVO, userObject);
  }
Example #7
0
  public static void convertRetailMeas(IMeasField[] voItems) throws BusinessException {
    if (voItems == null || voItems.length == 0) return;

    java.util.HashSet<String> hm = new java.util.HashSet<String>();
    for (int i = 0; i < voItems.length; i++) {
      hm.add(voItems[i].getInvbas());
    }

    String[] invids = new String[hm.size()];
    hm.toArray(invids);

    HashMap hmData = queryInvVos(invids);

    UFDouble udTmpNum = null;
    String sTmp = null;
    UFDouble one = new UFDouble(1);
    ArrayList alinv = null;
    // 无存货信息的存货的ID
    ArrayList<String> noInv = new ArrayList<String>();
    // 非主辅计量管理,主单位和辅单位不一致
    ArrayList<String> errMeas = new ArrayList<String>();
    for (int i = 0; i < voItems.length; i++) {
      alinv = (ArrayList) hmData.get(voItems[i].getInvbas());
      if (alinv == null || alinv.size() == 0) {
        noInv.add(((InvVO) alinv.get(0)).getInvcode());
        continue;
      }

      udTmpNum = voItems[i].getRetailNum();
      sTmp = voItems[i].getRetailMeas();
      for (int j = 0; j < alinv.size(); j++) {
        InvVO voInv = (InvVO) alinv.get(j);
        // 无零售单位, 零售单位和主单位一致 ,按照主单位、数量
        if (sTmp == null || sTmp.equals(voInv.getPk_measdoc())) {

          // 非辅单位管理
          if (voInv.getAssistunit() == null || !(voInv.getAssistunit().booleanValue())) {
            voItems[i].setMainMeas(voInv.getPk_measdoc());
            voItems[i].setMainNum(udTmpNum);
            break;
          } else {
            voItems[i].setMainMeas(voInv.getPk_measdoc());
            voItems[i].setMainNum(udTmpNum);
            voItems[i].setAstMeas(voInv.getPk_measdoc());
            voItems[i].setAstNum(udTmpNum);
            voItems[i].setHsl(one);

            break;
          }
        } else {
          // 非辅单位管理,零售单位不等于主单位,属于错误数据
          if (voInv.getAssistunit() == null || !(voInv.getAssistunit().booleanValue())) {
            errMeas.add(voInv.getInvcode());
            continue;
          } // 辅单位和零售单位一致,计算出主单位和换算率
          else if (voInv.getCassistunitid().equals(sTmp)) {
            voItems[i].setMainMeas(voInv.getPk_measdoc());
            voItems[i].setMainNum(udTmpNum.multiply(voInv.getMainmeasrate()));
            voItems[i].setAstMeas(sTmp);
            voItems[i].setAstNum(udTmpNum);
            voItems[i].setHsl(voInv.getMainmeasrate());

            break;
          }
        }
      }
    }

    // 异常处理
    if (noInv.size() > 0 || errMeas.size() > 0) {
      String err = "";
      if (noInv.size() > 0) {
        err = "以下ID的存货不存在:" + noInv.toString() + "\r\n";
      }
      if (errMeas.size() > 0) {
        err = err + "非辅单位管理的存货,零售单位须和主单位一致:" + errMeas.toString() + "\r\n";
      }
      throw new BusinessException(err);
    }
  }