瀏覽代碼

手动抄表接口提交

lv.wenbin 11 月之前
父節點
當前提交
3399376d59
共有 15 個文件被更改,包括 1247 次插入29 次删除
  1. 58 6
      ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/controller/MeterReadingManualController.java
  2. 5 3
      ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/domain/MeterReadingManual.java
  3. 11 0
      ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/mapper/MeterDeviceMapper.java
  4. 8 0
      ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/mapper/MeterReadingManualMapper.java
  5. 21 14
      ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/service/IMeterDeviceService.java
  6. 2 0
      ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/service/IMeterReadingManualService.java
  7. 7 0
      ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/service/impl/MeterDeviceServiceImpl.java
  8. 5 0
      ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/service/impl/MeterReadingManualServiceImpl.java
  9. 794 0
      ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/util/DateUtils.java
  10. 184 0
      ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/util/exception/Assert.java
  11. 59 0
      ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/util/exception/BusinessException.java
  12. 74 0
      ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/util/exception/ErrorCode.java
  13. 9 6
      ems-cloud/ems-modules/ems-server/src/main/resources/application-demo.yml
  14. 5 0
      ems-cloud/ems-modules/ems-server/src/main/resources/mapper/ems/MeterDeviceMapper.xml
  15. 5 0
      ems-cloud/ems-modules/ems-server/src/main/resources/mapper/ems/MeterReadingManualMapper.xml

+ 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);
+        }
+        catch (BusinessException e) {
+            return error(e.getMessage());
+        }
+
+        return toAjax(meterReadingManualService.update(meterRec));
     }
 
     /**
@@ -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(Year.now());
+            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(Year.now());
+            meterRec.setMeterMonth(DateUtils.dateToString(date, "yyyyMM"));
+            meterRec.setMeterTime(date);
+            meterRec.setIncrease(meterRec.getMeterReading() * meterDevice.getMagnification());
+        }
+    }
 }

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

@@ -1,5 +1,6 @@
 package com.ruoyi.ems.domain;
 
+import java.time.Year;
 import java.util.Date;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import org.apache.commons.lang3.builder.ToStringBuilder;
@@ -29,8 +30,9 @@ public class MeterReadingManual extends BaseEntity
     private String areaCode;
 
     /** 年份yyyy */
+    @JsonFormat(pattern = "yyyy")
     @Excel(name = "年份yyyy")
-    private String year;
+    private Year year;
 
     /** 计量月yyyyMM */
     @Excel(name = "计量月yyyyMM")
@@ -85,12 +87,12 @@ public class MeterReadingManual extends BaseEntity
     {
         return areaCode;
     }
-    public void setYear(String year) 
+    public void setYear(Year year)
     {
         this.year = year;
     }
 
-    public String getYear() 
+    public Year getYear()
     {
         return year;
     }

+ 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

+ 5 - 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}