|
@@ -115,7 +115,7 @@ public class MeterReadRecordDao extends BaseDao<MeterReadRecord, String> impleme
|
|
|
* @param lastCost:
|
|
|
* @return long
|
|
|
**/
|
|
|
- public long updateReadData(long id, int readDate, BigDecimal readData, BigDecimal lastCost){
|
|
|
+ public long updateReadData(long id, long deviceId, int readDate, BigDecimal readData, BigDecimal lastCost){
|
|
|
Query query = new Query();
|
|
|
query.addCriteria(Criteria.where("id").is(id));
|
|
|
query.addCriteria(Criteria.where("data.readDate").is(readDate));
|
|
@@ -127,15 +127,22 @@ public class MeterReadRecordDao extends BaseDao<MeterReadRecord, String> impleme
|
|
|
update.set("data.$.createBy", UserUtil.getCurrentUser().getUsername());
|
|
|
long total = upsert(query,update).getModifiedCount();
|
|
|
if (total > 0 ) {
|
|
|
- Device device = deviceMapper.findById(id);
|
|
|
+ Device device = deviceMapper.findById(deviceId);
|
|
|
if (device != null) {
|
|
|
LocalDateTime localDateTime = device.getLastReceiveTime();
|
|
|
- int monthLength = (localDateTime.getMonthValue() + "").length();
|
|
|
- String monthValue = monthLength == 1 ? "0" + localDateTime.getMonthValue() : localDateTime.getMonthValue() + "";
|
|
|
- int eqDate = Integer.parseInt(localDateTime.getYear() + "" + monthValue + "" + localDateTime.getDayOfMonth());
|
|
|
+ if (localDateTime == null) {
|
|
|
+ Device deviceUpdate = new Device();
|
|
|
+ deviceUpdate.setId(deviceId);
|
|
|
+ deviceUpdate.setReadData(readData.toPlainString());
|
|
|
+ deviceMapper.updateByDeviceData(deviceUpdate);
|
|
|
+ return total;
|
|
|
+ }
|
|
|
+ String month = (localDateTime.getMonthValue() +"").length() == 1 ? "0" + localDateTime.getMonthValue() : localDateTime.getMonthValue() +"";
|
|
|
+ String days = (localDateTime.getDayOfMonth() +"").length() == 1 ? "0" + localDateTime.getDayOfMonth() : localDateTime.getDayOfMonth() +"";
|
|
|
+ int eqDate = Integer.parseInt(localDateTime.getYear() + "" + month + "" + days);
|
|
|
if (readDate >= eqDate) {
|
|
|
Device deviceUpdate = new Device();
|
|
|
- deviceUpdate.setId(id);
|
|
|
+ deviceUpdate.setId(deviceId);
|
|
|
deviceUpdate.setReadData(readData.toPlainString());
|
|
|
deviceMapper.updateByDeviceData(deviceUpdate);
|
|
|
}
|