@Override
  public void save(OprEnterPortStandard entity) {
    User user = WebRalasafe.getCurrentUser(ServletActionContext.getRequest());
    String userName = user.get("name") + "";
    entity.setLastCountName(userName);
    entity.setLastCountTime(new Date());

    Query query = null;
    if (null != entity.getId() && entity.getId() > 0) {
      query =
          this.enterPortStandardDao.createQuery(
              "from OprEnterPortStandard where deptId=? and id!=?",
              entity.getDeptId(),
              entity.getId());
    } else {
      query =
          this.enterPortStandardDao.createQuery(
              "from OprEnterPortStandard where deptId=? ", entity.getDeptId());
    }
    List<OprEnterPortStandard> list = query.list();

    if (null == list || list.size() == 0) {
      super.save(entity);
    } else {
      throw new ServiceException("该部门已经存在!");
    }
  }
 public void payConfirmationRegisterBybatchNo(Long batchNo) throws Exception {
   List<FiDeliverycost> list = this.fiDeliverycostDao.findBy("batchNo", batchNo);
   if (list == null) throw new ServiceException("中转成本中根据批次号:" + batchNo + "未找到数据!");
   User user = WebRalasafe.getCurrentUser(ServletActionContext.getRequest());
   String hql =
       "update FiDeliverycost f set f.payStatus=0L,f.payTime=?,f.payUser=? where f.batchNo=?";
   this.fiDeliverycostDao.batchExecute(hql, new Date(), user.get("name").toString(), batchNo);
 }
 public void repeatAduit(Long osadId) throws Exception {
   User user = WebRalasafe.getCurrentUser(Struts2Utils.getRequest());
   OprShuntApplyDetail osad = oprShuntApplyDetailDao.get(osadId);
   osad.setStatus(0L);
   osad.setUpdateName(user.get("name").toString());
   osad.setUpdateTime(new Date());
   oprShuntApplyDetailDao.save(osad);
 }
  public void shuntApplyAduit(OprShuntApplyDetail osad) throws Exception {
    List<BasCar> list = basCarService.findBy("carCode", osad.getDisCarNo());
    BasCar bc = list.get(0);
    bc.setCarStatus("хэ│хол");
    basCarService.save(bc);

    User user = WebRalasafe.getCurrentUser(Struts2Utils.getRequest());
    osad.setRouteNumber(oprOvermemoService.findRouteNumberSeq());
    osad.setStatus(1L);
    osad.setCreateName(user.get("name").toString());
    osad.setCreateTime(new Date());
    oprShuntApplyDetailDao.save(osad);
  }
  @ModuleName(value = "提货成本管理导入Excel保存", logType = LogType.fi)
  public String saveFiExcel(File excelFile, String fileName) throws Exception {
    User user = WebRalasafe.getCurrentUser(ServletActionContext.getRequest());
    Long bussDepartId = Long.parseLong(user.get("bussDepart") + "");
    List<FiDeliverycostExcel> fiList = new ArrayList<FiDeliverycostExcel>();
    Long batchNo = fiDeliverycostExcelService.getBatchNO(bussDepartId);
    List list = null;
    if (fileName.toLowerCase().endsWith(".xlsx")) {
      ReadExcel2007 readExcel2007 = new ReadExcel2007(5);
      FileInputStream fint = new FileInputStream(excelFile);
      try {
        list = readExcel2007.readExcel2007(fint);
      } catch (Exception e) {
        throw new ServiceException("读取数据错误,存在非法空值");
      } finally {
        if (fint != null) {
          fint.close();
          fint = null;
        }
      }
    } else if (fileName.toLowerCase().endsWith(".xls")) {
      ReadExcel readExcel = new ReadExcel(5);
      FileInputStream fint = new FileInputStream(excelFile);
      try {
        list = readExcel.readExcel(fint);
      } catch (Exception e) {
        throw new ServiceException("读取数据错误,存在非法空值");
      } finally {
        if (fint != null) {
          fint.close();
          fint = null;
        }
      }
    } else {
      throw new ServiceException("请导入Excel文件,后缀为.xlsx或者.xls");
    }
    for (int i = 0; i < list.size(); i++) {
      FiDeliverycostExcel fiDeliveryExcel = new FiDeliverycostExcel();
      fiDeliveryExcel.setStatus(0l);
      fiDeliveryExcel.setBatchNo(batchNo);
      List row = (List) list.get(i);
      if (i != 0) {
        Iterator jt = row.iterator();
        String company = (String) jt.next();

        fiDeliveryExcel.setExcelCompany(company);
        jt.hasNext();

        String excelNo = (String) jt.next();
        fiDeliveryExcel.setExcelNo(excelNo);
        jt.hasNext();
        String excelWeight = (String) jt.next();
        if (excelWeight == null || "".equals(excelWeight)) {
          continue;
        }
        fiDeliveryExcel.setExcelWeight(Double.parseDouble(excelWeight));
        jt.hasNext();

        String excelAmount = (String) jt.next();
        if (excelAmount == null || "".equals(excelAmount)) {
          continue;
        }
        fiDeliveryExcel.setExcelAmount((Double.parseDouble(excelAmount)));
        jt.hasNext();

        String banFee = (String) jt.next();
        if (banFee == null || "".equals(banFee)) {
          continue;
        }
        fiDeliveryExcel.setExcelBanFee(Double.parseDouble(banFee));
        fiList.add(fiDeliveryExcel);
      }
    }

    for (FiDeliverycostExcel fiDeliverycostExcel : fiList) {
      fiDeliverycostExcelDao.save(fiDeliverycostExcel);
    }
    return batchNo + "";
  }
  public List<? extends PrintBean> setPrintBeanList(
      BillLadingList mainbill, Map<String, String> map) {
    List<PrintBean> list = new ArrayList<PrintBean>();

    String dno = map.get("dno");
    String changeNo = map.get("changeNo");

    if (null == map.get("changeNos") || "".equals(map.get("changeNos").trim())) {
      mainbill.setMsg("请传更改明细单号过来!");
      return list;
    }
    if (null == changeNo || "".equals(changeNo)) {
      mainbill.setMsg("请传更改单号过来!");
      return list;
    }
    if (null == dno || "".equals(dno)) {
      mainbill.setMsg("请传配送单号过来!");
      return list;
    }
    String changeNos[] = map.get("changeNos").split(",");
    OprChangeMain changeMain = this.oprFaxChangeDao.get(Long.valueOf(changeNo));
    if (null == changeMain) {
      mainbill.setMsg("更改单号有误,没有找到该更改单号!");
      return list;
    }
    OprFaxIn fax = this.oprFaxInDao.get(changeMain.getDno());
    if (null == fax) {
      mainbill.setMsg("没有找到对应的传真记录!");
      return list;
    }
    OprChangeDetail detail = null;
    OprFaxChangeBean bean = null;
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm ss");
    SimpleDateFormat sdfPrint = new SimpleDateFormat("yyyy-MM-dd HH:mm"); // 打印格式
    User user = WebRalasafe.getCurrentUser(ServletActionContext.getRequest());
    Iterator<OprChangeDetail> itr = changeMain.getOprChangeDetail().iterator();
    while (itr.hasNext()) {
      detail = itr.next();
      boolean bool = false;
      for (int i = 0; i < changeNos.length; i++) {

        if (detail.getId().equals(Long.valueOf(changeNos[i]))) {
          bool = true;
          break;
        }
      }
      if (!bool) {
        continue;
      }

      bean = new OprFaxChangeBean();
      bean.setChangeContent(
          "原 "
              + detail.getChangeFieldZh()
              + " 为:"
              + detail.getChangePre()
              + "   现改为:"
              + detail.getChangePost());
      try {
        bean.setChangeDate(sdf.format(changeMain.getCreateTime()));
      } catch (Exception e) {
        mainbill.setMsg("更改申请主表创建时间有误!");
        logger.debug("更改申请主表创建时间有误!");
      }
      bean.setChangeDepart(changeMain.getDepartName() == null ? "" : changeMain.getDepartName());
      bean.setChangeName(changeMain.getCreateName() == null ? "" : changeMain.getCreateName());
      bean.setChangeNo(changeNo);
      bean.setChangeTitle("配送中心更改通知单"); // 设置标题
      bean.setConsignee(fax.getConsignee() == null ? "" : fax.getConsignee());
      bean.setCusName(fax.getCpName() == null ? "" : fax.getCpName());
      bean.setDistributionMode(fax.getDistributionMode() == null ? "" : fax.getDistributionMode());
      bean.setDno(fax.getDno() + "");
      bean.setFlightMainNo(fax.getFlightMainNo() == null ? "" : fax.getFlightMainNo());
      bean.setSubNo(fax.getSubNo() == null ? "" : fax.getSubNo());
      bean.setGoWhere(fax.getRealGoWhere() == null ? "" : fax.getRealGoWhere());
      bean.setPayWay(fax.getWhoCash() == null ? "" : fax.getWhoCash());
      bean.setPiece(fax.getPiece() == null ? "0" : fax.getPiece() + "");
      bean.setTakeMode(fax.getTakeMode() == null ? "" : fax.getTakeMode());
      bean.setWeight(fax.getCqWeight() == null ? "0" : fax.getCqWeight() + ""); // 重量
      bean.setWeightFee(fax.getCusWeight() == null ? "" : fax.getCusWeight() + ""); // 计费重量
      bean.setXbwlImagePath(this.print_fax_change_img); // 设置图片路径

      bean.setPrintId("");
      bean.setPrintName(user.get("name") + "");
      bean.setPrintNum(1l);
      bean.setPrintTime(sdfPrint.format(new Date())); // 打印时间
      bean.setSourceNo(changeNo);

      list.add(bean);
    }
    return list;
  }