Commit 9439cba9 authored by lisong's avatar lisong

更新

parent 4a054b34
...@@ -25,12 +25,12 @@ import java.util.List; ...@@ -25,12 +25,12 @@ import java.util.List;
public class EnterpriseStatisticController extends BaseController { public class EnterpriseStatisticController extends BaseController {
@Autowired @Autowired
CylinderDateInfoServiceImpl cylinderDateInfoService; CylinderDateInfoServiceImpl cylinderDateInfoService;
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(value = "根据搜索信息获取表格数据") @ApiOperation(value = "根据搜索信息获取表格数据")
@GetMapping(value = "/getTableInfo") @GetMapping(value = "/getTableInfo")
public ResponseModel<List<CylinderTableDto>> cylinderTableInfo() { public ResponseModel<List<CylinderTableDto>> cylinderTableInfo() {
List<CylinderTableDto> result = cylinderDateInfoService.selectTodayDate(); List<CylinderTableDto> result = cylinderDateInfoService.selectTodayDate();
return ResponseHelper.buildResponse(result); return ResponseHelper.buildResponse(result);
} }
...@@ -39,8 +39,8 @@ public class EnterpriseStatisticController extends BaseController { ...@@ -39,8 +39,8 @@ public class EnterpriseStatisticController extends BaseController {
@ApiOperation(value = "根据搜索信息获取表格数据") @ApiOperation(value = "根据搜索信息获取表格数据")
@GetMapping(value = "/getTableInfoPage") @GetMapping(value = "/getTableInfoPage")
public ResponseModel<Page<CylinderTableDto>> cylinderTableInfoPage(String pageNumber, String pageSize, public ResponseModel<Page<CylinderTableDto>> cylinderTableInfoPage(String pageNumber, String pageSize,
@RequestParam(value = "regionName" ,required = false) String regionName, @RequestParam(value = "regionName", required = false) String regionName,
@RequestParam(value = "unitName" ,required = false) String unitName) { @RequestParam(value = "unitName", required = false) String unitName) {
Page<CylinderTableDto> cylinderTableDtoPage = cylinderDateInfoService.selectTodayDatePage(pageNumber, pageSize, regionName, unitName); Page<CylinderTableDto> cylinderTableDtoPage = cylinderDateInfoService.selectTodayDatePage(pageNumber, pageSize, regionName, unitName);
return ResponseHelper.buildResponse(cylinderTableDtoPage); return ResponseHelper.buildResponse(cylinderTableDtoPage);
} }
...@@ -49,17 +49,16 @@ public class EnterpriseStatisticController extends BaseController { ...@@ -49,17 +49,16 @@ public class EnterpriseStatisticController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(value = "创建表格数据") @ApiOperation(value = "创建表格数据")
@GetMapping(value = "/createTableInfoPage") @GetMapping(value = "/createTableInfoPage")
public ResponseModel createTableInfoPage() { public ResponseModel createTableInfoPage() {
cylinderDateInfoService.fixedDelayJob(); cylinderDateInfoService.fixedDelayJob();
return ResponseHelper.buildResponse(null); return ResponseHelper.buildResponse(null);
} }
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(value = "初始化统计数据") @ApiOperation(value = "初始化统计数据")
@GetMapping(value = "/initializeData") @GetMapping(value = "/initializeData")
public ResponseModel initializeData() { public ResponseModel initializeData() {
cylinderDateInfoService.initializeData(); cylinderDateInfoService.initializeData();
return ResponseHelper.buildResponse(null); return ResponseHelper.buildResponse(null);
} }
......
...@@ -18,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -18,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
...@@ -26,268 +27,265 @@ import java.util.List; ...@@ -26,268 +27,265 @@ import java.util.List;
@Service @Service
public class CylinderDateInfoServiceImpl extends BaseService<CylinderDateInfoDto, CylinderDateInfo, CylinderDateInfoMapper> { public class CylinderDateInfoServiceImpl extends BaseService<CylinderDateInfoDto, CylinderDateInfo, CylinderDateInfoMapper> {
private static final Logger logger = LogManager.getLogger(CylinderDateInfoServiceImpl.class); private static final Logger logger = LogManager.getLogger(CylinderDateInfoServiceImpl.class);
@Autowired
private CylinderUnitServiceImpl cylinderUnitService;
@Autowired
private CylinderFillingCheckServiceImpl cylinderFillingCheckService;
@Autowired
private CylinderFillingExamineServiceImpl cylinderFillingExamineService;
@Autowired @Autowired
private CylinderFillingRecordServiceImpl cylinderFillingRecordService; private CylinderUnitServiceImpl cylinderUnitService;
@Autowired @Autowired
private CylinderFillingServiceImpl cylinderFillingService; private CylinderFillingCheckServiceImpl cylinderFillingCheckService;
@Autowired @Autowired
private CylinderInfoServiceImpl cylinderInfoService; private CylinderFillingExamineServiceImpl cylinderFillingExamineService;
@Autowired @Autowired
private CylinderInspectionServiceImpl cylinderInspectionService; private CylinderFillingRecordServiceImpl cylinderFillingRecordService;
@Autowired @Autowired
private CylinderTagsServiceImpl cylinderTagsService; private CylinderFillingServiceImpl cylinderFillingService;
@Autowired @Autowired
private CylinderUnitMapper cylinderUnitMapper; private CylinderInfoServiceImpl cylinderInfoService;
public List<CylinderTableDto> selectTodayDate() { @Autowired
List<CylinderTableDto> result = new ArrayList<>(); private CylinderInspectionServiceImpl cylinderInspectionService;
List<CylinderUnit> cylinderUnits = cylinderUnitMapper.selectList(null); @Autowired
private CylinderTagsServiceImpl cylinderTagsService;
for (CylinderUnit token : cylinderUnits) { @Autowired
CylinderTableDto temp = new CylinderTableDto(); private CylinderUnitMapper cylinderUnitMapper;
temp.setUnitName(token.getUnitName());
// 获取气瓶基本信息
Integer cylinderUnit = 0;
Integer cylinder = 0;
Integer tags = 0;
Integer inspection = 0;
Integer flling = 0;
Integer fllingRecord = 0;
Integer fllingCheck = 0;
Integer examine = 0;
Integer total = 0;
// 获取气瓶基本信息 public List<CylinderTableDto> selectTodayDate() {
List<CylinderDateInfo> list = this.list(new LambdaQueryWrapper<CylinderDateInfo>().eq(CylinderDateInfo::getAppId, token.getAppId())); List<CylinderTableDto> result = new ArrayList<>();
for (CylinderDateInfo info : list) {
cylinder += info.getCylinderInfo();
cylinderUnit += info.getCylinderUnit();
tags += info.getCylinderTagInfo();
inspection += info.getCylinderInspectionInfo();
flling += info.getCylinderFillingInfo();
fllingRecord += info.getCylinderFillingRecordInfo();
fllingCheck += info.getCylinderFillingCheckInfo();
examine += info.getCylinderExamineInfo();
total += info.getCylinderTotal();
}
List<CylinderUnit> cylinderUnits = cylinderUnitMapper.selectList(null);
temp.setCylinderUnit(cylinderUnit); for (CylinderUnit token : cylinderUnits) {
temp.setCylinderFllingCheckInfo(fllingCheck); CylinderTableDto temp = new CylinderTableDto();
temp.setCylinderExamineInfo(examine); temp.setUnitName(token.getUnitName());
temp.setCylinderFllingInfo(flling); // 获取气瓶基本信息
temp.setCylinderFllingRecordInfo(fllingRecord); Integer cylinderUnit = 0;
temp.setCylinderInspectionInfo(inspection); Integer cylinder = 0;
temp.setCylinderTagInfo(tags); Integer tags = 0;
temp.setCylinderInfo(cylinder); Integer inspection = 0;
temp.setCylinderTotal(total); Integer flling = 0;
temp.setRegionName(token.getDeveloperAgency()); Integer fllingRecord = 0;
result.add(temp); Integer fllingCheck = 0;
} Integer examine = 0;
return result; Integer total = 0;
}
// 获取气瓶基本信息
List<CylinderDateInfo> list = this.list(new LambdaQueryWrapper<CylinderDateInfo>().eq(CylinderDateInfo::getAppId, token.getAppId()));
for (CylinderDateInfo info : list) {
cylinder += info.getCylinderInfo();
cylinderUnit += info.getCylinderUnit();
tags += info.getCylinderTagInfo();
inspection += info.getCylinderInspectionInfo();
flling += info.getCylinderFillingInfo();
fllingRecord += info.getCylinderFillingRecordInfo();
fllingCheck += info.getCylinderFillingCheckInfo();
examine += info.getCylinderExamineInfo();
total += info.getCylinderTotal();
}
temp.setCylinderUnit(cylinderUnit);
temp.setCylinderFllingCheckInfo(fllingCheck);
temp.setCylinderExamineInfo(examine);
temp.setCylinderFllingInfo(flling);
temp.setCylinderFllingRecordInfo(fllingRecord);
temp.setCylinderInspectionInfo(inspection);
temp.setCylinderTagInfo(tags);
temp.setCylinderInfo(cylinder);
temp.setCylinderTotal(total);
temp.setRegionName(token.getDeveloperAgency());
result.add(temp);
}
return result;
}
public Page<CylinderTableDto> selectTodayDatePage(String pageNumber, String pageSize,String regionName, String unitName) {
Page<CylinderTableDto> page = new Page<>();
List<CylinderTableDto> result = new ArrayList<>();
Page<CylinderUnit> cylinderUnitPage = new Page<>(Long.parseLong(pageNumber), Long.parseLong(pageSize));
LambdaQueryWrapper<CylinderUnit> lambda = new QueryWrapper<CylinderUnit>().lambda();
if (!ObjectUtils.isEmpty(regionName)){
lambda.like(CylinderUnit::getRegionCode, regionName);
}
if (!ObjectUtils.isEmpty(unitName)){
lambda.like(CylinderUnit::getUnitName, unitName);
}
IPage<CylinderUnit> cylinderUnitIPage = cylinderUnitMapper.selectPage(cylinderUnitPage, lambda);
for (CylinderUnit unit : cylinderUnitIPage.getRecords()) {
CylinderTableDto temp = new CylinderTableDto();
temp.setUnitName(unit.getUnitName());
// 获取气瓶基本信息
Integer cylinderUnit = 0;
Integer cylinder = 0;
Integer tags = 0;
Integer inspection = 0;
Integer flling = 0;
Integer fllingRecord = 0;
Integer fllingCheck = 0;
Integer examine = 0;
Integer total = 0;
// 获取气瓶基本信息
List<CylinderDateInfo> list = this.list(new LambdaQueryWrapper<CylinderDateInfo>().eq(CylinderDateInfo::getAppId, unit.getAppId()));
for (CylinderDateInfo info : list) {
cylinder += info.getCylinderInfo();
cylinderUnit += info.getCylinderUnit();
tags += info.getCylinderTagInfo();
inspection += info.getCylinderInspectionInfo();
flling += info.getCylinderFillingInfo();
fllingRecord += info.getCylinderFillingRecordInfo();
fllingCheck += info.getCylinderFillingCheckInfo();
examine += info.getCylinderExamineInfo();
total += info.getCylinderTotal();
}
temp.setCylinderUnit(cylinderUnit);
temp.setCylinderFllingCheckInfo(fllingCheck);
temp.setCylinderExamineInfo(examine);
temp.setCylinderFllingInfo(flling);
temp.setCylinderFllingRecordInfo(fllingRecord);
temp.setCylinderInspectionInfo(inspection);
temp.setCylinderTagInfo(tags);
temp.setCylinderInfo(cylinder);
temp.setCylinderTotal(total);
temp.setRegionName(unit.getRegionName());
result.add(temp);
}
page.setRecords(result);
page.setTotal(cylinderUnitIPage.getTotal());
return page;
}
@Scheduled(cron = "0 0 2 * * ?") //每天凌晨两点执行 public Page<CylinderTableDto> selectTodayDatePage(String pageNumber, String pageSize, String regionName, String unitName) {
public void fixedDelayJob(){ Page<CylinderTableDto> page = new Page<>();
// 每天更新或者添加昨天的数据 List<CylinderTableDto> result = new ArrayList<>();
Date date = new Date();//取时间 Page<CylinderUnit> cylinderUnitPage = new Page<>(Long.parseLong(pageNumber), Long.parseLong(pageSize));
Calendar calendar = Calendar.getInstance(); LambdaQueryWrapper<CylinderUnit> lambda = new QueryWrapper<CylinderUnit>().lambda();
calendar.setTime(date); if (!ObjectUtils.isEmpty(regionName)) {
calendar.add(Calendar.DATE,-1); lambda.like(CylinderUnit::getRegionCode, regionName);
//这个时间就是日期往后推一天的结果 }
date=calendar.getTime(); if (!ObjectUtils.isEmpty(unitName)) {
LambdaQueryWrapper<CylinderUnit> lambda = new QueryWrapper<CylinderUnit>().lambda(); lambda.like(CylinderUnit::getUnitName, unitName);
List<CylinderUnit> cylinderUnits = cylinderUnitMapper.selectList(lambda); }
for(CylinderUnit token : cylinderUnits) { IPage<CylinderUnit> cylinderUnitIPage = cylinderUnitMapper.selectPage(cylinderUnitPage, lambda);
try { for (CylinderUnit unit : cylinderUnitIPage.getRecords()) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); CylinderTableDto temp = new CylinderTableDto();
String todayStr = sdf.format(date); temp.setUnitName(unit.getUnitName());
List<CylinderDateInfo> list = this.list(new LambdaQueryWrapper<CylinderDateInfo>().between(CylinderDateInfo::getSyncDate,todayStr + " 00:00:00",todayStr + " 23:59:59").eq(CylinderDateInfo::getAppId,token.getAppId())); // 获取气瓶基本信息
if(ObjectUtils.isEmpty(list)) { Integer cylinderUnit = 0;
CylinderDateInfoDto temp = new CylinderDateInfoDto(); Integer cylinder = 0;
temp.setSyncDate(date); Integer tags = 0;
String appid = token.getAppId(); Integer inspection = 0;
temp.setUnitName(token.getUnitName()); Integer flling = 0;
temp.setAppId(appid); Integer fllingRecord = 0;
temp.setDeveloperAgency(token.getDeveloperAgency()); Integer fllingCheck = 0;
// 获取气瓶基本信息 Integer examine = 0;
Integer cylinder = cylinderInfoService.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId,appid).between(CylinderInfo::getSyncDate,todayStr + " 00:00:00",todayStr + " 23:59:59")); Integer total = 0;
Integer cylinderUnit = cylinderUnitService.count(new LambdaQueryWrapper<CylinderUnit>().eq(CylinderUnit::getAppId,appid).between(CylinderUnit::getSyncDate,todayStr + " 00:00:00",todayStr + " 23:59:59")); // 获取气瓶基本信息
Integer tags = cylinderTagsService.count(new LambdaQueryWrapper<CylinderTags>().eq(CylinderTags::getAppId,appid).between(CylinderTags::getSyncDate,todayStr + " 00:00:00",todayStr + " 23:59:59")); List<CylinderDateInfo> list = this.list(new LambdaQueryWrapper<CylinderDateInfo>().eq(CylinderDateInfo::getAppId, unit.getAppId()));
Integer inspection = cylinderInspectionService.count(new LambdaQueryWrapper<CylinderInspection>().eq(CylinderInspection::getAppId,appid).between(CylinderInspection::getSyncDate,todayStr + " 00:00:00",todayStr + " 23:59:59")); for (CylinderDateInfo info : list) {
Integer filling = cylinderFillingService.count(new LambdaQueryWrapper<CylinderFilling>().eq(CylinderFilling::getAppId,appid).between(CylinderFilling::getSyncDate,todayStr + " 00:00:00",todayStr + " 23:59:59")); cylinder += info.getCylinderInfo();
Integer fillingRecord = cylinderFillingRecordService.count(new LambdaQueryWrapper<CylinderFillingRecord>().eq(CylinderFillingRecord::getAppId,appid).between(CylinderFillingRecord::getSyncDate,todayStr+ " 00:00:00",todayStr + " 23:59:59")); cylinderUnit += info.getCylinderUnit();
Integer fillingCheck = cylinderFillingCheckService.count(new LambdaQueryWrapper<CylinderFillingCheck>().eq(CylinderFillingCheck::getAppId,appid).between(CylinderFillingCheck::getSyncDate,todayStr + " 00:00:00",todayStr + " 23:59:59")); tags += info.getCylinderTagInfo();
Integer examine = cylinderFillingExamineService.count(new LambdaQueryWrapper<CylinderFillingExamine>().eq(CylinderFillingExamine::getAppId,appid).between(CylinderFillingExamine::getSyncDate,todayStr + " 00:00:00",todayStr + " 23:59:59")); inspection += info.getCylinderInspectionInfo();
Integer total = cylinder + cylinderUnit + tags + inspection+filling+fillingRecord+fillingCheck+examine; flling += info.getCylinderFillingInfo();
temp.setCylinderExamineInfo(examine); fllingRecord += info.getCylinderFillingRecordInfo();
temp.setCylinderUnit(cylinderUnit); fllingCheck += info.getCylinderFillingCheckInfo();
temp.setCylinderFillingCheckInfo(fillingCheck); examine += info.getCylinderExamineInfo();
temp.setCylinderFillingInfo(filling); total += info.getCylinderTotal();
temp.setCylinderInspectionInfo(inspection); }
temp.setCylinderTagInfo(tags); temp.setCylinderUnit(cylinderUnit);
temp.setCylinderInfo(cylinder); temp.setCylinderFllingCheckInfo(fllingCheck);
temp.setCylinderFillingRecordInfo(fillingRecord); temp.setCylinderExamineInfo(examine);
temp.setCylinderTotal(total); temp.setCylinderFllingInfo(flling);
this.createWithModel(temp); temp.setCylinderFllingRecordInfo(fllingRecord);
} else { temp.setCylinderInspectionInfo(inspection);
list.forEach( info -> { temp.setCylinderTagInfo(tags);
String appId = token.getAppId(); temp.setCylinderInfo(cylinder);
// 获取气瓶基本信息 temp.setCylinderTotal(total);
Integer cylinder = cylinderInfoService.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId,appId).between(CylinderInfo::getSyncDate,todayStr + " 00:00:00",todayStr + " 23:59:59")); temp.setRegionName(unit.getRegionName());
Integer cylinderUnit = cylinderUnitService.count(new LambdaQueryWrapper<CylinderUnit>().eq(CylinderUnit::getAppId,appId).between(CylinderUnit::getSyncDate,todayStr + " 00:00:00",todayStr + " 23:59:59")); result.add(temp);
Integer tags = cylinderTagsService.count(new LambdaQueryWrapper<CylinderTags>().eq(CylinderTags::getAppId,appId).between(CylinderTags::getSyncDate,todayStr + " 00:00:00",todayStr + " 23:59:59")); }
Integer inspection = cylinderInspectionService.count(new LambdaQueryWrapper<CylinderInspection>().eq(CylinderInspection::getAppId,appId).between(CylinderInspection::getSyncDate,todayStr + " 00:00:00",todayStr + " 23:59:59")); page.setRecords(result);
Integer filling = cylinderFillingService.count(new LambdaQueryWrapper<CylinderFilling>().eq(CylinderFilling::getAppId,appId).between(CylinderFilling::getSyncDate,todayStr + " 00:00:00",todayStr + " 23:59:59")); page.setTotal(cylinderUnitIPage.getTotal());
Integer fillingRecord = cylinderFillingRecordService.count(new LambdaQueryWrapper<CylinderFillingRecord>().eq(CylinderFillingRecord::getAppId,appId).between(CylinderFillingRecord::getSyncDate,todayStr + " 00:00:00",todayStr + " 23:59:59")); return page;
Integer fillingCheck = cylinderFillingCheckService.count(new LambdaQueryWrapper<CylinderFillingCheck>().eq(CylinderFillingCheck::getAppId,appId).between(CylinderFillingCheck::getSyncDate,todayStr + " 00:00:00",todayStr + " 23:59:59")); }
Integer examine = cylinderFillingExamineService.count(new LambdaQueryWrapper<CylinderFillingExamine>().eq(CylinderFillingExamine::getAppId,appId).between(CylinderFillingExamine::getSyncDate,todayStr + " 00:00:00",todayStr + " 23:59:59"));
Integer total = cylinder + cylinderUnit + tags + inspection+filling+fillingRecord+fillingCheck+examine;
info.setCylinderExamineInfo(examine);
info.setCylinderUnit(cylinderUnit);
info.setCylinderFillingCheckInfo(fillingCheck);
info.setCylinderFillingInfo(filling);
info.setCylinderInspectionInfo(inspection);
info.setCylinderTagInfo(tags);
info.setCylinderInfo(cylinder);
info.setCylinderFillingRecordInfo(fillingRecord);
info.setCylinderTotal(total);
this.updateById(info);
});
}
} catch (Exception e) {
e.printStackTrace();
}
}
logger.info("更新昨日数据成功");
}
@Scheduled(cron = "0 0 2 * * ?") //每天凌晨两点执行
public void fixedDelayJob() {
// 每天更新或者添加昨天的数据
Date date = new Date();//取时间
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DATE, -1);
//这个时间就是日期往后推一天的结果
date = calendar.getTime();
LambdaQueryWrapper<CylinderUnit> lambda = new QueryWrapper<CylinderUnit>().lambda();
List<CylinderUnit> cylinderUnits = cylinderUnitMapper.selectList(lambda);
for (CylinderUnit token : cylinderUnits) {
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String todayStr = sdf.format(date);
List<CylinderDateInfo> list = this.list(new LambdaQueryWrapper<CylinderDateInfo>().between(CylinderDateInfo::getSyncDate, todayStr + " 00:00:00", todayStr + " 23:59:59").eq(CylinderDateInfo::getAppId, token.getAppId()));
if (ObjectUtils.isEmpty(list)) {
CylinderDateInfoDto temp = new CylinderDateInfoDto();
temp.setSyncDate(date);
String appid = token.getAppId();
temp.setUnitName(token.getUnitName());
temp.setAppId(appid);
temp.setDeveloperAgency(token.getDeveloperAgency());
// 获取气瓶基本信息
Integer cylinder = cylinderInfoService.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId, appid).between(CylinderInfo::getSyncDate, todayStr + " 00:00:00", todayStr + " 23:59:59"));
Integer cylinderUnit = cylinderUnitService.count(new LambdaQueryWrapper<CylinderUnit>().eq(CylinderUnit::getAppId, appid).between(CylinderUnit::getSyncDate, todayStr + " 00:00:00", todayStr + " 23:59:59"));
Integer tags = cylinderTagsService.count(new LambdaQueryWrapper<CylinderTags>().eq(CylinderTags::getAppId, appid).between(CylinderTags::getSyncDate, todayStr + " 00:00:00", todayStr + " 23:59:59"));
Integer inspection = cylinderInspectionService.count(new LambdaQueryWrapper<CylinderInspection>().eq(CylinderInspection::getAppId, appid).between(CylinderInspection::getSyncDate, todayStr + " 00:00:00", todayStr + " 23:59:59"));
Integer filling = cylinderFillingService.count(new LambdaQueryWrapper<CylinderFilling>().eq(CylinderFilling::getAppId, appid).between(CylinderFilling::getSyncDate, todayStr + " 00:00:00", todayStr + " 23:59:59"));
Integer fillingRecord = cylinderFillingRecordService.count(new LambdaQueryWrapper<CylinderFillingRecord>().eq(CylinderFillingRecord::getAppId, appid).between(CylinderFillingRecord::getSyncDate, todayStr + " 00:00:00", todayStr + " 23:59:59"));
Integer fillingCheck = cylinderFillingCheckService.count(new LambdaQueryWrapper<CylinderFillingCheck>().eq(CylinderFillingCheck::getAppId, appid).between(CylinderFillingCheck::getSyncDate, todayStr + " 00:00:00", todayStr + " 23:59:59"));
Integer examine = cylinderFillingExamineService.count(new LambdaQueryWrapper<CylinderFillingExamine>().eq(CylinderFillingExamine::getAppId, appid).between(CylinderFillingExamine::getSyncDate, todayStr + " 00:00:00", todayStr + " 23:59:59"));
Integer total = cylinder + cylinderUnit + tags + inspection + filling + fillingRecord + fillingCheck + examine;
temp.setCylinderExamineInfo(examine);
temp.setCylinderUnit(cylinderUnit);
temp.setCylinderFillingCheckInfo(fillingCheck);
temp.setCylinderFillingInfo(filling);
temp.setCylinderInspectionInfo(inspection);
temp.setCylinderTagInfo(tags);
temp.setCylinderInfo(cylinder);
temp.setCylinderFillingRecordInfo(fillingRecord);
temp.setCylinderTotal(total);
this.createWithModel(temp);
} else {
list.forEach(info -> {
String appId = token.getAppId();
// 获取气瓶基本信息
Integer cylinder = cylinderInfoService.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId, appId).between(CylinderInfo::getSyncDate, todayStr + " 00:00:00", todayStr + " 23:59:59"));
Integer cylinderUnit = cylinderUnitService.count(new LambdaQueryWrapper<CylinderUnit>().eq(CylinderUnit::getAppId, appId).between(CylinderUnit::getSyncDate, todayStr + " 00:00:00", todayStr + " 23:59:59"));
Integer tags = cylinderTagsService.count(new LambdaQueryWrapper<CylinderTags>().eq(CylinderTags::getAppId, appId).between(CylinderTags::getSyncDate, todayStr + " 00:00:00", todayStr + " 23:59:59"));
Integer inspection = cylinderInspectionService.count(new LambdaQueryWrapper<CylinderInspection>().eq(CylinderInspection::getAppId, appId).between(CylinderInspection::getSyncDate, todayStr + " 00:00:00", todayStr + " 23:59:59"));
Integer filling = cylinderFillingService.count(new LambdaQueryWrapper<CylinderFilling>().eq(CylinderFilling::getAppId, appId).between(CylinderFilling::getSyncDate, todayStr + " 00:00:00", todayStr + " 23:59:59"));
Integer fillingRecord = cylinderFillingRecordService.count(new LambdaQueryWrapper<CylinderFillingRecord>().eq(CylinderFillingRecord::getAppId, appId).between(CylinderFillingRecord::getSyncDate, todayStr + " 00:00:00", todayStr + " 23:59:59"));
Integer fillingCheck = cylinderFillingCheckService.count(new LambdaQueryWrapper<CylinderFillingCheck>().eq(CylinderFillingCheck::getAppId, appId).between(CylinderFillingCheck::getSyncDate, todayStr + " 00:00:00", todayStr + " 23:59:59"));
Integer examine = cylinderFillingExamineService.count(new LambdaQueryWrapper<CylinderFillingExamine>().eq(CylinderFillingExamine::getAppId, appId).between(CylinderFillingExamine::getSyncDate, todayStr + " 00:00:00", todayStr + " 23:59:59"));
Integer total = cylinder + cylinderUnit + tags + inspection + filling + fillingRecord + fillingCheck + examine;
info.setCylinderExamineInfo(examine);
info.setCylinderUnit(cylinderUnit);
info.setCylinderFillingCheckInfo(fillingCheck);
info.setCylinderFillingInfo(filling);
info.setCylinderInspectionInfo(inspection);
info.setCylinderTagInfo(tags);
info.setCylinderInfo(cylinder);
info.setCylinderFillingRecordInfo(fillingRecord);
info.setCylinderTotal(total);
this.updateById(info);
});
}
} catch (Exception e) {
e.printStackTrace();
}
}
logger.info("更新昨日数据成功");
}
public void initializeData(){
// 每天更新或者添加昨天的数据
Date date = new Date();//取时间
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
//这个时间就是日期往后推一天的结果
date=calendar.getTime();
LambdaQueryWrapper<CylinderUnit> lambda = new QueryWrapper<CylinderUnit>().lambda();
List<CylinderUnit> cylinderUnits = cylinderUnitMapper.selectList(lambda);
logger.info("清除cylinder_date_info表已有数据");
this.baseMapper.delete(null);
for(CylinderUnit token : cylinderUnits) {
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String todayStr = sdf.format(date);
CylinderDateInfoDto temp = new CylinderDateInfoDto();
temp.setSyncDate(date);
String appid = token.getAppId();
temp.setUnitName(token.getUnitName());
temp.setAppId(appid);
temp.setDeveloperAgency(token.getDeveloperAgency());
logger.info("初始化数据时间{}", todayStr);
// 获取气瓶基本信息 public void initializeData() {
Integer cylinder = cylinderInfoService.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId,appid).notLike(CylinderInfo::getSyncDate, todayStr)); // 每天更新或者添加昨天的数据
Integer cylinderUnit = cylinderUnitService.count(new LambdaQueryWrapper<CylinderUnit>().eq(CylinderUnit::getAppId,appid).notLike(CylinderUnit::getSyncDate, todayStr)); Date date = new Date();//取时间
Integer tags = cylinderTagsService.count(new LambdaQueryWrapper<CylinderTags>().eq(CylinderTags::getAppId,appid).notLike(CylinderTags::getSyncDate, todayStr)); Calendar calendar = Calendar.getInstance();
Integer inspection = cylinderInspectionService.count(new LambdaQueryWrapper<CylinderInspection>().eq(CylinderInspection::getAppId,appid).notLike(CylinderInspection::getSyncDate, todayStr)); calendar.setTime(date);
Integer filling = cylinderFillingService.count(new LambdaQueryWrapper<CylinderFilling>().eq(CylinderFilling::getAppId,appid).notLike(CylinderFilling::getSyncDate, todayStr)); //这个时间就是日期往后推一天的结果
Integer fillingRecord = cylinderFillingRecordService.count(new LambdaQueryWrapper<CylinderFillingRecord>().eq(CylinderFillingRecord::getAppId,appid).notLike(CylinderFillingRecord::getSyncDate, todayStr)); date = calendar.getTime();
Integer fillingCheck = cylinderFillingCheckService.count(new LambdaQueryWrapper<CylinderFillingCheck>().eq(CylinderFillingCheck::getAppId,appid).notLike(CylinderFillingCheck::getSyncDate, todayStr)); LambdaQueryWrapper<CylinderUnit> lambda = new QueryWrapper<CylinderUnit>().lambda();
Integer examine = cylinderFillingExamineService.count(new LambdaQueryWrapper<CylinderFillingExamine>().eq(CylinderFillingExamine::getAppId,appid).notLike(CylinderFillingExamine::getSyncDate, todayStr)); List<CylinderUnit> cylinderUnits = cylinderUnitMapper.selectList(lambda);
Integer total = cylinder + cylinderUnit + tags + inspection+filling+fillingRecord+fillingCheck+examine; logger.info("清除cylinder_date_info表已有数据");
temp.setCylinderExamineInfo(examine); this.baseMapper.delete(null);
temp.setCylinderUnit(cylinderUnit); for (CylinderUnit token : cylinderUnits) {
temp.setCylinderFillingCheckInfo(fillingCheck); try {
temp.setCylinderFillingInfo(filling); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
temp.setCylinderInspectionInfo(inspection); String todayStr = sdf.format(date);
temp.setCylinderTagInfo(tags); CylinderDateInfoDto temp = new CylinderDateInfoDto();
temp.setCylinderInfo(cylinder); temp.setSyncDate(date);
temp.setCylinderFillingRecordInfo(fillingRecord); String appid = token.getAppId();
temp.setCylinderTotal(total); temp.setUnitName(token.getUnitName());
this.createWithModel(temp); temp.setAppId(appid);
} catch (Exception e) { temp.setDeveloperAgency(token.getDeveloperAgency());
e.printStackTrace(); logger.info("初始化数据时间{}", todayStr);
}
}
logger.info("更新昨日数据成功");
}
// 获取气瓶基本信息
Integer cylinder = cylinderInfoService.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId, appid).notLike(CylinderInfo::getSyncDate, todayStr));
Integer cylinderUnit = cylinderUnitService.count(new LambdaQueryWrapper<CylinderUnit>().eq(CylinderUnit::getAppId, appid).notLike(CylinderUnit::getSyncDate, todayStr));
Integer tags = cylinderTagsService.count(new LambdaQueryWrapper<CylinderTags>().eq(CylinderTags::getAppId, appid).notLike(CylinderTags::getSyncDate, todayStr));
Integer inspection = cylinderInspectionService.count(new LambdaQueryWrapper<CylinderInspection>().eq(CylinderInspection::getAppId, appid).notLike(CylinderInspection::getSyncDate, todayStr));
Integer filling = cylinderFillingService.count(new LambdaQueryWrapper<CylinderFilling>().eq(CylinderFilling::getAppId, appid).notLike(CylinderFilling::getSyncDate, todayStr));
Integer fillingRecord = cylinderFillingRecordService.count(new LambdaQueryWrapper<CylinderFillingRecord>().eq(CylinderFillingRecord::getAppId, appid).notLike(CylinderFillingRecord::getSyncDate, todayStr));
Integer fillingCheck = cylinderFillingCheckService.count(new LambdaQueryWrapper<CylinderFillingCheck>().eq(CylinderFillingCheck::getAppId, appid).notLike(CylinderFillingCheck::getSyncDate, todayStr));
Integer examine = cylinderFillingExamineService.count(new LambdaQueryWrapper<CylinderFillingExamine>().eq(CylinderFillingExamine::getAppId, appid).notLike(CylinderFillingExamine::getSyncDate, todayStr));
Integer total = cylinder + cylinderUnit + tags + inspection + filling + fillingRecord + fillingCheck + examine;
temp.setCylinderExamineInfo(examine);
temp.setCylinderUnit(cylinderUnit);
temp.setCylinderFillingCheckInfo(fillingCheck);
temp.setCylinderFillingInfo(filling);
temp.setCylinderInspectionInfo(inspection);
temp.setCylinderTagInfo(tags);
temp.setCylinderInfo(cylinder);
temp.setCylinderFillingRecordInfo(fillingRecord);
temp.setCylinderTotal(total);
this.createWithModel(temp);
} catch (Exception e) {
e.printStackTrace();
}
}
logger.info("更新昨日数据成功");
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment