Commit 5440238c authored by lisong's avatar lisong

添加气瓶企业统计以及定时任务统计

parent f54537bc
package com.yeejoin.amos.boot.module.tzs.flc.api.dto;
import lombok.Data;
import java.util.Date;
@Data
public class CylinderDateInfoDto {
/**
*
*/
private static final long serialVersionUID = 1L;
private Date SyncDate;//同步时间 yyyy-MM-dd HH24:mi:ss
private String developerAgency;
protected String appId;
private String unitName;
private Integer cylinderInfo;
private Integer cylinderTagInfo;
private Integer cylinderInspectionInfo;
private Integer cylinderFillingInfo;
private Integer cylinderFillingRecordInfo;
private Integer cylinderFillingCheckInfo;
private Integer cylinderExamineInfo;
private Integer cylinderUnit;
private Integer cylinderTotal;
}
package com.yeejoin.amos.boot.module.tzs.flc.api.dto;
import lombok.Data;
/**
* @author fengwang
* @date 2022/1/24.
*/
@Data
public class CylinderTableDto {
/**
* 企业名称
*/
private String unitName;
/**
* 气瓶企业信息
*/
private Integer cylinderUnit;
/**
* 气瓶基本信息
*/
private Integer cylinderInfo;
/**
* 气瓶标签信息
*/
private Integer cylinderTagInfo;
/**
* 气瓶检验信息
*/
private Integer cylinderInspectionInfo;
/**
* 气瓶充装前检查
*/
private Integer cylinderFllingInfo;
/**
* 气瓶充装信息
*/
private Integer cylinderFllingRecordInfo;
/**
* 充装后复查
*/
private Integer cylinderFllingCheckInfo;
/**
* 气瓶充装信息审核
*/
private Integer cylinderExamineInfo;
/**
* 总量
*/
private Integer cylinderTotal;
/**
* 所属区域
*/
private String developerAgency;
}
package com.yeejoin.amos.boot.module.tzs.flc.api.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import java.util.Date;
/**
* 气瓶基本信息
*
*/
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("cylinder_date_info")
public class CylinderDateInfo extends BaseEntity {
/**
* 同步时间
*/
private static final long serialVersionUID = 1L;
@TableField("sync_date")
protected Date SyncDate;//同步时间 yyyy-MM-dd HH24:mi:ss
/**
* 服务机构-开发机构
*/
@TableField("DEVELOPER_AGENCY")
private String developerAgency;
/**
* 对接公司编码
*/
@TableField("app_Id")
protected String appId;
/**
* 气瓶企业信息
*/
@TableField("unit_name")
private String unitName;
/**
* 气瓶基本信息
*/
@TableField("cylinder_info")
private Integer cylinderInfo;
/**
* 气瓶标签信息
*/
@TableField("cylinder_tag_info")
private Integer cylinderTagInfo;
/**
* 气瓶检验信息
*/
@TableField("cylinder_inspection_info")
private Integer cylinderInspectionInfo;
/**
* 气瓶充装前检查
*/
@TableField("cylinder_filling_info")
private Integer cylinderFillingInfo;
/**
* 气瓶充装信息
*/
@TableField("cylinder_filling_record_info")
private Integer cylinderFillingRecordInfo;
/**
* 充装后复查
*/
@TableField("cylinder_filling_check_info")
private Integer cylinderFillingCheckInfo;
/**
* 气瓶充装信息审核
*/
@TableField("cylinder_examine_info")
private Integer cylinderExamineInfo;
/**
* 气瓶充装信息审核
*/
@TableField("cylinder_unit")
private Integer cylinderUnit;
/**
* 总量
*/
@TableField("cylinder_total")
private Integer cylinderTotal;
}
package com.yeejoin.amos.boot.module.tzs.flc.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.CylinderDateInfo;
public interface CylinderDateInfoMapper extends BaseMapper<CylinderDateInfo> {
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.tzs.flc.api.mapper.CylinderDateInfoMapper">
</mapper>
package com.yeejoin.amos.boot.module.tzs.flc.biz.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.CylinderTableDto;
import com.yeejoin.amos.boot.module.tzs.flc.biz.service.impl.CylinderDateInfoServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.List;
@RestController
@Api(tags = "企业气瓶统计Api")
@RequestMapping(value = "/enterpriseStatistic")
public class EnterpriseStatisticController extends BaseController {
@Autowired
CylinderDateInfoServiceImpl cylinderDateInfoService;
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(value = "根据搜索信息获取表格数据")
@GetMapping(value = "/getTableInfo")
public ResponseModel<List<CylinderTableDto>> cylinderTableInfo() {
List<CylinderTableDto> result = cylinderDateInfoService.selectTodayDate();
return ResponseHelper.buildResponse(result);
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(value = "根据搜索信息获取表格数据")
@GetMapping(value = "/getTableInfoPage")
public ResponseModel<Page<CylinderTableDto>> cylinderTableInfoPage(String pageNumber, String pageSize,
@RequestParam(value = "developerAgency" ,required = false) String developerAgency,
@RequestParam(value = "unitName" ,required = false) String unitName) {
Page<CylinderTableDto> cylinderTableDtoPage = cylinderDateInfoService.selectTodayDatePage(pageNumber, pageSize, developerAgency, unitName);
return ResponseHelper.buildResponse(cylinderTableDtoPage);
}
}
package com.yeejoin.amos.boot.module.tzs.flc.biz.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.CylinderDateInfoDto;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.CylinderTableDto;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.*;
import com.yeejoin.amos.boot.module.tzs.flc.api.mapper.CylinderDateInfoMapper;
import com.yeejoin.amos.boot.module.tzs.flc.api.mapper.CylinderUnitMapper;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
@Service
public class CylinderDateInfoServiceImpl extends BaseService<CylinderDateInfoDto, CylinderDateInfo, CylinderDateInfoMapper> {
@Autowired
private CylinderUnitServiceImpl cylinderUnitService;
@Autowired
private CylinderFillingCheckServiceImpl cylinderFillingCheckService;
@Autowired
private CylinderFillingExamineServiceImpl cylinderFillingExamineService;
@Autowired
private CylinderFillingRecordServiceImpl cylinderFillingRecordService;
@Autowired
private CylinderFillingServiceImpl cylinderFillingService;
@Autowired
private CylinderInfoServiceImpl cylinderInfoService;
@Autowired
private CylinderInspectionServiceImpl cylinderInspectionService;
@Autowired
private CylinderTagsServiceImpl cylinderTagsService;
@Autowired
private CylinderUnitMapper cylinderUnitMapper;
public List<CylinderTableDto> selectTodayDate() {
List<CylinderTableDto> result = new ArrayList<>();
List<CylinderUnit> cylinderUnits = cylinderUnitMapper.selectList(null);
for (CylinderUnit token : cylinderUnits) {
CylinderTableDto temp = new CylinderTableDto();
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;
// 获取气瓶基本信息
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.setDeveloperAgency(token.getDeveloperAgency());
result.add(temp);
}
return result;
}
public Page<CylinderTableDto> selectTodayDatePage(String pageNumber, String pageSize,String developerAgency, 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(developerAgency)){
lambda.like(CylinderUnit::getDeveloperAgency, developerAgency);
}
if (!ObjectUtils.isEmpty(unitName)){
lambda.like(CylinderUnit::getUnitName, unitName);
}
IPage<CylinderUnit> cylinderUnitIPage = cylinderUnitMapper.selectPage(cylinderUnitPage, lambda);
for (CylinderUnit token : cylinderUnitIPage.getRecords()) {
CylinderTableDto temp = new CylinderTableDto();
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;
// 获取气瓶基本信息
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.setDeveloperAgency(token.getDeveloperAgency());
result.add(temp);
}
page.setRecords(result);
page.setTotal(cylinderUnitIPage.getTotal());
return page;
}
@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(list.size() == 0) {
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();
}
}
System.out.println("更新昨日数据成功");
}
}
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