Commit 2f4ed3f9 authored by tianyiming's avatar tianyiming

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

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