Commit 181926e9 authored by suhuiguang's avatar suhuiguang

1.报检规则增加不予处理

parent ccaea804
...@@ -13,10 +13,10 @@ import com.yeejoin.amos.boot.module.jyjc.api.model.InspectionEquipInfoModel; ...@@ -13,10 +13,10 @@ import com.yeejoin.amos.boot.module.jyjc.api.model.InspectionEquipInfoModel;
import com.yeejoin.amos.boot.module.jyjc.biz.event.listener.InspectionApplicationPushEventListener; import com.yeejoin.amos.boot.module.jyjc.biz.event.listener.InspectionApplicationPushEventListener;
import com.yeejoin.amos.boot.module.jyjc.biz.listener.message.BizMessage; import com.yeejoin.amos.boot.module.jyjc.biz.listener.message.BizMessage;
import com.yeejoin.amos.boot.module.jyjc.biz.rule.InspectionEquipInfo; import com.yeejoin.amos.boot.module.jyjc.biz.rule.InspectionEquipInfo;
import com.yeejoin.amos.boot.module.jyjc.biz.service.impl.RuleCommonServiceImpl;
import com.yeejoin.amos.boot.module.ymt.api.entity.RegistrationInfo; import com.yeejoin.amos.boot.module.ymt.api.entity.RegistrationInfo;
import com.yeejoin.amos.boot.module.ymt.api.mapper.RegistrationInfoMapper; import com.yeejoin.amos.boot.module.ymt.api.mapper.RegistrationInfoMapper;
import com.yeejoin.amos.component.robot.AmosRequestContext; import com.yeejoin.amos.component.robot.AmosRequestContext;
import com.yeejoin.amos.component.rule.RuleTrigger;
import com.yeejoin.amos.feign.rule.Rule; import com.yeejoin.amos.feign.rule.Rule;
import com.yeejoin.amos.feign.rule.model.FactBaseModel; import com.yeejoin.amos.feign.rule.model.FactBaseModel;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -53,12 +53,13 @@ public class InspectionOrgRefreshListener extends EmqxListener { ...@@ -53,12 +53,13 @@ public class InspectionOrgRefreshListener extends EmqxListener {
@Value("${inspection.rule.project-name:报检规则}") @Value("${inspection.rule.project-name:报检规则}")
private String ruleName; private String ruleName;
@Autowired @Autowired
private EmqKeeper emqKeeper; private EmqKeeper emqKeeper;
@Autowired
private RuleTrigger ruleTrigger;
@Autowired @Autowired
private AmosRequestContext amosRequestContext; private AmosRequestContext amosRequestContext;
@Autowired @Autowired
private RegistrationInfoMapper registrationInfoMapper; private RegistrationInfoMapper registrationInfoMapper;
...@@ -74,13 +75,14 @@ public class InspectionOrgRefreshListener extends EmqxListener { ...@@ -74,13 +75,14 @@ public class InspectionOrgRefreshListener extends EmqxListener {
@Autowired @Autowired
Sequence sequence; Sequence sequence;
@Autowired private static final int REPEAT_TIME = 2;
private static final int repeatTime = 2;
@Autowired @Autowired
RedisUtils redisUtils; RedisUtils redisUtils;
@Autowired
RuleCommonServiceImpl ruleCommonService;
@Override @Override
public void processMessage(String topic, MqttMessage message) { public void processMessage(String topic, MqttMessage message) {
if (log.isInfoEnabled()) { if (log.isInfoEnabled()) {
...@@ -105,10 +107,10 @@ public class InspectionOrgRefreshListener extends EmqxListener { ...@@ -105,10 +107,10 @@ public class InspectionOrgRefreshListener extends EmqxListener {
BizMessage bizMessage = BLOCKING_QUEUE.take(); BizMessage bizMessage = BLOCKING_QUEUE.take();
// 解决前端组件在属性变化时重复发送两次问题 // 解决前端组件在属性变化时重复发送两次问题
if (!redisUtils.hasKey(bizMessage.getTopic())) { if (!redisUtils.hasKey(bizMessage.getTopic())) {
redisUtils.set(bizMessage.getTopic(), true, repeatTime); redisUtils.set(bizMessage.getTopic(), true, REPEAT_TIME);
processBizMessage(bizMessage); processBizMessage(bizMessage);
} else { } else {
log.warn("消息在{}秒内重复,", repeatTime); log.warn("消息在{}秒内重复,", REPEAT_TIME);
} }
} catch (Exception e) { } catch (Exception e) {
log.error("数据处理失败", e); log.error("数据处理失败", e);
...@@ -133,21 +135,31 @@ public class InspectionOrgRefreshListener extends EmqxListener { ...@@ -133,21 +135,31 @@ public class InspectionOrgRefreshListener extends EmqxListener {
inspectionEquipInfo.setRecord(equipInfoModel.getRecord()); inspectionEquipInfo.setRecord(equipInfoModel.getRecord());
inspectionEquipInfo.setBizType(getCategoryByType(JYJCTypeEnum.of(inspectionEquipInfo.getInspectionType()))); inspectionEquipInfo.setBizType(getCategoryByType(JYJCTypeEnum.of(inspectionEquipInfo.getInspectionType())));
inspectionEquipInfo.setUuid(sequence.nextId() + ""); inspectionEquipInfo.setUuid(sequence.nextId() + "");
inspectionEquipInfo.setRequestType(this.buildRequestType(equipInfoModel));
inspectionEquipInfo.setTechParams(this.getTechParams(registrationInfo)); inspectionEquipInfo.setTechParams(this.getTechParams(registrationInfo));
inspectionEquipInfo.setAreaCode(ruleCommonService.getArea(equipInfoModel.getRecord()));
JyjcInspectionApplicationNoAcceptLog jyjcInspectionApplicationNoAcceptLog = getLastNoAcceptLog(equipInfoModel);
inspectionEquipInfo.setRequestType(this.buildRequestType(equipInfoModel, jyjcInspectionApplicationNoAcceptLog));
inspectionEquipInfo.setLastNoAcceptInspectionCode(this.buildLastNoAcceptInspectionCode(jyjcInspectionApplicationNoAcceptLog));
touchRuleWithApi(inspectionEquipInfo); touchRuleWithApi(inspectionEquipInfo);
} }
private String buildLastNoAcceptInspectionCode(JyjcInspectionApplicationNoAcceptLog jyjcInspectionApplicationNoAcceptLog) {
if (jyjcInspectionApplicationNoAcceptLog != null) {
return jyjcInspectionApplicationNoAcceptLog.getInspectionUnitCode();
}
return "";
}
private Map<String, Object> getTechParams(RegistrationInfo registrationInfo) { private Map<String, Object> getTechParams(RegistrationInfo registrationInfo) {
return applicationPushEventListener.populateEquipInfoWithTechParams(registrationInfo.getEquList(), registrationInfo.getRecord()); return applicationPushEventListener.populateEquipInfoWithTechParams(registrationInfo.getEquList(), registrationInfo.getRecord());
} }
private String buildRequestType(InspectionEquipInfoModel equipInfoModel) { private String buildRequestType(InspectionEquipInfoModel equipInfoModel, JyjcInspectionApplicationNoAcceptLog jyjcInspectionApplicationNoAcceptLog) {
// 工作台发起申请 // 工作台发起申请
if (StringUtils.isEmpty(equipInfoModel.getAppSeq())) { if (StringUtils.isEmpty(equipInfoModel.getAppSeq())) {
return RequestTypeEnum.FIRST_REQUEST.getCode(); return RequestTypeEnum.FIRST_REQUEST.getCode();
} }
JyjcInspectionApplicationNoAcceptLog jyjcInspectionApplicationNoAcceptLog = getLastNoAcceptLog(equipInfoModel);
// 没有不予受理请求记录 // 没有不予受理请求记录
if (jyjcInspectionApplicationNoAcceptLog == null) { if (jyjcInspectionApplicationNoAcceptLog == null) {
return RequestTypeEnum.FIRST_REQUEST.getCode(); return RequestTypeEnum.FIRST_REQUEST.getCode();
...@@ -159,7 +171,7 @@ public class InspectionOrgRefreshListener extends EmqxListener { ...@@ -159,7 +171,7 @@ public class InspectionOrgRefreshListener extends EmqxListener {
private JyjcInspectionApplicationNoAcceptLog getLastNoAcceptLog(InspectionEquipInfoModel equipInfoModel) { private JyjcInspectionApplicationNoAcceptLog getLastNoAcceptLog(InspectionEquipInfoModel equipInfoModel) {
LambdaQueryWrapper<JyjcInspectionApplicationNoAcceptLog> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<JyjcInspectionApplicationNoAcceptLog> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(JyjcInspectionApplicationNoAcceptLog::getApplicationSeq, equipInfoModel.getAppSeq()); wrapper.eq(JyjcInspectionApplicationNoAcceptLog::getApplicationSeq, equipInfoModel.getAppSeq());
wrapper.orderByDesc(JyjcInspectionApplicationNoAcceptLog::getNoAcceptDate); wrapper.orderByDesc(JyjcInspectionApplicationNoAcceptLog::getRecDate);
wrapper.last("limit 1"); wrapper.last("limit 1");
wrapper.select(JyjcInspectionApplicationNoAcceptLog::getApplicationSeq, JyjcInspectionApplicationNoAcceptLog::getInspectionUnitCode); wrapper.select(JyjcInspectionApplicationNoAcceptLog::getApplicationSeq, JyjcInspectionApplicationNoAcceptLog::getInspectionUnitCode);
return inspectionApplicationNoAcceptLogMapper.selectOne(wrapper); return inspectionApplicationNoAcceptLogMapper.selectOne(wrapper);
...@@ -172,22 +184,6 @@ public class InspectionOrgRefreshListener extends EmqxListener { ...@@ -172,22 +184,6 @@ public class InspectionOrgRefreshListener extends EmqxListener {
.eq(RegistrationInfo::getRecord, record)); .eq(RegistrationInfo::getRecord, record));
} }
private void touchRuleWithMsg(InspectionEquipInfo inspectionEquipInfo) {
if (log.isInfoEnabled()) {
log.info("发送规则的消息对象:{}", toJSONString(inspectionEquipInfo));
}
RequestContext.setToken(amosRequestContext.getToken());
RequestContext.setAppKey(amosRequestContext.getAppKey());
RequestContext.setProduct(amosRequestContext.getProduct());
// 2.调用规则
try {
ruleTrigger.publish(inspectionEquipInfo, ruleName + "/" + inspectionEquipInfo.getBizType(), null);
} catch (Exception e) {
log.error("调用规则触发获取报检规则失败", e);
}
}
private void touchRuleWithApi(InspectionEquipInfo inspectionEquipInfo) { private void touchRuleWithApi(InspectionEquipInfo inspectionEquipInfo) {
if (log.isInfoEnabled()) { if (log.isInfoEnabled()) {
log.info("发送规则的消息对象:{}", toJSONString(inspectionEquipInfo)); log.info("发送规则的消息对象:{}", toJSONString(inspectionEquipInfo));
......
...@@ -51,4 +51,7 @@ public class InspectionEquipInfo implements Serializable { ...@@ -51,4 +51,7 @@ public class InspectionEquipInfo implements Serializable {
@ApiModelProperty(value = "最近不受理检验机构code") @ApiModelProperty(value = "最近不受理检验机构code")
private String lastNoAcceptInspectionCode; private String lastNoAcceptInspectionCode;
@ApiModelProperty(value = "所在区域")
private String areaCode;
} }
...@@ -177,6 +177,12 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec ...@@ -177,6 +177,12 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
private static final String SUMMIT_TYPE = "0"; private static final String SUMMIT_TYPE = "0";
/**
* 省特检院等特殊公司code
*/
@Value("${shanxi.tjy.code:126100004352004822}")
private String shanxiCompanyCode;
@Autowired @Autowired
RestHighLevelClient restHighLevelClient; RestHighLevelClient restHighLevelClient;
...@@ -565,6 +571,7 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec ...@@ -565,6 +571,7 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
public Map<String, Object> selectBySeq(Long sequenceNbr) { public Map<String, Object> selectBySeq(Long sequenceNbr) {
JyjcInspectionApplicationModel model = this.getBaseMapper().selectDataBySeq(sequenceNbr); JyjcInspectionApplicationModel model = this.getBaseMapper().selectDataBySeq(sequenceNbr);
int times = noAcceptLogService.count(new LambdaQueryWrapper<JyjcInspectionApplicationNoAcceptLog>().eq(JyjcInspectionApplicationNoAcceptLog::getApplicationSeq, sequenceNbr).eq(JyjcInspectionApplicationNoAcceptLog::getInspectionUnitCode,shanxiCompanyCode));
Map<String, Object> map = BeanUtil.beanToMap(model); Map<String, Object> map = BeanUtil.beanToMap(model);
List<Map<String, Object>> dataByApplicationSeq = jyjcInspectionApplicationAttachmentService.getBaseMapper().getDataByApplicationSeq(sequenceNbr); List<Map<String, Object>> dataByApplicationSeq = jyjcInspectionApplicationAttachmentService.getBaseMapper().getDataByApplicationSeq(sequenceNbr);
Map<String, Object> attMap = new HashMap<>(); Map<String, Object> attMap = new HashMap<>();
...@@ -599,6 +606,8 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec ...@@ -599,6 +606,8 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
map.put("equip", arrayList); map.put("equip", arrayList);
} }
map.putAll(attMap); map.putAll(attMap);
// 陕西特检验院不予首次的次数
map.put("sytjybyslcs",times);
this.setPlanData(sequenceNbr, map); this.setPlanData(sequenceNbr, map);
return map; return map;
} }
...@@ -869,7 +878,7 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec ...@@ -869,7 +878,7 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
task.setTaskId(taskId); task.setTaskId(taskId);
task.setComment(params.getOrDefault("comments", "").toString()); task.setComment(params.getOrDefault("comments", "").toString());
HashMap<String, Object> map = new HashMap<>(); HashMap<String, Object> map = new HashMap<>();
map.put("approvalStatus", "1"); map.put("approvalStatus", "8");
task.setVariable(map); task.setVariable(map);
//执行流程 //执行流程
task.setNextExecuteUserCompanyCode(model.getInspectionUnitCode()); task.setNextExecuteUserCompanyCode(model.getInspectionUnitCode());
...@@ -1063,7 +1072,7 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec ...@@ -1063,7 +1072,7 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
TaskModelDto modelDto = new TaskModelDto(); TaskModelDto modelDto = new TaskModelDto();
BeanUtil.copyProperties(taskV2Model, modelDto); BeanUtil.copyProperties(taskV2Model, modelDto);
modelDto.setNextExecuteUser(model.getNextExecuteIds()); modelDto.setNextExecuteUser(model.getNextExecuteIds());
if (model.getStatus().equals(FlowStatusEnum.REJECTED.getCode() + "") || model.getStatus().equals(FlowStatusEnum.NO_ACCEPT.getCode() + "")) { if (model.getStatus().equals(FlowStatusEnum.REJECTED.getCode() + "")) {
modelDto.setPageType("edit"); modelDto.setPageType("edit");
} }
TaskMessageDto obj = new TaskMessageDto(); TaskMessageDto obj = new TaskMessageDto();
......
package com.yeejoin.amos.boot.module.jyjc.biz.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yeejoin.amos.boot.module.ymt.api.entity.UseInfo;
import com.yeejoin.amos.boot.module.ymt.api.mapper.UseInfoMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import java.util.Arrays;
/**
* @author Administrator
*/
@Component
public class RuleCommonServiceImpl {
private UseInfoMapper useInfoMapper;
/**
* 特殊独立的区县
*/
private static final String[] EXCLUSION_CITY_REGIONS = {"610403", "610581"};
public RuleCommonServiceImpl(UseInfoMapper useInfoMapper) {
this.useInfoMapper = useInfoMapper;
}
public String getArea(String record) {
UseInfo equipUseInfo = useInfoMapper.selectOne(Wrappers.<UseInfo>lambdaQuery().select(UseInfo::getCity, UseInfo::getCounty).eq(UseInfo::getRecord, record));
if (equipUseInfo == null) {
return "";
}
// 特殊地区特殊处理,目前有韩城、杨凌,原因行政区划上是有层级的,但是业务办理时,他们与所在地市是同级别的
if (StringUtils.isEmpty(equipUseInfo.getCity()) || StringUtils.isEmpty(equipUseInfo.getCounty())) {
return "";
}
if (Arrays.asList(EXCLUSION_CITY_REGIONS).contains(equipUseInfo.getCounty())) {
return equipUseInfo.getCounty();
}
return equipUseInfo.getCity();
}
}
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