Commit 0adfe355 authored by suhuiguang's avatar suhuiguang

feat(jyjc): 报检开发调整

1.报检规则4.0开发
parent 73cc8215
......@@ -169,6 +169,12 @@ public class JyjcInspectionApplicationDto extends BaseModel {
@ApiModelProperty(value = "区域信息")
private String cityCode;
@ApiModelProperty(value = "地市")
private String city;
@ApiModelProperty(value = "区县")
private String county;
public String getProcessInstanceId() {
return this.instanceId != null ? this.instanceId : this.processInstanceId;
}
......
......@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.yeejoin.amos.boot.module.jyjc.api.model.InspectionPlanModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
......@@ -46,12 +47,32 @@ public class JyjcInspectionApplication extends BaseEntity {
private String equipClassify;
/**
* 地市
*/
@TableField("city")
private String city;
/**
* 区县
*/
@TableField("county")
private String county;
/**
* 设备类别code
*/
@TableField("equ_category")
private String equCategory;
/**
* 设备品种code
*/
@TableField("equ_define")
private String equDefine;
/**
* 报检单号
*/
@TableField("application_no")
......
......@@ -25,7 +25,8 @@ public enum JYJCTypeEnum {
SCJY("SCJY", "首次检验", "jy", BizTypeEnum.FIRST_INSPECTION.getCode()),
DQJY("DQJY", "定期检验", "jy", BizTypeEnum.FIRST_INSPECTION.getCode()),
WTJY("WTJY", "委托检验", "jy", BizTypeEnum.ENTRUST.getCode()),
DTJC("DTJC", "电梯检测", "jc", BizTypeEnum.DETECTION.getCode());
DTJC("DTJC", "电梯检测", "jc", BizTypeEnum.DETECTION.getCode()),
DQRBI("DQRBI", "基于风险RBI", "jy", BizTypeEnum.FIRST_INSPECTION.getCode());
private final String code;
private final String name;
......
......@@ -23,9 +23,21 @@ public class InspectionEquipInfoModel implements Serializable {
@ApiModelProperty(value = "申请表主键")
private String appSeq;
@ApiModelProperty(value = "设备种类")
private String equList;
@ApiModelProperty(value = "设备类别")
private String equCategory;
@ApiModelProperty(value = "设备品种")
private String equDefine;
@ApiModelProperty(value = "地市")
private String city;
@ApiModelProperty(value = "区县")
private String county;
@ApiModelProperty(value = "主题,无需上送,由topic解析出来")
private String componentKey;
}
package com.yeejoin.amos.boot.module.jyjc.api.model;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
......@@ -154,6 +155,12 @@ public class JyjcInspectionApplicationModel extends BaseModel {
@ApiModelProperty(value = "设备类别code")
private String equCategory;
/**
* 设备品种code
*/
@TableField("equ_define")
private String equDefine;
@ApiModelProperty(value = "监管码")
private String supervisoryCode;
......@@ -170,6 +177,13 @@ public class JyjcInspectionApplicationModel extends BaseModel {
@ApiModelProperty(value = "计划下发日期,统计办理时效使用,来源JyjcInspectionApplication.planCreateDate")
private Date planCreateDate;
@ApiModelProperty(value = "地市")
private String city;
@ApiModelProperty(value = "区县")
private String county;
/**
* 是否必须处理: true-必须处理,false-可不予受理
*/
......
......@@ -45,6 +45,11 @@ public class InspectionRuleEnableConfig {
*/
private Boolean DTJC;
/**
* 委托检验是否启用规则:true-启用,false-不启用
*/
private Boolean WTJY;
public Object getValueByFieldName(String fieldName){
Field field = null;
try {
......
package com.yeejoin.amos.boot.module.jyjc.biz.event;
public interface IRuleDataPrepare {
Boolean supportType();
void handle(InspectionOrgRefreshEvent event);
}
......@@ -10,7 +10,7 @@ import org.springframework.context.ApplicationEvent;
@Getter
public class InspectionOrgRefreshEvent extends ApplicationEvent {
private InspectionEquipInfoModel inspectionEquipInfoModel;
private final InspectionEquipInfoModel inspectionEquipInfoModel;
/**
* Create a new {@code ApplicationEvent}.
......
package com.yeejoin.amos.boot.module.jyjc.biz.event.listener;
import com.yeejoin.amos.boot.module.jyjc.api.model.InspectionEquipInfoModel;
import com.yeejoin.amos.boot.module.jyjc.biz.config.InspectionRuleEnableConfig;
import com.yeejoin.amos.boot.module.jyjc.biz.event.InspectionOrgRefreshEvent;
import com.yeejoin.amos.boot.module.jyjc.biz.event.rule.RuleDataPrepareHandlerFactory;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
@Component
@RequiredArgsConstructor
@Slf4j
public class DataPreparationAdapterListener implements ApplicationListener<InspectionOrgRefreshEvent> {
private final InspectionRuleEnableConfig inspectionRuleEnableConfig;
private final RuleDataPrepareHandlerFactory handlerFactory;
@Override
public void onApplicationEvent(InspectionOrgRefreshEvent event) {
InspectionEquipInfoModel equipInfoModel = event.getInspectionEquipInfoModel();
Boolean enable = this.getEnableState(equipInfoModel.getInspectionType());
handlerFactory.getRuleDataPrepare(enable).handle(event);
}
/**
* 按照检验类型判断是否启用, 不配置时默认不启用
*
* @param inspectionType 检验类型枚举 @see JYJCTypeEnum
* @return true-启用规则,false-不启用
*/
private boolean getEnableState(String inspectionType) {
return inspectionRuleEnableConfig.getValueByFieldName(inspectionType) != null && (Boolean) inspectionRuleEnableConfig.getValueByFieldName(inspectionType);
}
}
package com.yeejoin.amos.boot.module.jyjc.biz.event.rule;
import com.yeejoin.amos.boot.module.jyjc.biz.event.IRuleDataPrepare;
import com.yeejoin.amos.boot.module.jyjc.biz.event.InspectionOrgRefreshEvent;
import com.yeejoin.amos.boot.module.jyjc.biz.event.rule.service.DisableRuleDataPreparationService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
@Component
@RequiredArgsConstructor
public class DisableRuleDataPrepareHandler implements IRuleDataPrepare {
private final DisableRuleDataPreparationService preparationService;
@Override
public Boolean supportType() {
return false;
}
@Override
public void handle(InspectionOrgRefreshEvent event) {
preparationService.onApplicationEvent(event);
}
}
package com.yeejoin.amos.boot.module.jyjc.biz.event.rule;
import com.yeejoin.amos.boot.module.jyjc.biz.event.IRuleDataPrepare;
import com.yeejoin.amos.boot.module.jyjc.biz.event.InspectionOrgRefreshEvent;
import com.yeejoin.amos.boot.module.jyjc.biz.event.rule.service.EnableRuleDataPreparationService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@Component
@Slf4j
@RequiredArgsConstructor
public class EnableRuleDataPrepareHandler implements IRuleDataPrepare {
private final EnableRuleDataPreparationService preparationService;
@Override
public Boolean supportType() {
return true;
}
@Override
public void handle(InspectionOrgRefreshEvent event) {
preparationService.onApplicationEvent(event);
}
}
package com.yeejoin.amos.boot.module.jyjc.biz.event.rule;
import com.yeejoin.amos.boot.module.jyjc.biz.event.IRuleDataPrepare;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@Component
@RequiredArgsConstructor
public class RuleDataPrepareHandlerFactory {
private final List<IRuleDataPrepare> ruleDataPrepares;
private final Map<Boolean, IRuleDataPrepare> ruleDataPrepareMap = new ConcurrentHashMap<>();
public IRuleDataPrepare getRuleDataPrepare(Boolean enable) {
return ruleDataPrepareMap.computeIfAbsent(enable, k -> {
for (IRuleDataPrepare ruleDataPrepare : ruleDataPrepares) {
if (ruleDataPrepare.supportType().equals(enable)) {
return ruleDataPrepare;
}
}
throw new BadRequest("not found handler for " + enable);
});
}
}
package com.yeejoin.amos.boot.module.jyjc.biz.event.listener;
package com.yeejoin.amos.boot.module.jyjc.biz.event.rule.service;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.jyjc.api.enums.JYJCTypeEnum;
import com.yeejoin.amos.boot.module.jyjc.api.enums.OpenBizTypeEnum;
import com.yeejoin.amos.boot.module.jyjc.api.model.InspectionEquipInfoModel;
import com.yeejoin.amos.boot.module.jyjc.biz.config.InspectionRuleEnableConfig;
import com.yeejoin.amos.boot.module.jyjc.biz.event.InspectionOrgRefreshEvent;
import com.yeejoin.amos.boot.module.jyjc.biz.service.impl.RuleCommonServiceImpl;
import com.yeejoin.amos.boot.module.ymt.api.dto.TzBaseEnterpriseInfoDto;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* 不启用规则时,业务处理
*
* @author Administrator
*/
@Component
@Slf4j
public class DisableRuleDataPreparationListener implements ApplicationListener<InspectionOrgRefreshEvent> {
@RequiredArgsConstructor
public class DisableRuleDataPreparationService {
private InspectionRuleEnableConfig inspectionRuleEnableConfig;
private final RuleCommonServiceImpl ruleCommonService;
private RuleCommonServiceImpl ruleCommonService;
private final RedisUtils redisUtils;
private RedisUtils redisUtils;
public DisableRuleDataPreparationListener(InspectionRuleEnableConfig inspectionRuleEnableConfig, RuleCommonServiceImpl ruleCommonService, RedisUtils redisUtils) {
this.inspectionRuleEnableConfig = inspectionRuleEnableConfig;
this.ruleCommonService = ruleCommonService;
this.redisUtils = redisUtils;
}
@Override
public void onApplicationEvent(InspectionOrgRefreshEvent event) {
InspectionEquipInfoModel equipInfoModel = event.getInspectionEquipInfoModel();
String componentKey = equipInfoModel.getComponentKey();
// 规则不启用时业务处理
if (!this.getEnableConfig(equipInfoModel.getInspectionType())) {
log.warn("检验类型:{},未启用规则,将返回全部数据", equipInfoModel.getInspectionType());
this.responseForPublisher(componentKey, this.getAllInspectionOrgList(equipInfoModel));
}
}
/**
* 按照检验类型判断是否启用, 不配置时默认不启用
*
* @param inspectionType 检验类型枚举 @see JYJCTypeEnum
* @return true-启用规则,false-不启用
*/
private boolean getEnableConfig(String inspectionType) {
return inspectionRuleEnableConfig.getValueByFieldName(inspectionType) == null ? false : (Boolean) inspectionRuleEnableConfig.getValueByFieldName(inspectionType);
log.warn("检验类型:{},未启用规则,将返回全部数据", equipInfoModel.getInspectionType());
this.responseForPublisher(componentKey, this.getAllInspectionOrgList(equipInfoModel));
}
private void responseForPublisher(String componentKey, List<TzBaseEnterpriseInfoDto> allInspectionOrgList) {
......
package com.yeejoin.amos.boot.module.jyjc.biz.event.listener;
package com.yeejoin.amos.boot.module.jyjc.biz.event.rule.service;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yeejoin.amos.boot.biz.common.utils.SnowflakeIdUtil;
......@@ -9,21 +8,20 @@ import com.yeejoin.amos.boot.module.jyjc.api.enums.JYJCTypeEnum;
import com.yeejoin.amos.boot.module.jyjc.api.enums.RequestTypeEnum;
import com.yeejoin.amos.boot.module.jyjc.api.mapper.JyjcInspectionApplicationNoAcceptLogMapper;
import com.yeejoin.amos.boot.module.jyjc.api.model.InspectionEquipInfoModel;
import com.yeejoin.amos.boot.module.jyjc.biz.config.InspectionRuleEnableConfig;
import com.yeejoin.amos.boot.module.jyjc.biz.event.InspectionOrgRefreshEvent;
import com.yeejoin.amos.boot.module.jyjc.biz.event.TouchRuleEvent;
import com.yeejoin.amos.boot.module.jyjc.biz.event.listener.InspectionApplicationPushEventListener;
import com.yeejoin.amos.boot.module.jyjc.biz.event.publisher.EventPublisher;
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.IdxBizJgProjectContraption;
import com.yeejoin.amos.boot.module.ymt.api.entity.RegistrationInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.UseInfo;
import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgProjectContraptionMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.RegistrationInfoMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
......@@ -45,23 +43,22 @@ import static com.yeejoin.amos.boot.module.jyjc.api.enums.CategoryEnum.getCatego
*/
@Component
@Slf4j
public class EnableRuleDataPreparationListener implements ApplicationListener<InspectionOrgRefreshEvent> {
@RequiredArgsConstructor
public class EnableRuleDataPreparationService {
private SnowflakeIdUtil sequence;
private final SnowflakeIdUtil sequence;
private RegistrationInfoMapper registrationInfoMapper;
private final RegistrationInfoMapper registrationInfoMapper;
private RuleCommonServiceImpl ruleCommonService;
private final RuleCommonServiceImpl ruleCommonService;
private InspectionRuleEnableConfig inspectionRuleEnableConfig;
private final InspectionApplicationPushEventListener applicationPushEventListener;
private InspectionApplicationPushEventListener applicationPushEventListener;
private final JyjcInspectionApplicationNoAcceptLogMapper inspectionApplicationNoAcceptLogMapper;
private JyjcInspectionApplicationNoAcceptLogMapper inspectionApplicationNoAcceptLogMapper;
private final EventPublisher publisher;
private EventPublisher publisher;
private List<BlockingQueue<InspectionEquipInfoModel>> hashCodeBlockingQueues = new ArrayList<>();
private final List<BlockingQueue<InspectionEquipInfoModel>> hashCodeBlockingQueues = new ArrayList<>();
private final IdxBizJgProjectContraptionMapper jgProjectContraptionMapper;
......@@ -69,23 +66,6 @@ public class EnableRuleDataPreparationListener implements ApplicationListener<In
private int threadNumber;
public EnableRuleDataPreparationListener(SnowflakeIdUtil sequence,
RegistrationInfoMapper registrationInfoMapper,
RuleCommonServiceImpl ruleCommonService,
InspectionRuleEnableConfig inspectionRuleEnableConfig, InspectionApplicationPushEventListener applicationPushEventListener,
JyjcInspectionApplicationNoAcceptLogMapper inspectionApplicationNoAcceptLogMapper, EventPublisher publisher, IdxBizJgProjectContraptionMapper jgProjectContraptionMapper) {
this.sequence = sequence;
this.registrationInfoMapper = registrationInfoMapper;
this.ruleCommonService = ruleCommonService;
this.inspectionRuleEnableConfig = inspectionRuleEnableConfig;
this.applicationPushEventListener = applicationPushEventListener;
this.inspectionApplicationNoAcceptLogMapper = inspectionApplicationNoAcceptLogMapper;
this.publisher = publisher;
this.jgProjectContraptionMapper = jgProjectContraptionMapper;
}
@Override
public void onApplicationEvent(InspectionOrgRefreshEvent event) {
int queueIndex = Math.abs(event.getInspectionEquipInfoModel().getRecord().hashCode()) % threadNumber;
hashCodeBlockingQueues.get(queueIndex).add(event.getInspectionEquipInfoModel());
......@@ -119,10 +99,6 @@ public class EnableRuleDataPreparationListener implements ApplicationListener<In
}
private void dealData(InspectionEquipInfoModel equipInfoModel) {
// 判断规则是否启用,不启用时直接丢弃
if (!this.getEnableConfig(equipInfoModel.getInspectionType())) {
return;
}
InspectionEquipInfo inspectionEquipInfo = new InspectionEquipInfo();
if (equipInfoModel.getEquCategory() != null && equipInfoModel.getEquCategory().startsWith("8")) {
// 管道逻辑
......@@ -132,16 +108,10 @@ public class EnableRuleDataPreparationListener implements ApplicationListener<In
log.error("未找到装置,报检规则匹配流程结束!");
return;
}
inspectionEquipInfo.setEquCategory(projectContraption.getEquCategory());
inspectionEquipInfo.setEquList(projectContraption.getEquList());
inspectionEquipInfo.setEquDefine(projectContraption.getEquDefine());
inspectionEquipInfo.setEquCategory(equipInfoModel.getEquCategory());
inspectionEquipInfo.setEquList(equipInfoModel.getEquList());
inspectionEquipInfo.setEquDefine(equipInfoModel.getEquDefine());
inspectionEquipInfo.setTechParams(new HashMap<>());
// 地市
UseInfo useInfo = new UseInfo();
BeanUtil.copyProperties(projectContraption, useInfo, true);
inspectionEquipInfo.setAreaCode(ruleCommonService.getArea(useInfo));
// 区县
inspectionEquipInfo.setDistrictOrCountyCode(ruleCommonService.getCounty(useInfo));
} else {
// 非管道逻辑
RegistrationInfo registrationInfo = fetchRegistrationInfo(equipInfoModel.getRecord());
......@@ -149,18 +119,15 @@ public class EnableRuleDataPreparationListener implements ApplicationListener<In
log.error("未找到设备,报检规则匹配流程结束!");
return;
}
inspectionEquipInfo.setEquCategory(registrationInfo.getEquCategory());
inspectionEquipInfo.setEquList(registrationInfo.getEquList());
inspectionEquipInfo.setEquDefine(registrationInfo.getEquDefine());
inspectionEquipInfo.setEquCategory(equipInfoModel.getEquCategory());
inspectionEquipInfo.setEquList(equipInfoModel.getEquList());
inspectionEquipInfo.setEquDefine(equipInfoModel.getEquDefine());
inspectionEquipInfo.setTechParams(this.getTechParams(registrationInfo));
// 是否球罐 0 1 转 boolean
inspectionEquipInfo.setIsBallValve(!"0".equals(registrationInfo.getWhetherSphericalTank()));
UseInfo useInfo = ruleCommonService.getUseInfo(equipInfoModel.getRecord());
// 地市
inspectionEquipInfo.setAreaCode(ruleCommonService.getArea(useInfo));
// 区县
inspectionEquipInfo.setDistrictOrCountyCode(ruleCommonService.getCounty(useInfo));
}
inspectionEquipInfo.setAreaCode(ruleCommonService.getArea(equipInfoModel.getCity(), equipInfoModel.getCounty()));
inspectionEquipInfo.setDistrictOrCountyCode(equipInfoModel.getCounty());
inspectionEquipInfo.setComponentKey(equipInfoModel.getComponentKey());
inspectionEquipInfo.setInspectionType(equipInfoModel.getInspectionType());
inspectionEquipInfo.setRecord(equipInfoModel.getRecord());
......@@ -174,18 +141,6 @@ public class EnableRuleDataPreparationListener implements ApplicationListener<In
publisher.publish(new TouchRuleEvent(this, inspectionEquipInfo));
}
/**
* 按照检验类型判断是否启用, 不配置时默认不启用
*
* @param inspectionType 检验类型枚举 @see JYJCTypeEnum
* @return true-启用规则,false-不启用
*/
private boolean getEnableConfig(String inspectionType) {
return inspectionRuleEnableConfig.getValueByFieldName(inspectionType) != null && (Boolean) inspectionRuleEnableConfig.getValueByFieldName(inspectionType);
}
private String buildLastNoAcceptInspectionCode(JyjcInspectionApplicationNoAcceptLog jyjcInspectionApplicationNoAcceptLog) {
if (jyjcInspectionApplicationNoAcceptLog != null) {
return jyjcInspectionApplicationNoAcceptLog.getInspectionUnitCode();
......@@ -226,7 +181,5 @@ public class EnableRuleDataPreparationListener implements ApplicationListener<In
RegistrationInfo::getEquDefine, RegistrationInfo::getEquList, RegistrationInfo::getWhetherSphericalTank)
.eq(RegistrationInfo::getRecord, record));
}
}
......@@ -32,14 +32,14 @@ public class InspectionOrgRefreshListener extends EmqxListener {
private static final BlockingQueue<BizMessage> BLOCKING_QUEUE = new LinkedBlockingQueue<>();
private EmqKeeper emqKeeper;
private final EmqKeeper emqKeeper;
@Value("${spring.application.name}")
private String applicationName;
private RedisUtils redisUtils;
private final RedisUtils redisUtils;
private EventPublisher publisher;
private final EventPublisher publisher;
public InspectionOrgRefreshListener(EmqKeeper emqKeeper, RedisUtils redisUtils, EventPublisher publisher) {
this.emqKeeper = emqKeeper;
......@@ -84,6 +84,7 @@ public class InspectionOrgRefreshListener extends EmqxListener {
}
private void processBizMessage(BizMessage bizMessage) {
log.info("收到前端消息:{}", bizMessage);
byte[] payload = bizMessage.getMessage().getPayload();
InspectionEquipInfoModel equipInfoModel = parseObject(new String(payload, StandardCharsets.UTF_8), InspectionEquipInfoModel.class);
String componentKey = bizMessage.getTopic().split("/")[0];
......
......@@ -19,7 +19,6 @@ import com.yeejoin.amos.boot.biz.common.service.impl.DataDictionaryServiceImpl;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.biz.common.utils.SnowflakeIdUtil;
import com.yeejoin.amos.boot.biz.common.workflow.feign.WorkflowFeignService;
import com.yeejoin.amos.boot.module.common.api.dao.ESEquipmentCategory;
import com.yeejoin.amos.boot.module.common.api.dto.AttachmentDto;
import com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto;
......@@ -267,7 +266,7 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
model.setPromoter(reginParams.getUserModel().getUserId());
model.setApplicationUnitName(reginParams.getCompany().getCompanyName());
List<JyjcInspectionApplicationEquip> equipInfos = new ArrayList<>();
if (null != model.getEquip() && model.getEquip().size() > 0) {
if (null != model.getEquip() && !model.getEquip().isEmpty()) {
List<JyjcInspectionApplicationEquipDto> equips = JSONObject.parseArray(JSON.toJSONString(model.getEquip()), JyjcInspectionApplicationEquipDto.class);
for (JyjcInspectionApplicationEquipDto equip : equips) {
JyjcInspectionApplicationEquip equipInfo = new JyjcInspectionApplicationEquip();
......@@ -279,8 +278,7 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
this.setEquipCategoryIfPieLine(model, equipInfo, equip);
equipInfos.add(equipInfo);
}
model.setEquList(null2String(model.getEquip().get(0).get("EQU_LIST")));
model.setSupervisoryCode(null2String(model.getEquip().get(0).get("SUPERVISORY_CODE")));
model.setSupervisoryCode(this.getAllSupervisoryCode(equipInfos));
}
model.setCreateUserId(reginParams.getUserModel().getUserId());
model.setNumberOfEquip(equipInfos.size());
......@@ -311,7 +309,7 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
dto.setTaskType(BizTypeEnum.getNumByCode(model.getBizType()));
////业务主键
dto.setRelationId(model.getSequenceNbr() + "");
taskModelService.buildTaskModel(Arrays.asList(dto));
taskModelService.buildTaskModel(Collections.singletonList(dto));
}
} else {
jyjcInspectionApplicationEquipService.getBaseMapper().deleteByApplicationSeq(model.getSequenceNbr());
......@@ -323,9 +321,6 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
taskModelService.updateTaskContentById(MapBuilder.<String, Object>create().put("taskContent", this.buildTaskContent((model))).put("relationId", model.getSequenceNbr() + "").build());
}
}
//保存报检装备监管码
for (JyjcInspectionApplicationEquip equipInfo : equipInfos) {
equipInfo.setApplicationSeq(model.getSequenceNbr());
}
......@@ -355,12 +350,12 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
}
}
this.setNameAndIsMustAccept(model);
//更新报检装备监管码
jyjcInspectionApplicationEquipService.getBaseMapper().deleteByApplicationSeq(model.getSequenceNbr());
if (!model.getEquip().isEmpty()) {
List<JyjcInspectionApplicationEquipDto> equips = JSONObject.parseArray(JSON.toJSONString(model.getEquip()), JyjcInspectionApplicationEquipDto.class);
int num = equips.size();
model.setNumberOfEquip(num);
List<JyjcInspectionApplicationEquip> equipInfos = new ArrayList<>();
for (JyjcInspectionApplicationEquipDto equip : equips) {
JyjcInspectionApplicationEquip equipInfo = new JyjcInspectionApplicationEquip();
equipInfo.setEquDefine(equip.getEquDefineCode());
......@@ -369,12 +364,12 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
equipInfo.setEquCategory(equip.getEquCategoryCode());
equipInfo.setApplicationSeq(model.getSequenceNbr());
this.setEquipCategoryIfPieLine(model, equipInfo, equip);
jyjcInspectionApplicationEquipService.save(equipInfo);
equipInfos.add(equipInfo);
}
model.setEquList(null2String(model.getEquip().get(0).get("EQU_LIST")));
model.setSupervisoryCode(null2String(model.getEquip().get(0).get("SUPERVISORY_CODE")));
applicationEquipService.saveBatch(equipInfos);
model.setSupervisoryCode(this.getAllSupervisoryCode(equipInfos));
}
model.setEquList(model.getEquipClassify());
// 附件更新
List<String> enumNameList = DocumentEnum.getEnumNameList();
......@@ -410,7 +405,7 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
List<WorkflowResultDto> workflowResultDtos = taskModelService.buildWorkFlowInfo(Collections.singletonList(processTaskDTO));
String nextUserIds = workflowResultDtos.get(0).getNextExecutorUserIds();
String executorRoleIds = workflowResultDtos.get(0).getNextExecutorRoleIds();
if (processTaskDTO != null && processTaskDTO.getNextTask() != null && processTaskDTO.getNextTask().size() > 0) {
if (processTaskDTO != null && processTaskDTO.getNextTask() != null && !processTaskDTO.getNextTask().isEmpty()) {
taskName1 = processTaskDTO.getNextTask().get(0).getName();
nextTaskId = processTaskDTO.getNextTask().get(0).getId();
}
......@@ -434,6 +429,10 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
return this.buildRedundancyField(model);
}
private String getAllSupervisoryCode(List<JyjcInspectionApplicationEquip> equipInfos) {
return equipInfos.stream().map(JyjcInspectionApplicationEquip::getSupervisoryCode).collect(Collectors.joining(","));
}
private void setEquipCategoryIfPieLine(JyjcInspectionApplicationModel model, JyjcInspectionApplicationEquip equipInfo, JyjcInspectionApplicationEquipDto equipDto) {
if (model.getEquipClassify().equals(EquipmentClassifityEnum.YLGD.getCode())) {
equipInfo.setProjectContraptionId(model.getProjectContraptionId());
......@@ -482,7 +481,7 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
List<JyjcInspectionApplicationEquipDto> equips = JSONObject.parseArray(JSON.toJSONString(model.getEquip()), JyjcInspectionApplicationEquipDto.class);
recordsInFlowing = this.getBaseMapper().queryRecordListInFlowing(equips);
}
if (recordsInFlowing.size() > 0) {
if (!recordsInFlowing.isEmpty()) {
throw new BadRequest("存在设备已经在流程中,不允许重复提交检验!");
}
}
......@@ -561,14 +560,15 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
public void export(String bizType, HttpServletResponse response, List<String> ids) {
List<JyjcInspectionApplicationVo> exportData = this.baseMapper.queryExportInIds(ids);
String typeName;
if (FIRST_INSPECT.equals(bizType)) {
if (BizTypeEnum.FIRST_INSPECTION.getCode().equals(bizType)) {
typeName = "定(首)检验列表";
} else if (SUPERVISE.equals(bizType)) {
} else if (BizTypeEnum.SUPERVISE.getCode().equals(bizType)) {
typeName = "监督检验列表";
} else if (BizTypeEnum.ENTRUST.getCode().equals(bizType)) {
typeName = " 委托检验列表";
} else {
typeName = "电梯检列表";
typeName = "电梯检列表";
}
ExcelUtil.createTemplate(response, typeName + "数据", typeName, exportData, JyjcInspectionApplicationVo.class, null, false);
}
......@@ -778,7 +778,7 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
resultModel.setSequenceNbr(resultSeq);
resultModel.setIsExistNc(false);
resultModel.setManageType("batch");
this.setResultTypeByBizType(resultModel, model.getBizType());
this.setResultTypeByBizTypeV2(resultModel, model.getBizType());
resultModels.add(resultModel);
// TODO 以管道汇总样式表暂存json,在结果录入后,将数据更新技术参数,考虑老数据
Map<String, Object> paramDetail = getDeviceListByProjectContraption3(model);
......@@ -812,7 +812,7 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
resultModel.setEquCategory(applicationEquipModels.get(i).getEquCategory());
resultModel.setEquList(applicationEquipModels.get(i).getEquList());
resultModel.setIsExistNc(false);
this.setResultTypeByBizType(resultModel, model.getBizType());
this.setResultTypeByBizTypeV2(resultModel, model.getBizType());
Long resultSeq = sequence.nextId();
resultModel.setSequenceNbr(resultSeq);
resultModels.add(resultModel);
......@@ -841,6 +841,9 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
}
}
private void setResultTypeByBizTypeV2(JyjcInspectionResult resultModel, String bizType) {
}
public void createHisAfterReceive(JyjcInspectionApplicationModel model) {
if (model.getEquipClassify().equals(EquipmentClassifityEnum.YLGD.getCode())) {
JSONObject hisData = getDeviceListByProjectContraption2(model);
......@@ -885,7 +888,7 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
queryWrapper.eq(JyjcOpeningApplication::getStatus, FlowStatusEnum.TO_BE_FINISHED.getCode());
queryWrapper.select(JyjcOpeningApplication::getResultType);
List<JyjcOpeningApplication> applicationList = jyjcOpeningApplicationService.list(queryWrapper);
if (applicationList.size() > 0) {
if (!applicationList.isEmpty()) {
resultModel.setResultType(applicationList.get(0).getResultType());
}
}
......@@ -1171,7 +1174,7 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
dto.setStartDate(new Date());
dto.setNextExecuteUser(model.getNextExecuteIds());
taskModelService.buildTaskModel(Arrays.asList(dto));
taskModelService.buildTaskModel(Collections.singletonList(dto));
}
private void createNextTask(JyjcInspectionApplicationModel model, String taskName, String nextUserIds) {
......@@ -1469,8 +1472,17 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
}
// 设备类别编码
if (!ObjectUtils.isEmpty(map.getString("EQU_DEFINE_CODE"))) {
boolMust.must(QueryBuilders.matchPhraseQuery("EQU_DEFINE_CODE", QueryParser.escape(map.getString("EQU_DEFINE_CODE"))));
boolMust.must(QueryBuilders.termQuery("EQU_DEFINE_CODE", QueryParser.escape(map.getString("EQU_DEFINE_CODE"))));
}
// // 地市
// if (!ObjectUtils.isEmpty(map.getString("CITY"))) {
// boolMust.must(QueryBuilders.wildcardQuery("USE_PLACE_CODE", "*" + map.getString("CITY") + "*"));
// }
// // 区县
// if (!ObjectUtils.isEmpty(map.getString("COUNTY"))) {
// boolMust.must(QueryBuilders.wildcardQuery("USE_PLACE_CODE", "*" + map.getString("COUNTY") + "*"));
// }
// 设备代码模糊查询
if (!ObjectUtils.isEmpty(map.getString(EQU_CODE))) {
String test = QueryParser.escape(map.getString(EQU_CODE));
......@@ -1599,6 +1611,7 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
/**
* 使用地点-使用登记完成后回把使用登记的地点信息写到装置表。定期检验时显示
*
* @param projectContraption 装置
* @param re 返回结果:增加使用地点(工业管道是使用登记时的地址);公用、长输管道是安装地址(无使用登记证)
*/
......@@ -1628,9 +1641,9 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
jsonObject.put("projectContraptionId", applicationModel.getProjectContraptionId());
jsonObject.put("projectContraptionNo", projectContraption.getProjectContraptionNo());
jsonObject.put("pipelineLength", calTotalLength(equList));
jsonObject.put("equListName", projectContraption.getEquListName());
jsonObject.put("equListName", projectContraption.getEquListName());
jsonObject.put("equCategoryName", projectContraption.getEquCategoryName());
jsonObject.put("equDefineName" , projectContraption.getEquDefineName());
jsonObject.put("equDefineName", projectContraption.getEquDefineName());
jsonObject.put("useRegistrationCode", projectContraption.getUseRegistrationCode());
this.setInstallAddress(projectContraption, jsonObject);
this.setUseAddress(projectContraption, jsonObject);
......@@ -1643,6 +1656,7 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
/**
* 安装地址:安装告知完成后,此字段为安装地址
*
* @param projectContraption 装置
* @param jsonObject 增加安装地址
*/
......@@ -1652,6 +1666,7 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
/**
* 管道报检结果-管道详情页签-数据缓存---与getDeviceListByProjectContraption2区别,汇总表内不包含检验信息
*
* @param applicationModel 申请单
* @return 无检验信息的汇总管道-检验结果页面专用
*/
......@@ -1688,6 +1703,7 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
/**
* 查询单位下的所有工程装置(父ID为空)的数据
*
* @param useUnitCreditCode
* @param page
* @return
......
......@@ -8,6 +8,7 @@ import com.yeejoin.amos.boot.module.ymt.api.entity.UseInfo;
import com.yeejoin.amos.boot.module.ymt.api.mapper.TzBaseEnterpriseInfoMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.UseInfoMapper;
import com.yeejoin.amos.component.rule.config.RuleConfig;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.paho.client.mqttv3.MqttException;
......@@ -22,11 +23,12 @@ import java.util.List;
*/
@Component
@Slf4j
@RequiredArgsConstructor
public class RuleCommonServiceImpl {
private UseInfoMapper useInfoMapper;
private final UseInfoMapper useInfoMapper;
private TzBaseEnterpriseInfoMapper enterpriseInfoMapper;
private final TzBaseEnterpriseInfoMapper enterpriseInfoMapper;
private final EmqKeeper emqKeeper;
......@@ -35,12 +37,6 @@ public class RuleCommonServiceImpl {
*/
private static final String[] EXCLUSION_CITY_REGIONS = {"610403", "610581"};
public RuleCommonServiceImpl(UseInfoMapper useInfoMapper, TzBaseEnterpriseInfoMapper enterpriseInfoMapper, EmqKeeper emqKeeper) {
this.useInfoMapper = useInfoMapper;
this.enterpriseInfoMapper = enterpriseInfoMapper;
this.emqKeeper = emqKeeper;
}
String getArea(String record) {
UseInfo equipUseInfo = useInfoMapper.selectOne(Wrappers.<UseInfo>lambdaQuery().select(UseInfo::getCity, UseInfo::getCounty).eq(UseInfo::getRecord, record));
......@@ -76,6 +72,17 @@ public class RuleCommonServiceImpl {
return equipUseInfo.getCity();
}
public String getArea(String city, String county) {
// 特殊地区特殊处理,目前有韩城、杨凌,原因行政区划上是有层级的,但是业务办理时,他们与所在地市是同级别的
if (StringUtils.isEmpty(city) || StringUtils.isEmpty(county)) {
return "";
}
if (Arrays.asList(EXCLUSION_CITY_REGIONS).contains(county)) {
return county;
}
return city;
}
public String getCounty(UseInfo equipUseInfo) {
if (equipUseInfo == null) {
return "";
......
......@@ -73,4 +73,5 @@ inspection.rule.enabled.GZJDJY=true
#维修监督检验是否启用规则:true-启用,false-不启用
inspection.rule.enabled.WXJDJY=true
#电梯检测是否启用规则:true-启用,false-不启用
inspection.rule.enabled.DTJC=true
\ No newline at end of file
inspection.rule.enabled.DTJC=true
inspection.rule.enabled.WTJY=true
......@@ -260,7 +260,7 @@
FROM
tz_base_enterprise_info info
inner JOIN tz_jyjc_opening_application tjoa ON info.use_code = tjoa.unit_code
AND tjoa.status = '6616'
AND tjoa.status = '已完成'
<if test="openBizType != null and openBizType !=''">
and tjoa.open_biz_type = #{openBizType}
</if>
......@@ -276,7 +276,7 @@
FROM
tz_base_enterprise_info info
INNER JOIN tz_jyjc_opening_application tjoa ON info.use_code = tjoa.unit_code
AND tjoa.status = '6616'
AND tjoa.status = '已完成'
and tjoa.open_biz_type = #{openBizType}
<if test="list !=null and list.size()>0">
AND info.use_code in
......
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