Commit 12542e6b authored by LiuLin's avatar LiuLin

fix(jyjc):规则查询检验检测机构信息

parent 84724514
package com.yeejoin.amos.boot.module.jyjc.api.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum LicenceTypeEnum {
JY_JC("jyjc", "检验检测");
private final String code;
private final String name;
}
package com.yeejoin.amos.boot.module.jyjc.api.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author LiuLin
*/
@AllArgsConstructor
@Getter
public enum TopicEnum {
JYJC_INSPECTION_UNIT_LIST_TOPIC("检验检测报建机构","jyjc/inspection/unit/list/topic");
private final String name;
private final String topic;
}
package com.yeejoin.amos.boot.module.jyjc.biz.action;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.module.jyjc.api.enums.LicenceTypeEnum;
import com.yeejoin.amos.boot.module.jyjc.api.enums.TopicEnum;
import com.yeejoin.amos.boot.module.jyjc.biz.rule.InspectionEquipInfo;
import com.yeejoin.amos.boot.module.jyjc.biz.service.impl.CommonserviceImpl;
import com.yeejoin.amos.boot.module.ymt.api.entity.TzBaseUnitLicence;
import com.yeejoin.amos.boot.module.ymt.api.mapper.TzBaseEnterpriseInfoMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.TzBaseUnitLicenceMapper;
import com.yeejoin.amos.boot.module.ymt.api.entity.TzBaseEnterpriseInfo;
import com.yeejoin.amos.component.rule.config.RuleConfig;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import java.time.LocalDate;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author LiuLin
* @date 2024年01月02日 15:45
*/
@Component
@Slf4j
public class RuleActionHandler {
private final EmqKeeper emqKeeper;
private final TzBaseUnitLicenceMapper baseUnitLicenceMapper;
private final TzBaseEnterpriseInfoMapper tzBaseEnterpriseInfoMapper;
private final CommonserviceImpl commonserviceImpl;
@Autowired
public RuleActionHandler(EmqKeeper emqKeeper, TzBaseUnitLicenceMapper baseUnitLicenceMapper,
TzBaseEnterpriseInfoMapper tzBaseEnterpriseInfoMapper, CommonserviceImpl commonserviceImpl) {
this.emqKeeper = emqKeeper;
this.baseUnitLicenceMapper = baseUnitLicenceMapper;
this.tzBaseEnterpriseInfoMapper = tzBaseEnterpriseInfoMapper;
this.commonserviceImpl = commonserviceImpl;
}
public void filterInspectionOrgAction(Object bizObj, String itemCode) {
InspectionEquipInfo inspectionEquipInfo = (InspectionEquipInfo) bizObj;
try {
List<TzBaseUnitLicence> unitLicenceList = getBaseUnitLicenceList(itemCode);
List<TzBaseEnterpriseInfo> tzBaseEnterpriseInfoList = getInspectionUnitList(unitLicenceList);
publishMqttMessage(inspectionEquipInfo.getComponentKey(), tzBaseEnterpriseInfoList);
} catch (MqttException e) {
log.error("Error publishing MQTT message: {}", e.getMessage());
}
}
private List<TzBaseUnitLicence> getBaseUnitLicenceList(String itemCode) {
return baseUnitLicenceMapper.selectList(new LambdaQueryWrapper<TzBaseUnitLicence>()
.select(TzBaseUnitLicence::getUnitCode)
.eq(TzBaseUnitLicence::getLicenceType, LicenceTypeEnum.JY_JC.getCode())
.in(TzBaseUnitLicence::getItemCode, Arrays.asList(itemCode.split(",")))
.ge(TzBaseUnitLicence::getExpiryDate, LocalDate.now()));
}
private List<TzBaseEnterpriseInfo> getInspectionUnitList(List<TzBaseUnitLicence> unitLicenceList) {
if (!ValidationUtil.isEmpty(unitLicenceList)) {
return tzBaseEnterpriseInfoMapper.getInspectionUnitListByCode(unitLicenceList.stream()
.map(TzBaseUnitLicence::getUnitCode)
.collect(Collectors.toList()));
} else {
return commonserviceImpl.getInspectionUnitList();
}
}
private void publishMqttMessage(String componentKey, Object message) throws MqttException {
log.info("{}: {}", TopicEnum.JYJC_INSPECTION_UNIT_LIST_TOPIC.getName(), TopicEnum.JYJC_INSPECTION_UNIT_LIST_TOPIC.getTopic());
try {
emqKeeper.getMqttClient().publish(String.format(componentKey, TopicEnum.JYJC_INSPECTION_UNIT_LIST_TOPIC.getTopic()),
JSON.toJSONString(message).getBytes(), RuleConfig.DEFAULT_QOS, false);
} catch (MqttException e) {
log.error("Error publishing MQTT message: {}", e.getMessage());
throw e;
}
}
}
package com.yeejoin.amos.boot.module.jyjc.biz.rule;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @author LiuLin
* @date 2024年01月02日 16:47
*/
@Data
@ApiModel(value = "InspectionEquipInfo")
public class InspectionEquipInfo implements Serializable {
@ApiModelProperty(value = "请求唯一标识")
private String componentKey;
@ApiModelProperty(value = "设备ID")
private String record;
@ApiModelProperty(value = "检验类型")
private String bizType;
@ApiModelProperty(value = "技术参数")
private Object techParams;
@ApiModelProperty(value = "是否防爆")
private Boolean isAntiExplosion;
@ApiModelProperty(value = "设备品种")
private String equDefine;
@ApiModelProperty(value = "设备类别")
private String equCategory;
@ApiModelProperty(value = "设备种类")
private String equList;
@ApiModelProperty(value = "检验类型")
private String inspectionType;
}
...@@ -5,6 +5,7 @@ import java.util.Date; ...@@ -5,6 +5,7 @@ import java.util.Date;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity; import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
...@@ -14,6 +15,7 @@ import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity; ...@@ -14,6 +15,7 @@ import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
* @author duanwei * @author duanwei
* @date 2022-08-31 * @date 2022-08-31
*/ */
@EqualsAndHashCode(callSuper = true)
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
@TableName("tz_base_unit_licence") @TableName("tz_base_unit_licence")
......
...@@ -7,7 +7,6 @@ import com.yeejoin.amos.boot.biz.common.entity.BaseEntity; ...@@ -7,7 +7,6 @@ import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import java.util.Date; import java.util.Date;
/** /**
...@@ -170,4 +169,19 @@ public class BaseUnitLicence extends BaseEntity { ...@@ -170,4 +169,19 @@ public class BaseUnitLicence extends BaseEntity {
@TableField("is_not_sync") @TableField("is_not_sync")
private String isNotSync; private String isNotSync;
/**
* 机构类别枚举
*/
private String agencyType;
/**
* 机构类别枚举名称,冗余
*/
private String agencyTypeName;
/**
* 资质类型编码(检验检测、其他)
*/
private String licenceType;
} }
...@@ -92,13 +92,19 @@ public class TzBaseUnitLicence extends BaseEntity { ...@@ -92,13 +92,19 @@ public class TzBaseUnitLicence extends BaseEntity {
@ApiModelProperty(value = "固定检验地址") @ApiModelProperty(value = "固定检验地址")
private String itemAddress; private String itemAddress;
@ApiModelProperty(value = "更新人名称") @ApiModelProperty(value = "更新人名称")
private String recUserName; private String recUserName;
@ApiModelProperty(value = "是否删除(0:未删除,1:已删除)") @ApiModelProperty(value = "是否删除(0:未删除,1:已删除)")
private Boolean isDelete; private Boolean isDelete;
@ApiModelProperty(value = "机构类别枚举")
private String agencyType;
@ApiModelProperty(value = "机构类别枚举名称,冗余")
private String agencyTypeName;
@ApiModelProperty(value = "资质类型编码(检验检测、其他)")
private String licenceType;
} }
...@@ -53,6 +53,8 @@ public interface TzBaseEnterpriseInfoMapper extends BaseMapper<TzBaseEnterpriseI ...@@ -53,6 +53,8 @@ public interface TzBaseEnterpriseInfoMapper extends BaseMapper<TzBaseEnterpriseI
*/ */
List<TzBaseEnterpriseInfo> getInspectionUnitList(@Param("unitType") String unitType); List<TzBaseEnterpriseInfo> getInspectionUnitList(@Param("unitType") String unitType);
List<TzBaseEnterpriseInfo> getInspectionUnitListByCode(List<String> codes);
/** /**
* 根据ID查找企业详情信息 * 根据ID查找企业详情信息
* *
......
...@@ -167,6 +167,26 @@ ...@@ -167,6 +167,26 @@
AND status = '6616' AND status = '6616'
where unit_type LIKE CONCAT('%',#{unitType},'%') group by info.use_code where unit_type LIKE CONCAT('%',#{unitType},'%') group by info.use_code
</select> </select>
<select id="getInspectionUnitListByCode" resultType="com.yeejoin.amos.boot.module.ymt.api.entity.TzBaseEnterpriseInfo">
SELECT
info.sequence_nbr,
info.use_code,
info.use_unit,
info.use_contact,
info.contact_phone
FROM
tz_base_enterprise_info info
INNER JOIN tz_jyjc_opening_application tjoa ON info.use_code = tjoa.unit_code
AND status = '6616'
<if test="list !=null and list.size()>0">
AND use_code in
<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
group by info.use_code
</select>
<select id="selectBySeq" resultType="com.yeejoin.amos.boot.module.ymt.api.entity.TzBaseEnterpriseInfo"> <select id="selectBySeq" resultType="com.yeejoin.amos.boot.module.ymt.api.entity.TzBaseEnterpriseInfo">
select * from tz_base_enterprise_info where sequence_nbr = #{sequenceNbr} select * from tz_base_enterprise_info where sequence_nbr = #{sequenceNbr}
</select> </select>
......
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