private List<Score> generateProblemScore(
     JSONObject jsonInfoObj, String entityId, WeixinUser weixinUser, EntityAccount entityAccount) {
   // 获取问题
   Score score = null;
   List<Score> scoreList = new ArrayList<Score>();
   JSONObject jsonObj = null;
   // 实体用户信息
   if (jsonInfoObj.containsKey("problemScore")) {
     JSONArray jsonArray = jsonInfoObj.getJSONArray("problemScore");
     Integer var = null;
     if (!CollectionUtils.isEmpty(jsonArray)) {
       for (Object obj : jsonArray) {
         jsonObj = (JSONObject) obj;
         score = new Score();
         score.setId(CommonUtil.GeneGUID());
         score.setAppraisalId(entityId);
         score.setProblemId(jsonObj.getString("id"));
         var = jsonObj.getInteger("score");
         score.setScore((var == null ? 0 : var));
         score.setOpinion(jsonObj.getString("opinion"));
         score.setRaterId(weixinUser.getUserid());
         score.setRaterName(weixinUser.getName());
         score.setUserId(entityAccount.getAccountId());
         score.setUserName(entityAccount.getAccountName());
         scoreList.add(score);
       }
     }
   }
   return scoreList;
 }
  /**
   * 我发起的签到信息
   *
   * @return
   */
  @RequestMapping(value = "myLaunchSignDetailView", method = RequestMethod.GET)
  public ModelAndView myLaunchSignDetailView() {
    ModelAndView modelAndView = super.createModelAndView("myLaunch_signDetail");
    String id = HttpRequestUtil.getInstance().getString("id");
    // 需要获取签到信息
    Map<String, Object> dataMap = signService.getSignById(id);
    modelAndView.addObject("signInfo", dataMap);
    EntityAccount entityAccount = new EntityAccount();
    entityAccount.setEntityId(id);
    entityAccount.setEntityType(EntityType.QD.value());
    // 获取应签到用户
    List<EntityAccount> entityAccountList = entityAccountService.getEntityAccount(entityAccount);
    // 获取所有应签到用户
    SignUser signUser = new SignUser();
    signUser.setSignId(id);
    List<Map<String, Object>> signUserList = signUserService.getSignUser(signUser);
    // 查询已经签到用户
    List<String> userList = new ArrayList<String>();
    String userId = null;
    for (Map<String, Object> map : signUserList) {
      userId = StringUtil.getString(map.get("userId"));
      if (!userList.contains(userId)) {
        userList.add(userId);
      }
    }
    // 应该签到者
    StringBuffer shouldSignUserInfo = new StringBuffer();
    // 已签到者
    StringBuffer signUserInfo = new StringBuffer();
    // 未签到者
    StringBuffer noSignUserInfo = new StringBuffer();

    // 遍历应签到人
    for (int i = 0, size = (entityAccountList == null) ? 0 : entityAccountList.size();
        i < size;
        i++) {
      entityAccount = entityAccountList.get(i);
      userId = entityAccount.getAccountId();
      if (userList.contains(userId)) {
        signUserInfo.append(',').append(entityAccount.getAccountName());
      } else {
        noSignUserInfo.append(',').append(entityAccount.getAccountName());
      }
      shouldSignUserInfo.append(',').append(entityAccount.getAccountName());
    }

    if (signUserInfo.length() > 0) {
      signUserInfo.deleteCharAt(0);
    }
    if (noSignUserInfo.length() > 0) {
      noSignUserInfo.deleteCharAt(0);
    }
    if (shouldSignUserInfo.length() > 0) {
      shouldSignUserInfo.deleteCharAt(0);
    }
    if (StringUtils.isEmpty(signUserInfo.toString())) {
      signUserInfo.append("无");
    }
    if (StringUtils.isEmpty(noSignUserInfo.toString())) {
      noSignUserInfo.append("无");
    }
    if (StringUtils.isEmpty(shouldSignUserInfo.toString())) {
      shouldSignUserInfo.append("无");
    }
    modelAndView.addObject("signUserInfo", signUserInfo.toString());
    modelAndView.addObject("noSignUserInfo", noSignUserInfo.toString());
    modelAndView.addObject("shouldSignUserInfo", shouldSignUserInfo.toString());
    // 当前时间信息
    Date curentDate = new Date();
    modelAndView.addObject(
        "date", DateUtil.dateToString(curentDate, "MM月dd日") + DateUtil.getDayOfWeek(curentDate));
    modelAndView.addObject("time", DateUtil.dateToString(curentDate, "HH:mm"));

    // TODO 取出当月统计数据
    return modelAndView;
  }
  @Override
  public Object launchAppraisal(JSONObject jsonAppraisalObj) {
    // 判断对象是否有参数
    if (!CollectionUtils.isEmpty(jsonAppraisalObj)) {
      // 获取命令信息
      JSONObject jsonCommandInfo = jsonAppraisalObj.getJSONObject("commandInfo");
      if (CollectionUtils.isEmpty(jsonCommandInfo)) {
        throw new EnergyException("命令信息不能为空!");
      }
      String commandType = jsonCommandInfo.getString("commandType");
      if (StringUtils.isEmpty(commandType)) {
        throw new EnergyException("命令类型不能为空!");
      }
      if (!Constants.CMD_GENERAL.equals(commandType)) {
        throw new EnergyException("无效的命令类型:" + commandType);
      }

      // 获取当前用户
      WeixinUser weixinUser = SystemCacheUtil.getInstance().getCurrentUser();
      // 创建评价对象
      Appraisal appraisal = new Appraisal();

      appraisal.setUserId(weixinUser.getUserid());
      appraisal.setUserName(weixinUser.getName());
      appraisal.setTheme(jsonAppraisalObj.getString("theme"));
      appraisal.setOverallMerit(jsonAppraisalObj.getBoolean("overallMerit"));

      // 评价id
      String id = jsonAppraisalObj.getString("id");
      // 是否存在id 草稿 重新发起 都会存在id
      boolean hasId = false;
      if (StringUtils.isNotEmpty(id)) {
        appraisal.setId(id);
        hasId = true;
        // 清除与审批相关的 人员
        entityAccountService.deleteByEntityId(appraisal.getId());
      } else {
        appraisal.setId(CommonUtil.GeneGUID());
      }
      // 实体关系
      List<EntityAccount> entityAccountList = null;
      // 草稿状态下只存储
      if (Constants.CMD_DRAFT.equalsIgnoreCase(commandType)) {

      } else
      /** 发起审批操作 */
      if (Constants.CMD_GENERAL.equalsIgnoreCase(commandType)) {
        appraisal.setStatus(Status.未评价.value());
        appraisal.setCreateTime(new Date());
        if (hasId) {
          appraisalDao.updateAppraisal(appraisal);
        } else {
          appraisalDao.addAppraisal(appraisal);
        }
        // 问题记录

        List<ProblemTemplate> problemTemplateList =
            generateProblemTemplate(jsonAppraisalObj, appraisal.getId());
        if (!CollectionUtils.isEmpty(problemTemplateList)) {
          if (null != appraisal.getOverallMerit() && appraisal.getOverallMerit()) {
            ProblemTemplate problemTemplate = new ProblemTemplate();
            problemTemplate.setId(CommonUtil.GeneGUID());
            problemTemplate.setAppraisalId(appraisal.getId());
            problemTemplate.setQuota("需要填写综合评价");
            problemTemplateList.add(problemTemplate);
          }
          problemTemplateService.addProblemTemplate(
              problemTemplateList.toArray(new ProblemTemplate[] {}));
        }
        // 被评价人 评价人
        entityAccountList = generateEntityAccount(jsonAppraisalObj, appraisal.getId());
        if (!CollectionUtils.isEmpty(entityAccountList)) {
          StringBuffer shUser = new StringBuffer();
          for (EntityAccount entityAccount : entityAccountList) {
            if (EntityType.PJ.value().equals(entityAccount.getEntityType())) {
              if (PersonType.PJ.value().equals(entityAccount.getPersonType())) {
                shUser.append('|').append(entityAccount.getAccountId());
              }
            } else {
              LOGGER.error("人员列表数据内容非法!" + JSON.toJSONString(entityAccountList));
              throw new EnergyException("人员列表数据内容非法!");
            }
          }
          entityAccountService.addEntityAccount(entityAccountList.toArray(new EntityAccount[] {}));
          if (shUser.length() > 0) {
            shUser.deleteCharAt(0);
          }
          if (StringUtils.isNotEmpty(shUser.toString())) {
            // 给审核人推送消息
            SystemCacheUtil.getInstance()
                .getLinkedQueue()
                .add(
                    new AppraisalMsgExecutor(
                        appraisal.getId(), shUser.toString(), "template_appraisal_sh"));
          }
        } else {
          LOGGER.error("被评价或评价人不能为空!");
          throw new EnergyException("被评价或评价人不能为空!");
        }
      }
      return appraisal.getId();
    } else {
      LOGGER.warn("评价信息为空!");
    }
    return null;
  }
  @Override
  public Object appraisalOperate(JSONObject jsonAppraisalInfo) {
    // 判断对象是否有参数
    if (!CollectionUtils.isEmpty(jsonAppraisalInfo)) {
      // 获取命令信息
      JSONObject jsonCommandInfo = jsonAppraisalInfo.getJSONObject("commandInfo");
      if (CollectionUtils.isEmpty(jsonCommandInfo)) {
        throw new EnergyException("命令信息不能为空!");
      }
      String commandType = jsonCommandInfo.getString("commandType");
      if (StringUtils.isEmpty(commandType)) {
        throw new EnergyException("命令类型不能为空!");
      }

      String id = jsonAppraisalInfo.getString("id");
      if (StringUtils.isEmpty(id)) {
        throw new EnergyException("参数id不能为空!");
      }
      int type = jsonCommandInfo.getIntValue("commandType");
      // 获取当前用户
      WeixinUser weixinUser = SystemCacheUtil.getInstance().getCurrentUser();
      Appraisal currentAppraisal = appraisalDao.getAppraisalById(id);
      if (null == currentAppraisal) {
        throw new EnergyException(
            SpringContextUtil.getI18n("1002003", new String[] {"id", id}, null));
      }
      // 实体账户id
      if (Status.已评价.value().equals(currentAppraisal.getStatus())) {
        throw new EnergyException("当前评价已处理!");
      }
      switch (type) {
          // 提交评价
        case 1:
          // 获取问题列表
          String eaId = jsonAppraisalInfo.getString("eaId");
          if (StringUtils.isEmpty(eaId)) {
            throw new EnergyException(
                SpringContextUtil.getI18n("1002002", new String[] {"eaId", eaId}, null));
          }
          EntityAccount entityAccount = entityAccountService.getEntityAccountById(eaId);
          if (null == entityAccount) {
            throw new EnergyException(
                SpringContextUtil.getI18n("1002003", new String[] {"eaId", eaId}, null));
          }

          Score score = new Score();
          score.setAppraisalId(id);
          score.setRaterId(weixinUser.getUserid());
          score.setUserId(entityAccount.getAccountId());
          List<Score> scoreList = scoreService.getScore(score);
          if (!CollectionUtils.isEmpty(scoreList)) {
            throw new EnergyException("您已评价,不能重复评价!");
          }
          scoreList = generateProblemScore(jsonAppraisalInfo, id, weixinUser, entityAccount);
          if (!CollectionUtils.isEmpty(scoreList)) {
            scoreService.addScore(scoreList.toArray(new Score[] {}));
          }

          // 实体账户id
          if (!Status.评价中.value().equals(currentAppraisal.getStatus())) {
            Appraisal appraisal = new Appraisal();
            appraisal.setId(id);
            appraisal.setStatus(Status.评价中.value());
            appraisalDao.updateAppraisal(appraisal);
          }
          // 这里对每一个人评价进行标记 主要记录当前第几个人操作
          int appraiseTimes = entityAccount.getAppraiseTimes() + 1;
          entityAccount = new EntityAccount();
          entityAccount.setId(eaId);
          entityAccount.setAppraiseTimes(appraiseTimes);
          entityAccountService.updateEntityAccount(entityAccount);

          entityAccount = new EntityAccount();
          entityAccount.setEntityId(id);
          entityAccount.setPersonType(PersonType.PJ.value());
          // 获取总评价人数
          int count = (int) entityAccountService.getEntityAccountCount(entityAccount);
          // 查询所有带评价人 当前是否都已被评价
          entityAccount = new EntityAccount();
          entityAccount.setEntityId(id);
          entityAccount.setPersonType(PersonType.BPJ.value());
          List<EntityAccount> entityAccountList =
              entityAccountService.getEntityAccount(entityAccount);
          if (!CollectionUtils.isEmpty(entityAccountList)) {
            for (EntityAccount ea : entityAccountList) {
              if (ea.getAppraiseTimes() != count) {
                return null;
              }
            }
            Appraisal appraisal = new Appraisal();
            appraisal.setId(id);
            appraisal.setStatus(Status.已评价.value());
            appraisalDao.updateAppraisal(appraisal);
          }

          break;
          // 取消评价
        case 2:

          // 如果当前已被评价那么 禁止操作
          if (Status.未评价.value().equals(currentAppraisal.getStatus())) {
            // 被评价人 评价人 问题
            entityAccountService.deleteByEntityId(id);
            problemTemplateService.deleteByAppraisalId(id);
            appraisalDao.deleteAppraisalById(id);
          } else {
            throw new EnergyException("当前评价进行中不能操作!");
          }
          break;
        default:
          throw new EnergyException("无效操作!");
      }
    } else {
      LOGGER.warn("评价操作信息为空!");
    }
    return null;
  }