Commit 52ac1bea authored by suhuiguang's avatar suhuiguang

1.增加调用规则代码-tzs

parent 93144e2c
...@@ -134,4 +134,7 @@ public class CylinderInfoDto extends BaseDto { ...@@ -134,4 +134,7 @@ public class CylinderInfoDto extends BaseDto {
@ApiModelProperty(value = "客户类型") @ApiModelProperty(value = "客户类型")
private String customName; private String customName;
@ApiModelProperty(value = "联系电话")
private String contactPhone;
} }
...@@ -93,7 +93,8 @@ ...@@ -93,7 +93,8 @@
ci.latitude, ci.latitude,
eu.address, eu.address,
eu.custom_name, eu.custom_name,
eu.custom_type eu.custom_type,
eu.contact_phone
from from
tz_cylinder_info ci tz_cylinder_info ci
left join tz_end_user eu on ci.end_custom_code = eu.custom_code left join tz_end_user eu on ci.end_custom_code = eu.custom_code
......
...@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; ...@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.biz.common.utils.DateUtils; import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.tzs.api.dto.CylWarningMsgDto;
import com.yeejoin.amos.boot.module.tzs.api.entity.MsgLog; import com.yeejoin.amos.boot.module.tzs.api.entity.MsgLog;
import com.yeejoin.amos.boot.module.tzs.api.enums.EarlyWarningLevelEnum; import com.yeejoin.amos.boot.module.tzs.api.enums.EarlyWarningLevelEnum;
import com.yeejoin.amos.boot.module.tzs.biz.service.impl.MsgLogServiceImpl; import com.yeejoin.amos.boot.module.tzs.biz.service.impl.MsgLogServiceImpl;
...@@ -15,6 +16,7 @@ import com.yeejoin.amos.boot.module.tzs.flc.api.service.ICylinderInfoService; ...@@ -15,6 +16,7 @@ import com.yeejoin.amos.boot.module.tzs.flc.api.service.ICylinderInfoService;
import com.yeejoin.amos.component.rule.RuleTrigger; import com.yeejoin.amos.component.rule.RuleTrigger;
import com.yeejoin.amos.feign.systemctl.Systemctl; import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.RegionModel; import com.yeejoin.amos.feign.systemctl.model.RegionModel;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
...@@ -23,7 +25,6 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -23,7 +25,6 @@ import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.function.Consumer; import java.util.function.Consumer;
...@@ -36,6 +37,7 @@ import java.util.function.IntConsumer; ...@@ -36,6 +37,7 @@ import java.util.function.IntConsumer;
* @date 2021-12-14 * @date 2021-12-14
*/ */
@Service @Service
@Slf4j
public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, CylinderInfo, CylinderInfoMapper> implements ICylinderInfoService { public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, CylinderInfo, CylinderInfoMapper> implements ICylinderInfoService {
...@@ -588,12 +590,14 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind ...@@ -588,12 +590,14 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
} }
public void calEarlyWarningLevel() { public void calEarlyWarningLevel() {
if (log.isDebugEnabled()) {
log.debug("气瓶超期预警时间调用规则开始");
}
// 1.批量分组大小 // 1.批量分组大小
int size = 1000; int size = 500;
int total = this.count(); int total = this.count();
int groupNumber = total / size + 1; int groupNumber = total / size + 1;
Date now = new Date(); // 2.批量小分组处理数据,调用规则
// 2.批量小分组处理数据
for (int i = 0; i < groupNumber; i++) { for (int i = 0; i < groupNumber; i++) {
Page<CylinderInfo> page = new Page<>(); Page<CylinderInfo> page = new Page<>();
page.setCurrent(i); page.setCurrent(i);
...@@ -601,19 +605,36 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind ...@@ -601,19 +605,36 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
LambdaQueryWrapper<CylinderInfo> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CylinderInfo> wrapper = new LambdaQueryWrapper<>();
wrapper.orderByDesc(CylinderInfo::getSequenceNbr); wrapper.orderByDesc(CylinderInfo::getSequenceNbr);
IPage<CylinderInfo> result = this.page(page, wrapper); IPage<CylinderInfo> result = this.page(page, wrapper);
result.getRecords().forEach(r -> { for (CylinderInfo r : result.getRecords()) {
try { this.touchRuleToCalLevel(r);
int interval = DateUtils.dateBetweenIncludeToday(r.getNextInspectionDate(), now);
// TODO 循环调用规则 触发计算等级
// ruleTrigger.publish(equipmentInputItemRo, packageld, null);
} catch (ParseException e) {
log.error(JSON.toJSONString(r) + "格式化失败");
} }
});
this.updateBatchById(result.getRecords());
} }
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("气瓶超期预警时间更新完成"); log.debug("气瓶超期预警时间调用规则完成");
}
}
private void touchRuleToCalLevel(CylinderInfo r) {
Date now = new Date();
//1.气瓶详情
CylinderInfoDto cylinderInfoDto = this.getDetail(r.getSequenceCode());
try {
CylWarningMsgDto cylWarningMsgDto = new CylWarningMsgDto();
int interval = DateUtils.dateBetweenIncludeToday(cylinderInfoDto.getNextInspectionDate(), now);
cylWarningMsgDto.setNum(String.valueOf(interval));
cylWarningMsgDto.setFactoryNum(cylinderInfoDto.getFactoryNum());
cylWarningMsgDto.setUserType(cylinderInfoDto.getCustomType());
cylWarningMsgDto.setUserPeople(cylinderInfoDto.getCustomName());
cylWarningMsgDto.setUserPeoplePhone(cylinderInfoDto.getContactPhone());
cylWarningMsgDto.setCylSeq(cylinderInfoDto.getSequenceCode());
cylWarningMsgDto.setCompanyName(cylinderInfoDto.getUnitName());
// 2.循环调用规则 触发计算等级及发送消息
if (log.isInfoEnabled()) {
log.info("调用规则对象!+:{}", JSON.toJSONString(cylWarningMsgDto));
}
ruleTrigger.publish(cylWarningMsgDto, "气瓶监管", null);
} catch (Exception e) {
log.error("调用规则失败!:{}", JSON.toJSONString(cylinderInfoDto));
} }
} }
...@@ -626,7 +647,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind ...@@ -626,7 +647,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
public List<MsgLog> getMsgList(String sequenceCode, String terminalType) { public List<MsgLog> getMsgList(String sequenceCode, String terminalType) {
LambdaQueryWrapper<MsgLog> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<MsgLog> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(MsgLog::getRelationCode, sequenceCode); wrapper.eq(MsgLog::getRelationCode, sequenceCode);
wrapper.eq(StringUtils.isNotEmpty(terminalType),MsgLog::getTerminalType,terminalType); wrapper.eq(StringUtils.isNotEmpty(terminalType), MsgLog::getTerminalType, terminalType);
wrapper.orderByDesc(MsgLog::getSendTime); wrapper.orderByDesc(MsgLog::getSendTime);
return msgLogService.list(wrapper); return msgLogService.list(wrapper);
} }
...@@ -640,17 +661,18 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind ...@@ -640,17 +661,18 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
} }
public Boolean nextInspectionDateUpdate(List<CylinderInfoDto> cylinderInfoDtos) { public Boolean nextInspectionDateUpdate(List<CylinderInfoDto> cylinderInfoDtos) {
// 1.更新下次检验日期
List<CylinderInfo> cylinderInfos = new ArrayList<>(); List<CylinderInfo> cylinderInfos = new ArrayList<>();
cylinderInfoDtos.forEach(c->{ cylinderInfoDtos.forEach(c -> {
CylinderInfo cylinderInfo = this.getOne(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getSequenceCode,c.getSequenceCode())); CylinderInfo cylinderInfo = this.getOne(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getSequenceCode, c.getSequenceCode()));
cylinderInfo.setNextInspectionDate(c.getNextInspectionDate()); cylinderInfo.setNextInspectionDate(c.getNextInspectionDate());
cylinderInfos.add(cylinderInfo); cylinderInfos.add(cylinderInfo);
// TODO 循环调用规则 触发计算等级及发送消息
// ruleTrigger.publish(equipmentInputItemRo, packageld, null);
}); });
if(!cylinderInfos.isEmpty()){ if (!cylinderInfos.isEmpty()) {
this.updateBatchById(cylinderInfos); this.updateBatchById(cylinderInfos);
} }
// 2.循环调用规则 触发计算等级及发送消息
cylinderInfos.forEach(this::touchRuleToCalLevel);
return Boolean.TRUE; return Boolean.TRUE;
} }
} }
\ No newline at end of file
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