Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV
23个文件已修改
7个文件已删除
15个文件已添加
| | |
| | | if(threadPoolPriority != null && threadPoolPriority.intValue() >= 0){ |
| | | pro.put("org.quartz.threadPool.threadPriority", "" + (threadPoolPriority==null?5:(threadPoolPriority<=0?5:threadPoolPriority))); |
| | | } |
| | | if(threadPoolMaxCount != null && threadPoolPriority != null){ |
| | | if(threadPoolMaxCount.intValue() < threadPoolPriority.intValue()){ |
| | | throw new SchedulerException("threadPoolMaxCount必须大于等于threadPoolPriority") ; |
| | | } |
| | | } |
| | | scheduler = new StdSchedulerFactory(pro).getScheduler(); |
| | | } catch (SchedulerException e) { |
| | | log.error(e) ; |
| | |
| | | */ |
| | | public static Long lastXMinuteTime(int xMin) { |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.add(Calendar.MINUTE, -xMin); |
| | | cal.add(Calendar.MINUTE, xMin<=0?xMin:-xMin); |
| | | Date date = cal.getTime() ; |
| | | return date.getTime() ; |
| | | } |
| | |
| | | Date d = new SimpleDateFormat("yyyy-MM-dd HH", Locale.CHINA).parse(yyyy_MM_dd_HH); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.setTime(d); |
| | | cal.add(Calendar.HOUR_OF_DAY, -xhour); |
| | | cal.add(Calendar.HOUR_OF_DAY, xhour<=0?xhour:-xhour); |
| | | Date date = cal.getTime() ; |
| | | return DateTime.yyyy_MM_dd_HH(date) ; |
| | | } |
| | |
| | | Date d = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA).parse(yyyy_MM_dd_HH_mm); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.setTime(d); |
| | | cal.add(Calendar.HOUR_OF_DAY, -xhour); |
| | | cal.add(Calendar.HOUR_OF_DAY, xhour<=0?xhour:-xhour); |
| | | Date date = cal.getTime() ; |
| | | return DateTime.yyyy_MM_dd_HH_mm(date) ; |
| | | } |
| | |
| | | Date d = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).parse(yyyy_MM_dd_HH_mm_ss); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.setTime(d); |
| | | cal.add(Calendar.HOUR_OF_DAY, -xhour); |
| | | cal.add(Calendar.HOUR_OF_DAY, xhour<=0?xhour:-xhour); |
| | | Date date = cal.getTime() ; |
| | | return DateTime.yyyy_MM_dd_HH_mm_ss(date) ; |
| | | } |
| | |
| | | Date d = new SimpleDateFormat("yyyyMMddHH", Locale.CHINA).parse(yyyyMMddHH); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.setTime(d); |
| | | cal.add(Calendar.HOUR_OF_DAY, -xhour); |
| | | cal.add(Calendar.HOUR_OF_DAY, xhour<=0?xhour:-xhour); |
| | | Date date = cal.getTime() ; |
| | | return DateTime.yyyyMMddHH(date) ; |
| | | } |
| | |
| | | Date d = new SimpleDateFormat("yyyyMMddHHmm", Locale.CHINA).parse(yyyyMMddHHmm); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.setTime(d); |
| | | cal.add(Calendar.HOUR_OF_DAY, -xhour); |
| | | cal.add(Calendar.HOUR_OF_DAY, xhour<=0?xhour:-xhour); |
| | | Date date = cal.getTime() ; |
| | | return DateTime.yyyyMMddHHmm(date) ; |
| | | } |
| | |
| | | Date d = new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA).parse(yyyyMMddHHmmss); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.setTime(d); |
| | | cal.add(Calendar.HOUR_OF_DAY, -xhour); |
| | | cal.add(Calendar.HOUR_OF_DAY, xhour<=0?xhour:-xhour); |
| | | Date date = cal.getTime() ; |
| | | return DateTime.yyyyMMddHHmmss(date) ; |
| | | } |
| | |
| | | public static String lastXHour_yyyy_MM_dd_HH(int xhour){ |
| | | Date date = new Date(); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.add(Calendar.HOUR_OF_DAY, -xhour); |
| | | cal.add(Calendar.HOUR_OF_DAY, xhour<=0?xhour:-xhour); |
| | | date.setTime(cal.getTimeInMillis()); |
| | | return DateTime.yyyy_MM_dd_HH(date) ; |
| | | } |
| | |
| | | public static String lastXHour_yyyy_MM_dd_HH_mm(int xhour){ |
| | | Date date = new Date(); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.add(Calendar.HOUR_OF_DAY, -xhour); |
| | | cal.add(Calendar.HOUR_OF_DAY, xhour<=0?xhour:-xhour); |
| | | date.setTime(cal.getTimeInMillis()); |
| | | return DateTime.yyyy_MM_dd_HH_mm(date) ; |
| | | } |
| | |
| | | public static String lastXHour_yyyy_MM_dd_HH_mm_ss(int xhour){ |
| | | Date date = new Date(); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.add(Calendar.HOUR_OF_DAY, -xhour); |
| | | cal.add(Calendar.HOUR_OF_DAY, xhour<=0?xhour:-xhour); |
| | | date.setTime(cal.getTimeInMillis()); |
| | | return DateTime.yyyy_MM_dd_HH_mm_ss(date) ; |
| | | } |
| | |
| | | public static String lastXHour_yyyyMMddHH(int xhour){ |
| | | Date date = new Date(); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.add(Calendar.HOUR_OF_DAY, -xhour); |
| | | cal.add(Calendar.HOUR_OF_DAY, xhour<=0?xhour:-xhour); |
| | | date.setTime(cal.getTimeInMillis()); |
| | | return DateTime.yyyyMMddHH(date) ; |
| | | } |
| | |
| | | public static String lastXHour_yyyyMMddHHmm(int xhour){ |
| | | Date date = new Date(); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.add(Calendar.HOUR_OF_DAY, -xhour); |
| | | cal.add(Calendar.HOUR_OF_DAY, xhour<=0?xhour:-xhour); |
| | | date.setTime(cal.getTimeInMillis()); |
| | | return DateTime.yyyyMMddHHmm(date) ; |
| | | } |
| | |
| | | public static String lastXHour_yyyyMMddHHmmss(int xhour){ |
| | | Date date = new Date(); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.add(Calendar.HOUR_OF_DAY, -xhour); |
| | | cal.add(Calendar.HOUR_OF_DAY, xhour<=0?xhour:-xhour); |
| | | date.setTime(cal.getTimeInMillis()); |
| | | return DateTime.yyyyMMddHHmmss(date) ; |
| | | } |
| | |
| | | Date d = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).parse(yyyy_MM_dd_HH_mm_ss); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.setTime(d); |
| | | cal.add(Calendar.MINUTE, xminute); |
| | | cal.add(Calendar.MINUTE, xminute<=0?-xminute:xminute ); |
| | | Date date = cal.getTime() ; |
| | | return DateTime.yyyy_MM_dd_HH_mm_ss(date) ; |
| | | } |
| | |
| | | Date d = new SimpleDateFormat("yyyy-MM-dd HH", Locale.CHINA).parse(yyyy_MM_dd_HH); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.setTime(d); |
| | | cal.add(Calendar.HOUR_OF_DAY, xhour); |
| | | cal.add(Calendar.HOUR_OF_DAY, xhour<=0?-xhour:xhour ); |
| | | Date date = cal.getTime() ; |
| | | return DateTime.yyyy_MM_dd_HH(date) ; |
| | | } |
| | |
| | | Date d = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA).parse(yyyy_MM_dd_HH_mm); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.setTime(d); |
| | | cal.add(Calendar.HOUR_OF_DAY, xhour); |
| | | cal.add(Calendar.HOUR_OF_DAY, xhour<=0?-xhour:xhour); |
| | | Date date = cal.getTime() ; |
| | | return DateTime.yyyy_MM_dd_HH_mm(date) ; |
| | | } |
| | |
| | | Date d = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).parse(yyyy_MM_dd_HH_mm_ss); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.setTime(d); |
| | | cal.add(Calendar.HOUR_OF_DAY, xhour); |
| | | cal.add(Calendar.HOUR_OF_DAY, xhour<=0?-xhour:xhour); |
| | | Date date = cal.getTime() ; |
| | | return DateTime.yyyy_MM_dd_HH_mm_ss(date) ; |
| | | } |
| | |
| | | Date d = new SimpleDateFormat("yyyyMMddHH", Locale.CHINA).parse(yyyyMMddHH); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.setTime(d); |
| | | cal.add(Calendar.HOUR_OF_DAY, xhour); |
| | | cal.add(Calendar.HOUR_OF_DAY, xhour<=0?-xhour:xhour); |
| | | Date date = cal.getTime() ; |
| | | return DateTime.yyyyMMddHH(date) ; |
| | | } |
| | |
| | | Date d = new SimpleDateFormat("yyyyMMddHHmm", Locale.CHINA).parse(yyyyMMddHHmm); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.setTime(d); |
| | | cal.add(Calendar.HOUR_OF_DAY, xhour); |
| | | cal.add(Calendar.HOUR_OF_DAY, xhour<=0?-xhour:xhour); |
| | | Date date = cal.getTime() ; |
| | | return DateTime.yyyyMMddHHmm(date) ; |
| | | } /** |
| | |
| | | Date d = new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA).parse(yyyyMMddHHmmss); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.setTime(d); |
| | | cal.add(Calendar.HOUR_OF_DAY, xhour); |
| | | cal.add(Calendar.HOUR_OF_DAY, xhour<=0?-xhour:xhour); |
| | | Date date = cal.getTime() ; |
| | | return DateTime.yyyyMMddHHmmss(date) ; |
| | | } |
| | |
| | | public static String nextXHour_yyyy_MM_dd_HH(int xhour){ |
| | | Date date = new Date(); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.add(Calendar.HOUR_OF_DAY, xhour); |
| | | cal.add(Calendar.HOUR_OF_DAY, xhour<=0?-xhour:xhour); |
| | | date.setTime(cal.getTimeInMillis()); |
| | | return DateTime.yyyy_MM_dd_HH(date) ; |
| | | } |
| | |
| | | public static String nextXHour_yyyy_MM_dd_HH_mm(int xhour){ |
| | | Date date = new Date(); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.add(Calendar.HOUR_OF_DAY, xhour); |
| | | cal.add(Calendar.HOUR_OF_DAY, xhour<=0?-xhour:xhour); |
| | | date.setTime(cal.getTimeInMillis()); |
| | | return DateTime.yyyy_MM_dd_HH_mm(date) ; |
| | | } |
| | |
| | | public static String nextXHour_yyyy_MM_dd_HH_mm_ss(int xhour){ |
| | | Date date = new Date(); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.add(Calendar.HOUR_OF_DAY, xhour); |
| | | cal.add(Calendar.HOUR_OF_DAY, xhour<=0?-xhour:xhour); |
| | | date.setTime(cal.getTimeInMillis()); |
| | | return DateTime.yyyy_MM_dd_HH_mm_ss(date) ; |
| | | } |
| | |
| | | public static String nextXHour_yyyyMMddHH(int xhour){ |
| | | Date date = new Date(); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.add(Calendar.HOUR_OF_DAY, xhour); |
| | | cal.add(Calendar.HOUR_OF_DAY, xhour<=0?-xhour:xhour); |
| | | date.setTime(cal.getTimeInMillis()); |
| | | return DateTime.yyyyMMddHH(date) ; |
| | | } |
| | |
| | | public static String nextXHour_yyyyMMddHHmm(int xhour){ |
| | | Date date = new Date(); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.add(Calendar.HOUR_OF_DAY, xhour); |
| | | cal.add(Calendar.HOUR_OF_DAY, xhour<=0?-xhour:xhour); |
| | | date.setTime(cal.getTimeInMillis()); |
| | | return DateTime.yyyyMMddHHmm(date) ; |
| | | } |
| | |
| | | public static String nextXHour_yyyyMMddHHmmss(int xhour){ |
| | | Date date = new Date(); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.add(Calendar.HOUR_OF_DAY, xhour); |
| | | cal.add(Calendar.HOUR_OF_DAY, xhour<=0?-xhour:xhour); |
| | | date.setTime(cal.getTimeInMillis()); |
| | | return DateTime.yyyyMMddHHmmss(date) ; |
| | | } |
| | |
| | | Date d = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA).parse(yyyy_MM_dd); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.setTime(d); |
| | | cal.add(Calendar.DAY_OF_YEAR, -xday); |
| | | cal.add(Calendar.DAY_OF_YEAR, xday<=0?xday:-xday); |
| | | Date date = cal.getTime() ; |
| | | return DateTime.yyyy_MM_dd(date) ; |
| | | } |
| | |
| | | Date d = new SimpleDateFormat("yyyyMMdd", Locale.CHINA).parse(yyyyMMdd); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.setTime(d); |
| | | cal.add(Calendar.DAY_OF_YEAR, -xday); |
| | | cal.add(Calendar.DAY_OF_YEAR, xday<=0?xday:-xday); |
| | | Date date = cal.getTime() ; |
| | | return DateTime.yyyyMMdd(date) ; |
| | | } |
| | |
| | | public static String lastXDay_yyyy_MM_dd(int xday){ |
| | | Date date = new Date(); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.add(Calendar.DAY_OF_YEAR, -xday); |
| | | cal.add(Calendar.DAY_OF_YEAR, xday<=0?xday:-xday); |
| | | date.setTime(cal.getTimeInMillis()); |
| | | return DateTime.yyyy_MM_dd(date) ; |
| | | } |
| | |
| | | public static String lastXDay_yyyy_MM_dd_HH_ss(int xday){ |
| | | Date date = new Date(); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.add(Calendar.DAY_OF_YEAR, -xday); |
| | | cal.add(Calendar.DAY_OF_YEAR, xday<=0?xday:-xday); |
| | | date.setTime(cal.getTimeInMillis()); |
| | | return DateTime.yyyy_MM_dd_HH_mm_ss(date) ; |
| | | } |
| | |
| | | public static String lastXDay_yyyyMMdd(int xday){ |
| | | Date date = new Date(); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.add(Calendar.DAY_OF_YEAR, -xday); |
| | | cal.add(Calendar.DAY_OF_YEAR, xday<=0?xday:-xday); |
| | | date.setTime(cal.getTimeInMillis()); |
| | | return DateTime.yyyyMMdd(date) ; |
| | | } |
| | |
| | | Date d = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA).parse(yyyy_MM_dd); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.setTime(d); |
| | | cal.add(Calendar.DAY_OF_YEAR, xday); |
| | | cal.add(Calendar.DAY_OF_YEAR, xday<=0?-xday:xday); |
| | | Date date = cal.getTime() ; |
| | | return DateTime.yyyy_MM_dd(date) ; |
| | | } |
| | |
| | | Date d = new SimpleDateFormat("yyyyMMdd", Locale.CHINA).parse(yyyyMMdd); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.setTime(d); |
| | | cal.add(Calendar.DAY_OF_YEAR, xday); |
| | | cal.add(Calendar.DAY_OF_YEAR, xday<=0?-xday:xday); |
| | | Date date = cal.getTime() ; |
| | | return DateTime.yyyyMMdd(date) ; |
| | | } |
| | |
| | | public static String nextXDay_yyyy_MM_dd(int xday){ |
| | | Date date = new Date(); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.add(Calendar.DAY_OF_YEAR, xday); |
| | | cal.add(Calendar.DAY_OF_YEAR, xday<=0?-xday:xday); |
| | | date.setTime(cal.getTimeInMillis()); |
| | | return DateTime.yyyy_MM_dd(date) ; |
| | | } |
| | |
| | | public static String nextXDay_yyyyMMdd(int xday){ |
| | | Date date = new Date(); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.add(Calendar.DAY_OF_YEAR, xday); |
| | | cal.add(Calendar.DAY_OF_YEAR, xday<=0?-xday:xday); |
| | | date.setTime(cal.getTimeInMillis()); |
| | | return DateTime.yyyyMMdd(date) ; |
| | | } |
| | |
| | | Date dt = getDate(1447857387L) ; |
| | | String s = yyyy_MM_dd_HH_mm_ss(dt); |
| | | System.out.println(s); |
| | | |
| | | System.out.println(lastMonth_ym()) ; |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | private static final Object synObj = new Object() ; |
| | | |
| | | private static final int yearLenght = 4 ;//4:年度取四位, 3:年度取三位, 2:年度取两位, 1:年度取一位, 0:年度取0位 |
| | | private static final int yearLength = 4 ;//4:年度取四位, 3:年度取三位, 2:年度取两位, 1:年度取一位, 0:年度取0位 |
| | | |
| | | private static int add = 0 ; |
| | | private static final int chengShu = 1000 ;//1000:三位自增量,即一秒钟可产生10000个ID |
| | |
| | | * @return 处理后的年度 |
| | | */ |
| | | private static int dealYear(int year){ |
| | | if(yearLenght == 0){ |
| | | if(yearLength == 0){ |
| | | return 0 ; |
| | | }else if(yearLenght == 1){ |
| | | }else if(yearLength == 1){ |
| | | return year % 10 ; |
| | | }else if(yearLenght == 2){ |
| | | }else if(yearLength == 2){ |
| | | return year % 100 ; |
| | | }else if(yearLenght == 3){ |
| | | }else if(yearLength == 3){ |
| | | return year % 1000 ; |
| | | }else if(yearLenght == 4){ |
| | | }else if(yearLength == 4){ |
| | | return year ; |
| | | }else{ |
| | | return year ; |
| | | } |
| | | } |
| | | // |
| | | |
| | | // public static void main(String[] args){ |
| | | // Calendar cal = Calendar.getInstance(); |
| | | // System.out.println(cal.get(Calendar.MONTH) + 1) ; |
| | | // |
| | | // IDLongGenerator o = new IDLongGenerator() ; |
| | | // int total = 800 ; |
| | | // long start = System.currentTimeMillis() ; |
| | | // int total = 1 ; |
| | | // for(int i = 0 ; i < total ; i++){ |
| | | // System.out.println(o.generate()) ; |
| | | // } |
| | | // long start = System.currentTimeMillis() ; |
| | | // long end = System.currentTimeMillis() ; |
| | | // System.out.println("产生" + total + "ID用时" + (end - start) + "毫秒"); |
| | | // |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.dy.pipIrrGlobal.pojoRm.RmOnHourReportHistory; |
| | | import com.dy.pipIrrGlobal.pojoRm.RmOnHourReportLast; |
| | | import com.dy.pipIrrGlobal.voRm.VoOnHour; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | |
| | | * @return update count |
| | | */ |
| | | int updateByPrimaryKey(RmOnHourReportHistory record); |
| | | |
| | | /** |
| | | * 根据指定条件获取整点报历史记录数量 |
| | | * @param params |
| | | * @return |
| | | */ |
| | | Long getOnHourReportsCount_history(Map<?, ?> params); |
| | | |
| | | /** |
| | | * 根据指定条件获取整点报历史记录 |
| | | * @param params |
| | | * @return |
| | | */ |
| | | List<VoOnHour> getOnHourReports_history(Map<?, ?> params); |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrGlobal.daoSe; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.dy.pipIrrGlobal.pojoSe.SeManagerCard; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2024-07-24 10:36 |
| | | * @LastEditTime 2024-07-24 10:36 |
| | | * @Description |
| | | */ |
| | | |
| | | @Mapper |
| | | public interface SeManagerCardMapper extends BaseMapper<SeManagerCard> { |
| | | int deleteByPrimaryKey(Long id); |
| | | |
| | | int insert(SeManagerCard record); |
| | | |
| | | int insertSelective(SeManagerCard record); |
| | | |
| | | SeManagerCard selectByPrimaryKey(Long id); |
| | | |
| | | int updateByPrimaryKeySelective(SeManagerCard record); |
| | | |
| | | int updateByPrimaryKey(SeManagerCard record); |
| | | |
| | | /** |
| | | * 根据行政区划串模糊查询管理卡编号 |
| | | * @param areaCode |
| | | * @return |
| | | */ |
| | | String getManagerCardNumOfMax(@Param("areaCode") String areaCode); |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrGlobal.pojoSe; |
| | | |
| | | import com.alibaba.fastjson2.annotation.JSONField; |
| | | import com.alibaba.fastjson2.writer.ObjectWriterImplToString; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.dy.common.po.BaseEntity; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import lombok.*; |
| | | import org.hibernate.validator.constraints.Length; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2024-07-24 10:36 |
| | | * @LastEditTime 2024-07-24 10:36 |
| | | * @Description |
| | | */ |
| | | /** |
| | | * 管理员水卡表 |
| | | */ |
| | | |
| | | @TableName(value = "se_manager_card", autoResultMap = true) |
| | | @Data |
| | | @Builder |
| | | @ToString |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class SeManagerCard implements BaseEntity { |
| | | public static final long serialVersionUID = 202407241040001L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @JSONField(serializeUsing= ObjectWriterImplToString.class) |
| | | @TableId(type = IdType.INPUT) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 卡片地址 |
| | | */ |
| | | @NotBlank(message = "卡片地址不能为空") |
| | | private String cardAddr; |
| | | |
| | | /** |
| | | * 卡片编号 |
| | | */ |
| | | @NotBlank(message = "卡片编号不能为空") |
| | | private String cardNum; |
| | | |
| | | /** |
| | | * 卡片类型;2-管理科,4-开关阀卡,5清空卡 |
| | | */ |
| | | @NotNull(message = "卡片类型不能为空") |
| | | private Byte cardType; |
| | | |
| | | /** |
| | | * 开卡时间 |
| | | */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * 备注信息 |
| | | */ |
| | | @Length(max = 200) |
| | | private String remarks; |
| | | } |
| | |
| | | package com.dy.pipIrrGlobal.util; |
| | | |
| | | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.alibaba.fastjson2.annotation.JSONField; |
| | | import com.baomidou.mybatisplus.annotation.EnumValue; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | public enum Org { |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2024/7/24 11:45 |
| | | * @Description |
| | | */ |
| | | public class Org { |
| | | //用来转json |
| | | public static List<OrgVo> OrgList = new ArrayList<>(); |
| | | |
| | | // Ym("ym", "元谋"), |
| | | // Pj("pj", "片角镇"), |
| | | Sp("sp", "沙盘"), |
| | | Jyg("ym", "嘉峪关"); |
| | | |
| | | @EnumValue |
| | | public class OrgVo{ |
| | | public String tag ; |
| | | public String name ; |
| | | |
| | | Org(String tag, String name){ |
| | | this.tag = tag ; |
| | | this.name = name ; |
| | | } |
| | | //用来转json |
| | | public static List<Map> OrgList = new ArrayList<>(); |
| | | static { |
| | | Org[] all = Org.values(); |
| | | for (Org one : all) { |
| | | Map<String, String> objMap = new HashMap<>(); |
| | | objMap.put("tag", one.tag); |
| | | objMap.put("name", one.name); |
| | | OrgList.add(objMap) ; |
| | | } |
| | | } |
| | | |
| | | public String getTag() { |
| | | return this.tag ; |
| | |
| | | public String getName() { |
| | | return this.name ; |
| | | } |
| | | |
| | | public static Org get(String tag){ |
| | | // if(tag.equals(Ym.tag) || tag.equals(Jyg.tag)){ |
| | | // return Ym ; |
| | | // }else if(tag.equals(Pj.tag)){ |
| | | // return Pj ; |
| | | // } |
| | | if(tag.equals(Jyg.tag)){ |
| | | return Jyg ; |
| | | }else if(tag.equals(Sp.tag)) { |
| | | return Sp; |
| | | } |
| | | return null ; |
| | | } |
| | | |
| | | |
| | | @JSONField |
| | | public JSONObject toJson() { |
| | | return JSONObject.of("tag", getTag(), "name", getName()); |
| | | } |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrGlobal.util; |
| | | |
| | | import com.dy.common.util.ConfigXml; |
| | | import com.dy.common.webListener.ConfigListener; |
| | | import org.jdom2.Document; |
| | | import org.springframework.boot.context.event.ApplicationReadyEvent; |
| | | |
| | | import java.net.URL; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2024/7/24 13:41 |
| | | * @Description |
| | | */ |
| | | public abstract class OrgListenerSupport { |
| | | |
| | | /** |
| | | * 实始化 |
| | | */ |
| | | @SuppressWarnings("unused ") |
| | | protected void init() { |
| | | this.init(null); |
| | | } |
| | | /** |
| | | * 实始化 |
| | | */ |
| | | @SuppressWarnings("unused ") |
| | | protected void init(ApplicationReadyEvent event) { |
| | | try { |
| | | URL configFileURL = ConfigListener.class.getResource("/init-config.xml"); |
| | | ConfigXml configXml = new ConfigXml(); |
| | | Document doc = configXml.createDom(configFileURL); |
| | | this.doInit(configXml, doc); |
| | | } catch (Exception e) { |
| | | System.out.println("系统启动时,初始化配置出错 !"); |
| | | System.out.println(e.getMessage()); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | private void doInit(ConfigXml configXml, Document doc) throws Exception { |
| | | if (configXml != null && doc != null) { |
| | | for (int num = 1; num <= 10000; num++) { |
| | | if (configXml.existElement(doc, "config.orgs.org" + num)) { |
| | | String orgTag = configXml.getSetAttrTxt(doc, "config.orgs.org" + num, "tag", null, false, null); |
| | | String orgName = configXml.getSetAttrTxt(doc, "config.orgs.org" + num, "name", null, false, null); |
| | | Org.OrgVo vo = new Org().new OrgVo() ; |
| | | vo.tag = orgTag ; |
| | | vo.name = orgName ; |
| | | Org.OrgList.add(vo) ; |
| | | }else{ |
| | | break ; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrGlobal.voRm; |
| | | |
| | | import com.alibaba.fastjson2.annotation.JSONField; |
| | | import com.alibaba.fastjson2.writer.ObjectWriterImplToString; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2024-07-23 17:12 |
| | | * @LastEditTime 2024-07-23 17:12 |
| | | * @Description 整点报数据视图对象 |
| | | */ |
| | | |
| | | @Data |
| | | public class VoOnHour { |
| | | private static final long serialVersionUID = 202407231713001L; |
| | | |
| | | /** |
| | | * 取水口ID |
| | | */ |
| | | @JSONField(serializeUsing= ObjectWriterImplToString.class) |
| | | private Long intakeId; |
| | | |
| | | /** |
| | | * 取水口编号 |
| | | */ |
| | | private String intakeNum; |
| | | |
| | | /** |
| | | * 阀控器地址 |
| | | */ |
| | | private String rtuAddr; |
| | | |
| | | /** |
| | | * 数据接收时间 |
| | | */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private String receiveTime; |
| | | |
| | | /** |
| | | * 瞬时流量 |
| | | */ |
| | | private Double instantAmount; |
| | | |
| | | /** |
| | | * 累计流量 |
| | | */ |
| | | private Double totalAmount; |
| | | |
| | | /** |
| | | * 损失流量,从当日0时到当前的漏损累计流量 |
| | | */ |
| | | private Double lossAmount; |
| | | |
| | | /** |
| | | * 水压 |
| | | */ |
| | | private Double waterPress; |
| | | |
| | | /** |
| | | * 蓄电池电压 |
| | | */ |
| | | private Double batteryVolt; |
| | | |
| | | /** |
| | | * 信号强度 |
| | | */ |
| | | private Integer signalValue; |
| | | |
| | | /** |
| | | * 水价 |
| | | */ |
| | | private Double waterPrice; |
| | | } |
| | |
| | | # 数据源名称:当存在多个数据源时,设置名字可以很方便的来进行区分,默认自动生成名称,格式是:"DataSource-" + System.identityHashCode(this) |
| | | name: druid-mysql-pj |
| | | #配置初始化大小、最小、最大 |
| | | initialSize: 1 |
| | | minIdle: 1 |
| | | initialSize: 10 |
| | | minIdle: 10 |
| | | maxActive: 100 |
| | | #配置获取连接等待超时的时间,单位是毫秒 |
| | | # 获取连接时最大等待时间,单位毫秒。配置了maxWait之后,缺省启用公平锁,并发效率会有所下降,如果需要可以通过配置useUnfairLock属性为true使用非公平锁 |
| | | maxWait: 6000 |
| | | #配置间隔多久进行一次检测,检测需要关闭的空闲连接,单位毫秒。 默认是60s,太长可能会导致无法及时检测到连接中断 |
| | | timeBetweenEvictionRunsMillis: 60000 |
| | |
| | | #配置初始化大小、最小、最大 |
| | | initialSize: 10 |
| | | minIdle: 10 |
| | | maxActive: 200 |
| | | maxActive: 100 |
| | | # 获取连接时最大等待时间,单位毫秒。配置了maxWait之后,缺省启用公平锁,并发效率会有所下降,如果需要可以通过配置useUnfairLock属性为true使用非公平锁 |
| | | maxWait: 60000 |
| | | #配置间隔多久进行一次检测,检测需要关闭的空闲连接,单位毫秒。 默认是60s,太长可能会导致无法及时检测到连接中断 |
| | |
| | | #配置初始化大小、最小、最大 |
| | | initialSize: 10 |
| | | minIdle: 10 |
| | | maxActive: 200 |
| | | maxActive: 100 |
| | | # 获取连接时最大等待时间,单位毫秒。配置了maxWait之后,缺省启用公平锁,并发效率会有所下降,如果需要可以通过配置useUnfairLock属性为true使用非公平锁 |
| | | maxWait: 60000 |
| | | #配置间隔多久进行一次检测,检测需要关闭的空闲连接,单位毫秒。 默认是60s,太长可能会导致无法及时检测到连接中断 |
| | |
| | | projectNo: 10 |
| | | #控制器类型 |
| | | controllerType: 57 |
| | | #默认行政区划编码(天津-天津市-武清区-京滨工业园-大禹节水) |
| | | divisionCode: 120114403100 |
| | | |
| | | |
| | | #通讯协议 |
| | |
| | | - /sso/sso |
| | | - /remote/comRes/receive |
| | | - /wx/comRes/receive |
| | | #自动统计配置 |
| | | #自动统计配置,自动统计定时任务会每天定时进行 |
| | | auto-statistics: |
| | | #月统计 |
| | | month: |
| | | startDay: 1 |
| | | startHour: 0 |
| | | startMinute: 5 |
| | | startHour: 9 #开始小时 0 |
| | | startMinute: 51 #开始分钟 5 |
| | |
| | | <config> |
| | | <orgs> |
| | | <!-- 多个组织,用编号区分,编号从1开始 --> |
| | | <org1 name="ym"> |
| | | <org1 tag="ym" name="元谋"> |
| | | <districts> |
| | | <province name="云南省" num="53" level="1"> |
| | | <city name="楚雄彝族自治州" num="23" level="2"> |
| | |
| | | <item5 typeName="绿化用水"/> |
| | | </waterTypes> |
| | | </org1> |
| | | <org2 name="sp"> |
| | | <org2 tag="sp" name="沙盘"> |
| | | <districts> |
| | | <province name="天津" num="53" level="1"> |
| | | <city name="天津市" num="23" level="2"> |
| | |
| | | water_price = #{waterPrice,jdbcType=FLOAT} |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | |
| | | <!--根据指定条件获取整点报历史记录数量--> |
| | | <select id="getOnHourReportsCount_history" resultType="java.lang.Long"> |
| | | SELECT |
| | | COUNT(*) AS recordCount |
| | | FROM rm_on_hour_report_history oh |
| | | INNER JOIN pr_intake inta ON inta.id = oh.intake_id |
| | | <where> |
| | | <if test = "intakeName != null and intakeName !=''"> |
| | | AND inta.name LIKE CONCAT('%',#{intakeName},'%') |
| | | </if> |
| | | <if test = "rtuAddr != null and rtuAddr !=''"> |
| | | AND oh.rtu_addr LIKE CONCAT('%',#{rtuAddr},'%') |
| | | </if> |
| | | <if test = "timeStart != null and timeStop != null"> |
| | | AND oh.dt BETWEEN #{timeStart} AND #{timeStop} |
| | | </if> |
| | | </where> |
| | | </select> |
| | | |
| | | <!--根据指定条件获取整点报历史记录--> |
| | | <select id="getOnHourReports_history" resultType="com.dy.pipIrrGlobal.voRm.VoOnHour"> |
| | | SELECT |
| | | oh.intake_id AS intakeId, |
| | | inta.`name` AS intakeNum, |
| | | oh.rtu_addr AS rtuAddr, |
| | | oh.dt AS receiveTime, |
| | | oh.instant_amount AS instantAmount, |
| | | oh.total_amount AS totalAmount, |
| | | oh.loss_amount AS lossAmount, |
| | | oh.water_press AS waterPress, |
| | | oh.battery_volt AS batteryVolt, |
| | | oh.signal_value AS signalValue, |
| | | oh.water_price AS waterPrice |
| | | FROM rm_on_hour_report_history oh |
| | | INNER JOIN pr_intake inta ON inta.id = oh.intake_id |
| | | <where> |
| | | <if test = "intakeNum != null and intakeNum !=''"> |
| | | AND inta.name LIKE CONCAT('%',#{intakeNum},'%') |
| | | </if> |
| | | <if test = "rtuAddr != null and rtuAddr !=''"> |
| | | AND oh.rtu_addr LIKE CONCAT('%',#{rtuAddr},'%') |
| | | </if> |
| | | <if test = "timeStart != null and timeStop != null"> |
| | | AND oh.dt BETWEEN #{timeStart} AND #{timeStop} |
| | | </if> |
| | | </where> |
| | | ORDER BY oh.dt DESC |
| | | <trim prefix="limit " > |
| | | <if test="start != null and count != null"> |
| | | #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER} |
| | | </if> |
| | | </trim> |
| | | </select> |
| | | </mapper> |
New file |
| | |
| | | <?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.dy.pipIrrGlobal.daoSe.SeManagerCardMapper"> |
| | | <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoSe.SeManagerCard"> |
| | | <!--@mbg.generated--> |
| | | <!--@Table se_manager_card--> |
| | | <id column="id" jdbcType="BIGINT" property="id" /> |
| | | <result column="card_addr" jdbcType="VARCHAR" property="cardAddr" /> |
| | | <result column="card_num" jdbcType="VARCHAR" property="cardNum" /> |
| | | <result column="card_type" jdbcType="TINYINT" property="cardType" /> |
| | | <result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> |
| | | <result column="remarks" jdbcType="VARCHAR" property="remarks" /> |
| | | </resultMap> |
| | | <sql id="Base_Column_List"> |
| | | <!--@mbg.generated--> |
| | | id, card_addr, card_num, card_type, create_time, remarks |
| | | </sql> |
| | | <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> |
| | | <!--@mbg.generated--> |
| | | select |
| | | <include refid="Base_Column_List" /> |
| | | from se_manager_card |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> |
| | | <!--@mbg.generated--> |
| | | delete from se_manager_card |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </delete> |
| | | <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoSe.SeManagerCard"> |
| | | <!--@mbg.generated--> |
| | | insert into se_manager_card (id, card_addr, card_num, |
| | | card_type, create_time, remarks |
| | | ) |
| | | values (#{id,jdbcType=BIGINT}, #{cardAddr,jdbcType=VARCHAR}, #{cardNum,jdbcType=VARCHAR}, |
| | | #{cardType,jdbcType=TINYINT}, #{createTime,jdbcType=TIMESTAMP}, #{remarks,jdbcType=VARCHAR} |
| | | ) |
| | | </insert> |
| | | <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoSe.SeManagerCard"> |
| | | <!--@mbg.generated--> |
| | | insert into se_manager_card |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null"> |
| | | id, |
| | | </if> |
| | | <if test="cardAddr != null"> |
| | | card_addr, |
| | | </if> |
| | | <if test="cardNum != null"> |
| | | card_num, |
| | | </if> |
| | | <if test="cardType != null"> |
| | | card_type, |
| | | </if> |
| | | <if test="createTime != null"> |
| | | create_time, |
| | | </if> |
| | | <if test="remarks != null"> |
| | | remarks, |
| | | </if> |
| | | </trim> |
| | | <trim prefix="values (" suffix=")" suffixOverrides=","> |
| | | <if test="id != null"> |
| | | #{id,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="cardAddr != null"> |
| | | #{cardAddr,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="cardNum != null"> |
| | | #{cardNum,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="cardType != null"> |
| | | #{cardType,jdbcType=TINYINT}, |
| | | </if> |
| | | <if test="createTime != null"> |
| | | #{createTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | <if test="remarks != null"> |
| | | #{remarks,jdbcType=VARCHAR}, |
| | | </if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoSe.SeManagerCard"> |
| | | <!--@mbg.generated--> |
| | | update se_manager_card |
| | | <set> |
| | | <if test="cardAddr != null"> |
| | | card_addr = #{cardAddr,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="cardNum != null"> |
| | | card_num = #{cardNum,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="cardType != null"> |
| | | card_type = #{cardType,jdbcType=TINYINT}, |
| | | </if> |
| | | <if test="createTime != null"> |
| | | create_time = #{createTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | <if test="remarks != null"> |
| | | remarks = #{remarks,jdbcType=VARCHAR}, |
| | | </if> |
| | | </set> |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoSe.SeManagerCard"> |
| | | <!--@mbg.generated--> |
| | | update se_manager_card |
| | | set card_addr = #{cardAddr,jdbcType=VARCHAR}, |
| | | card_num = #{cardNum,jdbcType=VARCHAR}, |
| | | card_type = #{cardType,jdbcType=TINYINT}, |
| | | create_time = #{createTime,jdbcType=TIMESTAMP}, |
| | | remarks = #{remarks,jdbcType=VARCHAR} |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | |
| | | <!--根据行政区划串模糊查询管理卡编号--> |
| | | <select id="getManagerCardNumOfMax" resultType="java.lang.String"> |
| | | SELECT card_num |
| | | FROM se_manager_card |
| | | WHERE card_num LIKE CONCAT(#{areaCode},'%') |
| | | ORDER BY card_num desc |
| | | LIMIT 0,1 |
| | | </select> |
| | | </mapper> |
| | |
| | | if(ServerProperties.cacheUpDownDataMaxCount <= ServerProperties.cacheUpDownDataWarnCount){ |
| | | throw new Exception("cacheUpDownDataMaxCount必须大于cacheUpDownDataWarnCount") ; |
| | | } |
| | | //没有上行数据的分钟数,达到这个分钟数,认为RTU断网了,取值范围是2_100 |
| | | //没有上行数据的分钟数,达到这个分钟数,认为RTU断网了,取值范围是2-100 |
| | | ServerProperties.disconnectedByNoUpDataMinutes = 0L + conf.getSetAttrPlusInt(doc, "config.base", "disconnectedByNoUpDataMinutes", null, 1, 100, null) ; |
| | | if(ServerProperties.disconnectedByNoUpDataMinutes < 1 || ServerProperties.disconnectedByNoUpDataMinutes > 100){ |
| | | throw new Exception("disconnectedByNoUpDataMinutes取值必须是1~100") ; |
| | | } |
| | | ServerProperties.disconnectedByNoUpDataMinutes = ServerProperties.disconnectedByNoUpDataMinutes * 60 * 1000 ; |
| | | |
| | | //工作报太频繁,N次上报处理1次,取值范围是1-100 |
| | | ServerProperties.workReportDealOneByTimes = conf.getSetAttrPlusInt(doc, "config.base", "workReportDealOneByTimes", null, 1, 100, null) ; |
| | | if(ServerProperties.workReportDealOneByTimes < 1 || ServerProperties.workReportDealOneByTimes > 100){ |
| | | throw new Exception("workReportDealOneByTimes取值必须是1~100") ; |
| | | } |
| | | |
| | | //设置ID生成器的后缀 |
| | | IDLongGenerator.setSuffix(ServerProperties.dbDataIdSuffix.intValue()); |
| | | |
| | |
| | | //没有上行数据的分钟数,达到这个分钟数,认为RTU断网了,取值范围是2000_100000 |
| | | public static Long disconnectedByNoUpDataMinutes = 3000L ; |
| | | |
| | | //工作报太频繁,N次上报处理1次 |
| | | public static Integer workReportDealOneByTimes = 5 ; |
| | | |
| | | } |
| | |
| | | package com.dy.rtuMw.server.rtuData.p206V1_0_0; |
| | | |
| | | import com.dy.pipIrrGlobal.pojoSe.SeClient; |
| | | import com.dy.rtuMw.server.ServerProperties; |
| | | import com.dy.rtuMw.server.rtuData.TaskSurpport; |
| | | import com.dy.rtuMw.server.rtuData.dbSv.DbSv; |
| | | import com.dy.common.mw.protocol.Data; |
| | |
| | | import org.apache.logging.log4j.LogManager; |
| | | import org.apache.logging.log4j.Logger; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @Author liurunyu |
| | | * @Date 2024/2/27 14:20 |
| | |
| | | public class TkDealWorkReport extends TaskSurpport { |
| | | |
| | | private static final Logger log = LogManager.getLogger(TkDealWorkReport.class.getName()) ; |
| | | |
| | | private static final Map<String, Integer> RtuReportTimes = new HashMap<>(); |
| | | |
| | | //类ID,一定与Tree.xml配置文件中配置一致 |
| | | public static final String taskId = "TkDealWorkReport" ; |
| | |
| | | DataV1_0_1 dV1_0_1 = (DataV1_0_1) d.getSubData();//前面任务已经判断不为null |
| | | Object cdObj = dV1_0_1.subData; |
| | | if (cdObj != null && cdObj instanceof DataCd84Vo) { |
| | | boolean deal = false ; |
| | | Integer times = RtuReportTimes.get(d.rtuAddr) ; |
| | | if(times == null){ |
| | | times = 1 ; |
| | | RtuReportTimes.put(d.rtuAddr, times) ; |
| | | deal = true ;//第一次 |
| | | }else{ |
| | | times++ ; |
| | | if(times > ServerProperties.workReportDealOneByTimes){ |
| | | times = 1 ;//循环第一次 |
| | | deal = true ; |
| | | } |
| | | RtuReportTimes.put(d.rtuAddr, times) ; |
| | | } |
| | | if(deal){ |
| | | Object[] objs = this.getTaskResults(TkPreGenObjs.taskId) ; |
| | | DbSv sv = (DbSv)objs[0] ; |
| | | PrController controller = (PrController)objs[1] ; |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | /** |
| | | * 处理阀开工作报数据 |
| | | * @param sv 服务 |
| | |
| | | dbDataIdSuffix:数据库数据id生成器的id后缀,0是默认的后缀,一般web系统应用,数据中间件id后缀大于等于1 |
| | | cacheUpDownDataWarnCount:上下行数据缓存队列中缓存数据个数的报警量,这个与现实项目所接水表数相关 |
| | | cacheUpDownDataMaxCount:上下行数据缓存队列中缓存数据个数的最大值,这个与现实项目所接水表数相关 |
| | | disconnectedByNoUpDataMinutes:没有上行数据的分钟数,达到这个分钟数,认为RTU断网了,取值范围是2_100 |
| | | disconnectedByNoUpDataMinutes:没有上行数据的分钟数,达到这个分钟数,认为RTU断网了,取值范围是2-100 |
| | | workReportDealOneByTimes: 工作报太频繁,N次上报处理1次,取值范围是1-100 |
| | | --> |
| | | <base |
| | | orgTag="ym" |
| | |
| | | cacheUpDownDataWarnCount="100000" |
| | | cacheUpDownDataMaxCount="110000" |
| | | disconnectedByNoUpDataMinutes="3" |
| | | workReportDealOneByTimes="5" |
| | | /> |
| | | |
| | | <!-- |
| | |
| | | if(configXml != null && doc != null){ |
| | | for(int num = 1; num <= 10000; num++){ |
| | | if(configXml.existElement(doc, "config.orgs.org" + num)){ |
| | | String orgTag = configXml.getSetAttrTxt(doc, "config.orgs.org" + num,"name", null, false, null) ; |
| | | String orgTag = configXml.getSetAttrTxt(doc, "config.orgs.org" + num,"tag", null, false, null) ; |
| | | //设置数据源 |
| | | DataSourceContext.set(orgTag); |
| | | if(!this.existDistricts()){ |
New file |
| | |
| | | package com.dy.pipIrrRemote.report; |
| | | |
| | | import com.dy.common.aop.SsoAop; |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | | import com.dy.common.webUtil.QueryResultVo; |
| | | import com.dy.pipIrrGlobal.voRm.VoOnHour; |
| | | import com.dy.pipIrrRemote.report.qo.ReportQO; |
| | | import lombok.RequiredArgsConstructor; |
| | | 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.RestController; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2024-07-23 16:01 |
| | | * @LastEditTime 2024-07-23 16:01 |
| | | * @Description 各类数据报控制类 |
| | | */ |
| | | |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping(path = "report") |
| | | @RequiredArgsConstructor |
| | | public class ReportCtrl { |
| | | private final ReportSv reportSv; |
| | | |
| | | /** |
| | | * 根据指定条件获取整点报历史记录 |
| | | * @param qo |
| | | * @return |
| | | */ |
| | | @GetMapping(path = "/on_hour_report_history") |
| | | @SsoAop() |
| | | public BaseResponse<QueryResultVo<List<VoOnHour>>> getOnHourReportHistory(ReportQO qo){ |
| | | try { |
| | | return BaseResponseUtils.buildSuccess(reportSv.getOnHourReportsHistory(qo)); |
| | | } catch (Exception e) { |
| | | return BaseResponseUtils.buildException(e.getMessage()) ; |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrRemote.report; |
| | | |
| | | import com.dy.common.webUtil.QueryResultVo; |
| | | import com.dy.pipIrrGlobal.daoRm.*; |
| | | import com.dy.pipIrrGlobal.voRm.VoOnHour; |
| | | import com.dy.pipIrrRemote.report.qo.ReportQO; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.dubbo.common.utils.PojoUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2024-07-23 16:02 |
| | | * @LastEditTime 2024-07-23 16:02 |
| | | * @Description 各类数据报服务类 |
| | | */ |
| | | |
| | | @Slf4j |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class ReportSv { |
| | | // 阀控器整点报DAO |
| | | private final RmOnHourReportHistoryMapper rmOnHourReportHistoryMapper; |
| | | private final RmOnHourReportLastMapper rmOnHourReportLastMapper; |
| | | |
| | | // 阀控器开关阀报DAO |
| | | private final RmOpenCloseValveHistoryMapper rmOpenCloseValveHistoryMapper; |
| | | private final RmOpenCloseValveLastMapper rmOpenCloseValveLastMapper; |
| | | |
| | | // 阀控器定时报DAO |
| | | private final RmTimingReportHistoryMapper rmTimingReportHistoryMapper; |
| | | private final RmTimingReportLastMapper rmTimingReportLastMapper; |
| | | |
| | | // 工作报DAO |
| | | private final RmWorkReportHistoryMapper rmWorkReportHistoryMapper; |
| | | private final RmWorkReportLastMapper rmWorkReportLastMapper; |
| | | |
| | | /** |
| | | * 根据指定条件获取整点报历史记录 |
| | | * @param qo |
| | | * @return |
| | | */ |
| | | public QueryResultVo<List<VoOnHour>> getOnHourReportsHistory(ReportQO qo) { |
| | | String timeStart = qo.getTimeStart(); |
| | | String timeStop = qo.getTimeStop(); |
| | | if(timeStart != null) { |
| | | timeStart = timeStart + " 00:00:00"; |
| | | qo.setTimeStart(timeStart); |
| | | } |
| | | if(timeStop != null) { |
| | | timeStop = timeStop + " 23:59:59"; |
| | | qo.setTimeStop(timeStop); |
| | | } |
| | | |
| | | Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo); |
| | | Long itemTotal = rmOnHourReportHistoryMapper.getOnHourReportsCount_history(params); |
| | | |
| | | QueryResultVo<List<VoOnHour>> rsVo = new QueryResultVo<>() ; |
| | | rsVo.pageSize = qo.pageSize ; |
| | | rsVo.pageCurr = qo.pageCurr ; |
| | | |
| | | rsVo.calculateAndSet(itemTotal, params); |
| | | rsVo.obj = rmOnHourReportHistoryMapper.getOnHourReports_history(params); |
| | | return rsVo ; |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrRemote.report.qo; |
| | | |
| | | import com.dy.common.webUtil.QueryConditionVo; |
| | | import lombok.*; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2024-07-23 16:31 |
| | | * @LastEditTime 2024-07-23 16:31 |
| | | * @Description |
| | | */ |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @ToString(callSuper = true) |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | @Builder |
| | | public class ReportQO extends QueryConditionVo { |
| | | |
| | | /** |
| | | * 取水口编号 |
| | | */ |
| | | private String intakeNum; |
| | | |
| | | /** |
| | | * 阀控器地址 |
| | | */ |
| | | private String rtuAddr; |
| | | |
| | | /** |
| | | * 查询开始日期 |
| | | */ |
| | | private String timeStart; |
| | | |
| | | /** |
| | | * 查询结束日期 |
| | | */ |
| | | private String timeStop; |
| | | } |
| | |
| | | import com.dy.pipIrrGlobal.pojoBa.BaClient; |
| | | import com.dy.pipIrrGlobal.pojoSe.SeCardOperate; |
| | | import com.dy.pipIrrGlobal.pojoSe.SeClientCard; |
| | | import com.dy.pipIrrGlobal.pojoSe.SeManagerCard; |
| | | import com.dy.pipIrrGlobal.util.AmountToChinese; |
| | | import com.dy.pipIrrGlobal.voSe.VoActiveCard; |
| | | import com.dy.pipIrrGlobal.voSe.VoOperate; |
| | |
| | | import jakarta.validation.Valid; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.validation.BindingResult; |
| | |
| | | private final CardOperateSv cardOperateSv; |
| | | private final ClientCardSv clientCardSv; |
| | | |
| | | @Value("${project.divisionCode}") |
| | | private String divisionCode; |
| | | /** |
| | | * 开卡 |
| | | * @param po 开卡传入对象 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 创建管理卡 |
| | | * @param po |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "create_manager_card", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @SsoAop() |
| | | public BaseResponse<Boolean> createManagerCard(@RequestBody @Valid ManagerCard po, BindingResult bindingResult){ |
| | | if(bindingResult != null && bindingResult.hasErrors()){ |
| | | return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); |
| | | } |
| | | |
| | | /** |
| | | * 根据行政区划串(divisionCode)在管理卡表中针对卡片编号(cardNum)进行模糊查询 |
| | | * 如果顺序号已经达到最大值,提示用户联系系统管理员 |
| | | * 如果顺序号未达到最大值,则加1 |
| | | * cardNum为新的卡号 |
| | | */ |
| | | String cardNum = Optional.ofNullable(cardOperateSv.getManagerCardNumOfMax(divisionCode)).orElse(""); |
| | | if(cardNum != null && cardNum.trim().length() > 0) { |
| | | Integer number = Integer.parseInt(cardNum.substring(12)); |
| | | number = number + 1; |
| | | if(number > 65535) { |
| | | return BaseResponseUtils.buildErrorMsg(SellResultCode.CARD_NUMBER_OVERRUN.getMessage()); |
| | | } |
| | | cardNum = cardNum.substring(0, 12) + String.format("%05d", number); |
| | | } else { |
| | | cardNum = divisionCode + "00001"; |
| | | } |
| | | |
| | | SeManagerCard seManagerCard = new SeManagerCard(); |
| | | seManagerCard.setCardAddr(po.getCardAddr()); |
| | | seManagerCard.setCardNum(cardNum); |
| | | seManagerCard.setCardType(po.getCardType()); |
| | | seManagerCard.setCreateTime(new Date()); |
| | | seManagerCard.setRemarks(po.getRemarks()); |
| | | Long managerCardId = cardOperateSv.addManagerCard(seManagerCard); |
| | | if(managerCardId == 0) { |
| | | return BaseResponseUtils.buildErrorMsg(SellResultCode.CREATE_MANAGER_CARD_ERROR.getMessage()); |
| | | } |
| | | |
| | | return BaseResponseUtils.buildSuccess(cardNum); |
| | | |
| | | //Map map = new HashMap(); |
| | | //map.put("cardNum", cardNum); |
| | | //return BaseResponseUtils.buildSuccess(map) ; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取充值记录 |
| | | * @param vo |
| | | * @return |
| | |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | | import com.dy.common.webUtil.QueryResultVo; |
| | | import com.dy.pipIrrGlobal.daoBa.BaSettingsMapper; |
| | | import com.dy.pipIrrGlobal.daoSe.SeCardOperateMapper; |
| | | import com.dy.pipIrrGlobal.daoSe.SeClientCardMapper; |
| | | import com.dy.pipIrrGlobal.daoSe.SeClientMapper; |
| | | import com.dy.pipIrrGlobal.daoSe.SeGeneralMapper; |
| | | import com.dy.pipIrrGlobal.daoSe.*; |
| | | import com.dy.pipIrrGlobal.pojoSe.SeCardOperate; |
| | | import com.dy.pipIrrGlobal.pojoSe.SeClientCard; |
| | | import com.dy.pipIrrGlobal.pojoSe.SeManagerCard; |
| | | import com.dy.pipIrrGlobal.voSe.*; |
| | | import com.dy.pipIrrSell.cardOperate.dto.DtoRecharge; |
| | | import com.dy.pipIrrSell.cardOperate.enums.OperateTypeENUM; |
| | |
| | | @Autowired |
| | | private BaSettingsMapper baSettingsMapper; |
| | | |
| | | @Autowired |
| | | private SeManagerCardMapper seManagerCardMapper; |
| | | |
| | | |
| | | /** |
| | | * 添加开卡记录 |
| | |
| | | public Long getAreaCodeById(Long clientId) { |
| | | return seClientMapper.getAreaCodeById(clientId); |
| | | } |
| | | |
| | | /** |
| | | * 根据行政区划串模块查询水卡编号,开卡使用 |
| | | * @param areaCode |
| | | * @return |
| | | */ |
| | | String getCardNumOfMax(String areaCode) { |
| | | public String getCardNumOfMax(String areaCode) { |
| | | return seClientCardMapper.getCardNumOfMax(areaCode); |
| | | } |
| | | |
| | | /** |
| | | * 根据行政区划串模糊查询管理卡编号,创建管理卡使用 |
| | | * @param areaCode |
| | | * @return |
| | | */ |
| | | public String getManagerCardNumOfMax(String areaCode) { |
| | | return seManagerCardMapper.getManagerCardNumOfMax(areaCode); |
| | | } |
| | | |
| | | /** |
| | | * 创建管理卡 |
| | | * @param po |
| | | * @return |
| | | */ |
| | | public Long addManagerCard(SeManagerCard po) { |
| | | seManagerCardMapper.insert(po); |
| | | return po.getId(); |
| | | } |
| | | |
| | | /** |
| | | * 根据农户编号获取农户ID,开卡使用 |
| | | * @param clientNum |
| | | * @return |
New file |
| | |
| | | package com.dy.pipIrrSell.cardOperate.dto; |
| | | |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2024-07-24 11:25 |
| | | * @LastEditTime 2024-07-24 11:25 |
| | | * @Description 管理卡传输对象 |
| | | */ |
| | | |
| | | @Data |
| | | public class ManagerCard { |
| | | public static final long serialVersionUID = 202407241125001L; |
| | | |
| | | /** |
| | | * 水卡地址,仅保存,无业务 |
| | | */ |
| | | @NotBlank(message = "水卡地址不能为空") |
| | | private String cardAddr; |
| | | |
| | | /** |
| | | * 卡片类型,2-管理科,4-开关阀卡,5-清空卡 |
| | | */ |
| | | private Byte cardType; |
| | | |
| | | |
| | | /** |
| | | * 备注信息 |
| | | */ |
| | | private String remarks; |
| | | } |
| | |
| | | No_ActiveCards(10009, "没有符合条件的开卡数据"), |
| | | No_RECHARGES(10010, "没有符合条件的充值数据"), |
| | | No_ReissueCards(10011, "没有符合条件的补卡数据"), |
| | | No_CANCELS(10010, "没有符合条件的注销数据"), |
| | | PARAMS_ERROR(10010, "操作类型参数错误"), |
| | | |
| | | THE_CARD_NOT_EXIST(10012, "没有符合条件的水卡"), |
| | | THE_CARD_NOT_SUPPORT_THIS_OPERATION(10013, "水卡状态不支持当前操作"), |
| | | |
| | | THE_FEE_CANNOT_BE_REFUNDED(10014, "原卡挂失时已退款,补卡时不能补费用"), |
| | | No_CANCELS(10012, "没有符合条件的注销数据"), |
| | | PARAMS_ERROR(10013, "操作类型参数错误"), |
| | | CREATE_MANAGER_CARD_ERROR(10014, "创建管理卡失败"), |
| | | THE_CARD_NOT_EXIST(10015, "没有符合条件的水卡"), |
| | | THE_CARD_NOT_SUPPORT_THIS_OPERATION(10016, "水卡状态不支持当前操作"), |
| | | THE_FEE_CANNOT_BE_REFUNDED(10017, "原卡挂失时已退款,补卡时不能补费用"), |
| | | |
| | | /** |
| | | * 充值 |
| | |
| | | import java.util.Objects; |
| | | import java.util.UUID; |
| | | |
| | | //import org.springframework.cache.CacheManager; |
| | | |
| | | /** |
| | | * 注解Tag 在API中显示: Tag 注解, 给整个接口起了个名字与描述" |
| | | * 注解ApiResponses 和 注解ApiResponse 用来配置响应; |
| | |
| | | ) |
| | | }) |
| | | @GetMapping(path = "allOrg") |
| | | public BaseResponse<List<Org>> allOrg(){ |
| | | public BaseResponse<List<Org.OrgVo>> allOrg(){ |
| | | //List<Org> list = Arrays.asList(Org.Ym, Org.Pj) ; |
| | | return BaseResponseUtils.buildSuccess(Org.OrgList); |
| | | } |
| | |
| | | package com.dy.sso.util; |
| | | |
| | | import jakarta.servlet.ServletContext; |
| | | import jakarta.servlet.ServletContextEvent; |
| | | import jakarta.servlet.ServletContextListener; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import com.dy.pipIrrGlobal.util.OrgListenerSupport; |
| | | import org.springframework.boot.context.event.ApplicationReadyEvent; |
| | | import org.springframework.context.ApplicationListener; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | @Slf4j |
| | | public class SsoListener implements ServletContextListener { |
| | | @Component |
| | | public class SsoListener extends OrgListenerSupport implements ApplicationListener<ApplicationReadyEvent> { |
| | | |
| | | |
| | | @Override |
| | | public void contextInitialized(ServletContextEvent event) { |
| | | ServletContextListener.super.contextInitialized(event); |
| | | ServletContext con = event.getServletContext(); |
| | | public void onApplicationEvent(ApplicationReadyEvent event) { |
| | | try { |
| | | //等1秒,等待com.alibaba.druid.pool.DruidDataSource实始化完成 |
| | | Thread.sleep(1000L); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | super.init(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void contextDestroyed(ServletContextEvent event) { |
| | | ServletContextListener.super.contextDestroyed(event); |
| | | } |
| | | |
| | | } |
| | |
| | | }) |
| | | } |
| | | ) |
| | | @MapperScan(basePackages={"com.dy.pipIrrGlobal.daoBa"}) |
| | | @MapperScan(basePackages={"com.dy.pipIrrGlobal.daoRm", "com.dy.pipIrrGlobal.daoPr", "com.dy.pipIrrGlobal.daoSe", "com.dy.pipIrrGlobal.daoBa"}) |
| | | public class PipIrrStatisticsApplication { |
| | | |
| | | public static void main(String[] args) { |
New file |
| | |
| | | package com.dy.pipIrrStatistics.listeners; |
| | | |
| | | import com.dy.pipIrrGlobal.daoRm.RmClientAmountDayMapper; |
| | | import org.apache.logging.log4j.LogManager; |
| | | import org.apache.logging.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2024/7/24 9:31 |
| | | * @Description |
| | | */ |
| | | @Component |
| | | public class StClient { |
| | | |
| | | private static Logger log = LogManager.getLogger(StClient.class.getName()) ; |
| | | |
| | | @Autowired |
| | | protected RmClientAmountDayMapper rmClientAmountDayDao ; |
| | | |
| | | private String statisticsYyyy_mm; |
| | | private Long statisticsStartId ; |
| | | private Long statisticsEndId ; |
| | | |
| | | protected void statistics(String statisticsYyyy_mm, |
| | | Long statisticsStartId, |
| | | Long statisticsEndId){ |
| | | this.statisticsYyyy_mm = statisticsYyyy_mm ; |
| | | this.statisticsStartId = statisticsStartId ; |
| | | this.statisticsEndId = statisticsEndId ; |
| | | this.statisticsMonth() ; |
| | | this.statisticsYear() ; |
| | | } |
| | | |
| | | /** |
| | | * 月统计---农户 |
| | | */ |
| | | private void statisticsMonth(){ |
| | | log.info(statisticsYyyy_mm + " " + statisticsStartId + " " + statisticsEndId); |
| | | log.info(rmClientAmountDayDao.toString()); |
| | | } |
| | | |
| | | /** |
| | | * 年统计---农户 |
| | | */ |
| | | private void statisticsYear(){ |
| | | |
| | | } |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrStatistics.listeners; |
| | | |
| | | import com.dy.pipIrrGlobal.daoRm.RmIntakeAmountDayMapper; |
| | | import org.apache.logging.log4j.LogManager; |
| | | import org.apache.logging.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2024/7/24 9:30 |
| | | * @Description |
| | | */ |
| | | @Component |
| | | public class StIntake { |
| | | |
| | | private static Logger log = LogManager.getLogger(StIntake.class.getName()) ; |
| | | |
| | | @Autowired |
| | | protected RmIntakeAmountDayMapper rmIntakeAmountDayDao ; |
| | | |
| | | private String statisticsYyyy_mm; |
| | | private Long statisticsStartId ; |
| | | private Long statisticsEndId ; |
| | | |
| | | protected void statistics(String statisticsYyyy_mm, |
| | | Long statisticsStartId, |
| | | Long statisticsEndId){ |
| | | this.statisticsYyyy_mm = statisticsYyyy_mm ; |
| | | this.statisticsStartId = statisticsStartId ; |
| | | this.statisticsEndId = statisticsEndId ; |
| | | this.statisticsMonth() ; |
| | | this.statisticsYear() ; |
| | | } |
| | | |
| | | /** |
| | | * 月统计---取水口 |
| | | */ |
| | | private void statisticsMonth(){ |
| | | log.info(statisticsYyyy_mm + " " + statisticsStartId + " " + statisticsEndId); |
| | | log.info(rmIntakeAmountDayDao.toString()); |
| | | } |
| | | |
| | | /** |
| | | * 年统计---取水口 |
| | | */ |
| | | private void statisticsYear(){ |
| | | |
| | | } |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrStatistics.listeners; |
| | | |
| | | import com.dy.pipIrrGlobal.daoRm.RmLossHistoryMapper; |
| | | import org.apache.logging.log4j.LogManager; |
| | | import org.apache.logging.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2024/7/24 9:10 |
| | | * @Description |
| | | */ |
| | | @Component |
| | | public class StLoss { |
| | | |
| | | private static Logger log = LogManager.getLogger(StLoss.class.getName()) ; |
| | | |
| | | @Autowired |
| | | protected RmLossHistoryMapper rmLossHistoryDao ; |
| | | |
| | | private String statisticsYyyy_mm; |
| | | private Long statisticsStartId ; |
| | | private Long statisticsEndId ; |
| | | |
| | | protected void statistics(String statisticsYyyy_mm, |
| | | Long statisticsStartId, |
| | | Long statisticsEndId){ |
| | | this.statisticsYyyy_mm = statisticsYyyy_mm ; |
| | | this.statisticsStartId = statisticsStartId ; |
| | | this.statisticsEndId = statisticsEndId ; |
| | | this.statisticsMonth() ; |
| | | this.statisticsYear() ; |
| | | } |
| | | |
| | | /** |
| | | * 月统计---漏损 |
| | | */ |
| | | private void statisticsMonth(){ |
| | | log.info(statisticsYyyy_mm + " " + statisticsStartId + " " + statisticsEndId); |
| | | log.info(rmLossHistoryDao.toString()); |
| | | } |
| | | |
| | | /** |
| | | * 年统计---漏损 |
| | | */ |
| | | private void statisticsYear(){ |
| | | |
| | | } |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrStatistics.listeners; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2024/7/24 11:24 |
| | | * @Description |
| | | */ |
| | | public class StLossSv { |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrStatistics.listeners; |
| | | |
| | | import com.dy.common.schedulerTask.TaskJob; |
| | | import com.dy.common.schedulerTask.Test; |
| | | import com.dy.common.springUtil.SpringContextUtil; |
| | | import com.dy.common.util.DateTime; |
| | | import com.dy.common.util.IDLongGenerator; |
| | | import org.apache.logging.log4j.LogManager; |
| | | import org.apache.logging.log4j.Logger; |
| | | import org.quartz.JobExecutionContext; |
| | | import org.quartz.JobExecutionException; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2024/7/22 16:41 |
| | | * @Description |
| | | */ |
| | | public class StatisticsJob extends TaskJob { |
| | | |
| | | private static Logger log = LogManager.getLogger(Test.class.getName()) ; |
| | | |
| | | private StLoss stLoss ; |
| | | |
| | | private StIntake stIntake ; |
| | | |
| | | private StClient stClient ; |
| | | |
| | | private String statisticsYyyy_mm; |
| | | private Long statisticsStartId ; |
| | | private Long statisticsEndId ; |
| | | |
| | | @Override |
| | | public void execute(JobExecutionContext ctx) throws JobExecutionException { |
| | | stLoss = SpringContextUtil.getBean(StLoss.class); |
| | | stIntake = SpringContextUtil.getBean(StIntake.class); |
| | | stClient = SpringContextUtil.getBean(StClient.class); |
| | | if(stLoss != null && stIntake != null && stClient != null){ |
| | | int[] ymd = DateTime.yyyy_MM_dd_2_ymdGroup(DateTime.yyyy_MM_dd()) ; |
| | | if(ymd[2] == 1){ |
| | | //统计上个月的 |
| | | statisticsYyyy_mm = DateTime.lastMonth_ym() ;//统计月 |
| | | int lastYear = Integer.parseInt(statisticsYyyy_mm.substring(0, 4)) ; |
| | | int lastMonth = Integer.parseInt(statisticsYyyy_mm.substring(5, 7)) ; |
| | | statisticsStartId = IDLongGenerator.generateOneDayStartId(lastYear, lastMonth, 1) ; |
| | | statisticsEndId = IDLongGenerator.generateOneDayEndId(lastYear, lastMonth, 31) ; |
| | | }else{ |
| | | //统计本月的 |
| | | statisticsYyyy_mm = ymd[0] + "-" + ymd[1] ;//统计月 |
| | | statisticsStartId = IDLongGenerator.generateOneDayStartId(ymd[0], ymd[1], 1) ; |
| | | statisticsEndId = IDLongGenerator.generateOneDayEndId(ymd[0], ymd[1], 31) ; |
| | | } |
| | | doStatistics() ; |
| | | }else{ |
| | | log.error("未能从Spring容器中得到统计bean"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 统计 |
| | | */ |
| | | private void doStatistics(){ |
| | | stLoss.statistics(statisticsYyyy_mm, statisticsStartId, statisticsEndId) ; |
| | | stIntake.statistics(statisticsYyyy_mm, statisticsStartId, statisticsEndId) ; |
| | | stClient.statistics(statisticsYyyy_mm, statisticsStartId, statisticsEndId) ; |
| | | } |
| | | } |
New file |
| | |
| | | package com.dy.pipIrrStatistics.listeners; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | | * @Date: 2024/7/22 14:39 |
| | | * @Description |
| | | */ |
| | | |
| | | import com.dy.common.schedulerTask.SchedulerTaskSupport; |
| | | import org.apache.logging.log4j.LogManager; |
| | | import org.apache.logging.log4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.boot.context.event.ApplicationReadyEvent; |
| | | import org.springframework.context.ApplicationListener; |
| | | import org.springframework.lang.NonNull; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * 监听器,实现功能:在系统启动时初始化,向数据库中插入数据 |
| | | * 本监听器不能采用ServletContextListener方式,因为Servlet上下文Context创建后 |
| | | * Spring容器并没有创建完,而本类中用了Spring容器中的Bean,即*Dao 。 |
| | | * 所以采用了Spring事件监听器来实现 |
| | | */ |
| | | @Component |
| | | public class StatisticsListener implements ApplicationListener<ApplicationReadyEvent> { |
| | | |
| | | private static Logger log = LogManager.getLogger(StatisticsListener.class.getName()) ; |
| | | |
| | | private static final String JobName = "statisticsJob" ; |
| | | private static final String JobGroupName = "statisticsGroup" ; |
| | | private static final Integer ThreadPoolMaxCount = 1 ;//线程池线程最大个数 |
| | | private static final Integer ThreadPoolPriority = 5 ;//线程优先级 |
| | | |
| | | @Value("${auto-statistics.startHour: 0}") |
| | | protected Integer startHour;//统计开始小时 |
| | | |
| | | @Value("${auto-statistics.startMinute: 5}") |
| | | protected Integer startMinute;//统计开始分钟 |
| | | |
| | | /** |
| | | * SpringBoot容器已经准备好了,执行下面方法 |
| | | * @param event 事件 |
| | | */ |
| | | @Override |
| | | public void onApplicationEvent(@NonNull ApplicationReadyEvent event) { |
| | | try { |
| | | //等1秒,等待com.alibaba.druid.pool.DruidDataSource实始化完成 |
| | | Thread.sleep(1000L); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | }finally { |
| | | try{ |
| | | this.start(event); |
| | | }catch (Exception e){ |
| | | log.error("注册统计定时任务出错", e); |
| | | } |
| | | |
| | | } |
| | | } |
| | | /** |
| | | * 初始化 |
| | | */ |
| | | private void start(ApplicationReadyEvent event) throws Exception{ |
| | | SchedulerTaskSupport.setThreadPoolPro(ThreadPoolMaxCount, ThreadPoolPriority); |
| | | SchedulerTaskSupport.addDailyJob(JobName, JobGroupName, StatisticsJob.class, null, startHour, startMinute ) ; |
| | | } |
| | | } |
| | |
| | | spring: |
| | | profiles: |
| | | include: global, database |
| | | include: global, database, database-ym, database-pj, database-sp |
| | | |
| | | #actutor的web端口 |
| | | management: |
| | |
| | | server: |
| | | port: ${pipIrr.statistics.webPort} |
| | | servlet: |
| | | context-path: /sso #web访问上下文路径 |
| | | context-path: /statistics #web访问上下文路径 |
| | | context-parameters: |
| | | #GenerateIdSetSuffixListener中应用,取值范围是0-99 |
| | | IdSuffix: ${pipIrr.statistics.IdSuffix} |
| | | #ConfigListener中应用 |
| | | configFileNames: config-global.xml,config-sso.xml |
| | | configFileNames: config-global.xml |