示例#1
0
 /**
  * 签到处理
  *
  * @return
  * @throws UnsupportedEncodingException
  */
 @RequestMapping(
     value = "doSign",
     method = {RequestMethod.GET, RequestMethod.POST})
 public @ResponseBody Object doSign() {
   ResponseResult responseResult = new ResponseResult();
   try {
     // 获取请假申请信息
     JSONObject jsonSignInfoObj =
         JSON.parseObject(
             URLDecoder.decode(HttpRequestUtil.getInstance().getString("signInfo"), "UTF-8"));
     Map<String, Object> resultData = new HashMap<String, Object>();
     responseResult.setValue(resultData);
     if (null != jsonSignInfoObj) {
       String sSignTime = DateUtil.dateToString(new Date(), "yyyy-MM-dd HH:mm");
       Date signTime = DateUtil.stringToDate(sSignTime + ":00");
       String id = CommonUtil.GeneGUID();
       jsonSignInfoObj.put("signTime", signTime);
       jsonSignInfoObj.put("id", id);
       resultData.put("id", id);
       resultData.put("signTime", DateUtil.dateToString(signTime, "HH:mm"));
     }
     signService.doSign(jsonSignInfoObj);
   } catch (Exception e) {
     e.printStackTrace();
     responseResult.setStatus(-1);
   }
   return responseResult;
 }
 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;
 }
示例#3
0
 /**
  * 发起签到
  *
  * @param model
  * @return
  */
 @RequestMapping(
     value = "launchSign",
     method = {RequestMethod.GET, RequestMethod.POST})
 public @ResponseBody Object launchSign(HttpServletRequest request) {
   ResponseResult responseResult = new ResponseResult();
   try {
     // 获取签到发布信息
     JSONObject jsonLaunchSignInfo =
         JSON.parseObject(
             URLDecoder.decode(
                 HttpRequestUtil.getInstance().getString("launchSignInfo"), "UTF-8"));
     String id = CommonUtil.GeneGUID();
     jsonLaunchSignInfo.put("id", id);
     responseResult.setValue(id);
     signService.launchSign(jsonLaunchSignInfo);
   } catch (Exception e) {
     e.printStackTrace();
     responseResult.setStatus(-1);
   }
   return responseResult;
 }
 private List<ProblemTemplate> generateProblemTemplate(JSONObject jsonInfoObj, String entityId) {
   // 获取问题
   ProblemTemplate problemTemplate = null;
   List<ProblemTemplate> problemTemplateList = new ArrayList<ProblemTemplate>();
   JSONObject jsonObj = null;
   // 实体用户信息
   if (jsonInfoObj.containsKey("problemList")) {
     JSONArray jsonArray = jsonInfoObj.getJSONArray("problemList");
     if (!CollectionUtils.isEmpty(jsonArray)) {
       for (Object obj : jsonArray) {
         jsonObj = (JSONObject) obj;
         problemTemplate = new ProblemTemplate();
         problemTemplate.setId(CommonUtil.GeneGUID());
         problemTemplate.setAppraisalId(entityId);
         problemTemplate.setQuota(jsonObj.getString("quota"));
         problemTemplate.setStandard(jsonObj.getString("standard"));
         problemTemplate.setScores(jsonObj.getInteger("score"));
         problemTemplateList.add(problemTemplate);
       }
     }
   }
   return problemTemplateList;
 }
  @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;
  }