/**
   * 设置活动的图片信息
   *
   * @param file_array 上传文件信息
   * @param findActivity 活动对象
   * @param dictPath 存储路径
   */
  private void setFileData(String[] file_array, FindActivity findActivity, String dictPath) {

    // 设置广告图片
    if (null != file_array && file_array.length > 0) {

      String fileJsonData = file_array[0];
      System.out.println("**" + file_array[0]);
      Map<String, Object> map = JSONUtil.getMap(fileJsonData);
      if (map.get("id") == null) {

        String saveName = map.get("saveName") + "";
        String savePath = "";
        try {
          savePath = Base64Util.decodeBytesInAndroid(map.get("savePath") + "");
        } catch (IOException e1) {
          e1.printStackTrace();
        }

        findActivity.setDiskFileName(saveName);
        findActivity.setFileName(map.get("fileName") + "");
        findActivity.setFileSize(Long.valueOf(map.get("fileSize") + ""));
        findActivity.setFileSuffix(
            saveName.substring(saveName.lastIndexOf(".") + 1, saveName.length()));
        findActivity.setRootPath(dictPath);

        // 日期作为相对路径
        SimpleDateFormat formatdate = new SimpleDateFormat("yyyy/MM/dd/");
        String relative_path = formatdate.format(new Date());
        findActivity.setRelativePath(relative_path);
        File filePath = new File(dictPath + relative_path);
        if (!filePath.exists()) {
          filePath.mkdirs();
        }
        try {

          if (!new File(dictPath + relative_path + saveName).exists()) {
            FileUtils.copyFile(new File(savePath), new File(dictPath + relative_path + saveName));
          }
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    }
  }
  /**
   * 保存操作
   *
   * @param request 访问对象
   * @param op 操作类型 add:添加 modify:修改
   * @param findActivity 活动对象
   * @param dictPath 字典维护的保存路径
   */
  @Transactional(rollbackFor = Exception.class)
  public void save(
      HttpServletRequest request,
      String op,
      FindActivity findActivity,
      String dictPath,
      SysUser sysUser) {

    String[] goodsId_array = request.getParameterValues("goodsId");
    String[] file_array = request.getParameterValues("activity_file");

    if (op.equals("add")) {

      findActivity.setUnitId(sysUser.getUnitId());
      findActivity.setUserId(sysUser.getId());
      findActivity.setActivityStatus(0);
      findActivity.setCreateDate(DateUtil.getSystemTime());
      // 图片
      setFileData(file_array, findActivity, dictPath);
      findActivityDao.add(findActivity);
    } else {

      FindActivity findActivity2 = findActivityDao.get(findActivity.getId());
      findActivity.setCreateDate(findActivity2.getCreateDate());
      findActivity.setUpdateDate(DateUtil.getSystemTime());
      findActivity.setUserId(sysUser.getId());
      findActivity.setUnitId(sysUser.getUnitId());
      findActivity.setActivityStatus(0);

      findActivity.setFileName(findActivity2.getFileName());
      findActivity.setDiskFileName(findActivity2.getDiskFileName());
      findActivity.setRootPath(findActivity2.getRootPath());
      findActivity.setRelativePath(findActivity2.getRelativePath());
      findActivity.setFileSize(findActivity2.getFileSize());
      findActivity.setFileSuffix(findActivity2.getFileSuffix());

      // 图片
      setFileData(file_array, findActivity, dictPath);
      int flag = findActivityDao.update(findActivity);

      // 删除原消息推送
      if (flag > 0) {
        Map<String, Object> postMap = new HashMap<String, Object>();
        postMap.put("sourceType", PushUtil.PushLoginType.datasourceType.value);
        postMap.put("sourceId", findActivity.getId());
        DataRequestUtil.getRequestData("msg/deleteUnpushedMsg.htm", postMap);
      }

      // 删除商品关联
      // findActivityGoodsDao.deleteByActivityId(findActivity.getId());
    }

    // 添加活动商品关联,暂时不用关联商品
    if (null != goodsId_array && goodsId_array.length > 0) {

      List<FindActivityGoods> activityGoodsList = new ArrayList<FindActivityGoods>();
      for (String goodsId : goodsId_array) {
        FindActivityGoods findActivityGoods = new FindActivityGoods();
        findActivityGoods.setActivityId(findActivity.getId());
        findActivityGoods.setGoodsId(Long.valueOf(goodsId));
        activityGoodsList.add(findActivityGoods);
      }
      findActivityGoodsDao.addBatch(activityGoodsList);
    }

    // 消息推送
    if (1 == findActivity.getIfSetPush() && 0 == findActivity.getActivityStatus()) {
      pushMsg(findActivity);
    }
  }