コード例 #1
0
  // 提交单据
  public Bill addNewBill(Bill bill) {
    Farm farm = billDao.getEntityById(Farm.class, bill.getFarm().getId());
    Factory factory = billDao.getEntityById(Factory.class, bill.getFactory().getId());
    // 生成订单号
    bill.setOrderId(Util.genOrderId(farm.getName(), factory.getName(), getCurrNum()));
    // 当前处理人
    User userObj = (User) ActionContext.getContext().getSession().get(WebConstants.SESS_USER_OBJ);
    if (userObj instanceof AreaAccount) {
      AreaAccount aa = (AreaAccount) userObj;
      bill.setCurrUserName(aa.getArea().getFarm().getManager().getName());
      bill.setAreaAccount(aa);
    } else if (userObj instanceof ManagerAccount) {
      ManagerAccount aa = (ManagerAccount) userObj;
      bill.setCurrUserName(aa.getName());
      bill.setManager(aa);
    } else if (userObj instanceof Admin) {
      bill.setCurrUserName(userObj.getName());
    }
    // 保存创建人和创建日期
    if (bill.getCreateDate() == null) bill.setCreateDate(new Date());
    if (bill.getCreateName() == null) bill.setCreateName(userObj.getName());

    baseDao.saveOrUpdate(bill);
    // 保存日志
    BillLog log = Util.getBaseLog(BillLog.class, "草稿 -> 审核中");
    log.setBill(bill);
    log.setRemark(bill.getApplyRemark());
    baseDao.saveOrUpdate(log);

    // 发邮件
    sendEmail(bill, "单据提交成功");

    logger.info("提交单据【" + bill.getOrderId() + "】成功");
    return bill;
  }
コード例 #2
0
 private String buildEmailBody(Bill bill) {
   StringBuffer sb = new StringBuffer();
   sb.append(
       "您有一条新任务,请进入<a href=\""
           + WebConstants.URL
           + "\" target=\"_blank\">"
           + WebConstants.URL
           + "</a>来处理");
   sb.append("农场管区: ");
   sb.append(bill.getFarm() == null ? "" : bill.getFarm().getName());
   sb.append("-" + bill.getArea() == null ? "" : bill.getArea().getName());
   sb.append("\n");
   sb.append("饲料经理签名:" + (bill.getManager() == null ? "" : bill.getManager().getName()));
   sb.append("\n");
   sb.append("单据编号:" + bill.getOrderId());
   sb.append("\n");
   sb.append("管区:" + (bill.getArea() == null ? "" : bill.getArea().getName()));
   sb.append("\n");
   sb.append("单据:" + (bill.getOrderNo() == null ? "" : bill.getOrderNo()));
   sb.append("\n");
   sb.append("负责人:" + bill.getCurrUserName());
   sb.append("\n");
   sb.append("饲料规格:" + bill.getModel());
   sb.append("\n");
   sb.append("饲料型号:" + bill.getSize());
   sb.append("\n");
   sb.append("饲料吨数:" + bill.getAmount());
   sb.append("\n");
   sb.append("预计达到时间:" + Util.getDate(bill.getPlanDate()));
   sb.append("\n");
   return sb.toString();
 }
コード例 #3
0
  // 保存单据草稿
  public Bill saveBillDraft(Bill bill) {
    if (bill == null) return null;
    /*
    if (!Util.isEmpty(bill.getFarmer().getName())) {
    	Farmer farmer = this.getEntityByUnique(Farmer.class, "name", bill.getFarmer().getName());
    	bill.setFarmer(farmer);
    }*/
    Farm farm = billDao.getEntityById(Farm.class, bill.getFarm().getId());
    Factory factory = billDao.getEntityById(Factory.class, bill.getFactory().getId());
    // 生成订单号
    bill.setOrderId(Util.genOrderId(farm.getName(), factory.getName(), getCurrNum()));
    // 当前处理人
    User userObj = (User) ActionContext.getContext().getSession().get(WebConstants.SESS_USER_OBJ);
    if (userObj instanceof AreaAccount) {
      AreaAccount aa = (AreaAccount) userObj;
      bill.setAreaAccount(aa);
    } else if (userObj instanceof ManagerAccount) {
      ManagerAccount aa = (ManagerAccount) userObj;
      bill.setManager(aa);
    }
    bill.setCurrUserName(userObj.getName());
    baseDao.saveOrUpdate(bill);
    // 保存日志
    BillLog log =
        Util.getBaseLog(
            BillLog.class,
            (bill.getShenpiResult() != null && bill.getShenpiResult() == false)
                ? "审核中 -> 草稿"
                : "拟定 -> 草稿");
    log.setBill(bill);
    log.setRemark(
        (bill.getShenpiResult() != null && bill.getShenpiResult() == false)
            ? bill.getShenpiRemark()
            : bill.getApplyRemark());
    baseDao.saveOrUpdate(log);

    logger.info("保存单据草稿【" + bill.getOrderId() + "】成功");
    return bill;
  }
コード例 #4
0
  // 对已经有的草稿进行提交
  public Bill submitDraftBill(Bill bill) {
    // 当前处理人
    User userObj = (User) ActionContext.getContext().getSession().get(WebConstants.SESS_USER_OBJ);
    if (userObj instanceof AreaAccount) {
      AreaAccount aa = (AreaAccount) userObj;
      bill.setCurrUserName(aa.getArea().getFarm().getManager().getName());
      bill.setAreaAccount(aa);
    } else if (userObj instanceof Admin) {
      bill.setCurrUserName(userObj.getName());
    }
    baseDao.saveOrUpdate(bill);
    // 保存日志
    BillLog log = Util.getBaseLog(BillLog.class, "草稿 -> 审核中");
    log.setBill(bill);
    log.setRemark(bill.getApplyRemark());
    baseDao.saveOrUpdate(log);

    // 发邮件
    sendEmail(bill, "单据提交成功");

    logger.info("提交单据【" + bill.getOrderId() + "】成功");
    return bill;
  }
コード例 #5
0
  // 确认单据
  public Bill confirmBill(Bill bill) {
    // 当前处理人
    Provider provider = billDao.getEntityById(Provider.class, bill.getProvider().getId());
    bill.setCurrUserName(provider.getAccount().getName());
    bill.setProviderAccount(provider.getAccount());

    User userObj = (User) ActionContext.getContext().getSession().get(WebConstants.SESS_USER_OBJ);
    if (userObj instanceof ManagerAccount) {
      ManagerAccount aa = (ManagerAccount) userObj;
      bill.setManager(aa);
    }
    baseDao.saveOrUpdate(bill);
    // 保存日志
    BillLog log = Util.getBaseLog(BillLog.class, "审核中 -> 已审核");
    log.setBill(bill);
    log.setRemark(bill.getShenpiRemark());
    baseDao.saveOrUpdate(log);

    // 发邮件
    sendEmail(bill, "单据通过审核");

    logger.info("提交单据【" + bill.getOrderId() + "】成功");
    return bill;
  }