|
@@ -0,0 +1,96 @@
|
|
|
+package com.github.zuihou.business.controller.dispatchRecord;
|
|
|
+
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.util.ReflectUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.baomidou.mybatisplus.annotation.TableField;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.github.zuihou.base.R;
|
|
|
+import com.github.zuihou.base.controller.SuperSimpleController;
|
|
|
+import com.github.zuihou.base.request.PageParams;
|
|
|
+import com.github.zuihou.business.dispatchRecord.entity.DispatchException;
|
|
|
+import com.github.zuihou.business.dispatchRecord.entity.DispatchRecord;
|
|
|
+import com.github.zuihou.business.dispatchRecord.service.DispatchExceptionService;
|
|
|
+import com.github.zuihou.business.dispatchRecord.service.DispatchRecordService;
|
|
|
+import com.github.zuihou.database.mybatis.conditions.Wraps;
|
|
|
+import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
|
|
|
+import com.github.zuihou.database.mybatis.conditions.query.QueryWrap;
|
|
|
+import com.github.zuihou.log.annotation.SysLog;
|
|
|
+import com.github.zuihou.utils.DateUtils;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import java.lang.reflect.Field;
|
|
|
+import java.util.Iterator;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+@Validated
|
|
|
+@RestController
|
|
|
+@RequestMapping("/dispatchException")
|
|
|
+@Api(value = "dispatchException", tags = "调度异常")
|
|
|
+@SysLog(enabled = true)
|
|
|
+public class DispatchExceptionController extends SuperSimpleController<DispatchExceptionService, DispatchException> {
|
|
|
+
|
|
|
+ @ApiOperation(value = "查询设备刀具管理", notes = "查询设备刀具管理")
|
|
|
+ @PostMapping("/page")
|
|
|
+ public R<IPage<DispatchException>> page(@RequestBody @Validated PageParams<DispatchException> params) {
|
|
|
+ IPage<DispatchException> page = params.buildPage();
|
|
|
+ QueryWrap<DispatchException> wrap = handlerWrapper(null, params);
|
|
|
+ LbqWrapper<DispatchException> wrapper = wrap.lambda();
|
|
|
+ wrapper.like(DispatchException::getName, params.getModel().getName())
|
|
|
+ .orderByDesc(DispatchException::getCreateTime);
|
|
|
+ baseService.page(page, wrapper);
|
|
|
+ return this.success(page);
|
|
|
+ }
|
|
|
+
|
|
|
+ private QueryWrap<DispatchException> handlerWrapper(DispatchException model, PageParams<DispatchException> params) {
|
|
|
+ QueryWrap<DispatchException> wrapper = model == null ? Wraps.q() : Wraps.q(model);
|
|
|
+ if (CollUtil.isNotEmpty(params.getMap())) {
|
|
|
+ Map<String, String> map = params.getMap();
|
|
|
+ Iterator var5 = map.entrySet().iterator();
|
|
|
+
|
|
|
+ while (var5.hasNext()) {
|
|
|
+ Map.Entry<String, String> field = (Map.Entry) var5.next();
|
|
|
+ String key = (String) field.getKey();
|
|
|
+ String value = (String) field.getValue();
|
|
|
+ if (!StrUtil.isEmpty(value)) {
|
|
|
+ String beanField;
|
|
|
+ if (key.endsWith("_st")) {
|
|
|
+ beanField = StrUtil.subBefore(key, "_st", true);
|
|
|
+ wrapper.ge(this.getDbField(beanField, this.getEntityClass()), DateUtils.getStartTime(value));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (key.endsWith("_ed")) {
|
|
|
+ beanField = StrUtil.subBefore(key, "_ed", true);
|
|
|
+ wrapper.le(this.getDbField(beanField, this.getEntityClass()), DateUtils.getEndTime(value));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return wrapper;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getDbField(String beanField, Class<?> clazz) {
|
|
|
+ Field field = ReflectUtil.getField(clazz, beanField);
|
|
|
+ if (field == null) {
|
|
|
+ return "";
|
|
|
+ } else {
|
|
|
+ TableField tf = (TableField)field.getAnnotation(TableField.class);
|
|
|
+ if (tf != null && StringUtils.isNotEmpty(tf.value())) {
|
|
|
+ String str = tf.value();
|
|
|
+ return str;
|
|
|
+ } else {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|