| | |
| | | import com.ruoyi.system.service.*; |
| | | import com.ruoyi.system.vo.system.AppealDetailVO; |
| | | import com.ruoyi.system.vo.system.AppealListVO; |
| | | import com.ruoyi.web.controller.tool.EmailUtils; |
| | | import com.ruoyi.web.controller.tool.MsgUtils; |
| | | import com.tencentcloudapi.es.v20180416.models.TaskDetail; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | } |
| | | @Resource |
| | | private TNoticeService noticeService; |
| | | @Resource |
| | | private MsgUtils msgUtils; |
| | | @Resource |
| | | private TNoticeSetService noticeSetService; |
| | | @Resource |
| | | private TDictDataService dictDataService; |
| | | @Log(title = "审核申诉记录", businessType = BusinessType.UPDATE) |
| | | @ApiOperation(value = "审核申诉记录") |
| | | @PostMapping(value = "/audit") |
| | | public R<Boolean> audit(@RequestBody @Valid TAppealAuditDTO dto) { |
| | | public R<Boolean> audit(@RequestBody @Valid TAppealAuditDTO dto) throws Exception { |
| | | List<SysUser> sysUsers = sysUserService.selectAllList(); |
| | | TAppeal appeal = appealService.getById(dto.getId()); |
| | | SysUser sysUser = sysUsers.stream().filter(e -> e.getUserId().equals(Long.valueOf(dto.getAppealPerson()))) |
| | | .findFirst().orElse(null); |
| | | dto.setStatus(dto.getStatus()); |
| | | dto.setAuditPerson(tokenService.getLoginUser().getUserId()+""); |
| | | dto.setAuditTime(LocalDateTime.now()); |
| | |
| | | taskDetail.setTaskId(appeal.getTaskId()); |
| | | Long count = tTaskDetailService.lambdaQuery().eq(TTaskDetail::getTaskId, appeal.getTaskId()) |
| | | .eq(TTaskDetail::getHandleType, 1).count(); |
| | | TNoticeSet noticeSet = noticeSetService.lambdaQuery().eq(TNoticeSet::getType, 2).last("limit 1") |
| | | .one(); |
| | | // 邮箱 |
| | | TDictData email = dictDataService.lambdaQuery().eq(TDictData::getDataType,4).one(); |
| | | // 授权码 |
| | | TDictData code = dictDataService.lambdaQuery().eq(TDictData::getDataType,5).one(); |
| | | if (dto.getStatus()==2){ |
| | | taskDetail.setClearStatus(1); |
| | | taskDetail.setAuditTime(LocalDateTime.now()); |
| | |
| | | taskCleanService.updateById(byId); |
| | | tNotice.setNoticeType(5); |
| | | tNotice.setNoticeContent("【"+location.getLocationName()+"】任务申诉通过"); |
| | | if (sysUser!=null){ |
| | | switch (noticeSet.getNoticeType()) { |
| | | case 1: |
| | | msgUtils.sendMsg3(sysUser.getPhonenumber(),location.getLocationName(),"通过"); |
| | | break; |
| | | case 2: |
| | | if (StringUtils.hasLength(email.getDataContent())&&StringUtils.hasLength(code.getDataContent())){ |
| | | EmailUtils.sendEmail(sysUser.getEmail(),email.getDataContent(),code.getDataContent(),"【"+location.getLocationName()+"】任务申诉通过"); |
| | | } |
| | | break; |
| | | case 3: |
| | | break; |
| | | } |
| | | } |
| | | }else{ |
| | | taskDetail.setClearStatus(2); |
| | | taskDetail.setAuditTime(LocalDateTime.now()); |
| | |
| | | taskDetail.setAppealId(dto.getId()); |
| | | tNotice.setNoticeType(4); |
| | | tNotice.setNoticeContent("【"+location.getLocationName()+"】任务申诉驳回"); |
| | | if (sysUser!=null){ |
| | | switch (noticeSet.getNoticeType()) { |
| | | case 1: |
| | | msgUtils.sendMsg3(sysUser.getPhonenumber(),location.getLocationName(),"通过"); |
| | | break; |
| | | case 2: |
| | | if (StringUtils.hasLength(email.getDataContent())&&StringUtils.hasLength(code.getDataContent())){ |
| | | EmailUtils.sendEmail(sysUser.getEmail(),email.getDataContent(),code.getDataContent(),"【"+location.getLocationName()+"】任务申诉驳回"); |
| | | } |
| | | break; |
| | | case 3: |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | noticeService.save(tNotice); |
| | | dto.setAuditPerson(tokenService.getLoginUser().getUserId()+""); |
| | |
| | | List<TLocation> locationList = locationService.list(); |
| | | List<TTask> taskList = taskCleanerService.list(); |
| | | if (StringUtils.hasLength(query.getDeptName())){ |
| | | List<String> projectIds = projectDeptService.lambdaQuery().like(TProjectDept::getProjectName, query.getDeptName()).list() |
| | | List<TProjectDept> list = projectDeptService.lambdaQuery().like(TProjectDept::getProjectName, query.getDeptName()).list(); |
| | | List<String> listIds = projectDeptService.lambdaQuery().like(TProjectDept::getProjectName, query.getDeptName()).list() |
| | | .stream().map(TProjectDept::getId).collect(Collectors.toList()); |
| | | for (TProjectDept tProjectDept : list) { |
| | | if (tProjectDept.getParentId().equals("0")){ |
| | | List<String> collect = projectDeptService.lambdaQuery().eq(TProjectDept::getParentId, tProjectDept.getId()).list() |
| | | .stream().map(TProjectDept::getId).collect(Collectors.toList()); |
| | | listIds.addAll(collect); |
| | | listIds.add(tProjectDept.getId()); |
| | | } |
| | | } |
| | | List<String> deptIds = deptService.lambdaQuery().like(TDept::getDeptName, query.getDeptName()).list() |
| | | .stream().map(TDept::getId).collect(Collectors.toList()); |
| | | projectIds.addAll(deptIds); |
| | | if (projectIds.isEmpty()){ |
| | | listIds.addAll(deptIds); |
| | | if (listIds.isEmpty()){ |
| | | return R.ok(new PageInfo<>()); |
| | | } |
| | | List<Long> collect = sysUsers.stream().filter(e -> listIds.contains(e.getDeptId())) |
| | | .map(SysUser::getUserId).collect(Collectors.toList()); |
| | | query.setPatrolInspectorIds( collect); |
| | | if (StringUtils.hasLength(query.getPhonenumber())){ |
| | | List<Long> patrolInspectorIds = sysUsers.stream().filter(sysUser -> |
| | | sysUser.getPhonenumber().equals(query.getPhonenumber()) |
| | | && projectIds.contains(sysUser.getDeptId()) |
| | | sysUser.getPhonenumber().contains(query.getPhonenumber()) |
| | | && listIds.contains(sysUser.getDeptId()) |
| | | ).map(SysUser::getUserId).collect(Collectors.toList()); |
| | | if (patrolInspectorIds.isEmpty()){ |
| | | return R.ok(new PageInfo<>()); |
| | |
| | | } |
| | | if (StringUtils.hasLength(query.getPhonenumber())){ |
| | | List<Long> patrolInspectorIds = sysUsers.stream().filter(sysUser -> |
| | | sysUser.getPhonenumber().equals(query.getPhonenumber()) |
| | | sysUser.getPhonenumber().contains(query.getPhonenumber()) |
| | | ).map(SysUser::getUserId).collect(Collectors.toList()); |
| | | query.setPatrolInspectorIds(patrolInspectorIds); |
| | | if (!query.getPatrolInspectorIds().isEmpty()){ |
| | | // 取交集 |
| | | patrolInspectorIds = patrolInspectorIds.stream().filter(query.getPatrolInspectorIds()::contains).collect(Collectors.toList()); |
| | |
| | | query.setLocationIds(collect); |
| | | return R.ok(new PageInfo<>()); |
| | | }else{ |
| | | if (query.getLocationIds()!=null && !query.getLocationIds().isEmpty()){ |
| | | collect = collect.stream().filter(query.getLocationIds()::contains).collect(Collectors.toList()); |
| | | if (collect.isEmpty()){ |
| | | return R.ok(new PageInfo<>()); |
| | | } |
| | | } |
| | | query.setLocationIds(collect); |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.system.service.*; |
| | | import com.ruoyi.system.vo.system.InspectorListVO; |
| | | import com.ruoyi.system.vo.system.TaskListVO; |
| | | import com.ruoyi.web.controller.tool.EmailUtils; |
| | | import com.ruoyi.web.controller.tool.MsgUtils; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | |
| | | } |
| | | query.setLocationIds(collect); |
| | | } |
| | | } |
| | | if (StringUtils.hasLength(query.getEndTime())){ |
| | | String replace = query.getEndTime().replace(" 00:00:00", " 23:59:59"); |
| | | query.setEndTime(replace); |
| | | } |
| | | return R.ok(inspectorService.pageList(query)); |
| | | } |
| | |
| | | private TNoticeService noticeService; |
| | | @Resource |
| | | private TNoticeSetService noticeSetService; |
| | | @Resource |
| | | private TDictDataService dictDataService; |
| | | @Resource |
| | | private MsgUtils msgUtils; |
| | | @Log(title = "审核任务", businessType = BusinessType.UPDATE) |
| | | @ApiOperation(value = "审核任务") |
| | | @PostMapping(value = "/audit") |
| | | public R<Boolean> audit(@RequestBody TInspectorAuditDTO dto) { |
| | | public R<Boolean> audit(@RequestBody TInspectorAuditDTO dto) throws Exception { |
| | | TTaskAuditDTO tTaskAuditDTO = new TTaskAuditDTO(); |
| | | BeanUtils.copyProperties(dto, tTaskAuditDTO); |
| | | TTask task = taskCleanerService.getById(dto.getTaskId()); |
| | |
| | | tNotice.setStatus(1); |
| | | tNotice.setDataId(task.getId()); |
| | | tNotice.setNoticeSetType(noticeSet.getNoticeType()); |
| | | TInspector byId = inspectorService.getById(dto.getId()); |
| | | SysUser sysUser = sysUserService.selectUserById(Long.valueOf(task.getPatrolInspector())); |
| | | // 邮箱 |
| | | TDictData email = dictDataService.lambdaQuery().eq(TDictData::getDataType,4).one(); |
| | | // 授权码 |
| | | TDictData code = dictDataService.lambdaQuery().eq(TDictData::getDataType,5).one(); |
| | | if (dto.getAuditStatus()==1){ |
| | | if (dto.getClearStatus()==2){ |
| | | if (byId.getClearStatus()==2){ |
| | | tTaskAuditDTO.setHandleType(3); |
| | | dto.setStatus(2); |
| | | // 增加消息 |
| | | tNotice.setNoticeType(1); |
| | | tNotice.setNoticeType(8); |
| | | tNotice.setNoticeContent("【"+location.getLocationName()+"】督察任务不合格,请重新上传!"); |
| | | noticeService.save(tNotice); |
| | | switch (noticeSet.getNoticeType()) { |
| | | case 1: |
| | | msgUtils.sendMsg5(sysUser.getPhonenumber(), location.getLocationName()); |
| | | break; |
| | | case 2: |
| | | if (StringUtils.hasLength(email.getDataContent()) && StringUtils.hasLength(code.getDataContent())) { |
| | | EmailUtils.sendEmail(sysUser.getEmail(), email.getDataContent(), code.getDataContent(), "【"+location.getLocationName()+"】任务督察不合格,请及时整改!"); |
| | | } |
| | | break; |
| | | case 3: |
| | | break; |
| | | } |
| | | }else{ |
| | | if (dto.getAuditTime()!=null){ |
| | | dto.setStatus(3); |
| | |
| | | @ApiOperation(value = "根据部门/项目部id查询巡检员列表 不分页") |
| | | @GetMapping(value = "/listUsers") |
| | | public R<List<SysUser>> listUsers(@RequestParam String id) { |
| | | List<SysUser> res = sysUserService.selectUserByDeptId(id); |
| | | List<String> strings = new ArrayList<>(); |
| | | strings.add(id); |
| | | TProjectDept projectDept = projectDeptService.getById(id); |
| | | if (projectDept.getParentId().equals("0")){ |
| | | List<String> collect = projectDeptService.lambdaQuery().eq(TProjectDept::getParentId, projectDept.getId()) |
| | | .list().stream().map(TProjectDept::getId).collect(Collectors.toList()); |
| | | strings.addAll(collect); |
| | | } |
| | | List<SysUser> res = sysUserService.selectUserByDeptId(strings); |
| | | return R.ok(res); |
| | | } |
| | | @Log(title = "新增点位", businessType = BusinessType.INSERT) |
| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.net.URLEncoder; |
| | |
| | | import com.ruoyi.system.query.TaskListQuery; |
| | | import com.ruoyi.system.service.*; |
| | | import com.ruoyi.system.vo.system.*; |
| | | import com.ruoyi.web.controller.tool.EmailUtils; |
| | | import com.ruoyi.web.controller.tool.MsgUtils; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | |
| | | private TTaskCleanService taskCleanerService; |
| | | @Resource |
| | | private TNoticeService noticeService; |
| | | @Resource |
| | | private TNoticeSetService noticeSetService; |
| | | |
| | | @Resource |
| | | private TEarlyWarningService earlyWarningService; |
| | | @Resource |
| | |
| | | private TDeptService deptService; |
| | | @Resource |
| | | private ISysUserService sysUserService; |
| | | @Resource |
| | | private TDictDataService dictDataService; |
| | | |
| | | @Resource |
| | | private TokenService tokenService; |
| | | @Resource |
| | |
| | | taskCleanerService.save(dto); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Resource |
| | | private MsgUtils msgUtils; |
| | | @Resource |
| | | private TNoticeSetService noticeSetService; |
| | | @Resource |
| | | private TDictDataService dictDataService; |
| | | @Log(title = "审核任务", businessType = BusinessType.UPDATE) |
| | | @ApiOperation(value = "审核任务") |
| | | @PostMapping(value = "/audit") |
| | | public R<Boolean> audit(@RequestBody TTaskAuditDTO dto) { |
| | | public R<Boolean> audit(@RequestBody TTaskAuditDTO dto) throws Exception { |
| | | dto.setAuditTime(LocalDateTime.now()); |
| | | TTask task = taskCleanerService.getById(dto.getTaskId()); |
| | | SysUser sysUser = sysUserService.selectUserById(Long.valueOf(task.getPatrolInspector())); |
| | | |
| | | TTaskDetail one = taskDetailService.lambdaQuery().eq(TTaskDetail::getTaskId, dto.getTaskId()) |
| | | .eq(TTaskDetail::getHandleType,1) |
| | | .orderByDesc(BaseModel::getCreateTime).last("limit 1").one(); |
| | |
| | | TNotice tNotice = new TNotice(); |
| | | TNoticeSet noticeSet = noticeSetService.lambdaQuery().eq(TNoticeSet::getType, 2).last("limit 1") |
| | | .one(); |
| | | // 邮箱 |
| | | TDictData email = dictDataService.lambdaQuery().eq(TDictData::getDataType,4).one(); |
| | | // 授权码 |
| | | TDictData code = dictDataService.lambdaQuery().eq(TDictData::getDataType,5).one(); |
| | | |
| | | tNotice.setUserId(task.getPatrolInspector()); |
| | | tNotice.setStatus(1); |
| | | tNotice.setDataId(task.getId()); |
| | |
| | | // 增加消息 |
| | | tNotice.setNoticeType(1); |
| | | tNotice.setNoticeContent("【"+location.getLocationName()+"】任务不合格,请重新上传!"); |
| | | if (sysUser!=null){ |
| | | switch (noticeSet.getNoticeType()) { |
| | | case 1: |
| | | msgUtils.sendMsg1(sysUser.getPhonenumber(),location.getLocationName(),"驳回"); |
| | | break; |
| | | case 2: |
| | | if (StringUtils.hasLength(email.getDataContent())&&StringUtils.hasLength(code.getDataContent())){ |
| | | EmailUtils.sendEmail(sysUser.getEmail(),email.getDataContent(),code.getDataContent(),"【" + location.getLocationName() + "】任务不合格,请重新上传!"); |
| | | } |
| | | break; |
| | | case 3: |
| | | break; |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | }else{ |
| | | if (dto.getClearStatus()==2){ |
| | | if (StringUtils.hasLength(location.getUnqualifiedTaskId())){ |
| | |
| | | tNotice.setNoticeType(2); |
| | | tNotice.setNoticeContent("【"+location.getLocationName()+"】任务已通过"); |
| | | } |
| | | if (sysUser!=null){ |
| | | switch (noticeSet.getNoticeType()) { |
| | | case 1: |
| | | msgUtils.sendMsg1(sysUser.getPhonenumber(),location.getLocationName(),"通过"); |
| | | break; |
| | | case 2: |
| | | if (StringUtils.hasLength(email.getDataContent())&&StringUtils.hasLength(code.getDataContent())){ |
| | | EmailUtils.sendEmail(sysUser.getEmail(),email.getDataContent(),code.getDataContent(),"【" + location.getLocationName() + "】任务已通过"); |
| | | } |
| | | break; |
| | | case 3: |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | noticeService.save(tNotice); |
| | | dto.setAuditPerson(tokenService.getLoginUser().getUserId()+""); |
| | |
| | | taskDetailService.updateById(one); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Log(title = "批量审核任务", businessType = BusinessType.UPDATE) |
| | | @ApiOperation(value = "批量审核任务") |
| | | @PostMapping(value = "/auditBatch") |
| | |
| | | }else{ |
| | | tTaskDetail.setHandleType(2); |
| | | // 如果是初次审核就通过 将状态设置为已完成 |
| | | List<TTaskDetail> list = taskDetailService.lambdaQuery().eq(TTaskDetail::getTaskId, s).list(); |
| | | if (list.isEmpty()){ |
| | | List<TTaskDetail> list = taskDetailService.lambdaQuery() |
| | | .eq(TTaskDetail::getHandleType, 1).eq(TTaskDetail::getTaskId, s).list(); |
| | | if (list.size() == 1) { |
| | | byId.setStatus(6); |
| | | taskCleanerService.updateById(byId); |
| | | }else{ |
| | |
| | | taskDetailService.saveBatch(tTaskDetails); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @ApiOperation(value = "详情任务") |
| | | @GetMapping(value = "/detail") |
| | | public R<TaskDetailVO> detail(@RequestParam String id) { |
| | |
| | | taskDetailVO.setRecords(list); |
| | | return R.ok(taskDetailVO); |
| | | } |
| | | |
| | | @ApiOperation(value = "详情任务-根据任务编号") |
| | | @GetMapping(value = "/detailByTaskCode") |
| | | public R<TaskDetailVO> detailByTaskCode(@RequestParam String taskCode) { |
| | |
| | | |
| | | return R.ok(taskDetailVO); |
| | | } |
| | | |
| | | @ApiOperation(value = "详情任务-操作记录-详情") |
| | | @GetMapping(value = "/detailRecord") |
| | | public R<TaskRecordDetailVO> detailRecord(@RequestParam String id) { |
| | |
| | | taskDetailVO.setTaskDetail(byId4); |
| | | return R.ok(taskDetailVO); |
| | | } |
| | | |
| | | @Log(title = "批量删除任务", businessType = BusinessType.DELETE) |
| | | @ApiOperation(value = "批量删除任务") |
| | | @DeleteMapping(value = "/deleteByIds") |
| | |
| | | String code = String.valueOf((int) (Math.random() * 1000000)); |
| | | redisCache.setCacheObject(phone, code,5*60,TimeUnit.SECONDS); |
| | | try { |
| | | msgUtils.sendMsg(phone, code); |
| | | // msgUtils.sendMsg(phone, code); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | |
| | | roleInfoVo.setRoleType(role.getRoleType()); |
| | | // 获取当前角色的菜单列表 |
| | | List<SysMenu> menus = menuService.selectListByRoleId(roleId); |
| | | if(menus.size()==0){ |
| | | return AjaxResult.success(new ArrayList<>()); |
| | | } |
| | | List<Long> menusId = menus.stream().map(SysMenu::getMenuId).collect(Collectors.toList()); |
| | | |
| | | // 获取当前的权限菜单(有层级) |
| | | if (!menusId.isEmpty()){ |
| | | List<SysMenu> levelMenus = roleService.getMenuLevelList(menusId); |
| | | |
| | | roleInfoVo.setMenus(menusId); |
| | | }else{ |
| | | roleInfoVo.setMenus(new ArrayList<>()); |
| | | } |
| | | return AjaxResult.success(roleInfoVo); |
| | | } |
| | | |
| | |
| | | import com.ruoyi.system.mapper.TCleanerMapper; |
| | | import com.ruoyi.system.model.*; |
| | | import com.ruoyi.system.service.*; |
| | | import com.ruoyi.web.controller.tool.EmailUtils; |
| | | import com.ruoyi.web.controller.tool.MsgUtils; |
| | | import javafx.concurrent.Task; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.poi.ss.formula.functions.T; |
| | |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | |
| | | private TEarlyWarningService earlyWarningService; |
| | | @Autowired |
| | | private TLeaveService leaveService; |
| | | @Resource |
| | | private TNoticeService noticeService; |
| | | |
| | | |
| | | // 每一个小时执行一次 |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | @Resource |
| | | private TNoticeSetService noticeSetService; |
| | | @Resource |
| | | private MsgUtils msgUtils; |
| | | @Resource |
| | | private TDictDataService dictDataService; |
| | | @Scheduled(cron = "0 0 20 * * ?") |
| | | public void dayOfEarlyWarning() { |
| | | try { |
| | |
| | | List<TTask> taskCleanList = taskCleanService.list(Wrappers.lambdaQuery(TTask.class) |
| | | .like(TTask::getImplementTime, LocalDate.now()) |
| | | .eq(TTask::getStatus, 1)); |
| | | List<String> userIds = taskCleanList.stream().map(TTask::getPatrolInspector).distinct().collect(Collectors.toList()); |
| | | List<SysUser> sysUsers = sysUserService.selectAllList(); |
| | | TNoticeSet noticeSet = noticeSetService.lambdaQuery().eq(TNoticeSet::getType, 2).last("limit 1") |
| | | .one(); |
| | | // 邮箱 |
| | | TDictData email = dictDataService.lambdaQuery().eq(TDictData::getDataType,4).one(); |
| | | // 授权码 |
| | | TDictData code = dictDataService.lambdaQuery().eq(TDictData::getDataType,5).one(); |
| | | if (!CollectionUtils.isEmpty(taskCleanList)) { |
| | | List<TEarlyWarning> earlyWarningList = new ArrayList<>(); |
| | | List<TNotice> noticeList = new ArrayList<>(); |
| | | List<TNotice> addNotice = new ArrayList<>(); |
| | | taskCleanList.forEach(task -> { |
| | | task.setStatus(2); |
| | | TEarlyWarning earlyWarning = new TEarlyWarning(); |
| | | earlyWarning.setWarningType(1); |
| | | earlyWarning.setTaskId(task.getId()); |
| | | earlyWarningList.add(earlyWarning); |
| | | TNotice tNotice = new TNotice(); |
| | | tNotice.setUserId(task.getPatrolInspector()); |
| | | tNotice.setStatus(1); |
| | | tNotice.setDataId(task.getId()); |
| | | tNotice.setNoticeType(3); |
| | | tNotice.setNoticeSetType(noticeSet.getNoticeType()); |
| | | noticeList.add(tNotice); |
| | | }); |
| | | earlyWarningService.saveBatch(earlyWarningList); |
| | | |
| | | for (String userId : userIds) { |
| | | SysUser sysUser = sysUsers.stream().filter(e -> e.getUserId().equals(Long.valueOf(userId))).findFirst().orElse(null); |
| | | long count = taskCleanList.stream().filter(e -> e.getPatrolInspector().equals(userId)).count(); |
| | | TNotice tNotice = new TNotice(); |
| | | tNotice.setUserId(userId); |
| | | tNotice.setStatus(1); |
| | | tNotice.setNoticeType(3); |
| | | tNotice.setNoticeContent("今日剩余"+count+"个任务未完成,请尽快处理"); |
| | | tNotice.setNoticeSetType(noticeSet.getNoticeType()); |
| | | addNotice.add(tNotice); |
| | | |
| | | if (sysUser!=null){ |
| | | switch (noticeSet.getNoticeType()) { |
| | | case 1: |
| | | msgUtils.sendMsg2(sysUser.getPhonenumber(),count+""); |
| | | break; |
| | | case 2: |
| | | if (StringUtils.hasLength(email.getDataContent())&&StringUtils.hasLength(code.getDataContent())){ |
| | | EmailUtils.sendEmail(sysUser.getEmail(),email.getDataContent(),code.getDataContent(),"今日剩余"+count+"个任务未完成,请尽快处理"); |
| | | } |
| | | break; |
| | | case 3: |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | noticeService.saveBatch(addNotice); |
| | | taskCleanService.updateBatchById(taskCleanList); |
| | | } |
| | | } catch (Exception e) { |
New file |
| | |
| | | package com.ruoyi.web.controller.tool; |
| | | |
| | | import com.aliyun.dysmsapi20170525.models.SendSmsRequest; |
| | | import com.aliyun.dysmsapi20170525.models.SendSmsResponse; |
| | | import com.aliyun.tea.TeaException; |
| | | import com.aliyun.teaopenapi.models.Config; |
| | | import com.aliyun.teautil.models.RuntimeOptions; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.compress.utils.IOUtils; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.activation.DataHandler; |
| | | import javax.activation.FileDataSource; |
| | | import javax.mail.*; |
| | | import javax.mail.internet.*; |
| | | import java.io.File; |
| | | import java.io.FileOutputStream; |
| | | import java.io.InputStream; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URL; |
| | | import java.util.Date; |
| | | import java.util.Properties; |
| | | |
| | | @Slf4j |
| | | public class EmailUtils { |
| | | |
| | | public static void sendEmail(String userEmail, String sendEmail, String code, String content) throws Exception { |
| | | // 发送邮箱 |
| | | // 收件人电子邮箱,TODO 换成自己的收件箱 |
| | | String to = userEmail; |
| | | // 发件人电子邮箱,TODO 换成自己的发件箱 |
| | | String from = sendEmail; |
| | | // 指定发送邮件的主机为 |
| | | String host = "smtp.163.com"; |
| | | Properties properties = new Properties(); |
| | | properties.put("mail.smtp.host", host); |
| | | properties.put("mail.smtp.socketFactory.port", "465"); |
| | | properties.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); |
| | | properties.put("mail.smtp.auth", "true"); |
| | | properties.put("mail.smtp.port", "465"); |
| | | properties.put("mail.smtp.ssl.enable", "true"); // 明确开启SSL |
| | | // 获取默认session对象 |
| | | Session session = Session.getDefaultInstance(properties,new Authenticator(){ |
| | | @Override |
| | | public javax.mail.PasswordAuthentication getPasswordAuthentication() |
| | | { |
| | | //发件人邮件用户名、授权码,换成自己的发件箱及授权码 |
| | | return new PasswordAuthentication(from, code); |
| | | } |
| | | }); |
| | | |
| | | try{ |
| | | // 创建默认的 MimeMessage 对象 |
| | | MimeMessage message = new MimeMessage(session); |
| | | // Set From,设置发件人 |
| | | InternetAddress fromMail = new InternetAddress(from); |
| | | //设置发件人名称,TODO 换成自己的发件箱 |
| | | fromMail.setPersonal(MimeUtility.encodeText("沿海市政<" + from + ">")); |
| | | message.setFrom(fromMail); |
| | | // Set To: 设置收件人 |
| | | InternetAddress toMail = new InternetAddress(to); |
| | | // TODO 换成自己的收件箱 |
| | | InternetAddress toMail2 = new InternetAddress(to); |
| | | //发多个邮箱 |
| | | Address[] allRecipients = {toMail, toMail2}; |
| | | message.setRecipients(Message.RecipientType.TO, allRecipients); |
| | | // Set Subject: 邮件主体 |
| | | message.setSubject("沿海市政"); |
| | | // 设置消息体 |
| | | message.setSentDate(new Date()); |
| | | javax.mail.internet.MimeMultipart msgMultipart = new MimeMultipart("mixed"); |
| | | |
| | | // 指定为混合关系 |
| | | message.setContent(msgMultipart); |
| | | // 邮件信息组装 |
| | | //组装的顺序非常重要,一定要先组装文本域,再组装文件 |
| | | javax.mail.internet.MimeBodyPart htmlPart = new javax.mail.internet.MimeBodyPart(); |
| | | // 组装内容 |
| | | htmlPart.setContent(content, "text/html;charset=UTF-8"); |
| | | msgMultipart.addBodyPart(htmlPart); |
| | | try { |
| | | message.saveChanges(); |
| | | //发送 |
| | | //Transport.send(message, message.getAllRecipients()); |
| | | Transport.send(message); |
| | | System.out.println("发送成功"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | }catch (MessagingException | UnsupportedEncodingException mex) { |
| | | mex.printStackTrace(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | @Slf4j |
| | | public class MsgUtils { |
| | | |
| | | @Value("${code.config.accessKeyId}") |
| | | private String accessKeyId; |
| | | @Value("${code.config.accessKeySecret}") |
| | | private String accessKeySecret; |
| | | @Value("${code.config.signName}") |
| | | private String signName; |
| | | @Value("${code.config.templateCode}") |
| | | private String templateCode; |
| | | @Value("${code.config.signNameTest}") |
| | | private String signNameTest; |
| | | @Value("${code.config.templateCodeTest}") |
| | | private String templateCodeTest; |
| | | |
| | | |
| | | /** |
| | | * 使用AK&SK初始化账号Client |
| | |
| | | return new com.aliyun.dysmsapi20170525.Client(config); |
| | | } |
| | | |
| | | public void sendMsg(String phone,String code) throws Exception { |
| | | com.aliyun.dysmsapi20170525.Client client = MsgUtils.createClient(accessKeyId,accessKeySecret); |
| | | // 任务审核结果通知 |
| | | public void sendMsg1(String phone,String point,String result) throws Exception { |
| | | com.aliyun.dysmsapi20170525.Client client = MsgUtils.createClient("LTAI5t6SvJEZ9Wv28ranrfLV","hL9wbTdM3rPOLMj0DAhCn90URVzvvw"); |
| | | SendSmsRequest sendSmsRequest = new SendSmsRequest() |
| | | .setSignName(signName) |
| | | .setTemplateCode(templateCode) |
| | | .setSignName("沿海市政") |
| | | .setTemplateCode("SMS_490460059") |
| | | .setPhoneNumbers(phone) |
| | | .setTemplateParam("{\"code\":\""+code+"\"}"); |
| | | .setTemplateParam("{\"point\":\""+point+"\",\"result\":\""+result+"\"}"); |
| | | RuntimeOptions runtime = new RuntimeOptions(); |
| | | try { |
| | | // 复制代码运行请自行打印 API 的返回值 |
| | | SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, runtime); |
| | | log.info("短信发送成功:{},{}",sendSmsResponse.getBody().getMessage(),sendSmsResponse.getStatusCode()); |
| | | log.info("任务审核结果通知短信发送成功:{},{}",sendSmsResponse.getBody().getMessage(),sendSmsResponse.getStatusCode()); |
| | | } catch (TeaException error) { |
| | | // 如有需要,请打印 error |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | log.info("短信发送失败:{}",error.message); |
| | | log.info("任务审核结果通知短信发送失败:{}",error.message); |
| | | } catch (Exception _error) { |
| | | TeaException error = new TeaException(_error.getMessage(), _error); |
| | | // 如有需要,请打印 error |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | log.info("短信发送失败:{}",error.message); |
| | | log.info("任务审核结果通知短信发送失败:{}",error.message); |
| | | } |
| | | } |
| | | // 今日任务未完成 |
| | | public void sendMsg2(String phone,String count) throws Exception { |
| | | com.aliyun.dysmsapi20170525.Client client = MsgUtils.createClient("LTAI5t6SvJEZ9Wv28ranrfLV","hL9wbTdM3rPOLMj0DAhCn90URVzvvw"); |
| | | SendSmsRequest sendSmsRequest = new SendSmsRequest() |
| | | .setSignName("沿海市政") |
| | | .setTemplateCode("SMS_490450039") |
| | | .setPhoneNumbers(phone) |
| | | .setTemplateParam("{\"count\":\""+count+"\"}"); |
| | | RuntimeOptions runtime = new RuntimeOptions(); |
| | | try { |
| | | // 复制代码运行请自行打印 API 的返回值 |
| | | SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, runtime); |
| | | log.info("今日任务未完成短信发送成功:{},{}",sendSmsResponse.getBody().getMessage(),sendSmsResponse.getStatusCode()); |
| | | } catch (TeaException error) { |
| | | // 如有需要,请打印 error |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | log.info("今日任务未完成短信发送失败:{}",error.message); |
| | | } catch (Exception _error) { |
| | | TeaException error = new TeaException(_error.getMessage(), _error); |
| | | // 如有需要,请打印 error |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | log.info("今日任务未完成短信发送失败:{}",error.message); |
| | | } |
| | | } |
| | | // 申诉结果通知通知 |
| | | public void sendMsg3(String phone,String point,String result) throws Exception { |
| | | com.aliyun.dysmsapi20170525.Client client = MsgUtils.createClient("LTAI5t6SvJEZ9Wv28ranrfLV","hL9wbTdM3rPOLMj0DAhCn90URVzvvw"); |
| | | SendSmsRequest sendSmsRequest = new SendSmsRequest() |
| | | .setSignName("沿海市政") |
| | | .setTemplateCode("SMS_490535047") |
| | | .setPhoneNumbers(phone) |
| | | .setTemplateParam("{\"point\":\""+point+"\",\"result\":\""+result+"\"}"); |
| | | RuntimeOptions runtime = new RuntimeOptions(); |
| | | try { |
| | | // 复制代码运行请自行打印 API 的返回值 |
| | | SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, runtime); |
| | | log.info("申诉结果通知短信发送成功:{},{}",sendSmsResponse.getBody().getMessage(),sendSmsResponse.getStatusCode()); |
| | | } catch (TeaException error) { |
| | | // 如有需要,请打印 error |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | log.info("申诉结果通知短信发送失败:{}",error.message); |
| | | } catch (Exception _error) { |
| | | TeaException error = new TeaException(_error.getMessage(), _error); |
| | | // 如有需要,请打印 error |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | log.info("申诉结果通知短信发送失败:{}",error.message); |
| | | } |
| | | } |
| | | // 请假待审核提醒 |
| | | public void sendMsg3(String phone) throws Exception { |
| | | com.aliyun.dysmsapi20170525.Client client = MsgUtils.createClient("LTAI5t6SvJEZ9Wv28ranrfLV","hL9wbTdM3rPOLMj0DAhCn90URVzvvw"); |
| | | SendSmsRequest sendSmsRequest = new SendSmsRequest() |
| | | .setSignName("沿海市政") |
| | | .setTemplateCode("SMS_490305062") |
| | | .setPhoneNumbers(phone); |
| | | RuntimeOptions runtime = new RuntimeOptions(); |
| | | try { |
| | | // 复制代码运行请自行打印 API 的返回值 |
| | | SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, runtime); |
| | | log.info("请假待审核提醒短信发送成功:{},{}",sendSmsResponse.getBody().getMessage(),sendSmsResponse.getStatusCode()); |
| | | } catch (TeaException error) { |
| | | // 如有需要,请打印 error |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | log.info("请假待审核提醒短信发送失败:{}",error.message); |
| | | } catch (Exception _error) { |
| | | TeaException error = new TeaException(_error.getMessage(), _error); |
| | | // 如有需要,请打印 error |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | log.info("请假待审核提醒短信发送失败:{}",error.message); |
| | | } |
| | | } |
| | | // 请假结果抄送 |
| | | public void sendMsg4(String phone,String name,String date) throws Exception { |
| | | com.aliyun.dysmsapi20170525.Client client = MsgUtils.createClient("LTAI5t6SvJEZ9Wv28ranrfLV","hL9wbTdM3rPOLMj0DAhCn90URVzvvw"); |
| | | SendSmsRequest sendSmsRequest = new SendSmsRequest() |
| | | .setSignName("沿海市政") |
| | | .setTemplateCode("SMS_490325051") |
| | | .setPhoneNumbers(phone) |
| | | .setTemplateParam("{\"name\":\""+name+"\",\"date\":\""+date+"\"}"); |
| | | RuntimeOptions runtime = new RuntimeOptions(); |
| | | try { |
| | | // 复制代码运行请自行打印 API 的返回值 |
| | | SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, runtime); |
| | | log.info("请假结果抄送短信发送成功:{},{}",sendSmsResponse.getBody().getMessage(),sendSmsResponse.getStatusCode()); |
| | | } catch (TeaException error) { |
| | | // 如有需要,请打印 error |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | log.info("请假结果抄送短信发送失败:{}",error.message); |
| | | } catch (Exception _error) { |
| | | TeaException error = new TeaException(_error.getMessage(), _error); |
| | | // 如有需要,请打印 error |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | log.info("请假结果抄送短信发送失败:{}",error.message); |
| | | } |
| | | } |
| | | // 督察任务整改通知 |
| | | public void sendMsg5(String phone,String point) throws Exception { |
| | | com.aliyun.dysmsapi20170525.Client client = MsgUtils.createClient("LTAI5t6SvJEZ9Wv28ranrfLV","hL9wbTdM3rPOLMj0DAhCn90URVzvvw"); |
| | | SendSmsRequest sendSmsRequest = new SendSmsRequest() |
| | | .setSignName("沿海市政") |
| | | .setTemplateCode("SMS_490375046") |
| | | .setPhoneNumbers(phone) |
| | | .setTemplateParam("{\"point\":\""+point+"\"}"); |
| | | RuntimeOptions runtime = new RuntimeOptions(); |
| | | try { |
| | | // 复制代码运行请自行打印 API 的返回值 |
| | | SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, runtime); |
| | | log.info("督察任务整改通知短信发送成功:{},{}",sendSmsResponse.getBody().getMessage(),sendSmsResponse.getStatusCode()); |
| | | } catch (TeaException error) { |
| | | // 如有需要,请打印 error |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | log.info("督察任务整改通知短信发送失败:{}",error.message); |
| | | } catch (Exception _error) { |
| | | TeaException error = new TeaException(_error.getMessage(), _error); |
| | | // 如有需要,请打印 error |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | log.info("督察任务整改通知短信发送失败:{}",error.message); |
| | | } |
| | | } |
| | | } |
| | |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | TSystemBulletin systemBulletin = systemBulletinService.lambdaQuery().eq(TSystemBulletin::getStatus, 1).last("limit 1").one(); |
| | | return R.ok(systemBulletin); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "首页-数据概览-更多") |
| | | @PostMapping(value = "/dataReport") |
| | |
| | | // 获取今天凌晨00:00:00 和今天23:59:59 类型为LocalDateTime |
| | | LocalDateTime startOfToday = LocalDateTime.of(LocalDate.now(), LocalTime.MIN); |
| | | LocalDateTime endOfToday = LocalDateTime.of(LocalDate.now(), LocalTime.MAX); |
| | | tTaskLambdaQueryWrapper.ge(TTask::getImplementTime, startOfToday); |
| | | tTaskLambdaQueryWrapper.le(TTask::getImplementTime, endOfToday); |
| | | String startOfTodayStr = startOfToday.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | String endOfTodayStr = endOfToday.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | tTaskLambdaQueryWrapper.ge(TTask::getImplementTime, startOfTodayStr); |
| | | tTaskLambdaQueryWrapper.le(TTask::getImplementTime, endOfTodayStr); |
| | | } |
| | | // tTaskLambdaQueryWrapper.ne(TTask::getStatus, 1); |
| | | List<TTask> tasks = taskCleanerService.list(tTaskLambdaQueryWrapper); |
| | |
| | | // 获取今天凌晨00:00:00 和今天23:59:59 类型为LocalDateTime |
| | | LocalDateTime startOfToday = LocalDateTime.of(LocalDate.now(), LocalTime.MIN); |
| | | LocalDateTime endOfToday = LocalDateTime.of(LocalDate.now(), LocalTime.MAX); |
| | | String startOfTodayStr = startOfToday.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | String endOfTodayStr = endOfToday.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | List<TTask> taskToday = taskCleanerService.lambdaQuery() |
| | | .between(TTask::getImplementTime, startOfToday, endOfToday) |
| | | .between(TTask::getImplementTime, startOfTodayStr, endOfTodayStr) |
| | | .eq(TTask::getPatrolInspector, userId).list(); |
| | | List<SysUser> sysUsers = sysUserService.selectAllList(); |
| | | SysUser sysUser = sysUserService.selectUserById(userId); |
| | |
| | | import com.ruoyi.system.query.TaskListQuery; |
| | | import com.ruoyi.system.service.*; |
| | | import com.ruoyi.system.vo.system.*; |
| | | import com.ruoyi.web.controller.tool.EmailUtils; |
| | | import com.ruoyi.web.controller.tool.MsgUtils; |
| | | import com.sun.jna.platform.win32.LMAccess; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | @Resource |
| | | private TDictDataService dictDataService; |
| | | @Resource |
| | | private TNoticeSetService noticeSetService; |
| | | @Resource |
| | | private TLeaveService leaveService; |
| | | @Resource |
| | | private TLeaveAuditService leaveAuditService; |
| | |
| | | private TProblemEscalationService problemEscalationService; |
| | | @Resource |
| | | private TNoticeService noticeService; |
| | | @Resource |
| | | private MsgUtils msgUtils; |
| | | |
| | | @ApiOperation(value = "消息通知列表") |
| | | @PostMapping(value = "/noticeList") |
| | |
| | | public R<List<TaskListAllVO>> listAllTask(@RequestBody AppealListDTO appealListDTO) { |
| | | appealListDTO.setUserId(tokenService.getLoginUserApplet().getUserId() + ""); |
| | | SysUser sysUser = sysUserService.selectUserById(tokenService.getLoginUserApplet().getUserId()); |
| | | if (sysUser.getDeptType()==2){ |
| | | // 公司部门查询所有任务 |
| | | appealListDTO.setUserId(null); |
| | | } |
| | | // if (sysUser.getDeptType()==2){ |
| | | // // 公司部门查询所有任务 |
| | | // appealListDTO.setUserId(null); |
| | | // } |
| | | List<TaskListAllVO> res = appealService.listAllTask(appealListDTO); |
| | | return R.ok(res); |
| | | } |
| | |
| | | |
| | | @ApiOperation(value = "上传督察任务") |
| | | @PostMapping(value = "/addInspector") |
| | | public R<Boolean> addInspector(@RequestBody InspectorAddDTO dto) { |
| | | public R<Boolean> addInspector(@RequestBody InspectorAddDTO dto) throws Exception { |
| | | TTask task = taskCleanerService.getById(dto.getTaskId()); |
| | | TLocation location = locationService.getById(task.getLocationId()); |
| | | SysUser sysUser = sysUserService.selectUserById(Long.valueOf(task.getPatrolInspector())); |
| | | dto.setCommitPerson(tokenService.getLoginUserApplet().getUserId() + ""); |
| | | |
| | | if (dto.getClearStatus() == 1) { |
| | | dto.setStatus(4); |
| | | } else { |
| | | dto.setStatus(1); |
| | | TNotice tNotice = new TNotice(); |
| | | tNotice.setUserId(sysUser.getUserId()+""); |
| | | tNotice.setNoticeContent("【"+location.getLocationName()+"】任务督察不合格,请及时整改!"); |
| | | tNotice.setStatus(1); |
| | | tNotice.setDataId(dto.getTaskId()); |
| | | tNotice.setNoticeType(8); |
| | | noticeService.save(tNotice); |
| | | |
| | | } |
| | | inspectorService.save(dto); |
| | | return R.ok(); |
| | |
| | | |
| | | @ApiOperation(value = "发起请假") |
| | | @PostMapping(value = "/addLeave") |
| | | public R addLeave(@RequestBody LeaveDTO leaveDTO) { |
| | | public R addLeave(@RequestBody LeaveDTO leaveDTO) throws Exception { |
| | | // String startTime1 = leaveDTO.getStartTime1(); |
| | | // // 轉化爲LocalDateTime類型 |
| | | // leaveDTO.setStartTime(LocalDateTime.parse(startTime1, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | |
| | | leaveDTO.setTemplateId(user.getTemplateId()); |
| | | leaveDTO.setLeavePerson(userId + ""); |
| | | leaveService.save(leaveDTO); |
| | | TNoticeSet noticeSet = noticeSetService.lambdaQuery().eq(TNoticeSet::getType, 2).last("limit 1") |
| | | .one(); |
| | | // 邮箱 |
| | | TDictData email = dictDataService.lambdaQuery().eq(TDictData::getDataType,4).one(); |
| | | // 授权码 |
| | | TDictData code = dictDataService.lambdaQuery().eq(TDictData::getDataType,5).one(); |
| | | //项目部负责人、部门负责人、公司成员提交由最终审批人审批; |
| | | if (user.getDeptType() == 2 || sysRole.getRoleName().contains("项目部负责人") || sysRole.getRoleName().contains("部门负责人")) { |
| | | TLeaveAudit tLeaveAudit1 = new TLeaveAudit(); |
| | |
| | | tLeaveAudit1.setAuditId(sysUser.getUserId() + ""); |
| | | tLeaveAudit1.setAuditType(1); |
| | | leaveAuditService.save(tLeaveAudit1); |
| | | // 新增消息 |
| | | TNotice tNotice = new TNotice(); |
| | | tNotice.setUserId(sysUser.getUserId()+""); |
| | | tNotice.setNoticeContent(user.getNickName() + "提交了请假申请,请尽快审核"); |
| | | tNotice.setStatus(1); |
| | | tNotice.setDataId(leaveDTO.getId()); |
| | | tNotice.setNoticeType(6); |
| | | |
| | | switch (noticeSet.getNoticeType()) { |
| | | case 1: |
| | | msgUtils.sendMsg4(sysUser.getPhonenumber()); |
| | | break; |
| | | case 2: |
| | | if (StringUtils.hasLength(email.getDataContent()) && StringUtils.hasLength(code.getDataContent())) { |
| | | EmailUtils.sendEmail(sysUser.getEmail(), email.getDataContent(), code.getDataContent(), "你有一条请假申请待处理,请登录沿海市政质管小程序处理。"); |
| | | } |
| | | break; |
| | | case 3: |
| | | break; |
| | | } |
| | | |
| | | |
| | | noticeService.save(tNotice); |
| | | TLeaveAudit tLeaveAudit2 = new TLeaveAudit(); |
| | | tLeaveAudit2.setLeaveId(leaveDTO.getId()); |
| | | tLeaveAudit2.setAuditStatus(2); |
| | |
| | | tLeaveAudit1.setAuditId(sysUser.getUserId() + ""); |
| | | tLeaveAudit1.setAuditType(1); |
| | | leaveAuditService.save(tLeaveAudit1); |
| | | // 新增消息 |
| | | TNotice tNotice = new TNotice(); |
| | | tNotice.setUserId(sysUser.getUserId()+""); |
| | | tNotice.setNoticeContent(user.getNickName() + "提交了请假申请,请尽快审核"); |
| | | tNotice.setStatus(1); |
| | | tNotice.setDataId(leaveDTO.getId()); |
| | | tNotice.setNoticeType(6); |
| | | noticeService.save(tNotice); |
| | | switch (noticeSet.getNoticeType()) { |
| | | case 1: |
| | | msgUtils.sendMsg4(sysUser.getPhonenumber()); |
| | | break; |
| | | case 2: |
| | | if (StringUtils.hasLength(email.getDataContent()) && StringUtils.hasLength(code.getDataContent())) { |
| | | EmailUtils.sendEmail(sysUser.getEmail(), email.getDataContent(), code.getDataContent(), "你有一条请假申请待处理,请登录沿海市政质管小程序处理。"); |
| | | } |
| | | break; |
| | | case 3: |
| | | break; |
| | | } |
| | | TLeaveAudit tLeaveAudit2 = new TLeaveAudit(); |
| | | tLeaveAudit2.setLeaveId(leaveDTO.getId()); |
| | | tLeaveAudit2.setAuditStatus(2); |
| | |
| | | tLeaveAudit1.setAuditId(sysUser.getUserId() + ""); |
| | | tLeaveAudit1.setAuditType(1); |
| | | leaveAuditService.save(tLeaveAudit1); |
| | | // 新增消息 |
| | | TNotice tNotice = new TNotice(); |
| | | tNotice.setUserId(sysUser.getUserId()+""); |
| | | tNotice.setNoticeContent(user.getNickName() + "提交了请假申请,请尽快审核"); |
| | | tNotice.setStatus(1); |
| | | tNotice.setDataId(leaveDTO.getId()); |
| | | tNotice.setNoticeType(6); |
| | | noticeService.save(tNotice); |
| | | switch (noticeSet.getNoticeType()) { |
| | | case 1: |
| | | msgUtils.sendMsg4(sysUser.getPhonenumber()); |
| | | break; |
| | | case 2: |
| | | if (StringUtils.hasLength(email.getDataContent()) && StringUtils.hasLength(code.getDataContent())) { |
| | | EmailUtils.sendEmail(sysUser.getEmail(), email.getDataContent(), code.getDataContent(), "你有一条请假申请待处理,请登录沿海市政质管小程序处理。"); |
| | | } |
| | | break; |
| | | case 3: |
| | | break; |
| | | } |
| | | TLeaveAudit tLeaveAudit2 = new TLeaveAudit(); |
| | | tLeaveAudit2.setLeaveId(leaveDTO.getId()); |
| | | tLeaveAudit2.setAuditStatus(2); |
| | |
| | | } |
| | | } |
| | | |
| | | // 新增消息 |
| | | TNotice tNotice = new TNotice(); |
| | | tNotice.setUserId(leaveDTO.getAuditId()); |
| | | tNotice.setNoticeContent(user.getNickName() + "提交了请假申请,请尽快审核"); |
| | | tNotice.setStatus(1); |
| | | tNotice.setDataId(leaveDTO.getId()); |
| | | tNotice.setNoticeType(6); |
| | | noticeService.save(tNotice); |
| | | |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | |
| | | @ApiOperation(value = "我的审批-审批") |
| | | @PostMapping(value = "/auditLeave") |
| | | public R<Boolean> auditLeave(@RequestBody LeaveAuditDTO dto) { |
| | | public R<Boolean> auditLeave(@RequestBody LeaveAuditDTO dto) throws Exception { |
| | | |
| | | dto.setAuditId(tokenService.getLoginUserApplet().getUserId() + ""); |
| | | dto.setAuditTime(LocalDateTime.now()); |
| | | leaveService.updateById(dto); |
| | | List<SysUser> sysUsers = sysUserService.selectAllList(); |
| | | SysUser sysUser = sysUserService.selectUserById(Long.valueOf(dto.getLeavePerson())); |
| | | TLeaveAudit leaveAudit = leaveAuditService.lambdaQuery().eq(TLeaveAudit::getLeaveId, dto.getId()) |
| | | .eq(TLeaveAudit::getAuditType, 2).one(); |
| | | TNoticeSet noticeSet = noticeSetService.lambdaQuery().eq(TNoticeSet::getType, 2).last("limit 1") |
| | | .one(); |
| | | // 邮箱 |
| | | TDictData email = dictDataService.lambdaQuery().eq(TDictData::getDataType,4).one(); |
| | | // 授权码 |
| | | TDictData code = dictDataService.lambdaQuery().eq(TDictData::getDataType,5).one(); |
| | | TNotice tNotice = new TNotice(); |
| | | tNotice.setUserId(leaveAudit.getAuditId().split(",")[0]); |
| | | tNotice.setNoticeContent(sysUser.getNickName()+"的请假申请已审核,请查收"); |
| | |
| | | tNotice.setDataId(dto.getId()); |
| | | tNotice.setNoticeType(7); |
| | | noticeService.save(tNotice); |
| | | LocalDateTime startTime = dto.getStartTime(); |
| | | LocalDateTime endTime = dto.getEndTime(); |
| | | SysUser sysUser1 = sysUsers.stream().filter(e -> e.getUserId().equals(Long.valueOf(leaveAudit.getAuditId().split(",")[0]))) |
| | | .findFirst().orElse(null); |
| | | SysUser sysUser2 = sysUsers.stream().filter(e -> e.getUserId().equals(Long.valueOf(leaveAudit.getAuditId().split(",")[1]))) |
| | | .findFirst().orElse(null); |
| | | // 转化为yyyy-MM-dd 格式字符串 |
| | | String leaveTime = startTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))+"至"+endTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | if (sysUser1!=null){ |
| | | switch (noticeSet.getNoticeType()) { |
| | | case 1: |
| | | msgUtils.sendMsg5(sysUser1.getPhonenumber(),sysUser1.getNickName(),leaveTime); |
| | | break; |
| | | case 2: |
| | | if (StringUtils.hasLength(email.getDataContent())&&StringUtils.hasLength(code.getDataContent())){ |
| | | EmailUtils.sendEmail(sysUser1.getEmail(),email.getDataContent(),code.getDataContent(),sysUser1.getNickName()+"的请假申请已审核,请查收"); |
| | | } |
| | | break; |
| | | case 3: |
| | | break; |
| | | } |
| | | } |
| | | |
| | | TNotice tNotice1 = new TNotice(); |
| | | tNotice1.setUserId(leaveAudit.getAuditId().split(",")[1]); |
| | | tNotice1.setNoticeContent(sysUser.getNickName()+"的请假申请已审核,请查收"); |
| | |
| | | tNotice1.setDataId(dto.getId()); |
| | | tNotice1.setNoticeType(7); |
| | | noticeService.save(tNotice1); |
| | | if (sysUser2!=null) { |
| | | switch (noticeSet.getNoticeType()) { |
| | | case 1: |
| | | msgUtils.sendMsg5(sysUser2.getPhonenumber(), sysUser2.getNickName(), leaveTime); |
| | | break; |
| | | case 2: |
| | | if (StringUtils.hasLength(email.getDataContent()) && StringUtils.hasLength(code.getDataContent())) { |
| | | EmailUtils.sendEmail(sysUser2.getEmail(), email.getDataContent(), code.getDataContent(), sysUser2.getNickName() + "的请假申请已审核,请查收"); |
| | | } |
| | | break; |
| | | case 3: |
| | | break; |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
New file |
| | |
| | | package com.ruoyi.web.controller.tool; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import javax.mail.*; |
| | | import javax.mail.internet.*; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.util.Date; |
| | | import java.util.Properties; |
| | | |
| | | @Slf4j |
| | | public class EmailUtils { |
| | | |
| | | public static void sendEmail(String userEmail, String sendEmail, String code, String content) throws Exception { |
| | | // 发送邮箱 |
| | | // 收件人电子邮箱,TODO 换成自己的收件箱 |
| | | String to = userEmail; |
| | | // 发件人电子邮箱,TODO 换成自己的发件箱 |
| | | String from = sendEmail; |
| | | // 指定发送邮件的主机为 |
| | | String host = "smtp.163.com"; |
| | | Properties properties = new Properties(); |
| | | properties.put("mail.smtp.host", host); |
| | | properties.put("mail.smtp.socketFactory.port", "465"); |
| | | properties.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); |
| | | properties.put("mail.smtp.auth", "true"); |
| | | properties.put("mail.smtp.port", "465"); |
| | | properties.put("mail.smtp.ssl.enable", "true"); // 明确开启SSL |
| | | // 获取默认session对象 |
| | | Session session = Session.getDefaultInstance(properties,new Authenticator(){ |
| | | @Override |
| | | public PasswordAuthentication getPasswordAuthentication() |
| | | { |
| | | //发件人邮件用户名、授权码,换成自己的发件箱及授权码 |
| | | return new PasswordAuthentication(from, code); |
| | | } |
| | | }); |
| | | |
| | | try{ |
| | | // 创建默认的 MimeMessage 对象 |
| | | MimeMessage message = new MimeMessage(session); |
| | | // Set From,设置发件人 |
| | | InternetAddress fromMail = new InternetAddress(from); |
| | | //设置发件人名称,TODO 换成自己的发件箱 |
| | | fromMail.setPersonal(MimeUtility.encodeText("沿海市政<" + from + ">")); |
| | | message.setFrom(fromMail); |
| | | // Set To: 设置收件人 |
| | | InternetAddress toMail = new InternetAddress(to); |
| | | // TODO 换成自己的收件箱 |
| | | InternetAddress toMail2 = new InternetAddress(to); |
| | | //发多个邮箱 |
| | | Address[] allRecipients = {toMail, toMail2}; |
| | | message.setRecipients(Message.RecipientType.TO, allRecipients); |
| | | // Set Subject: 邮件主体 |
| | | message.setSubject("沿海市政"); |
| | | // 设置消息体 |
| | | message.setSentDate(new Date()); |
| | | MimeMultipart msgMultipart = new MimeMultipart("mixed"); |
| | | |
| | | // 指定为混合关系 |
| | | message.setContent(msgMultipart); |
| | | // 邮件信息组装 |
| | | //组装的顺序非常重要,一定要先组装文本域,再组装文件 |
| | | MimeBodyPart htmlPart = new MimeBodyPart(); |
| | | // 组装内容 |
| | | htmlPart.setContent(content, "text/html;charset=UTF-8"); |
| | | msgMultipart.addBodyPart(htmlPart); |
| | | try { |
| | | message.saveChanges(); |
| | | //发送 |
| | | //Transport.send(message, message.getAllRecipients()); |
| | | Transport.send(message); |
| | | System.out.println("发送成功"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | }catch (MessagingException | UnsupportedEncodingException mex) { |
| | | mex.printStackTrace(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import com.aliyun.teaopenapi.models.Config; |
| | | import com.aliyun.teautil.models.RuntimeOptions; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | @Component |
| | | @Slf4j |
| | | public class MsgUtils { |
| | | |
| | | @Value("${code.config.accessKeyId}") |
| | | private String accessKeyId; |
| | | @Value("${code.config.accessKeySecret}") |
| | | private String accessKeySecret; |
| | | @Value("${code.config.signName}") |
| | | private String signName; |
| | | @Value("${code.config.templateCode}") |
| | | private String templateCode; |
| | | @Value("${code.config.signNameTest}") |
| | | private String signNameTest; |
| | | @Value("${code.config.templateCodeTest}") |
| | | private String templateCodeTest; |
| | | |
| | | |
| | | /** |
| | | * 使用AK&SK初始化账号Client |
| | |
| | | return new com.aliyun.dysmsapi20170525.Client(config); |
| | | } |
| | | |
| | | public void sendMsg(String phone,String code) throws Exception { |
| | | com.aliyun.dysmsapi20170525.Client client = MsgUtils.createClient(accessKeyId,accessKeySecret); |
| | | // 任务审核结果通知 |
| | | public void sendMsg1(String phone,String point,String result) throws Exception { |
| | | com.aliyun.dysmsapi20170525.Client client = MsgUtils.createClient("LTAI5t6SvJEZ9Wv28ranrfLV","hL9wbTdM3rPOLMj0DAhCn90URVzvvw"); |
| | | SendSmsRequest sendSmsRequest = new SendSmsRequest() |
| | | .setSignName(signName) |
| | | .setTemplateCode(templateCode) |
| | | .setSignName("沿海市政") |
| | | .setTemplateCode("SMS_490460059") |
| | | .setPhoneNumbers(phone) |
| | | .setTemplateParam("{\"code\":\""+code+"\"}"); |
| | | .setTemplateParam("{\"point\":\""+point+"\",\"result\":\""+result+"\"}"); |
| | | RuntimeOptions runtime = new RuntimeOptions(); |
| | | try { |
| | | // 复制代码运行请自行打印 API 的返回值 |
| | | SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, runtime); |
| | | log.info("短信发送成功:{},{}",sendSmsResponse.getBody().getMessage(),sendSmsResponse.getStatusCode()); |
| | | log.info("任务审核结果通知短信发送成功:{},{}",sendSmsResponse.getBody().getMessage(),sendSmsResponse.getStatusCode()); |
| | | } catch (TeaException error) { |
| | | // 如有需要,请打印 error |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | log.info("短信发送失败:{}",error.message); |
| | | log.info("任务审核结果通知短信发送失败:{}",error.message); |
| | | } catch (Exception _error) { |
| | | TeaException error = new TeaException(_error.getMessage(), _error); |
| | | // 如有需要,请打印 error |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | log.info("短信发送失败:{}",error.message); |
| | | log.info("任务审核结果通知短信发送失败:{}",error.message); |
| | | } |
| | | } |
| | | // 今日任务未完成 |
| | | public void sendMsg2(String phone,String count) throws Exception { |
| | | com.aliyun.dysmsapi20170525.Client client = MsgUtils.createClient("LTAI5t6SvJEZ9Wv28ranrfLV","hL9wbTdM3rPOLMj0DAhCn90URVzvvw"); |
| | | SendSmsRequest sendSmsRequest = new SendSmsRequest() |
| | | .setSignName("沿海市政") |
| | | .setTemplateCode("SMS_490450039") |
| | | .setPhoneNumbers(phone) |
| | | .setTemplateParam("{\"count\":\""+count+"\"}"); |
| | | RuntimeOptions runtime = new RuntimeOptions(); |
| | | try { |
| | | // 复制代码运行请自行打印 API 的返回值 |
| | | SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, runtime); |
| | | log.info("今日任务未完成短信发送成功:{},{}",sendSmsResponse.getBody().getMessage(),sendSmsResponse.getStatusCode()); |
| | | } catch (TeaException error) { |
| | | // 如有需要,请打印 error |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | log.info("今日任务未完成短信发送失败:{}",error.message); |
| | | } catch (Exception _error) { |
| | | TeaException error = new TeaException(_error.getMessage(), _error); |
| | | // 如有需要,请打印 error |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | log.info("今日任务未完成短信发送失败:{}",error.message); |
| | | } |
| | | } |
| | | // 申诉结果通知通知 |
| | | public void sendMsg3(String phone,String point,String result) throws Exception { |
| | | com.aliyun.dysmsapi20170525.Client client = MsgUtils.createClient("LTAI5t6SvJEZ9Wv28ranrfLV","hL9wbTdM3rPOLMj0DAhCn90URVzvvw"); |
| | | SendSmsRequest sendSmsRequest = new SendSmsRequest() |
| | | .setSignName("沿海市政") |
| | | .setTemplateCode("SMS_490535047") |
| | | .setPhoneNumbers(phone) |
| | | .setTemplateParam("{\"point\":\""+point+"\",\"result\":\""+result+"\"}"); |
| | | RuntimeOptions runtime = new RuntimeOptions(); |
| | | try { |
| | | // 复制代码运行请自行打印 API 的返回值 |
| | | SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, runtime); |
| | | log.info("申诉结果通知短信发送成功:{},{}",sendSmsResponse.getBody().getMessage(),sendSmsResponse.getStatusCode()); |
| | | } catch (TeaException error) { |
| | | // 如有需要,请打印 error |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | log.info("申诉结果通知短信发送失败:{}",error.message); |
| | | } catch (Exception _error) { |
| | | TeaException error = new TeaException(_error.getMessage(), _error); |
| | | // 如有需要,请打印 error |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | log.info("申诉结果通知短信发送失败:{}",error.message); |
| | | } |
| | | } |
| | | // 请假待审核提醒 |
| | | public void sendMsg4(String phone) throws Exception { |
| | | com.aliyun.dysmsapi20170525.Client client = MsgUtils.createClient("LTAI5t6SvJEZ9Wv28ranrfLV","hL9wbTdM3rPOLMj0DAhCn90URVzvvw"); |
| | | SendSmsRequest sendSmsRequest = new SendSmsRequest() |
| | | .setSignName("沿海市政") |
| | | .setTemplateCode("SMS_490305062") |
| | | .setPhoneNumbers(phone); |
| | | RuntimeOptions runtime = new RuntimeOptions(); |
| | | try { |
| | | // 复制代码运行请自行打印 API 的返回值 |
| | | SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, runtime); |
| | | log.info("请假待审核提醒短信发送成功:{},{}",sendSmsResponse.getBody().getMessage(),sendSmsResponse.getStatusCode()); |
| | | } catch (TeaException error) { |
| | | // 如有需要,请打印 error |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | log.info("请假待审核提醒短信发送失败:{}",error.message); |
| | | } catch (Exception _error) { |
| | | TeaException error = new TeaException(_error.getMessage(), _error); |
| | | // 如有需要,请打印 error |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | log.info("请假待审核提醒短信发送失败:{}",error.message); |
| | | } |
| | | } |
| | | // 请假结果抄送 |
| | | public void sendMsg5(String phone,String name,String date) throws Exception { |
| | | com.aliyun.dysmsapi20170525.Client client = MsgUtils.createClient("LTAI5t6SvJEZ9Wv28ranrfLV","hL9wbTdM3rPOLMj0DAhCn90URVzvvw"); |
| | | SendSmsRequest sendSmsRequest = new SendSmsRequest() |
| | | .setSignName("沿海市政") |
| | | .setTemplateCode("SMS_490325051") |
| | | .setPhoneNumbers(phone) |
| | | .setTemplateParam("{\"name\":\""+name+"\",\"date\":\""+date+"\"}"); |
| | | RuntimeOptions runtime = new RuntimeOptions(); |
| | | try { |
| | | // 复制代码运行请自行打印 API 的返回值 |
| | | SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, runtime); |
| | | log.info("请假结果抄送短信发送成功:{},{}",sendSmsResponse.getBody().getMessage(),sendSmsResponse.getStatusCode()); |
| | | } catch (TeaException error) { |
| | | // 如有需要,请打印 error |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | log.info("请假结果抄送短信发送失败:{}",error.message); |
| | | } catch (Exception _error) { |
| | | TeaException error = new TeaException(_error.getMessage(), _error); |
| | | // 如有需要,请打印 error |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | log.info("请假结果抄送短信发送失败:{}",error.message); |
| | | } |
| | | } |
| | | // 督察任务整改通知 |
| | | public void sendMsg6(String phone,String point) throws Exception { |
| | | com.aliyun.dysmsapi20170525.Client client = MsgUtils.createClient("LTAI5t6SvJEZ9Wv28ranrfLV","hL9wbTdM3rPOLMj0DAhCn90URVzvvw"); |
| | | SendSmsRequest sendSmsRequest = new SendSmsRequest() |
| | | .setSignName("沿海市政") |
| | | .setTemplateCode("SMS_490375046") |
| | | .setPhoneNumbers(phone) |
| | | .setTemplateParam("{\"point\":\""+point+"\"}"); |
| | | RuntimeOptions runtime = new RuntimeOptions(); |
| | | try { |
| | | // 复制代码运行请自行打印 API 的返回值 |
| | | SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, runtime); |
| | | log.info("督察任务整改通知短信发送成功:{},{}",sendSmsResponse.getBody().getMessage(),sendSmsResponse.getStatusCode()); |
| | | } catch (TeaException error) { |
| | | // 如有需要,请打印 error |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | log.info("督察任务整改通知短信发送失败:{}",error.message); |
| | | } catch (Exception _error) { |
| | | TeaException error = new TeaException(_error.getMessage(), _error); |
| | | // 如有需要,请打印 error |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | log.info("督察任务整改通知短信发送失败:{}",error.message); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | List<SysUser> selectUserByTempLateId(@Param("templateId")String templateId); |
| | | |
| | | List<SysUser> selectUserByDeptId(@Param("id")String id); |
| | | List<SysUser> selectUserByDeptId(@Param("ids")List<String> ids); |
| | | |
| | | List<TaskFinishListVO> pageListReport(@Param("query")DataReportQuery query, @Param("pageInfo")PageInfo<TaskFinishListVO> pageInfo); |
| | | |
| | |
| | | */ |
| | | public interface TEarlyWarningMapper extends BaseMapper<TEarlyWarning> { |
| | | |
| | | List<TaskWarningVO> pageList(@Param("query")TaskWarningQuery query, @Param("pageInfo")PageInfo<TaskWarningVO> pageInfo); |
| | | List<TaskWarningVO> pageList(@Param("query")TaskWarningQuery query); |
| | | |
| | | } |
| | |
| | | */ |
| | | List<SysUser> selectListByDeptIds(List<String> projectIds); |
| | | |
| | | List<SysUser> selectUserByDeptId(String id); |
| | | List<SysUser> selectUserByDeptId(List<String> ids); |
| | | |
| | | PageInfo<TaskFinishListVO> pageListReport(DataReportQuery dataReportQuery); |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<SysUser> selectUserByDeptId(String id) { |
| | | return userMapper.selectUserByDeptId(id); |
| | | public List<SysUser> selectUserByDeptId(List<String> ids) { |
| | | return userMapper.selectUserByDeptId(ids); |
| | | } |
| | | |
| | | @Override |
| | |
| | | import com.ruoyi.system.service.TEarlyWarningService; |
| | | import com.ruoyi.system.vo.system.CleanerListVO; |
| | | import com.ruoyi.system.vo.system.TaskWarningVO; |
| | | import com.sun.org.apache.bcel.internal.generic.NEW; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Override |
| | | public PageInfo<TaskWarningVO> pageList(TaskWarningQuery query) { |
| | | List<TTask> taskList = taskMapper.selectList(null); |
| | | |
| | | PageInfo<TaskWarningVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); |
| | | List<TaskWarningVO> list = this.baseMapper.pageList(query,pageInfo); |
| | | List<TaskWarningVO> list = this.baseMapper.pageList(query); |
| | | List<String> strings = new ArrayList<>(); |
| | | List<String> taskIds = new ArrayList<>(); |
| | | List<TaskWarningVO> res = new ArrayList<>(); |
| | | for (TaskWarningVO taskWarningVO : list) { |
| | | String[] split = taskWarningVO.getTaskId().split(","); |
| | | TTask tTask = taskList.stream().filter(e -> e.getId().equals(split[0])).findFirst().orElse(null); |
| | |
| | | } |
| | | } |
| | | // 去除最后一位 |
| | | taskWarningVO.setTaskCode(taskWarningVO.getTaskCode().substring(0, taskWarningVO.getTaskCode().length() - 1)); |
| | | if (StringUtils.hasLength(taskCode.toString())){ |
| | | taskWarningVO.setTaskCode(taskCode.substring(0, taskCode.length() - 1)); |
| | | strings.add(taskWarningVO.getTaskCode()); |
| | | } |
| | | String format = taskWarningVO.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | |
| | | taskIds.add(taskWarningVO.getTaskId()+","+format); |
| | | |
| | | } |
| | | |
| | | for (String string : taskIds) { |
| | | if (string.split(",").length>2){ |
| | | List<String> userIds = new ArrayList<>(); |
| | | List<TaskWarningVO> temp = new ArrayList<>(); |
| | | String s1 = string.split(",")[3]; |
| | | // 转化为LocalDateTime |
| | | LocalDateTime localDateTime = LocalDateTime.parse(s1, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | // 点位不合格预警 |
| | | for (String s : string.split(",")) { |
| | | TaskWarningVO taskWarningVO = new TaskWarningVO(); |
| | | taskWarningVO.setWarningType(2); |
| | | taskWarningVO.setCreateTime(localDateTime); |
| | | TTask tTask = taskList.stream().filter(e -> e.getId().equals(s)).findFirst().orElse(null); |
| | | // 任务所属巡检员 |
| | | if (tTask!=null){ |
| | | SysUser sysUser = sysUserMapper.selectUserById(Long.valueOf(tTask.getPatrolInspector())); |
| | | if (!userIds.contains(tTask.getPatrolInspector())){ |
| | | userIds.add(tTask.getPatrolInspector()); |
| | | taskWarningVO.setTaskCode(tTask.getTaskCode()); |
| | | TLocation tLocation = locationMapper.selectById(tTask.getLocationId()); |
| | | if (tLocation!=null){ |
| | | taskWarningVO.setLocationName(tLocation.getLocationName()); |
| | | } |
| | | SysUser sysUser = sysUserMapper.selectUserById(Long.valueOf(tTask.getPatrolInspector())); |
| | | if (sysUser!=null){ |
| | | taskWarningVO.setPhonenumber(sysUser.getPhonenumber()); |
| | | taskWarningVO.setPatrolInspectorName(sysUser.getNickName()); |
| | |
| | | taskWarningVO.setDeptName(tDept.getDeptName()); |
| | | } |
| | | } |
| | | temp.add(taskWarningVO); |
| | | res.add(taskWarningVO); |
| | | }else{ |
| | | for (TaskWarningVO warningVO : temp) { |
| | | if (warningVO.getPhonenumber().equals(sysUser.getPhonenumber()+"")){ |
| | | warningVO.setTaskCode(warningVO.getTaskCode()+","+tTask.getTaskCode()); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }else{ |
| | | String s1 = string.split(",")[1]; |
| | | // 转化为LocalDateTime |
| | | LocalDateTime localDateTime = LocalDateTime.parse(s1, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | // 超时预警 |
| | | TaskWarningVO taskWarningVO = new TaskWarningVO(); |
| | | taskWarningVO.setCreateTime(localDateTime); |
| | | |
| | | taskWarningVO.setWarningType(1); |
| | | TTask tTask = taskList.stream().filter(e -> e.getId().equals(string.split(",")[0])).findFirst().orElse(null); |
| | | // 任务所属巡检员 |
| | | if (tTask!=null){ |
| | | SysUser sysUser = sysUserMapper.selectUserById(Long.valueOf(tTask.getPatrolInspector())); |
| | | taskWarningVO.setTaskCode(tTask.getTaskCode()); |
| | | TLocation tLocation = locationMapper.selectById(tTask.getLocationId()); |
| | | if (tLocation!=null){ |
| | | taskWarningVO.setLocationName(tLocation.getLocationName()); |
| | | } |
| | | pageInfo.setRecords(list); |
| | | if (sysUser!=null){ |
| | | taskWarningVO.setPhonenumber(sysUser.getPhonenumber()); |
| | | taskWarningVO.setPatrolInspectorName(sysUser.getNickName()); |
| | | if (sysUser.getDeptType() == 1){ |
| | | TProjectDept tProjectDept = projectDeptMapper.selectById(sysUser.getDeptId()); |
| | | if (!tProjectDept.getParentId().equals("0")){ |
| | | TProjectDept tProjectDept1 = projectDeptMapper.selectById(tProjectDept.getParentId()); |
| | | taskWarningVO.setDeptName(tProjectDept1.getProjectName()+">"+tProjectDept.getProjectName()); |
| | | }else{ |
| | | taskWarningVO.setDeptName(tProjectDept.getProjectName()); |
| | | } |
| | | }else{ |
| | | TDept tDept = deptMapper.selectById(sysUser.getDeptId()); |
| | | taskWarningVO.setDeptName(tDept.getDeptName()); |
| | | } |
| | | } |
| | | res.add(taskWarningVO); |
| | | } |
| | | } |
| | | } |
| | | pageInfo.setTotal(res.size()); |
| | | // 手动对res进行分页 |
| | | res = res.stream().skip((long) (query.getPageNum() - 1) * query.getPageSize()).limit(query.getPageSize()).collect(Collectors.toList()); |
| | | pageInfo.setRecords(res); |
| | | return pageInfo; |
| | | } |
| | | } |
| | |
| | | for (InspectorListVO taskListVO : list) { |
| | | TTask tTask = tTasks.stream().filter(e -> e.getId().equals(taskListVO.getTaskId())).findFirst().orElse(null); |
| | | if (tTask!=null){ |
| | | taskListVO.setTaskType(tTask.getTaskType()); |
| | | SysUser sysUser = sysUsers.stream().filter(e -> e.getUserId().equals(Long.valueOf(tTask.getPatrolInspector()))).findFirst().orElse(null); |
| | | if (sysUser!=null){ |
| | | if (sysUser.getDeptType()==2){ |
| | |
| | | @Excel(name = "清洁情况 1合格2不合格", orderNum = "7", width = 20,replace = {"1_合格","2_不合格"}) |
| | | |
| | | private Integer clearStatus; |
| | | @ApiModelProperty(value = "任务类型1日常任务 2自建任务") |
| | | @Excel(name = "任务类型", orderNum = "8", width = 20,replace = {"1_日常任务","2_自建任务"}) |
| | | |
| | | private Integer taskType; |
| | | |
| | | } |
| | |
| | | |
| | | <sql id="selectRoleVo"> |
| | | select distinct r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.menu_check_strictly, r.dept_check_strictly, |
| | | r.status, r.del_flag, r.create_time, r.remark,r.postType,r.removeDays |
| | | r.status, r.del_flag, r.create_time, r.remark,r.postType,r.removeDays,r.role_type as roleType |
| | | from sys_role r |
| | | left join sys_user_role ur on ur.role_id = r.role_id |
| | | left join sys_user u on u.user_id = ur.user_id |
| | |
| | | </select> |
| | | <select id="selectUserByDeptId" resultType="com.ruoyi.common.core.domain.entity.SysUser"> |
| | | select * from sys_user |
| | | where deptId = #{id} |
| | | where 1=1 |
| | | <if test="ids != null and ids.size()>0"> |
| | | AND deptId IN |
| | | <foreach collection="ids" separator="," item="id" open="(" close=")"> |
| | | #{id} |
| | | </foreach> |
| | | </if> |
| | | and status = 0 |
| | | and del_flag = 0 |
| | | </select> |
| | |
| | | <if test="query.startTime != null and startTime != ''"> |
| | | and (t1.create_time between #{startTime} and #{endTime}) |
| | | </if> |
| | | <if test="query.warningType != null "> |
| | | and t1.warning_type= #{query.warningType} |
| | | </if> |
| | | and t1.`disabled` = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()} |
| | | order by t1.create_time desc |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | <if test="query.status != null"> |
| | | and t1.status = #{query.status} |
| | | </if> |
| | | <if test="query.startTime != null and startTime != ''"> |
| | | and (t5.implement_time between #{startTime} and #{endTime}) |
| | | <if test="query.startTime != null and query.startTime != ''"> |
| | | and (t1.create_time between #{query.startTime} and #{query.endTime}) |
| | | </if> |
| | | order by t1.create_time desc |
| | | </select> |
| | | <select id="pageListExport" resultType="com.ruoyi.system.vo.system.InspectorListVO"> |
| | | select t1.*,t2.location_name as locationName,t3.location_name as locationTypeName, |
| | |
| | | #{id} |
| | | </foreach> |
| | | </if> |
| | | order by t1.create_time desc |
| | | </select> |
| | | |
| | | </mapper> |