Ejemplo n.º 1
0
 @RequestMapping(value = "/removeGPSInfo.acl")
 public String removeGPSInfo(HttpServletRequest request, HttpServletResponse response)
     throws Exception {
   Map<String, String> model = QueryUtil.getRequestParameterMapByAjax(request);
   GPSInfo ownInfo = new GPSInfo();
   this.baseService.copyAndOverrideExistedValueFromStringMap(model, ownInfo, null);
   // ownInfo.setId(model.get("id"));
   ownInfo = (GPSInfo) this.baseService.findEntityByID(GPSInfo.class, model.get("id"));
   //	 Iterator<OwnAccount> set=ownInfo.getOwnAccounts().iterator();
   //		 while(set.hasNext()){
   //			 OwnAccount s =set.next();
   //			 this.baseService.removeEntity(s);
   //		 }
   //		 this.baseService.removeAllEntites(ownInfo.getOwnAccounts());
   this.baseService.removeEntity(ownInfo);
   if (logger.isInfoEnabled()) {
     logger.info("删除成功!");
   }
   return null;
 }
Ejemplo n.º 2
0
  @RequestMapping(value = "/updateGPSInfo.acl")
  public String updateGPSInfo(HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    Map<String, String> model = QueryUtil.getRequestParameterMapByAjax(request);
    GPSInfo ownInfo = new GPSInfo();
    String custid = model.get("cust_name");
    String dealerid = model.get("dealer_name");
    String contractid = model.get("contract_number");
    String equipid = model.get("chassisnum");
    this.baseService.copyAndOverrideExistedValueFromStringMap(model, ownInfo, null);
    ownInfo.setId(model.get("id"));
    // 获取承租人
    if (custid != null && !"".equals(custid) && "" != custid) {
      CustInfo cust = this.baseService.findEntityByID(CustInfo.class, custid);
      ownInfo.setCustId(cust);
    }
    // 获取经销商
    if (dealerid != null && !"".equals(dealerid) && "" != dealerid) {
      CustInfo dealer = this.baseService.findEntityByID(CustInfo.class, dealerid);
      ownInfo.setCustDealer(dealer);
    }
    // 获取合同
    if (contractid != null && !"".equals(contractid) && "" != contractid) {
      ContractInfo contract = this.baseService.findEntityByID(ContractInfo.class, contractid);
      ownInfo.setContractId(contract);
    }

    // 车架号
    if (equipid != null && !"".equals(equipid) && "" != equipid) {
      ContractEquip equip = this.baseService.findEntityByID(ContractEquip.class, equipid);
      ownInfo.setEquipID(equip);
    }
    this.baseService.updateEntity(ownInfo);
    if (logger.isInfoEnabled()) {
      logger.info("修改成功!");
    }
    return null;
  }
Ejemplo n.º 3
0
  @Override
  public String insertFinanceReport(HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    // 获得上传的附件
    InputStream is = null;
    MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
    MultipartFile multipartFile = multipartRequest.getFile("tableImportTemplate");
    if (null == multipartFile) {
      throw new BusinessException("没有上传财务报表");
    }
    // 上传的参数据
    Map<String, String> model = QueryUtil.getRequestParameterMapByAjax(request);
    // 列名对象解析
    String financeparams = model.get("parames");
    if (null == financeparams
        || "".equals(financeparams)
        || "null".equalsIgnoreCase(financeparams.trim())) {
      throw new BusinessException("没有对Excel的配置");
    }
    try {
      BaseFile bf = templateService.saveUpFiletoService(multipartFile, model);
      String custid = "";
      CustInfo custinfo = null;
      if (model.containsKey("custid")) {
        custid = model.get("custid");
        custinfo = this.tableService.findEntityByID(CustInfo.class, custid);
        if (null == custinfo) {
          throw new BusinessException("给定的客户的ID没有找到客户");
        }
      } else {
        throw new BusinessException("没有给定客户的ID");
      }

      Workbook wb = null;
      is = multipartFile.getInputStream();
      String importFileName = multipartFile.getOriginalFilename().toLowerCase();
      if (importFileName.endsWith("xlsx")) {
        wb = PoiExcelUtil.readWorkbook(is, ExcelVersionEnum.VERSION2007);
      } else {
        wb = PoiExcelUtil.readWorkbook(is, ExcelVersionEnum.VERSION2003);
      }
      List<FinanceReportParamBean> inintParam = this.getImportParams(financeparams);
      if (inintParam.size() > 0) {
        for (FinanceReportParamBean param : inintParam) {
          Map<String, FinanceReportBean> Mapfield =
              this.getClassFieldExcel(param.getSheeName(), param.getTargetClass());
          if (Mapfield.keySet().size() > 0) {
            try {
              Sheet sheet = wb.getSheet(param.getSheeName());
              if (null != sheet) {
                List finance =
                    (List)
                        this.getFinanceReprotEntitysByConfig(sheet, Mapfield, param, bf, custinfo);
                // 保证实体
                if (null != finance) {
                  this.tableService.saveOrUpdateAllEntities(finance);
                }
              } else {
                throw new BusinessException("上传的EXCEL中没有" + param.getSheeName());
              }
            } catch (Exception e) {
              // TODO Auto-generated catch block
              throw new BusinessException(
                  "上传的EXCEL中没有" + param.getSheeName() + ":" + e.getMessage());
            }

          } else {
            throw new BusinessException("excel中" + param.getSheeName() + "没有配置相应的类");
          }
        }
      } else {
        throw new BusinessException("没有对Excel的配置");
      }
    } catch (BusinessException b) {
      throw new BusinessException(b.getMessage());
    } catch (Exception e) {
      e.printStackTrace();
      // TODO Auto-generated catch block
      throw new BusinessException(e.getMessage());
    }
    return "成功";
  }