|
@@ -128,30 +128,37 @@ 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(deviceId);
|
|
|
- if (device != null) {
|
|
|
- LocalDateTime localDateTime = device.getLastReceiveTime();
|
|
|
- if (localDateTime == null) {
|
|
|
- Device deviceUpdate = new Device();
|
|
|
- deviceUpdate.setId(deviceId);
|
|
|
- deviceUpdate.setReadData(readData.toPlainString());
|
|
|
- deviceMapper.updateByPrimaryKeySelective(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(deviceId);
|
|
|
- deviceUpdate.setReadData(readData.toPlainString());
|
|
|
- deviceMapper.updateByPrimaryKeySelective(deviceUpdate);
|
|
|
- }
|
|
|
- }
|
|
|
+ updateDeviceReadData(deviceId, readDate, readData);
|
|
|
}
|
|
|
return total;
|
|
|
}
|
|
|
|
|
|
+ private void updateDeviceReadData(long deviceId, int readDate, BigDecimal readData){
|
|
|
+ Device device = deviceMapper.findById(deviceId);
|
|
|
+ if (device == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ LocalDateTime localDateTime = device.getLastReceiveTime();
|
|
|
+ if (localDateTime != null) {
|
|
|
+ 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(deviceId);
|
|
|
+ deviceUpdate.setReadData(readData.toPlainString());
|
|
|
+ deviceMapper.updateByPrimaryKeySelective(deviceUpdate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ int nowDate = DateUtil.getDate(new Date());
|
|
|
+ if (readDate >= nowDate) {
|
|
|
+ Device deviceUpdate = new Device();
|
|
|
+ deviceUpdate.setId(deviceId);
|
|
|
+ deviceUpdate.setReadData(readData.toPlainString());
|
|
|
+ deviceMapper.updateByPrimaryKeySelective(deviceUpdate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @author Andy
|
|
|
* @description 查询集合
|
|
@@ -314,7 +321,7 @@ public class MeterReadRecordDao extends BaseDao<MeterReadRecord, String> impleme
|
|
|
* @description 查询条件
|
|
|
* @date 10:37 2021/7/23
|
|
|
* @param dto, query
|
|
|
- * @return java.util.List<org.springframework.data.mongodb.core.aggregation.AggregationOperation>
|
|
|
+ * @return java.util.List<org.springframework.data.mongo.core.aggregation.AggregationOperation>
|
|
|
**/
|
|
|
private List<AggregationOperation> queryCondition(MeterReadRecordDto dto, UserCondition userCondition){
|
|
|
LocalDate localDate;
|
|
@@ -378,7 +385,7 @@ public class MeterReadRecordDao extends BaseDao<MeterReadRecord, String> impleme
|
|
|
* @description 分组查询
|
|
|
* @date 18:36 2021/7/27
|
|
|
* @param year, beginDate, endDate, groupOperation
|
|
|
- * @return java.util.List<org.springframework.data.mongodb.core.aggregation.AggregationOperation>
|
|
|
+ * @return java.util.List<org.springframework.data.mongo.core.aggregation.AggregationOperation>
|
|
|
**/
|
|
|
private List<AggregationOperation> groupCondition(int year, int readDateBeginDate, int readDateEndDate, GroupOperation groupOperation){
|
|
|
Criteria unwindCriteria;
|