Browse Source

Merge branch 'develop' of gitadmin/tuoheng_freeway into release

pull/393/head
wanjing 10 months ago
parent
commit
736bb21396
7 changed files with 51 additions and 64 deletions
  1. +14
    -15
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/QueryInspectionPageListService.java
  2. +1
    -1
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/controller/WxController.java
  3. +0
    -5
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/entity/query/InspectionQuery.java
  4. +3
    -1
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/enums/UserCodeEnum.java
  5. +1
    -1
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/IWxService.java
  6. +12
    -24
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/InspectionServiceImpl.java
  7. +20
    -17
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/WxServiceImpl.java

+ 14
- 15
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/QueryInspectionPageListService.java View File

import com.tuoheng.admin.entity.*; import com.tuoheng.admin.entity.*;
import com.tuoheng.admin.enums.DataPermissionEnum; import com.tuoheng.admin.enums.DataPermissionEnum;
import com.tuoheng.admin.enums.MarkEnum; import com.tuoheng.admin.enums.MarkEnum;
import com.tuoheng.admin.enums.code.inspection.QueryInspectionPageListCodeEnum;
import com.tuoheng.admin.mapper.*; import com.tuoheng.admin.mapper.*;
import com.tuoheng.admin.request.inspection.QueryInspectionPageListRequest; import com.tuoheng.admin.request.inspection.QueryInspectionPageListRequest;
import com.tuoheng.admin.service.inspection.query.handle.GenerateInspectionFieldHander; import com.tuoheng.admin.service.inspection.query.handle.GenerateInspectionFieldHander;
return result; 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); request.setDeptIdList(deptIdList);
} }




/** /**
* 管理员和普通用户可查本部门及子部门的任务 * 管理员和普通用户可查本部门及子部门的任务
* 1)、如果前端检索条件,传了部门Id,则根据deptId来查
* 2)、如果前端检索条件,部门Id为空,则表示查本部门及子部门的任务
* 1)、如果前端检索条件,传了部门Id,则根据deptId来查
* 2)、如果前端检索条件,部门Id为空,则表示查本部门及子部门的任务
* *
* @param request * @param request
* @return * @return
} }


/** /**
* 1)、查找已确认问题数、发现问题数字段
* 2)、判断是否有操作权限:立即执行、直播、回放、问题详情、问题核实、重新提交
* 1)、查找已确认问题数、发现问题数字段
* 2)、判断是否有操作权限:立即执行、直播、回放、问题详情、问题核实、重新提交
* *
* @param user * @param user
* @param dept * @param dept
} }


/** /**
* 设置任务列表中每一个任务的部门名称
* 查询到的任务列表中的部门Id,作为部门id列表,查询所有的部门,该结果数据量不会太大,放到map中
* 设置任务列表中每一个任务的部门名称
* 查询到的任务列表中的部门Id,作为部门id列表,查询所有的部门,该结果数据量不会太大,放到map中
* *
* @param inspectionList * @param inspectionList
* @return * @return

+ 1
- 1
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/controller/WxController.java View File

@GetMapping("/getOpenId/{code}") @GetMapping("/getOpenId/{code}")
public JsonResult getOpenId(@PathVariable("code") String code) { public JsonResult getOpenId(@PathVariable("code") String code) {
log.info("进入获取openId接口"); log.info("进入获取openId接口");
return iWxService.openid(code);
return iWxService.openId(code);
} }


@PostMapping("/send/message") @PostMapping("/send/message")

+ 0
- 5
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/entity/query/InspectionQuery.java View File

*/ */
private String time; private String time;


/**
* 结束日期(传入)
*/
// private String endTime;

/** /**
* 日期,日期类型 * 日期,日期类型
*/ */

+ 3
- 1
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/enums/UserCodeEnum.java View File

USER_NAME_IS_NULL(1240102, "登录用户名为空"), USER_NAME_IS_NULL(1240102, "登录用户名为空"),
OLD_PASSWORD_IS_ERROR(1240103, "密码错误"), OLD_PASSWORD_IS_ERROR(1240103, "密码错误"),
PASSWORD_REVISE_FAIL(1240104, "密码修改失败"), PASSWORD_REVISE_FAIL(1240104, "密码修改失败"),
PASSWORD_REVISE_SUCCESS(1240105, "密码修改成功");
PASSWORD_REVISE_SUCCESS(1240105, "密码修改成功"),
USER_ID_IS_NULL(1240106, "登录用户id为空"),
USER_0PENID_IS_NULL(1240107, "用户openID为空");


/** /**
* 错误码 * 错误码

+ 1
- 1
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/IWxService.java View File

* @param code * @param code
* @return * @return
*/ */
JsonResult openid(String code);
JsonResult openId(String code);


/** /**
* 发送消息 * 发送消息

+ 12
- 24
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/InspectionServiceImpl.java View File

if (null == query.getLimit() && null == query.getPage()) { if (null == query.getLimit() && null == query.getPage()) {
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
} }
//登录用户信息
User user = CurrentUserUtil.getUserInfo(); User user = CurrentUserUtil.getUserInfo();
Integer type = user.getDataPermission();
if (null == type) {
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
}
String tenantId = user.getTenantId(); String tenantId = user.getTenantId();
query.setTenantId(tenantId); 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<Inspection> page = new Page<>(query.getPage(), query.getLimit());
IPage<InspectionInfoVo> pageDataVo = 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<>(); List<InspectionInfoVo> inspectionInfoVoList = new ArrayList<>();
//用户角色判断 1超级管理员 2部门管理员 3普通用户
if (DataPermissionEnum.ALL.getCode() == type) {
if (DataPermissionEnum.ALL.getCode() == user.getDataPermission()) {
query.setDeptId(""); // 要查所有部门的, 因此不通过deptId过滤 query.setDeptId(""); // 要查所有部门的, 因此不通过deptId过滤
IPage<InspectionInfoVo> IPageData = inspectionMapper.queryPage(page, query); IPage<InspectionInfoVo> IPageData = inspectionMapper.queryPage(page, query);
IPageData.getRecords().stream().forEach(x -> { IPageData.getRecords().stream().forEach(x -> {
for (InspectionInfoVo record : records) { for (InspectionInfoVo record : records) {
inspectionInfoVoList.add(record); inspectionInfoVoList.add(record);
} }
//构建返回结果对象
pageDataVo.setPages(IPageData.getPages()); pageDataVo.setPages(IPageData.getPages());
pageDataVo.setCurrent(IPageData.getCurrent()); pageDataVo.setCurrent(IPageData.getCurrent());
pageDataVo.setSize(IPageData.getSize()); pageDataVo.setSize(IPageData.getSize());
pageDataVo.setTotal(IPageData.getTotal()); 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集合 // 根据部门id获取此部门id和所有下级部门id封装list集合
List<String> deptLists = deptMapper.selectAllChildListById(query.getDeptId()); List<String> deptLists = deptMapper.selectAllChildListById(query.getDeptId());
if (StringUtils.isEmpty(deptLists)) { if (StringUtils.isEmpty(deptLists)) {
inspectionInfoVoList.add(record); inspectionInfoVoList.add(record);
} }


//构建返回结果对象
pageDataVo.setPages(pageData.getPages()); pageDataVo.setPages(pageData.getPages());
pageDataVo.setCurrent(pageData.getCurrent()); pageDataVo.setCurrent(pageData.getCurrent());
pageDataVo.setSize(pageData.getSize()); pageDataVo.setSize(pageData.getSize());
pageDataVo.setTotal(pageData.getTotal()); pageDataVo.setTotal(pageData.getTotal());

} }
} }
Map<Integer, AirportLineVo> airportLineMap = this.getAirportLineMap(inspectionInfoVoList); Map<Integer, AirportLineVo> airportLineMap = this.getAirportLineMap(inspectionInfoVoList);

+ 20
- 17
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/WxServiceImpl.java View File

* @return * @return
*/ */
@Override @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 userId = CurrentUserUtil.getUserId();
String openidResult = GetOpenIdUtil.getopenid(code, CommonConfig.appId, CommonConfig.appSecret); String openidResult = GetOpenIdUtil.getopenid(code, CommonConfig.appId, CommonConfig.appSecret);
if (null != JSONObject.parseObject(openidResult).getInteger("errcode") || if (null != JSONObject.parseObject(openidResult).getInteger("errcode") ||
//根据当前登录用户id查询授权表是否存在一条授权数据 //根据当前登录用户id查询授权表是否存在一条授权数据
UserAuthorize beforeUserAuthorize = userAuthorizeMapper.selectOne(Wrappers.<UserAuthorize>lambdaQuery() UserAuthorize beforeUserAuthorize = userAuthorizeMapper.selectOne(Wrappers.<UserAuthorize>lambdaQuery()
.eq(UserAuthorize::getUserId, userId) .eq(UserAuthorize::getUserId, userId)
.eq(UserAuthorize::getOpenId, openid)
.eq(UserAuthorize::getMark, MarkEnum.VALID.getCode())); .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(); User user = CurrentUserUtil.getUserInfo();
if (ObjectUtil.isEmpty(user)) { if (ObjectUtil.isEmpty(user)) {
user.setUpdateUser(userId); user.setUpdateUser(userId);
int count = userMapper.updateById(user); int count = userMapper.updateById(user);
if (count <= 0) { if (count <= 0) {
log.info("用户授权标识更新失败, userId={}", userId);
return JsonResult.error("用户授权标识更新失败"); return JsonResult.error("用户授权标识更新失败");
} }
return JsonResult.success(); return JsonResult.success();
//失效时间 = 当前时间+有效期(提前一分钟,也可以不提前) //失效时间 = 当前时间+有效期(提前一分钟,也可以不提前)
expiresTime = System.currentTimeMillis() + (expires_in - 60) * 1000; expiresTime = System.currentTimeMillis() + (expires_in - 60) * 1000;
} }

return accessToken; return accessToken;
} }



Loading…
Cancel
Save