@@ -143,12 +143,12 @@ public class InspectionController { | |||
/** | |||
* 根据用户id获取最新的五条任务信息 | |||
* @param query | |||
* @param | |||
* @return | |||
*/ | |||
@GetMapping("/getNewInspectionList") | |||
public JsonResult getNewInspectionList(InspectionFileQuery query){ | |||
return iInspectionService.getNewInspectionList(query); | |||
public JsonResult getNewInspectionList(){ | |||
return iInspectionService.getNewInspectionList(); | |||
} | |||
} |
@@ -12,7 +12,8 @@ public enum ListByDeptUserTypeEnum { | |||
INSPECTION_TYPE_LIST_IS_NULL(1100303, "问题列表为空"), | |||
INSPECTION_LIST_IS_NULL(1100304, "任务列表为空"), | |||
DEPT_ID_IS_NULL(1100305, "部门id为空"), | |||
QUESTION_ID_IS_NULL(1100306, "问题列表为空"); | |||
QUESTION_ID_IS_NULL(1100306, "问题列表为空"), | |||
TENANT_ID_IS_NULL(1100307, "租户id为空"); | |||
/** | |||
* 错误码 |
@@ -1,4 +1,4 @@ | |||
package com.tuoheng.admin.enums.code.questionType; | |||
package com.tuoheng.admin.enums.code.questiontype; | |||
/** | |||
* @Author ChengWang |
@@ -10,7 +10,7 @@ import com.tuoheng.admin.entity.QuestionType; | |||
import com.tuoheng.admin.entity.User; | |||
import com.tuoheng.admin.enums.UserTypeEnum; | |||
import com.tuoheng.admin.enums.code.inspectionfile.ListByDeptUserTypeEnum; | |||
import com.tuoheng.admin.enums.code.questionType.QuestionTypeEnum; | |||
import com.tuoheng.admin.enums.code.questiontype.QuestionTypeEnum; | |||
import com.tuoheng.admin.mapper.*; | |||
import com.tuoheng.admin.query.InspectionFileQuery; | |||
import com.tuoheng.admin.request.inspectionfile.QueryInspectionFilePageListByInspectionIdRequest; | |||
@@ -31,8 +31,6 @@ import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.BeanUtils; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import org.springframework.web.bind.annotation.GetMapping; | |||
import org.springframework.web.bind.annotation.RequestBody; | |||
import java.util.ArrayList; |
@@ -109,9 +109,9 @@ public interface IInspectionService { | |||
/** | |||
* 根据用户id获取最新的五条任务信息 | |||
* @param query | |||
* @param | |||
* @return | |||
*/ | |||
JsonResult getNewInspectionList(InspectionFileQuery query); | |||
JsonResult getNewInspectionList(); | |||
} |
@@ -210,12 +210,12 @@ public class InspectionServiceImpl implements IInspectionService { | |||
/** | |||
* 根据用户id获取最新的五条任务信息 | |||
* @param query | |||
* @param | |||
* @return | |||
*/ | |||
@Override | |||
public JsonResult getNewInspectionList(InspectionFileQuery query) { | |||
return queryNewInspectionListService.getList(query); | |||
public JsonResult getNewInspectionList() { | |||
return queryNewInspectionListService.getList(); | |||
} | |||
} |
@@ -40,23 +40,23 @@ public class QueryNewInspectionListService { | |||
public JsonResult getList(InspectionFileQuery query) { | |||
if(null == query.getUserId()){ | |||
JsonResult.error(ListByDeptUserTypeEnum.QUERY_IS_FAILED.getCode(),ListByDeptUserTypeEnum.QUERY_IS_FAILED.getMsg()); | |||
} | |||
public JsonResult getList() { | |||
//获取登录用户信息 | |||
//String username = SecurityUserUtils.username(); | |||
// String username = "admin"; | |||
// if(StringUtils.isEmpty(username)){ | |||
// JsonResult.error(ListByDeptUserTypeEnum.USER_NAME_IS_NULL.getCode(),ListByDeptUserTypeEnum.USER_NAME_IS_NULL.getMsg()); | |||
// } | |||
String username = "admin"; | |||
if(StringUtils.isEmpty(username)){ | |||
JsonResult.error(ListByDeptUserTypeEnum.USER_NAME_IS_NULL.getCode(),ListByDeptUserTypeEnum.USER_NAME_IS_NULL.getMsg()); | |||
} | |||
User user = userMapper.selectOne(Wrappers.<User>lambdaQuery() | |||
.eq(User::getId, query.getUserId()).eq(User::getMark, 1)); | |||
.eq(User::getUsername, username).eq(User::getMark, 1)); | |||
if(ObjectUtil.isNull(user)){ | |||
JsonResult.error(ListByDeptUserTypeEnum.USER_IS_NULL.getCode(),ListByDeptUserTypeEnum.USER_IS_NULL.getMsg()); | |||
} | |||
String tenantId = user.getTenantId(); | |||
String deptId = user.getDeptId(); | |||
if(StringUtils.isEmpty(tenantId)){ | |||
JsonResult.error(ListByDeptUserTypeEnum.TENANT_ID_IS_NULL.getCode(),ListByDeptUserTypeEnum.TENANT_ID_IS_NULL.getMsg()); | |||
} | |||
//判断用户角色 1超级管理员 2部门管理员 3普通用户 | |||
if(null == user.getType()){ | |||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||
@@ -82,7 +82,7 @@ public class QueryNewInspectionListService { | |||
//若角色为部门管理员或普通用户,查询最新五条数据 | |||
if(UserTypeEnum.ADMIN.getCode()==user.getType() || UserTypeEnum.ORDINARY_USER.getCode()==user.getType()){ | |||
String deptId = user.getDeptId(); | |||
if(StringUtils.isEmpty(deptId)){ | |||
JsonResult.error(QueryInspectionListServiceEnum.DEPT_ID_IS_NULL.getCode(),QueryInspectionListServiceEnum.DEPT_ID_IS_NULL.getMsg()); | |||
} |
@@ -94,4 +94,14 @@ public class InspectionFileController { | |||
return iInspectionFileService.seeQuestion(id); | |||
} | |||
/** | |||
* 导航 | |||
* @param id | |||
* @return | |||
*/ | |||
@GetMapping("/Navigation/{id}") | |||
public JsonResult navigation(@PathVariable("id") String id){ | |||
return iInspectionFileService.navigation(id); | |||
} | |||
} |
@@ -0,0 +1,38 @@ | |||
package com.tuoheng.miniprogram.controller; | |||
import com.tuoheng.common.core.common.BaseController; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import com.tuoheng.miniprogram.entity.WorkOrder; | |||
import com.tuoheng.miniprogram.entity.dto.WorkOrderDto; | |||
import com.tuoheng.miniprogram.service.IWorkOrderService; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.*; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2022/12/6 | |||
*/ | |||
@RestController | |||
@RequestMapping("/workOrder") | |||
public class WorkOrderController extends BaseController { | |||
@Autowired | |||
private IWorkOrderService workOrderService; | |||
/** | |||
* 新增 | |||
* @param dto | |||
* @return | |||
*/ | |||
@PostMapping("/add") | |||
public JsonResult add(@RequestBody WorkOrderDto dto){ | |||
return workOrderService.addInfo(dto); | |||
} | |||
} |
@@ -0,0 +1,22 @@ | |||
package com.tuoheng.miniprogram.controller; | |||
import com.tuoheng.miniprogram.service.IWorkOrderFileService; | |||
import com.tuoheng.miniprogram.service.IWorkOrderService; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2022/12/6 | |||
*/ | |||
@RestController | |||
@RequestMapping("/workOrderFile") | |||
public class WorkOrderFileController { | |||
@Autowired | |||
private IWorkOrderFileService workOrderFileService; | |||
} |
@@ -0,0 +1,11 @@ | |||
package com.tuoheng.miniprogram.dao; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import com.tuoheng.miniprogram.entity.WorkOrderFile; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2022/12/6 | |||
*/ | |||
public interface WorkOrderFileMapper extends BaseMapper<WorkOrderFile> { | |||
} |
@@ -0,0 +1,12 @@ | |||
package com.tuoheng.miniprogram.dao; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import com.tuoheng.miniprogram.entity.WorkOrder; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2022/12/6 | |||
*/ | |||
public interface WorkOrderMapper extends BaseMapper<WorkOrder> { | |||
} |
@@ -0,0 +1,76 @@ | |||
package com.tuoheng.miniprogram.entity; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import com.fasterxml.jackson.annotation.JsonFormat; | |||
import com.tuoheng.common.core.common.BaseEntity; | |||
import lombok.Data; | |||
import lombok.EqualsAndHashCode; | |||
import lombok.experimental.Accessors; | |||
import org.springframework.format.annotation.DateTimeFormat; | |||
import java.util.Date; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2022/12/6 | |||
*/ | |||
@Data | |||
@EqualsAndHashCode(callSuper = true) | |||
@Accessors(chain = true) | |||
@TableName("th_work_order") | |||
public class WorkOrder extends BaseEntity { | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 租户id | |||
*/ | |||
private String tenantId; | |||
/** | |||
* 部门id | |||
*/ | |||
private String deptId; | |||
/** | |||
* 分配人员id | |||
*/ | |||
private String distributionId; | |||
/** | |||
* 问题工单号 | |||
*/ | |||
private String code; | |||
/** | |||
* 工单状态 5待分配 10处理中(已分配) 15已完成 | |||
*/ | |||
private Integer status; | |||
/** | |||
* 指派部门ID | |||
*/ | |||
private String assignDeptId; | |||
/** | |||
* 指派负责人 | |||
*/ | |||
private String assignUser; | |||
/** | |||
* 指派负责人联系方式 | |||
*/ | |||
private String assignContact; | |||
/** | |||
* 指派备注 | |||
*/ | |||
private String assignNote; | |||
/** | |||
* 指派时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
private Date assignTime; | |||
} |
@@ -0,0 +1,34 @@ | |||
package com.tuoheng.miniprogram.entity; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import lombok.Data; | |||
import lombok.EqualsAndHashCode; | |||
import lombok.experimental.Accessors; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2022/12/6 | |||
*/ | |||
@Data | |||
@EqualsAndHashCode(callSuper = false) | |||
@Accessors(chain = true) | |||
@TableName("th_work_order_file") | |||
public class WorkOrderFile { | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 租户id | |||
*/ | |||
private String tenantId; | |||
/** | |||
* 巡检问题工单ID | |||
*/ | |||
private String workOrderId; | |||
/** | |||
* 巡检问题文件id | |||
*/ | |||
private String inspectionFileId; | |||
} |
@@ -0,0 +1,27 @@ | |||
package com.tuoheng.miniprogram.entity.dto; | |||
import lombok.Data; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2022/12/6 | |||
*/ | |||
@Data | |||
public class WorkOrderDto { | |||
/** | |||
* 问题id | |||
*/ | |||
private String inspectionFileId; | |||
/** | |||
*租户id | |||
*/ | |||
private String tenantId; | |||
/** | |||
* 登录用户id | |||
*/ | |||
//private String UserId; | |||
} |
@@ -0,0 +1,49 @@ | |||
package com.tuoheng.miniprogram.enums; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2022/12/6 | |||
*/ | |||
public enum WorkOrderEnum { | |||
INSPECTION_FILE_ID_IS_NULL(1210100, "问题id为空"), | |||
TENANT_ID_IS_NULL(1210101, "租户id为空"), | |||
USER_ID_IS_NULL(1210102, "用户id为空"), | |||
USER_NAME_IS_NULL(1210103, "登录用户名为空"), | |||
USER__IS_NOT_EXIST(1210104, "用户为空"), | |||
DEPT__ID_IS_NULL(1210105, "部门id为空"); | |||
/** | |||
* 错误码 | |||
*/ | |||
private int code; | |||
/** | |||
* 错误信息 | |||
*/ | |||
private String msg; | |||
WorkOrderEnum(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; | |||
} | |||
} |
@@ -0,0 +1,44 @@ | |||
package com.tuoheng.miniprogram.enums; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2022/12/6 | |||
*/ | |||
public enum WorkOrderStatusEnum { | |||
STATUS_ALLOCATED(5, "工单待分配"), | |||
STATUS_ASSIGNED(10, "工单处理中已分配"), | |||
STATUS_COMPLETED(15, "工单已完成"); | |||
/** | |||
* 编码 | |||
*/ | |||
private int code; | |||
/** | |||
* 状态信息 | |||
*/ | |||
private String msg; | |||
WorkOrderStatusEnum(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; | |||
} | |||
} |
@@ -23,4 +23,6 @@ public interface IInspectionFileService { | |||
JsonResult ignore(InspectionFile entity); | |||
JsonResult seeQuestion(String id); | |||
JsonResult navigation(String id); | |||
} |
@@ -0,0 +1,8 @@ | |||
package com.tuoheng.miniprogram.service; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2022/12/6 | |||
*/ | |||
public interface IWorkOrderFileService { | |||
} |
@@ -0,0 +1,17 @@ | |||
package com.tuoheng.miniprogram.service; | |||
import com.tuoheng.common.core.common.IBaseService; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import com.tuoheng.miniprogram.entity.WorkOrder; | |||
import com.tuoheng.miniprogram.entity.dto.WorkOrderDto; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2022/12/6 | |||
*/ | |||
public interface IWorkOrderService extends IBaseService<WorkOrder> { | |||
JsonResult addInfo(WorkOrderDto dto); | |||
} |
@@ -59,7 +59,7 @@ public class InspectionFileServiceImpl implements IInspectionFileService { | |||
*/ | |||
@Override | |||
public JsonResult unconfirmedQuestion(InspectionFileQuery query) { | |||
if(null==query.getLimit() && null == query.getPage()){ | |||
if(null == query.getLimit() && null == query.getPage()){ | |||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||
} | |||
if(StringUtils.isEmpty(query.getInspectionId())){ | |||
@@ -278,6 +278,17 @@ public class InspectionFileServiceImpl implements IInspectionFileService { | |||
return JsonResult.success(vo); | |||
} | |||
/** | |||
* 导航 | |||
* @param id | |||
* @return | |||
*/ | |||
@Override | |||
public JsonResult navigation(String id) { | |||
return null; | |||
} | |||
/** | |||
* 多个url进行转换,用,号隔开 | |||
* |
@@ -0,0 +1,14 @@ | |||
package com.tuoheng.miniprogram.service.impl; | |||
import com.tuoheng.miniprogram.service.IWorkOrderFileService; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.stereotype.Service; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2022/12/6 | |||
*/ | |||
@Service | |||
@Slf4j | |||
public class WorkOrderFileServiceImpl implements IWorkOrderFileService { | |||
} |
@@ -0,0 +1,103 @@ | |||
package com.tuoheng.miniprogram.service.impl; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.tuoheng.common.core.common.BaseServiceImpl; | |||
import com.tuoheng.common.core.utils.DateUtils; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import com.tuoheng.common.core.utils.SecurityUserUtils; | |||
import com.tuoheng.common.core.utils.StringUtils; | |||
import com.tuoheng.miniprogram.dao.DeptMapper; | |||
import com.tuoheng.miniprogram.dao.UserMapper; | |||
import com.tuoheng.miniprogram.dao.WorkOrderFileMapper; | |||
import com.tuoheng.miniprogram.dao.WorkOrderMapper; | |||
import com.tuoheng.miniprogram.entity.User; | |||
import com.tuoheng.miniprogram.entity.WorkOrder; | |||
import com.tuoheng.miniprogram.entity.WorkOrderFile; | |||
import com.tuoheng.miniprogram.entity.dto.WorkOrderDto; | |||
import com.tuoheng.miniprogram.enums.WorkOrderEnum; | |||
import com.tuoheng.miniprogram.enums.WorkOrderStatusEnum; | |||
import com.tuoheng.miniprogram.service.IWorkOrderService; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import java.text.SimpleDateFormat; | |||
import java.util.Date; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2022/12/6 | |||
*/ | |||
@Service | |||
@Slf4j | |||
public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkOrder> implements IWorkOrderService { | |||
@Autowired | |||
private UserMapper userMapper; | |||
@Autowired | |||
private WorkOrderMapper workOrderMapper; | |||
@Autowired | |||
private WorkOrderFileMapper workOrderFileMapper; | |||
@Autowired | |||
private DeptMapper deptMapper; | |||
@Override | |||
public JsonResult addInfo(WorkOrderDto dto) { | |||
if(StringUtils.isEmpty(dto.getTenantId())){ | |||
return JsonResult.error(WorkOrderEnum.TENANT_ID_IS_NULL.getCode(),WorkOrderEnum.TENANT_ID_IS_NULL.getMsg()); | |||
} | |||
if(StringUtils.isEmpty(dto.getInspectionFileId())) { | |||
return JsonResult.error(WorkOrderEnum.INSPECTION_FILE_ID_IS_NULL.getCode(), WorkOrderEnum.INSPECTION_FILE_ID_IS_NULL.getMsg()); | |||
} | |||
// if(StringUtils.isEmpty(dto.getUserId())){ | |||
// return JsonResult.error(WorkOrderEnum.USER_ID_IS_NULL.getCode(),WorkOrderEnum.USER_ID_IS_NULL.getMsg()); | |||
// } | |||
//String username = SecurityUserUtils.username(); | |||
String username ="admin"; | |||
if(StringUtils.isEmpty(username)){ | |||
return JsonResult.error(WorkOrderEnum.USER_NAME_IS_NULL.getCode(),WorkOrderEnum.USER_NAME_IS_NULL.getMsg()); | |||
} | |||
//根据用户id查询部门id | |||
User user = userMapper.selectOne(Wrappers.<User>lambdaQuery() | |||
.eq(User::getMark, 1).eq(User::getUsername,username)); | |||
if(ObjectUtil.isNull(user)){ | |||
return JsonResult.error(WorkOrderEnum.USER__IS_NOT_EXIST.getCode(),WorkOrderEnum.USER__IS_NOT_EXIST.getMsg()); | |||
} | |||
String deptId = user.getDeptId(); | |||
if(StringUtils.isEmpty(deptId)){ | |||
return JsonResult.error(WorkOrderEnum.DEPT__ID_IS_NULL.getCode(),WorkOrderEnum.DEPT__ID_IS_NULL.getMsg()); | |||
} | |||
WorkOrder workOrder = new WorkOrder(); | |||
workOrder.setTenantId(dto.getTenantId()); | |||
workOrder.setDeptId(deptId); | |||
//分配人员是当前登录用户 | |||
workOrder.setDistributionId(user.getId()); | |||
//工单编号 XJGD+日期+随机 | |||
Date now = DateUtils.now(); | |||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); | |||
String str = sdf.format(now); | |||
String code = "XJGD"+str+(int)(Math.random()*10000); | |||
workOrder.setCode(code); | |||
workOrder.setStatus(WorkOrderStatusEnum.STATUS_ASSIGNED.getCode()); | |||
workOrder.setAssignDeptId(deptId); | |||
workOrder.setAssignUser(username); | |||
workOrder.setAssignContact(user.getMobile()); | |||
workOrder.setAssignTime(DateUtils.now()); | |||
workOrder.setCreateUser(user.getId()); | |||
workOrder.setCreateTime(DateUtils.now()); | |||
workOrder.setMark(1); | |||
super.add(workOrder); | |||
//工单子表数据入库 | |||
WorkOrderFile workOrderFile = new WorkOrderFile(); | |||
workOrderFile.setTenantId(dto.getTenantId()); | |||
workOrderFile.setInspectionFileId(dto.getInspectionFileId()); | |||
workOrderFile.setWorkOrderId(workOrder.getId()); | |||
workOrderFileMapper.insert(workOrderFile); | |||
return JsonResult.success(); | |||
} | |||
} |
@@ -0,0 +1,7 @@ | |||
<?xml version="1.0" encoding="UTF-8" ?> | |||
<!DOCTYPE mapper | |||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||
<mapper namespace="com.tuoheng.miniprogram.dao.WorkOrderFileMapper"> | |||
</mapper> |
@@ -0,0 +1,7 @@ | |||
<?xml version="1.0" encoding="UTF-8" ?> | |||
<!DOCTYPE mapper | |||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||
<mapper namespace="com.tuoheng.miniprogram.dao.WorkOrderMapper"> | |||
</mapper> |