Commit 998abdd7 authored by suhuiguang's avatar suhuiguang

1.特种气瓶-登记证扫一扫后端接口

parent a1b9c8c0
package com.yeejoin.amos.boot.biz.common.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* @author system_generator
* @date 2024-07-03
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value="JgUseRegistrationManageDto", description="")
public class JgUseRegistrationManageDto extends BaseDto {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "使用单位名称")
private String useUnitName;
@ApiModelProperty(value = "申请编号")
private String applyNo;
@ApiModelProperty(value = "使用登记证状态(已登记,已注销)")
private String certificateStatus;
@ApiModelProperty(value = "接收机构/登记机关")
private String receiveOrgName;
@ApiModelProperty(value = "办理日期")
private String auditPassDate;
@ApiModelProperty(value = "登记类别")
private String regType;
@ApiModelProperty(value = "申请日期")
private String regDate;
@ApiModelProperty(value = "设备种类")
private String equList;
@ApiModelProperty(value = "设备类别")
private String equCategory;
@ApiModelProperty(value = "设备品种")
private String equDefine;
@ApiModelProperty(value = "设备种类编码")
private String equListCode;
@ApiModelProperty(value = "设备类别编码")
private String equCategoryCode;
@ApiModelProperty(value = "设备品种编码")
private String equDefineCode;
@ApiModelProperty(value = "备注")
private String remark;
@ApiModelProperty(value = "创建人ID")
private String createUserId;
@ApiModelProperty(value = "创建时间")
private String createDate;
@ApiModelProperty(value = "使用登记证编号")
private String useRegistrationCode;
@ApiModelProperty(value = "使用单位统一信用代码")
private String useUnitCreditCode;
@ApiModelProperty(value = "原使用单位统一信用代码")
private String originalUseUnitCreditCode;
@ApiModelProperty(value = "接收机构公司代码")
private String receiveCompanyCode;
@ApiModelProperty(value = "登记证书编号/登记证书唯一码")
private String certificateNo;
@ApiModelProperty(value = "数据类型:监管/行政审批局,企业")
private String dataType;
@ApiModelProperty(value = "车牌号-车用气瓶登记")
private String carNumber;
@ApiModelProperty(value = "设备使用地址")
private String equUseAddress;
@ApiModelProperty(value = "使用单位地址")
private String useUnitAddress;
@ApiModelProperty("使用登记办理类型,unit单位, set台套")
private String manageType;
@ApiModelProperty(value = "使用单位统一信用代码-搜索使用")
private String useUnitCreditCodeForSearch;
@ApiModelProperty(value = "是否车用气瓶--过滤数据使用")
private String whetherVehicleCylinder;
@ApiModelProperty(value = "是否气瓶--过滤数据使用 ---目前使用场景:注销报废业务 值为true 只过滤出气瓶的使用登记证)")
private String isCyl;
@ApiModelProperty(value = "是否报废状态:1报废 0 未报废 ---目前使用场景:非单位业务办理报废业务,筛选出非报废状态的证--过滤数据使用)")
private String isScrap;
@ApiModelProperty(value = "业务类型code,报废业务使用")
private String applyType;
@ApiModelProperty(value = "城市名称")
private String cityName;
}
package com.yeejoin.amos.boot.module.app.api.annotation;
import java.util.HashMap;
import java.util.Map;
public class ChargeMediaConverter implements Converter<String> {
private static final Map<String, String> dictionary = new HashMap<>();
static {
dictionary.put("LIQUEFIED_NATURAL_GAS", "液化天然气");
dictionary.put("LIQUEFIED_PETROLEUM_GAS", "液化石油气");
dictionary.put("COMPRESSED_NATURAL_GAS", "压缩天然气");
dictionary.put("HYDROGEN", "氢气");
dictionary.put("HELIUM", "氦气");
dictionary.put("AIR", "空气");
dictionary.put("OXYGEN", "氧气");
dictionary.put("PROPANE", "丙烷");
dictionary.put("BUTANCE", "丁烷");
dictionary.put("LIQUEFIED_CARBON_DIOXIDE", "液化二氧化碳");
dictionary.put("LIQUID_OXYGEN", "液氧");
dictionary.put("NITROGEN", "氮气");
dictionary.put("ARGON", "氩气");
dictionary.put("LIQUID_ARGON", "液氩");
dictionary.put("LIQUID_NITROGEN", "液氮");
dictionary.put("DISSOLVE_ACETYLENE", "溶解乙炔");
dictionary.put("1,1,1,2-TETRAFLUOROETHANE_(R134A)", "1,1,1,2-四氟乙烷(R134a)");
}
@Override
public String convertToLabelData(String key) {
return dictionary.getOrDefault(key, key);
}
}
package com.yeejoin.amos.boot.module.app.api.annotation;
public interface Converter<V> {
V convertToLabelData(String key);
}
package com.yeejoin.amos.boot.module.app.api.annotation;
public class DefaultConverter implements Converter<String> {
@Override
public String convertToLabelData(String key) {
return key;
}
}
package com.yeejoin.amos.boot.module.app.api.annotation;
import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@Documented
public @interface FieldDisplayDefine {
String value();
boolean isExist() default true;
Class<? extends Converter> converter() default DefaultConverter.class;
}
package com.yeejoin.amos.boot.module.app.api.annotation;
import java.util.HashMap;
import java.util.Map;
public class InspectResultConverter implements Converter<String> {
private static final Map<String, String> dictionary = new HashMap<>();
static {
dictionary.put("6040", "合格");
dictionary.put("6041", "不合格");
dictionary.put("6042", "复检合格");
dictionary.put("6043", "复检不合格");
dictionary.put("6044", "其他");
dictionary.put("6045", "整改后合格");
dictionary.put("6046", "符合");
dictionary.put("6047", "不符合");
dictionary.put("6048", "符合要求");
dictionary.put("6049", "基本符合要求");
dictionary.put("6050", "不符合要求");
dictionary.put("6051", "允许使用");
}
@Override
public String convertToLabelData(String key) {
return dictionary.getOrDefault(key, key);
}
}
package com.yeejoin.amos.boot.module.app.api.dto;
import com.yeejoin.amos.boot.module.app.api.annotation.ChargeMediaConverter;
import com.yeejoin.amos.boot.module.app.api.annotation.FieldDisplayDefine;
import com.yeejoin.amos.boot.module.app.api.annotation.InspectResultConverter;
import lombok.Data;
@Data
public class CylinderInfoForWX {
private String record;
@FieldDisplayDefine(value = "设备品种")
private String equDefine;
@FieldDisplayDefine(value = "产品编号")
private String factoryNum;
@FieldDisplayDefine(value = "设备代码")
private String equCode;
@FieldDisplayDefine(value = "制造单位")
private String produceUnitName;
@FieldDisplayDefine(value = "制造年月")
private String produceDate;
@FieldDisplayDefine(value = "充装介质", converter = ChargeMediaConverter.class)
private String chargingMedium;
@FieldDisplayDefine(value = "公称工作压力(MPa)")
private String nominalWorkingPressure;
@FieldDisplayDefine(value = "容积(L)")
private String singleBottleVolume;
@FieldDisplayDefine(value = "最近一次检验日期")
private String lastInspectDate;
@FieldDisplayDefine(value = "下次检验日期")
private String nextInspectDate;
@FieldDisplayDefine(value = "检验结果" ,converter = InspectResultConverter.class)
private String inspectConclusion;
}
package com.yeejoin.amos.boot.module.app.api.dto;
import com.yeejoin.amos.boot.module.app.api.annotation.FieldDisplayDefine;
import lombok.Data;
@Data
public class VehicleInfoForWX {
@FieldDisplayDefine(value = "车牌号")
private String carNumber;
@FieldDisplayDefine(value = "使用登记证编号")
private String useRegistrationCode;
@FieldDisplayDefine(value = "设备类别")
private String equCategory;
@FieldDisplayDefine(value = "所属区域")
private String useUnitAddress;
@FieldDisplayDefine(value = "气瓶数量")
private String gasNum;
@FieldDisplayDefine(value = "使用单位名称", isExist = false)
private String useUnitName;
@FieldDisplayDefine(value = "设备种类",isExist = false)
private String equList;
@FieldDisplayDefine(value = "设备品种",isExist = false)
private String equDefine;
}
package com.yeejoin.amos.boot.module.app.api.mapper;
import com.yeejoin.amos.boot.biz.common.dto.JgUseRegistrationManageDto;
import com.yeejoin.amos.boot.module.app.api.dto.CylinderInfoForWX;
import com.yeejoin.amos.boot.module.app.api.dto.VehicleInfoForWX;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* Mapper 接口
*
* @author system_generator
* @date 2023-12-13
*/
@Mapper
public interface AppCommonMapper {
/**
* 查询指定单号下的车用气瓶信息
*
* @param applyNo 单号
* @return 车用气瓶信息
*/
List<CylinderInfoForWX> queryCylinderIfoOfVehicle(String applyNo);
/**
* 查询车辆基本信息
*
* @param applyNo 申请单号
* @return 车辆基本信息
*/
VehicleInfoForWX queryVehicleBaseInfo(String applyNo);
JgUseRegistrationManageDto selectOneCert(String applyNo);
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.app.api.mapper.AppCommonMapper">
<select id="queryCylinderIfoOfVehicle" resultType="com.yeejoin.amos.boot.module.app.api.dto.CylinderInfoForWX">
select
*
from
(select
f.record,
f.FACTORY_NUM,
f.PRODUCE_UNIT_NAME,
date_format(f.PRODUCE_DATE, 'YYYY-MM-DD') as PRODUCE_DATE,
p.CHARGING_MEDIUM,
p.NOMINAL_WORKING_PRESSURE,
p.SINGLE_BOTTLE_VOLUME,
r.equ_code
from
idx_biz_jg_factory_info f,
idx_biz_jg_tech_params_vessel p,
idx_biz_jg_register_info r
where
f.record=p.record and r.record = f.record and f.record in (
select
equ_id as record
from
(select
b.equ_id,
a.apply_no
from
tzs_jg_vehicle_information a,
tzs_jg_vehicle_information_eq b
where
b.vehicle_id = a.sequence_nbr
union ALL
select
b.equ_id,
a.apply_no
from
tzs_jg_change_vehicle_registration_unit a,
tzs_jg_change_vehicle_registration_unit_eq b
where
b.unit_change_id = a.sequence_nbr) as s1
WHERE
s1.apply_no = #{applyNo})) a
left join
(select
record,
date_format(INSPECT_DATE, 'YYYY-MM-DD') as lastInspectDate,
date_format(NEXT_INSPECT_DATE, 'YYYY-MM-DD') nextInspectDate,
INSPECT_CONCLUSION as inspectConclusion
from
idx_biz_jg_inspection_detection_info
where record in (select record from (select max(INSPECT_DATE), record FROM "idx_biz_jg_inspection_detection_info" where record in (
select
equ_id as record
from
(select
b.equ_id,
a.apply_no
from
tzs_jg_vehicle_information a,
tzs_jg_vehicle_information_eq b
where
b.vehicle_id = a.sequence_nbr
union ALL
select
b.equ_id,
a.apply_no
from
tzs_jg_change_vehicle_registration_unit a,
tzs_jg_change_vehicle_registration_unit_eq b
where
b.unit_change_id = a.sequence_nbr) as s1
WHERE
s1.apply_no = #{applyNo}) GROUP BY record))) b
on a.record = b.record
</select>
<select id="queryVehicleBaseInfo" resultType="com.yeejoin.amos.boot.module.app.api.dto.VehicleInfoForWX">
SELECT
use_registration_code,
car_number,
equ_list,
equ_define,
equ_category,
gas_num,
use_unit_address,
use_unit_name
FROM
"tzs_jg_use_registration_manage"
where
apply_no=#{applyNo} limit 1
</select>
<select id="selectOneCert" resultType="com.yeejoin.amos.boot.biz.common.dto.JgUseRegistrationManageDto">
SELECT
*
FROM
"tzs_jg_use_registration_manage"
WHERE
apply_no = #{applyNo}
and is_delete = false
ORDER BY rec_date desc limit 1
</select>
</mapper>
...@@ -125,6 +125,20 @@ public class TzsAppController { ...@@ -125,6 +125,20 @@ public class TzsAppController {
/** /**
* 小程序获取证详情-微信扫一扫
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping(value = "/certInfoWX")
@ApiOperation(httpMethod = "GET", value = "小程序获取登记证或者使用标志详情", notes = "小程序获取登记证或者使用标志详情")
public ResponseModel<Map> getCertInfoForWX(@RequestParam String applyNo,
@RequestParam String from) {
return ResponseHelper.buildResponse(appService.getCertInfoForWX(applyNo,from));
}
/**
* 根据监管码查询设备详情 * 根据监管码查询设备详情
* *
* @return * @return
......
package com.yeejoin.amos.boot.module.app.biz.service.impl;
import com.yeejoin.amos.boot.module.app.biz.strategy.ISearchDetailHandler;
import org.springframework.stereotype.Component;
import java.util.Collections;
import java.util.Map;
@Component
public class SetSearchDetailDetailHandlerImpl implements ISearchDetailHandler<Map<String, Object>> {
@Override
public String manageType() {
return "set";
}
@Override
public Map<String, Object> hanlder(String applyNo, String from) {
return Collections.emptyMap();
}
}
...@@ -248,7 +248,6 @@ public class TzsAuthServiceImpl implements TzsAuthService { ...@@ -248,7 +248,6 @@ public class TzsAuthServiceImpl implements TzsAuthService {
this.loginUser(weRobotUser, weRobotPassword, weChatToken); this.loginUser(weRobotUser, weRobotPassword, weChatToken);
} }
} }
String weToken = redisUtils.get(weChatToken).toString(); return redisUtils.get(weChatToken).toString();
return weToken;
} }
} }
\ No newline at end of file
package com.yeejoin.amos.boot.module.app.biz.service.impl;
import com.yeejoin.amos.boot.module.app.biz.strategy.ISearchDetailHandler;
import org.springframework.stereotype.Component;
import java.util.Collections;
import java.util.Map;
@Component
public class UnitSearchDetailDetailHandlerImpl implements ISearchDetailHandler<Map<String,Object>> {
@Override
public String manageType() {
return "unit";
}
@Override
public Map<String, Object> hanlder(String applyNo, String from) {
return Collections.emptyMap();
}
}
package com.yeejoin.amos.boot.module.app.biz.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.biz.common.utils.QRCodeUtil;
import com.yeejoin.amos.boot.module.app.api.annotation.Converter;
import com.yeejoin.amos.boot.module.app.api.annotation.FieldDisplayDefine;
import com.yeejoin.amos.boot.module.app.api.dto.CylinderInfoForWX;
import com.yeejoin.amos.boot.module.app.api.dto.VehicleInfoForWX;
import com.yeejoin.amos.boot.module.app.api.mapper.AppCommonMapper;
import com.yeejoin.amos.boot.module.app.biz.strategy.ISearchDetailHandler;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import org.apache.http.entity.ContentType;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.util.*;
@Component
public class VehicleSearchDetailDetailHandlerImpl implements ISearchDetailHandler<Map<String, Object>> {
private final AppCommonMapper appCommonMapper;
public VehicleSearchDetailDetailHandlerImpl(AppCommonMapper appCommonMapper) {
this.appCommonMapper = appCommonMapper;
}
@Override
public String manageType() {
return "vehicle";
}
@Override
public Map<String, Object> hanlder(String applyNo, String from) {
return this.getQueryCarCylinderInfo(applyNo);
}
private Map<String, Object> getQueryCarCylinderInfo(String qrCode) {
VehicleInfoForWX baseInfo = appCommonMapper.queryVehicleBaseInfo(qrCode);
List<CylinderInfoForWX> cylinderInfos = appCommonMapper.queryCylinderIfoOfVehicle(qrCode);
fillEquDefine(baseInfo, cylinderInfos);
Map<String, Object> result = new LinkedHashMap<>();
JSONArray tabs = new JSONArray();
buildFixFields(qrCode, baseInfo, result);
buildOneItemTypeMap( baseInfo, tabs);
buildManyItemTypeTab(cylinderInfos, tabs);
result.put("tab", tabs);
return result;
}
private void fillEquDefine(VehicleInfoForWX baseInfo, List<CylinderInfoForWX> cylinderInfos) {
cylinderInfos.forEach(c-> c.setEquDefine(baseInfo.getEquDefine()));
}
private void buildFixFields(String qrCode, VehicleInfoForWX baseInfo, Map<String, Object> result) {
result.putAll(getQRCode(qrCode));
result.put("unitName", baseInfo.getUseUnitName());
result.put("equList", baseInfo.getEquList());
}
private void buildManyItemTypeTab(List<CylinderInfoForWX> cylinderInfos, JSONArray tabs) {
JSONObject tab = new JSONObject();
tab.put("title", "气瓶信息");
tab.put("tabValue", this.buildFieldsWithGroup(cylinderInfos));
tab.put("isGroup", true);
tabs.add(tab);
}
private void buildOneItemTypeMap(VehicleInfoForWX baseInfo, JSONArray tabs) {
JSONObject tab = new JSONObject();
tab.put("title", "基本信息");
tab.put("tabValue", this.buildFieldsNoGroup(baseInfo));
tab.put("isGroup", false);
tabs.add(tab);
}
private Object buildFieldsNoGroup(VehicleInfoForWX baseInfo) {
JSONArray fieldArray = new JSONArray();
Field[] fields = baseInfo.getClass().getDeclaredFields();
for (Field field : fields) {
field.setAccessible(true);
FieldDisplayDefine displayDefine = field.getAnnotation(FieldDisplayDefine.class);
try {
if (displayDefine != null && displayDefine.isExist()) {
String fieldName = displayDefine.value();
JSONObject json = new JSONObject();
json.put("fieldName", fieldName);
json.put("fieldKey", field.getName());
json.put("fieldValue", field.get(baseInfo));
fieldArray.add(json);
}
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
return fieldArray;
}
private Object buildFieldsWithGroup(List<CylinderInfoForWX> cylinderInfos) {
JSONArray groupArray = new JSONArray();
for(CylinderInfoForWX cylinderInfo: cylinderInfos){
JSONObject group = new JSONObject();
JSONArray fieldArray = new JSONArray();
Field[] fields = cylinderInfo.getClass().getDeclaredFields();
for (Field field : fields) {
field.setAccessible(true);
FieldDisplayDefine displayDefine = field.getAnnotation(FieldDisplayDefine.class);
try {
if (displayDefine != null && displayDefine.isExist()) {
String fieldName = displayDefine.value();
JSONObject json = new JSONObject();
json.put("fieldName", fieldName);
json.put("fieldKey", field.getName());
Converter<String> converter = displayDefine.converter().newInstance();
if(field.get(cylinderInfo) != null){
json.put("fieldValue", converter.convertToLabelData((String)field.get(cylinderInfo)));
} else {
json.put("fieldValue", "");
}
fieldArray.add(json);
}
} catch (IllegalAccessException | InstantiationException e) {
throw new RuntimeException(e);
}
}
group.put("groupName", String.format("气瓶(%s)", cylinderInfo.getFactoryNum()));
group.put("groupFields", fieldArray);
groupArray.add(group);
}
return groupArray;
}
private JSONObject getQRCode(String code) {
JSONObject jsonObject = new JSONObject();
byte[] bytes = QRCodeUtil.generateQRCodeImageByteData(code, 50);
InputStream inputStream = new ByteArrayInputStream(bytes);
try {
MultipartFile file = new MockMultipartFile(code + ".jpg", code + ".jpg", ContentType.APPLICATION_OCTET_STREAM.toString(), inputStream);
FeignClientResult<Map<String, String>> date = Systemctl.fileStorageClient.updateCommonFileFree(file, "ugp/qrcode");
if (date != null) {
Map<String, String> map = date.getResult();
Iterator<String> it = map.keySet().iterator();
String urlString = it.next();
jsonObject.put("fileUrl", urlString);
jsonObject.put("fileName", code);
}
} catch (IOException e) {
e.printStackTrace();
}
return jsonObject;
}
}
package com.yeejoin.amos.boot.module.app.biz.strategy;
import java.util.Map;
public interface ISearchDetailHandler<T extends Map<String, Object>> {
/**
* 可处理方式
* @return 处理方式
*/
String manageType();
/**
* 处理处理
* @param applyNo 单号
* @param from 来源
* @return T
*/
T hanlder(String applyNo, String from);
}
package com.yeejoin.amos.boot.module.app.biz.strategy;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
@Component
public class SearchDetailStrategyContext implements ApplicationContextAware {
private static final Map<String, ISearchDetailHandler> handlerMap = new ConcurrentHashMap<>();
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
Map<String, ISearchDetailHandler> searchHandlerMap = applicationContext.getBeansOfType(ISearchDetailHandler.class);
if (searchHandlerMap.isEmpty()) {
return;
}
for (ISearchDetailHandler handler : searchHandlerMap.values()) {
handlerMap.put(handler.manageType(), handler);
}
}
public static ISearchDetailHandler getHandler(String type) {
return Optional.ofNullable(handlerMap.get(type)).orElseThrow(() -> new RuntimeException(String.format("not found %s type strategy", type)));
}
}
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