提交 5a41e138 编写于 作者: Z zhourui

fix/wrapCopy

上级 3ac04111
package com.x.base.core.project.bean;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import org.apache.commons.beanutils.PropertyUtilsBean;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.reflect.FieldUtils;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.tools.ListTools;
public class WrapCopier<T, W> {
......@@ -46,9 +50,19 @@ public class WrapCopier<T, W> {
}
copyFields.stream().forEach(f -> {
try {
Object o = propertyUtilsBean.getProperty(orig, f);
if (null != o || (!ignoreNull)) {
propertyUtilsBean.setProperty(dest, f, o);
if (StringUtils.equals(f, JpaObject.IDCOLUMN)) {
Field field = FieldUtils.getField(orig.getClass(), f, true);
if (null != field) {
Object o = FieldUtils.readField(field, orig, true);
if (null != o || (!ignoreNull)) {
propertyUtilsBean.setProperty(dest, f, o);
}
}
} else {
Object o = propertyUtilsBean.getProperty(orig, f);
if (null != o || (!ignoreNull)) {
propertyUtilsBean.setProperty(dest, f, o);
}
}
} catch (Exception e) {
e.printStackTrace();
......
......@@ -2,6 +2,7 @@ package com.x.base.core.project.utils.time;
import java.text.ParseException;
import java.util.Calendar;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
......@@ -196,7 +197,11 @@ public class BaseWorkTime {
return false;
}
private boolean inDefinedHoliday(Calendar c) {
public boolean inDefinedHoliday(Date d) {
return this.inDefinedHoliday(DateUtils.toCalendar(d));
}
public boolean inDefinedHoliday(Calendar c) {
if (ArrayUtils.isNotEmpty(this.definedHolidays)) {
if (ArrayUtils.indexOf(this.definedHolidays,
DateFormatUtils.format(c, DATEPARTFORMATPATTERN[0])) > ArrayUtils.INDEX_NOT_FOUND) {
......@@ -206,7 +211,11 @@ public class BaseWorkTime {
return false;
}
private boolean inDefinedWorkday(Calendar c) {
public boolean inDefinedWorkday(Date d) {
return this.inDefinedWorkday(DateUtils.toCalendar(d));
}
public boolean inDefinedWorkday(Calendar c) {
if (ArrayUtils.isNotEmpty(this.definedWorkdays)) {
if (ArrayUtils.indexOf(this.definedWorkdays,
DateFormatUtils.format(c, DATEPARTFORMATPATTERN[0])) > ArrayUtils.INDEX_NOT_FOUND) {
......
package com.x.general.assemble.control.jaxrs.worktime;
import java.util.Date;
import com.x.base.core.project.config.Config;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WrapBoolean;
import com.x.base.core.project.tools.DateTools;
public class ActionInDefinedHoliday extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String date) throws Exception {
ActionResult<Wo> result = new ActionResult<>();
Date value = DateTools.parse(date);
Wo wo = new Wo();
wo.setValue(Config.workTime().inDefinedHoliday(value));
result.setData(wo);
return result;
}
public static class Wo extends WrapBoolean {
}
}
package com.x.general.assemble.control.jaxrs.worktime;
import java.util.Date;
import com.x.base.core.project.config.Config;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WrapBoolean;
import com.x.base.core.project.tools.DateTools;
public class ActionInDefinedWorkDay extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String date) throws Exception {
ActionResult<Wo> result = new ActionResult<>();
Date value = DateTools.parse(date);
Wo wo = new Wo();
wo.setValue(Config.workTime().inDefinedWorkday(value));
result.setData(wo);
return result;
}
public static class Wo extends WrapBoolean {
}
}
......@@ -156,4 +156,40 @@ public class WorkTimeAction extends StandardJaxrsAction {
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "返回指定时间是否定义为节假日.", action = ActionInDefinedHoliday.class)
@GET
@Path("indefinedholiday/{date}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void inDefinedHoliday(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("指定日期") @PathParam("date") String date) {
ActionResult<ActionInDefinedHoliday.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionInDefinedHoliday().execute(effectivePerson, date);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "返回指定时间是否定义为工作日.", action = ActionInDefinedWorkDay.class)
@GET
@Path("indefinedworkday/{date}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void inDefinedWorkDay(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("指定日期") @PathParam("date") String date) {
ActionResult<ActionInDefinedWorkDay.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionInDefinedWorkDay().execute(effectivePerson, date);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册