Browse Source

修改处理问题接口

tags/v1.0.0^2
chengwang 1 year ago
parent
commit
da819bb47f
8 changed files with 220 additions and 3 deletions
  1. +11
    -1
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/controller/InspectionFileController.java
  2. +4
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/dao/InspectionFileMapper.java
  3. +49
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/enums/InspectionFileEnum.java
  4. +2
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/IInspectionFileService.java
  5. +110
    -2
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/InspectionFileServiceImpl.java
  6. +24
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/vo/InspectionFileCountVo.java
  7. +5
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/vo/InspectionFileInfoVo.java
  8. +15
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/resources/mapper/InspectionFileMapper.xml

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

@@ -5,7 +5,6 @@ import com.tuoheng.miniprogram.entity.InspectionFile;
import com.tuoheng.miniprogram.entity.dto.QuestionIdentificationDto;
import com.tuoheng.miniprogram.entity.query.InspectionFileQuery;
import com.tuoheng.miniprogram.service.IInspectionFileService;
import com.tuoheng.miniprogram.service.IInspectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@@ -104,4 +103,15 @@ public class InspectionFileController {
return iInspectionFileService.navigation(id);
}

/**
* 问题处理统计
* @return
*/
@GetMapping("/handleCount")
public JsonResult handleCount(){
return iInspectionFileService.handleCount();
}



}

+ 4
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/dao/InspectionFileMapper.java View File

@@ -13,4 +13,8 @@ public interface InspectionFileMapper extends BaseMapper<InspectionFile> {


SeeQuestionVo selectByInspectionId(@Param("id") String id);
//查询当前登录人处理问题总数
Integer getInspectionFileCount(@Param("today") String s,@Param("userId") String id);

Integer getInspectionFileHandleCount(@Param("today") String s,@Param("userId") String id);
}

+ 49
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/enums/InspectionFileEnum.java View File

@@ -0,0 +1,49 @@
package com.tuoheng.miniprogram.enums;

/**
* @Author ChengWang
* @Date 2022/12/12
*/
public enum InspectionFileEnum {

INSPECTION_FILE_ID_IS_NULL(1210400, "问题id为空"),
TENANT_ID_IS_NULL(1210401, "租户id为空"),
USER_ID_IS_NULL(1210402, "用户id为空"),
USER_NAME_IS_NULL(1210403, "登录用户名为空"),
WORK_ORDER_ID_NULL(1210404, "登录用户名为空"),
USER_IS_NOT_EXIST(1210405, "用户为空"),
DEPT_ID_IS_NULL(1210406, "部门id为空"),
DATA_IS_NULL(1210407, "数据为空");


/**
* 错误码
*/
private int code;

/**
* 错误信息
*/
private String msg;

InspectionFileEnum(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;
}
}

+ 2
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/IInspectionFileService.java View File

@@ -25,4 +25,6 @@ public interface IInspectionFileService {
JsonResult seeQuestion(String id);

JsonResult navigation(String id);

JsonResult handleCount();
}

+ 110
- 2
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/InspectionFileServiceImpl.java View File

@@ -1,6 +1,9 @@
package com.tuoheng.miniprogram.service.impl;

import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -17,15 +20,18 @@ import com.tuoheng.miniprogram.dao.*;
import com.tuoheng.miniprogram.entity.*;
import com.tuoheng.miniprogram.entity.dto.QuestionIdentificationDto;
import com.tuoheng.miniprogram.entity.query.InspectionFileQuery;
import com.tuoheng.miniprogram.enums.InspectionFileEnum;
import com.tuoheng.miniprogram.enums.UserTypeEnum;
import com.tuoheng.miniprogram.service.IInspectionFileService;
import com.tuoheng.miniprogram.vo.InspectionFileCountVo;
import com.tuoheng.miniprogram.vo.InspectionFileInfoVo;
import com.tuoheng.miniprogram.vo.SeeQuestionVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;
import java.text.ParseException;
import java.util.*;
import java.util.stream.Collectors;


@@ -294,6 +300,75 @@ public class InspectionFileServiceImpl implements IInspectionFileService {
return JsonResult.success(inspectionFile);
}

/**
* 问题处理统计
* @return
*/
@Override
public JsonResult handleCount() {
//获取当前登录人信息
//String username = SecurityUserUtils.username();
String username = "admin";
if(StringUtils.isEmpty(username)){
return JsonResult.error(InspectionFileEnum.USER_NAME_IS_NULL.getCode(),InspectionFileEnum.USER_NAME_IS_NULL.getMsg());
}
User user = userMapper.selectOne(Wrappers.<User>lambdaQuery()
.eq(User::getMark, 1)
.eq(User::getUsername, username));
if(ObjectUtil.isNull(user)){
return JsonResult.error(InspectionFileEnum.USER_IS_NOT_EXIST.getCode(),InspectionFileEnum.USER_IS_NOT_EXIST.getMsg());
}
if(StringUtils.isEmpty(user.getId())){
return JsonResult.error(InspectionFileEnum.USER_ID_IS_NULL.getCode(),InspectionFileEnum.USER_ID_IS_NULL.getMsg());
}
if(null == user.getType()){
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
}
//今日
DateTime endTime = DateUtil.endOfDay(DateUtil.date());
//一周前的时间
DateTime startTime = DateUtil.offset(DateUtil.beginOfDay(DateUtil.date()), DateField.WEEK_OF_MONTH, -1);
List<InspectionFileCountVo> result = new ArrayList<>();
//判断角色 1超级管理员 2部门管理员 3普通用户
if(UserTypeEnum.SUPER_ADMIN.getCode() == user.getType()){
try {
List<String> list = findDates(startTime, endTime);
for (String s : list) {
InspectionFileCountVo vo = new InspectionFileCountVo();
vo.setCheckTime(s);
//查询当日登录用户的已处理问题总数,创建时间
Integer num = inspectionFileMapper.getInspectionFileHandleCount(s,user.getId());
if(null != num){
vo.setInspectionHandleSum(num);
}
result.add(vo);
}
} catch (ParseException e) {
e.printStackTrace();
}
}
if(UserTypeEnum.ADMIN.getCode() == user.getType() || UserTypeEnum.ORDINARY_USER.getCode() == user.getType()){
try {
List<String> list = findDates(startTime, endTime);
for (String s : list) {
InspectionFileCountVo vo = new InspectionFileCountVo();
vo.setCheckTime(s);
//查询当日登录用户的已处理问题总数,创建时间
Integer num = inspectionFileMapper.getInspectionFileCount(s,user.getId());
if(null != num){
vo.setInspectionHandleSum(num);
}
result.add(vo);
}
} catch (ParseException e) {
e.printStackTrace();
}
}


return JsonResult.success(result);
}

/**
* 多个url进行转换,用,号隔开
*
@@ -342,9 +417,42 @@ public class InspectionFileServiceImpl implements IInspectionFileService {
if(null != questionType.getName()){
vo.setQuestionName(questionType.getName());
}
if(StringUtils.isNotEmpty(questionType.getContent())){
vo.setContent(questionType.getContent());
}
}

return vo;
});
}


/**
* 传入两个时间范围,返回这两个时间范围内的所有时间,并保存在一个集合中
*
* @param beginTime
* @param endTime
* @return
* @throws ParseException
*/
public static List<String> findDates(Date beginTime, Date endTime)
throws ParseException {
List<String> allDate = new ArrayList();
allDate.add(DateUtil.formatDate(beginTime));
Calendar calBegin = Calendar.getInstance();
// 使用给定的 Date 设置此 Calendar 的时间
calBegin.setTime(beginTime);
Calendar calEnd = Calendar.getInstance();
// 使用给定的 Date 设置此 Calendar 的时间
calEnd.setTime(endTime);
// 测试此日期是否在指定日期之后
while (endTime.after(calBegin.getTime())) {
// 根据日历的规则,为给定的日历字段添加或减去指定的时间量
calBegin.add(Calendar.DAY_OF_MONTH, 1);
allDate.add(DateUtil.formatDate(calBegin.getTime()));
}
allDate.remove(allDate.size() - 1);
return allDate;
}

}

+ 24
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/vo/InspectionFileCountVo.java View File

@@ -0,0 +1,24 @@
package com.tuoheng.miniprogram.vo;

import lombok.Data;

/**
* @Author ChengWang
* @Date 2022/12/12
*/
@Data
public class InspectionFileCountVo {

/**
* 日期时间
*/
private String checkTime;

/**
* 问题总数
*/
private Integer InspectionHandleSum;



}

+ 5
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/vo/InspectionFileInfoVo.java View File

@@ -28,6 +28,11 @@ public class InspectionFileInfoVo {
*/
private Integer questionName;

/**
* 问题类型名称
*/
private String content;

/**
* 位置(公路代号)
*/

+ 15
- 0
tuoheng-service/tuoheng-miniprogram/src/main/resources/mapper/InspectionFileMapper.xml View File

@@ -22,4 +22,19 @@
where tf.mark =1 and tfh.mark=1
and tf.id=#{id}
</select>


<select id="getInspectionFileCount" resultType="java.lang.Integer">
select count(id)
from th_inspection_file
where date_format(update_time, '%Y-%m-%d') = #{today}
and mark = 1
and update_user = #{userId}
</select>
<select id="getInspectionFileHandleCount" resultType="java.lang.Integer">
select count(id)
from th_inspection_file
where date_format(update_time, '%Y-%m-%d') = #{today}
and mark = 1
</select>
</mapper>

Loading…
Cancel
Save