/**
  * 批量生成工资条
  *
  * @param year
  * @param month
  * @param workDays
  * @return
  */
 @RequestMapping(value = "/makeSaralyClips.do", produces = "application/json;charset=UTF-8")
 @ResponseBody
 public String makeSaralyClips(Integer year, Integer month, double workDays) {
   // 如果已经存在了当月的工资条
   if (saralyClipService.getSaralyClipCountByMonth(year, month) > 0) {
     // 返回提示信息
     return StatusUtil.statusInfo(StatusConst.ISFAIL).toJSONString();
   } else {
     // 批量计算并插入当月工资条
     try {
       // 获取员工的薪资信息
       List<EmployeeSaralyVo> list = employeeDetailService.getEmployeeSaralyVoList();
       // 批量计算出员工工资条
       List<SaralyClip> saralyClipList =
           SaralyUtil.batchCaculateSaraly(
               list, year, month, workDays, vacationService, allowanceService);
       // 批量存储员工工资条
       if (saralyClipList.size() != 0) {
         saralyClipService.batchSave(saralyClipList);
       }
     } catch (Exception e) {
       return StatusUtil.statusInfo(e.toString()).toJSONString();
     }
   }
   return StatusUtil.statusInfo(StatusConst.ISSUCCESSFULL).toJSONString();
 }
 @RequestMapping(value = "changeType.do", produces = "application/json;charset=UTF-8")
 @ResponseBody
 public String changeType(SaralyClip saralyClip) {
   try {
     if (saralyClip.getType().equals(SaralyClipConst.TRUN_TO_THIS_MONTH)) {
       saralyClip.setType(SaralyClipConst.TRUN_TO_THIS_MONTH);
       saralyClipService.changeType(saralyClip);
     }
     if (saralyClip.getType().equals(SaralyClipConst.TURN_TO_NEXT_MONTH)) {
       saralyClip.setType(SaralyClipConst.TURN_TO_NEXT_MONTH);
       saralyClipService.changeType(saralyClip);
       Allowance allowance = new Allowance();
       allowance.setAmount(saralyClip.getFinalSaraly());
       if (saralyClip.getMonth().equals(12)) {
         allowance.setYear(saralyClip.getYear() + 1);
         allowance.setMonth(1);
       } else {
         allowance.setYear(saralyClip.getYear());
         allowance.setMonth(saralyClip.getMonth() + 1);
       }
       allowance.setRemark(saralyClip.getMonth() + "月的工资");
       allowance.setEmployeeId(saralyClip.getEmployeeId());
       allowanceService.save(allowance);
     }
   } catch (Exception e) {
     return StatusUtil.statusInfo(e.toString()).toJSONString();
   }
   return StatusUtil.statusInfo(StatusConst.ISSUCCESSFULL).toJSONString();
 }
 /**
  * 发送单人工资条
  *
  * @param id
  * @return
  */
 @RequestMapping(value = "/singleSendEmail.do", produces = "application/json;charset=UTF-8")
 @ResponseBody
 public String singleSendEmail(Integer id) {
   try {
     SaralyClip saralyClip = saralyClipService.getById(id);
     sendMailService.sendEmail(saralyClip.getMonth() + "月薪资", saralyClip);
   } catch (Exception e) {
     StatusUtil.statusInfo(e.toString()).toJSONString();
   }
   return StatusUtil.statusInfo(StatusConst.ISSUCCESSFULL).toJSONString();
 }
 /**
  * 群发工资条
  *
  * @param year
  * @param month
  * @return
  */
 @RequestMapping(value = "/groupSendEmail.do", produces = "application/json;charset=UTF-8")
 @ResponseBody
 public String groupSendEmail(Integer year, Integer month) {
   try {
     List<SaralyClip> list = saralyClipService.getAllSaralyClipByMonth(year, month);
     for (SaralyClip item : list) {
       if (item.getType().equals(SaralyClipConst.CAN_SEND)
           || item.getType().equals(SaralyClipConst.TRUN_TO_THIS_MONTH)) {
         sendMailService.sendEmail(month + "月薪资", item);
       }
     }
   } catch (Exception e) {
     return StatusUtil.statusInfo(e.toString()).toJSONString();
   }
   return StatusUtil.statusInfo(StatusConst.ISSUCCESSFULL).toJSONString();
 }
 /**
  * 更新个人工资条
  *
  * @param id
  * @param employeeId
  * @param year
  * @param month
  * @param workDays
  * @return
  */
 @RequestMapping(
     value = "/updateSaralyClipByPerson.do",
     produces = "application/json;charset=UTF-8")
 @ResponseBody
 public String updateSaralyClipByPerson(
     Integer id, Integer employeeId, Integer year, Integer month, double workDays) {
   try {
     // 根据employeeId获取雇员的薪资信息
     EmployeeSaralyVo employeeSaralyVo =
         employeeDetailService.getEmployeeSaralyVoByEmployeeId(employeeId);
     // 根据薪资信息重新生成雇员的工资条
     SaralyClip saralyClip =
         SaralyUtil.updateSaralyClipByPerson(
             id, employeeSaralyVo, year, month, workDays, vacationService, allowanceService);
     // 用新生成的工资条去更新数据库中的工资条
     saralyClipService.updateByPerson(saralyClip);
   } catch (Exception e) {
     e.printStackTrace();
     return StatusUtil.statusInfo(e.toString()).toJSONString();
   }
   return StatusUtil.statusInfo(StatusConst.ISSUCCESSFULL).toJSONString();
 }