コード例 #1
0
 @RequestMapping(params = "method=setCategoryPage")
 public void setCategoryPage(HttpServletRequest request, HttpServletResponse response)
     throws Exception {
   String jsonStr = "[]";
   StringBuffer sb = new StringBuffer("[");
   Long shopId = WebUtil.getShopId(request);
   Long startPageNo = 1l;
   RFITxnService txnService = ServiceManager.getService(RFITxnService.class);
   CategoryServiceSearchDTO categoryServiceSearchDTO = new CategoryServiceSearchDTO();
   categoryServiceSearchDTO.setServiceDTOs(
       txnService.getServicesByCategory(
           shopId,
           categoryServiceSearchDTO.getServiceName(),
           categoryServiceSearchDTO.getCategoryName(),
           CategoryType.BUSINESS_CLASSIFICATION,
           startPageNo,
           PAGE_SIZE));
   for (ServiceDTO service : categoryServiceSearchDTO.getServiceDTOs()) {
     String name = service.getName() == null ? "" : service.getName();
     String id = service.getId() == null ? "" : service.getId().toString();
     sb.append("{\"name\":\"" + name + "\",");
     sb.append("\"id\":\"" + id + "\"},");
   }
   sb.replace(sb.length() - 1, sb.length(), "]");
   jsonStr = sb.toString();
   PrintWriter writer = response.getWriter();
   writer.write(jsonStr);
   writer.close();
 }
コード例 #2
0
 @ResponseBody
 @RequestMapping(params = "method=getCategoryItemSearch")
 public Object getCategoryItemSearch(
     ModelMap model,
     HttpServletRequest request,
     CategoryServiceSearchDTO categoryServiceSearchDTO) {
   RFITxnService txnService = ServiceManager.getService(RFITxnService.class);
   Long shopId = WebUtil.getShopId(request);
   Long startPageNo = 1l;
   if (StringUtils.isNotBlank(request.getParameter("startPageNo"))
       && NumberUtil.isNumber(request.getParameter("startPageNo"))) {
     startPageNo = NumberUtil.longValue(request.getParameter("startPageNo"));
   }
   Map<String, Object> returnMap = new HashMap<String, Object>();
   try {
     if (categoryServiceSearchDTO == null) {
       categoryServiceSearchDTO = new CategoryServiceSearchDTO();
     }
     Pager pager = null;
     // 全部
     if (categoryServiceSearchDTO.getCategoryServiceType() == null) {
       categoryServiceSearchDTO.setServiceDTOs(
           txnService.getServicesByCategory(
               shopId,
               categoryServiceSearchDTO.getServiceName(),
               categoryServiceSearchDTO.getCategoryName(),
               CategoryType.BUSINESS_CLASSIFICATION,
               startPageNo,
               PAGE_SIZE));
       pager =
           new Pager(
               txnService.countServiceByCategory(
                   shopId,
                   categoryServiceSearchDTO.getServiceName(),
                   categoryServiceSearchDTO.getCategoryName(),
                   CategoryType.BUSINESS_CLASSIFICATION),
               startPageNo.intValue(),
               (int) PAGE_SIZE);
     }
     categoryServiceSearchDTO.setCategoryDTOs(txnService.getCategoryByShopId(shopId));
     returnMap.put("pager", pager);
     returnMap.put("categoryServiceSearchDTO", categoryServiceSearchDTO);
     returnMap.put("result", new Result(true));
     return returnMap;
   } catch (Exception e) {
     LOG.debug("/category.do");
     LOG.debug("method=getCategoryItemSearch");
     LOG.error(e.getMessage(), e);
     returnMap.put("result", new Result(false));
     return returnMap;
   }
 }
コード例 #3
0
 /*
   初始化摄像头配置
 */
 @ResponseBody
 @RequestMapping(params = "method=initCameraConfigList")
 public Object initCameraConfigList(HttpServletRequest request, Integer page, Integer rows) {
   Long shopId = null;
   shopId = WebUtil.getShopId(request);
   ICameraService cameraService = ServiceManager.getService(ICameraService.class);
   Map<String, Object> result = new HashMap<String, Object>();
   try {
     int total = cameraService.getCountCameraConfigByShopId(StringUtil.valueOf(shopId));
     Pager pager = new Pager(total, page, rows);
     result.put("total", total);
     if (total > 0) {
       List<CameraConfigDTO> rowsList = new ArrayList<CameraConfigDTO>();
       rowsList = cameraService.getCameraConfigByShopId(shopId.toString());
       result.put("rows", rowsList);
     }
   } catch (Exception e) {
     LOG.error(e.getMessage(), e);
   }
   return result;
 }
コード例 #4
0
 /*
   初始化到店车辆记录
 */
 @ResponseBody
 @RequestMapping(params = "method=initCameraRecordList")
 public Object initCameraRecordList(HttpServletRequest request, CameraSearchCondition condition) {
   Long shopId = null;
   shopId = WebUtil.getShopId(request);
   condition.setShopId(shopId.toString());
   ICameraService cameraService = ServiceManager.getService(ICameraService.class);
   Map<String, Object> result = new HashMap<String, Object>();
   try {
     int total = cameraService.getCameraRecordDTOListAccountByShopId(condition);
     Pager pager = new Pager(total, condition.getPage(), condition.getRows());
     result.put("total", total);
     List<CameraRecordDTO> rowsList = new ArrayList<CameraRecordDTO>();
     if (total > 0) {
       rowsList = cameraService.getCameraRecordListByShopId(pager, condition);
     }
     result.put("rows", rowsList);
   } catch (Exception e) {
     LOG.error(e.getMessage(), e);
   }
   return result;
 }
コード例 #5
0
  /**
   * 导入前: 1.读取excel文件表头 2.保存导入记录(文件)到数据库
   *
   * @param request
   * @return
   */
  @RequestMapping(params = "method=uploadExcel")
  public void getExcelHeader(HttpServletRequest request, HttpServletResponse response) {
    IImportService importService = ServiceManager.getService(IImportService.class);
    IPrivilegeService privilegeService = ServiceManager.getService(IPrivilegeService.class);
    Map result = new HashMap();
    try {
      MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
      MultipartFile multipartFile = multipartRequest.getFile("selectfile");
      String fileName = multipartFile.getOriginalFilename();
      if (!validateOrderType(fileName)) { // todo 不起作用
        response.setHeader("Charset", "UTF-8");
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter writer = response.getWriter();
        result.put("orderImportMsg", "上传文件名无法识别,请使用标准模板名!");
        String resultStr = JsonUtil.mapToJson(result);
        writer.write(resultStr);
        writer.flush();
        writer.close();
        return;
      }
      InputStream inputStream = multipartFile.getInputStream();
      if (inputStream.available() > ImportConstants.UPLOAD_FILE_MAX_SIZE) {
        PrintWriter writer = response.getWriter();
        writer.write(
            "上传文件大小不能超过" + NumberUtil.byteToMillion(ImportConstants.UPLOAD_FILE_MAX_SIZE) + "M!");
        writer.flush();
        writer.close();
        return;
      }
      byte[] fileContent = IOUtil.readFromStream(inputStream);
      // 先读取表头
      ImportContext importContext = new ImportContext();
      importContext.setFileContent(fileContent);
      importContext.setFileName(fileName);
      List<String> headList = importService.parseHead(importContext);
      if (headList == null || headList.isEmpty()) {
        result.put("message", "解析导入文件头部失败!");
      } else {
        result.put("headList", headList);
      }

      // 再存入数据库
      ImportRecordDTO importRecordDTO = new ImportRecordDTO();
      importRecordDTO.setShopId(WebUtil.getShopId(request));
      importRecordDTO.setStatus(ImportConstants.Status.STATUS_WAITING);
      importRecordDTO.setType(ImportConstants.Type.TYPE_ORDER);
      importRecordDTO.setFileName(fileName);
      importRecordDTO.setFileContent(fileContent);
      importRecordDTO = importService.createImportRecord(importRecordDTO);
      if (importRecordDTO == null || importRecordDTO.getId() == null) {
        result.put("message", "保存导入记录出错!");
      } else {
        result.put("importRecordId", String.valueOf(importRecordDTO.getId()));
      }
      result.put(
          "systemFieldList",
          getOrderFieldList(
              PrivilegeRequestProxy.verifierShopVersionResourceProxy(
                  request, LogicResource.WEB_VERSION_WHOLESALERS)));
      String resultStr = JsonUtil.mapToJson(result);
      response.setHeader("Charset", "UTF-8");
      response.setContentType("text/html;charset=UTF-8");
      PrintWriter writer = response.getWriter();
      writer.write(resultStr);
      writer.flush();
      writer.close();
    } catch (Exception e) {
      LOG.error("上传文件出现异常!");
      LOG.error(e.getMessage(), e);
    }
  }