@@ -69,6 +69,17 @@ public class WorkOrderController extends BaseController { | |||
return workOrderService.getCompleted(query); | |||
} | |||
/** | |||
* 工单详情 | |||
* @param query | |||
* @return | |||
*/ | |||
@GetMapping("/details") | |||
public JsonResult details(HandleQuery query){ | |||
return workOrderService.details(query); | |||
} | |||
@@ -211,6 +211,12 @@ public class User implements Serializable { | |||
*/ | |||
private Integer mark; | |||
/** | |||
* 部门名称 | |||
*/ | |||
@TableField(exist = false) | |||
private String deptName; | |||
/** | |||
* 角色ID | |||
*/ |
@@ -0,0 +1,50 @@ | |||
package com.tuoheng.miniprogram.enums; | |||
import lombok.Data; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2022/12/8 | |||
*/ | |||
public enum UserCodeEnum { | |||
USER_IS_NULL(1240100, "登录用户为空"), | |||
USER_STATUS_INTERDICT(1240101, "用户状态禁用"), | |||
USER_NAME_IS_NULL(1240102, "登录用户名为空"), | |||
OLD_PASSWORD_IS_NULL(1240103, "原密码为空"), | |||
PASSWORD_REVISE_FAIL(1240104, "密码修改失败"), | |||
PASSWORD_REVISE_SUCCESS(1240105, "密码修改成功"); | |||
/** | |||
* 错误码 | |||
*/ | |||
private int code; | |||
/** | |||
* 错误信息 | |||
*/ | |||
private String msg; | |||
UserCodeEnum(int code, String msg){ | |||
this.code = code; | |||
this.msg = msg; | |||
} | |||
public int getCode() { | |||
return code; | |||
} | |||
public void setCode(int code) { | |||
this.code = code; | |||
} | |||
public String getMsg() { | |||
return msg; | |||
} | |||
public void setMsg(String msg) { | |||
this.msg = msg; | |||
} | |||
} |
@@ -22,4 +22,6 @@ public interface IWorkOrderService extends IBaseService<WorkOrder> { | |||
JsonResult getCompleted(WorkOrderQuery query); | |||
JsonResult details(HandleQuery query); | |||
} |
@@ -12,10 +12,13 @@ import com.tuoheng.common.core.utils.SecurityUserUtils; | |||
import com.tuoheng.common.core.utils.StringUtils; | |||
import com.tuoheng.miniprogram.config.CommonsConfig; | |||
import com.tuoheng.miniprogram.constant.OidcUrlConstant; | |||
import com.tuoheng.miniprogram.dao.DeptMapper; | |||
import com.tuoheng.miniprogram.dao.UserMapper; | |||
import com.tuoheng.miniprogram.entity.Dept; | |||
import com.tuoheng.miniprogram.entity.dto.ResetPwdDto; | |||
import com.tuoheng.miniprogram.entity.User; | |||
import com.tuoheng.miniprogram.entity.query.OidcUpdatePassRequest; | |||
import com.tuoheng.miniprogram.enums.UserCodeEnum; | |||
import com.tuoheng.miniprogram.service.IUserService; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
@@ -37,22 +40,36 @@ public class IUserServiceImpl extends ServiceImpl<UserMapper, User> implements I | |||
@Autowired | |||
private RestTemplate restTemplate; | |||
@Autowired | |||
private DeptMapper deptMapper; | |||
@Override | |||
public JsonResult getUserInfo() { | |||
//获取登录用户名称 | |||
String username = SecurityUserUtils.username(); | |||
//String username = SecurityUserUtils.username(); | |||
String username = "admin"; | |||
if(StringUtils.isEmpty(username)){ | |||
return JsonResult.error(UserCodeEnum.USER_NAME_IS_NULL.getCode(),UserCodeEnum.USER_NAME_IS_NULL.getMsg()); | |||
} | |||
User user = userMapper.selectOne(new LambdaQueryWrapper<User>() | |||
.eq(null != username, User::getUsername, username)); | |||
if(ObjectUtil.isNull(user)){ | |||
return JsonResult.error("登录用户为空"); | |||
return JsonResult.error(UserCodeEnum.USER_IS_NULL.getCode(),UserCodeEnum.USER_IS_NULL.getMsg()); | |||
} | |||
if(2== user.getStatus()){ | |||
return JsonResult.error("用户状态禁用"); | |||
return JsonResult.error(UserCodeEnum.USER_STATUS_INTERDICT.getCode(),UserCodeEnum.USER_STATUS_INTERDICT.getMsg()); | |||
} | |||
if(StringUtils.isNotEmpty(user.getAvatar())){ | |||
user.setAvatar(CommonConfig.imageURL+user.getAvatar()); | |||
} | |||
//获取部门名称 | |||
if(StringUtils.isNotEmpty(user.getDeptId())){ | |||
Dept dept = deptMapper.selectById(user.getDeptId()); | |||
if(StringUtils.isNotNull(dept)){ | |||
user.setDeptName(dept.getName()); | |||
} | |||
} | |||
return JsonResult.success(user); | |||
} | |||
@@ -67,17 +84,17 @@ public class IUserServiceImpl extends ServiceImpl<UserMapper, User> implements I | |||
.eq(User::getMark, 1) | |||
.eq(User::getStatus, 1)); | |||
if(ObjectUtil.isNull(user)){ | |||
return JsonResult.error("用户不存在"); | |||
return JsonResult.error(UserCodeEnum.USER_IS_NULL.getCode(),UserCodeEnum.USER_IS_NULL.getMsg()); | |||
} | |||
//密码校验 | |||
if (!user.getPassword().equals(CommonUtils.password(dto.getOldPassword()))) { | |||
return JsonResult.error("旧密码不正确"); | |||
return JsonResult.error(UserCodeEnum.OLD_PASSWORD_IS_NULL.getCode(),UserCodeEnum.OLD_PASSWORD_IS_NULL.getMsg()); | |||
} | |||
//设置新密码 | |||
user.setPassword(CommonUtils.password(dto.getNewPassword())); | |||
int count = userMapper.updateById(user); | |||
if (count == 0) { | |||
return JsonResult.error(null, "密码修改失败"); | |||
return JsonResult.error(UserCodeEnum.PASSWORD_REVISE_FAIL.getCode(), UserCodeEnum.PASSWORD_REVISE_FAIL.getMsg()); | |||
} | |||
//设置第三方请求实体 | |||
OidcUpdatePassRequest oidcUpdatePassRequest = new OidcUpdatePassRequest(); | |||
@@ -104,6 +121,6 @@ public class IUserServiceImpl extends ServiceImpl<UserMapper, User> implements I | |||
log.error("oidc修改用户密码失败" + response.getBody()); | |||
return JsonResult.error(response.getBody().getMsg()); | |||
} | |||
return JsonResult.success(null, "用户密码修改成功"); | |||
return JsonResult.success(UserCodeEnum.PASSWORD_REVISE_SUCCESS.getCode(), UserCodeEnum.PASSWORD_REVISE_SUCCESS.getMsg()); | |||
} | |||
} |
@@ -1,5 +1,6 @@ | |||
package com.tuoheng.miniprogram.service.impl; | |||
import cn.hutool.core.convert.Convert; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | |||
@@ -296,7 +297,9 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO | |||
WorkOrderHandleVo vo = new WorkOrderHandleVo(); | |||
BeanUtils.copyProperties(t, vo); | |||
//缩略图处理 | |||
vo.setFileThumbnail(CommonConfig.imageURL+t.getFileThumbnail()); | |||
if(StringUtils.isNotEmpty(t.getFileThumbnail())){ | |||
vo.setFileThumbnail(CommonConfig.imageURL+t.getFileThumbnail()); | |||
} | |||
//任务名称 任务执行时间 道路位置编号 | |||
if (StringUtils.isEmpty(t.getInspectionId())) { | |||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||
@@ -474,5 +477,70 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO | |||
return JsonResult.error(WorkOrderEnum.DATA_IS_NULL.getCode(),WorkOrderEnum.DATA_IS_NULL.getMsg()); | |||
} | |||
/** | |||
* 工单详情 | |||
* @param query | |||
* @return | |||
*/ | |||
@Override | |||
public JsonResult details(HandleQuery query) { | |||
if(StringUtils.isEmpty(query.getId())){ | |||
JsonResult.error(WorkOrderEnum.WORK_ORDER_ID_IS_NULL.getCode(),WorkOrderEnum.WORK_ORDER_ID_IS_NULL.getMsg()); | |||
} | |||
if(null == query.getPage() && null == query.getLimit()){ | |||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||
} | |||
//获取分页数据 | |||
IPage<InspectionFile> page = new Page<>(query.getPage(),query.getLimit()); | |||
IPage<WorkOrderHandleVo> pageData = new Page<>(query.getPage(),query.getLimit()); | |||
//根据工单id获取对应的问题集合 | |||
List<WorkOrderFile> workOrderFiles = workOrderFileMapper.selectList(Wrappers.<WorkOrderFile>lambdaQuery() | |||
.eq(WorkOrderFile::getWorkOrderId, query.getId())); | |||
if(null == workOrderFiles){ | |||
return JsonResult.error(WorkOrderEnum.DATA_IS_NULL.getCode(),WorkOrderEnum.DATA_IS_NULL.getMsg()); | |||
} | |||
//工单子表获取对应的问题集合id | |||
List<String> inspectionFiledIds = workOrderFiles.stream().map(o -> o.getInspectionFileId()).collect(Collectors.toList()); | |||
List<InspectionFile> inspectionFilesList = inspectionFileMapper.selectBatchIds(inspectionFiledIds); | |||
//设置分页 | |||
IPage<InspectionFile> inspectionFilePageData = page.setRecords(inspectionFilesList); | |||
IPage<WorkOrderHandleVo> result = inspectionFilePageData.convert(p -> { | |||
WorkOrderHandleVo covert = Convert.convert(WorkOrderHandleVo.class, p); | |||
//缩略图处理 | |||
if (StringUtils.isNotEmpty(p.getFileThumbnail())) { | |||
covert.setFileThumbnail(p.getFileThumbnail()); | |||
} | |||
//任务名称 任务执行时间 道路位置编号 | |||
if (StringUtils.isEmpty(p.getInspectionId())) { | |||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||
} | |||
Inspection inspection = inspectionMapper.selectById(p.getInspectionId()); | |||
if (ObjectUtil.isNotNull(inspection)) { | |||
covert.setName(inspection.getName()); | |||
covert.setExecutionStartTime(inspection.getExecutionStartTime()); | |||
RoadInformation roadInformation = roadInformationMapper.selectById(inspection.getRoadId()); | |||
if (null != roadInformation) { | |||
if (StringUtils.isEmpty(roadInformation.getCode())) { | |||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||
} | |||
covert.setCode(roadInformation.getCode()); | |||
} | |||
} | |||
//问题类型 | |||
if (StringUtils.isEmpty(p.getQuestionId())) { | |||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||
} | |||
QuestionType questionType = questionTypeMapper.selectById(p.getQuestionId()); | |||
if (ObjectUtil.isNotNull(questionType)) { | |||
covert.setType(questionType.getName()); | |||
} | |||
return covert; | |||
}); | |||
return JsonResult.success(result); | |||
} | |||
} |