|
|
@@ -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; |
|
|
|
} |
|
|
|
|
|
|
|
} |