@@ -9,7 +9,6 @@ import com.tuoheng.admin.conver.InspectionConverMapper; | |||
import com.tuoheng.admin.entity.*; | |||
import com.tuoheng.admin.enums.DataPermissionEnum; | |||
import com.tuoheng.admin.enums.MarkEnum; | |||
import com.tuoheng.admin.enums.code.inspection.QueryInspectionPageListCodeEnum; | |||
import com.tuoheng.admin.mapper.*; | |||
import com.tuoheng.admin.request.inspection.QueryInspectionPageListRequest; | |||
import com.tuoheng.admin.service.inspection.query.handle.GenerateInspectionFieldHander; | |||
@@ -125,14 +124,14 @@ public class QueryInspectionPageListService { | |||
return result; | |||
} | |||
if(StringUtils.isEmpty(request.getDeptId())){ | |||
List<String> deptIdList = new ArrayList<>(); | |||
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { | |||
} else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) { | |||
deptIdList = deptMapper.selectAllChildListById(user.getDeptId()); | |||
} else if (DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) { | |||
deptIdList.add(user.getDeptId()); | |||
} | |||
if (StringUtils.isEmpty(request.getDeptId())) { | |||
List<String> deptIdList = new ArrayList<>(); | |||
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { | |||
} else if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission()) { | |||
deptIdList = deptMapper.selectAllChildListById(user.getDeptId()); | |||
} else if (DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) { | |||
deptIdList.add(user.getDeptId()); | |||
} | |||
request.setDeptIdList(deptIdList); | |||
} | |||
@@ -200,8 +199,8 @@ public class QueryInspectionPageListService { | |||
/** | |||
* 管理员和普通用户可查本部门及子部门的任务 | |||
* 1)、如果前端检索条件,传了部门Id,则根据deptId来查 | |||
* 2)、如果前端检索条件,部门Id为空,则表示查本部门及子部门的任务 | |||
* 1)、如果前端检索条件,传了部门Id,则根据deptId来查 | |||
* 2)、如果前端检索条件,部门Id为空,则表示查本部门及子部门的任务 | |||
* | |||
* @param request | |||
* @return | |||
@@ -221,8 +220,8 @@ public class QueryInspectionPageListService { | |||
} | |||
/** | |||
* 1)、查找已确认问题数、发现问题数字段 | |||
* 2)、判断是否有操作权限:立即执行、直播、回放、问题详情、问题核实、重新提交 | |||
* 1)、查找已确认问题数、发现问题数字段 | |||
* 2)、判断是否有操作权限:立即执行、直播、回放、问题详情、问题核实、重新提交 | |||
* | |||
* @param user | |||
* @param dept | |||
@@ -288,8 +287,8 @@ public class QueryInspectionPageListService { | |||
} | |||
/** | |||
* 设置任务列表中每一个任务的部门名称 | |||
* 查询到的任务列表中的部门Id,作为部门id列表,查询所有的部门,该结果数据量不会太大,放到map中 | |||
* 设置任务列表中每一个任务的部门名称 | |||
* 查询到的任务列表中的部门Id,作为部门id列表,查询所有的部门,该结果数据量不会太大,放到map中 | |||
* | |||
* @param inspectionList | |||
* @return |
@@ -23,7 +23,7 @@ public class WxController { | |||
@GetMapping("/getOpenId/{code}") | |||
public JsonResult getOpenId(@PathVariable("code") String code) { | |||
log.info("进入获取openId接口"); | |||
return iWxService.openid(code); | |||
return iWxService.openId(code); | |||
} | |||
@PostMapping("/send/message") |
@@ -66,11 +66,6 @@ public class InspectionQuery extends BaseQuery { | |||
*/ | |||
private String time; | |||
/** | |||
* 结束日期(传入) | |||
*/ | |||
// private String endTime; | |||
/** | |||
* 日期,日期类型 | |||
*/ |
@@ -14,7 +14,9 @@ public enum UserCodeEnum { | |||
USER_NAME_IS_NULL(1240102, "登录用户名为空"), | |||
OLD_PASSWORD_IS_ERROR(1240103, "密码错误"), | |||
PASSWORD_REVISE_FAIL(1240104, "密码修改失败"), | |||
PASSWORD_REVISE_SUCCESS(1240105, "密码修改成功"); | |||
PASSWORD_REVISE_SUCCESS(1240105, "密码修改成功"), | |||
USER_ID_IS_NULL(1240106, "登录用户id为空"), | |||
USER_0PENID_IS_NULL(1240107, "用户openID为空"); | |||
/** | |||
* 错误码 |
@@ -14,7 +14,7 @@ public interface IWxService { | |||
* @param code | |||
* @return | |||
*/ | |||
JsonResult openid(String code); | |||
JsonResult openId(String code); | |||
/** | |||
* 发送消息 |
@@ -74,34 +74,24 @@ public class InspectionServiceImpl implements IInspectionService { | |||
if (null == query.getLimit() && null == query.getPage()) { | |||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||
} | |||
//登录用户信息 | |||
User user = CurrentUserUtil.getUserInfo(); | |||
Integer type = user.getDataPermission(); | |||
if (null == type) { | |||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||
} | |||
String tenantId = user.getTenantId(); | |||
query.setTenantId(tenantId); | |||
//初始部门id | |||
String deptIdInt = query.getDeptId(); | |||
//开始、结束时间 | |||
if (StringUtils.isNotEmpty(query.getTime())) { | |||
Date startTime = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, query.getTime() + " 00:00:00"); | |||
Date endTime = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, query.getTime() + " 23:59:59"); | |||
query.setStartTimeDate(startTime); | |||
query.setEndTimeDate(endTime); | |||
} | |||
//获取当前部门对应的巡检任务 | |||
//获取分页数据 | |||
IPage<Inspection> page = new Page<>(query.getPage(), query.getLimit()); | |||
IPage<InspectionInfoVo> pageDataVo = new Page<>(query.getPage(), query.getLimit()); | |||
Date startTime = null; | |||
Date endTime = null; | |||
if (StringUtils.isNotEmpty(query.getTime())) { | |||
startTime = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, query.getTime() + " 00:00:00"); | |||
endTime = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, query.getTime() + " 23:59:59"); | |||
} | |||
query.setStartTimeDate(startTime); | |||
query.setEndTimeDate(endTime); | |||
List<InspectionInfoVo> inspectionInfoVoList = new ArrayList<>(); | |||
//用户角色判断 1超级管理员 2部门管理员 3普通用户 | |||
if (DataPermissionEnum.ALL.getCode() == type) { | |||
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) { | |||
query.setDeptId(""); // 要查所有部门的, 因此不通过deptId过滤 | |||
IPage<InspectionInfoVo> IPageData = inspectionMapper.queryPage(page, query); | |||
IPageData.getRecords().stream().forEach(x -> { | |||
@@ -129,16 +119,14 @@ public class InspectionServiceImpl implements IInspectionService { | |||
for (InspectionInfoVo record : records) { | |||
inspectionInfoVoList.add(record); | |||
} | |||
//构建返回结果对象 | |||
pageDataVo.setPages(IPageData.getPages()); | |||
pageDataVo.setCurrent(IPageData.getCurrent()); | |||
pageDataVo.setSize(IPageData.getSize()); | |||
pageDataVo.setTotal(IPageData.getTotal()); | |||
} | |||
//登录用户角色为部门管理员或普通用户 | |||
if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == type || DataPermissionEnum.DEPT.getCode() == type) { | |||
if (DataPermissionEnum.DEPT_AND_SUB_DEPT.getCode() == user.getDataPermission() || DataPermissionEnum.DEPT.getCode() == user.getDataPermission()) { | |||
// 根据部门id获取此部门id和所有下级部门id封装list集合 | |||
List<String> deptLists = deptMapper.selectAllChildListById(query.getDeptId()); | |||
if (StringUtils.isEmpty(deptLists)) { | |||
@@ -175,11 +163,11 @@ public class InspectionServiceImpl implements IInspectionService { | |||
inspectionInfoVoList.add(record); | |||
} | |||
//构建返回结果对象 | |||
pageDataVo.setPages(pageData.getPages()); | |||
pageDataVo.setCurrent(pageData.getCurrent()); | |||
pageDataVo.setSize(pageData.getSize()); | |||
pageDataVo.setTotal(pageData.getTotal()); | |||
} | |||
} | |||
Map<Integer, AirportLineVo> airportLineMap = this.getAirportLineMap(inspectionInfoVoList); |
@@ -58,7 +58,11 @@ public class WxServiceImpl implements IWxService { | |||
* @return | |||
*/ | |||
@Override | |||
public JsonResult openid(String code) { | |||
public JsonResult openId(String code) { | |||
if (StringUtils.isEmpty(code)) { | |||
log.info("code为空"); | |||
return JsonResult.error("code为空"); | |||
} | |||
String userId = CurrentUserUtil.getUserId(); | |||
String openidResult = GetOpenIdUtil.getopenid(code, CommonConfig.appId, CommonConfig.appSecret); | |||
if (null != JSONObject.parseObject(openidResult).getInteger("errcode") || | |||
@@ -74,24 +78,23 @@ public class WxServiceImpl implements IWxService { | |||
//根据当前登录用户id查询授权表是否存在一条授权数据 | |||
UserAuthorize beforeUserAuthorize = userAuthorizeMapper.selectOne(Wrappers.<UserAuthorize>lambdaQuery() | |||
.eq(UserAuthorize::getUserId, userId) | |||
.eq(UserAuthorize::getOpenId, openid) | |||
.eq(UserAuthorize::getMark, MarkEnum.VALID.getCode())); | |||
if (ObjectUtil.isNull(beforeUserAuthorize)) { | |||
UserAuthorize userAuthorize = new UserAuthorize(); | |||
if (StringUtils.isNotEmpty(openid)) { | |||
//查询出来openId数据入库 | |||
userAuthorize.setOpenId(openid); | |||
} | |||
userAuthorize.setUserId(userId); | |||
userAuthorize.setCreateTime(DateUtils.now()); | |||
if (StringUtils.isNotEmpty(userId)) { | |||
userAuthorize.setCreateUser(userId); | |||
} | |||
int result = userAuthorizeMapper.insert(userAuthorize); | |||
if (ObjectUtil.isNotEmpty(beforeUserAuthorize)) { | |||
log.info("该用户已做过授权, openid={}", openid); | |||
return JsonResult.error("该用户已做过授权"); | |||
} | |||
if (result <= 0) { | |||
return JsonResult.error("授权数据入库失败"); | |||
} | |||
UserAuthorize userAuthorize = new UserAuthorize(); | |||
userAuthorize.setOpenId(openid); | |||
userAuthorize.setUserId(userId); | |||
userAuthorize.setCreateTime(DateUtils.now()); | |||
userAuthorize.setCreateUser(userId); | |||
int result = userAuthorizeMapper.insert(userAuthorize); | |||
if (result <= 0) { | |||
return JsonResult.error("授权数据入库失败"); | |||
} | |||
//关联登录用户,已经做过授权 修改授权标识 | |||
User user = CurrentUserUtil.getUserInfo(); | |||
if (ObjectUtil.isEmpty(user)) { | |||
@@ -102,6 +105,7 @@ public class WxServiceImpl implements IWxService { | |||
user.setUpdateUser(userId); | |||
int count = userMapper.updateById(user); | |||
if (count <= 0) { | |||
log.info("用户授权标识更新失败, userId={}", userId); | |||
return JsonResult.error("用户授权标识更新失败"); | |||
} | |||
return JsonResult.success(); | |||
@@ -136,7 +140,6 @@ public class WxServiceImpl implements IWxService { | |||
//失效时间 = 当前时间+有效期(提前一分钟,也可以不提前) | |||
expiresTime = System.currentTimeMillis() + (expires_in - 60) * 1000; | |||
} | |||
return accessToken; | |||
} | |||