Commit 2f4ed3f9 authored by tianyiming's avatar tianyiming

两员配备- 气瓶基本信息,气瓶充装信息存入es优化

parent b22267d2
......@@ -93,6 +93,10 @@ public class ESCylinderFillingRecordDto {
@Field(type = FieldType.Text)
private String inspectionDate;
//充装前检查时间毫秒值
@Field(type = FieldType.Long)
private Long inspectionDateMs;
//充装前检查结果
@Field(type = FieldType.Text)
private String fillingResult;
......@@ -106,6 +110,10 @@ public class ESCylinderFillingRecordDto {
@Field(type = FieldType.Text)
private String inspectionDateAfter;
//充装前检查结果毫秒值
@Field(type = FieldType.Long)
private Long inspectionDateAfterMS;
//重装后检查结果
@Field(type = FieldType.Text)
private String checkResult;
......@@ -122,4 +130,7 @@ public class ESCylinderFillingRecordDto {
@Field(type = FieldType.Text)
private String regionCode;
//appid+气瓶唯一标识
private String appIdAndSequenceCode;
}
......@@ -72,6 +72,10 @@ public class ESCylinderInfoDto {
@Field(type = FieldType.Text)
private String inspectionDate;
//检验日期
@Field(type = FieldType.Long)
private Long inspectionDateMs;
//气瓶唯一标识
@Field(type = FieldType.Text)
private String sequenceCode;
......
......@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.cylinder.flc.api.mapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.cylinder.api.dto.CylinderFillingRecordDtoEs;
import com.yeejoin.amos.boot.module.cylinder.api.entity.ESCylinderFillingRecordDto;
import com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CylinderFillingRecordDto;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
......@@ -47,7 +48,7 @@ public interface CylinderFillingRecordMapper extends BaseMapper<CylinderFillingR
);
Page<ESCylinderFillingRecordDto> getCyinderFillingRecord(Page<ESCylinderFillingRecordDto> cylinderFillingRecordDto);
List<ESCylinderFillingRecordDto> getCylinderFillingRecord();
Double getFillingSumByMonth(@Param("appId") String appId, @Param("time") Date time);
......@@ -55,7 +56,9 @@ public interface CylinderFillingRecordMapper extends BaseMapper<CylinderFillingR
Double getFillingSumByDate(@Param("appId") String appId, @Param("time") Date time);
ESCylinderFillingRecordDto getCyinderFillingRecordInfo(String appId, String sequenceCode);
List<ESCylinderFillingRecordDto> getCylinderFillingRecordInfo(@Param("appIds") List<String> appIds,@Param("sequenceCodeS") List<String> sequenceCodeS);
Integer getCylinderFillingRecordTotal();
void updateCylinderFillingToEsStatus( @Param("ids")List<String> ids);
}
......@@ -16,7 +16,8 @@ public interface ICylinderFillingRecordService {
ESCylinderFillingRecordDto saveCylinderFillingRecordToES(ESCylinderFillingRecordDto ci);
Page<ESCylinderFillingRecordDto> getCyinderFillingRecord(Page<ESCylinderFillingRecordDto> cylinderFillingRecordDto);
List<ESCylinderFillingRecordDto> getCylinderFillingRecordAll();
List<ESCylinderFillingRecordDto> getCylinderFillingRecordTest();
Page<ESCylinderFillingRecordDto> queryByKeys(ESCylinderFillingRecordDto esCylinderFillingRecordDto, int pageNum, int pageSize);
......
......@@ -146,9 +146,8 @@
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 id="getCyinderFillingRecord" resultType="com.yeejoin.amos.boot.module.cylinder.api.entity.ESCylinderFillingRecordDto">
SELECT
DISTINCT( r.filling_record_id),
<select id="getCylinderFillingRecord" resultType="com.yeejoin.amos.boot.module.cylinder.api.entity.ESCylinderFillingRecordDto">
SELECT DISTINCT(r.filling_record_id),
r.sequence_nbr AS sequenceNbr,
r.filling_startTime AS fillingStarttime,
r.filling_endTime AS fillingEndtime,
......@@ -160,32 +159,48 @@
WHEN 3139 THEN
'有异常'
WHEN 3140 THEN
'正常' ELSE''
'正常'
ELSE ''
END AS abnormalStr,
b.inspector_user AS inspectorUser,
b.inspection_date AS inspectionDate,
b.check_results AS fillingResult,
b.sequence_code AS sequenceCode,
b.app_id AS appId,
concat(b.app_id, b.sequence_code) AS appIdAndSequenceCode,
b.filling_unit_name AS fillingUnitName,
af.inspector AS inspector,
af.inspection_date AS inspectionDateAfter,
af.check_results AS checkResult
FROM
tz_cylinder_filling_record r
( SELECT * FROM tz_cylinder_filling_record WHERE is_not_es IS NULL LIMIT 5000 ) r
LEFT JOIN tz_cylinder_filling b ON b.filling_before_id = r.filling_before_id
AND r.filling_before_id is NOT null
AND date_format (b.inspection_date, '%Y-%m-%d') = date_format ( r.filling_startTime, '%Y-%m-%d' )
AND r.filling_before_id IS NOT NULL and b.inspection_date NOT LIKE'16%'
AND date_format ( b.inspection_date, '%Y-%m-%d' ) = date_format ( r.filling_startTime, '%Y-%m-%d' )
LEFT JOIN tz_cylinder_filling_check af ON af.filling_check_id = r.filling_check_id
AND date_format (af.inspection_date,'%Y-%m-%d') = date_format ( r.filling_startTime, '%Y-%m-%d' )
LEFT JOIN tz_cylinder_info i ON b.sequence_code = i.sequence_code
AND date_format ( af.inspection_date, '%Y-%m-%d' ) = date_format ( r.filling_startTime, '%Y-%m-%d' )
WHERE b.sequence_code is not null AND b.app_id is not null
</select>
<select id="getCylinderFillingRecordTotal" resultType="java.lang.Integer">
SELECT
COUNT(1)
FROM
tz_cylinder_filling_record r
WHERE
r.is_not_es IS NULL
AND b.inspection_date not like '16%'
ORDER BY r.filling_record_id
AND r.filling_before_id IS NOT NULL
AND r.filling_check_id IS NOT NULL
</select>
<select id="getCyinderFillingRecordInfo"
<update id="updateCylinderFillingToEsStatus">
UPDATE tz_cylinder_filling_record SET "is_not_es" = 1 WHERE "sequence_nbr" IN
<foreach collection="ids" separator="," item="id" open="(" close=")">
#{id}
</foreach>
</update>
<select id="getCylinderFillingRecordInfo"
resultType="com.yeejoin.amos.boot.module.cylinder.api.entity.ESCylinderFillingRecordDto">
SELECT
ci.unit_name AS unit_name,
......@@ -198,31 +213,27 @@
ct.electronic_label_code,
ci.app_id,
ci.credit_code,
tn.region_code
tn.region_code,
concat(ci.app_id, ci.sequence_code) AS appIdAndSequenceCode
FROM
tz_cylinder_info AS ci
LEFT JOIN cb_data_dictionary AS d1 ON d1.TYPE = 'CZJZMC' AND d1.code = ci.filling_media
LEFT JOIN cb_data_dictionary AS d2 ON d2.sequence_nbr = ci.cylinder_variety
LEFT JOIN tz_cylinder_tags AS ct ON ct.sequence_code = ci.sequence_code and ct.app_id = ci.app_id
LEFT JOIN tz_cylinder_unit AS tn ON ci.app_id = tn.app_id
where
ci.sequence_code = #{sequenceCode}
and ci.app_id = #{appId}
</select>
<select id="getCylinderFillingRecordTotal" resultType="java.lang.Integer">
SELECT
COUNT(1)
FROM
tz_cylinder_filling_record r
LEFT JOIN tz_cylinder_filling b ON b.filling_before_id = r.filling_before_id
AND r.filling_before_id IS NOT NULL
AND date_format ( b.inspection_date, '%Y-%m-%d' ) = date_format ( r.filling_startTime, '%Y-%m-%d' )
LEFT JOIN tz_cylinder_filling_check af ON af.filling_check_id = r.filling_check_id
AND date_format ( af.inspection_date, '%Y-%m-%d' ) = date_format ( r.filling_startTime, '%Y-%m-%d' )
LEFT JOIN tz_cylinder_info i ON b.sequence_code = i.sequence_code
WHERE
r.is_not_es IS NULL
AND b.inspection_date NOT LIKE'16%'
<where>
<if test="appIds != null and appIds.size() > 0">
ci.app_id in
<foreach item="appId" collection="appIds" separator="," open="(" close=")" index="">
#{appId}
</foreach>
</if>
<if test="sequenceCodeS != null and sequenceCodeS.size() > 0">
and ci.sequence_code in
<foreach item="sequenceCode" collection="sequenceCodeS" separator="," open="(" close=")" index="">
#{sequenceCode}
</foreach>
</if>
</where>
</select>
</mapper>
......@@ -601,7 +601,7 @@ public class CylinderInfoController extends BaseController {
cylinderInfoPage.setCurrent(1);
cylinderInfoPage.setSize(1000);
cylinderInfoPage = cylinderInfoServiceImpl.getCyinderInfoList(cylinderInfoPage);
if (!ObjectUtils.isEmpty(cylinderInfoPage)) {
if (!ObjectUtils.isEmpty(cylinderInfoPage) && cylinderInfoPage.getRecords().size() > 0) {
cylinderInfoServiceImpl.saveCylinderInfo2ES(cylinderInfoPage.getRecords());
}
return ResponseHelper.buildResponse(true);
......@@ -639,45 +639,19 @@ public class CylinderInfoController extends BaseController {
return ResponseHelper.buildResponse(pageResult);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@TycloudOperation(ApiLevel = UserType.AGENCY ,needAuth = false)
@GetMapping(value = "/saveCyinderFillingRecord")
@ApiOperation(httpMethod = "GET", value = "气瓶充装信息存入es", notes = "气瓶充装信息存入es")
public void saveCyinderFillingRecord() {
Page<ESCylinderFillingRecordDto> recordDtoPage = new Page<>();
Integer count = cylinderFillingRecordServiceImpl.getCylinderFillingRecordTotal();
Integer times = 0;
if (count != 0) {
times = count / 1000;
int last = count % 1000;
if (last > 0) {
times++;
}
} else {
return;
}
for (int i = 0; i <= times; i++) {
recordDtoPage.setCurrent(1);
recordDtoPage.setSize(1000);
Page<ESCylinderFillingRecordDto> cyinderFillingRecord = cylinderFillingRecordServiceImpl.getCyinderFillingRecord(recordDtoPage);
if (!ObjectUtils.isEmpty(cyinderFillingRecord)) {
cylinderFillingRecordServiceImpl.saveCylinderFillingRecord2ES(cyinderFillingRecord.getRecords());
}
}
public ResponseModel<Object> saveCyinderFillingRecord() {
return ResponseHelper.buildResponse(cylinderFillingRecordServiceImpl.getCylinderFillingRecordAll());
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@GetMapping(value = "/getCyinderFillingRecord")
@ApiOperation(httpMethod = "GET", value = "气瓶充装信息存入es入口", notes = "气瓶充装信息存入es入口")
public Page<ESCylinderFillingRecordDto> getCyinderFillingRecord() {
Page<ESCylinderFillingRecordDto> cylinderInfoPage = new Page<>();
cylinderInfoPage.setCurrent(1);
cylinderInfoPage.setSize(10);
Page<ESCylinderFillingRecordDto> cyinderFillingRecord = cylinderFillingRecordServiceImpl.getCyinderFillingRecord(cylinderInfoPage);
for (ESCylinderFillingRecordDto ci : cyinderFillingRecord.getRecords()) {
cylinderFillingRecordServiceImpl.saveCylinderFillingRecordToES(ci);
}
return cyinderFillingRecord;
public ResponseModel<Object> getCyinderFillingRecord() {
return ResponseHelper.buildResponse(cylinderFillingRecordServiceImpl.getCylinderFillingRecordTest());
}
......
......@@ -744,7 +744,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
});
}
// @Scheduled(cron = "${tzs.cylinder.info.cron}")
@Scheduled(cron = "${tzs.cylinder.info.cron}")
@SchedulerLock(name = "cylinderInfoToESTask", lockAtMostFor = "PT6H")
public void setTimeSaveCylinderInfoToES() {
Page<CylinderInfoDto> cylinderInfoPage = new Page<>();
......@@ -778,6 +778,11 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
ESCylinderInfoDto esCylinderInfo = new ESCylinderInfoDto();
BeanUtils.copyProperties(record, esCylinderInfo);
esCylinderInfoDto.add(esCylinderInfo);
try {
esCylinderInfo.setInspectionDateMs(ObjectUtils.isEmpty(esCylinderInfo.getInspectionDate()) ? 0L : DateUtils.dateParse(esCylinderInfo.getInspectionDate(), DateUtils.DATE_TIME_PATTERN).getTime());
} catch (ParseException e) {
throw new RuntimeException(e);
}
ids.add(String.valueOf(record.getSequenceNbr()));
}
StopWatch stopWatch = new StopWatch();
......
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