|
@@ -12,6 +12,7 @@ import com.rongwei.rwcommon.base.BaseDo;
|
|
import com.rongwei.rwcommon.base.R;
|
|
import com.rongwei.rwcommon.base.R;
|
|
import com.rongwei.rwcommon.base.exception.CustomException;
|
|
import com.rongwei.rwcommon.base.exception.CustomException;
|
|
import com.rongwei.rwcommon.utils.SecurityUtil;
|
|
import com.rongwei.rwcommon.utils.SecurityUtil;
|
|
|
|
+import com.rongwei.safecommon.utils.CXCommonUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -22,6 +23,7 @@ import java.util.ArrayList;
|
|
import java.util.Calendar;
|
|
import java.util.Calendar;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -108,6 +110,53 @@ public class EquGdyRecordServiceImpl extends ServiceImpl<EquGdyRecordDao, EquGdy
|
|
return R.ok(currentData);
|
|
return R.ok(currentData);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public R generateByDate(Date startDate, Date endDate) {
|
|
|
|
+ String currentUserFactoryId = CXCommonUtils.getCurrentUserFactoryId(null);
|
|
|
|
+ // 获取所有的表具信息
|
|
|
|
+ List<EquGdyMeterDo> gdyMeterDoList = equGdyMeterService.list(new LambdaQueryWrapper<EquGdyMeterDo>()
|
|
|
|
+ .eq(BaseDo::getDeleted, "0")
|
|
|
|
+ .eq(EquGdyMeterDo::getStatus, "enable")
|
|
|
|
+ .eq(EquGdyMeterDo::getTenantid, currentUserFactoryId));
|
|
|
|
+ Calendar startInstance = Calendar.getInstance();
|
|
|
|
+ startInstance.setTime(startDate);
|
|
|
|
+ Calendar endInstance = Calendar.getInstance();
|
|
|
|
+ endInstance.setTime(endDate);
|
|
|
|
+ Date now = new Date();
|
|
|
|
+ List<EquGdyRecordDo> saveData = new ArrayList<>();
|
|
|
|
+ while (startInstance.compareTo(endInstance)<=0) {
|
|
|
|
+ // 获取当天的数据
|
|
|
|
+ List<String> meteridList = this.getBaseMapper().getMeteridByDate(startInstance.getTime(), currentUserFactoryId);
|
|
|
|
+ // 获取没有生成数量的表具信息
|
|
|
|
+ List<EquGdyRecordDo> collect = gdyMeterDoList.stream().filter(data -> !meteridList.contains(data.getId()))
|
|
|
|
+ .map(info -> {
|
|
|
|
+ EquGdyRecordDo equGdyRecordDo = new EquGdyRecordDo();
|
|
|
|
+ equGdyRecordDo.setId(SecurityUtil.getUUID());
|
|
|
|
+ equGdyRecordDo.setEnergytype(info.getEnergytype());
|
|
|
|
+ equGdyRecordDo.setMeterid(info.getId());
|
|
|
|
+ equGdyRecordDo.setMetername(info.getMetername());
|
|
|
|
+ equGdyRecordDo.setMetercode(info.getMetercode());
|
|
|
|
+ equGdyRecordDo.setCbdate(startInstance.getTime());
|
|
|
|
+ equGdyRecordDo.setUsedeptid(info.getUsedeptid());
|
|
|
|
+ equGdyRecordDo.setCreatedate(now);
|
|
|
|
+ equGdyRecordDo.setModifydate(now);
|
|
|
|
+ equGdyRecordDo.setTenantid(info.getTenantid());
|
|
|
|
+ equGdyRecordDo.setMeterlocation(info.getMeterlocation());
|
|
|
|
+ equGdyRecordDo.setYear(startInstance.get(Calendar.YEAR));
|
|
|
|
+ equGdyRecordDo.setMonth(startInstance.get(Calendar.MONTH) + 1);
|
|
|
|
+ equGdyRecordDo.setDay(startInstance.get(Calendar.DAY_OF_MONTH));
|
|
|
|
+ return equGdyRecordDo;
|
|
|
|
+ }
|
|
|
|
+ ).collect(Collectors.toList());
|
|
|
|
+ saveData.addAll(collect);
|
|
|
|
+ startInstance.add(Calendar.DATE, 1);
|
|
|
|
+ }
|
|
|
|
+ if (!saveData.isEmpty()) {
|
|
|
|
+ this.saveBatch(saveData, 100);
|
|
|
|
+ }
|
|
|
|
+ return R.ok();
|
|
|
|
+ }
|
|
|
|
+
|
|
public EquGdyRecordDo dataFromTheDayBefore(EquGdyRecordDo equGdyRecordDo, int changeDay) {
|
|
public EquGdyRecordDo dataFromTheDayBefore(EquGdyRecordDo equGdyRecordDo, int changeDay) {
|
|
Date cbdate = equGdyRecordDo.getCbdate();
|
|
Date cbdate = equGdyRecordDo.getCbdate();
|
|
if (cbdate == null) {
|
|
if (cbdate == null) {
|
|
@@ -119,10 +168,10 @@ public class EquGdyRecordServiceImpl extends ServiceImpl<EquGdyRecordDao, EquGdy
|
|
instance.add(Calendar.DATE, changeDay);
|
|
instance.add(Calendar.DATE, changeDay);
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
|
- return this.getOne(new LambdaQueryWrapper<EquGdyRecordDo>()
|
|
|
|
|
|
+ return this.getOne(new LambdaQueryWrapper<EquGdyRecordDo>()
|
|
.eq(BaseDo::getDeleted, "0")
|
|
.eq(BaseDo::getDeleted, "0")
|
|
.eq(EquGdyRecordDo::getCbdate, dateFormat.format(instance.getTime()))
|
|
.eq(EquGdyRecordDo::getCbdate, dateFormat.format(instance.getTime()))
|
|
- .eq(EquGdyRecordDo::getMeterid, equGdyRecordDo.getMeterid()),false);
|
|
|
|
|
|
+ .eq(EquGdyRecordDo::getMeterid, equGdyRecordDo.getMeterid()), false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|