bean2json 各种自定义


import java.io.Serializable;

import org.apache.commons.lang.StringUtils;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.xjgz.cdc.common.utils.TimeUtil;
import com.xjgz.cdc.common.utils.model.ModelPropertyAlias;
import com.xjgz.cdc.common.utils.model.ModelTableAlias;
import com.xjgz.cdc.model.hbase.enums.Sex;
import com.xjgz.cdc.model.subscribe.UserSubscribe.Color;
import com.xjgz.cdc.model.subscribe.UserSubscribe.HairStyle;
import com.xjgz.cdc.model.subscribe.UserSubscribe.SkinColor;
import com.xjgz.cdc.runtime.phoenix.PhoenixBaseBean;

/**
* 以图搜图
*
* @author wangjun
*
*/
/** 不序列化的属性 */
@JsonIgnoreProperties(value = { "id", "createTime", "success", "message", "result", "createResult", "historyResult", "imgSrc" })
/** null或者""不序列化 */
@JsonSerialize(include = JsonSerialize.Inclusion.NON_EMPTY)
@ModelTableAlias(tableName = "CDC_SEARCH_IMG_BY_IMG")
public class SearchImgByImg extends PhoenixBaseBean implements Serializable {

/** 唯一标识 */
@ModelPropertyAlias(column = "ID", rowkey = true)
private String id;

/** 检测时间开始范围 */
@ModelPropertyAlias(column = "S_PERSON_APPEAR_TIME")
private String sPersonAppearTime;

/** 检测时间开始范围 */
@ModelPropertyAlias(column = "E_PERSON_APPEAR_TIME")
private String ePersonAppearTime;

/** 判断性别 */
@ModelPropertyAlias(column = "GENDER_CODE")
private String genderCode;

/** 判断年龄开始区间 */
@ModelPropertyAlias(column = "S_AGE")
private String sAge;

/** 判断年龄结束区间 */
@ModelPropertyAlias(column = "E_AGE")
private String eAge;

/** 衣服颜色 */
@ModelPropertyAlias(column = "COAT_COLOR")
private String coatColor;

/** 裤子颜色 */
@ModelPropertyAlias(column = "TROUSERS_COLOR")
private String trousersColor;

/** 鞋子颜色 */
@ModelPropertyAlias(column = "SHOES_COLOR")
private String shoesColor;

/** 发型 */
@ModelPropertyAlias(column = "HAIR_STYLE")
private String hairStyle;

/** 肤色 */
@ModelPropertyAlias(column = "SKIN_COLOR")
private String skinColor;

/** 帽子颜色 */
@ModelPropertyAlias(column = "CAP_COLOR")
private String capColor;

/** 眼镜款式 */
@ModelPropertyAlias(column = "GLASS_STYLE")
private String glassStyle;

/** 眼镜颜色 */
@ModelPropertyAlias(column = "GLASS_COLOR")
private String glassColor;

/** 口罩颜色 */
@ModelPropertyAlias(column = "RESPIRATOR_COLOR")
private String respiratorColor;

/** 身高开始范围 */
@ModelPropertyAlias(column = "S_Height")
private String sHeight;

/** 身高结束范围 */
@ModelPropertyAlias(column = "E_HEIGHT")
private String eHeight;

/** 瞳孔距离开始区间 */
@ModelPropertyAlias(column = "S_PUPILS_DISTANCE")
private String sPupilsDistance;

/** 瞳孔距离结束区间 */
@ModelPropertyAlias(column = "E_PUPILS_DISTANCE")
private String ePupilsDistance;

/** 上传图片后返回的唯一码 */
@ModelPropertyAlias(column = "SERIAL_NUM")
private String serial_num;

/** 最低相似度 */
@ModelPropertyAlias(column = "SIMILARITY")
private String similarity;

/** 区域编号 */
@ModelPropertyAlias(column = "AREA_ID")
private String areaID;

/** 摄像头编号,多个以|隔开 */
@ModelPropertyAlias(column = "DEVICE_IDS")
private String deviceIDs;

/** 创建时间 */
@ModelPropertyAlias(column = "CREATE_TIME")
private String createTime;

/** true:成功,false:失败 */
@ModelPropertyAlias(column = "SUCCESS")
private String success;

/** 操作成功! */
@ModelPropertyAlias(column = "MESSAGE")
private String message;

/** 任务结果 */
@ModelPropertyAlias(column = "RESULT")
private String result;

/** 创建任务结果 */
@ModelPropertyAlias(column = "CREATE_RESULT")
private String createResult;

/** 历史任务结果 */
@ModelPropertyAlias(column = "HISTORY_RESULT")
private String historyResult;

/** 以图搜图图片的路径 */
@ModelPropertyAlias(column = "IMG_SRC")
private String imgSrc;

/** 结果状态 */
@ModelPropertyAlias(column = "STATES")
private String states = "1";

public SearchImgByImg() {
}

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

@JsonProperty("sPersonAppearTime")
public String getSPersonAppearTime() {
return sPersonAppearTime;
}

public void setSPersonAppearTime(String sPersonAppearTime) {
this.sPersonAppearTime = sPersonAppearTime;
}

@JsonProperty("ePersonAppearTime")
public String getEPersonAppearTime() {
return ePersonAppearTime;
}

public void setEPersonAppearTime(String ePersonAppearTime) {
this.ePersonAppearTime = ePersonAppearTime;
}

@JsonProperty("genderCode")
public String getGenderCode() {
return genderCode;
}

public void setGenderCode(String genderCode) {
this.genderCode = genderCode;
}

@JsonProperty("sAge")
public String getSAge() {
return sAge;
}

public void setSAge(String sAge) {
this.sAge = sAge;
}

@JsonProperty("eAge")
public String getEAge() {
return eAge;
}

public void setEAge(String eAge) {
this.eAge = eAge;
}

@JsonProperty("coatColor")
public String getCoatColor() {
return coatColor;
}

public void setCoatColor(String coatColor) {
this.coatColor = coatColor;
}

@JsonProperty("trousersColor")
public String getTrousersColor() {
return trousersColor;
}

public void setTrousersColor(String trousersColor) {
this.trousersColor = trousersColor;
}

@JsonProperty("shoesColor")
public String getShoesColor() {
return shoesColor;
}

public void setShoesColor(String shoesColor) {
this.shoesColor = shoesColor;
}

@JsonProperty("hairStyle")
public String getHairStyle() {
return hairStyle;
}

public void setHairStyle(String hairStyle) {
this.hairStyle = hairStyle;
}

@JsonProperty("skinColor")
public String getSkinColor() {
return skinColor;
}

public void setSkinColor(String skinColor) {
this.skinColor = skinColor;
}

@JsonProperty("capColor")
public String getCapColor() {
return capColor;
}

public void setCapColor(String capColor) {
this.capColor = capColor;
}

@JsonProperty("glassStyle")
public String getGlassStyle() {
return glassStyle;
}

public void setGlassStyle(String glassStyle) {
this.glassStyle = glassStyle;
}

@JsonProperty("glassColor")
public String getGlassColor() {
return glassColor;
}

public void setGlassColor(String glassColor) {
this.glassColor = glassColor;
}

@JsonProperty("respiratorColor")
public String getRespiratorColor() {
return respiratorColor;
}

public void setRespiratorColor(String respiratorColor) {
this.respiratorColor = respiratorColor;
}

@JsonProperty("sHeight")
public String getSHeight() {
return sHeight;
}

public void setSHeight(String sHeight) {
this.sHeight = sHeight;
}

@JsonProperty("eHeight")
public String getEHeight() {
return eHeight;
}

public void setEHeight(String eHeight) {
this.eHeight = eHeight;
}

@JsonProperty("sPupilsDistance")
public String getSPupilsDistance() {
return sPupilsDistance;
}

public void setSPupilsDistance(String sPupilsDistance) {
this.sPupilsDistance = sPupilsDistance;
}

@JsonProperty("ePupilsDistance")
public String getEPupilsDistance() {
return ePupilsDistance;
}

public void setEPupilsDistance(String ePupilsDistance) {
this.ePupilsDistance = ePupilsDistance;
}

@JsonProperty("serial_num")
public String getSerial_num() {
return serial_num;
}

public void setSerial_num(String serial_num) {
this.serial_num = serial_num;
}

@JsonProperty("similarity")
public String getSimilarity() {
return similarity;
}

public void setSimilarity(String similarity) {
this.similarity = similarity;
}

@JsonProperty("areaID")
public String getAreaID() {
return areaID;
}

public void setAreaID(String areaID) {
this.areaID = areaID;
}

@JsonProperty("deviceIDs")
public String getDeviceIDs() {
return deviceIDs;
}

public void setDeviceIDs(String deviceIDs) {
this.deviceIDs = deviceIDs;
}

public String getCreateTime() {
return createTime;
}

public void setCreateTime(String createTime) {
this.createTime = createTime;
}

public String getSuccess() {
return success;
}

public void setSuccess(String success) {
this.success = success;
}

public String getMessage() {
return message;
}

public void setMessage(String message) {
this.message = message;
}

public String getResult() {
return result;
}

public void setResult(String result) {
this.result = result;
}

public String getCreateResult() {
return createResult;
}

public void setCreateResult(String createResult) {
this.createResult = createResult;
}

public String getHistoryResult() {
return historyResult;
}

public void setHistoryResult(String historyResult) {
this.historyResult = historyResult;
}

public String getImgSrc() {
return imgSrc;
}

public void setImgSrc(String imgSrc) {
this.imgSrc = imgSrc;
}

public String getStates() {
return states;
}

public void setStates(String states) {
this.states = states;
}

@Override
public String toString() {

StringBuffer sb = new StringBuffer();
String f = " | ";
if (StringUtils.isNotEmpty(similarity)) {
sb.append("相似度:" + similarity + f);
}
if (StringUtils.isNotEmpty(sPersonAppearTime) && StringUtils.isNotEmpty(ePersonAppearTime)) {
String s = TimeUtil.dateToString(TimeUtil.StringToDate(sPersonAppearTime, "yyyyMMddHHmmss"), "yyyy年MM月dd日 HH:mm:ss");
String e = TimeUtil.dateToString(TimeUtil.StringToDate(ePersonAppearTime, "yyyyMMddHHmmss"), "yyyy年MM月dd日 HH:mm:ss");
sb.append("检索时间:" + s + "-" + e + f);
}
if (StringUtils.isNotEmpty(genderCode)) {
sb.append("性别:" + Sex.fromCodeOrDesc(genderCode).getDesc() + f);
}
if (StringUtils.isNotEmpty(skinColor)) {
sb.append("肤色:" + SkinColor.fromCodeOrDesc(skinColor).getDesc() + f);
}
if (StringUtils.isNotEmpty(hairStyle)) {
sb.append("发型:" + HairStyle.fromCodeOrDesc(hairStyle).getDesc() + f);
}
if (StringUtils.isNotEmpty(sAge) && StringUtils.isNotEmpty(eAge)) {
sb.append("年龄:" + sAge + "-" + eAge + "岁" + f);
}
if (StringUtils.isNotEmpty(sHeight) && StringUtils.isNotEmpty(eHeight)) {
sb.append("身高:" + sHeight + "-" + eHeight + "cm" + f);
}
if (StringUtils.isNotEmpty(sPupilsDistance) && StringUtils.isNotEmpty(ePupilsDistance)) {
sb.append("瞳孔距离:" + sPupilsDistance + "-" + ePupilsDistance + "mm" + f);
}
if (StringUtils.isNotEmpty(capColor)) {
sb.append("帽子颜色:" + Color.fromCodeOrDesc(capColor).getDesc() + f);
}
if (StringUtils.isNotEmpty(respiratorColor)) {
sb.append("口罩颜色:" + Color.fromCodeOrDesc(respiratorColor).getDesc() + f);
}
if (StringUtils.isNotEmpty(coatColor)) {
sb.append("衣服颜色:" + Color.fromCodeOrDesc(coatColor).getDesc() + f);
}
if (StringUtils.isNotEmpty(trousersColor)) {
sb.append("裤子颜色:" + Color.fromCodeOrDesc(trousersColor).getDesc() + f);
}
if (StringUtils.isNotEmpty(shoesColor)) {
sb.append("鞋子颜色:" + Color.fromCodeOrDesc(shoesColor).getDesc() + f);
}
if (StringUtils.isNotEmpty(glassColor)) {
sb.append("眼镜颜色:" + Color.fromCodeOrDesc(glassColor).getDesc() + f);
}
sb.delete(sb.length() - 3, sb.length());
return sb.toString();
}

public final static String TABLE_NAME = "CDC_SEARCH_IMG_BY_IMG";
public final static int FIELD_SIZE = 31;
public final static String FIELD_NAME = "ID,S_PERSON_APPEAR_TIME,E_PERSON_APPEAR_TIME,GENDER_CODE,S_AGE,E_AGE,COAT_COLOR,TROUSERS_COLOR,SHOES_COLOR,HAIR_STYLE,SKIN_COLOR,CAP_COLOR,GLASS_STYLE,GLASS_COLOR,RESPIRATOR_COLOR,S_HEIGHT,E_HEIGHT,S_PUPILS_DISTANCE,E_PUPILS_DISTANCE,SERIAL_NUM,SIMILARITY,AREA_ID,DEVICE_IDS,CREATE_TIME,SUCCESS,MESSAGE,RESULT,CREATE_RESULT,HISTORY_RESULT,IMG_SRC,STATES";
public final static String CREATE_SQL = "create table CDC_SEARCH_IMG_BY_IMG (ID varchar not null primary key,CDC.S_PERSON_APPEAR_TIME varchar,CDC.E_PERSON_APPEAR_TIME varchar,CDC.GENDER_CODE varchar,CDC.S_AGE varchar,CDC.E_AGE varchar,CDC.COAT_COLOR varchar,CDC.TROUSERS_COLOR varchar,CDC.SHOES_COLOR varchar,CDC.HAIR_STYLE varchar,CDC.SKIN_COLOR varchar,CDC.CAP_COLOR varchar,CDC.GLASS_STYLE varchar,CDC.GLASS_COLOR varchar,CDC.RESPIRATOR_COLOR varchar,CDC.S_HEIGHT varchar,CDC.E_HEIGHT varchar,CDC.S_PUPILS_DISTANCE varchar,CDC.E_PUPILS_DISTANCE varchar,CDC.SERIAL_NUM varchar,CDC.SIMILARITY varchar,CDC.AREA_ID varchar,CDC.DEVICE_IDS varchar,CDC.CREATE_TIME varchar,CDC.SUCCESS varchar,CDC.MESSAGE varchar,CDC.RESULT varchar,CDC.CREATE_RESULT varchar,CDC.HISTORY_RESULT varchar,CDC.IMG_SRC varchar,CDC.STATES varchar)";
}

你可能感兴趣的:(java,json,bean2json)