Commit 016ed367 authored by suhuiguang's avatar suhuiguang

1.增加证扫描逻辑

parent aae3334d
......@@ -10,6 +10,12 @@ public @interface FieldDisplayDefine {
String value();
/**
* 字段别名 兼容前端使用
* @return 别名key
*/
String alias() default "";
boolean isExist() default true;
Class<? extends Converter> converter() default DefaultConverter.class;
......
......@@ -22,7 +22,7 @@ public class CylinderInfoForWX {
@FieldDisplayDefine(value = "制造单位")
private String produceUnitName;
@FieldDisplayDefine(value = "制造年月")
@FieldDisplayDefine(value = "制造年月", alias="produceDateStr")
private String produceDate;
@FieldDisplayDefine(value = "充装介质", converter = ChargeMediaConverter.class)
......@@ -34,10 +34,10 @@ public class CylinderInfoForWX {
@FieldDisplayDefine(value = "容积(L)")
private String singleBottleVolume;
@FieldDisplayDefine(value = "最近一次检验日期")
@FieldDisplayDefine(value = "最近一次检验日期", alias="lastInspectDateStr")
private String lastInspectDate;
@FieldDisplayDefine(value = "下次检验日期")
@FieldDisplayDefine(value = "下次检验日期", alias="nextInspectDateStr")
private String nextInspectDate;
@FieldDisplayDefine(value = "检验结果" ,converter = InspectResultConverter.class)
......
......@@ -10,9 +10,12 @@ public class VehicleInfoForWX {
@FieldDisplayDefine(value = "车牌号")
private String carNumber;
@FieldDisplayDefine(value = "使用登记证编号")
@FieldDisplayDefine(value = "使用登记证编号" ,isExist = false)
private String useRegistrationCode;
@FieldDisplayDefine(value = "使用登记证状态" ,isExist = false)
private String certificateStatus;
@FieldDisplayDefine(value = "设备类别")
private String equCategory;
......
......@@ -85,7 +85,8 @@
equ_category,
gas_num,
use_unit_address,
use_unit_name
use_unit_name,
certificate_status
FROM
"tzs_jg_use_registration_manage"
where
......
......@@ -130,11 +130,11 @@ public class TzsAppController {
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping(value = "/certInfoWX")
@GetMapping(value = "/{certSeq}/certInfo")
@ApiOperation(httpMethod = "GET", value = "小程序获取登记证或者使用标志详情", notes = "小程序获取登记证或者使用标志详情")
public ResponseModel<Map> getCertInfoForWX(@RequestParam String applyNo,
@RequestParam String from) {
return ResponseHelper.buildResponse(appService.getCertInfoForWX(applyNo,from));
public ResponseModel<Map> getCertInfoForWX(@PathVariable String certSeq,
@RequestParam(required = false) String certType) {
return ResponseHelper.buildResponse(appService.getCertInfoForWX(certSeq,certType));
}
......
......@@ -7,7 +7,7 @@ import java.util.Collections;
import java.util.Map;
@Component
public class SetSearchDetailDetailHandlerImpl implements ISearchDetailHandler<Map<String, Object>> {
public class SetSearchDetailDetailHandlerImpl implements ISearchDetailHandler {
@Override
public String manageType() {
return "set";
......
......@@ -264,17 +264,19 @@ public class TzsAppService {
return map;
}
public Map<String, Object> getCertInfoForWX(String applyNo, String from) {
// 单位办理方式[unit](气瓶、压力管道)、台套办理方式[set](7大类,不包含压力管道)、车用气瓶(压力容器->气瓶)
public Map<String, Object> getCertInfoForWX(String certSeq, String certType) {
return SearchDetailStrategyContext.getHandler(this.getManageType(certSeq)).hanlder(certSeq, certType);
}
private String getManageType(String applyNo) {
// 3类:单位办理方式[unit](气瓶、压力管道)、台套办理方式[set](7大类,不包含压力管道)、车用气瓶[vehicle](压力容器->气瓶)
JgUseRegistrationManageDto jgUseRegistrationManage = commonMapper.selectOneCert(applyNo);
// 使用登记、车用气瓶登记
String regType = jgUseRegistrationManage.getRegType();
// unit、set、null
String manageType = jgUseRegistrationManage.getManageType() == null ? "set" : jgUseRegistrationManage.getManageType();
if (REG_TYPE_VEHICLE.equals(regType)) {
return SearchDetailStrategyContext.getHandler("vehicle").hanlder(applyNo, from);
return "vehicle";
}
return SearchDetailStrategyContext.getHandler(manageType).hanlder(applyNo, from);
return jgUseRegistrationManage.getManageType() == null ? "set" : jgUseRegistrationManage.getManageType();
}
......
......@@ -7,7 +7,7 @@ import java.util.Collections;
import java.util.Map;
@Component
public class UnitSearchDetailDetailHandlerImpl implements ISearchDetailHandler<Map<String,Object>> {
public class UnitSearchDetailDetailHandlerImpl implements ISearchDetailHandler {
@Override
public String manageType() {
return "unit";
......
......@@ -11,6 +11,7 @@ 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.commons.lang3.StringUtils;
import org.apache.http.entity.ContentType;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Component;
......@@ -23,7 +24,7 @@ import java.lang.reflect.Field;
import java.util.*;
@Component
public class VehicleSearchDetailDetailHandlerImpl implements ISearchDetailHandler<Map<String, Object>> {
public class VehicleSearchDetailDetailHandlerImpl implements ISearchDetailHandler {
private final AppCommonMapper appCommonMapper;
......@@ -38,17 +39,17 @@ public class VehicleSearchDetailDetailHandlerImpl implements ISearchDetailHandle
}
@Override
public Map<String, Object> hanlder(String applyNo, String from) {
return this.getQueryCarCylinderInfo(applyNo);
public Map<String, Object> hanlder(String certSeq, String certType) {
return this.getQueryCarCylinderInfo(certSeq);
}
private Map<String, Object> getQueryCarCylinderInfo(String qrCode) {
VehicleInfoForWX baseInfo = appCommonMapper.queryVehicleBaseInfo(qrCode);
List<CylinderInfoForWX> cylinderInfos = appCommonMapper.queryCylinderIfoOfVehicle(qrCode);
private Map<String, Object> getQueryCarCylinderInfo(String certSeq) {
VehicleInfoForWX baseInfo = appCommonMapper.queryVehicleBaseInfo(certSeq);
List<CylinderInfoForWX> cylinderInfos = appCommonMapper.queryCylinderIfoOfVehicle(certSeq);
fillEquDefine(baseInfo, cylinderInfos);
Map<String, Object> result = new LinkedHashMap<>();
JSONArray tabs = new JSONArray();
buildFixFields(qrCode, baseInfo, result);
buildFixFields(baseInfo, result);
buildOneItemTypeMap( baseInfo, tabs);
buildManyItemTypeTab(cylinderInfos, tabs);
result.put("tab", tabs);
......@@ -59,29 +60,34 @@ public class VehicleSearchDetailDetailHandlerImpl implements ISearchDetailHandle
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());
private void buildFixFields(VehicleInfoForWX baseInfo, Map<String, Object> result) {
result.put("useUnitName", baseInfo.getUseUnitName());
result.put("equList", baseInfo.getEquList());
result.put("useRegistrationCode", baseInfo.getUseRegistrationCode());
result.put("status", baseInfo.getCertificateStatus());
// 控制颜色 扩展证状态使用
result.put("color", "#00FF00");
}
private void buildManyItemTypeTab(List<CylinderInfoForWX> cylinderInfos, JSONArray tabs) {
JSONObject tab = new JSONObject();
tab.put("title", "气瓶信息");
tab.put("tabKey", "cylinderInfo");
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);
tab.put("tabKey", "baseInfo");
tab.put("tabValue", this.buildFieldsOneGroup(baseInfo));
tabs.add(tab);
}
private Object buildFieldsNoGroup(VehicleInfoForWX baseInfo) {
private JSONArray buildFieldsOneGroup(VehicleInfoForWX baseInfo) {
JSONArray groupArray = new JSONArray();
JSONObject group = new JSONObject();
JSONArray fieldArray = new JSONArray();
Field[] fields = baseInfo.getClass().getDeclaredFields();
for (Field field : fields) {
......@@ -92,7 +98,7 @@ public class VehicleSearchDetailDetailHandlerImpl implements ISearchDetailHandle
String fieldName = displayDefine.value();
JSONObject json = new JSONObject();
json.put("fieldName", fieldName);
json.put("fieldKey", field.getName());
json.put("fieldKey", StringUtils.isNotBlank(displayDefine.alias()) ? displayDefine.alias() : field.getName());
json.put("fieldValue", field.get(baseInfo));
fieldArray.add(json);
}
......@@ -100,7 +106,11 @@ public class VehicleSearchDetailDetailHandlerImpl implements ISearchDetailHandle
throw new RuntimeException(e);
}
}
return fieldArray;
group.put("groupKey", "baseInfo");
group.put("groupName", "");
group.put("groupValue", fieldArray);
groupArray.add(group);
return groupArray;
}
private Object buildFieldsWithGroup(List<CylinderInfoForWX> cylinderInfos) {
......@@ -117,7 +127,7 @@ public class VehicleSearchDetailDetailHandlerImpl implements ISearchDetailHandle
String fieldName = displayDefine.value();
JSONObject json = new JSONObject();
json.put("fieldName", fieldName);
json.put("fieldKey", field.getName());
json.put("fieldKey", StringUtils.isNotBlank(displayDefine.alias()) ? displayDefine.alias() : field.getName());
Converter<String> converter = displayDefine.converter().newInstance();
if(field.get(cylinderInfo) != null){
json.put("fieldValue", converter.convertToLabelData((String)field.get(cylinderInfo)));
......@@ -130,8 +140,9 @@ public class VehicleSearchDetailDetailHandlerImpl implements ISearchDetailHandle
throw new RuntimeException(e);
}
}
group.put("groupKey", cylinderInfo.getEquCode());
group.put("groupName", String.format("气瓶(%s)", cylinderInfo.getFactoryNum()));
group.put("groupFields", fieldArray);
group.put("groupValue", fieldArray);
groupArray.add(group);
}
return groupArray;
......
......@@ -2,7 +2,7 @@ package com.yeejoin.amos.boot.module.app.biz.strategy;
import java.util.Map;
public interface ISearchDetailHandler<T extends Map<String, Object>> {
public interface ISearchDetailHandler {
/**
* 可处理方式
......@@ -16,5 +16,5 @@ public interface ISearchDetailHandler<T extends Map<String, Object>> {
* @param from 来源
* @return T
*/
T hanlder(String applyNo, String from);
Map<String, Object> hanlder(String applyNo, String from);
}
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