From b78d8b59e00c0c5e2bc92ce18f2476f3792c350b Mon Sep 17 00:00:00 2001 From: "OUMYYE\\Administrator" Date: Mon, 5 Feb 2024 19:30:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=A7=E5=B1=8F=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/biutag/enums/DeptTypeEnum.java | 29 + .../java/com/biutag/enums/LogMoneyEnum.java | 76 -- .../main/java/com/biutag/util/DateUtils.java | 735 ++++++++++++++++++ .../datascreen/DataScreenController.java | 111 +++ .../biutag/lan/mapper/DataScreenMapper.java | 137 ++++ .../biutag/lan/service/DataScreenService.java | 176 +++++ .../com/biutag/lan/service/IDutyService.java | 16 +- .../lan/service/impl/DutyServiceImpl.java | 13 + .../resources/mapper/DataScreenMapper.xml | 124 +++ 9 files changed, 1336 insertions(+), 81 deletions(-) create mode 100644 mailbox-common/src/main/java/com/biutag/enums/DeptTypeEnum.java delete mode 100644 mailbox-common/src/main/java/com/biutag/enums/LogMoneyEnum.java create mode 100644 mailbox-common/src/main/java/com/biutag/util/DateUtils.java create mode 100644 mailbox-lan/src/main/java/com/biutag/lan/controller/datascreen/DataScreenController.java create mode 100644 mailbox-lan/src/main/java/com/biutag/lan/mapper/DataScreenMapper.java create mode 100644 mailbox-lan/src/main/java/com/biutag/lan/service/DataScreenService.java create mode 100644 mailbox-lan/src/main/resources/mapper/DataScreenMapper.xml diff --git a/mailbox-common/src/main/java/com/biutag/enums/DeptTypeEnum.java b/mailbox-common/src/main/java/com/biutag/enums/DeptTypeEnum.java new file mode 100644 index 0000000..27e266c --- /dev/null +++ b/mailbox-common/src/main/java/com/biutag/enums/DeptTypeEnum.java @@ -0,0 +1,29 @@ +package com.biutag.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum DeptTypeEnum { + + + SJ_TYPE("1", "市局专班"), + + + FJ_TYPE("2", "分县市局"), + + // 三级机构专班 + ZD_TYPE("3", "支队"), + + // 二级机构领导 + BW_TYPE("4", "部委警校"), + + // 三级机构领导 + SD_TYPE("5", "所队"); + + private String type; + + private String name; + +} diff --git a/mailbox-common/src/main/java/com/biutag/enums/LogMoneyEnum.java b/mailbox-common/src/main/java/com/biutag/enums/LogMoneyEnum.java deleted file mode 100644 index fec0d34..0000000 --- a/mailbox-common/src/main/java/com/biutag/enums/LogMoneyEnum.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.biutag.enums; - -import java.util.LinkedHashMap; -import java.util.Map; - -public enum LogMoneyEnum { - - /** - * 用户余额类型 - */ - UM_INC_ADMIN(1001, "平台增加余额"), - UM_DEC_ADMIN(1002, "平台减少余额"), - UM_INC_RECHARGE(1003, "充值余额增加"), - UM_DEC_RECHARGE(1004, "充值余额退回"); - - /** - * 构造方法 - */ - private final int code; - private final String msg; - LogMoneyEnum(int code, String msg) { - this.code = code; - this.msg = msg; - } - - /** - * 获取状态码 - * - * @author - * @return Long - */ - public int getCode() { - return this.code; - } - - /** - * 获取提示 - * - * @author - * @return String - */ - public String getMsg() { - return this.msg; - } - - /** - * 根据编码获取Msg - * - * @author - * @param code 类型 - * @return String - */ - public static String getMsgByCode(Integer code){ - for(LogMoneyEnum enumItem : LogMoneyEnum.values()) { - if (enumItem.getCode() == code) { - return enumItem.getMsg(); - } - } - return null; - } - - /** - * 获取所有类型 - * - * @author - * @return String - */ - public static Map getTypeList(){ - Map map = new LinkedHashMap<>(); - for(LogMoneyEnum enumItem : LogMoneyEnum.values()) { - map.put(enumItem.getCode(), enumItem.getMsg()); - } - return map; - } - -} diff --git a/mailbox-common/src/main/java/com/biutag/util/DateUtils.java b/mailbox-common/src/main/java/com/biutag/util/DateUtils.java new file mode 100644 index 0000000..57b6541 --- /dev/null +++ b/mailbox-common/src/main/java/com/biutag/util/DateUtils.java @@ -0,0 +1,735 @@ +package com.biutag.util; + +import org.apache.commons.lang3.time.DateFormatUtils; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; + + +/** + * 日期工具类, + * 继承org.apache.commons.lang.time.DateUtils类 + * + * + * @version 2014-4-15 + */ +public class DateUtils extends org.apache.commons.lang3.time.DateUtils { + + + private static final long ONE_MILLIS = 1000; + private static final long ONE_MINUTE = 60; + private static final long ONE_HOUR = 3600; + private static final long ONE_DAY = 86400; + private static final long ONE_MONTH = 2592000; + private static final long ONE_YEAR = 31104000; + + private static final TimeZone zone = TimeZone.getTimeZone("GMT+8"); + private static String[] parsePatterns = { + "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM", + "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM", + "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM", + "yyyyMMdd", "yyyyMMddHHmmss", "yyyyMMddHHmm", "yyyyMM"}; + + /** + * 日期型字符串转化为日期 格式 + * { + * "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM", + * "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM", + * "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM", + * "yyyyMMdd", "yyyyMMddHHmmss", "yyyyMMddHHmm", "yyyyMM"} + */ + public static Date parseDate(String str) { + if (str == null) { + return null; + } + try { + return parseDate(str, parsePatterns); + } catch (ParseException e) { + return null; + } + } + + /** + * 得到当前日期字符串 格式(yyyy-MM-dd) + */ + public static String formatCurrentDate() { + return formatCurrentDate("yyyy-MM-dd"); + } + + /** + * 得到当前日期字符串 格式(yyyy-MM-dd) pattern可以为:"yyyy-MM-dd" "HH:mm:ss" "E" + */ + public static String formatCurrentDate(String pattern) { + return DateFormatUtils.format(new Date(), pattern); + } + + /** + * 得到日期字符串 默认格式(yyyy-MM-dd) pattern可以为:"yyyy-MM-dd" "HH:mm:ss" "E" + */ + public static String formatDate(Date date, String pattern) { + String formatDate = null; + if (pattern != null) { + formatDate = DateFormatUtils.format(date, pattern); + } else { + formatDate = DateFormatUtils.format(date, "yyyy-MM-dd"); + } + return formatDate; + } + /** + * 得到当前日期字符串 格式(yyyy-MM-dd) + */ + public static String formatDate() { + return formatDate("yyyy-MM-dd"); + } + + /** + * 得到当前日期字符串 格式(yyyy-MM-dd) pattern可以为:"yyyy-MM-dd" "HH:mm:ss" "E" + */ + public static String formatDate(String pattern) { + return DateFormatUtils.format(new Date(), pattern,zone); + } + + /** + * 得到日期字符串 默认格式(yyyy-MM-dd) pattern可以为:"yyyy-MM-dd" "HH:mm:ss" "E" + */ + + + + /** + * 获取当前时间戳(yyyyMMddHHmmss) + * + * @return nowTimeStamp + */ + public static long getCurrentTimestamp() { + long nowTimeStamp = Long.parseLong(getCurrentTimestampStr()); + return nowTimeStamp; + } + + /** + * 获取当前时间戳(yyyyMMddHHmmss) + * + * @return + */ + public static String getCurrentTimestampStr() { + return formatDate(new Date(), "yyyyMMddHHmmss"); + } + + /** + * 获取当前时间戳(yyyyMMddHHmmss) + * + * @return + */ + public static String getCurrentTimestampStr(String pattern) { + return formatDate(new Date(), pattern); + } + /** + * 获取Unix时间戳 + * + * @return + */ + public static long getCurrentUnixTimestamp() { + long nowTimeStamp = System.currentTimeMillis() / 1000; + return nowTimeStamp; + } + + /** + * 获取Unix时间戳 + * + * @return + */ + public static String getCurrentUnixTimestampStr() { + return String.valueOf(getCurrentUnixTimestamp()); + } + + /** + * 转换Unix时间戳 + * + * @return nowTimeStamp + */ + public static long parseUnixTimeStamp(long time) { + return time / ONE_MILLIS; + } + + /** + * 获取前一周 + * + * @param date + * @return + */ + public static Date getBeforeWeek(Date date) { + return getAddDate(date, Calendar.WEEK_OF_YEAR, -1); + } + + /** + * 获取前一天 + * + * @param date + * @return + */ + public static Date getBeforeDay(Date date) { + return getAddDate(date, Calendar.DAY_OF_YEAR, -1); + } + + /** + * 获取前一月 + * + * @param date + * @return + */ + public static Date getBeforeMouth(Date date) { + return getAddDate(date, Calendar.MONTH, -1); + } + + /** + * 获取前一年 + * + * @param date + * @return + */ + public static Date getBeforeYear(Date date) { + return getAddDate(date, Calendar.YEAR, -1); + } + + + /** + * 获取前一周 + * + * @param date + * @return + */ + public static Date getAfterWeek(Date date) { + return getAddDate(date, Calendar.WEEK_OF_YEAR, 1); + } + + /** + * 获取前一天 + * + * @param date + * @return + */ + public static Date getAfterDay(Date date) { + return getAddDate(date, Calendar.DAY_OF_YEAR, 1); + } + + /** + * 获取前一月 + * + * @param date + * @return + */ + public static Date getAfterMouth(Date date) { + return getAddDate(date, Calendar.MONTH, 1); + } + + /** + * 获取前一年 + * + * @param date + * @return + */ + public static Date getAfterYear(Date date) { + return getAddDate(date, Calendar.YEAR, 1); + } + + + /** + * 增加日期 + * + * @param date + * @param field Calendar.MONTH,Calendar.DAY_OF_YEAR + * @param amount 正数为将来时间, 负数为过去时间 + * @return + */ + public static Date getAddDate(Date date, int field, int amount) { + Calendar cl = Calendar.getInstance(); + cl.setTime(date); + cl.add(field, amount); + Date dateFrom = cl.getTime(); + return dateFrom; + } + + /** + * 得到日期时间字符串,转换格式(yyyy-MM-dd HH:mm:ss) + */ + public static String formatDateTime(Date date) { + return formatDate(date, "yyyy-MM-dd HH:mm:ss"); + } + + /** + * 得到当前时间字符串 格式(HH:mm:ss) + */ + public static String formatTime() { + return formatDate(new Date(), "HH:mm:ss"); + } + + /** + * 得到当前日期和时间字符串 格式(yyyy-MM-dd HH:mm:ss) + */ + public static String formatCurrentDateTime() { + return formatDate(new Date(), "yyyy-MM-dd HH:mm:ss"); + } + + /** + * 得到当前年份字符串 格式(yyyy) + */ + public static String formatYear() { + return formatDate(new Date(), "yyyy"); + } + + /** + * 得到当前月份字符串 格式(MM) + */ + public static String formatMonth() { + return formatDate(new Date(), "MM"); + } + + /** + * 得到当天字符串 格式(dd) + */ + public static String formatDay() { + return formatDate(new Date(), "dd"); + } + + /** + * 得到当前星期字符串 格式(E)星期几 + */ + public static String formatWeek() { + return formatDate(new Date(), "E"); + } + + /** + * 获取过去的天数 + * + * @param date + * @return + */ + public static long getBeforeDays(Date date) { + long t = System.currentTimeMillis() - date.getTime(); + return t / (ONE_DAY * ONE_MILLIS); + } + + /** + * 获取过去的小时 + * + * @param date + * @return + */ + public static long getBeforeHours(Date date) { + long t = System.currentTimeMillis() - date.getTime(); + return t / (ONE_HOUR * ONE_MILLIS); + } + + /** + * 获取过去的分钟 + * + * @param date + * @return + */ + public static long getBeforeMinutes(Date date) { + long t = System.currentTimeMillis() - date.getTime(); + return t / (ONE_MINUTE * ONE_MILLIS); + } + + /** + * 获取过去的秒 + * + * @param date + * @return + */ + public static long getBeforeSeconds(Date date) { + long t = System.currentTimeMillis() - date.getTime(); + return t / ONE_MILLIS; + } + + /** + * 获取两个日期之间的天数 + * + * @param before + * @param after + * @return + */ + public static double getDays(Date before, Date after) { + long beforeTime = before.getTime(); + long afterTime = after.getTime(); + return (afterTime - beforeTime) / (ONE_MILLIS * ONE_DAY); + } + /** + * 获取昨天 + * + * @param date + * @param pattern + * @return + */ + public static String getLastDay(Date date, String pattern) { + Calendar cl = Calendar.getInstance(); + cl.setTime(date); + //一天 + cl.add(Calendar.DAY_OF_YEAR, -1); + Date dateFrom = cl.getTime(); + return formatDate(dateFrom, pattern); + } + + /** + * 获取上个月 + * + * @param date + * @param pattern + * @return + */ + public static String getLastMouth(Date date, String pattern) { + Calendar cl = Calendar.getInstance(); + cl.setTime(date); + //一个月 + cl.add(Calendar.MONTH, -1); + Date dateFrom = cl.getTime(); + return formatDate(dateFrom, pattern); + } + + /** + * 距离今天多久 + * + * @param date + * @return + */ + public static String formatFromToday(Date date) { + if (date != null) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + + long time = date.getTime() / ONE_MILLIS; + long now = System.currentTimeMillis() / ONE_MILLIS; + long ago = now - time; + if (ago <= ONE_HOUR) { + return ago / ONE_MINUTE + "分钟前"; + } else if (ago <= ONE_DAY) { + return ago / ONE_HOUR + "小时" + (ago % ONE_HOUR / ONE_MINUTE) + + "分钟前"; + } else if (ago <= ONE_DAY * 2) { + return "昨天" + calendar.get(Calendar.HOUR_OF_DAY) + "点" + + calendar.get(Calendar.MINUTE) + "分"; + } else if (ago <= ONE_DAY * 3) { + return "前天" + calendar.get(Calendar.HOUR_OF_DAY) + "点" + + calendar.get(Calendar.MINUTE) + "分"; + } else if (ago <= ONE_MONTH) { + long day = ago / ONE_DAY; + return day + "天前" + calendar.get(Calendar.HOUR_OF_DAY) + "点" + + calendar.get(Calendar.MINUTE) + "分"; + } else if (ago <= ONE_YEAR) { + long month = ago / ONE_MONTH; + long day = ago % ONE_MONTH / ONE_DAY; + return month + "个月" + day + "天前" + + calendar.get(Calendar.HOUR_OF_DAY) + "点" + + calendar.get(Calendar.MINUTE) + "分"; + } else { + long year = ago / ONE_YEAR; + // JANUARY which is 0 so month+1 + int month = calendar.get(Calendar.MONTH) + 1; + return year + "年前" + month + "月" + calendar.get(Calendar.DATE) + + "日"; + } + + } else { + return ""; + } + + } + + /** + * 距离今天多久 + * + * @param createAt + * @return + */ + public static String formatTextFromtoday(Date createAt) { + // 定义最终返回的结果字符串。 + String interval = null; + if (createAt == null) { + return ""; + } + long millisecond = System.currentTimeMillis() - createAt.getTime(); + + long second = millisecond / ONE_MILLIS; + + if (second <= 0) { + second = 0; + } + //*--------------微博体(标准) + if (second == 0) { + interval = "刚刚"; + } else if (second < ONE_MINUTE / 2) { + interval = second + "秒以前"; + } else if (second >= ONE_MINUTE / 2 && second < ONE_MINUTE) { + interval = "半分钟前"; + } else if (second >= ONE_MINUTE && second < ONE_MINUTE * ONE_MINUTE) { + //大于1分钟 小于1小时 + long minute = second / ONE_MINUTE; + interval = minute + "分钟前"; + } else if (second >= ONE_HOUR && second < ONE_DAY) { + //大于1小时 小于24小时 + long hour = (second / ONE_MINUTE) / ONE_MINUTE; + interval = hour + "小时前"; + } else if (second >= ONE_DAY && second <= ONE_DAY * 2) { + //大于1D 小于2D + interval = "昨天" + formatDate(createAt, "HH:mm"); + } else if (second >= ONE_DAY * 2 && second <= ONE_DAY * 7) { + //大于2D小时 小于 7天 + long day = ((second / ONE_MINUTE) / ONE_MINUTE) / 24; + interval = day + "天前"; + } else if (second <= ONE_DAY * 365 && second >= ONE_DAY * 7) { + //大于7天小于365天 + interval = formatDate(createAt, "MM-dd HH:mm"); + } else if (second >= ONE_DAY * 365) { + //大于365天 + interval = formatDate(createAt, "yyyy-MM-dd HH:mm"); + } else { + interval = "0"; + } + return interval; + } + + + /** + * 距离截止日期还有多长时间 + * + * @param date + * @return + */ + public static String formatTextFromDeadline(Date date) { + long deadline = date.getTime() / ONE_MILLIS; + long now = (System.currentTimeMillis()) / ONE_MILLIS; + long remain = deadline - now; + if (remain <= ONE_HOUR) { + return "只剩下" + remain / ONE_MINUTE + "分钟"; + } else if (remain <= ONE_DAY) { + return "只剩下" + remain / ONE_HOUR + "小时" + + (remain % ONE_HOUR / ONE_MINUTE) + "分钟"; + } else { + long day = remain / ONE_DAY; + long hour = remain % ONE_DAY / ONE_HOUR; + long minute = remain % ONE_DAY % ONE_HOUR / ONE_MINUTE; + return "只剩下" + day + "天" + hour + "小时" + minute + "分钟"; + } + + } + + + /** + * 转换为时间(天,时:分:秒.毫秒) + * + * @param timeMillis + * @return + */ + public static String formatDateTime(long timeMillis) { + long day = timeMillis / (ONE_DAY * ONE_MILLIS); + long hour = (timeMillis / (ONE_HOUR * ONE_MILLIS) - day * 24); + long min = ((timeMillis / (ONE_MINUTE * ONE_MILLIS)) - day * 24 * ONE_MINUTE - hour * ONE_MINUTE); + long s = (timeMillis / ONE_MILLIS - day * 24 * ONE_MINUTE * ONE_MINUTE - hour * ONE_MINUTE * ONE_MINUTE - min * ONE_MINUTE); + long sss = (timeMillis - day * 24 * ONE_MINUTE * ONE_MINUTE * ONE_MILLIS - hour * ONE_MINUTE * ONE_MINUTE * ONE_MILLIS - min * ONE_MINUTE * ONE_MILLIS - s * ONE_MILLIS); + return (day > 0 ? day + "," : "") + hour + ":" + min + ":" + s + "." + sss; + } + + public static String formatDate(long timeMillis) { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");//12小时制 + Date date = new Date(); + date.setTime(timeMillis); + return (simpleDateFormat.format(date)); + } + + /** + * Unix时间戳转换成指定格式日期字符串 + * + * @param timestampString 时间戳 如:"1473048265"; + * @param pattern 要格式化的格式 默认:"yyyy-MM-dd HH:mm:ss"; + * @return 返回结果 如:"2016-09-05 16:06:42"; + */ + public static String unixTimeStamp2Date(String timestampString, String pattern) { + if (StringUtils.isBlank(pattern)) { + pattern = "yyyy-MM-dd HH:mm:ss"; + } + Long timestamp = Long.parseLong(timestampString) * ONE_MINUTE; + String date = new SimpleDateFormat(pattern, Locale.CHINA).format(new Date(timestamp)); + return date; + } + + /** + * 日期格式字符串转换成Unix时间戳 + * + * @param dateStr 字符串日期 + * @param pattern 如:yyyy-MM-dd HH:mm:ss + * @return + */ + public static String date2UnixTimeStamp(String dateStr, String pattern) { + try { + SimpleDateFormat sdf = new SimpleDateFormat(pattern); + return String.valueOf(sdf.parse(dateStr).getTime() / ONE_MINUTE); + } catch (Exception e) { + e.printStackTrace(); + } + return ""; + } + + /** + * 毫秒转化时分秒毫秒 10000 - 10秒 + * + * @param ms + * @return + */ + public static String formatTime(Long ms) { + long ss = ONE_MINUTE; + long mi = ss * ONE_MINUTE; + long hh = mi * ONE_MINUTE; + long dd = hh * 24; + + Long day = ms / dd; + Long hour = (ms - day * dd) / hh; + Long minute = (ms - day * dd - hour * hh) / mi; + Long second = (ms - day * dd - hour * hh - minute * mi) / ss; + StringBuffer sb = new StringBuffer(); + if (day > 0) { + sb.append(day + "天"); + } + if (hour > 0) { + sb.append(hour + "小时"); + } + if (minute > 0) { + sb.append(minute + "分钟"); + } + if (second > 0) { + sb.append(second + "秒"); + } + return sb.toString(); + } + + /** + * 获取中国星期的下标 + * @param date + * @return + */ + public static int getWeekIndex(Date date){ + Calendar cal = Calendar.getInstance(); + cal.setTime(date); + int week_index = cal.get(Calendar.DAY_OF_WEEK) - 1; + if (week_index <= 0){ + week_index = 7; + } + return week_index; + } + + /** + * 得到距离今天int类型数量的某天 + * @param date + * @param day + * @return + */ + public static String getSomeDay(Date date, int day){ + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + calendar.add(Calendar.DATE, day); + return formatDate(calendar.getTime(),null); + } + + /** + * 获取某个月 + * + * @param date + * @param pattern + * @return + */ + public static String getSomeMouth(Date date, int mouth, String pattern) { + Calendar cl = Calendar.getInstance(); + cl.setTime(date); + //一个月 + cl.add(Calendar.MONTH, mouth); + Date dateFrom = cl.getTime(); + return formatDate(dateFrom, pattern); + } + + public static String getNowEndDay(){ + return formatDate(new Date(),"yyyy-MM-dd 23:59:59"); + } + public static long getNowEndDayMilles() { + long current=System.currentTimeMillis();//当前时间毫秒数 + long zero=current/(1000*3600*24)*(1000*3600*24)-TimeZone.getDefault().getRawOffset();//今天零点零分零秒的毫秒数 + long twelve=zero+24*60*60*1000-1;//今天23点59分59秒的毫秒数 + return twelve; + } + + //JAVA获取某段时间内的所有日期 + public static List findDates(Date dStart, Date dEnd) { + Calendar cStart = Calendar.getInstance(); + cStart.setTime(dStart); + + List dateList = new ArrayList<>(); + //别忘了,把起始日期加上 + dateList.add(dStart); + // 此日期是否在指定日期之后 + while (dEnd.after(cStart.getTime())) { + // 根据日历的规则,为给定的日历字段添加或减去指定的时间量 + cStart.add(Calendar.DAY_OF_MONTH, 1); + dateList.add(cStart.getTime()); + } + return dateList; + } + + + public static List findWeeKDates(Date dStart, Date dEnd) { + Calendar cStart = Calendar.getInstance(); + cStart.setTime(dStart); + + List dateList = new ArrayList<>(); + //别忘了,把起始日期加上 + dateList.add( cStart.get(Calendar.YEAR) +"/" + cStart.get(Calendar.WEEK_OF_YEAR)); + // 此日期是否在指定日期之后 + while (dEnd.after(cStart.getTime())) { + // 根据日历的规则,为给定的日历字段添加或减去指定的时间量 + cStart.add(Calendar.WEEK_OF_YEAR, 1); + dateList.add(cStart.get(Calendar.YEAR) +"/"+cStart.get(Calendar.WEEK_OF_YEAR)); + } + return dateList; + } + // string类型转换为date类型 + // strTime要转换的string类型的时间,formatType要转换的格式yyyy-MM-dd HH:mm:ss//yyyy年MM月dd日 + // HH时mm分ss秒, + // strTime的时间格式必须要与formatType的时间格式相同 + public static Date stringToDate(String strTime, String formatType) + throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(formatType); + Date date = null; + date = formatter.parse(strTime); + return date; + } + + public static List getMonthList(int year) { + List monthList = new ArrayList<>(); + Calendar calendar = Calendar.getInstance(); + + // 设置年份 + calendar.set(Calendar.YEAR, year); + + // 遍历月份,添加到列表中 + for (int month = 0; month < 12; month++) { + // 设置月份 + calendar.set(Calendar.MONTH, month); + + // 获取当前月份的名称 + //String monthName = calendar.getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.getDefault()); + int monthValue = calendar.get(Calendar.MONTH) + 1; + // 将月份添加到列表 + monthList.add(monthValue); + } + + return monthList; + } + + public static void main(String[] args) { + + + List dayList= DateUtils.getMonthList(2023); + + dayList.forEach(date -> { + System.out.printf(date+" "); + + }); + } +} diff --git a/mailbox-lan/src/main/java/com/biutag/lan/controller/datascreen/DataScreenController.java b/mailbox-lan/src/main/java/com/biutag/lan/controller/datascreen/DataScreenController.java new file mode 100644 index 0000000..d339f19 --- /dev/null +++ b/mailbox-lan/src/main/java/com/biutag/lan/controller/datascreen/DataScreenController.java @@ -0,0 +1,111 @@ +package com.biutag.lan.controller.datascreen; + +import com.biutag.aop.NotLogin; +import com.biutag.core.AjaxResult; +import com.biutag.entity.system.Duty; +import com.biutag.enums.DeptTypeEnum; +import com.biutag.lan.AdminThreadLocal; +import com.biutag.lan.domain.Mail; +import com.biutag.lan.domain.MailSource; +import com.biutag.lan.service.DataScreenService; +import com.biutag.lan.service.IDutyService; +import com.biutag.lan.service.IIndexService; +import com.biutag.util.DateUtils; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import jakarta.annotation.Resource; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.*; + +@Slf4j +@RestController +@RequestMapping("api/dataScreen") +@Api(tags = "主页数据管理") +public class DataScreenController { + + + @Resource + DataScreenService dataScreenService; + @Resource + IDutyService iDutyService; + + + @NotLogin + @GetMapping("/mapData") + @ApiOperation(value="地图数据") + public AjaxResult>> mapData(@RequestParam Map params) { + + return AjaxResult.success(dataScreenService.mapData(null)); + } + + + + @NotLogin + @GetMapping("/peopleMail") + @ApiOperation(value="群众来信") + public AjaxResult> peopleMail() { + return AjaxResult.success(dataScreenService.selectRecentlyMailList()); + } + + @NotLogin + @GetMapping("/consoleData") + @ApiOperation(value="大屏数据") + public AjaxResult> consoleData() { + return AjaxResult.success(dataScreenService.consoleData(null)); + } + + + @NotLogin + @GetMapping("/dutyDay") + @ApiOperation(value="今日值班") + public AjaxResult> dutyDay() { + Map map =new HashMap<>(); + List dutySjList = iDutyService.getSameDayDuty(DeptTypeEnum.SJ_TYPE.getType()); + List dutyFjList = iDutyService.getSameDayDuty(DeptTypeEnum.FJ_TYPE.getType()); + List dutyZdList = iDutyService.getSameDayDuty(DeptTypeEnum.ZD_TYPE.getType()); + List dutyBwList = iDutyService.getSameDayDuty(DeptTypeEnum.BW_TYPE.getType()); + map.put("dutySjList",dutySjList); + map.put("dutyFjList",dutyFjList); + map.put("dutyZdList",dutyZdList); + map.put("dutyBwList",dutyBwList); + return AjaxResult.success(map); + } + + @NotLogin + @GetMapping("/threeRate") + @ApiOperation(value="三率") + public AjaxResult> threeRate() { + Map map =new HashMap<>(); + List> completeList = dataScreenService.getCompletedRate(); + List> satisfiedList = dataScreenService.getSatisfiedRate(); + List> resolvedList = dataScreenService.getResolvedRate(); + map.put("completeList",completeList); + map.put("satisfiedList",satisfiedList); + map.put("resolvedList",resolvedList); + return AjaxResult.success(map); + } + + + @NotLogin + @GetMapping("/mailTrend") + @ApiOperation(value="来信趋势") + public AjaxResult> mailTrend(@RequestParam Map params) { + return AjaxResult.success(dataScreenService.getMailTrend(params)); + } + + + @NotLogin + @GetMapping("/mailTypeRank") + @ApiOperation(value="信件类型排行") + public AjaxResult< List>> mailTypeRank() { + return AjaxResult.success(dataScreenService.mailTypeRank()); + } + + + +} diff --git a/mailbox-lan/src/main/java/com/biutag/lan/mapper/DataScreenMapper.java b/mailbox-lan/src/main/java/com/biutag/lan/mapper/DataScreenMapper.java new file mode 100644 index 0000000..35e19fa --- /dev/null +++ b/mailbox-lan/src/main/java/com/biutag/lan/mapper/DataScreenMapper.java @@ -0,0 +1,137 @@ +package com.biutag.lan.mapper; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.toolkit.Constants; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.biutag.lan.domain.Mail; +import com.biutag.lan.domain.MailSource; +import com.biutag.lan.domain.Work; +import com.biutag.lan.domain.vo.WorkVo; +import org.apache.ibatis.annotations.Param; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +public interface DataScreenMapper extends BaseMapper { + + + + + List> mapData(String deptId); + /** + * 最近信件 + * @return + */ + List selectRecentlyMailList(); + + + /** + * 获取三率 + * @return + */ + List> getCompletedRate(); + + + /** + * 获取三率 + * @return + */ + List> getResolvedRate(); + + + + /** + * 获取三率 + * @return + */ + List> getSatisfiedRate(); + + + + + /** + * 获取所队三率 + * @return + */ + List> getStationCompletedRateByDept(String deptId); + + /** + * 获取所队三率 + * @return + */ + List> getStationResolvedRateByDept(String deptId); + + /** + * 获取所队三率 + * @return + */ + List> getStationSatisfiedRateByDept(String deptId); + + + /** + * 获取今日来信数量 + * @return + */ + Integer getTodayMailCount(@Param("deptId") String deptId); + + + /** + * 获取总共来信数量 + * @return + */ + Integer getAllMailCount(@Param("deptId") String deptId); + + + /** + * 全长沙办结率 + * @return + */ + Map getAllResolvedRate(); + + + + /** + * 全长沙解决率 + * @return + */ + Map getAllResolvedRate(@Param("deptId") String deptId); + + /** + * 全长沙办结率 + * @return + */ + Map getAllCompletedRate(@Param("deptId") String deptId); + + + /** + * 全长沙满意率 + * @return + */ + Map getAllSatisfiedRate(@Param("deptId") String deptId); + + /** + * 各区县办结率 + * @param deptId + * @return + */ + Map getResolvedRateByDeptId(@Param("deptId") String deptId); + + + + /** + * 各类型占比 + * @param + * @return + */ + List< Map> mailTypeRank(); + + + + List< Map> getMailDayTrend(@Param("startDate") String startDate,@Param("endDate") String endDate); + + List< Map> getMailWeekTrend(@Param("startDate") String startDate,@Param("endDate") String endDate); + + List< Map> getMailMonthTrend(@Param("year") String year); +} diff --git a/mailbox-lan/src/main/java/com/biutag/lan/service/DataScreenService.java b/mailbox-lan/src/main/java/com/biutag/lan/service/DataScreenService.java new file mode 100644 index 0000000..db15bb1 --- /dev/null +++ b/mailbox-lan/src/main/java/com/biutag/lan/service/DataScreenService.java @@ -0,0 +1,176 @@ +package com.biutag.lan.service; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.biutag.lan.domain.Mail; +import com.biutag.lan.mapper.DataScreenMapper; +import com.biutag.util.DateUtils; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.*; +import java.util.concurrent.atomic.AtomicReference; + +@RequiredArgsConstructor +@Service +public class DataScreenService extends ServiceImpl { + + + public List> mapData(String deptId){ + return baseMapper.mapData(deptId); + } + + + public List selectRecentlyMailList() { + + return baseMapper.selectRecentlyMailList(); + } + + /** + * 办结率 + * @return + */ + public List> getCompletedRate(){ + return baseMapper.getCompletedRate(); + } + + /** + * 解决率 + * @return + */ + + public List> getResolvedRate(){ + return baseMapper.getResolvedRate(); + } + + + /** + * 满意率 + * @return + */ + public List> getSatisfiedRate(){ + return baseMapper.getSatisfiedRate(); + } + + + + /** + * 获取所队三率 + * @return + */ + public List> getStationCompletedRateByDept(String deptId){ + return baseMapper.getStationCompletedRateByDept(deptId); + } + + /** + * 获取所队三率 + * @return + */ + public List> getStationResolvedRateByDept(String deptId){ + return baseMapper.getStationResolvedRateByDept(deptId); + } + + /** + * 获取所队三率 + * @return + */ + public List> getStationSatisfiedRateByDept(String deptId){ + return baseMapper.getStationSatisfiedRateByDept(deptId); + } + public Map consoleData(String deptId) { + Map mapCompleted = baseMapper.getAllCompletedRate(null);//获取长沙市局 办结率 + Map mapResolved = baseMapper.getAllResolvedRate(null);//获取长沙市局 解决率 + Map mapSatisfied = baseMapper.getAllSatisfiedRate(null);//获取长沙市局 满意率 + Integer allSum =baseMapper.getAllMailCount(null); + Integer toDayCount=baseMapper.getTodayMailCount(null); + mapCompleted.putAll(mapResolved); + mapCompleted.putAll(mapSatisfied); + mapCompleted.put("todaySum",toDayCount); + mapCompleted.put("allSum",allSum); + return mapCompleted; + } + + + public List> mailTypeRank(){ + return baseMapper.mailTypeRank(); + } + + public Map getMailTrend( Map params){ + Map dataMap=new HashMap(); + //按天 + Date endDayDate =new Date(); + Date startDayDate = DateUtils.getAddDate(endDayDate, Calendar.DAY_OF_YEAR, -(Integer.valueOf(params.get("day").toString()))); + List dayList= DateUtils.findDates(startDayDate,endDayDate); + List dayXList= new ArrayList<>(); + dayList.forEach(date -> { + dayXList.add(DateUtils.formatDate(date,"yyyy/MM/dd")); + + }); + String endDayDataStr=DateUtils.formatDate(endDayDate,"yyyy-MM-dd")+ " 23:59:59"; + String startDayDateStr=DateUtils.formatDate(startDayDate,"yyyy-MM-dd")+ " 00:00:00"; + List< Map> dayDataList= baseMapper.getMailDayTrend(startDayDateStr,endDayDataStr); + List dayYList= new ArrayList<>(); + AtomicReference dayTrue= new AtomicReference<>(true); + dayXList.forEach(date-> { + dayTrue.set(true); + dayDataList.forEach(map ->{ + if(date.equals(map.get("create_time").toString()) ){ + dayYList.add(Integer.valueOf(map.get("countsum").toString()) ); + dayTrue.set(false); + } + }); + if(dayTrue.get()){ + dayYList.add(0); + } + + }); + + dataMap.put("dayXList",dayXList); + dataMap.put("dayYList",dayYList); + //按周 + Date startWeekDate = DateUtils.getAddDate(endDayDate, Calendar.WEEK_OF_YEAR, -(Integer.valueOf(params.get("week").toString()))); + String startWeekDateStr=DateUtils.formatDate(startWeekDate,"yyyy-MM-dd")+ " 00:00:00"; + List weekXList= DateUtils.findWeeKDates(startWeekDate,endDayDate); + List< Map> weekDataList= baseMapper.getMailWeekTrend(startWeekDateStr,endDayDataStr); + List weekYList= new ArrayList<>(); + AtomicReference weekTrue= new AtomicReference<>(true); + weekXList.forEach(date-> { + weekTrue.set(true); + weekDataList.forEach(map ->{ + if(date.equals(map.get("week").toString()) ){ + weekYList.add(Integer.valueOf(map.get("countsum").toString())); + weekTrue.set(false); + } + }); + if(weekTrue.get()){ + weekYList.add(0); + } + + }); + + dataMap.put("weekXList",weekXList); + dataMap.put("weekYList",weekYList); + //按月 + String year=params.get("year").toString(); + List monthXList= DateUtils.getMonthList(Integer.valueOf(year)); + List> monthDataList= baseMapper.getMailMonthTrend(year); + List monthYList= new ArrayList<>(); + AtomicReference monthTrue= new AtomicReference<>(true); + monthXList.forEach(month-> { + monthTrue.set(true); + monthDataList.forEach(map ->{ + if(month.equals(Integer.valueOf(map.get("month").toString())) ){ + monthYList.add(Integer.valueOf(map.get("countsum").toString())); + monthTrue.set(false); + } + }); + if(monthTrue.get()) { + monthYList.add(0); + } + }); + dataMap.put("monthXList",monthXList); + dataMap.put("monthYList",monthYList); + return dataMap; + } + + +} diff --git a/mailbox-lan/src/main/java/com/biutag/lan/service/IDutyService.java b/mailbox-lan/src/main/java/com/biutag/lan/service/IDutyService.java index ade0e4c..d2bcf8c 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/service/IDutyService.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/service/IDutyService.java @@ -1,5 +1,6 @@ package com.biutag.lan.service; +import com.biutag.entity.system.Duty; import com.biutag.lan.validate.commons.PageValidate; import com.biutag.lan.validate.system.DutyCreateValidate; import com.biutag.lan.validate.system.DutyUpdateValidate; @@ -8,6 +9,8 @@ import com.biutag.lan.vo.system.DutyListedVo; import com.biutag.lan.vo.system.DutyDetailVo; import com.biutag.core.PageResult; +import java.util.List; + /** * 值班服务接口类 * @author oumyye @@ -15,7 +18,7 @@ import com.biutag.core.PageResult; public interface IDutyService { /** - * 节假日列表 + * 值班列表 * * @author oumyye * @param pageValidate 分页参数 @@ -25,7 +28,7 @@ public interface IDutyService { PageResult list(PageValidate pageValidate, DutySearchValidate searchValidate); /** - * 节假日详情 + * 值班详情 * * @author oumyye * @param id 主键ID @@ -34,7 +37,7 @@ public interface IDutyService { DutyDetailVo detail(Integer id); /** - * 节假日新增 + * 值班新增 * * @author oumyye * @param createValidate 参数 @@ -42,7 +45,7 @@ public interface IDutyService { void add(DutyCreateValidate createValidate); /** - * 节假日编辑 + * 值班编辑 * * @author oumyye * @param updateValidate 参数 @@ -50,11 +53,14 @@ public interface IDutyService { void edit(DutyUpdateValidate updateValidate); /** - * 节假日删除 + * 值班删除 * * @author oumyye * @param id 主键ID */ void del(Integer id); + + + List getSameDayDuty(String depatType); } diff --git a/mailbox-lan/src/main/java/com/biutag/lan/service/impl/DutyServiceImpl.java b/mailbox-lan/src/main/java/com/biutag/lan/service/impl/DutyServiceImpl.java index 6f6284b..6eb54ae 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/service/impl/DutyServiceImpl.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/service/impl/DutyServiceImpl.java @@ -7,6 +7,7 @@ import com.biutag.constants.AppConstants; import com.biutag.entity.setting.DictData; import com.biutag.entity.system.Dept; import com.biutag.entity.system.PoliceUser; +import com.biutag.entity.system.Post; import com.biutag.lan.validate.commons.PageValidate; import com.biutag.lan.service.IDutyService; import com.biutag.lan.validate.system.DutyCreateValidate; @@ -20,6 +21,7 @@ import com.biutag.mapper.system.DutyMapper; import com.biutag.mapper.setting.DictDataMapper; import com.biutag.mapper.system.DeptMapper; import com.biutag.mapper.system.PoliceUserMapper; +import com.biutag.util.TimeUtils; import jakarta.annotation.Resource; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; @@ -194,4 +196,15 @@ public class DutyServiceImpl implements IDutyService { dutyMapper.delete(new QueryWrapper().eq("id", id)); } + @Override + public List getSameDayDuty(String depatType) { + Date today = TimeUtils.nowDate(); + List dutyList = dutyMapper.selectList(new QueryWrapper() + .eq("dept_type", depatType) + .lt("start_time",today) + .gt("end_time",today) + .orderByDesc("create_time")); + return dutyList; + } + } diff --git a/mailbox-lan/src/main/resources/mapper/DataScreenMapper.xml b/mailbox-lan/src/main/resources/mapper/DataScreenMapper.xml new file mode 100644 index 0000000..18a117b --- /dev/null +++ b/mailbox-lan/src/main/resources/mapper/DataScreenMapper.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +