Exemplo n.º 1
0
  /**
   * 查询SIM卡信息
   *
   * @return
   */
  public String querySimInfo() {
    if (simId == "" || simId == null) {
      return ERROR;
    } else {
      try {
        simInfo = (SimInfo) service.getObject("SimManage.getSimInfoById", simId);

        // 设置旧SIM卡号
        setSimOldNumber(simInfo.getSimCardNumber());
        // 设置旧手机号
        setOldPhoneNumber(simInfo.getCellPhone());
        getBusinessInfos();

        // 显示信息
        if (null != message) {
          addActionError(getText(message));
        }

      } catch (BusinessException e) {
        setMessage("info.db.error");
        log.error("Query sim detail error:" + e.getMessage());
        return ERROR;
      } catch (Exception e) {
        setMessage("info.db.error");
        log.error("Query sim detail error:" + e.getMessage());
        return ERROR;
      }
    }
    return SUCCESS;
  }
Exemplo n.º 2
0
  /**
   * 更新SIM卡信息
   *
   * @return
   */
  public String update() {
    UserInfo currentUser =
        (UserInfo) ActionContext.getContext().getSession().get(Constants.USER_SESSION_KEY);
    if (simInfo != null) {
      // 设置修改用户
      simInfo.setModifier(currentUser.getUserID());
      // 设置SIM卡主键值
      simInfo.setSimId(simId);
      // 设置旧SIM卡号值
      simInfo.setOldSimCardNumber(simOldNumber);
    }

    try {
      // 修改SIM卡信息
      simManageService.updateSimInfo(simInfo);
      setMessage("sim.update.success");
    } catch (BusinessException e) {
      setMessage("info.db.error");
      log.error("Update sim info error:" + e.getMessage());
      return ERROR;
    } catch (Exception e) {
      setMessage("info.db.error");
      log.error("Update sim info error:" + e.getMessage());
      return ERROR;
    } finally {
      setOperationType(Constants.UPDATE, ModuleId.CLW_M_CS_SIM_MODIFY_MID);
      addOperationLog("修改SIM卡信息");
    }

    return SUCCESS;
  }
Exemplo n.º 3
0
  /**
   * 创建SIM卡信息
   *
   * @return
   */
  public String addSim() {
    UserInfo currentUser =
        (UserInfo) ActionContext.getContext().getSession().get(Constants.USER_SESSION_KEY);
    if (simInfo != null) {
      // 设置创建用户
      simInfo.setCreater(currentUser.getUserID());
      // 设置主键值
      simInfo.setSimId(UUIDGenerator.getUUID());
    }

    try {
      // 创建SIM卡信息
      service.insert("SimManage.mergeSimInfos", simInfo);
      setMessage("sim.create.success");
    } catch (BusinessException e) {
      setMessage("info.db.error");
      log.error(e.getMessage());
      return ERROR;
    } catch (Exception e) {
      setMessage("info.db.error");
      log.error(e.getMessage());
      return ERROR;
    } finally {
      setOperationType(Constants.INSERT, ModuleId.CLW_M_CS_SIM_ADD_MID);
      addOperationLog("新建SIM卡信息");
    }

    return SUCCESS;
  }
Exemplo n.º 4
0
 public String queryVehicle() {
   try {
     UserInfo user = getCurrentUser();
     VehcileInfo vehinfo = new VehcileInfo();
     vehinfo.setOrganization_id(user.getOrganizationID());
     if (vehicle_ln != null && vehicle_ln != "") {
       vehinfo.setVehicle_ln(vehicle_ln.trim());
     }
     vehicleList = (List<VehcileInfo>) service.getObjects("WxManage.getInfosVeh", vehinfo);
     if (vehicleList != null && vehicleList.size() == 0) {
       // 无用户信息
       addActionError(getText("nodata.list"));
       return ERROR;
     }
   } catch (BusinessException e) {
     super.addActionError(getText("info.db.error"));
     log.error(e.getMessage());
     return ERROR;
   } catch (Exception e) {
     super.addActionError(getText("info.db.error"));
     log.error(e.getMessage());
     return ERROR;
   }
   return SUCCESS;
 }
Exemplo n.º 5
0
  /** 处理记录导出 */
  public String exportOperatedList() {
    List<AlarmEntity> exportlist;
    UserInfo user = getCurrentUser();

    if (searchVO.getOrganization_id() == null || "".equals(searchVO.getOrganization_id())) {
      searchVO.setOrganization_id(user.getOrganizationID());
    }
    try {
      searchVO.setOperate_state("1"); // 已处理
      exportlist = this.service.getObjects("VehicleCheckManage.getVehicleCheckList", searchVO);
      for (AlarmEntity obj : exportlist) {
        // 处理类型
        if (Constants.VECHICLE_ILLEAGAL_USE.equals(obj.getOperate_type())) {
          obj.setOperate_type("公车私用");
        } else {
          obj.setOperate_type("正常使用");
        }
      }
    } catch (BusinessException e) {
      log.error("Export error:" + e.getMessage(), e);
      return ERROR;
    }
    String title = "异常用车处理记录";
    return exportList(title, "operatedExport", exportlist);
  }
Exemplo n.º 6
0
  /**
   * 页面初始化/查询
   *
   * @return
   */
  public String init() {

    try {
      UserInfo user = getCurrentUser();
      if (info == null) {
        info = new StudentInfo();
      }
      info.setOrganization_id(user.getOrganizationID());
      info.setEnterprise_id(user.getEntiID());
      studentList = (List<StudentInfo>) service.getObjects("User.getStudentList", info);

      if (studentList != null && studentList.size() == 0) {
        // 无用户信息
        addActionError("无任何记录信息!");
        return ERROR;
      }
    } catch (BusinessException e) {
      super.addActionError("数据库操作失败!");
      log.error(e.getMessage());
      return ERROR;
    } catch (Exception e) {
      super.addActionError("数据库操作失败!");
      log.error(e.getMessage());
      return ERROR;
    }

    return SUCCESS;
  }
Exemplo n.º 7
0
  /**
   * 获取运营商列表
   *
   * @return
   */
  private boolean getBusinessInfos() {
    if (businessList.isEmpty()) {
      try {
        businessList = service.getObjects("SimManage.getBusinessInfos", null);
      } catch (BusinessException e) {
        log.error("Query business list error:" + e.getMessage());
        return false;
      } catch (Exception e) {
        log.error("Query business list error:" + e.getMessage());
        return false;
      }
    }

    if (apnTypeList.isEmpty()) {
      try {
        apnTypeList =
            service.getObjects("CommonBaseInfo.getCommonBaseInfos", Constants.APNTYPE_CODE);
      } catch (BusinessException e) {
        log.error(e.getMessage());
        return false;
      } catch (Exception e) {
        log.error(e.getMessage());
        return false;
      }
    }

    return true;
  }
Exemplo n.º 8
0
  /**
   * 页面初始化/查询
   *
   * @return
   */
  public String init() {
    try {
      Map<String, String> map = new HashMap<String, String>();
      map.put("enterpriseName", enterpriseName);
      map.put("enterpriseCode", enterpriseCode);
      map.put("flag", flag);

      if ("2".equals(flag)) {
        enterpriseList =
            (List<EnterprisePopupInfo>)
                service.getObjects("EnterpriseBrowse.getAllEnterpriseInfos", map);
      } else {
        enterpriseList =
            (List<EnterprisePopupInfo>)
                service.getObjects("EnterpriseBrowse.getEnterpriseInfos", map);
      }

      if (enterpriseList != null && enterpriseList.size() == 0) {
        // 无企业信息
        addActionError(getText("common.no.data"));
        return ERROR;
      }
    } catch (BusinessException e) {
      super.addActionError(getText("info.db.error"));
      log.error(e.getMessage());
      return ERROR;
    } catch (Exception e) {
      super.addActionError(getText("info.db.error"));
      log.error(e.getMessage());
      return ERROR;
    }

    return SUCCESS;
  }
Exemplo n.º 9
0
 public String showVehicleDetail() {
   try {
     AnnouncementInfo info =
         (AnnouncementInfo) service.getObject("WxManage.getGonggaoInfoById", announcementInfo);
     String vins = info.getGonggao_veh();
     if (vins != null && !"".equals(vins)) {
       String vinStr = "";
       String[] tmp = vins.split(",");
       for (String v : tmp) {
         vinStr += "'" + v + "',";
       }
       if (!"".equals(vinStr)) vinStr = vinStr.substring(0, vinStr.length() - 1);
       UserInfo user = getCurrentUser();
       VehcileInfo vehinfo = new VehcileInfo();
       vehinfo.setOrganization_id(user.getOrganizationID());
       if (vehicle_ln != null && vehicle_ln != "") {
         vehinfo.setVehicle_ln(vehicle_ln.trim());
       }
       vehinfo.setVehicle_vin(vinStr);
       vehicleList = (List<VehcileInfo>) service.getObjects("WxManage.getInfosVeh", vehinfo);
     }
   } catch (BusinessException e) {
     super.addActionError(getText("info.db.error"));
     log.error(e.getMessage());
     return ERROR;
   } catch (Exception e) {
     super.addActionError(getText("info.db.error"));
     log.error(e.getMessage());
     return ERROR;
   }
   return SUCCESS;
 }
Exemplo n.º 10
0
  public String addAnnouncement() {
    if (null == announcementInfo) {
      return addBefore();
    }
    final String addTitle = getText("announcement.add.info");
    log.info(addTitle);
    try {
      UserInfo user = getCurrentUser();
      announcementInfo.setGonggao_author(user.getUserID());
      announcementInfo.setGonggao_id(UUIDGenerator.getUUID());
      announcementInfo.setEnterprise_id(user.getOrganizationID());
      service.insert("WxManage.insertannouncementInfo", announcementInfo);
    } catch (BusinessException e) {
      log.error(addTitle, e);
      addActionError(e.getMessage());
      return ERROR;
    }
    setMessage("announcement.addsuccess.message");

    this.addOperationLog(formatLog(addTitle, null));
    // 设置操作类型
    this.setOperationType(Constants.INSERT);
    // 设置所属应用系统
    this.setApplyId(Constants.CLW_P_CODE);
    // 设置所属模块
    //        this.setModuleId(MouldId.XCP_DRIVERMANAGE_ADD);
    return SUCCESS;
  }
Exemplo n.º 11
0
 /**
  * 浏览公告信息
  *
  * @return
  */
 public String announcementBrowse() {
   final String browseTitle = getText("wx.announcement.browse.title");
   log.info(browseTitle);
   HttpServletRequest request =
       (HttpServletRequest)
           ActionContext.getContext().get(org.apache.struts2.StrutsStatics.HTTP_REQUEST);
   UserInfo user = getCurrentUser();
   try {
     if (null == announcementInfo) {
       announcementInfo = new AnnouncementInfo();
     }
     announcementInfo.setGonggao_author(author);
     announcementInfo.setStart_time(start_time + " 00:00:00");
     announcementInfo.setEnd_time(end_time + " 23:59:59");
     announcementInfo.setEnterprise_id(user.getOrganizationID());
     String rpNum = request.getParameter("rp");
     String pageIndex = request.getParameter("page");
     String sortName = request.getParameter("sortname");
     String sortOrder = request.getParameter("sortorder");
     announcementInfo.setSortname(sortName);
     announcementInfo.setSortorder(sortOrder);
     int totalCount = 0;
     totalCount = service.getCount("WxManage.getCount", announcementInfo);
     // Page pageObj = new Page(page, totalCount, pageSize, url, param);
     // this.pageBar = PageHelper.getPageBar(pageObj);
     announcementList =
         (List<AnnouncementInfo>)
             service.getObjectsByPage(
                 "WxManage.getInfos",
                 announcementInfo,
                 (Integer.parseInt(pageIndex) - 1) * Integer.parseInt(rpNum),
                 Integer.parseInt(rpNum));
     this.map = getPagination(announcementList, totalCount, pageIndex, rpNum); // 转换map
     //            if (announcementList.size() == 0) {
     //                addActionMessage(getText("nodata.list"));
     //            }
     // 用于添加或者删除时显示消息
     if (null != message) {
       addActionMessage(getText(message));
     }
     // 设置操作描述
     this.addOperationLog(formatLog(browseTitle, null));
     // 设置操作类型
     this.setOperationType(Constants.SELECT);
     // 设置所属应用系统
     this.setApplyId(Constants.CLW_P_CODE);
     // 设置所属模块
     //            this.setModuleId(MouldId.XCP_DRIVERMANAGE_QUERY);
   } catch (BusinessException e) {
     addActionError(getText(e.getMessage()));
     log.error(browseTitle, e);
     return ERROR;
   }
   return SUCCESS;
 }
Exemplo n.º 12
0
  /** 为了行车规划做的学生列表 */
  public String stList() {
    final String vehTitle = "学生选择列表";
    int totalCount = 0;
    UserInfo user = getCurrentUser();

    HttpServletRequest request =
        (HttpServletRequest)
            ActionContext.getContext().get(org.apache.struts2.StrutsStatics.HTTP_REQUEST);
    // 每页显示条数
    String rpNum = request.getParameter("rp");
    // 当前页码
    String pageIndex = request.getParameter("page");
    String sortName = request.getParameter("sortname");
    String sortOrder = request.getParameter("sortorder");

    try {
      if (info == null) {
        info = new StudentInfo();
      }
      info.setOrganization_id(user.getOrganizationID());
      info.setEnterprise_id(user.getEntiID());
      info.setSortname(sortName);
      info.setSortorder(sortOrder);
      // info.setRp(rpNum);
      // info.setPage(pageIndex);
      totalCount = service.getCount("RidingPlan.getCountST", info);

      studentList =
          (List<StudentInfo>)
              service.getObjectsByPage(
                  "RidingPlan.getStudentList",
                  info,
                  (Integer.parseInt(pageIndex) - 1) * Integer.parseInt(rpNum),
                  Integer.parseInt(rpNum));

      this.map = getPagination(studentList, totalCount, pageIndex);

      // 设置操作描述
      // this.addOperationLog(formatLog(vehTitle, null));
      // 设置操作类型
      // this.setOperationType(Constants.SELECT);
      // 设置所属应用系统
      // this.setApplyId(Constants.CLW_P_CODE);
      // 设置所属模块
      // this.setModuleId(MouldId.YTP_OILMANAGE_QUREY_ID);
    } catch (BusinessException e) {
      addActionError(getText(e.getMessage()));
      log.error(vehTitle, e);
      return ERROR;
    }

    return SUCCESS;
  }
Exemplo n.º 13
0
 public String showDetail() {
   try {
     announcementInfo =
         (AnnouncementInfo) service.getObject("WxManage.getGonggaoInfoById", announcementInfo);
   } catch (BusinessException e) {
     super.addActionError(getText("info.db.error"));
     log.error(e.getMessage());
     return ERROR;
   } catch (Exception e) {
     super.addActionError(getText("info.db.error"));
     log.error(e.getMessage());
     return ERROR;
   }
   return SUCCESS;
 }
Exemplo n.º 14
0
  /** 展示详细 */
  public String stShow() {
    final String vehTitle = "学生选择列表";
    int totalCount = 0;
    UserInfo user = getCurrentUser();

    HttpServletRequest request =
        (HttpServletRequest)
            ActionContext.getContext().get(org.apache.struts2.StrutsStatics.HTTP_REQUEST);
    // 每页显示条数
    String rpNum = request.getParameter("rp");
    // 当前页码
    String pageIndex = request.getParameter("page");
    String sortName = request.getParameter("sortname");
    String sortOrder = request.getParameter("sortorder");

    try {
      if (info == null) {
        info = new StudentInfo();
      }
      info.setOrganization_id(user.getOrganizationID());
      info.setEnterprise_id(user.getEntiID());
      info.setSortname(sortName);
      info.setSortorder(sortOrder);
      if (info.getStu_id() == null
          || "none".equals(info.getStu_id())
          || "".equals(info.getStu_id())) {
        info.setStu_id("-1");
      }
      totalCount = service.getCount("RidingPlan.getCountSTShow", info);

      studentList =
          (List<StudentInfo>)
              service.getObjectsByPage(
                  "RidingPlan.getStudentShow",
                  info,
                  (Integer.parseInt(pageIndex) - 1) * Integer.parseInt(rpNum),
                  Integer.parseInt(rpNum));

      this.map = getPagination2(studentList, totalCount, pageIndex);
    } catch (BusinessException e) {
      addActionError(getText(e.getMessage()));
      log.error(vehTitle, e);
      return ERROR;
    }

    return SUCCESS;
  }
Exemplo n.º 15
0
  /**
   * 页面初始化/查询
   *
   * @return
   */
  public String init() {
    ActionContext.getContext()
        .getSession()
        .put(Constants.CURRENT_LOCATION, getText("sim.manage.location"));

    try {
      Map<String, String> map = new HashMap<String, String>();
      map.put("simNumber", SearchUtil.formatSpecialChar(simNumber));
      map.put("phoneNumber", SearchUtil.formatSpecialChar(phoneNumber));

      int totalCount = 0;
      totalCount = service.getCount("SimManage.getCount", map);
      Page pageObj = new Page(page, totalCount, pageSize, url, param);
      this.pageBar = PageHelper.getPageBar(pageObj);

      simList =
          (List<SimInfo>)
              service.getObjectsByPage(
                  "SimManage.getSimInfos", map, pageObj.getStartOfPage(), pageSize);

      if (simList != null && simList.size() == 0) {
        // 无SIM卡信息
        addActionError(getText("common.no.data"));
        return ERROR;
      }

      // 显示操作成功信息
      if (null != message) {
        addActionMessage(getText(message));
      }

    } catch (BusinessException e) {
      super.addActionError(getText("info.db.error"));
      log.error("Query sim infos error:" + e.getMessage());
      return ERROR;
    } catch (Exception e) {
      super.addActionError(getText("info.db.error"));
      log.error("Query sim infos error:" + e.getMessage());
      return ERROR;
    } finally {
      setOperationType(Constants.SELECT, ModuleId.CLW_M_CS_SIM_QUERY_MID);
      addOperationLog("查询SIM卡信息");
    }

    return SUCCESS;
  }
Exemplo n.º 16
0
  /** 异常用车导出 */
  public String exportIllList() {
    List<AlarmEntity> exportlist;
    UserInfo user = getCurrentUser();

    if (searchVO.getOrganization_id() == null || "".equals(searchVO.getOrganization_id())) {
      searchVO.setOrganization_id(user.getOrganizationID());
    }
    try {
      searchVO.setOperate_state("0"); // 未处理
      exportlist = this.service.getObjects("VehicleCheckManage.getVehicleCheckList", searchVO);
    } catch (BusinessException e) {
      log.error("Export error:" + e.getMessage(), e);
      return ERROR;
    }
    String title = "异常用车记录";
    return exportList(title, "illListExport", exportlist);
  }
Exemplo n.º 17
0
 /** 新选学生专用 */
 public String stShow2() {
   final String vehTitle = "学生选择列表";
   try {
     if (info == null) {
       info = new StudentInfo();
     }
     if ("none".equals(stu_id) || "".equals(stu_id)) {
       info.setStu_id("-1");
     } else {
       info.setStu_id(stu_id);
     }
     studentList = (List<StudentInfo>) service.getObjects("RidingPlan.getStudentShow", info);
   } catch (BusinessException e) {
     addActionError(getText(e.getMessage()));
     log.error(vehTitle, e);
     return ERROR;
   }
   return SUCCESS;
 }
Exemplo n.º 18
0
  public void getupstudentname() {
    final String vehTitle = "取得学生姓名";
    String studentname = "";
    try {
      if (info == null) {
        info = new StudentInfo();
      }
      info.setUpstudentids(upstudentids);
      studentname = (String) service.getObject("RidingPlan.getupstudentname", info);

      HttpServletResponse response = ServletActionContext.getResponse();
      response.setCharacterEncoding("UTF-8");

      try {
        response.getWriter().write(studentname);
      } catch (IOException ioException) {;
      }
    } catch (BusinessException e) {
      addActionError(getText(e.getMessage()));
      log.error(vehTitle, e);
    }
  }
Exemplo n.º 19
0
  /** 为了行车规划做的新学生列表 */
  public String stList2() {
    final String vehTitle = "学生选择列表";
    UserInfo user = getCurrentUser();

    try {
      if (info == null) {
        info = new StudentInfo();
      }
      info.setOrganization_id(user.getOrganizationID());
      info.setEnterprise_id(user.getEntiID());
      info.setStu_name(stu_name);
      info.setStu_code(stu_code);
      info.setStu_class(stu_class);
      info.setStu_school(stu_school);
      info.setSite_desc(site_desc);
      info.setUpnotexist(upnotexist);
      info.setDownnotexist(downnotexist);
      info.setRoute_id(route_id);
      info.setDelupexistdata(delupexistdata);
      info.setDeldownexistdata(deldownexistdata);
      info.setSearchparam(searchparam);
      studentList = (List<StudentInfo>) service.getObjects("RidingPlan.getStudentList", info);
      // 设置操作描述
      // this.addOperationLog(formatLog(vehTitle, null));
      // 设置操作类型
      // this.setOperationType(Constants.SELECT);
      // 设置所属应用系统
      // this.setApplyId(Constants.CLW_P_CODE);
      // 设置所属模块
      // this.setModuleId(MouldId.YTP_OILMANAGE_QUREY_ID);
    } catch (BusinessException e) {
      addActionError(getText(e.getMessage()));
      log.error(vehTitle, e);
      return ERROR;
    }

    return SUCCESS;
  }
Exemplo n.º 20
0
  /**
   * 删除SIM卡信息
   *
   * @return
   */
  public String delete() {
    UserInfo currentUser =
        (UserInfo) ActionContext.getContext().getSession().get(Constants.USER_SESSION_KEY);
    if (simInfo != null) {
      // 设置修改用户
      simInfo.setModifier(currentUser.getUserID());
      // 设置SIM卡主键值
      simInfo.setSimId(simId);
    }

    try {
      int countNum = service.getCount("SimManage.getSIMRegisteredCount", simId);

      if (countNum > 0) {
        setMessage("sim.delete.notpermission");
        log.error("The sim is registered");
        return ERROR;
      }

      // 删除SIM卡信息
      service.update("SimManage.updateSimValid", simInfo);
      setMessage("sim.delete.success");
    } catch (BusinessException e) {
      setMessage("info.db.error");
      log.error("Delete sim error:" + e.getMessage());
      return ERROR;
    } catch (Exception e) {
      setMessage("info.db.error");
      log.error("Delete sim error:" + e.getMessage());
      return ERROR;
    } finally {
      setOperationType(Constants.DELETE, ModuleId.CLW_M_CS_SIM_DELETE_MID);
      addOperationLog("删除SIM卡信息");
    }

    return SUCCESS;
  }
Exemplo n.º 21
0
 /**
  * 转换Map
  *
  * @param oilusedList
  * @param totalCountDay
  * @param pageIndex
  * @return
  */
 public Map<String, Object> getPagination(
     List<AnnouncementInfo> announcementList, int totalCount, String pageIndex, String rpNum) {
   List<Map<String, Object>> mapList = new ArrayList<Map<String, Object>>();
   Map<String, Object> mapData = new LinkedHashMap<String, Object>();
   try {
     for (int i = 0; i < announcementList.size(); i++) {
       AnnouncementInfo s = (AnnouncementInfo) announcementList.get(i);
       String[] vehTmp = new String[0];
       int wxUserCount = 0;
       if (s.getGonggao_veh() != null && !"".equals(s.getGonggao_veh())) {
         vehTmp = s.getGonggao_veh().split(",");
         String veh = "'" + s.getGonggao_veh().replaceAll(",", "','") + "'";
         wxUserCount = (Integer) service.getObject("WxManage.getWxUserCount", veh);
       }
       Map<String, Object> cellMap = new LinkedHashMap<String, Object>();
       cellMap.put("id", s.getGonggao_id());
       cellMap.put(
           "cell",
           new Object[] {
             (i + 1) + (Integer.parseInt(pageIndex) - 1) * Integer.parseInt(rpNum),
             s.getGonggao_title(),
             s.getUser_name(),
             s.getGonggao_date(),
             vehTmp.length,
             wxUserCount
           });
       mapList.add(cellMap);
     }
     mapData.put("page", pageIndex); // 从前台获取当前第page页
     mapData.put("total", totalCount); // 从数据库获取总记录数
     mapData.put("rows", mapList);
   } catch (BusinessException e) {
     addActionError(getText(e.getMessage()));
   }
   return mapData;
 }
Exemplo n.º 22
0
 /**
  * 按记录导出
  *
  * @return
  */
 public String exportRecord() {
   String exportTitle = "驾驶员刷卡记录";
   List<DriverStatInfo> list = new ArrayList<DriverStatInfo>();
   try {
     if ("1".equals(exportObj.getSearchTimeType())) { // 按时段查询
       String start_time = exportObj.getBegTime();
       String end_time = exportObj.getEndTime();
       exportObj.setBegTime(start_time + " 00:00:00");
       exportObj.setEndTime(end_time + " 23:59:59");
     } else {
       String month = exportObj.getMonth();
       String first = month + "-01";
       Calendar cal = Calendar.getInstance();
       cal.set(Calendar.YEAR, Integer.parseInt(month.substring(0, 4)));
       cal.set(Calendar.MONTH, Integer.parseInt(month.substring(5, 7)));
       cal.set(Calendar.DAY_OF_MONTH, 1);
       cal.add(Calendar.DAY_OF_MONTH, -1);
       exportObj.setBegTime(first + " 00:00:00");
       System.out.println(cal.get(Calendar.DAY_OF_MONTH));
       exportObj.setEndTime(month + "-" + cal.get(Calendar.DAY_OF_MONTH) + " 23:59:59");
     }
     String driverIds = exportObj.getDriverId();
     String searchIds = "";
     if (driverIds.length() > 0) {
       String[] Ids = driverIds.split(","); // 字符串转字符数组
       for (String id : Ids) {
         searchIds = searchIds + "'" + id + "',";
       }
       exportObj.setDriverId(searchIds.substring(0, searchIds.length() - 1));
     }
     UserInfo user =
         (UserInfo) ActionContext.getContext().getSession().get(Constants.USER_SESSION_KEY);
     exportObj.setEnterpriseId(user.getOrganizationID());
     if ("1".equals(exportObj.getState())) exportObj.setState("UP");
     else if ("2".equals(exportObj.getState())) exportObj.setState("DOWN");
     list =
         (List<DriverStatInfo>) service.getObjects("Drivershuaka.getDriverRecordList", exportObj);
   } catch (BusinessException e) {
     setMessage("info.db.error");
     log.error(exportTitle + "Export Data error:" + e.getMessage());
     return ERROR;
   } catch (Exception e) {
     e.printStackTrace();
     setMessage("info.db.error");
     log.error(exportTitle + "Export Data error:" + e.getMessage());
     return ERROR;
   }
   String filePath = "";
   OutputStream outputStream = null;
   try {
     filePath = "/tmp/" + UUIDGenerator.getUUID() + "DriverShuaka.xls";
     File file = new File(filePath);
     if (!file.getParentFile().exists()) {
       file.getParentFile().mkdirs();
     }
     outputStream = new FileOutputStream(filePath);
     IEExcelExporter excelExporter = new IEExcelExporter(outputStream);
     if ("1".equals(exportObj.getSearchTimeType())) // 按时段查询
     excelExporter.setTitle(
           exportTitle
               + "("
               + exportObj.getBegTime().substring(0, 10)
               + "——"
               + exportObj.getEndTime().substring(0, 10)
               + ")");
     else excelExporter.setTitle(exportTitle + "(" + exportObj.getMonth() + ")");
     if (null == list || list.size() < 1) {
       list.add(new DriverStatInfo());
     }
     excelExporter.putAutoExtendSheets("exportDriverShuaka", 0, list);
     // 将Excel写入到指定的流中
     excelExporter.write();
   } catch (FileNotFoundException e) {
     setMessage("file.export.error");
     log.error(exportTitle + "Export Data error:" + e.getMessage());
     return ERROR;
   } catch (Exception e) {
     setMessage("file.export.error");
     log.error(exportTitle + "Export Data error:" + e.getMessage());
     return ERROR;
   } finally {
     // 关闭流
     if (null != outputStream) {
       try {
         outputStream.close();
       } catch (IOException e) {;
       }
     }
   }
   // 设置下载文件属性
   HttpServletResponse response = ServletActionContext.getResponse();
   response.setHeader(
       "Content-disposition",
       "attachment;filename=driver_shuaka_info-" + DateUtil.getCurrentDayTime() + ".xls");
   response.setContentType("application/msexcel; charset=\"utf-8\"");
   FileInputStream fileInputStream = null;
   OutputStream out = null;
   try {
     // 下载刚生成的文件
     fileInputStream = new FileInputStream(filePath);
     out = response.getOutputStream();
     int i = 0;
     while ((i = fileInputStream.read()) != -1) {
       out.write(i);
     }
   } catch (FileNotFoundException e) {
     setMessage("file.export.error");
     log.error("Export student error:" + e.getMessage());
     return ERROR;
   } catch (Exception e) {
     setMessage("file.export.error");
     log.error("Export student error:" + e.getMessage());
     return null;
   } finally {
     // 关闭流
     if (null != fileInputStream) {
       try {
         fileInputStream.close();
       } catch (IOException e) {;
       }
     }
     if (null != out) {
       try {
         out.close();
       } catch (IOException e) {;
       }
     }
   }
   // 导出文件成功
   return null;
 }
Exemplo n.º 23
0
  /**
   * 导出SIM卡信息
   *
   * @return
   */
  public String exportSim() {
    Map<String, String> map = new HashMap<String, String>();
    map.put("simNumber", simNumber);
    map.put("phoneNumber", phoneNumber);
    List<SimInfo> list = new ArrayList<SimInfo>();
    try {
      list = (List<SimInfo>) service.getObjects("SimManage.getSimInfos", map);
    } catch (BusinessException e) {
      setMessage("info.db.error");
      log.error("Export sim error:" + e.getMessage());
      return ERROR;
    } catch (Exception e) {
      setMessage("info.db.error");
      log.error("Export sim error:" + e.getMessage());
      return ERROR;
    }

    String filePath = "";
    OutputStream outputStream = null;
    try {
      // String realPath =
      // ServletActionContext.getServletContext().getRealPath("/");
      // realPath = realPath.replace("\\", "/");
      // realPath = realPath + "exportfile/";

      filePath = "/tmp/" + UUIDGenerator.getUUID() + "Sim.xls";

      File file = new File(filePath);
      if (!file.getParentFile().exists()) {
        file.getParentFile().mkdirs();
      }

      outputStream = new FileOutputStream(filePath);
      // 使用Excel导出器IEExcelExporter
      IEExcelExporter excelExporter = new IEExcelExporter(outputStream);
      excelExporter.setTitle("SIM卡信息");

      excelExporter.putAutoExtendSheets("exportSim", 0, list);
      // 将Excel写入到指定的流中
      excelExporter.write();
    } catch (FileNotFoundException e) {
      setMessage("file.export.error");
      log.error("Export sim error:" + e.getMessage());
      return ERROR;
    } catch (Exception e) {
      setMessage("file.export.error");
      log.error("Export sim error:" + e.getMessage());
      return ERROR;
    } finally {
      // 关闭流
      if (null != outputStream) {
        try {
          outputStream.close();
        } catch (IOException e) {;
        }
      }
    }

    // 设置下载文件属性
    HttpServletResponse response = ServletActionContext.getResponse();
    response.setHeader("Content-disposition", "attachment;filename=Sim.xls");
    response.setContentType("application/msexcel; charset=\"utf-8\"");

    FileInputStream fileInputStream = null;
    OutputStream out = null;
    try {
      // 下载刚生成的文件
      fileInputStream = new FileInputStream(filePath);
      out = response.getOutputStream();
      int i = 0;
      while ((i = fileInputStream.read()) != -1) {
        out.write(i);
      }
    } catch (FileNotFoundException e) {
      setMessage("file.export.error");
      log.error("Export sim error:" + e.getMessage());
      return ERROR;
    } catch (Exception e) {
      setMessage("file.export.error");
      log.error("Export sim error:" + e.getMessage());
      return null;
    } finally {
      // 关闭流
      if (null != fileInputStream) {
        try {
          fileInputStream.close();
        } catch (IOException e) {;
        }
      }
      if (null != out) {
        try {
          out.close();
        } catch (IOException e) {;
        }
      }
      setOperationType(Constants.EXPORT, ModuleId.CLW_M_CS_SIM_EXPORT_MID);
      addOperationLog("导出SIM卡信息");
    }
    // 导出文件成功
    return null;
  }
Exemplo n.º 24
0
  /**
   * 导入SIM卡信息
   *
   * @return
   */
  public String importSim() {
    if (null == file
        || null == fileContentType
        || null == fileFileName
        || fileFileName.length() < 3) {
      getBusinessInfos();
      log.info(getText("file.not.exist"));
      addActionError(getText("file.not.exist"));
      return ERROR;
    } else if (!"xls"
        .equals(fileFileName.substring(fileFileName.length() - 3, fileFileName.length()))) {
      // 判断是否是excel类型文件
      getBusinessInfos();
      addActionError(getText("file.type.err"));
      log.info(getText("file.type.err"));
      return ERROR;
    }

    List<SimInfo> list = new ArrayList<SimInfo>();

    FileInputStream fis = null;
    try {
      fis = new FileInputStream(file);
      IEExcelImporter excelImplortor = null;
      try {
        excelImplortor = new IEExcelImporter(fis);
      } catch (Exception e) {
        setMessage("file.import.error");
        log.error("Import file error:" + e.getMessage());
      }

      list = excelImplortor.getSheetData("importSim", 0);

      String errMessage = getFileContentError(excelImplortor.getErrorMessage());

      if (errMessage.length() > 0) {
        getBusinessInfos();
        addActionError(errMessage);
        return ERROR;
      }
    } catch (Exception e) {
      getBusinessInfos();
      setMessage(getText("file.import.error"));
      log.error("Import file error:" + e.getMessage());
      return ERROR;
    } finally {
      // 关闭流
      if (null != fis) {
        try {
          fis.close();
        } catch (IOException e) {;
        }
      }
    }

    // 格式化数据
    list = formatSimInfos(list);

    if (list.size() == 0) {
      getBusinessInfos();
      // 文件中无内容
      addActionMessage(getText("file.content.empty"));
      return ERROR;
    } else {
      try {
        // 导入SIM卡信息
        simManageService.importSimInfos(list);
        setMessage("file.import.success");
      } catch (BusinessException e) {
        getBusinessInfos();
        addActionError(getText("info.db.error"));
        log.error("Import sim error:" + e.getMessage());
        return ERROR;
      } catch (Exception e) {
        getBusinessInfos();
        addActionError(getText("info.db.error"));
        log.error("Import sim error:" + e.getMessage());
        return ERROR;
      } finally {
        setOperationType(Constants.IMPORT, ModuleId.CLW_M_CS_SIM_IMPORT_MID);
        addOperationLog("导入SIM卡信息");
      }
    }

    return SUCCESS;
  }