/*
   * (non-Javadoc)
   *
   * @see com.synesoft.fisp.domain.service.cm.BusinessCommonService#
   * commonBusinessValidate(java.lang.String, java.lang.Object)
   */
  @SuppressWarnings({"unchecked", "rawtypes"})
  @Override
  public void commonBusinessValidate(String pageId, Object obj) {
    ResultMessages messages = ResultMessages.error();
    SysControlDept query_SysControlDept = new SysControlDept();
    UserInf userInfo = ContextConst.getCurrentUser();
    query_SysControlDept.setControlDept(userInfo.getDepartment());
    query_SysControlDept.setPageId(pageId);
    List<SysControlDept> sysControlDepts =
        sysControlDeptRepos.queryListByPageCheck(query_SysControlDept);
    Class clazz = obj.getClass();

    if (null != sysControlDepts) {
      for (int i = 0; i < sysControlDepts.size(); i++) {
        Object objValue = null;
        String getValue = "get" + sysControlDepts.get(i).getControlId();
        Method method;
        try {
          method = clazz.getMethod(getValue, new Class[] {});
          objValue = method.invoke(obj);
          if (objValue instanceof String) {
            if (!StringUtil.isNotTrimEmpty((String) objValue)) {
              ResultMessage resultMessage =
                  ResultMessage.fromCode(
                      "e.fisp.commonValidate." + sysControlDepts.get(i).getControlId());
              messages.add(resultMessage);
            }
          } else {
            if (null == objValue) {
              ResultMessage resultMessage =
                  ResultMessage.fromCode(
                      "e.fisp.commonValidate." + sysControlDepts.get(i).getControlId());
              messages.add(resultMessage);
            }
          }
        } catch (SecurityException e) {
          e.printStackTrace();
        } catch (NoSuchMethodException e) {
          e.printStackTrace();
        } catch (IllegalArgumentException e) {
          e.printStackTrace();
        } catch (IllegalAccessException e) {
          e.printStackTrace();
        } catch (InvocationTargetException e) {
          e.printStackTrace();
        }
        if (messages.isNotEmpty()) {
          throw new BusinessException(messages);
        }
      }
    }
  }
Example #2
0
  @RequestMapping("AddDtlDtlSubmit")
  public String AddDtlDtlSubmit(Model model, FTZ210205Form form, BindingResult result) {

    FtzInTxnDtl issert_FtzInTxnDtl = form.getFtzInTxnDtl();
    // 开始校验
    ResultMessages resultMessages = ResultMessages.error();

    // 出/入账标志
    if (null == issert_FtzInTxnDtl.getCdFlag()
        || "".equals(issert_FtzInTxnDtl.getCdFlag().trim())) {
      ResultMessage resultMessage = ResultMessage.fromCode("e.ftzmis.210101.0013");
      resultMessages.add(resultMessage);
    }

    if ("3".equals(issert_FtzInTxnDtl.getCdFlag().trim())
        || "4".equals(issert_FtzInTxnDtl.getCdFlag().trim())) {
      if (null == issert_FtzInTxnDtl.getOrgTranDate()
          || "".equals(issert_FtzInTxnDtl.getOrgTranDate().trim())
          || ((null != issert_FtzInTxnDtl.getTranDate())
              && DateUtil.getFormatDateRemoveSprit(issert_FtzInTxnDtl.getTranDate())
                      .compareToIgnoreCase(
                          DateUtil.getFormatDateRemoveSprit(issert_FtzInTxnDtl.getOrgTranDate()))
                  < 0)) {
        ResultMessage resultMessage = ResultMessage.fromCode("e.ftzmis.210101.0027");
        resultMessages.add(resultMessage);
      }
    }

    // 记帐日期
    if (null == issert_FtzInTxnDtl.getTranDate()
        || "".equals(issert_FtzInTxnDtl.getTranDate().trim())) {
      ResultMessage resultMessage = ResultMessage.fromCode("e.ftzmis.210101.0014");
      resultMessages.add(resultMessage);
    }
    // 金额
    if (null == issert_FtzInTxnDtl.getAmount()) {
      ResultMessage resultMessage = ResultMessage.fromCode("e.ftzmis.210101.0015");
      resultMessages.add(resultMessage);
    } else {
      if (!Validator.CheckAmount(issert_FtzInTxnDtl.getAmount())) {
        ResultMessage resultMessage = ResultMessage.fromCode("e.ftzmis.210303.0013");
        resultMessages.add(resultMessage);
      }
    }

    // 国别代码
    if (null == issert_FtzInTxnDtl.getCountryCode()
        || "".equals(issert_FtzInTxnDtl.getCountryCode().trim())) {
      ResultMessage resultMessage = ResultMessage.fromCode("e.ftzmis.210101.0016");
      resultMessages.add(resultMessage);
    }

    // 交易性质
    if (null == issert_FtzInTxnDtl.getTranType()
        || "".equals(issert_FtzInTxnDtl.getTranType().trim())) {
      ResultMessage resultMessage = ResultMessage.fromCode("e.ftzmis.210101.0017");
      resultMessages.add(resultMessage);
    }
    // 正常出账或入账时必输
    if ("1".equals(issert_FtzInTxnDtl.getCdFlag().trim())
        || "2".equals(issert_FtzInTxnDtl.getCdFlag().trim())) {
      if (null == issert_FtzInTxnDtl.getOppAccount()
          || "".equals(issert_FtzInTxnDtl.getOppAccount().trim())) {
        ResultMessage resultMessage = ResultMessage.fromCode("e.ftzmis.210205.0001");
        resultMessages.add(resultMessage);
      }
    }
    // 正常出账或者入账时用户名必输
    if ("1".equals(issert_FtzInTxnDtl.getCdFlag().trim())
        || "2".equals(issert_FtzInTxnDtl.getCdFlag().trim())) {
      if (null == issert_FtzInTxnDtl.getOppName()
          || "".equals(issert_FtzInTxnDtl.getOppName().trim())) {
        ResultMessage resultMessage = ResultMessage.fromCode("e.ftzmis.210205.0006");
        resultMessages.add(resultMessage);
      }
    }
    //		//对方客户性质
    if (null == issert_FtzInTxnDtl.getOppCusType()
        || "".equals(issert_FtzInTxnDtl.getOppCusType().trim())) {
      ResultMessage resultMessage = ResultMessage.fromCode("e.ftzmis.210205.0002");
      resultMessages.add(resultMessage);
    }

    if (resultMessages.isNotEmpty()) {
      model.addAttribute(resultMessages);
      return "ftzmis/FTZ210205_Input_Dtl_Dtl";
    }

    FtzInTxnDtl query_FtzInTxnDtl = new FtzInTxnDtl();
    query_FtzInTxnDtl.setMsgId(issert_FtzInTxnDtl.getMsgId());
    List<FtzInTxnDtl> ftzInTxnDtls = ftz210205Serv.queryFtzInTxnDtlList(query_FtzInTxnDtl);
    if (null == ftzInTxnDtls || ftzInTxnDtls.size() == 0) {
      issert_FtzInTxnDtl.setSeqNo(StringUtil.addZeroForNum("1", 6));
    } else {
      FtzInTxnDtl ftzInTxnDtl_tmp = ftzInTxnDtls.get(ftzInTxnDtls.size() - 1);
      String seqNo = Integer.parseInt(ftzInTxnDtl_tmp.getSeqNo()) + 1 + "";
      issert_FtzInTxnDtl.setSeqNo(StringUtil.addZeroForNum(seqNo, 6));
    }

    issert_FtzInTxnDtl.setTranDate(
        DateUtil.getFormatDateRemoveSprit(issert_FtzInTxnDtl.getTranDate()));
    issert_FtzInTxnDtl.setValueDate(
        DateUtil.getFormatDateRemoveSprit(issert_FtzInTxnDtl.getValueDate()));
    issert_FtzInTxnDtl.setOrgTranDate(
        DateUtil.getFormatDateRemoveSprit(issert_FtzInTxnDtl.getOrgTranDate()));
    issert_FtzInTxnDtl.setExpireDate(
        DateUtil.getFormatDateRemoveSprit(issert_FtzInTxnDtl.getExpireDate()));
    UserInf userInfo = ContextConst.getCurrentUser();
    issert_FtzInTxnDtl.setMakUserId(userInfo.getUserid());
    issert_FtzInTxnDtl.setMakDatetime(DateUtil.getNowInputDateTime());
    issert_FtzInTxnDtl.setChkStatus(CommonConst.FTZ_MSG_STATUS_INPUT_COMPLETED);
    int i = ftz210205Serv.insertFtzInTxnDtl(issert_FtzInTxnDtl);
    if (i < 1) {
      model.addAttribute(ResultMessages.error().add("e.sysrunner.0006"));
    } else {
      model.addAttribute(ResultMessages.success().add("i.ftzmis.210210.0003"));
      model.addAttribute("uptFlag", "1");
    }
    form.getFtzInTxnDtl()
        .setTranDate(DateUtil.getFormatDateAddSprit(form.getFtzInTxnDtl().getTranDate()));
    form.getFtzInTxnDtl()
        .setOrgTranDate(DateUtil.getFormatDateAddSprit(form.getFtzInTxnDtl().getOrgTranDate()));
    form.getFtzInTxnDtl()
        .setExpireDate(DateUtil.getFormatDateAddSprit(form.getFtzInTxnDtl().getExpireDate()));
    form.getFtzInTxnDtl()
        .setMakDatetime(
            DateUtil.getFormatDateTimeAddSpritAndColon(form.getFtzInTxnDtl().getMakDatetime()));
    form.getFtzInTxnDtl()
        .setChkDatetime(
            DateUtil.getFormatDateTimeAddSpritAndColon(form.getFtzInTxnDtl().getChkDatetime()));
    return "ftzmis/FTZ210205_Input_Dtl_Dtl";
  }