瀏覽代碼

Merge remote-tracking branch 'origin/master'

chen.cheng 11 月之前
父節點
當前提交
99f6baa761
共有 19 個文件被更改,包括 1288 次插入55 次删除
  1. 58 6
      ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/controller/MeterReadingManualController.java
  2. 6 5
      ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/domain/MeterReadingManual.java
  3. 13 0
      ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/domain/vo/QueryMeterReading.java
  4. 11 0
      ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/mapper/MeterDeviceMapper.java
  5. 8 0
      ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/mapper/MeterReadingManualMapper.java
  6. 21 14
      ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/service/IMeterDeviceService.java
  7. 2 0
      ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/service/IMeterReadingManualService.java
  8. 7 0
      ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/service/impl/MeterDeviceServiceImpl.java
  9. 5 0
      ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/service/impl/MeterReadingManualServiceImpl.java
  10. 794 0
      ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/util/DateUtils.java
  11. 184 0
      ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/util/exception/Assert.java
  12. 59 0
      ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/util/exception/BusinessException.java
  13. 74 0
      ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/util/exception/ErrorCode.java
  14. 9 6
      ems-cloud/ems-modules/ems-server/src/main/resources/application-demo.yml
  15. 5 0
      ems-cloud/ems-modules/ems-server/src/main/resources/mapper/ems/MeterDeviceMapper.xml
  16. 6 0
      ems-cloud/ems-modules/ems-server/src/main/resources/mapper/ems/MeterReadingManualMapper.xml
  17. 8 8
      ems-cloud/sql/ems_init_data.sql
  18. 1 1
      ems-cloud/sql/ems_server.sql
  19. 17 15
      ems-cloud/sql/ems_sys.sql

+ 58 - 6
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/controller/MeterReadingManualController.java

@@ -5,9 +5,14 @@ import com.ruoyi.common.core.web.domain.AjaxResult;
 import com.ruoyi.common.log.annotation.Log;
 import com.ruoyi.common.log.enums.BusinessType;
 import com.ruoyi.common.security.annotation.RequiresPermissions;
+import com.ruoyi.ems.domain.MeterDevice;
 import com.ruoyi.ems.domain.MeterReadingManual;
 import com.ruoyi.ems.domain.vo.QueryMeterReading;
+import com.ruoyi.ems.service.IMeterDeviceService;
 import com.ruoyi.ems.service.IMeterReadingManualService;
+import com.ruoyi.ems.util.DateUtils;
+import com.ruoyi.ems.util.exception.Assert;
+import com.ruoyi.ems.util.exception.BusinessException;
 import io.swagger.annotations.Api;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.DeleteMapping;
@@ -20,6 +25,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.time.Year;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -35,6 +42,9 @@ public class MeterReadingManualController extends BaseController {
     @Autowired
     private IMeterReadingManualService meterReadingManualService;
 
+    @Autowired
+    private IMeterDeviceService meterDeviceService;
+
     /**
      * 查询手动抄记录列表
      */
@@ -59,8 +69,15 @@ public class MeterReadingManualController extends BaseController {
     @RequiresPermissions("ems:meterReading:add")
     @Log(title = "手动抄记录", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody MeterReadingManual meterReadingManual) {
-        return toAjax(meterReadingManualService.insert(meterReadingManual));
+    public AjaxResult add(@RequestBody MeterReadingManual meterRec) {
+        try {
+            fillData(meterRec);
+            int count = meterReadingManualService.insert(meterRec);
+            return toAjax(count);
+        }
+        catch (BusinessException e) {
+            return error(e.getMessage());
+        }
     }
 
     /**
@@ -69,8 +86,19 @@ public class MeterReadingManualController extends BaseController {
     @RequiresPermissions("ems:meterReading:edit")
     @Log(title = "手动抄记录", businessType = BusinessType.UPDATE)
     @PutMapping
-    public AjaxResult edit(@RequestBody MeterReadingManual meterReadingManual) {
-        return toAjax(meterReadingManualService.update(meterReadingManual));
+    public AjaxResult edit(@RequestBody MeterReadingManual meterRec) {
+        try {
+            MeterReadingManual dbItem = meterReadingManualService.selectById(meterRec.getId());
+            Assert.notNull(dbItem, -1, "该记录不存在");
+            meterReadingManualService.deleteById(meterRec.getId());
+            dbItem.setMeterReading(meterRec.getMeterReading());
+            fillData(meterRec);
+            int count = meterReadingManualService.insert(meterRec);
+            return toAjax(count);
+        }
+        catch (BusinessException e) {
+            return error(e.getMessage());
+        }
     }
 
     /**
@@ -79,8 +107,32 @@ public class MeterReadingManualController extends BaseController {
     @RequiresPermissions("ems:meterReading:remove")
     @Log(title = "手动抄记录", businessType = BusinessType.DELETE)
     @DeleteMapping("/{id}")
-    public AjaxResult remove(@PathVariable Long id)
-    {
+    public AjaxResult remove(@PathVariable Long id) {
         return toAjax(meterReadingManualService.deleteById(id));
     }
+
+    private void fillData(MeterReadingManual meterRec) {
+        MeterReadingManual lastItem = meterReadingManualService.selectLastItem(meterRec.getAreaCode(),
+            meterRec.getDeviceCode());
+        MeterDevice meterDevice = meterDeviceService.selectMeterDeviceByCode(meterRec.getAreaCode(),
+            meterRec.getDeviceCode());
+        Date date = new Date();
+
+        if (null != lastItem) {
+            Assert.isTrue(meterRec.getMeterReading() >= lastItem.getMeterReading(), -1, "抄表值不能小于上一条记录");
+            meterRec.setYear(DateUtils.dateToString(date, "yyyy"));
+            meterRec.setMeterMonth(DateUtils.dateToString(date, "yyyyMM"));
+            meterRec.setLastReading(lastItem.getMeterReading());
+            meterRec.setLastTime(lastItem.getMeterTime());
+            meterRec.setMeterTime(date);
+            meterRec.setIncrease(
+                (meterRec.getMeterReading() - lastItem.getMeterReading()) * meterDevice.getMagnification());
+        }
+        else {
+            meterRec.setYear(DateUtils.dateToString(date, "yyyy"));
+            meterRec.setMeterMonth(DateUtils.dateToString(date, "yyyyMM"));
+            meterRec.setMeterTime(date);
+            meterRec.setIncrease(meterRec.getMeterReading() * meterDevice.getMagnification());
+        }
+    }
 }

+ 6 - 5
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/domain/MeterReadingManual.java

@@ -1,11 +1,12 @@
 package com.ruoyi.ems.domain;
 
-import java.util.Date;
 import com.fasterxml.jackson.annotation.JsonFormat;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
 import com.ruoyi.common.core.annotation.Excel;
 import com.ruoyi.common.core.web.domain.BaseEntity;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+import java.util.Date;
 
 /**
  * 手动抄记录对象 adm_meter_reading_manual
@@ -85,12 +86,12 @@ public class MeterReadingManual extends BaseEntity
     {
         return areaCode;
     }
-    public void setYear(String year) 
+    public void setYear(String year)
     {
         this.year = year;
     }
 
-    public String getYear() 
+    public String getYear()
     {
         return year;
     }

+ 13 - 0
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/domain/vo/QueryMeterReading.java

@@ -35,6 +35,11 @@ public class QueryMeterReading {
     /** 结束月份 */
     private String endMonth;
 
+    /**
+     * 排序方式
+     */
+    private String orderFlag = "ASC";
+
     public String getAreaCode() {
         return areaCode;
     }
@@ -74,4 +79,12 @@ public class QueryMeterReading {
     public void setEndMonth(String endMonth) {
         this.endMonth = endMonth;
     }
+
+    public String getOrderFlag() {
+        return orderFlag;
+    }
+
+    public void setOrderFlag(String orderFlag) {
+        this.orderFlag = orderFlag;
+    }
 }

+ 11 - 0
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/mapper/MeterDeviceMapper.java

@@ -1,7 +1,9 @@
 package com.ruoyi.ems.mapper;
 
 import java.util.List;
+
 import com.ruoyi.ems.domain.MeterDevice;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * 计量设备Mapper接口
@@ -19,6 +21,15 @@ public interface MeterDeviceMapper {
     MeterDevice selectMeterDeviceById(Long id);
 
     /**
+     * 查询计量设备
+     *
+     * @param areaCode   区域code
+     * @param deviceCode 设备code
+     * @return 计量设备
+     */
+    MeterDevice selectMeterDeviceByCode(@Param("areaCode") String areaCode, @Param("deviceCode") String deviceCode);
+
+    /**
      * 查询计量设备列表
      *
      * @param meterDevice 计量设备

+ 8 - 0
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/mapper/MeterReadingManualMapper.java

@@ -16,6 +16,14 @@ public interface MeterReadingManualMapper {
     /**
      * 查询手动抄记录列表
      *
+     * @param id   区域编码
+     * @return 手动抄记录集合
+     */
+    MeterReadingManual selectById(@Param("id") Long id);
+
+    /**
+     * 查询手动抄记录列表
+     *
      * @param areaCode   区域编码
      * @param deviceCode 设备编码
      * @return 手动抄记录集合

+ 21 - 14
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/service/IMeterDeviceService.java

@@ -6,57 +6,64 @@ import java.util.List;
 
 /**
  * 计量设备Service接口
- * 
+ *
  * @author ruoyi
  * @date 2024-08-08
  */
-public interface IMeterDeviceService
-{
+public interface IMeterDeviceService {
     /**
      * 查询计量设备
-     * 
+     *
      * @param id 计量设备主键
      * @return 计量设备
      */
     MeterDevice selectMeterDeviceById(Long id);
 
     /**
+     * 查询计量设备
+     * @param areaCode 区域code
+     * @param deviceCode 设备code
+     * @return 计量设备
+     */
+    MeterDevice selectMeterDeviceByCode(String areaCode, String deviceCode);
+
+    /**
      * 查询计量设备列表
-     * 
+     *
      * @param meterDevice 计量设备
      * @return 计量设备集合
      */
-     List<MeterDevice> selectMeterDeviceList(MeterDevice meterDevice);
+    List<MeterDevice> selectMeterDeviceList(MeterDevice meterDevice);
 
     /**
      * 新增计量设备
-     * 
+     *
      * @param meterDevice 计量设备
      * @return 结果
      */
-     int insertMeterDevice(MeterDevice meterDevice);
+    int insertMeterDevice(MeterDevice meterDevice);
 
     /**
      * 修改计量设备
-     * 
+     *
      * @param meterDevice 计量设备
      * @return 结果
      */
-     int updateMeterDevice(MeterDevice meterDevice);
+    int updateMeterDevice(MeterDevice meterDevice);
 
     /**
      * 批量删除计量设备
-     * 
+     *
      * @param ids 需要删除的计量设备主键集合
      * @return 结果
      */
-     int deleteMeterDeviceByIds(Long[] ids);
+    int deleteMeterDeviceByIds(Long[] ids);
 
     /**
      * 删除计量设备信息
-     * 
+     *
      * @param id 计量设备主键
      * @return 结果
      */
-     int deleteMeterDeviceById(Long id);
+    int deleteMeterDeviceById(Long id);
 }

+ 2 - 0
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/service/IMeterReadingManualService.java

@@ -13,6 +13,8 @@ import java.util.List;
  */
 public interface IMeterReadingManualService
 {
+    MeterReadingManual selectById(Long id);
+
     /**
      * 查询手动抄记录列表
      *

+ 7 - 0
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/service/impl/MeterDeviceServiceImpl.java

@@ -61,6 +61,13 @@ public class MeterDeviceServiceImpl implements IMeterDeviceService {
         return meterDevice;
     }
 
+    @Override
+    public MeterDevice selectMeterDeviceByCode(String areaCode, String deviceCode) {
+        MeterDevice meterDevice = meterDeviceMapper.selectMeterDeviceByCode(areaCode, deviceCode);
+        fillObjName(meterDevice);
+        return meterDevice;
+    }
+
     /**
      * 查询计量设备列表
      *

+ 5 - 0
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/service/impl/MeterReadingManualServiceImpl.java

@@ -21,6 +21,11 @@ public class MeterReadingManualServiceImpl implements IMeterReadingManualService
     private MeterReadingManualMapper meterReadingManualMapper;
 
     @Override
+    public MeterReadingManual selectById(Long id) {
+        return meterReadingManualMapper.selectById(id);
+    }
+
+    @Override
     public MeterReadingManual selectLastItem(String areaCode, String deviceCode) {
         return meterReadingManualMapper.selectLastItem(areaCode, deviceCode);
     }

+ 794 - 0
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/util/DateUtils.java

@@ -0,0 +1,794 @@
+/*
+ * 文 件 名:  DateUtils.java
+ * 版    权:  浩鲸云计算科技有限公司
+ * 描    述:  日期工具类
+ * 修 改 人:  lvwenbin
+ * 修改时间:  2018年9月20日
+ * 修改内容:  <修改内容>
+ */
+package com.ruoyi.ems.util;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.exception.ExceptionUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.TimeZone;
+
+/**
+ * 日期工具类 <功能详细描述>
+ * 
+ * @author lvwenbin
+ * @version [版本号, 2018年9月20日]
+ * @see [相关类/方法]
+ * @since [产品/模块版本]
+ */
+public abstract class DateUtils {
+    public static final String DEFAULT_TIME_FORMAT = "yyyyMMddHHmmss";
+
+    /**
+     * 通用时间展示格式
+     */
+    public static final String COMMON_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
+
+    private static final Logger log = LoggerFactory.getLogger(DateUtils.class);
+
+    /**
+     * $ 时间年偏移 <功能详细描述>
+     * 
+     * @param date 日期
+     * @param offset 偏移量
+     * @return date 日期
+     * @see [类、类#方法、类#成员]
+     */
+    public static Date adjustYear(Date date, int offset) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        calendar.add(Calendar.YEAR, offset);
+        Date newDate = calendar.getTime();
+        return newDate;
+    }
+
+    /**
+     * $时间年偏移 <功能详细描述>
+     * 
+     * @param time yyyyMMddHHmmss
+     * @param offset 偏移量
+     * @return yyyyMMddHHmmss
+     * @see [类、类#方法、类#成员]
+     */
+    public static String adjustYear(String time, int offset) {
+        return adjustYear(time, offset, DEFAULT_TIME_FORMAT);
+    }
+
+    /**
+     * $时间年偏移 <功能详细描述>
+     * 
+     * @param time yyyyMMddHHmmss
+     * @param offset 偏移量
+     * @param format 格式化
+     * @return yyyyMMddHHmmss
+     * @see [类、类#方法、类#成员]
+     */
+    public static String adjustYear(String time, int offset, String format) {
+        SimpleDateFormat formatter = new SimpleDateFormat(format);
+        String retTime = null;
+
+        try {
+            Date date = formatter.parse(time);
+            Date newDate = adjustYear(date, offset);
+            retTime = formatter.format(newDate);
+        }
+        catch (ParseException e) {
+            log.error("adjustYear fail!" + ExceptionUtils.getStackTrace(e));
+        }
+
+        return retTime;
+    }
+
+    /**
+     * 时间月偏移
+     * @param date 日期
+     * @param offset 偏移量
+     * @return date 日期
+     */
+    public static Date adjustMonth(Date date, int offset) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        calendar.add(Calendar.MONTH, offset);
+        Date newDate = calendar.getTime();
+        return newDate;
+    }
+
+    /**
+     * $时间月偏移 <功能详细描述>
+     * 
+     * @param time yyyyMMddHHmmss
+     * @param offset 偏移量
+     * @return yyyyMMddHHmmss
+     * @see [类、类#方法、类#成员]
+     */
+    public static String adjustMonth(String time, int offset) {
+        return adjustMonth(time, offset, DEFAULT_TIME_FORMAT);
+    }
+
+    /**
+     * $时间月偏移 <功能详细描述>
+     * 
+     * @param time yyyyMMddHHmmss
+     * @param offset 偏移量
+     * @param format 格式化时间
+     * @return yyyyMMddHHmmss
+     * @see [类、类#方法、类#成员]
+     */
+    public static String adjustMonth(String time, int offset, String format) {
+        SimpleDateFormat formatter = new SimpleDateFormat(format);
+        String retTime = null;
+
+        try {
+            Date date = formatter.parse(time);
+            Date newDate = adjustMonth(date, offset);
+            retTime = formatter.format(newDate);
+        }
+        catch (ParseException e) {
+            log.error("adjustMonth fail!" + ExceptionUtils.getStackTrace(e));
+        }
+
+        return retTime;
+    }
+
+    /**
+     * $时间周偏移 <功能详细描述>
+     * 
+     * @param date 日期
+     * @param offset 偏移量
+     * @return date
+     * @see [类、类#方法、类#成员]
+     */
+    public static Date adjustWeek(Date date, int offset) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        calendar.add(Calendar.DATE, 7 * offset);
+        Date newDate = calendar.getTime();
+        return newDate;
+    }
+
+    /**
+     * $时间周偏移 <功能详细描述>
+     * 
+     * @param time yyyyMMddHHmmss
+     * @param offset 偏移量
+     * @return yyyyMMddHHmmss
+     * @see [类、类#方法、类#成员]
+     */
+    public static String adjustWeek(String time, int offset) {
+        return adjustWeek(time, offset, DEFAULT_TIME_FORMAT);
+    }
+
+    /**
+     * $时间周偏移 <功能详细描述>
+     * 
+     * @param time 字符串日期
+     * @param offset 偏移量
+     * @return yyyyMMddHHmmss
+     * @see [类、类#方法、类#成员]
+     */
+    public static String adjustWeek(String time, int offset, String format) {
+        SimpleDateFormat formatter = new SimpleDateFormat(format);
+        String retTime = null;
+
+        try {
+            Date date = formatter.parse(time);
+            Date newDate = adjustWeek(date, offset);
+            retTime = formatter.format(newDate);
+        }
+        catch (ParseException e) {
+            log.error("adjustWeek fail!" + ExceptionUtils.getStackTrace(e));
+        }
+
+        return retTime;
+    }
+
+    /**
+     * $时间日偏移 <功能详细描述>
+     * 
+     * @param date 日期
+     * @param offset 偏移量
+     * @return yyyyMMddHHmmss
+     * @see [类、类#方法、类#成员]
+     */
+    public static Date adjustDay(Date date, int offset) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        calendar.add(Calendar.DATE, offset);
+        Date newDate = calendar.getTime();
+        return newDate;
+    }
+
+    /**
+     * $时间日偏移 <功能详细描述>
+     * 
+     * @param time yyyyMMddHHmmss
+     * @param offset 偏移量
+     * @return yyyyMMddHHmmss
+     * @see [类、类#方法、类#成员]
+     */
+    public static String adjustDay(String time, int offset) {
+        return adjustDay(time, offset, DEFAULT_TIME_FORMAT);
+    }
+
+    /**
+     * $时间日偏移 <功能详细描述>
+     * 
+     * @param time 字符串日期
+     * @param offset 偏移量
+     * @return yyyyMMddHHmmss
+     * @see [类、类#方法、类#成员]
+     */
+    public static String adjustDay(String time, int offset, String format) {
+        SimpleDateFormat formatter = new SimpleDateFormat(format);
+        String retTime = null;
+
+        try {
+            Date date = formatter.parse(time);
+            Date newDate = adjustDay(date, offset);
+            retTime = formatter.format(newDate);
+        }
+        catch (ParseException e) {
+            log.error("adjustDay fail!" + ExceptionUtils.getStackTrace(e));
+        }
+
+        return retTime;
+    }
+
+    /**
+     * $时间小时偏移 <功能详细描述>
+     * 
+     * @param date 日期
+     * @param offset 偏移量
+     * @return yyyyMMddHHmmss
+     * @see [类、类#方法、类#成员]
+     */
+    public static Date adjustHour(Date date, int offset) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        calendar.add(Calendar.HOUR_OF_DAY, offset);
+        Date newDate = calendar.getTime();
+
+        return newDate;
+    }
+
+    /**
+     * $时间小时偏移 <功能详细描述>
+     * 
+     * @param time yyyyMMddHHmmss
+     * @param offset 偏移量
+     * @return yyyyMMddHHmmss
+     * @see [类、类#方法、类#成员]
+     */
+    public static String adjustHour(String time, int offset) {
+        return adjustHour(time, offset, DEFAULT_TIME_FORMAT);
+    }
+
+    /**
+     * $时间小时偏移 <功能详细描述>
+     * 
+     * @param time yyyyMMddHHmmss
+     * @param offset 偏移量
+     * @return yyyyMMddHHmmss
+     * @see [类、类#方法、类#成员]
+     */
+    public static String adjustHour(String time, int offset, String format) {
+        SimpleDateFormat formatter = new SimpleDateFormat(format);
+        String retTime = null;
+
+        try {
+            Date date = formatter.parse(time);
+            Date newDate = adjustHour(date, offset);
+            retTime = formatter.format(newDate);
+        }
+        catch (ParseException e) {
+            log.error("adjustHour fail!" + ExceptionUtils.getStackTrace(e));
+        }
+
+        return retTime;
+    }
+
+    /**
+     * $时间分钟偏移 <功能详细描述>
+     * 
+     * @param date 日期
+     * @param offset 偏移量
+     * @return yyyyMMddHHmmss
+     * @see [类、类#方法、类#成员]
+     */
+    public static Date adjustMinute(Date date, int offset) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        calendar.add(Calendar.MINUTE, offset);
+        Date newDate = calendar.getTime();
+        return newDate;
+    }
+
+    /**
+     * $时间分钟偏移 <功能详细描述>
+     * 
+     * @param time yyyyMMddHHmmss
+     * @param offset 偏移量
+     * @return yyyyMMddHHmmss
+     * @see [类、类#方法、类#成员]
+     */
+    public static String adjustMinute(String time, int offset) {
+        return adjustMinute(time, offset, DEFAULT_TIME_FORMAT);
+    }
+
+    /**
+     * $时间分钟偏移 <功能详细描述>
+     * 
+     * @param time 字符串日期
+     * @param offset 偏移量
+     * @return yyyyMMddHHmmss
+     * @see [类、类#方法、类#成员]
+     */
+    public static String adjustMinute(String time, int offset, String format) {
+        SimpleDateFormat formatter = new SimpleDateFormat(format);
+        String retTime = null;
+
+        try {
+            Date date = formatter.parse(time);
+            Date newDate = adjustMinute(date, offset);
+            retTime = formatter.format(newDate);
+        }
+        catch (ParseException e) {
+            log.error("adjustMinute fail!" + ExceptionUtils.getStackTrace(e));
+        }
+
+        return retTime;
+    }
+
+    /**
+     * $时间秒偏移 <功能详细描述>
+     * 
+     * @param date 字符串日期
+     * @param offset 偏移量
+     * @return yyyyMMddHHmmss
+     * @see [类、类#方法、类#成员]
+     */
+    public static Date adjustSecond(Date date, int offset) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        calendar.add(Calendar.SECOND, offset);
+        Date newDate = calendar.getTime();
+        return newDate;
+    }
+
+    /**
+     * $时间秒偏移 <功能详细描述>
+     * 
+     * @param time yyyyMMddHHmmss
+     * @param offset 偏移量
+     * @return yyyyMMddHHmmss
+     * @see [类、类#方法、类#成员]
+     */
+    public static String adjustSecond(String time, int offset) {
+        return adjustSecond(time, offset, DEFAULT_TIME_FORMAT);
+    }
+
+    /**
+     * $时间秒偏移 <功能详细描述>
+     * 
+     * @param time yyyyMMddHHmmss
+     * @param offset 偏移量
+     * @return yyyyMMddHHmmss
+     * @see [类、类#方法、类#成员]
+     */
+    public static String adjustSecond(String time, int offset, String format) {
+        SimpleDateFormat formatter = new SimpleDateFormat(format);
+        String retTime = null;
+
+        try {
+            Date date = formatter.parse(time);
+            Date newDate = adjustSecond(date, offset);
+            retTime = formatter.format(newDate);
+        }
+        catch (ParseException e) {
+            log.error("adjustSecond fail!" + ExceptionUtils.getStackTrace(e));
+        }
+
+        return retTime;
+    }
+
+    /**
+     * $获取两个间隔日期间的天数 <功能详细描述>
+     * 
+     * @param timeBefore yyyyMMdd格式
+     * @param timeAfter yyyyMMdd格式
+     * @return 天数
+     * @see [类、类#方法、类#成员]
+     */
+    public static int getDayBetween(String timeBefore, String timeAfter) {
+        SimpleDateFormat sd = new SimpleDateFormat("yyyyMMdd");
+        long num = 0;
+
+        try {
+            long diff = sd.parse(timeAfter).getTime() - sd.parse(timeBefore).getTime();
+            num = diff / (1000 * 24 * 60 * 60);
+        }
+        catch (ParseException e) {
+            log.error("getDayBetween fail!", e);
+        }
+
+        return (int) num;
+    }
+
+    /**
+     * $获取一个月最后一天
+     * 
+     * @param time yyyyMMdd格式
+     * @return 日期
+     * @see [类、类#方法、类#成员]
+     */
+    public static String getMaxDateOfMonth(String time, String format) {
+        SimpleDateFormat sd = new SimpleDateFormat(format);
+        Calendar cDay = Calendar.getInstance();
+
+        try {
+            Date date = sd.parse(time);
+            cDay.setTime(date);
+        }
+        catch (ParseException e) {
+            log.error("getMaxDateOfMonth fail!", e);
+        }
+
+        return String.valueOf(cDay.getActualMaximum(Calendar.DAY_OF_MONTH));
+    }
+
+    /**
+     * Date转String <br>
+     * 根据format格式转换时间为字符串
+     * 
+     * @param date 时刻
+     * @param format 转换模板
+     * @return 字符串日期
+     * @see [类、类#方法、类#成员]
+     */
+    public static String dateToString(Date date, String format) {
+        if (date == null) {
+            date = new Date();
+        }
+
+        SimpleDateFormat formatter = new SimpleDateFormat(format);
+        String retTime = formatter.format(date);
+
+        return retTime;
+    }
+
+    /**
+     * $格式化取时间
+     * 
+     * @param dateString yyyyMMddHHmmss时刻
+     * @param format 转换模板
+     * @return 字符串日期
+     * @see [类、类#方法、类#成员]
+     */
+    public static String formater(String dateString, String format) {
+        Date date = stringToDate(dateString);
+        SimpleDateFormat formatter = new SimpleDateFormat(format);
+        String retTime = formatter.format(date);
+
+        return retTime;
+    }
+
+    /**
+     * 格式化取时间
+     * @param dateString 字符串日期
+     * @param from 源格式
+     * @param to 目标格式
+     * @return String
+     */
+    public static String formater(String dateString, String from, String to) {
+        Date date = stringToDate(dateString, from);
+        SimpleDateFormat formatter = new SimpleDateFormat(to);
+        String retTime = formatter.format(date);
+
+        return retTime;
+    }
+
+    /**
+     * $时间转换 <功能详细描述>
+     * 
+     * @param dateKey 天
+     * @param timeKey  时间
+     * @param format 格式
+     * @return String
+     * @see [类、类#方法、类#成员]
+     */
+    public static String formater(int dateKey, int timeKey, String format) {
+        int year = dateKey / 10000;
+        int month = (dateKey / 100) % 100;
+        int day = dateKey % 100;
+        int hour = timeKey / 10000;
+        int min = (timeKey / 100) % 100;
+        int second = timeKey % 100;
+
+        GregorianCalendar calender = new GregorianCalendar(year, month - 1, day, hour, min, second);
+        return dateToString(calender.getTime(), format);
+    }
+
+    /**
+     * Date转String <br>
+     * 根据format格式转换时间为字符串
+     * 
+     * @param date 时刻
+     * @return 字符串日期
+     * @see [类、类#方法、类#成员]
+     */
+    public static String dateToString(Date date) {
+        return dateToString(date, COMMON_TIME_FORMAT);
+    }
+
+    /**
+     * String转Date <br>
+     * 根据format格式转换时间为字符串
+     * 
+     * @param dateString 时刻
+     * @return date
+     * @see [类、类#方法、类#成员]
+     */
+    public static Date stringToDate(String dateString) {
+        return stringToDate(dateString, DEFAULT_TIME_FORMAT);
+    }
+
+    /**
+     * String转Date
+     * @param dateString 字符串日期
+     * @param format 格式
+     * @return date
+     */
+    public static Date stringToDate(String dateString, String format) {
+        SimpleDateFormat sd = new SimpleDateFormat(format);
+        Date date = null;
+
+        try {
+            date = sd.parse(dateString);
+        }
+        catch (ParseException e) {
+            log.error("stringToDate fail!", e);
+        }
+
+        return date;
+    }
+
+    /**
+     * String转Calendar <br>
+     * 根据format格式转换时间为字符串
+     * 
+     * @param dateString 时刻
+     * @return Calendar
+     * @see [类、类#方法、类#成员]
+     */
+    public static Calendar stringToCalendar(String dateString) {
+        if ((dateString == null) || (dateString.length() < 14)) {
+            throw new IllegalArgumentException(dateString);
+        }
+
+        Date date = stringToDate(dateString);
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+
+        return calendar;
+    }
+
+    /**
+     * String转Calendar <br>
+     * 根据format格式转换时间为字符串
+     * 
+     * @param dateString 时间字符串
+     * @param format 格式
+     * @return Calendar
+     * @see [类、类#方法、类#成员]
+     */
+    public static Calendar stringToCalendar(String dateString, String format) {
+        Date date = stringToDate(dateString, format);
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        return calendar;
+    }
+
+    /**
+     * $获取当前时间 <功能详细描述>
+     * 
+     * @return String yyyyMMddHHmmss
+     * @see [类、类#方法、类#成员]
+     */
+    public static String getCurrentTime() {
+        return dateToString(new Date(), DEFAULT_TIME_FORMAT);
+    }
+
+    /**
+     * $获取两个时间之间的间隔(毫秒) <功能详细描述>
+     * 
+     * @param d1 日期1
+     * @param d2 日期2
+     * @return
+     * @see [类、类#方法、类#成员]
+     */
+    public static long getTimeBetween(Date d1, Date d2) {
+        return Math.abs(d2.getTime() - d1.getTime());
+    }
+
+    /**
+     * $获取星期几
+     * 
+     * @param date 输入日期
+     * @return 星期几
+     */
+    public static int getWeekOfDate(Date date) {
+        Calendar cd = Calendar.getInstance();
+        cd.setTime(date);
+        int wd = cd.get(Calendar.DAY_OF_WEEK);
+
+        if (wd == 1) {
+            return 7;
+        }
+        else {
+            return wd - 1;
+        }
+    }
+
+    /**
+     * $早高峰区间
+     */
+    private static final String[] MORING_PEAK_INTERVAL = new String[] {
+        "070000", "090000"
+    };
+
+    /**
+     * $晚高峰区间
+     */
+    private static final String[] EVENING_PEAK_INTERVAL = new String[] {
+        "170000", "190000"
+    };
+
+    /**
+     * $平峰区间
+     */
+    private static final String[] FLAT_PEAK_INTERVAL = new String[] {
+        "090000", "170000"
+    };
+
+    /**
+     * $判断是否早高峰 <07:00~09:00>
+     * 
+     * @param date 输入日期
+     * @return boolean
+     */
+    public static boolean checkMoringPeak(Date date) {
+        String time = StringUtils.substring(dateToString(date, DEFAULT_TIME_FORMAT), 8, 14);
+        return StringUtils.compare(time, MORING_PEAK_INTERVAL[0]) >= 0
+            && StringUtils.compare(time, MORING_PEAK_INTERVAL[1]) <= 0;
+    }
+
+    /**
+     * $判断是否晚高峰 <07:00~09:00>
+     * 
+     * @param date 输入日期
+     * @return boolean
+     */
+    public static boolean checkEveningPeak(Date date) {
+        String time = StringUtils.substring(dateToString(date, DEFAULT_TIME_FORMAT), 8, 14);
+        return StringUtils.compare(time, EVENING_PEAK_INTERVAL[0]) >= 0
+            && StringUtils.compare(time, EVENING_PEAK_INTERVAL[1]) <= 0;
+    }
+
+    /**
+     * $判断是否平峰 <09:00~17:00>
+     * 
+     * @param date 输入日期
+     * @return boolean
+     */
+    public static boolean checkFlatPeak(Date date) {
+        String time = StringUtils.substring(dateToString(date, DEFAULT_TIME_FORMAT), 8, 14);
+        return StringUtils.compare(time, FLAT_PEAK_INTERVAL[0]) >= 0
+            && StringUtils.compare(time, FLAT_PEAK_INTERVAL[1]) <= 0;
+    }
+
+    /**
+     * $判断是否工作日 <功能详细描述>
+     * 
+     * @param date 日期
+     * @return
+     * @see [类、类#方法、类#成员]
+     */
+    public static boolean checkWorkDay(Date date) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        int wd = calendar.get(Calendar.DAY_OF_WEEK) - 1;
+        return wd >= 1 && wd <= 5;
+    }
+
+    /**
+     * $判断是否非工作日 <功能详细描述>
+     * 
+     * @param date 日期
+     * @return
+     * @see [类、类#方法、类#成员]
+     */
+    public static boolean checkNoWorkDay(Date date) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        int wd = calendar.get(Calendar.DAY_OF_WEEK) - 1;
+        return wd == 6 || wd == 0;
+    }
+
+    public static Integer dateToStepIndex(String YmDHms, String tp) {
+        LocalDateTime localDateTime = LocalDateTime.parse(YmDHms, DateTimeFormatter.ofPattern(COMMON_TIME_FORMAT));
+        int hour = localDateTime.getHour();
+        int minute = localDateTime.getMinute();
+        int stepIndex = 0;
+
+        if (tp.endsWith("mi")) {
+            int interval = Integer.parseInt(tp.split("mi")[0]);
+            Double floor = Math.floor((hour * 60 + minute) / (double) interval);
+            stepIndex = floor.intValue();
+        }
+        else if (tp.endsWith("h")) {
+            stepIndex = hour;
+        }
+        return stepIndex;
+    }
+
+    /**
+     * 计算时间序列 - 当前时刻是当天第N个时间片
+     * @param period 时间片间隔
+     * @param timeStr 当前时间yyyy-MM-dd HH:mm:ss
+     * @return 时间序列
+     */
+    public static int buildColTimeIndex(long period, String timeStr) {
+        long dataTp = period / 60;
+        return dateToStepIndex(timeStr, dataTp + "mi");
+    }
+
+    public static String dateToUtcString(Date date){
+        SimpleDateFormat sdfutc = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'");
+        sdfutc.setTimeZone(TimeZone.getTimeZone("UTC"));
+        String format = sdfutc.format(date);
+        return format;
+    }
+
+    public static Date stringUtcToDate(String date) {
+        SimpleDateFormat sdfutc = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
+        sdfutc.setTimeZone(TimeZone.getTimeZone("UTC"));
+        Date parse = null;
+        try {
+            parse = sdfutc.parse(date);
+        } catch (ParseException e) {
+            log.error("mongoDbUtcToBjDate fail!" + ExceptionUtils.getStackTrace(e));
+        }
+
+        return parse;
+    }
+
+    public static Date currentDateZeroHours(Date date){
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        Date parse = null;
+        try {
+            parse = simpleDateFormat.parse(simpleDateFormat.format(date));
+        } catch (ParseException e) {
+            log.error("currentDateZeroHours fail!" + ExceptionUtils.getStackTrace(e));
+        }
+        return parse;
+    }
+
+    public static Integer secondDifferenceCount(Date start,Date end,Integer frequency){
+        Long count = (end.getTime()-start.getTime())/frequency;
+        return count.intValue();
+    }
+}

+ 184 - 0
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/util/exception/Assert.java

@@ -0,0 +1,184 @@
+/*
+ * 文 件 名:  Assert
+ * 版    权:  浩鲸云计算科技股份有限公司
+ * 描    述:  <描述>
+ * 修 改 人:  lv.wenbin@iwhalecloud.com
+ * 修改时间:  2019/4/21
+ */
+package com.ruoyi.ems.util.exception;
+
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ * 断言 <功能详细描述>
+ *
+ * @author lv.wenbin@iwhalecloud.com
+ * @version [版本号, 2019/4/21]
+ * @see [相关类/方法]
+ * @since [产品/模块版本]
+ */
+public abstract class Assert {
+    /**
+     * 真假断言 <功能详细描述>
+     *
+     * @param expression 真假
+     * @param errorCode  错误码
+     * @param message    错误消息
+     * @throws BusinessException 异常
+     * @see [类、类#方法、类#成员]
+     */
+    public static void isTrue(boolean expression, int errorCode, String message) throws BusinessException {
+        if (!expression) {
+            throw new BusinessException(errorCode, message);
+        }
+    }
+
+    /**
+     * 真假断言 <功能详细描述>
+     *
+     * @param expression 真假
+     * @param errorCode  错误码
+     * @throws BusinessException 异常
+     * @see [类、类#方法、类#成员]
+     */
+    public static void isTrue(boolean expression, ErrorCode errorCode) throws BusinessException {
+        if (!expression) {
+            throw new BusinessException(errorCode.getCode(), errorCode.getMessage());
+        }
+    }
+
+    /**
+     * 真假断言 <功能详细描述>
+     *
+     * @param expression 真假
+     * @param errorCode  错误码
+     * @param message    错误消息
+     * @param ext        扩展属性
+     * @throws BusinessException 异常
+     * @see [类、类#方法、类#成员]
+     */
+    public static void isTrue(boolean expression, int errorCode, String message, Object ext) throws BusinessException {
+        if (!expression) {
+            throw new BusinessException(errorCode, message, ext);
+        }
+    }
+
+    /**
+     * 空判断 <功能详细描述>
+     *
+     * @param object    对象
+     * @param errorCode 错误码
+     * @param message   错误消息
+     * @throws BusinessException 异常
+     * @see [类、类#方法、类#成员]
+     */
+    public static void isNull(Object object, int errorCode, String message) throws BusinessException {
+        if (object != null) {
+            throw new BusinessException(errorCode, message);
+        }
+    }
+
+    /**
+     * 空判断 <功能详细描述>
+     *
+     * @param object    对象
+     * @param errorCode 错误
+     * @throws BusinessException 异常
+     * @see [类、类#方法、类#成员]
+     */
+    public static void isNull(Object object, ErrorCode errorCode) throws BusinessException {
+        if (object != null) {
+            throw new BusinessException(errorCode.getCode(), errorCode.getMessage());
+        }
+    }
+
+    /**
+     * 非空判断 <功能详细描述>
+     *
+     * @param object    对象
+     * @param errorCode 错误码
+     * @param message   错误消息
+     * @throws BusinessException 异常
+     * @see [类、类#方法、类#成员]
+     */
+    public static void notNull(Object object, int errorCode, String message) throws BusinessException {
+        if (object == null) {
+            throw new BusinessException(errorCode, message);
+        }
+    }
+
+    /**
+     * 非空判断 <功能详细描述>
+     *
+     * @param object    对象
+     * @param errorCode 错误
+     * @throws BusinessException 异常
+     * @see [类、类#方法、类#成员]
+     */
+    public static void notNull(Object object, ErrorCode errorCode) throws BusinessException {
+        if (object == null) {
+            throw new BusinessException(errorCode.getCode(), errorCode.getMessage());
+        }
+    }
+
+    /**
+     * 数组非空判断 <功能详细描述>
+     *
+     * @param array     数组
+     * @param errorCode 错误码
+     * @param message   错误消息
+     * @throws BusinessException 异常
+     * @see [类、类#方法、类#成员]
+     */
+    public static void notEmpty(Object[] array, int errorCode, String message) throws BusinessException {
+        if (array == null || array.length == 0) {
+            throw new BusinessException(errorCode, message);
+        }
+    }
+
+    /**
+     * 集合非空判断 <功能详细描述>
+     *
+     * @param collection 集合列表
+     * @param errorCode  错误码
+     * @param message    错误信息
+     * @throws BusinessException 异常
+     * @see [类、类#方法、类#成员]
+     */
+    public static <T> void notEmpty(Collection<T> collection, int errorCode, String message) throws BusinessException {
+        if (collection == null || collection.isEmpty()) {
+            throw new BusinessException(errorCode, message);
+        }
+    }
+
+    /**
+     * Map非空判断
+     *
+     * @param map       Map Map集合
+     * @param errorCode 错误码
+     * @param message   错误信息
+     * @throws BusinessException 异常
+     * @see [类、类#方法、类#成员]
+     */
+    public static <K, V> void notEmpty(Map<K, V> map, int errorCode, String message) throws BusinessException {
+        if (map == null || map.isEmpty()) {
+            throw new BusinessException(errorCode, message);
+        }
+    }
+
+    /**
+     * 字符串空判断 <功能详细描述>
+     *
+     * @param str       字符串
+     * @param errorCode 错误码
+     * @param message   错误信息
+     * @throws BusinessException 异常
+     * @see [类、类#方法、类#成员]
+     */
+    public static void notEmpty(String str, int errorCode, String message) throws BusinessException {
+        if (str == null || str.length() == 0) {
+            throw new BusinessException(errorCode, message);
+        }
+    }
+}

+ 59 - 0
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/util/exception/BusinessException.java

@@ -0,0 +1,59 @@
+package com.ruoyi.ems.util.exception;
+
+/**
+ * 业务异常
+ *
+ * @author ruoyi
+ */
+public class BusinessException extends RuntimeException {
+    /**
+     * 错误码
+     */
+    protected int code;
+
+    protected final String message;
+
+    /**
+     * 扩展属性
+     */
+    private Object ext;
+
+    public BusinessException(String message) {
+        this.message = message;
+    }
+
+    public BusinessException(int code, String message) {
+        this.code = code;
+        this.message = message;
+    }
+
+    public BusinessException(String message, Throwable e) {
+        super(message, e);
+        this.message = message;
+    }
+
+    public BusinessException(int code, String message, Throwable e) {
+        super(message, e);
+        this.code = code;
+        this.message = message;
+    }
+
+    public BusinessException(int code, String message, Object ext) {
+        this.code = code;
+        this.message = message;
+        this.ext = ext;
+    }
+
+    @Override
+    public String getMessage() {
+        return message;
+    }
+
+    public int getCode() {
+        return code;
+    }
+
+    public Object getExt() {
+        return ext;
+    }
+}

+ 74 - 0
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/util/exception/ErrorCode.java

@@ -0,0 +1,74 @@
+/*
+ * 文 件 名:  BusinessError
+ * 版    权:  浩鲸云科技股份有限公司
+ * 描    述:  <描述>
+ * 修 改 人:  lv.wenbin@iwhalecloud.com
+ * 修改时间:  2018/12/10
+ */
+package com.ruoyi.ems.util.exception;
+
+/**
+ * 异常枚举 <功能详细描述>
+ *
+ * @author lv.wenbin@iwhalecloud.com
+ * @version [版本号, 2018/12/10]
+ * @see [相关类/方法]
+ * @since [产品/模块版本]
+ */
+public enum ErrorCode {
+    /**
+     * 成功
+     */
+    SUCCESS(0, "成功."),
+
+    /**
+     * 未知错误
+     */
+    UNKNOWN_ERROR(-1, "未知错误."),
+
+    /**
+     * 参数错误
+     */
+    PARAM_ERROR(1001, "参数错误."),
+
+    /**
+     * 参数错误
+     */
+    DB_ERROR(3001, "数据库异常."),
+
+    /**
+     * 服务不可用
+     */
+    SERVICE_UNAVAILABLE(9001, "服务不可用.");
+
+    /**
+     * 错误码分段: <br/>
+     * 0000 :业务正常 <br/>
+     * -001 :未知异常 <br/>
+     * 1xxx : 参数异常 <br/>
+     * 2xxx : 框架异常 <br/>
+     * 3xxx : DB异常 <br/>
+     * 4xxx : MQ异常 <br/>
+     * 5xxx : xx <br/>
+     * 6xxx : xx <br/>
+     * 7xxx : xx <br/>
+     * 8xxx : xx <br/>
+     * 9xxxxx : 业务异常
+     */
+    private int code;
+
+    private String message;
+
+    private ErrorCode(int code, String message) {
+        this.code = code;
+        this.message = message;
+    }
+
+    public int getCode() {
+        return code;
+    }
+
+    public String getMessage() {
+        return message;
+    }
+}

+ 9 - 6
ems-cloud/ems-modules/ems-server/src/main/resources/application-demo.yml

@@ -1,5 +1,8 @@
 # spring配置
 spring:
+  mvc:
+    pathmatch:
+      matching-strategy: ant_path_matcher
   redis:
     host: 172.10.0.18
     port: 6379
@@ -43,12 +46,12 @@ spring:
 # mybatis配置
 mybatis:
   # 搜索指定包别名
-  typeAliasesPackage: com.ruoyi.system
+  typeAliasesPackage: com.ruoyi.ems.**.domain;com.ruoyi.quartz.**.domain
   # 配置mapper的扫描,找到所有的mapper.xml映射文件
-  mapperLocations: classpath:mapper/**/*.xml
-
+  mapperLocations: classpath*:mapper/**/*.xml
+  configuration:
+    map-underscore-to-camel-case: true
 # swagger配置
 swagger:
-  title: 系统模块接口文档
-  license: Powered By ruoyi
-  licenseUrl: https://ruoyi.vip
+  title: 能源模块接口文档
+  enabled: true

+ 5 - 0
ems-cloud/ems-modules/ems-server/src/main/resources/mapper/ems/MeterDeviceMapper.xml

@@ -44,6 +44,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <include refid="selectMeterDeviceVo"/>
         where id = #{id}
     </select>
+
+    <select id="selectMeterDeviceByCode"  resultMap="meterDeviceResult">
+        <include refid="selectMeterDeviceVo"/>
+        where area_code = #{areaCode} and device_code = #{deviceCode}
+    </select>
         
     <insert id="insertMeterDevice" parameterType="com.ruoyi.ems.domain.MeterDevice" useGeneratedKeys="true" keyProperty="id">
         insert into adm_meter_device

+ 6 - 0
ems-cloud/ems-modules/ems-server/src/main/resources/mapper/ems/MeterReadingManualMapper.xml

@@ -24,6 +24,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         select id, device_code, area_code, `year`, meter_month, last_reading, last_time, meter_reading, meter_time, increase, create_time, update_time from adm_meter_reading_manual
     </sql>
 
+    <select id="selectById"  parameterType="Long" resultMap="MeterReadingManualResult">
+        <include refid="selectMeterReadingManualVo"/>
+        where id = #{id}
+    </select>
+
     <select id="selectLastItem"  resultMap="MeterReadingManualResult">
         <include refid="selectMeterReadingManualVo"/>
         where area_code = #{areaCode} and device_code = #{deviceCode}
@@ -40,6 +45,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="startMonth != null  and startMonth != ''"> and meter_month &gt;= #{startMonth}</if>
             <if test="endMonth != null  and endMonth != ''"> and meter_month &lt;= #{endMonth}</if>
         </where>
+        ORDER BY meter_month ${orderFlag}
     </select>
 
     <insert id="insert" parameterType="com.ruoyi.ems.domain.MeterReadingManual" useGeneratedKeys="true" keyProperty="id">

+ 8 - 8
ems-cloud/sql/ems_init_data.sql

@@ -244,11 +244,11 @@ INSERT INTO adm_co_charging_config (`area_code`, `elec_unit_price`, `elec_gt_com
 INSERT INTO adm_co_charging_config (`area_code`, `elec_unit_price`, `elec_gt_compute_type`, `elec_compute_desc`, `water_unit_price`, `water_gt_compute_type`, `water_compute_desc`) VALUES ('321283124S3002', 0.6068, 1, '1.按户数均摊\n公摊电费每户收费 = 公摊电费 / 户数\n2、按面积分摊\n单户公摊电费 = 公摊电费 * (单户面积 / 总面积)', 3.04, 0, NULL);
 
 -- 抄表demo数据
-INSERT INTO adm_meter_reading_manual (`device_code`, `area_code`, `year`, `meter_month`, `last_reading`, `last_time`, `meter_reading`, `meter_time`, `increase`, `create_time`, `update_time`) VALUES ('J-D-B-102', '321283124S3001', 2024, '202401', 0, '2024-02-29', 100, '2024-01-31', 100, NULL, NULL);
-INSERT INTO adm_meter_reading_manual (`device_code`, `area_code`, `year`, `meter_month`, `last_reading`, `last_time`, `meter_reading`, `meter_time`, `increase`, `create_time`, `update_time`) VALUES ('J-D-B-102', '321283124S3001', 2024, '202402', 100, '2024-02-29', 200, '2024-02-28', 100, NULL, NULL);
-INSERT INTO adm_meter_reading_manual (`device_code`, `area_code`, `year`, `meter_month`, `last_reading`, `last_time`, `meter_reading`, `meter_time`, `increase`, `create_time`, `update_time`) VALUES ('J-D-B-102', '321283124S3001', 2024, '202403', 200, '2024-02-29', 300, '2024-03-31', 100, NULL, NULL);
-INSERT INTO adm_meter_reading_manual (`device_code`, `area_code`, `year`, `meter_month`, `last_reading`, `last_time`, `meter_reading`, `meter_time`, `increase`, `create_time`, `update_time`) VALUES ('J-D-B-102', '321283124S3001', 2024, '202404', 300, '2024-03-31', 400, '2024-04-30', 100, NULL, NULL);
-INSERT INTO adm_meter_reading_manual (`device_code`, `area_code`, `year`, `meter_month`, `last_reading`, `last_time`, `meter_reading`, `meter_time`, `increase`, `create_time`, `update_time`) VALUES ('J-D-B-102', '321283124S3001', 2024, '202405', 400, '2024-04-30', 500, '2024-05-31', 100, NULL, NULL);
-INSERT INTO adm_meter_reading_manual (`device_code`, `area_code`, `year`, `meter_month`, `last_reading`, `last_time`, `meter_reading`, `meter_time`, `increase`, `create_time`, `update_time`) VALUES ('J-D-B-102', '321283124S3001', 2024, '202406', 500, '2024-05-31', 600, '2024-06-30', 100, NULL, NULL);
-INSERT INTO adm_meter_reading_manual (`device_code`, `area_code`, `year`, `meter_month`, `last_reading`, `last_time`, `meter_reading`, `meter_time`, `increase`, `create_time`, `update_time`) VALUES ('J-D-B-102', '321283124S3001', 2024, '202407', 600, '2024-06-30', 700, '2024-07-31', 100, NULL, NULL);
-INSERT INTO adm_meter_reading_manual (`device_code`, `area_code`, `year`, `meter_month`, `last_reading`, `last_time`, `meter_reading`, `meter_time`, `increase`, `create_time`, `update_time`) VALUES ('J-D-B-102', '321283124S3001', 2024, '202408', 700, '2024-07-31', 800, '2024-08-31', 100, NULL, NULL);
+INSERT INTO adm_meter_reading_manual (`device_code`, `area_code`, `year`, `meter_month`, `last_reading`, `last_time`, `meter_reading`, `meter_time`, `increase`, `create_time`, `update_time`) VALUES ('J-D-B-102', '321283124S3001', '2024', '202401', 0, '2024-02-29', 100, '2024-01-31', 100, NULL, NULL);
+INSERT INTO adm_meter_reading_manual (`device_code`, `area_code`, `year`, `meter_month`, `last_reading`, `last_time`, `meter_reading`, `meter_time`, `increase`, `create_time`, `update_time`) VALUES ('J-D-B-102', '321283124S3001', '2024', '202402', 100, '2024-02-29', 200, '2024-02-28', 100, NULL, NULL);
+INSERT INTO adm_meter_reading_manual (`device_code`, `area_code`, `year`, `meter_month`, `last_reading`, `last_time`, `meter_reading`, `meter_time`, `increase`, `create_time`, `update_time`) VALUES ('J-D-B-102', '321283124S3001', '2024', '202403', 200, '2024-02-29', 300, '2024-03-31', 100, NULL, NULL);
+INSERT INTO adm_meter_reading_manual (`device_code`, `area_code`, `year`, `meter_month`, `last_reading`, `last_time`, `meter_reading`, `meter_time`, `increase`, `create_time`, `update_time`) VALUES ('J-D-B-102', '321283124S3001', '2024', '202404', 300, '2024-03-31', 400, '2024-04-30', 100, NULL, NULL);
+INSERT INTO adm_meter_reading_manual (`device_code`, `area_code`, `year`, `meter_month`, `last_reading`, `last_time`, `meter_reading`, `meter_time`, `increase`, `create_time`, `update_time`) VALUES ('J-D-B-102', '321283124S3001', '2024', '202405', 400, '2024-04-30', 500, '2024-05-31', 100, NULL, NULL);
+INSERT INTO adm_meter_reading_manual (`device_code`, `area_code`, `year`, `meter_month`, `last_reading`, `last_time`, `meter_reading`, `meter_time`, `increase`, `create_time`, `update_time`) VALUES ('J-D-B-102', '321283124S3001', '2024', '202406', 500, '2024-05-31', 600, '2024-06-30', 100, NULL, NULL);
+INSERT INTO adm_meter_reading_manual (`device_code`, `area_code`, `year`, `meter_month`, `last_reading`, `last_time`, `meter_reading`, `meter_time`, `increase`, `create_time`, `update_time`) VALUES ('J-D-B-102', '321283124S3001', '2024', '202407', 600, '2024-06-30', 700, '2024-07-31', 100, NULL, NULL);
+INSERT INTO adm_meter_reading_manual (`device_code`, `area_code`, `year`, `meter_month`, `last_reading`, `last_time`, `meter_reading`, `meter_time`, `increase`, `create_time`, `update_time`) VALUES ('J-D-B-102', '321283124S3001', '2024', '202408', 700, '2024-07-31', 800, '2024-08-31', 100, NULL, NULL);

+ 1 - 1
ems-cloud/sql/ems_server.sql

@@ -827,7 +827,7 @@ create table adm_meter_reading_manual (
   `id`               bigint(20)      not null auto_increment      comment '序号',
   `device_code`      varchar(16)     not null                     comment '计量设备code',
   `area_code`        varchar(16)     not null                     comment '服务区代码',
-  `year`             year            not null                     comment '年份yyyy',
+  `year`             varchar(4)      not null                     comment '年份yyyy',
   `meter_month`      varchar(6)      not null                     comment '计量月yyyyMM',
   `last_reading`     int             default null                 comment '上次示数',
   `last_time`        date            default null                 comment '上次抄表日期',

+ 17 - 15
ems-cloud/sql/ems_sys.sql

@@ -193,9 +193,9 @@ insert into sys_menu values ('142',  '设备台账',       '5',    '2',  'device
 insert into sys_menu values ('143',  '设备告警',       '5',    '3',  'analysis-warn',       'analysis/device/warn',   '', 1, 0, 'C', '0', '0',   'analysis:device',        'deviceanalyze',  'admin', sysdate(), '', null, '设备分析');
 insert into sys_menu values ('144',  '手动抄表',       '5',    '4',  'meterRead-manual',    'devmgr/meterRead',       '', 1, 0, 'C', '0', '0',   'ems:meterReading:list',  'meterReading',   'admin', sysdate(), '', null, '手动抄表');
 
-INSERT INTO sys_menu VALUES (151, '告警策略', 6, 1, 'warn-strategy', 'alarm/index', '', 1, 0, 'C', '0', '0', 'warn:strategy', 'warnstrategy', 'admin', '2024-08-29 15:40:27', 'admin', '2024-08-29 16:01:10', '告警策略');
-INSERT INTO sys_menu VALUES (152, '告警列表', 6, 2, 'warn-list', 'alarm/alarm-info/index', '', 1, 0, 'C', '0', '0', 'warn:list', 'warnmsg', 'admin', '2024-08-29 15:40:27', 'admin', '2024-08-29 16:01:36', '告警策略');
-INSERT INTO sys_menu VALUES (153, '巡检任务', 6, 3, 'oper-task', 'task/index', '', 1, 0, 'C', '0', '0', 'oper-mgr:task', 'task', 'admin', '2024-08-29 15:40:27', 'admin', '2024-08-29 16:02:38', '巡检任务');
+INSERT INTO sys_menu VALUES ('151',  '告警策略',       '6',    '1',  'warn-strategy',       'alarm/index',            '', 1, 0, 'C', '0', '0',    'warn:strategy', 'warnstrategy', 'admin', '2024-08-29 15:40:27', 'admin', '2024-08-29 16:01:10', '告警策略');
+INSERT INTO sys_menu VALUES ('152',  '告警列表',       '6',    '2',  'warn-list',           'alarm/alarm-info/index', '', 1, 0, 'C', '0', '0',    'warn:list', 'warnmsg', 'admin', '2024-08-29 15:40:27', 'admin', '2024-08-29 16:01:36', '告警策略');
+INSERT INTO sys_menu VALUES ('153',  '巡检任务',       '6',    '3',  'oper-task',           'task/index',             '', 1, 0, 'C', '0', '0',    'oper-mgr:task', 'task', 'admin', '2024-08-29 15:40:27', 'admin', '2024-08-29 16:02:38', '巡检任务');
 insert into sys_menu values ('154',  '巡检报告',       '6',    '4',  'oper-report',        'task/report/index',        '', 1, 0, 'C', '0', '0',   'oper-mgr:report',        'note',           'admin', sysdate(), '', null, '巡检报告');
 
 insert into sys_menu values ('161',  '建筑区块',       '7',    '1',  'buildingcfg',        '',                       '', 1, 0, 'M', '0', '0',   'basecfg:building',       'building',       'admin', sysdate(), '', null, '用户管理菜单');
@@ -216,18 +216,20 @@ insert into sys_menu values ('179',  '在线用户',       '8',   '10', 'online'
 INSERT INTO sys_menu VALUES ('180',  '任务调度',       '8',   '10', 'task/job',           'monitor/job/index',      '', 1, 0, 'C', '0', '0',   'monitor:job',            'date-range',     'admin', sysdate(), '', NULL, '任务调度');
 
 
-insert into sys_menu values ('190',  '光伏',          '9',   '1',  'adapter-pv',         'adapter/pv/index',      '', 1, 0, 'C', '0', '0',   'adapter:user:list',       'photovoltaic',        'admin', sysdate(), '', null, '光伏');
-insert into sys_menu values ('191',  '光储直柔',       '9',   '2',  'adapter-gczr',       'adapter/gczr/index',    '', 1, 0, 'C', '0', '0',   'adapter:role:list',       'deviceaccess',      'admin', sysdate(), '', null, '光储直柔');
-insert into sys_menu values ('192',  '光储充',         '9',   '3',  'adapter-gcc',        'adapter/gcc/index',     '', 1, 0, 'C', '0', '0',   'adapter:menu:list',       'energyconsume',       'admin', sysdate(), '', null, '光储充');
-insert into sys_menu values ('193',  '充电桩',         '9',   '4',  'adapter-cdz',        'adapter/cdz/index',     '', 1, 0, 'C', '0', '0',   'adapter:dept:list',       'powerstore',       'admin', sysdate(), '', null, '充电桩');
-insert into sys_menu values ('194',  '智慧照明',       '9',   '5',  'adapter-zm',         'adapter/zm/index',      '', 1, 0, 'C', '0', '0',   'adapter:post:list',       'system',        'admin', sysdate(), '', null, '智慧照明');
-insert into sys_menu values ('195',  '智慧海绵',       '9',   '6',  'adapter-hm',         'adapter/hm/index',      '', 1, 0, 'C', '0', '0',   'adapter:dict:list',       'system',        'admin', sysdate(), '', null, '智慧海绵');
-insert into sys_menu values ('196',  '垃圾厨余',       '9',   '7',  'adapter-ljcy',       'adapter/ljcy/index',    '', 1, 0, 'C', '0', '0',   'adapter:config:list',     'system',      'admin', sysdate(), '', null, '垃圾厨余');
-insert into sys_menu values ('197',  '能耗监测',       '9',   '8',  'adapter-nhjc',       'adapter/nhjc/index',    '', 1, 0, 'C', '0', '0',   'adapter:notice:list',     'system',      'admin', sysdate(), '', null, '能耗监测');
-insert into sys_menu values ('198',  '设备管理',       '9',   '9',  'adapter-devc',       'adapter/devc/index',    '', 1, 0, 'M', '0', '0',   'adapter:devc:list',       'system',      'admin', sysdate(), '', null, '设备管理');
-
-insert into sys_menu values ('998',  '表单构建',       '99',   '1',  'build',              'tool/build/index',       '', 1, 0, 'C', '0', '0',   'tool:build:list',        'build',          'admin', sysdate(), '', null, '表单构建菜单');
-insert into sys_menu values ('999',  '代码生成',       '99',   '2',  'gen',                'tool/gen/index',         '', 1, 0, 'C', '0', '0',   'tool:gen:list',          'code',           'admin', sysdate(), '', null, '代码生成菜单');
+insert into sys_menu values ('190',  '系统信息',       '9',   '1',  'adapter-subsystem',  'adapter/subsystem/index',  '', 1, 0, 'C', '0', '0',   'adapter:subsystem:list',  'note',           'admin', sysdate(), '', null, '光伏');
+insert into sys_menu values ('191',  '光伏',          '9',   '2',  'adapter-pv',         'adapter/pv/index',      '', 1, 0, 'C', '0', '0',   'adapter:user:list',       'photovoltaic',        'admin', sysdate(), '', null, '光伏');
+insert into sys_menu values ('192',  '光储直柔',       '9',   '3',  'adapter-gczr',       'adapter/gczr/index',    '', 1, 0, 'C', '0', '0',   'adapter:role:list',       'deviceaccess',      'admin', sysdate(), '', null, '光储直柔');
+insert into sys_menu values ('193',  '光储充',         '9',   '4',  'adapter-gcc',        'adapter/gcc/index',     '', 1, 0, 'C', '0', '0',   'adapter:menu:list',       'energyconsume',       'admin', sysdate(), '', null, '光储充');
+insert into sys_menu values ('194',  '充电桩',         '9',   '5',  'adapter-cdz',        'adapter/cdz/index',     '', 1, 0, 'C', '0', '0',   'adapter:dept:list',       'powerstore',       'admin', sysdate(), '', null, '充电桩');
+insert into sys_menu values ('195',  '智慧照明',       '9',   '6',  'adapter-zm',         'adapter/zm/index',      '', 1, 0, 'C', '0', '0',   'adapter:post:list',       'system',        'admin', sysdate(), '', null, '智慧照明');
+insert into sys_menu values ('196',  '智慧海绵',       '9',   '7',  'adapter-hm',         'adapter/hm/index',      '', 1, 0, 'C', '0', '0',   'adapter:dict:list',       'system',        'admin', sysdate(), '', null, '智慧海绵');
+insert into sys_menu values ('197',  '垃圾厨余',       '9',   '8',  'adapter-ljcy',       'adapter/ljcy/index',    '', 1, 0, 'C', '0', '0',   'adapter:config:list',     'system',      'admin', sysdate(), '', null, '垃圾厨余');
+insert into sys_menu values ('198',  '能耗监测',       '9',   '9',  'adapter-nhjc',       'adapter/nhjc/index',    '', 1, 0, 'C', '0', '0',   'adapter:notice:list',     'system',      'admin', sysdate(), '', null, '能耗监测');
+insert into sys_menu values ('199',  '设备管理',       '9',   '10',  'adapter-devc',       'adapter/devc/index',    '', 1, 0, 'M', '0', '0',   'adapter:devc:list',       'system',      'admin', sysdate(), '', null, '设备管理');
+
+insert into sys_menu values ('997',  '表单构建',       '99',   '1',  'build',              'tool/build/index',       '', 1, 0, 'C', '0', '0',   'tool:build:list',        'build',          'admin', sysdate(), '', null, '表单构建菜单');
+insert into sys_menu values ('998',  '代码生成',       '99',   '2',  'gen',                'tool/gen/index',         '', 1, 0, 'C', '0', '0',   'tool:gen:list',          'code',           'admin', sysdate(), '', null, '代码生成菜单');
+insert into sys_menu values ('999',  '系统接口',       '99',   '3',  'http://localhost:9100/swagger-ui/index.html',   '', '', 0, 0, 'C', '0', '0', 'tool:swagger:list',   'swagger',        'admin', sysdate(), '', null, '系统接口菜单');
 
 -- 三级菜单
 -- 预测菜单