Commit e25d0ed4 authored by 韩桐桐's avatar 韩桐桐

fix(cyl):新增接口 向以天为维度的企业气瓶统计表中刷入当前时间前30天的数据

parent 9cee2dd5
...@@ -19,6 +19,8 @@ public interface CylinderFillingCheckMapper extends BaseMapper<CylinderFillingCh ...@@ -19,6 +19,8 @@ public interface CylinderFillingCheckMapper extends BaseMapper<CylinderFillingCh
Integer getFillingCountByMonth(@Param("appId") String appId, @Param("time") Date time); Integer getFillingCountByMonth(@Param("appId") String appId, @Param("time") Date time);
Integer getFillingCountByDay(@Param("appId") String appId, @Param("time") Date time);
Integer getFillingPassedCountByMonth(@Param("appId") String appId, @Param("time") Date time); Integer getFillingPassedCountByMonth(@Param("appId") String appId, @Param("time") Date time);
void saveOrUpdateByCondition(List<CylinderFillingCheck> fillingChecks); void saveOrUpdateByCondition(List<CylinderFillingCheck> fillingChecks);
......
...@@ -18,5 +18,7 @@ public interface CylinderFillingMapper extends BaseMapper<CylinderFilling> { ...@@ -18,5 +18,7 @@ public interface CylinderFillingMapper extends BaseMapper<CylinderFilling> {
Integer getFillingCountByMonth(@Param("appId") String appId, @Param("time") Date time); Integer getFillingCountByMonth(@Param("appId") String appId, @Param("time") Date time);
Integer getFillingCountByDay(@Param("appId") String appId, @Param("time") Date time);
Integer getFillingPassedCountByMonth(@Param("appId") String appId, @Param("time") Date time); Integer getFillingPassedCountByMonth(@Param("appId") String appId, @Param("time") Date time);
} }
...@@ -53,6 +53,10 @@ public interface CylinderFillingRecordMapper extends BaseMapper<CylinderFillingR ...@@ -53,6 +53,10 @@ public interface CylinderFillingRecordMapper extends BaseMapper<CylinderFillingR
Integer getFillingCountByMonth(@Param("appId") String appId, @Param("time") Date time); Integer getFillingCountByMonth(@Param("appId") String appId, @Param("time") Date time);
Integer getFillingCountByDay(@Param("appId") String appId, @Param("time") Date time);
Integer getFillingUnqualifiedCountByDay(@Param("appId") String appId, @Param("time") Date time);
Double getFillingSumByDate(@Param("appId") String appId, @Param("time") Date time); Double getFillingSumByDate(@Param("appId") String appId, @Param("time") Date time);
List<ESCylinderFillingRecordDto> getCylinderFillingRecordInfo(@Param("appIds") List<String> appIds,@Param("sequenceCodeS") List<String> sequenceCodeS); List<ESCylinderFillingRecordDto> getCylinderFillingRecordInfo(@Param("appIds") List<String> appIds,@Param("sequenceCodeS") List<String> sequenceCodeS);
......
...@@ -44,8 +44,10 @@ public interface ICylinderInfoService { ...@@ -44,8 +44,10 @@ public interface ICylinderInfoService {
void synUnitFillingCheckDataJob(); void synUnitFillingCheckDataJob();
void fillingCheckDataSynHandler(); void fillingCheckDataSynHandler();
void synFillingUnloadUnitData(); void fillingRecordDataSynHandler();
void synFillingUnloadUnitData();
Page<CylinderInfoDto> getCyinderInfoList(Page<CylinderInfoDto> page); Page<CylinderInfoDto> getCyinderInfoList(Page<CylinderInfoDto> page);
......
...@@ -76,6 +76,10 @@ ...@@ -76,6 +76,10 @@
select count(1) from tz_cylinder_filling_check r where date_format(r.inspection_date,'%Y-%m') = date_format(#{time},'%Y-%m') and app_id = #{appId} select count(1) from tz_cylinder_filling_check r where date_format(r.inspection_date,'%Y-%m') = date_format(#{time},'%Y-%m') and app_id = #{appId}
</select> </select>
<select id="getFillingCountByDay" resultType="java.lang.Integer">
select count(1) from tz_cylinder_filling_check r where date_format(r.inspection_date,'%Y-%m-%d') = date_format(#{time},'%Y-%m-%d') and app_id = #{appId}
</select>
<select id="getFillingPassedCountByMonth" resultType="java.lang.Integer"> <select id="getFillingPassedCountByMonth" resultType="java.lang.Integer">
select select
IFNULL( IFNULL(
......
...@@ -10,6 +10,11 @@ ...@@ -10,6 +10,11 @@
<select id="getFillingCountByMonth" resultType="java.lang.Integer"> <select id="getFillingCountByMonth" resultType="java.lang.Integer">
select count(1) from tz_cylinder_filling r where date_format(r.inspection_date,'%Y-%m') = date_format(#{time},'%Y-%m') and app_id = #{appId} select count(1) from tz_cylinder_filling r where date_format(r.inspection_date,'%Y-%m') = date_format(#{time},'%Y-%m') and app_id = #{appId}
</select> </select>
<select id="getFillingCountByDay" resultType="java.lang.Integer">
select count(1) from tz_cylinder_filling r where date_format(r.inspection_date,'%Y-%m-%d') = date_format(#{time},'%Y-%m-%d') and app_id = #{appId}
</select>
<select id="getFillingPassedCountByMonth" resultType="java.lang.Integer"> <select id="getFillingPassedCountByMonth" resultType="java.lang.Integer">
select select
IFNULL( IFNULL(
......
...@@ -146,6 +146,20 @@ ...@@ -146,6 +146,20 @@
select count(1) from tz_cylinder_filling_record r where date_format(r.filling_endTime,'%Y-%m') = date_format(#{time},'%Y-%m') and app_id = #{appId} select count(1) from tz_cylinder_filling_record r where date_format(r.filling_endTime,'%Y-%m') = date_format(#{time},'%Y-%m') and app_id = #{appId}
</select> </select>
<select id="getFillingCountByDay" resultType="java.lang.Integer">
select count(1) from tz_cylinder_filling_record r where date_format(r.filling_endTime,'%Y-%m-%d') = date_format(#{time},'%Y-%m-%d') and app_id = #{appId}
</select>
<select id="getFillingUnqualifiedCountByDay" resultType="java.lang.Integer">
SELECT COUNT(1) AS unqualified_count
FROM tz_cylinder_filling_record AS record
LEFT JOIN tz_cylinder_filling AS before ON record.filling_before_id = before.filling_before_id
LEFT JOIN tz_cylinder_filling_check AS after ON record.filling_check_id = after.filling_check_id
WHERE DATE_FORMAT(record.filling_endTime, '%Y-%m-%d') = DATE_FORMAT(#{time}, '%Y-%m-%d')
AND record.app_id = #{appId}
AND (before.check_results = '不合格' OR after.check_results = '不合格')
</select>
<select id="getCylinderFillingRecord" resultType="com.yeejoin.amos.boot.module.cylinder.api.entity.ESCylinderFillingRecordDto"> <select id="getCylinderFillingRecord" resultType="com.yeejoin.amos.boot.module.cylinder.api.entity.ESCylinderFillingRecordDto">
SELECT DISTINCT(r.filling_record_id), SELECT DISTINCT(r.filling_record_id),
r.sequence_nbr AS sequenceNbr, r.sequence_nbr AS sequenceNbr,
......
...@@ -1336,6 +1336,14 @@ public class CylinderInfoController extends BaseController { ...@@ -1336,6 +1336,14 @@ public class CylinderInfoController extends BaseController {
return ResponseHelper.buildResponse(map); return ResponseHelper.buildResponse(map);
} }
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "主动向以天为维度的企业气瓶统计表中刷入当前时间前30天的数据")
@GetMapping(value = "/thirtyDayEnterpriseCylinderDataRefreshTask")
public ResponseModel<Object> thirtyDayEnterpriseCylinderDataRefreshTask() {
cylinderInfoServiceImpl.fillingRecordDataSynHandler();
return ResponseHelper.buildResponse("ok");
}
/** /**
* 地市气瓶,气站信息统计 * 地市气瓶,气站信息统计
* *
......
...@@ -41,6 +41,10 @@ public class CylinderFillingCheckServiceImpl extends BaseService<CylinderFilling ...@@ -41,6 +41,10 @@ public class CylinderFillingCheckServiceImpl extends BaseService<CylinderFilling
return this.baseMapper.getFillingCountByMonth(appId,time); return this.baseMapper.getFillingCountByMonth(appId,time);
} }
public Integer getFillingCountByDay(String appId, Date time) {
return this.baseMapper.getFillingCountByDay(appId,time);
}
public Integer getFillingPassedCountByMonth(String appId, Date time) { public Integer getFillingPassedCountByMonth(String appId, Date time) {
return this.baseMapper.getFillingPassedCountByMonth(appId,time); return this.baseMapper.getFillingPassedCountByMonth(appId,time);
} }
......
...@@ -112,6 +112,13 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin ...@@ -112,6 +112,13 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
public Integer getFillingCountByMonth(String appId, Date time) { public Integer getFillingCountByMonth(String appId, Date time) {
return baseMapper.getFillingCountByMonth(appId, time); return baseMapper.getFillingCountByMonth(appId, time);
} }
public Integer getFillingCountByDay(String appId, Date time) {
return baseMapper.getFillingCountByDay(appId, time);
}
public Integer getFillingUnqualifiedCountByDay(String appId, Date time) {
return baseMapper.getFillingUnqualifiedCountByDay(appId, time);
}
public Double getFillingSumByDate(String appId, Date time) { public Double getFillingSumByDate(String appId, Date time) {
return baseMapper.getFillingSumByDate(appId, time); return baseMapper.getFillingSumByDate(appId, time);
......
...@@ -41,6 +41,10 @@ public class CylinderFillingServiceImpl extends BaseService<CylinderFillingDto, ...@@ -41,6 +41,10 @@ public class CylinderFillingServiceImpl extends BaseService<CylinderFillingDto,
return this.baseMapper.getFillingCountByMonth(appId,time); return this.baseMapper.getFillingCountByMonth(appId,time);
} }
public Integer getFillingCountByDay(String appId, Date time) {
return this.baseMapper.getFillingCountByDay(appId,time);
}
public Integer getFillingPassedCountByMonth(String appId, Date time) { public Integer getFillingPassedCountByMonth(String appId, Date time) {
return this.baseMapper.getFillingPassedCountByMonth(appId,time); return this.baseMapper.getFillingPassedCountByMonth(appId,time);
} }
......
...@@ -8,12 +8,14 @@ import com.baomidou.mybatisplus.core.metadata.IPage; ...@@ -8,12 +8,14 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils; import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.cylinder.api.dto.CylinderFillingRecordStatisticsUnitDayDto;
import com.yeejoin.amos.boot.module.cylinder.api.dto.WarningMsgDto; import com.yeejoin.amos.boot.module.cylinder.api.dto.WarningMsgDto;
import com.yeejoin.amos.boot.module.cylinder.api.entity.ESCylinderInfoDto; import com.yeejoin.amos.boot.module.cylinder.api.entity.ESCylinderInfoDto;
import com.yeejoin.amos.boot.module.cylinder.api.entity.MsgLog; import com.yeejoin.amos.boot.module.cylinder.api.entity.MsgLog;
import com.yeejoin.amos.boot.module.cylinder.api.enums.EarlyWarningLevelEnum; import com.yeejoin.amos.boot.module.cylinder.api.enums.EarlyWarningLevelEnum;
import com.yeejoin.amos.boot.module.cylinder.api.mapper.ScheduleMapper; import com.yeejoin.amos.boot.module.cylinder.api.mapper.ScheduleMapper;
import com.yeejoin.amos.boot.module.cylinder.biz.dao.ESCylinderInfoRepository; import com.yeejoin.amos.boot.module.cylinder.biz.dao.ESCylinderInfoRepository;
import com.yeejoin.amos.boot.module.cylinder.biz.service.impl.CylinderFillingRecordStatisticsUnitDayServiceImpl;
import com.yeejoin.amos.boot.module.cylinder.biz.service.impl.MsgLogServiceImpl; import com.yeejoin.amos.boot.module.cylinder.biz.service.impl.MsgLogServiceImpl;
import com.yeejoin.amos.boot.module.cylinder.biz.service.impl.StartPlatformTokenService; import com.yeejoin.amos.boot.module.cylinder.biz.service.impl.StartPlatformTokenService;
import com.yeejoin.amos.boot.module.cylinder.biz.service.impl.TzsAuthServiceImpl; import com.yeejoin.amos.boot.module.cylinder.biz.service.impl.TzsAuthServiceImpl;
...@@ -36,6 +38,7 @@ import org.elasticsearch.client.RequestOptions; ...@@ -36,6 +38,7 @@ import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient; import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.index.query.BoolQueryBuilder; import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.aggregations.AggregationBuilders; import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.Aggregations; import org.elasticsearch.search.aggregations.Aggregations;
import org.elasticsearch.search.aggregations.metrics.ParsedCardinality; import org.elasticsearch.search.aggregations.metrics.ParsedCardinality;
...@@ -134,6 +137,9 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind ...@@ -134,6 +137,9 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
CylinderFillingUnloadDataUnitServiceImpl cylinderFillingUnloadDataUnitServiceImpl; CylinderFillingUnloadDataUnitServiceImpl cylinderFillingUnloadDataUnitServiceImpl;
@Autowired @Autowired
CylinderFillingRecordStatisticsUnitDayServiceImpl cylinderFillingRecordStatisticsUnitDayServiceImpl;
@Autowired
MsgLogServiceImpl msgLogService; MsgLogServiceImpl msgLogService;
@Autowired @Autowired
TzsAuthServiceImpl tzsAuthService; TzsAuthServiceImpl tzsAuthService;
...@@ -800,6 +806,63 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind ...@@ -800,6 +806,63 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
cylinderFillingCheckDataUnitDto.setAppId(cylinderUnit.getAppId()); cylinderFillingCheckDataUnitDto.setAppId(cylinderUnit.getAppId());
} }
@Override
public void fillingRecordDataSynHandler() {
// 清空数据
cylinderFillingRecordStatisticsUnitDayServiceImpl.remove(new LambdaQueryWrapper<>());
countByUnit(cylinderUnit -> {
// 当前企业前31天数据填充
Calendar calendar = Calendar.getInstance();
for (int i = 0; i <= 30; i++) {
CylinderFillingRecordStatisticsUnitDayDto unitDay = new CylinderFillingRecordStatisticsUnitDayDto();
calendar.add(Calendar.DAY_OF_MONTH, -1);
calcCylinderFillingCheckDataUnitDataWithDay(cylinderUnit,calendar,unitDay);
cylinderFillingRecordStatisticsUnitDayServiceImpl.createWithModel(unitDay);
}
});
}
/**
* 计算当前单位的充装检查数据统计-以日为单位
*
* @param cylinderUnit
* @param calender
* @param unitDay
*/
public void calcCylinderFillingCheckDataUnitDataWithDay(CylinderUnit cylinderUnit, Calendar calender, CylinderFillingRecordStatisticsUnitDayDto unitDay) {
unitDay.setFillingDate(calender.getTime());
unitDay.setAppId(cylinderUnit.getAppId());
unitDay.setRegionCode(cylinderUnit.getRegionCode());
// 当天充装次数
Integer countThisDay = cylinderFillingRecordServiceImpl
.getFillingCountByDay(cylinderUnit.getAppId(), calender.getTime());
unitDay.setTotalSum(countThisDay);
// 当前充装前检查数
Integer fillingBeforeCount = cylinderFillingServiceImpl.getFillingCountByDay(cylinderUnit.getAppId(),
calender.getTime());
unitDay.setFillingBeforeSum(fillingBeforeCount);
// 当天充装后检查数
Integer fillingAfterCount = cylinderFillingCheckServiceImpl
.getFillingCountByDay(cylinderUnit.getAppId(), calender.getTime());
unitDay.setFillingAfterSum(fillingAfterCount);
// 当天充装量
Double fillingSumByDate= cylinderFillingRecordServiceImpl
.getFillingSumByDate(cylinderUnit.getAppId(), calender.getTime());
unitDay.setFillingQuantity(BigDecimal.valueOf(fillingSumByDate));
// 充装检查不合格数
Integer uniqueFillingBeforeSum = cylinderFillingRecordServiceImpl
.getFillingUnqualifiedCountByDay(cylinderUnit.getAppId(), calender.getTime());
unitDay.setFillingNotPassedCount(uniqueFillingBeforeSum);
}
/** /**
* 充装量、卸液量按单位统计 * 充装量、卸液量按单位统计
*/ */
...@@ -1099,7 +1162,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind ...@@ -1099,7 +1162,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
long totle = 0; long totle = 0;
try { try {
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT); SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
for (org.elasticsearch.search.SearchHit hit : response.getHits()) { for (SearchHit hit : response.getHits()) {
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(hit); JSONObject jsonObject = (JSONObject) JSONObject.toJSON(hit);
ESCylinderInfoDto esCylinderInfoDto = JSONObject.toJavaObject(jsonObject.getJSONObject("sourceAsMap"), ESCylinderInfoDto.class); ESCylinderInfoDto esCylinderInfoDto = JSONObject.toJavaObject(jsonObject.getJSONObject("sourceAsMap"), ESCylinderInfoDto.class);
list.add(esCylinderInfoDto); list.add(esCylinderInfoDto);
......
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