Commit cc1553af authored by tianyiming's avatar tianyiming

修改气瓶基本信息、充装信息同步es接口

parent 5699726c
...@@ -56,4 +56,6 @@ public interface CylinderFillingRecordMapper extends BaseMapper<CylinderFillingR ...@@ -56,4 +56,6 @@ 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); ESCylinderFillingRecordDto getCyinderFillingRecordInfo(String appId, String sequenceCode);
Integer getCylinderFillingRecordTotal();
} }
...@@ -84,4 +84,7 @@ public interface CylinderInfoMapper extends BaseMapper<CylinderInfo> { ...@@ -84,4 +84,7 @@ public interface CylinderInfoMapper extends BaseMapper<CylinderInfo> {
Page<CylinderInfoDto> getCyinderInfoList(Page<CylinderInfoDto> page); Page<CylinderInfoDto> getCyinderInfoList(Page<CylinderInfoDto> page);
Page<CylinderInfoDto> cyinderOutInfoList(Page<CylinderInfoDto> page, CylinderInfoDto cylinderInfoDto, String sort, List<String> appids); Page<CylinderInfoDto> cyinderOutInfoList(Page<CylinderInfoDto> page, CylinderInfoDto cylinderInfoDto, String sort, List<String> appids);
Integer getInfoTotal();
} }
...@@ -21,4 +21,6 @@ public interface ICylinderFillingRecordService { ...@@ -21,4 +21,6 @@ public interface ICylinderFillingRecordService {
Page<ESCylinderFillingRecordDto> queryByKeys(ESCylinderFillingRecordDto esCylinderFillingRecordDto, int pageNum, int pageSize); Page<ESCylinderFillingRecordDto> queryByKeys(ESCylinderFillingRecordDto esCylinderFillingRecordDto, int pageNum, int pageSize);
void saveCylinderFillingRecord2ES(List<ESCylinderFillingRecordDto> records); void saveCylinderFillingRecord2ES(List<ESCylinderFillingRecordDto> records);
Integer getCylinderFillingRecordTotal();
} }
...@@ -52,4 +52,6 @@ public interface ICylinderInfoService { ...@@ -52,4 +52,6 @@ public interface ICylinderInfoService {
Page<ESCylinderInfoDto> queryByKeys(CylinderInfoDto cylinderInfoDto, int pageNum, int pageSize); Page<ESCylinderInfoDto> queryByKeys(CylinderInfoDto cylinderInfoDto, int pageNum, int pageSize);
void saveCylinderInfo2ES(List<CylinderInfoDto> records); void saveCylinderInfo2ES(List<CylinderInfoDto> records);
Integer getInfoTotal();
} }
...@@ -209,4 +209,20 @@ ...@@ -209,4 +209,20 @@
ci.sequence_code = #{sequenceCode} ci.sequence_code = #{sequenceCode}
and ci.app_id = #{appId} and ci.app_id = #{appId}
</select> </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%'
</select>
</mapper> </mapper>
...@@ -324,4 +324,18 @@ ...@@ -324,4 +324,18 @@
where ci.is_not_es IS NULL where ci.is_not_es IS NULL
AND region_code is not null AND region_code is not null
</select> </select>
<select id="getInfoTotal" resultType="java.lang.Integer">
SELECT
count(1)
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 cb_data_dictionary AS d3 ON d3.sequence_nbr = ci.cylinder_status
LEFT JOIN tz_cylinder_tags AS ct ON ct.sequence_code = ci.sequence_code
LEFT JOIN tz_cylinder_unit AS cu ON ci.app_id = cu.app_id
where ci.is_not_es IS NULL
AND region_code is not null
</select>
</mapper> </mapper>
...@@ -567,27 +567,29 @@ public class CylinderInfoController extends BaseController { ...@@ -567,27 +567,29 @@ public class CylinderInfoController extends BaseController {
@GetMapping(value = "/saveCyinderInfo") @GetMapping(value = "/saveCyinderInfo")
@ApiOperation(httpMethod = "GET", value = "气瓶基本信息存入es", notes = "气瓶基本信息存入es") @ApiOperation(httpMethod = "GET", value = "气瓶基本信息存入es", notes = "气瓶基本信息存入es")
public void saveCyinderInfo() { public void saveCyinderInfo() {
Page<CylinderInfoDto> cylinderInfoPage = new Page<>(); Page<CylinderInfoDto> cylinderInfoPage = new Page<>();
Integer count = cylinderInfoServiceImpl.count(); Integer count = cylinderInfoServiceImpl.getInfoTotal();
Integer times = 0; Integer times = 0;
if (count != 0) { if (count != 0) {
times = count / 1000; times = count / 1000;
int last = count % 1000; int last = count % 1000;
if (last > 0) { if (last > 0) {
times++; times++;
} }
} } else {
for (int i = 0; i <= times; i++) { return;
cylinderInfoPage.setCurrent(i); }
cylinderInfoPage.setSize(1000); for (int i = 0; i <= times; i++) {
cylinderInfoPage = cylinderInfoServiceImpl.getCyinderInfoList(cylinderInfoPage); cylinderInfoPage.setCurrent(i);
if(!ObjectUtils.isEmpty(cylinderInfoPage)){ cylinderInfoPage.setSize(1000);
cylinderInfoPage = cylinderInfoServiceImpl.getCyinderInfoList(cylinderInfoPage);
if (!ObjectUtils.isEmpty(cylinderInfoPage)) {
cylinderInfoServiceImpl.saveCylinderInfo2ES(cylinderInfoPage.getRecords()); cylinderInfoServiceImpl.saveCylinderInfo2ES(cylinderInfoPage.getRecords());
} }
// for (CylinderInfoDto ci : cylinderInfoPage.getRecords()) { // for (CylinderInfoDto ci : cylinderInfoPage.getRecords()) {
// cylinderInfoServiceImpl.saveCylinderInfoToES(ci); // cylinderInfoServiceImpl.saveCylinderInfoToES(ci);
// } // }
} }
} }
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
...@@ -640,31 +642,30 @@ public class CylinderInfoController extends BaseController { ...@@ -640,31 +642,30 @@ public class CylinderInfoController extends BaseController {
@GetMapping(value = "/saveCyinderFillingRecord") @GetMapping(value = "/saveCyinderFillingRecord")
@ApiOperation(httpMethod = "GET", value = "气瓶充装信息存入es", notes = "气瓶充装信息存入es") @ApiOperation(httpMethod = "GET", value = "气瓶充装信息存入es", notes = "气瓶充装信息存入es")
public void saveCyinderFillingRecord() { public void saveCyinderFillingRecord() {
Page<ESCylinderFillingRecordDto> recordDtoPage = new Page<>(); Page<ESCylinderFillingRecordDto> recordDtoPage = new Page<>();
Integer count = cylinderFillingRecordServiceImpl.count(); Integer count = cylinderFillingRecordServiceImpl.getCylinderFillingRecordTotal();
Integer times = 0; Integer times = 0;
if (count != 0) { if (count != 0) {
times = count / 1000; times = count / 1000;
int last = count % 1000; int last = count % 1000;
if (last > 0) { if (last > 0) {
times++; times++;
} }
} } else {
for (int i = 0; i <= times; i++) { return;
recordDtoPage.setCurrent(i); }
recordDtoPage.setSize(1000); for (int i = 0; i <= times; i++) {
recordDtoPage.setCurrent(1);
recordDtoPage.setSize(1000);
// CylinderFillingRecordDto cylinderFillingRecordDto = new CylinderFillingRecordDto(); // CylinderFillingRecordDto cylinderFillingRecordDto = new CylinderFillingRecordDto();
// if (StringUtils.isEmpty(cylinderFillingRecordDto.getSequenceCode())) { // if (StringUtils.isEmpty(cylinderFillingRecordDto.getSequenceCode())) {
// cylinderFillingRecordDto.setAppId("9B150BB7D0C21A7A62BD6837E14A44BF"); // cylinderFillingRecordDto.setAppId("9B150BB7D0C21A7A62BD6837E14A44BF");
// } // }
Page<ESCylinderFillingRecordDto> cyinderFillingRecord = cylinderFillingRecordServiceImpl.getCyinderFillingRecord(recordDtoPage); Page<ESCylinderFillingRecordDto> cyinderFillingRecord = cylinderFillingRecordServiceImpl.getCyinderFillingRecord(recordDtoPage);
if(!ObjectUtils.isEmpty(cyinderFillingRecord)){ if (!ObjectUtils.isEmpty(cyinderFillingRecord)) {
cylinderFillingRecordServiceImpl.saveCylinderFillingRecord2ES(cyinderFillingRecord.getRecords()); cylinderFillingRecordServiceImpl.saveCylinderFillingRecord2ES(cyinderFillingRecord.getRecords());
} }
// for (ESCylinderFillingRecordDto ci : cyinderFillingRecord.getRecords()) { }
// cylinderFillingRecordServiceImpl.saveCylinderFillingRecordToES(ci);
// }
}
} }
......
...@@ -368,7 +368,12 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin ...@@ -368,7 +368,12 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
cylinderFillingRecordList.add(cylinderFillingRecord); cylinderFillingRecordList.add(cylinderFillingRecord);
} }
esCylinderFillingRecordRepository.saveAll(records); esCylinderFillingRecordRepository.saveAll(records);
this.saveOrUpdateBatch(cylinderFillingRecordList); this.updateBatchById(cylinderFillingRecordList);
}
@Override
public Integer getCylinderFillingRecordTotal() {
return cylinderFillingRecordMapper.getCylinderFillingRecordTotal();
} }
@Override @Override
......
...@@ -733,7 +733,12 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind ...@@ -733,7 +733,12 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
CylinderInfoList.add(cylinderInfo); CylinderInfoList.add(cylinderInfo);
} }
esCylinderInfoRepository.saveAll(esCylinderInfoDto); esCylinderInfoRepository.saveAll(esCylinderInfoDto);
this.saveOrUpdateBatch(CylinderInfoList); this.updateBatchById(CylinderInfoList);
}
@Override
public Integer getInfoTotal() {
return cylinderInfoMapper.getInfoTotal();
} }
@Override @Override
......
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