Commit 611f4102 authored by suhuiguang's avatar suhuiguang

1邢磊增加返字段

parent e88422f6
...@@ -48,7 +48,8 @@ ...@@ -48,7 +48,8 @@
(SELECT cdd1.NAME from cb_data_dictionary cdd1 where cdd1.code = tzjia.inspection_classify AND cdd1.TYPE = 'JYJCLB' limit 1) as inspectionClassify, (SELECT cdd1.NAME from cb_data_dictionary cdd1 where cdd1.code = tzjia.inspection_classify AND cdd1.TYPE = 'JYJCLB' limit 1) as inspectionClassify,
(SELECT cdd2.NAME from cb_data_dictionary cdd2 where cdd2.code = tzjia.status and cdd2.type = 'JYLCZT' limit 1) AS statusName, (SELECT cdd2.NAME from cb_data_dictionary cdd2 where cdd2.code = tzjia.status and cdd2.type = 'JYLCZT' limit 1) AS statusName,
(SELECT cdd3.NAME from cb_data_dictionary cdd3 where cdd3.code = tzjia.inspection_type and cdd3.type = 'JYJC' limit 1) AS inspectionType, (SELECT cdd3.NAME from cb_data_dictionary cdd3 where cdd3.code = tzjia.inspection_type and cdd3.type = 'JYJC' limit 1) AS inspectionType,
(SELECT name FROM "tz_equipment_category" ca where ca.code = tzjia.equip_classify) AS equipClassify (SELECT name FROM "tz_equipment_category" ca where ca.code = tzjia.equip_classify) AS equipClassify,
tzjia.equip_classify as equListCode
FROM FROM
tz_jyjc_inspection_application AS tzjia, tz_jyjc_inspection_application AS tzjia,
tz_base_enterprise_info b tz_base_enterprise_info b
......
package com.yeejoin.amos.boot.module.statistcs.biz.config;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import org.apache.commons.lang3.StringUtils;
import org.typroject.tyboot.core.foundation.utils.DateTimeUtil;
import java.io.IOException;
import java.lang.reflect.Field;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* @JsonComponent 会覆盖JsonFormat, 这里解析字段提升JsonFormat优先级
* <p>
* ProjectName: amos-boot-biz
* PackageName: com.yeejoin.amos.boot.module.jg.biz.config
*
* @author yangyang
* @version v1.0
* @date 2023/12/18 17:35
*/
public class BizCustomDateSerializer extends StdSerializer<Date> {
private List<String> customFields = Arrays.asList("acceptDate", "expiryDate","applicationDate");
public BizCustomDateSerializer()
{
super(Date.class);
}
@Override
public void serialize(Date value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
try {
Class<?> clazz = jgen.getCurrentValue().getClass();
if (Objects.equals(clazz, HashMap.class)) {
// 分页参数
if (customFields.contains(jgen.getOutputContext().getCurrentName())) {
SimpleDateFormat formatter = new SimpleDateFormat(DateTimeUtil.ISO_DATE);
jgen.writeString(formatter.format(value));
return;
}
} else {
Field field = clazz.getDeclaredField(jgen.getOutputContext().getCurrentName());
if (Objects.equals(field.getType(), Date.class)) {
if (field.isAnnotationPresent(JsonFormat.class)) {
String pattern = field.getAnnotation(JsonFormat.class).pattern();
if (StringUtils.isNotBlank(pattern)) {
SimpleDateFormat formatter = new SimpleDateFormat(pattern);
jgen.writeString(formatter.format(value));
return;
}
}
}
}
jgen.writeString(defaultFormattedDate(value));
} catch (Exception e) {
jgen.writeString(defaultFormattedDate(value));
}
}
private String defaultFormattedDate(Date value) {
SimpleDateFormat formatter = new SimpleDateFormat(DateTimeUtil.ISO_DATE_HOUR24_MIN_SEC);
return formatter.format(value);
}
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.statistcs.biz.config;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import org.springframework.boot.jackson.JsonComponent;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import org.typroject.tyboot.core.restful.config.BaseModelSerializer;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Date;
/**
* Created by yaohelang on 2019/1/18.
*/
@JsonComponent
public class BizJsonSerializerManage {
@Bean
@Primary
public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder) {
ObjectMapper objectMapper = builder.createXmlMapper(false).build();
/**
* 序列换成json时,将所有的long变成string
* 因为js中得数字类型不能包含所有的java long值
*/
/**
* 序列换成json时,将所有的long变成string
* 因为js中得数字类型不能包含所有的java long值
*/
SimpleModule simpleModule = new SimpleModule();
simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance);
BizCustomDateSerializer customDateSerializer = new BizCustomDateSerializer();
simpleModule.addSerializer(Date.class,customDateSerializer);
//序列化将BigInteger转String类型
simpleModule.addSerializer(BigInteger.class, ToStringSerializer.instance);
//序列化将BigDecimal转String类型
simpleModule.addSerializer(BigDecimal.class, ToStringSerializer.instance);
simpleModule.addSerializer(BaseModel.class,new BaseModelSerializer());
objectMapper.registerModule(simpleModule);
return objectMapper;
}
}
\ No newline at end of file
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