add:增加手持功能;
add:增加看板功能
This commit is contained in:
@@ -4,6 +4,7 @@ import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.alicp.jetcache.anno.config.EnableCreateCacheAnnotation;
|
||||
import com.alicp.jetcache.anno.config.EnableMethodCache;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
@@ -35,6 +36,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@EnableJpaAuditing(auditorAwareRef = "auditorAware")
|
||||
@EnableMethodCache(basePackages = "org.nl")
|
||||
@EnableCreateCacheAnnotation
|
||||
@MapperScan("org.nl.**.mapper")
|
||||
public class AppRun {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -31,7 +31,7 @@ import static org.nl.acs.agv.server.impl.NDCAgvServiceImpl.Bytes2HexString;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
//@Component
|
||||
public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
|
||||
Socket s;
|
||||
|
||||
@@ -207,7 +207,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
if (StrUtil.equals(inst.getInstruction_status(), "1")) {
|
||||
if (StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) {
|
||||
vehicle_code = inst.getVehicle_code();
|
||||
inst.setExecute_device_code(this.device_code);
|
||||
inst.setExecute_code(this.device_code);
|
||||
finish_instruction();
|
||||
logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈完成状态,反馈成功,指令号:" + task);
|
||||
} else {
|
||||
|
||||
@@ -191,7 +191,7 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
}
|
||||
if (StrUtil.equals(inst.getInstruction_status(), "1")) {
|
||||
if (!StrUtil.equals(inst.getExecute_code(), this.device_code)) {
|
||||
inst.setExecute_device_code(this.device_code);
|
||||
inst.setExecute_code(this.device_code);
|
||||
instructionService.update(inst);
|
||||
}
|
||||
}
|
||||
@@ -216,7 +216,7 @@ public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
if (mode == 0) {
|
||||
this.setIsonline(false);
|
||||
message = "未联机";
|
||||
|
||||
|
||||
} else {
|
||||
this.setIsonline(true);
|
||||
this.setIserror(false);
|
||||
|
||||
@@ -140,7 +140,7 @@ public interface InstructionService {
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
void finish(String id) throws Exception;
|
||||
void finish(String id) ;
|
||||
|
||||
/**
|
||||
* 完成指令
|
||||
@@ -163,7 +163,9 @@ public interface InstructionService {
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
void cancel(String id) throws Exception;
|
||||
void cancel(String id) ;
|
||||
void recover(String id) ;
|
||||
void pause(String id) ;
|
||||
|
||||
/**
|
||||
* 取消指令
|
||||
|
||||
@@ -227,7 +227,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
}
|
||||
|
||||
@Override
|
||||
public List queryAll(String whereJson) {
|
||||
public List<Instruction> queryAll(String whereJson) {
|
||||
WQLObject wo = WQLObject.getWQLObject("acs_instruction");
|
||||
JSONArray arr = wo.query(whereJson, "create_time").getResultJSONArray(0);
|
||||
List<Instruction> list = arr.toJavaList(Instruction.class);
|
||||
@@ -844,12 +844,12 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel(String id) throws Exception {
|
||||
public void cancel(String id) {
|
||||
// flag= true时取消指令
|
||||
boolean flag = false;
|
||||
Instruction entity = this.findById(id);
|
||||
if (entity == null) {
|
||||
throw new BadRequestException("被删除或无权限,操作失败!");
|
||||
throw new BadRequestException("指令不存在");
|
||||
}
|
||||
TaskDto task = taskService.findByCodeFromCache(entity.getTask_code());
|
||||
if (StrUtil.isEmpty(entity.getRoute_plan_code())) {
|
||||
@@ -1388,4 +1388,14 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recover(String id) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pause(String id) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ public interface TaskService {
|
||||
*
|
||||
* @param dto /
|
||||
*/
|
||||
void create(TaskDto dto) throws Exception;
|
||||
void create(TaskDto dto);
|
||||
|
||||
/**
|
||||
* 常规任务保存
|
||||
@@ -179,6 +179,8 @@ public interface TaskService {
|
||||
* @param ids
|
||||
*/
|
||||
void finish(String ids);
|
||||
//强制完成任务并调用外部系统
|
||||
void forchFinich(String code);
|
||||
|
||||
/**
|
||||
* 完成任务
|
||||
|
||||
@@ -430,7 +430,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void create(TaskDto dto) throws Exception {
|
||||
public void create(TaskDto dto) {
|
||||
// dto = foramte(dto);
|
||||
if (!StrUtil.isEmpty(dto.getVehicle_code())) {
|
||||
TaskDto vehicle_dto = this.findByContainer(dto.getVehicle_code());
|
||||
@@ -780,6 +780,21 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
||||
// }
|
||||
// }
|
||||
}
|
||||
public void forchFinich(String taskCode) {
|
||||
TaskDto entity = this.findByCode(taskCode);
|
||||
if (entity == null) throw new BadRequestException("任务不存在");
|
||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||
String now = DateUtil.now();
|
||||
entity.setUpdate_time(now);
|
||||
entity.setUpdate_by(currentUsername);
|
||||
entity.setTask_status("2");
|
||||
WQLObject wo = WQLObject.getWQLObject("acs_task");
|
||||
JSONObject json = (JSONObject) JSONObject.toJSON(entity);
|
||||
wo.update(json);
|
||||
removeByCodeFromCache(entity.getTask_code());
|
||||
// 判断是否为WMS下发的任务,如果是反馈任务状态给WMS
|
||||
String hasWms = paramService.findByCode(AcsConfig.HASWMS).getValue();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.nl.common.utils;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2022/11/29 2:55 下午
|
||||
*/
|
||||
public class MapOf implements Serializable {
|
||||
|
||||
public static <K> HashMap of(K... key) {
|
||||
HashMap map = new HashMap<>();
|
||||
for (int i = 0; i < (key.length & ~1); i = i + 2) {
|
||||
map.put(key[i], key[i + 1]);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package org.nl.common.utils;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.http.HttpStatus;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 表格分页数据对象
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class TableDataInfo<T> implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 列表数据
|
||||
*/
|
||||
/**
|
||||
* 消息状态码
|
||||
*/
|
||||
private Integer status;
|
||||
private String timestamp = DateUtil.now();
|
||||
/**
|
||||
* 消息内容
|
||||
*/
|
||||
private String message;
|
||||
/**
|
||||
* 反馈数据
|
||||
*/
|
||||
private Object data;
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param list 列表数据
|
||||
* @param total 总记录数
|
||||
*/
|
||||
public TableDataInfo(List<T> list, long total) {
|
||||
this.data = list;
|
||||
}
|
||||
|
||||
public static <T> TableDataInfo<T> build(IPage<T> page) {
|
||||
TableDataInfo<T> rspData = new TableDataInfo<>();
|
||||
rspData.setStatus(HttpStatus.HTTP_OK);
|
||||
rspData.setMessage("操作成功");
|
||||
rspData.setData(page.getRecords());
|
||||
return rspData;
|
||||
}
|
||||
|
||||
public static <T> TableDataInfo<T> build(List<T> list) {
|
||||
TableDataInfo<T> rspData = new TableDataInfo<>();
|
||||
rspData.setStatus(HttpStatus.HTTP_OK);
|
||||
rspData.setMessage("操作成功");
|
||||
rspData.setData(list);
|
||||
return rspData;
|
||||
}
|
||||
|
||||
public static <T> TableDataInfo<T> build() {
|
||||
TableDataInfo<T> rspData = new TableDataInfo<>();
|
||||
rspData.setStatus(HttpStatus.HTTP_OK);
|
||||
rspData.setMessage("操作成功");
|
||||
return rspData;
|
||||
}
|
||||
|
||||
public static <T> TableDataInfo<T> buildJson(Object result) {
|
||||
TableDataInfo<T> rspData = new TableDataInfo<>();
|
||||
rspData.setStatus(HttpStatus.HTTP_OK);
|
||||
rspData.setData(result);
|
||||
rspData.setMessage("操作成功");
|
||||
return rspData;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package org.nl.common.utils.query;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.LambdaUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.support.ColumnCache;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.utils.MapOf;
|
||||
import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 泛型必须为数据tb对应do:由mybatis管理
|
||||
* @author ZZQ
|
||||
* @Date 2022/12/14 6:33 下午
|
||||
*/
|
||||
@Data
|
||||
public class BaseQuery<T> {
|
||||
/**
|
||||
* 模糊查询
|
||||
*/
|
||||
private String blurry;
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
private String is_used;
|
||||
/**
|
||||
* 创建时间范围查询
|
||||
*/
|
||||
private String start_time;
|
||||
private String end_time;
|
||||
|
||||
|
||||
/**
|
||||
* 字段映射Map:指定字段对应QueryWrapper的查询类型
|
||||
* 字段与数据库字段对应,不支持驼峰
|
||||
* @see org.nl.common.enums.QueryTEnum
|
||||
* 通过buid构建
|
||||
*/
|
||||
public Map<String, QParam> doP = MapOf.of("blurry", QParam.builder().k(new String[]{"name"}).type(QueryTEnum.LK).build()
|
||||
,"startTime", QParam.builder().k(new String[]{"create_time"}).type(QueryTEnum.LT).build()
|
||||
,"endTime", QParam.builder().k(new String[]{"create_time"}).type(QueryTEnum.LE).build()
|
||||
,"sort", QParam.builder().k(new String[]{"sort"}).type(QueryTEnum.BY).build()
|
||||
);
|
||||
|
||||
public QueryWrapper<T> build(){
|
||||
this.paramMapping();
|
||||
QueryWrapper<T> wrapper = new QueryWrapper<>();
|
||||
JSONObject json = (JSONObject)JSONObject.toJSON(this);
|
||||
Type[] types = ((ParameterizedTypeImpl) this.getClass().getGenericSuperclass()).getActualTypeArguments();
|
||||
Map<String, ColumnCache> columnMap = LambdaUtils.getColumnMap((Class<?>) types[0]);
|
||||
|
||||
String dopStr = "doP";
|
||||
json.forEach((key, vel) -> {
|
||||
if (vel != null && !key.equals(dopStr)){
|
||||
if (vel instanceof String){
|
||||
if (StringUtils.isNotEmpty((CharSequence) vel)){
|
||||
QParam qParam = doP.get(key);
|
||||
if (qParam != null){
|
||||
QueryTEnum.build(qParam.type,wrapper,qParam.k,vel);
|
||||
}else {
|
||||
ColumnCache columnCache = columnMap.get(LambdaUtils.formatKey(key));
|
||||
if (columnCache!=null){
|
||||
wrapper.eq(columnCache.getColumn(),vel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else {
|
||||
QParam qParam = doP.get(key);
|
||||
if (qParam != null){
|
||||
QueryTEnum.build(qParam.type,wrapper,qParam.k,vel);
|
||||
}else {
|
||||
ColumnCache columnCache = columnMap.get(LambdaUtils.formatKey(key));
|
||||
if (columnCache!=null){
|
||||
wrapper.eq(columnCache.getColumn(),vel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
public void paramMapping(){};
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.nl.common.utils.query;
|
||||
|
||||
/**
|
||||
* s
|
||||
* @author ZZQ
|
||||
* @Date 2022/12/14 8:40 下午
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface LConsumer<X,Y,Z> {
|
||||
|
||||
/**
|
||||
* 切面
|
||||
* @param x 、
|
||||
* @param y 、
|
||||
* @param z 、
|
||||
*/
|
||||
void accept(X x,Y y,Z z);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
package org.nl.common.utils.query;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 分页参数
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2023-11-16
|
||||
*/
|
||||
@Data
|
||||
public class PageQuery implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 分页大小
|
||||
*/
|
||||
private Integer size=100;
|
||||
|
||||
/**
|
||||
* 当前页数
|
||||
*/
|
||||
private Integer page=0;
|
||||
|
||||
/**
|
||||
* 排序列menu_sort,desc
|
||||
*/
|
||||
private String sort;
|
||||
|
||||
/**
|
||||
* 排序的方向desc或者asc
|
||||
*/
|
||||
private Boolean isAsc;
|
||||
|
||||
/**
|
||||
* 当前记录起始索引 默认值
|
||||
*/
|
||||
public static final int DEFAULT_PAGE_NUM = 1;
|
||||
|
||||
/**
|
||||
* 每页显示记录数 默认值 默认查全部
|
||||
*/
|
||||
public static final int DEFAULT_PAGE_SIZE = Integer.MAX_VALUE;
|
||||
|
||||
public <T> Page<T> build() {
|
||||
Integer pageNum = ObjectUtil.defaultIfNull(getPage(), DEFAULT_PAGE_NUM);
|
||||
Integer pageSize = ObjectUtil.defaultIfNull(getSize(), DEFAULT_PAGE_SIZE);
|
||||
if (pageNum <= 0) {
|
||||
pageNum = DEFAULT_PAGE_NUM;
|
||||
}
|
||||
Page<T> page = new Page<>(pageNum, pageSize);
|
||||
if (StringUtils.isNotEmpty(sort)){
|
||||
String[] split = sort.split(",");
|
||||
for (int i = 0; i < (split.length & ~1); i = i + 2) {
|
||||
String col = split[i];
|
||||
OrderItem item = new OrderItem();
|
||||
item.setColumn(col);
|
||||
item.setAsc(split[i + 1].toLowerCase(Locale.ROOT).equals("asc"));
|
||||
page.addOrder(item);
|
||||
}
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
public static void trimStringFields(Object obj) {
|
||||
if (obj == null) {
|
||||
return;
|
||||
}
|
||||
Field[] fields = obj.getClass().getDeclaredFields();
|
||||
for (Field field : fields) {
|
||||
if (field.getType() == String.class) {
|
||||
field.setAccessible(true);
|
||||
try {
|
||||
String value = (String) field.get(obj);
|
||||
if (value != null) {
|
||||
field.set(obj, value.trim().toUpperCase());
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public <R, T> Page<T> build(Class<R> r) {
|
||||
Integer pageNum = ObjectUtil.defaultIfNull(getPage(), DEFAULT_PAGE_NUM);
|
||||
Integer pageSize = ObjectUtil.defaultIfNull(getSize(), DEFAULT_PAGE_SIZE);
|
||||
if (pageNum <= 0) {
|
||||
pageNum = DEFAULT_PAGE_NUM;
|
||||
}
|
||||
Page<T> page = new Page<>(pageNum, pageSize);
|
||||
if (StringUtils.isNotEmpty(sort)) {
|
||||
String[] split = sort.split(",");
|
||||
for (int i = 0; i < (split.length & ~1); i=i+2) {
|
||||
String col = split[i];
|
||||
if ("id".equals(col)){
|
||||
String mId = mappingId(r);
|
||||
col = StringUtils.isNotEmpty(mId)?mId:col;
|
||||
}
|
||||
OrderItem item = new OrderItem();
|
||||
item.setColumn(col);
|
||||
item.setAsc(split[i+1].toLowerCase(Locale.ROOT).equals("asc"));
|
||||
page.addOrder(item);
|
||||
}
|
||||
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
private <R> String mappingId(R r){
|
||||
if (r instanceof Class){
|
||||
Field[] fields = ((Class) r).getDeclaredFields();
|
||||
for (Field field : fields) {
|
||||
TableId[] byType = field.getAnnotationsByType(TableId.class);
|
||||
if (byType !=null && byType.length>0){
|
||||
TableId tableId = byType[0];
|
||||
return tableId.value();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package org.nl.common.utils.query;
|
||||
|
||||
import lombok.Builder;
|
||||
|
||||
/**
|
||||
* s
|
||||
* @author ZZQ
|
||||
* @Date 2022/12/15 1:41 下午
|
||||
*/
|
||||
@Builder
|
||||
public class QParam {
|
||||
public String[] k;
|
||||
public QueryTEnum type;
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package org.nl.common.utils.query;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.Getter;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* s
|
||||
*
|
||||
* @author ZZQ
|
||||
* @Date 2022/12/14 8:26 下午
|
||||
*/
|
||||
@Getter
|
||||
public enum QueryTEnum {
|
||||
//
|
||||
EQ((q, k, v) -> {
|
||||
q.eq(k[0], v);
|
||||
}),
|
||||
IN((q, key, o) -> {
|
||||
if (o instanceof Collection) {
|
||||
q.in(key[0], (Collection) o);
|
||||
}
|
||||
}),
|
||||
LK((q, keys, o) -> {
|
||||
for (String key : keys) {
|
||||
q.like(key, o);
|
||||
}
|
||||
}),
|
||||
ORLK((q, k, o) -> {
|
||||
q.and(query -> {
|
||||
QueryWrapper queryWrapper = (QueryWrapper) query;
|
||||
for (int i = 0; i < k.length; i++) {
|
||||
queryWrapper.like(k[i], o);
|
||||
if (i != (k.length - 1)) {
|
||||
queryWrapper.or();
|
||||
}
|
||||
}
|
||||
});
|
||||
}),
|
||||
LE((q, k, v) -> {
|
||||
q.le(k[0], v);
|
||||
}),
|
||||
GE((q, k, v) -> {
|
||||
q.ge(k[0], v);
|
||||
}),
|
||||
BY((q, k, v) -> {
|
||||
q.orderByDesc(k[0], String.valueOf(v));
|
||||
}),
|
||||
NO((q, k, v) -> {
|
||||
q.isNull(k[0]);
|
||||
}),
|
||||
NULL_OR_EMPTY((queryWrapper, k, v) -> {
|
||||
queryWrapper.nested(a -> a.isNull(k[0]).or().eq(k[0], ""));
|
||||
}),
|
||||
LT((q, k, v) -> {
|
||||
q.lt(k[0], v);
|
||||
}),
|
||||
GT((q, k, v) -> {
|
||||
q.gt(k[0], v);
|
||||
}),
|
||||
OREQ((q, k, v) -> {
|
||||
if (StringUtils.isBlank((String) v)) {
|
||||
q.isNull(k[0]);
|
||||
} else {
|
||||
q.eq(k[0], v);
|
||||
}
|
||||
});
|
||||
|
||||
private LConsumer<QueryWrapper<T>, String[], Object> doP;
|
||||
|
||||
QueryTEnum(LConsumer<QueryWrapper<T>, String[], Object> doP) {
|
||||
this.doP = doP;
|
||||
}
|
||||
|
||||
public static void build(QueryTEnum type, QueryWrapper q, String[] k, Object v) {
|
||||
type.getDoP().accept(q, k, v);
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,9 @@ import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.utils.TableDataInfo;
|
||||
import org.nl.hand.service.PadService;
|
||||
import org.nl.hand.service.dto.TaskPad;
|
||||
import org.nl.modules.logging.annotation.Log;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@@ -22,43 +24,52 @@ public class PadController {
|
||||
|
||||
private final PadService padService;
|
||||
|
||||
@PostMapping("/tasks")
|
||||
@Log("任务操作")
|
||||
@ApiOperation("任务操作")
|
||||
@PostMapping("/list")
|
||||
@Log("任务列表")
|
||||
@ApiOperation("任务列表")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> tasks(@RequestBody Map<String, String> whereJson) {
|
||||
return new ResponseEntity<>(padService.tasks(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/taskoperation")
|
||||
@PostMapping("/taskOperation")
|
||||
@Log("任务操作")
|
||||
@ApiOperation("任务操作")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> taskoperation(@RequestBody Map<String, String> whereJson) {
|
||||
public ResponseEntity<Object> taskOperation(@RequestBody Map<String, String> whereJson) {
|
||||
return new ResponseEntity<>(padService.taskoperation(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/insts")
|
||||
@PostMapping("/queryInst")
|
||||
@Log("查询指令信息")
|
||||
@ApiOperation("查询指令信息")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> insts(@RequestBody Map<String, String> whereJson) {
|
||||
return new ResponseEntity<>(padService.insts(whereJson), HttpStatus.OK);
|
||||
public ResponseEntity<Object> queryInst(@RequestBody TaskPad taskPad) {
|
||||
return new ResponseEntity<>(TableDataInfo.build(padService.insts(taskPad)), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/inst")
|
||||
@PostMapping("/instoperation")
|
||||
@Log("指令操作")
|
||||
@ApiOperation("指令操作")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> instoperation(@RequestBody Map<String, String> whereJson) {
|
||||
return new ResponseEntity<>(padService.instoperation(whereJson), HttpStatus.OK);
|
||||
public ResponseEntity<Object> instoperation(@RequestBody TaskPad taskPad) {
|
||||
padService.instoperation(taskPad);
|
||||
return new ResponseEntity<>(TableDataInfo.build(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/callTask")
|
||||
@Log("定点任务")
|
||||
@ApiOperation("定点任务")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> callTask(@RequestBody Map<String, String> whereJson) {
|
||||
return new ResponseEntity<>(padService.callTask(whereJson), HttpStatus.OK);
|
||||
public ResponseEntity<Object> callTask(@RequestBody TaskPad taskPad) {
|
||||
padService.callTask(taskPad);
|
||||
return new ResponseEntity<>(TableDataInfo.build(), HttpStatus.OK);
|
||||
}
|
||||
@PostMapping("/signalInteract")
|
||||
@Log("信号交互")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> signalInteract(@RequestBody TaskPad taskPad) {
|
||||
padService.signalInteract(taskPad);
|
||||
return new ResponseEntity<>(TableDataInfo.build(), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package org.nl.hand.service;
|
||||
|
||||
import org.nl.hand.service.dto.TaskPad;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface PadService {
|
||||
@@ -26,7 +29,7 @@ public interface PadService {
|
||||
* @param whereJson
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> insts(Map<String, String> whereJson);
|
||||
List insts(TaskPad pad);
|
||||
|
||||
/**
|
||||
* 指令操作
|
||||
@@ -34,7 +37,7 @@ public interface PadService {
|
||||
* @param whereJson
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> instoperation(Map<String, String> whereJson);
|
||||
void instoperation(TaskPad pad);
|
||||
|
||||
/**
|
||||
* 定点任务
|
||||
@@ -42,5 +45,7 @@ public interface PadService {
|
||||
* @param whereJson
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> callTask(Map<String, String> whereJson);
|
||||
void callTask(TaskPad pad);
|
||||
|
||||
void signalInteract(TaskPad pad);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package org.nl.hand.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class TaskPad implements Serializable {
|
||||
//任务操作页面用
|
||||
/**
|
||||
* 任务操作码:"1"任务取消"2"任务完成"3"任务暂停"4"任务回复
|
||||
*/
|
||||
private String operation;
|
||||
/**
|
||||
* 指令id
|
||||
*/
|
||||
private String inst_id;
|
||||
//任务操作页面查询任务用
|
||||
/**
|
||||
* 车辆号
|
||||
*/
|
||||
private String car_no;
|
||||
/**
|
||||
* 托盘号
|
||||
*/
|
||||
private String containerCode;
|
||||
private String vehicle_code;
|
||||
//任务创建
|
||||
/**
|
||||
* 扫码起点
|
||||
*/
|
||||
private String start;
|
||||
/**
|
||||
* 扫码终点
|
||||
*/
|
||||
private String end;
|
||||
//焊接线安全交互
|
||||
/**
|
||||
* 托盘号
|
||||
*/
|
||||
private String point;
|
||||
/**
|
||||
* type:1.请求取货2取货完成3请求放货4放货完成
|
||||
*/
|
||||
private String type;
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.instruction.service.dto.Instruction;
|
||||
import org.nl.acs.opc.Device;
|
||||
@@ -11,6 +12,8 @@ import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.acs.task.service.dto.TaskDto;
|
||||
import org.nl.hand.service.PadService;
|
||||
import org.nl.hand.service.dto.TaskPad;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -116,126 +119,76 @@ public class PadServiceImpl implements PadService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> insts(Map<String, String> whereJson) {
|
||||
JSONObject resultJson = new JSONObject();
|
||||
String car_no = whereJson.get("car_no");
|
||||
String device_code = whereJson.get("device_code");
|
||||
List<Instruction> instructions = instructionService.findAllInstFromCache();
|
||||
List<Map<String, Object>> list = (instructions == null ? Stream.<Instruction>empty() : instructions.stream())
|
||||
.filter(instruction -> {
|
||||
if (StrUtil.isEmpty(car_no)) return true;
|
||||
String vc = instruction.getCarno();
|
||||
return StrUtil.isNotEmpty(vc) && vc.contains(car_no);
|
||||
})
|
||||
.filter(instruction -> {
|
||||
if (StrUtil.isEmpty(device_code)) return true;
|
||||
String s = instruction.getStart_device_code();
|
||||
String n = instruction.getNext_device_code();
|
||||
return (StrUtil.isNotEmpty(s) && s.contains(device_code))
|
||||
|| (StrUtil.isNotEmpty(n) && n.contains(device_code));
|
||||
})
|
||||
.map(instruction -> {
|
||||
Map<String, Object> m = new HashMap<>();
|
||||
m.put("inst_id", instruction.getInstruction_id());
|
||||
m.put("instruction_code", instruction.getInstruction_code());
|
||||
m.put("task_no", instruction.getTask_code());
|
||||
m.put("priority", instruction.getPriority());
|
||||
m.put("point_code1", instruction.getStart_device_code());
|
||||
m.put("point_code2", instruction.getNext_device_code());
|
||||
m.put("inst_status", instruction.getInstruction_status());
|
||||
m.put("vehicle_code", instruction.getVehicle_code());
|
||||
m.put("car_no", instruction.getCarno());
|
||||
m.put("create_time", instruction.getCreate_time());
|
||||
return m;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
resultJson.put("data", list);
|
||||
resultJson.put("code", "1");
|
||||
resultJson.put("message", "ok");
|
||||
return resultJson;
|
||||
public List<Instruction>insts(TaskPad pad) {
|
||||
String carNo = pad.getCar_no();
|
||||
String containerCode = pad.getVehicle_code();
|
||||
String query = "instruction_status < 2 and is_delete = 0 ";
|
||||
if (StringUtils.isNotEmpty(carNo)){
|
||||
query = query+" and carno = '"+carNo+"'";
|
||||
}
|
||||
if (StringUtils.isNotEmpty(containerCode)){
|
||||
query = query+" and vehicle_code = '"+containerCode+"'";
|
||||
}
|
||||
List<Instruction> result = instructionService.queryAll(query);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> instoperation(Map<String, String> whereJson) {
|
||||
JSONObject resultJson = new JSONObject();
|
||||
String type = whereJson.get("type");
|
||||
if (StrUtil.isEmpty(type)) {
|
||||
resultJson.put("code", "0");
|
||||
resultJson.put("message", "操作类型不能为空!");
|
||||
return resultJson;
|
||||
}
|
||||
String inst_id = whereJson.get("inst_id");
|
||||
if (StrUtil.isEmpty(inst_id)) {
|
||||
resultJson.put("code", "0");
|
||||
resultJson.put("message", "指令ID不能为空!");
|
||||
return resultJson;
|
||||
}
|
||||
if (type.equals("1")) {
|
||||
try {
|
||||
instructionService.cancel(inst_id);
|
||||
} catch (Exception e) {
|
||||
resultJson.put("code", "0");
|
||||
resultJson.put("message", "取消失败, " + e.getMessage());
|
||||
return resultJson;
|
||||
}
|
||||
} else if (type.equals("2")) {
|
||||
try {
|
||||
instructionService.finish(inst_id);
|
||||
} catch (Exception e) {
|
||||
resultJson.put("code", "0");
|
||||
resultJson.put("message", "完成失败, " + e.getMessage());
|
||||
return resultJson;
|
||||
public void instoperation(TaskPad pad) {
|
||||
String operation = pad.getOperation();
|
||||
//任务操作码:"1"任务取消"2"任务完成"3"车辆暂停"4"车辆恢复
|
||||
String instId = pad.getInst_id();
|
||||
if (StrUtil.isEmpty(operation)) {
|
||||
throw new BadRequestException("操作类型不能为空");}
|
||||
if (StrUtil.isEmpty(instId)) {
|
||||
throw new BadRequestException("指令ID不能为空");}
|
||||
if (operation.equals("1")) {
|
||||
Instruction entity = instructionService.findById(instId);
|
||||
if (entity == null) {
|
||||
throw new BadRequestException("指令不存在");
|
||||
}
|
||||
instructionService.cancel(instId);
|
||||
taskService.forchFinich(entity.getTask_code());
|
||||
} else if (operation.equals("2")) {
|
||||
instructionService.finish(instId);
|
||||
}else if (operation.equals("3")) {
|
||||
//调用套件
|
||||
instructionService.pause(instId);
|
||||
}else if (operation.equals("4")) {
|
||||
instructionService.recover(instId);
|
||||
}
|
||||
resultJson.put("code", "1");
|
||||
resultJson.put("message", "操作成功!");
|
||||
return resultJson;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> callTask(Map<String, String> whereJson) {
|
||||
JSONObject resultJson = new JSONObject();
|
||||
String start_device_code = whereJson.get("start_device_code");
|
||||
if (StrUtil.isEmpty(start_device_code)) {
|
||||
resultJson.put("code", "0");
|
||||
resultJson.put("message", "起始库位不能为空!");
|
||||
return resultJson;
|
||||
public void callTask(TaskPad pad) {
|
||||
String start = pad.getStart();
|
||||
String end = pad.getEnd();
|
||||
if (StringUtils.isEmpty(start) || StringUtils.isEmpty(end)){
|
||||
throw new BadRequestException("任务搬运起点或者终点不能为空");
|
||||
}
|
||||
Device startDevice = deviceAppService.findDeviceByCode(start_device_code);
|
||||
Device startDevice = deviceAppService.findDeviceByCode(start);
|
||||
if (startDevice == null) {
|
||||
resultJson.put("code", "0");
|
||||
resultJson.put("message", "起始库位不存在,请添加起始库位!");
|
||||
return resultJson;
|
||||
throw new BadRequestException("起始库位不存在,请添加起始库位!");
|
||||
}
|
||||
String next_device_code = whereJson.get("next_device_code");
|
||||
if (StrUtil.isEmpty(next_device_code)) {
|
||||
resultJson.put("code", "0");
|
||||
resultJson.put("message", "目的库位不能为空!");
|
||||
return resultJson;
|
||||
Device endDevice = deviceAppService.findDeviceByCode(end);
|
||||
if (endDevice == null) {
|
||||
throw new BadRequestException("终点库位不存在,请添加起始库位!");
|
||||
}
|
||||
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
|
||||
if (nextDevice == null) {
|
||||
resultJson.put("code", "0");
|
||||
resultJson.put("message", "目的库位不存在,请添加目的库位!");
|
||||
return resultJson;
|
||||
}
|
||||
|
||||
TaskDto taskDto = new TaskDto();
|
||||
taskDto.setStart_device_code(start_device_code);
|
||||
taskDto.setStart_point_code(start_device_code);
|
||||
taskDto.setStart_parent_code(start_device_code);
|
||||
taskDto.setNext_device_code(next_device_code);
|
||||
taskDto.setNext_point_code(next_device_code);
|
||||
taskDto.setNext_parent_code(next_device_code);
|
||||
try {
|
||||
taskService.create(taskDto);
|
||||
} catch (Exception e) {
|
||||
resultJson.put("code", "0");
|
||||
resultJson.put("message", "生成失败, " + e.getMessage());
|
||||
return resultJson;
|
||||
taskDto.setStart_device_code(start);
|
||||
taskDto.setStart_point_code(start);
|
||||
taskDto.setStart_parent_code(start);
|
||||
taskDto.setNext_device_code(end);
|
||||
taskDto.setNext_point_code(end);
|
||||
taskDto.setNext_parent_code(end);
|
||||
if (StringUtils.isNotEmpty(pad.getVehicle_code())){
|
||||
taskDto.setVehicle_code(pad.getContainerCode());
|
||||
}
|
||||
resultJson.put("code", "1");
|
||||
resultJson.put("message", "生成成功!");
|
||||
return resultJson;
|
||||
taskService.create(taskDto);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void signalInteract(TaskPad pad) {
|
||||
//焊接线安全交互
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
package org.nl.modules.layout.car.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import org.nl.common.utils.query.PageQuery;
|
||||
import org.nl.modules.layout.car.dao.AgvCarQuery;
|
||||
import org.nl.modules.layout.car.dto.AgvCarDto;
|
||||
import org.nl.modules.layout.car.entity.AgvCar;
|
||||
import org.nl.modules.layout.car.service.AgvCarService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 车辆信息Controller
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/agvCar")
|
||||
@SaIgnore
|
||||
public class AgvCarController {
|
||||
|
||||
@Autowired
|
||||
private AgvCarService agvCarService;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public ResponseEntity<Object> pageList(AgvCarQuery query, PageQuery pageQuery) {
|
||||
return new ResponseEntity<>(agvCarService.page(pageQuery.build(), query.build()), HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有
|
||||
*/
|
||||
@GetMapping("/all")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> list() {
|
||||
return new ResponseEntity<>(agvCarService.list(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<Object> getById(@PathVariable Integer id) {
|
||||
return new ResponseEntity<>(agvCarService.getById(id), HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping
|
||||
public ResponseEntity<Object> add(@RequestBody AgvCarDto dto) {
|
||||
AgvCar entity = new AgvCar();
|
||||
BeanUtils.copyProperties(dto, entity);
|
||||
agvCarService.save(entity);
|
||||
return new ResponseEntity<>(entity, HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@PutMapping
|
||||
public ResponseEntity<Object> update(@RequestBody AgvCarDto dto) {
|
||||
AgvCar entity = new AgvCar();
|
||||
BeanUtils.copyProperties(dto, entity);
|
||||
agvCarService.updateById(entity);
|
||||
return new ResponseEntity<>(entity, HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestBody Integer[] ids) {
|
||||
agvCarService.removeByIds(Arrays.asList(ids));
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package org.nl.modules.layout.car.dao;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.utils.query.BaseQuery;
|
||||
import org.nl.modules.layout.car.entity.AgvCar;
|
||||
|
||||
/**
|
||||
* 车辆信息查询对象
|
||||
*/
|
||||
public class AgvCarQuery extends BaseQuery<AgvCar> {
|
||||
|
||||
/**
|
||||
* 车辆ID
|
||||
*/
|
||||
private String carId;
|
||||
|
||||
/**
|
||||
* 车辆类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
public String getCarId() {
|
||||
return carId;
|
||||
}
|
||||
|
||||
public void setCarId(String carId) {
|
||||
if (StringUtils.isNotEmpty(carId)){
|
||||
this.carId = carId;
|
||||
}
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
if (StringUtils.isNotEmpty(type)){
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package org.nl.modules.layout.car.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 车辆信息DTO
|
||||
*/
|
||||
@Data
|
||||
public class AgvCarDto implements Serializable {
|
||||
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 车辆ID
|
||||
*/
|
||||
private String carId;
|
||||
|
||||
/**
|
||||
* 车辆类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 车辆图标地址
|
||||
*/
|
||||
private String icon;
|
||||
|
||||
/**
|
||||
* 图标文件ID
|
||||
*/
|
||||
private String fileId;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package org.nl.modules.layout.car.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 车辆信息表
|
||||
*/
|
||||
@Data
|
||||
@TableName("agv_car")
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class AgvCar implements Serializable {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 车辆ID
|
||||
*/
|
||||
private String carId;
|
||||
|
||||
/**
|
||||
* 车辆类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 车辆图标地址
|
||||
*/
|
||||
private String icon;
|
||||
/**
|
||||
* 车辆图标地址
|
||||
*/
|
||||
private String fileId;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package org.nl.modules.layout.car.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.nl.modules.layout.car.entity.AgvCar;
|
||||
|
||||
/**
|
||||
* 车辆信息Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface AgvCarMapper extends BaseMapper<AgvCar> {
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package org.nl.modules.layout.car.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.modules.layout.car.entity.AgvCar;
|
||||
|
||||
/**
|
||||
* 车辆信息Service
|
||||
*/
|
||||
public interface AgvCarService extends IService<AgvCar> {
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package org.nl.modules.layout.car.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.nl.modules.layout.car.entity.AgvCar;
|
||||
import org.nl.modules.layout.car.mapper.AgvCarMapper;
|
||||
import org.nl.modules.layout.car.service.AgvCarService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 车辆信息ServiceImpl
|
||||
*/
|
||||
@Service
|
||||
public class AgvCarServiceImpl extends ServiceImpl<AgvCarMapper, AgvCar> implements AgvCarService {
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package org.nl.modules.layout.device.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import org.nl.common.utils.query.PageQuery;
|
||||
import org.nl.modules.layout.device.dao.BaseDataDeviceQuery;
|
||||
import org.nl.modules.layout.device.dto.BaseDataDeviceDto;
|
||||
import org.nl.modules.layout.device.entity.BaseDataDevice;
|
||||
import org.nl.modules.layout.device.service.BaseDataDeviceService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 设备信息Controller
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/baseDevice")
|
||||
@SaIgnore
|
||||
public class BaseDataDeviceController {
|
||||
|
||||
@Autowired
|
||||
private BaseDataDeviceService baseDataDeviceService;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public ResponseEntity<Object> pageList(BaseDataDeviceQuery query, PageQuery pageQuery) {
|
||||
return new ResponseEntity<>(baseDataDeviceService.page(pageQuery.build(), query.build()), HttpStatus.OK);
|
||||
}
|
||||
@GetMapping("/component")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> List() {
|
||||
return new ResponseEntity<>(baseDataDeviceService.list(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<Object> getById(@PathVariable Integer id) {
|
||||
return new ResponseEntity<>(baseDataDeviceService.getById(id), HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping
|
||||
public ResponseEntity<Object> add(@RequestBody BaseDataDeviceDto dto) {
|
||||
BaseDataDevice entity = new BaseDataDevice();
|
||||
BeanUtils.copyProperties(dto, entity);
|
||||
entity.setCreateTime(new Date());
|
||||
baseDataDeviceService.save(entity);
|
||||
return new ResponseEntity<>(entity, HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@PutMapping
|
||||
public ResponseEntity<Object> update(@RequestBody BaseDataDeviceDto dto) {
|
||||
BaseDataDevice entity = new BaseDataDevice();
|
||||
BeanUtils.copyProperties(dto, entity);
|
||||
entity.setUpdateTime(new Date());
|
||||
baseDataDeviceService.updateById(entity);
|
||||
return new ResponseEntity<>(entity, HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestBody Integer[] ids) {
|
||||
baseDataDeviceService.removeByIds(Arrays.asList(ids));
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package org.nl.modules.layout.device.dao;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.utils.query.BaseQuery;
|
||||
import org.nl.modules.layout.device.entity.BaseDataDevice;
|
||||
|
||||
/**
|
||||
* 设备信息查询对象
|
||||
*/
|
||||
public class BaseDataDeviceQuery extends BaseQuery<BaseDataDevice> {
|
||||
|
||||
/**
|
||||
* 设备编码
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 设备类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 所属区域
|
||||
*/
|
||||
private String region;
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
if (StringUtils.isNotEmpty(code)){
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
if (StringUtils.isNotEmpty(type)){
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
||||
public String getRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
public void setRegion(String region) {
|
||||
if (StringUtils.isNotEmpty(region)){
|
||||
this.region = region;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package org.nl.modules.layout.device.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 设备信息DTO
|
||||
*/
|
||||
@Data
|
||||
public class BaseDataDeviceDto implements Serializable {
|
||||
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 设备类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 设备描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 设备扩展信息
|
||||
*/
|
||||
private String editParam;
|
||||
|
||||
/**
|
||||
* 图标地址
|
||||
*/
|
||||
private String icon;
|
||||
|
||||
/**
|
||||
* 图标文件ID
|
||||
*/
|
||||
private String fileId;
|
||||
|
||||
/**
|
||||
* 所属区域
|
||||
*/
|
||||
private String region;
|
||||
|
||||
/**
|
||||
* x坐标
|
||||
*/
|
||||
private Integer x;
|
||||
|
||||
/**
|
||||
* y坐标
|
||||
*/
|
||||
private Integer y;
|
||||
|
||||
/**
|
||||
* 角度
|
||||
*/
|
||||
private Integer angle;
|
||||
|
||||
/**
|
||||
* 放大比例
|
||||
*/
|
||||
private Integer size;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 创建用户
|
||||
*/
|
||||
private String createName;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 修改用户
|
||||
*/
|
||||
private String updateName;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
private Boolean isUsed;
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package org.nl.modules.layout.device.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 设备信息表
|
||||
*/
|
||||
@Data
|
||||
@TableName("base_data_device")
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class BaseDataDevice implements Serializable {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 设备类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 设备描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 设备扩展信息
|
||||
*/
|
||||
private String editParam;
|
||||
|
||||
/**
|
||||
* 图标地址
|
||||
*/
|
||||
private String icon;
|
||||
|
||||
/**
|
||||
* 图标文件ID
|
||||
*/
|
||||
private String fileId;
|
||||
|
||||
/**
|
||||
* 所属区域
|
||||
*/
|
||||
private String region;
|
||||
|
||||
/**
|
||||
* x坐标
|
||||
*/
|
||||
private Integer x;
|
||||
|
||||
/**
|
||||
* y坐标
|
||||
*/
|
||||
private Integer y;
|
||||
|
||||
/**
|
||||
* 角度
|
||||
*/
|
||||
private Integer angle;
|
||||
|
||||
/**
|
||||
* 放大比例
|
||||
*/
|
||||
private Integer size;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 创建用户
|
||||
*/
|
||||
private String createName;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 修改用户
|
||||
*/
|
||||
private String updateName;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
private Boolean isUsed;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package org.nl.modules.layout.device.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.nl.modules.layout.device.entity.BaseDataDevice;
|
||||
|
||||
/**
|
||||
* 设备信息Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface BaseDataDeviceMapper extends BaseMapper<BaseDataDevice> {
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package org.nl.modules.layout.device.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.modules.layout.device.entity.BaseDataDevice;
|
||||
|
||||
/**
|
||||
* 设备信息Service
|
||||
*/
|
||||
public interface BaseDataDeviceService extends IService<BaseDataDevice> {
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package org.nl.modules.layout.device.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.nl.modules.layout.device.entity.BaseDataDevice;
|
||||
import org.nl.modules.layout.device.mapper.BaseDataDeviceMapper;
|
||||
import org.nl.modules.layout.device.service.BaseDataDeviceService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 设备信息ServiceImpl
|
||||
*/
|
||||
@Service
|
||||
public class BaseDataDeviceServiceImpl extends ServiceImpl<BaseDataDeviceMapper, BaseDataDevice> implements BaseDataDeviceService {
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package org.nl.modules.layout.deviceLayout.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import org.nl.common.utils.query.PageQuery;
|
||||
import org.nl.modules.layout.deviceLayout.dao.AgvLayoutDeviceQuery;
|
||||
import org.nl.modules.layout.deviceLayout.dto.AgvLayoutDeviceDto;
|
||||
import org.nl.modules.layout.deviceLayout.entity.AgvLayoutDevice;
|
||||
import org.nl.modules.layout.deviceLayout.service.AgvLayoutDeviceService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 设备布局Controller
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/deviceLayout")
|
||||
@SaIgnore
|
||||
public class AgvLayoutDeviceController {
|
||||
|
||||
@Autowired
|
||||
private AgvLayoutDeviceService agvLayoutDeviceService;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public ResponseEntity<Object> pageList(AgvLayoutDeviceQuery query, PageQuery pageQuery) {
|
||||
return new ResponseEntity<>(agvLayoutDeviceService.page(pageQuery.build(), query.build()), HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<Object> getById(@PathVariable Integer id) {
|
||||
return new ResponseEntity<>(agvLayoutDeviceService.getById(id), HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping
|
||||
public ResponseEntity<Object> add(@RequestBody AgvLayoutDeviceDto dto) {
|
||||
AgvLayoutDevice entity = new AgvLayoutDevice();
|
||||
BeanUtils.copyProperties(dto, entity);
|
||||
agvLayoutDeviceService.save(entity);
|
||||
return new ResponseEntity<>(entity, HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@PutMapping
|
||||
public ResponseEntity<Object> update(@RequestBody AgvLayoutDeviceDto dto) {
|
||||
AgvLayoutDevice entity = new AgvLayoutDevice();
|
||||
BeanUtils.copyProperties(dto, entity);
|
||||
agvLayoutDeviceService.updateById(entity);
|
||||
return new ResponseEntity<>(entity, HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestBody Integer[] ids) {
|
||||
agvLayoutDeviceService.removeByIds(Arrays.asList(ids));
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.nl.modules.layout.deviceLayout.dao;
|
||||
|
||||
import lombok.Data;
|
||||
import org.nl.common.utils.query.BaseQuery;
|
||||
import org.nl.modules.layout.deviceLayout.entity.AgvLayoutDevice;
|
||||
|
||||
|
||||
/**
|
||||
* 设备布局查询对象
|
||||
*/
|
||||
@Data
|
||||
public class AgvLayoutDeviceQuery extends BaseQuery<AgvLayoutDevice> {
|
||||
|
||||
/**
|
||||
* 地图布局ID
|
||||
*/
|
||||
private Integer mapLayoutId;
|
||||
|
||||
/**
|
||||
* 设备ID
|
||||
*/
|
||||
private Integer deviceId;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package org.nl.modules.layout.deviceLayout.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 设备布局DTO
|
||||
*/
|
||||
@Data
|
||||
public class AgvLayoutDeviceDto implements Serializable {
|
||||
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 地图布局ID
|
||||
*/
|
||||
private Integer mapLayoutId;
|
||||
|
||||
/**
|
||||
* 设备ID
|
||||
*/
|
||||
private Integer deviceId;
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* x坐标
|
||||
*/
|
||||
private Integer x;
|
||||
|
||||
/**
|
||||
* y坐标
|
||||
*/
|
||||
private Integer y;
|
||||
|
||||
/**
|
||||
* 角度
|
||||
*/
|
||||
private Integer angle;
|
||||
|
||||
/**
|
||||
* 放大比例
|
||||
*/
|
||||
private Integer size;
|
||||
|
||||
/**
|
||||
* 图标
|
||||
*/
|
||||
private String icon;
|
||||
private String fileId;
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package org.nl.modules.layout.deviceLayout.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 设备布局表
|
||||
*/
|
||||
@Data
|
||||
@TableName("agv_layout_device")
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class AgvLayoutDevice implements Serializable {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 地图布局ID
|
||||
*/
|
||||
private Integer mapLayoutId;
|
||||
|
||||
/**
|
||||
* 设备ID
|
||||
*/
|
||||
private Integer deviceId;
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* x坐标
|
||||
*/
|
||||
private Integer x;
|
||||
|
||||
/**
|
||||
* y坐标
|
||||
*/
|
||||
private Integer y;
|
||||
|
||||
/**
|
||||
* 角度
|
||||
*/
|
||||
private Integer angle;
|
||||
|
||||
/**
|
||||
* 放大比例
|
||||
*/
|
||||
private Integer size;
|
||||
|
||||
/**
|
||||
* 图标
|
||||
*/
|
||||
private String icon;
|
||||
private String fileId;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package org.nl.modules.layout.deviceLayout.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.nl.modules.layout.deviceLayout.entity.AgvLayoutDevice;
|
||||
|
||||
/**
|
||||
* 设备布局Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface AgvLayoutDeviceMapper extends BaseMapper<AgvLayoutDevice> {
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package org.nl.modules.layout.deviceLayout.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.modules.layout.deviceLayout.entity.AgvLayoutDevice;
|
||||
|
||||
/**
|
||||
* 设备布局Service
|
||||
*/
|
||||
public interface AgvLayoutDeviceService extends IService<AgvLayoutDevice> {
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package org.nl.modules.layout.deviceLayout.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.nl.modules.layout.deviceLayout.entity.AgvLayoutDevice;
|
||||
import org.nl.modules.layout.deviceLayout.mapper.AgvLayoutDeviceMapper;
|
||||
import org.nl.modules.layout.deviceLayout.service.AgvLayoutDeviceService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 设备布局ServiceImpl
|
||||
*/
|
||||
@Service
|
||||
public class AgvLayoutDeviceServiceImpl extends ServiceImpl<AgvLayoutDeviceMapper, AgvLayoutDevice> implements AgvLayoutDeviceService {
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package org.nl.modules.layout.mapLayout.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.utils.query.PageQuery;
|
||||
import org.nl.modules.layout.mapLayout.dao.AgvLayoutMapQuery;
|
||||
import org.nl.modules.layout.mapLayout.dto.AgvLayoutMapDto;
|
||||
import org.nl.modules.layout.mapLayout.dto.AgvStatus;
|
||||
import org.nl.modules.layout.mapLayout.entity.AgvLayoutMap;
|
||||
import org.nl.modules.layout.mapLayout.service.AgvLayoutMapService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* 地图布局Controller
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/mapLayout")
|
||||
@SaIgnore
|
||||
public class AgvLayoutMapController {
|
||||
|
||||
@Autowired
|
||||
private AgvLayoutMapService agvLayoutMapService;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> pageList(AgvLayoutMapQuery query, PageQuery pageQuery) {
|
||||
return new ResponseEntity<>(agvLayoutMapService.page(pageQuery.build(), query.build()), HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<Object> getById(@PathVariable Integer id) {
|
||||
return new ResponseEntity<>(agvLayoutMapService.getById(id), HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping
|
||||
public ResponseEntity<Object> add(@RequestBody AgvLayoutMapDto dto) {
|
||||
agvLayoutMapService.saveLayout(dto);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@PutMapping
|
||||
public ResponseEntity<Object> update(@RequestBody AgvLayoutMapDto dto) {
|
||||
AgvLayoutMap entity = new AgvLayoutMap();
|
||||
BeanUtils.copyProperties(dto, entity);
|
||||
agvLayoutMapService.updateById(entity);
|
||||
return new ResponseEntity<>(entity, HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestBody Integer[] ids) {
|
||||
agvLayoutMapService.removeByIds(Arrays.asList(ids));
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("initLayout")
|
||||
@SaIgnore
|
||||
public ResponseEntity<AgvLayoutMapDto> initLayout(Long id) {
|
||||
AgvLayoutMapDto agvLayoutMapDto = agvLayoutMapService.initLayoutMap(id);
|
||||
return new ResponseEntity<>(agvLayoutMapDto,HttpStatus.OK);
|
||||
}
|
||||
@GetMapping("status")
|
||||
@SaIgnore
|
||||
public ResponseEntity<List> status(String carId) {
|
||||
List<AgvStatus> list = new ArrayList<>();
|
||||
for (int i = 0; i < 4; i++) {
|
||||
AgvStatus build = AgvStatus.builder()
|
||||
.status("2")
|
||||
.carId(String.valueOf(i + 1))
|
||||
.action("请求取货")
|
||||
.actionInfo("申请取货中")
|
||||
.taskCode("33876")
|
||||
.icon("/Users/mima0000/Desktop/car.png")
|
||||
.fileId("3029")
|
||||
.x(new Random().nextInt(1189) + 100)
|
||||
.y(new Random().nextInt(1189) + 100)
|
||||
.power(66)
|
||||
.angle(new Random().nextInt(160) + 10).build();
|
||||
list.add(build);
|
||||
}
|
||||
return new ResponseEntity<>(list,HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package org.nl.modules.layout.mapLayout.dao;
|
||||
|
||||
import lombok.Data;
|
||||
import org.nl.common.utils.query.BaseQuery;
|
||||
import org.nl.modules.layout.mapLayout.entity.AgvLayoutMap;
|
||||
|
||||
/**
|
||||
* 地图布局查询对象
|
||||
*/
|
||||
@Data
|
||||
public class AgvLayoutMapQuery extends BaseQuery<AgvLayoutMap> {
|
||||
|
||||
/**
|
||||
* 地图ID
|
||||
*/
|
||||
private String mapId;
|
||||
|
||||
/**
|
||||
* 版本
|
||||
*/
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
private Boolean enable;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package org.nl.modules.layout.mapLayout.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import org.nl.modules.layout.deviceLayout.dto.AgvLayoutDeviceDto;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 地图布局DTO
|
||||
*/
|
||||
@Data
|
||||
public class AgvLayoutMapDto implements Serializable {
|
||||
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 地图ID
|
||||
*/
|
||||
private String mapId;
|
||||
|
||||
/**
|
||||
* 地图名称
|
||||
*/
|
||||
private String mapName;
|
||||
|
||||
/**
|
||||
* 版本
|
||||
*/
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* 地图URL
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 高度
|
||||
*/
|
||||
private Integer height;
|
||||
|
||||
/**
|
||||
* 宽度
|
||||
*/
|
||||
private Integer width;
|
||||
|
||||
/**
|
||||
* x坐标
|
||||
*/
|
||||
private Integer x;
|
||||
|
||||
/**
|
||||
* y坐标
|
||||
*/
|
||||
private Integer y;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
private Boolean enable;
|
||||
|
||||
|
||||
private List<AgvLayoutDeviceDto> device;
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package org.nl.modules.layout.mapLayout.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class AgvStatus {
|
||||
/**
|
||||
* 车辆ID
|
||||
*/
|
||||
private String carId;
|
||||
/**
|
||||
* 车辆类型
|
||||
*/
|
||||
private String type;
|
||||
/**
|
||||
* 图标地址
|
||||
*/
|
||||
private String icon="/Users/mima0000/Desktop/car.png";
|
||||
/**
|
||||
* 车辆图片地址ID
|
||||
*/
|
||||
private String fileId;
|
||||
/**
|
||||
* 状态类型:1.休息 2.正常运行 3.异常
|
||||
*/
|
||||
private String status;
|
||||
/**
|
||||
* 异常时的异常信息
|
||||
*/
|
||||
private String error;
|
||||
/**
|
||||
* 动作状态:请求取货/取货完成/请求放货/放货完成
|
||||
*/
|
||||
private String action;
|
||||
/**
|
||||
* 动作交互信息
|
||||
*/
|
||||
private String actionInfo;
|
||||
/**
|
||||
* 任务号
|
||||
*/
|
||||
private String taskCode;
|
||||
/**
|
||||
* 坐标X
|
||||
*/
|
||||
private Integer x;
|
||||
/**
|
||||
* 坐标Y
|
||||
*/
|
||||
private Integer y;
|
||||
/**
|
||||
* 航向角
|
||||
*/
|
||||
private Integer angle;
|
||||
/**
|
||||
* 电量
|
||||
*/
|
||||
private Integer power;
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package org.nl.modules.layout.mapLayout.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 地图布局表
|
||||
*/
|
||||
@Data
|
||||
@TableName("agv_layout_map")
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class AgvLayoutMap implements Serializable {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 地图ID
|
||||
*/
|
||||
private String mapId;
|
||||
|
||||
/**
|
||||
* 地图名称
|
||||
*/
|
||||
private String mapName;
|
||||
|
||||
/**
|
||||
* 版本
|
||||
*/
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* 地图URL
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 高度
|
||||
*/
|
||||
private Integer height;
|
||||
|
||||
/**
|
||||
* 宽度
|
||||
*/
|
||||
private Integer width;
|
||||
|
||||
/**
|
||||
* x坐标
|
||||
*/
|
||||
private Integer x;
|
||||
|
||||
/**
|
||||
* y坐标
|
||||
*/
|
||||
private Integer y;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
private Boolean enable;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package org.nl.modules.layout.mapLayout.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Options;
|
||||
import org.nl.modules.layout.mapLayout.dto.AgvLayoutMapDto;
|
||||
import org.nl.modules.layout.mapLayout.entity.AgvLayoutMap;
|
||||
|
||||
/**
|
||||
* 地图布局Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface AgvLayoutMapMapper extends BaseMapper<AgvLayoutMap> {
|
||||
@Insert("INSERT INTO agv_layout_map (map_id,map_name, url, height, width, x, y) VALUES (#{mapId},#{mapName}, #{url}, #{height}, #{width}, #{x}, #{y})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id")
|
||||
void insertUseGeneratedKeys(AgvLayoutMap map);
|
||||
|
||||
AgvLayoutMapDto initLayoutMap(Long id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.nl.modules.layout.mapLayout.mapper.AgvLayoutMapMapper">
|
||||
|
||||
|
||||
<resultMap id="mapLayoutResultMap" type="org.nl.modules.layout.mapLayout.dto.AgvLayoutMapDto">
|
||||
<result property="mapId" column="map_id"/>
|
||||
<result property="width" column="width"/>
|
||||
<result property="height" column="height"/>
|
||||
<result property="url" column="url"/>
|
||||
<result property="x" column="x"/>
|
||||
<result property="y" column="y"/>
|
||||
<!-- 映射设备列表 -->
|
||||
<collection property="device" ofType="org.nl.modules.layout.deviceLayout.dto.AgvLayoutDeviceDto">
|
||||
<id property="id" column="id"/>
|
||||
<id property="deviceId" column="device_id"/>
|
||||
<result property="code" column="code"/>
|
||||
<result property="name" column="name"/>
|
||||
<result property="type" column="type"/>
|
||||
<result property="icon" column="icon"/>
|
||||
<result property="fileId" column="file_id"/>
|
||||
<result property="x" column="dx"/>
|
||||
<result property="y" column="dy"/>
|
||||
<result property="angle" column="angle"/>
|
||||
<result property="size" column="size"/>
|
||||
</collection>
|
||||
</resultMap>
|
||||
<select id="initLayoutMap" resultMap="mapLayoutResultMap">
|
||||
SELECT
|
||||
m.map_id ,
|
||||
m.width,
|
||||
m.height,
|
||||
m.url,
|
||||
m.x ,
|
||||
m.y ,
|
||||
d.id ,
|
||||
d.device_id ,
|
||||
d.code ,
|
||||
d.name,
|
||||
d.type,
|
||||
d.icon,
|
||||
d.file_id,
|
||||
d.x as dx,
|
||||
d.y as dy,
|
||||
d.angle,
|
||||
d.size
|
||||
FROM agv_layout_map m
|
||||
LEFT JOIN agv_layout_device d ON m.id = d.map_layout_id
|
||||
WHERE m.id = #{id}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,14 @@
|
||||
package org.nl.modules.layout.mapLayout.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.modules.layout.mapLayout.dto.AgvLayoutMapDto;
|
||||
import org.nl.modules.layout.mapLayout.entity.AgvLayoutMap;
|
||||
|
||||
/**
|
||||
* 地图布局Service
|
||||
*/
|
||||
public interface AgvLayoutMapService extends IService<AgvLayoutMap> {
|
||||
void saveLayout(AgvLayoutMapDto dto);
|
||||
|
||||
AgvLayoutMapDto initLayoutMap(Long id);
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package org.nl.modules.layout.mapLayout.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.nl.modules.layout.deviceLayout.dto.AgvLayoutDeviceDto;
|
||||
import org.nl.modules.layout.deviceLayout.entity.AgvLayoutDevice;
|
||||
import org.nl.modules.layout.deviceLayout.mapper.AgvLayoutDeviceMapper;
|
||||
import org.nl.modules.layout.mapLayout.dto.AgvLayoutMapDto;
|
||||
import org.nl.modules.layout.mapLayout.entity.AgvLayoutMap;
|
||||
import org.nl.modules.layout.mapLayout.mapper.AgvLayoutMapMapper;
|
||||
import org.nl.modules.layout.mapLayout.service.AgvLayoutMapService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 地图布局ServiceImpl
|
||||
*/
|
||||
@Service
|
||||
public class AgvLayoutMapServiceImpl extends ServiceImpl<AgvLayoutMapMapper, AgvLayoutMap> implements AgvLayoutMapService {
|
||||
|
||||
@Resource
|
||||
private AgvLayoutDeviceMapper agvLayoutDeviceMapper;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void saveLayout(AgvLayoutMapDto dto) {
|
||||
AgvLayoutMap layoutMap = AgvLayoutMap.builder()
|
||||
.mapId(dto.getMapId())
|
||||
.mapName(dto.getMapName())
|
||||
.url(dto.getUrl())
|
||||
.width(dto.getWidth())
|
||||
.version("1")
|
||||
.height(dto.getHeight())
|
||||
.x(dto.getX())
|
||||
.y(dto.getY()).build();
|
||||
this.baseMapper.insertUseGeneratedKeys(layoutMap);
|
||||
List<AgvLayoutDeviceDto> deviceLayout = dto.getDevice();
|
||||
if (!CollectionUtils.isEmpty(deviceLayout)){
|
||||
for (AgvLayoutDeviceDto device : deviceLayout) {
|
||||
AgvLayoutDevice layoutDevice = AgvLayoutDevice.builder()
|
||||
.deviceId(device.getDeviceId())
|
||||
.mapLayoutId(layoutMap.getId())
|
||||
.name(device.getName())
|
||||
.code(device.getCode())
|
||||
.type(device.getType())
|
||||
.angle(device.getAngle())
|
||||
.x(device.getX())
|
||||
.y(device.getY())
|
||||
.size(device.getSize())
|
||||
.icon(device.getIcon())
|
||||
.fileId(device.getFileId()).build();
|
||||
agvLayoutDeviceMapper.insert(layoutDevice);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AgvLayoutMapDto initLayoutMap(Long id) {
|
||||
return this.baseMapper.initLayoutMap(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package org.nl.modules.localStorage.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.utils.query.PageQuery;
|
||||
import org.nl.modules.localStorage.service.LocalStorageService;
|
||||
import org.nl.modules.localStorage.service.dao.LocalStorageQuery;
|
||||
import org.nl.modules.localStorage.service.entity.LocalStorage;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping({"/api/localStorage"})
|
||||
@SaIgnore
|
||||
public class LocalStorageController {
|
||||
|
||||
@Autowired
|
||||
private LocalStorageService localStorageService;
|
||||
|
||||
@GetMapping("/list")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> pageList(LocalStorageQuery query, PageQuery pageQuery) {
|
||||
return new ResponseEntity<>(localStorageService.page(pageQuery.build(),query.build()), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> query(@RequestParam String annex) {
|
||||
List<LocalStorage> list = new ArrayList<>();
|
||||
if (StringUtils.isNotEmpty(annex)){
|
||||
String[] split = annex.split(",");
|
||||
list = localStorageService.listByIds(Arrays.asList(split));
|
||||
}
|
||||
return new ResponseEntity<>(list, HttpStatus.OK);
|
||||
}
|
||||
@PostMapping({"/upload"})
|
||||
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> upload(@RequestParam MultipartFile file) {
|
||||
LocalStorage localStorage = localStorageService.upload(file);
|
||||
return new ResponseEntity<>(localStorage, HttpStatus.OK);
|
||||
}
|
||||
@GetMapping({"/download"})
|
||||
@SaIgnore
|
||||
public void download(@RequestParam Long storageId , HttpServletResponse response, HttpServletRequest request) throws IOException {
|
||||
this.localStorageService.downloadFile(this.localStorageService.getById(storageId),request, response);
|
||||
}
|
||||
|
||||
|
||||
@DeleteMapping
|
||||
@SaIgnore
|
||||
public ResponseEntity delete(@RequestBody Long[] ids) {
|
||||
localStorageService.removeByIds(Arrays.asList(ids));
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.nl.modules.localStorage.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.modules.localStorage.service.entity.LocalStorage;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public interface LocalStorageService extends IService<LocalStorage> {
|
||||
|
||||
LocalStorage upload(MultipartFile file);
|
||||
List<LocalStorage> batchUpload(MultipartFile[] file);
|
||||
|
||||
void download(List<LocalStorage> localStorageDtos, HttpServletResponse response) throws IOException;
|
||||
void downloadFile(LocalStorage localStorage, HttpServletRequest request, HttpServletResponse response) throws IOException;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package org.nl.modules.localStorage.service.dao;
|
||||
|
||||
import org.nl.common.utils.query.BaseQuery;
|
||||
import org.nl.modules.localStorage.service.entity.LocalStorage;
|
||||
|
||||
public class LocalStorageQuery extends BaseQuery<LocalStorage> {
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package org.nl.modules.localStorage.service.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@Data
|
||||
@TableName("local_storage")
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class LocalStorage implements Serializable {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
private String name;
|
||||
private String suffix;
|
||||
private String path;
|
||||
private String type;
|
||||
private String size;
|
||||
private Integer orderCode;
|
||||
private Date createTime;
|
||||
private String createName;
|
||||
private Date updateTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package org.nl.modules.localStorage.service.impl;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import org.nl.modules.common.config.FileProperties;
|
||||
import org.nl.modules.common.utils.FileUtil;
|
||||
import org.nl.modules.localStorage.service.LocalStorageService;
|
||||
import org.nl.modules.localStorage.service.entity.LocalStorage;
|
||||
import org.nl.modules.localStorage.service.mapper.LocalStorageMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
|
||||
@Service
|
||||
public class LocalStorageServiceImpl extends ServiceImpl<LocalStorageMapper, LocalStorage> implements LocalStorageService {
|
||||
@Autowired
|
||||
private FileProperties fileProperties;
|
||||
|
||||
|
||||
@Override
|
||||
public LocalStorage upload(MultipartFile multipartFile) {
|
||||
String filename = multipartFile.getOriginalFilename();
|
||||
String suffix = FileUtil.getExtensionName(filename);
|
||||
String type = FileUtil.getFileType(suffix);
|
||||
File file = FileUtil.upload(multipartFile, this.fileProperties.getPath().getPath() + type + File.separator);
|
||||
LocalStorage storage = LocalStorage.builder().name(filename)
|
||||
.path(file.getPath())
|
||||
.size(FileUtil.getSize(multipartFile.getSize()))
|
||||
.suffix(type)
|
||||
.type(type).createTime(new Date()).build();
|
||||
this.baseMapper.insertUseGeneratedKeys(storage);
|
||||
return storage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LocalStorage> batchUpload(MultipartFile[] multipartFile) {
|
||||
List<LocalStorage> result = new ArrayList<>();
|
||||
if (multipartFile!=null){
|
||||
for (MultipartFile item : multipartFile) {
|
||||
String filename = item.getOriginalFilename();
|
||||
String suffix = FileUtil.getExtensionName(filename);
|
||||
String type = FileUtil.getFileType(suffix);
|
||||
File file = FileUtil.upload(item, this.fileProperties.getPath().getPath() + type + File.separator);
|
||||
LocalStorage storage = LocalStorage.builder().name(filename)
|
||||
.path(file.getPath())
|
||||
.size(FileUtil.getSize(item.getSize()))
|
||||
.suffix(type)
|
||||
.type(type).createTime(new Date()).build();
|
||||
result.add(storage);
|
||||
}
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(result)){
|
||||
this.saveBatch(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@Override
|
||||
public void download(List<LocalStorage> queryAll, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList();
|
||||
Iterator var4 = queryAll.iterator();
|
||||
|
||||
while(var4.hasNext()) {
|
||||
LocalStorage localStorageDTO = (LocalStorage)var4.next();
|
||||
Map<String, Object> map = new LinkedHashMap();
|
||||
map.put("文件名", localStorageDTO.getName());
|
||||
map.put("备注名", localStorageDTO.getName());
|
||||
map.put("文件类型", localStorageDTO.getType());
|
||||
map.put("文件大小", localStorageDTO.getSize());
|
||||
map.put("创建者", localStorageDTO.getCreateName());
|
||||
map.put("创建日期", localStorageDTO.getCreateTime());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadFile(LocalStorage localStorage, HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
String path = localStorage.getPath();
|
||||
File file = new File(path);
|
||||
FileUtil.downloadFile(request, response,file,false);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package org.nl.modules.localStorage.service.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Options;
|
||||
import org.nl.modules.localStorage.service.entity.LocalStorage;
|
||||
|
||||
@Mapper
|
||||
public interface LocalStorageMapper extends BaseMapper<LocalStorage> {
|
||||
|
||||
@Insert("INSERT INTO local_storage (name, suffix, path, type, size, order_code, create_time, create_name, update_time) VALUES (#{name}, #{suffix}, #{path}, #{type}, #{size}, #{orderCode}, #{createTime}, #{createName}, #{updateTime})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id")
|
||||
void insertUseGeneratedKeys(LocalStorage user);
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.nl.modules.tools.config;
|
||||
|
||||
import org.springframework.boot.web.servlet.MultipartConfigFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.servlet.MultipartConfigElement;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @date 2018-12-28
|
||||
* @author https://blog.csdn.net/llibin1024530411/article/details/79474953
|
||||
*/
|
||||
@Configuration
|
||||
public class MultipartConfig {
|
||||
|
||||
/**
|
||||
* 文件上传临时路径
|
||||
*/
|
||||
@Bean
|
||||
MultipartConfigElement multipartConfigElement() {
|
||||
MultipartConfigFactory factory = new MultipartConfigFactory();
|
||||
String location = System.getProperty("user.home") + "/.eladmin/file/tmp";
|
||||
File tmpFile = new File(location);
|
||||
if (!tmpFile.exists()) {
|
||||
if (!tmpFile.mkdirs()) {
|
||||
System.out.println("create was not successful.");
|
||||
}
|
||||
}
|
||||
factory.setLocation(location);
|
||||
return factory.createMultipartConfig();
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.nl.modules.tools.domain;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.nl.modules.common.base.BaseEntity;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-09-05
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name="tool_local_storage")
|
||||
@NoArgsConstructor
|
||||
public class LocalStorage extends BaseEntity implements Serializable {
|
||||
|
||||
@Id
|
||||
@Column(name = "storage_id")
|
||||
@ApiModelProperty(value = "ID", hidden = true)
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "真实文件名")
|
||||
private String realName;
|
||||
|
||||
@ApiModelProperty(value = "文件名")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "后缀")
|
||||
private String suffix;
|
||||
|
||||
@ApiModelProperty(value = "路径")
|
||||
private String path;
|
||||
|
||||
@ApiModelProperty(value = "类型")
|
||||
private String type;
|
||||
|
||||
@ApiModelProperty(value = "大小")
|
||||
private String size;
|
||||
|
||||
public LocalStorage(String realName,String name, String suffix, String path, String type, String size) {
|
||||
this.realName = realName;
|
||||
this.name = name;
|
||||
this.suffix = suffix;
|
||||
this.path = path;
|
||||
this.type = type;
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public void copy(LocalStorage source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.nl.modules.tools.repository;
|
||||
|
||||
import org.nl.modules.tools.domain.LocalStorage;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-09-05
|
||||
*/
|
||||
public interface LocalStorageRepository extends JpaRepository<LocalStorage, Long>, JpaSpecificationExecutor<LocalStorage> {
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.nl.modules.tools.rest;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.common.utils.FileUtil;
|
||||
import org.nl.modules.logging.annotation.Log;
|
||||
import org.nl.modules.tools.domain.LocalStorage;
|
||||
import org.nl.modules.tools.service.LocalStorageService;
|
||||
import org.nl.modules.tools.service.dto.LocalStorageQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-09-05
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "工具:本地存储管理")
|
||||
@RequestMapping("/api/localStorage")
|
||||
public class LocalStorageController {
|
||||
|
||||
private final LocalStorageService localStorageService;
|
||||
|
||||
@ApiOperation("查询文件")
|
||||
@GetMapping
|
||||
@SaCheckPermission("storage:list")
|
||||
public ResponseEntity<Object> query(LocalStorageQueryCriteria criteria, Pageable pageable) {
|
||||
return new ResponseEntity<>(localStorageService.queryAll(criteria, pageable), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
@SaCheckPermission("storage:list")
|
||||
public void download(HttpServletResponse response, LocalStorageQueryCriteria criteria) throws IOException {
|
||||
localStorageService.download(localStorageService.queryAll(criteria), response);
|
||||
}
|
||||
|
||||
@ApiOperation("上传文件")
|
||||
@PostMapping
|
||||
@SaCheckPermission("storage:add")
|
||||
public ResponseEntity<Object> create(@RequestParam String name, @RequestParam("file") MultipartFile file) {
|
||||
LocalStorage localStorage = localStorageService.create(name, file);
|
||||
return new ResponseEntity<>(localStorage, HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PostMapping("/pictures")
|
||||
@ApiOperation("上传图片")
|
||||
public ResponseEntity<Object> upload(@RequestParam MultipartFile file) {
|
||||
// 判断文件是否为图片
|
||||
String suffix = FileUtil.getExtensionName(file.getOriginalFilename());
|
||||
if (!FileUtil.IMAGE.equals(FileUtil.getFileType(suffix))) {
|
||||
throw new BadRequestException("只能上传图片");
|
||||
}
|
||||
LocalStorage localStorage = localStorageService.create(null, file);
|
||||
return new ResponseEntity<>(localStorage, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("修改文件")
|
||||
@ApiOperation("修改文件")
|
||||
@PutMapping
|
||||
@SaCheckPermission("storage:edit")
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody LocalStorage resources) {
|
||||
localStorageService.update(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Log("删除文件")
|
||||
@DeleteMapping
|
||||
@ApiOperation("多选删除")
|
||||
public ResponseEntity<Object> delete(@RequestBody Long[] ids) {
|
||||
localStorageService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.nl.modules.tools.service;
|
||||
|
||||
|
||||
import org.nl.modules.tools.domain.LocalStorage;
|
||||
import org.nl.modules.tools.service.dto.LocalStorageDto;
|
||||
import org.nl.modules.tools.service.dto.LocalStorageQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-09-05
|
||||
*/
|
||||
public interface LocalStorageService {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param criteria 条件
|
||||
* @param pageable 分页参数
|
||||
* @return /
|
||||
*/
|
||||
Object queryAll(LocalStorageQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 查询全部数据
|
||||
* @param criteria 条件
|
||||
* @return /
|
||||
*/
|
||||
List<LocalStorageDto> queryAll(LocalStorageQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
* @param id /
|
||||
* @return /
|
||||
*/
|
||||
LocalStorageDto findById(Long id);
|
||||
|
||||
/**
|
||||
* 上传
|
||||
* @param name 文件名称
|
||||
* @param file 文件
|
||||
* @return
|
||||
*/
|
||||
LocalStorage create(String name, MultipartFile file);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param resources 文件信息
|
||||
*/
|
||||
void update(LocalStorage resources);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Long[] ids);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
* @param localStorageDtos 待导出的数据
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
void download(List<LocalStorageDto> localStorageDtos, HttpServletResponse response) throws IOException;
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.nl.modules.tools.service.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.nl.modules.common.base.BaseDTO;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-09-05
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class LocalStorageDto extends BaseDTO implements Serializable {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String realName;
|
||||
|
||||
private String name;
|
||||
|
||||
private String suffix;
|
||||
|
||||
private String type;
|
||||
|
||||
private String size;
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.nl.modules.tools.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import org.nl.modules.common.annotation.Query;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-09-05
|
||||
*/
|
||||
@Data
|
||||
public class LocalStorageQueryCriteria{
|
||||
|
||||
@Query(blurry = "name,suffix,type,createBy,size")
|
||||
private String blurry;
|
||||
|
||||
@Query(type = Query.Type.BETWEEN)
|
||||
private List<Timestamp> createTime;
|
||||
}
|
||||
@@ -1,138 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.nl.modules.tools.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.modules.common.config.FileProperties;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.common.utils.FileUtil;
|
||||
import org.nl.modules.common.utils.PageUtil;
|
||||
import org.nl.modules.common.utils.QueryHelp;
|
||||
import org.nl.modules.common.utils.ValidationUtil;
|
||||
import org.nl.modules.tools.domain.LocalStorage;
|
||||
import org.nl.modules.tools.repository.LocalStorageRepository;
|
||||
import org.nl.modules.tools.service.LocalStorageService;
|
||||
import org.nl.modules.tools.service.dto.LocalStorageDto;
|
||||
import org.nl.modules.tools.service.dto.LocalStorageQueryCriteria;
|
||||
import org.nl.modules.tools.service.mapstruct.LocalStorageMapper;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-09-05
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class LocalStorageServiceImpl implements LocalStorageService {
|
||||
|
||||
private final LocalStorageRepository localStorageRepository;
|
||||
private final LocalStorageMapper localStorageMapper;
|
||||
private final FileProperties properties;
|
||||
|
||||
@Override
|
||||
public Object queryAll(LocalStorageQueryCriteria criteria, Pageable pageable){
|
||||
Page<LocalStorage> page = localStorageRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
return PageUtil.toPage(page.map(localStorageMapper::toDto));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LocalStorageDto> queryAll(LocalStorageQueryCriteria criteria){
|
||||
return localStorageMapper.toDto(localStorageRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalStorageDto findById(Long id){
|
||||
LocalStorage localStorage = localStorageRepository.findById(id).orElseGet(LocalStorage::new);
|
||||
ValidationUtil.isNull(localStorage.getId(),"LocalStorage","id",id);
|
||||
return localStorageMapper.toDto(localStorage);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public LocalStorage create(String name, MultipartFile multipartFile) {
|
||||
FileUtil.checkSize(properties.getMaxSize(), multipartFile.getSize());
|
||||
String suffix = FileUtil.getExtensionName(multipartFile.getOriginalFilename());
|
||||
String type = FileUtil.getFileType(suffix);
|
||||
File file = FileUtil.upload(multipartFile, properties.getPath().getPath() + type + File.separator);
|
||||
if(ObjectUtil.isNull(file)){
|
||||
throw new BadRequestException("上传失败");
|
||||
}
|
||||
try {
|
||||
name = StrUtil.isEmpty(name) ? FileUtil.getFileNameNoEx(multipartFile.getOriginalFilename()) : name;
|
||||
LocalStorage localStorage = new LocalStorage(
|
||||
file.getName(),
|
||||
name,
|
||||
suffix,
|
||||
file.getPath(),
|
||||
type,
|
||||
FileUtil.getSize(multipartFile.getSize())
|
||||
);
|
||||
return localStorageRepository.save(localStorage);
|
||||
}catch (Exception e){
|
||||
FileUtil.del(file);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(LocalStorage resources) {
|
||||
LocalStorage localStorage = localStorageRepository.findById(resources.getId()).orElseGet(LocalStorage::new);
|
||||
ValidationUtil.isNull( localStorage.getId(),"LocalStorage","id",resources.getId());
|
||||
localStorage.copy(resources);
|
||||
localStorageRepository.save(localStorage);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteAll(Long[] ids) {
|
||||
for (Long id : ids) {
|
||||
LocalStorage storage = localStorageRepository.findById(id).orElseGet(LocalStorage::new);
|
||||
FileUtil.del(storage.getPath());
|
||||
localStorageRepository.delete(storage);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(List<LocalStorageDto> queryAll, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (LocalStorageDto localStorageDTO : queryAll) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("文件名", localStorageDTO.getRealName());
|
||||
map.put("备注名", localStorageDTO.getName());
|
||||
map.put("文件类型", localStorageDTO.getType());
|
||||
map.put("文件大小", localStorageDTO.getSize());
|
||||
map.put("创建者", localStorageDTO.getCreateBy());
|
||||
map.put("创建日期", localStorageDTO.getCreateTime());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.nl.modules.tools.service.mapstruct;
|
||||
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
import org.nl.modules.common.base.BaseMapper;
|
||||
import org.nl.modules.tools.domain.LocalStorage;
|
||||
import org.nl.modules.tools.service.dto.LocalStorageDto;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-09-05
|
||||
*/
|
||||
@Mapper(componentModel = "spring",unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface LocalStorageMapper extends BaseMapper<LocalStorageDto, LocalStorage> {
|
||||
|
||||
}
|
||||
@@ -9,7 +9,12 @@ spring:
|
||||
redis:
|
||||
repositories:
|
||||
enabled: false
|
||||
|
||||
main:
|
||||
allow-circular-references: true
|
||||
servlet:
|
||||
multipart:
|
||||
max-request-size: 100MB
|
||||
max-file-size: 100MB
|
||||
#配置 Jpa
|
||||
jpa:
|
||||
hibernate:
|
||||
@@ -78,3 +83,8 @@ security:
|
||||
- /api/localStorage/pictures
|
||||
# 参数
|
||||
- /api/param/getValueByCode
|
||||
mybatis-plus:
|
||||
configuration:
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
mapper-locations:
|
||||
- classpath:/org/nl/**/mapper/**/*.xml
|
||||
|
||||
Reference in New Issue
Block a user