Преглед изворни кода

完成调度对话记录模块功能

oyq28 пре 3 година
родитељ
комит
cbf39850c6
10 измењених фајлова са 390 додато и 0 уклоњено
  1. 10 0
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/dispatchRecord/dao/DispatchExceptionMapper.java
  2. 10 0
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/dispatchRecord/dao/DispatchRecordMapper.java
  3. 7 0
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/dispatchRecord/service/DispatchExceptionService.java
  4. 8 0
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/dispatchRecord/service/DispatchRecordService.java
  5. 23 0
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/dispatchRecord/service/impl/DispatchExceptionServiceImpl.java
  6. 22 0
      imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/dispatchRecord/service/impl/DispatchRecordServiceImpl.java
  7. 96 0
      imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/dispatchRecord/DispatchExceptionController.java
  8. 96 0
      imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/dispatchRecord/DispatchRecordController.java
  9. 62 0
      imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/dispatchRecord/entity/DispatchException.java
  10. 56 0
      imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/dispatchRecord/entity/DispatchRecord.java

+ 10 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/dispatchRecord/dao/DispatchExceptionMapper.java

@@ -0,0 +1,10 @@
+package com.github.zuihou.business.dispatchRecord.dao;
+
+import com.github.zuihou.base.mapper.SuperMapper;
+import com.github.zuihou.business.dispatchRecord.entity.DispatchException;
+import com.github.zuihou.business.dispatchRecord.entity.DispatchRecord;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface DispatchExceptionMapper extends SuperMapper<DispatchException> {
+}

+ 10 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/dispatchRecord/dao/DispatchRecordMapper.java

@@ -0,0 +1,10 @@
+package com.github.zuihou.business.dispatchRecord.dao;
+
+import com.github.zuihou.base.mapper.SuperMapper;
+import com.github.zuihou.business.dispatchRecord.entity.DispatchRecord;
+import com.github.zuihou.business.edgeLibrary.entity.Shelves;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface DispatchRecordMapper extends SuperMapper<DispatchRecord> {
+}

+ 7 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/dispatchRecord/service/DispatchExceptionService.java

@@ -0,0 +1,7 @@
+package com.github.zuihou.business.dispatchRecord.service;
+
+import com.github.zuihou.base.service.SuperCacheService;
+import com.github.zuihou.business.dispatchRecord.entity.DispatchException;
+
+public interface DispatchExceptionService extends SuperCacheService<DispatchException> {
+}

+ 8 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/dispatchRecord/service/DispatchRecordService.java

@@ -0,0 +1,8 @@
+package com.github.zuihou.business.dispatchRecord.service;
+
+import com.github.zuihou.base.service.SuperCacheService;
+import com.github.zuihou.business.dispatchRecord.entity.DispatchRecord;
+
+public interface DispatchRecordService extends SuperCacheService<DispatchRecord> {
+
+}

+ 23 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/dispatchRecord/service/impl/DispatchExceptionServiceImpl.java

@@ -0,0 +1,23 @@
+package com.github.zuihou.business.dispatchRecord.service.impl;
+
+import com.github.zuihou.base.service.SuperCacheServiceImpl;
+import com.github.zuihou.business.dispatchRecord.dao.DispatchExceptionMapper;
+import com.github.zuihou.business.dispatchRecord.dao.DispatchRecordMapper;
+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 lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import static com.github.zuihou.common.constant.CacheKey.TENANT;
+
+@Slf4j
+@Service
+public class DispatchExceptionServiceImpl extends SuperCacheServiceImpl<DispatchExceptionMapper, DispatchException> implements DispatchExceptionService {
+
+    @Override
+    protected String getRegion() {
+        return TENANT;
+    }
+}

+ 22 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/dispatchRecord/service/impl/DispatchRecordServiceImpl.java

@@ -0,0 +1,22 @@
+package com.github.zuihou.business.dispatchRecord.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.github.zuihou.base.service.SuperCacheServiceImpl;
+import com.github.zuihou.business.dispatchRecord.dao.DispatchRecordMapper;
+import com.github.zuihou.business.dispatchRecord.entity.DispatchRecord;
+import com.github.zuihou.business.dispatchRecord.service.DispatchRecordService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import static com.github.zuihou.common.constant.CacheKey.TENANT;
+
+@Slf4j
+@Service
+public class DispatchRecordServiceImpl extends SuperCacheServiceImpl<DispatchRecordMapper, DispatchRecord> implements DispatchRecordService {
+
+    @Override
+    protected String getRegion() {
+        return TENANT;
+    }
+}

+ 96 - 0
imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/dispatchRecord/DispatchExceptionController.java

@@ -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 "";
+               }
+           }
+       }
+
+}

+ 96 - 0
imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/dispatchRecord/DispatchRecordController.java

@@ -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.DispatchRecord;
+import com.github.zuihou.business.dispatchRecord.service.DispatchRecordService;
+import com.github.zuihou.business.productionResourceCenter.entity.Tool;
+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.List;
+import java.util.Map;
+
+@Slf4j
+@Validated
+@RestController
+@RequestMapping("/dispatchRecord")
+@Api(value = "dispatchRecord", tags = "调度对话")
+@SysLog(enabled = true)
+public class DispatchRecordController extends SuperSimpleController<DispatchRecordService, DispatchRecord> {
+
+    @ApiOperation(value = "查询设备刀具管理", notes = "查询设备刀具管理")
+    @PostMapping("/page")
+    public R<IPage<DispatchRecord>> page(@RequestBody @Validated PageParams<DispatchRecord> params) {
+        IPage<DispatchRecord> page = params.buildPage();
+        QueryWrap<DispatchRecord> wrap = handlerWrapper(null, params);
+        LbqWrapper<DispatchRecord> wrapper = wrap.lambda();
+        wrapper.like(DispatchRecord::getName, params.getModel().getName())
+                .orderByDesc(DispatchRecord::getCreateTime);
+        baseService.page(page, wrapper);
+        return this.success(page);
+    }
+
+    private QueryWrap<DispatchRecord> handlerWrapper(DispatchRecord model, PageParams<DispatchRecord> params) {
+       QueryWrap<DispatchRecord> 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 "";
+               }
+           }
+       }
+
+}

+ 62 - 0
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/dispatchRecord/entity/DispatchException.java

@@ -0,0 +1,62 @@
+package com.github.zuihou.business.dispatchRecord.entity;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.github.zuihou.base.entity.Entity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.*;
+import lombok.experimental.Accessors;
+import org.hibernate.validator.constraints.Length;
+
+import java.time.LocalDateTime;
+
+import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;
+
+@Data
+@NoArgsConstructor
+@ToString(callSuper = true)
+@EqualsAndHashCode(callSuper = true)
+@Accessors(chain = true)
+@TableName("imcs_dispatch_exception")
+@ApiModel(value = "DispatchException", description = "调度异常处理")
+@AllArgsConstructor
+public class DispatchException  extends Entity<Long> {
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "指令内容")
+    @Length(max = 128, message = "名称长度不能超过128")
+    @TableField(value = "name", condition = LIKE)
+    @Excel(name = "指令内容")
+    private String name;
+
+    @ApiModelProperty(value = "操作设备")
+    @Length(max = 128, message = "名称长度不能超过128")
+    @TableField(value = "device", condition = LIKE)
+    @Excel(name = "device")
+    private String device;
+
+    @ApiModelProperty(value = "执行时间")
+    @TableField(value = "operation_time", condition = LIKE)
+    @Excel(name = "执行时间")
+    private LocalDateTime operationTime;
+
+    @ApiModelProperty(value = "状态(1-运行中2-执行失败3-发送失败)")
+    @TableField(value = "status", condition = LIKE)
+    @Length(max = 1, message = "名称长度不能超过1")
+    @Excel(name = "状态(1-运行中2-执行失败3-发送失败)")
+    private String status;
+
+    @Builder
+    public DispatchException(LocalDateTime createTime, Long createUser, LocalDateTime updateTime, Long updateUser, String name, String device, LocalDateTime operationTime, String status) {
+        this.name = name;
+        this.device = device;
+        this.operationTime = operationTime;
+        this.status = status;
+        this.createTime = createTime;
+        this.createUser = createUser;
+        this.updateTime = updateTime;
+        this.updateUser = updateUser;
+    }
+}

+ 56 - 0
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/dispatchRecord/entity/DispatchRecord.java

@@ -0,0 +1,56 @@
+package com.github.zuihou.business.dispatchRecord.entity;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.github.zuihou.base.entity.Entity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.*;
+import lombok.experimental.Accessors;
+import org.hibernate.validator.constraints.Length;
+
+import java.time.LocalDateTime;
+
+import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;
+
+@Data
+@NoArgsConstructor
+@ToString(callSuper = true)
+@EqualsAndHashCode(callSuper = true)
+@Accessors(chain = true)
+@TableName("imcs_dispatch_record")
+@ApiModel(value = "DispatchRecord", description = "调度对话记录")
+@AllArgsConstructor
+public class DispatchRecord extends Entity<Long> {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 名称
+     */
+    @ApiModelProperty(value = "指令内容")
+    @Length(max = 128, message = "名称长度不能超过128")
+    @TableField(value = "name", condition = LIKE)
+    @Excel(name = "指令内容")
+    private String name;
+
+
+    @ApiModelProperty(value = "下发时间")
+    @TableField(value = "distribute_time", condition = LIKE)
+    @Excel(name = "下发时间")
+    private LocalDateTime distributeTime;
+
+
+    @Builder
+    public DispatchRecord(Long id, LocalDateTime createTime, Long updateUser, Long createUser, LocalDateTime updateTime,
+                  LocalDateTime distributeTime, String name) {
+        this.id = id;
+        this.createTime = createTime;
+        this.updateUser = updateUser;
+        this.createUser = createUser;
+        this.updateTime = updateTime;
+        this.name = name;
+        this.distributeTime = distributeTime;
+    }
+
+}