diff --git a/renren-admin/src/main/java/io/renren/modules/demanData/listener/DemandDataListener.java b/renren-admin/src/main/java/io/renren/modules/demanData/listener/DemandDataListener.java index 5893ba61..c0ae1890 100644 --- a/renren-admin/src/main/java/io/renren/modules/demanData/listener/DemandDataListener.java +++ b/renren-admin/src/main/java/io/renren/modules/demanData/listener/DemandDataListener.java @@ -1,8 +1,7 @@ package io.renren.modules.demanData.listener; import com.alibaba.fastjson.JSONObject; -import com.google.gson.Gson; -import com.google.gson.JsonElement; +import com.google.gson.*; import io.renren.modules.demanData.dto.TDemandDataDTO; import io.renren.modules.demanData.service.TDemandDataService; import io.renren.modules.sys.dto.SysDeptDTO; @@ -22,6 +21,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; +import java.lang.reflect.Type; +import java.util.Date; import java.util.Map; /** @@ -51,7 +52,7 @@ public class DemandDataListener implements TaskListener, ExecutionListener, Acti @Override public void notify(DelegateExecution execution) throws Exception { - + execution.getProcessBusinessKey(); } @Override @@ -100,7 +101,15 @@ public class DemandDataListener implements TaskListener, ExecutionListener, Acti private void create(DelegateTask delegateTask, final SysRoleDTO roleDTO) { Map kv = delegateTask.getVariables(); - Gson gson = new Gson(); + GsonBuilder builder = new GsonBuilder(); + builder.registerTypeAdapter(Date.class, new JsonDeserializer() { + public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { + return new Date(json.getAsJsonPrimitive().getAsLong()); + } + }); + + Gson gson = builder.create(); +// Gson gson = new Gson(); JsonElement jsonElement = gson.toJsonTree(kv); TDemandDataDTO demandDataDTO = gson.fromJson(jsonElement, TDemandDataDTO.class);