add: 历史记录模块添加导出功能

This commit is contained in:
yanps
2023-12-05 18:01:27 +08:00
parent 045a1f9066
commit 9398535dcc
20 changed files with 501 additions and 36 deletions

View File

@@ -443,6 +443,26 @@
<version>${commons-csv.version}</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.12.0</version>
</dependency>
</dependencies>
<build>

View File

@@ -389,6 +389,19 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
//查找有没有对应的指令
Instruction inst = instructionService.findByDeviceCodeFromCache(this.device_code);
if (ObjectUtil.isNotNull(inst) && "1".equals(inst.getInstruction_type())) {
List<RouteLineDto> routeLineDtos = routeLineService.selectDeviceCodeList(this.device_code);
if (routeLineDtos.size() < 1) {
return false;
}
int i = 0;
for (RouteLineDto routeLineDto : routeLineDtos) {
if (routeLineDto.getNext_device_code().equals(inst.getNext_device_code())) {
i++;
}
}
if (i == 0) {
return false;
}
Device nextdevice = deviceAppservice.findDeviceByCode(inst.getNext_device_code());
String next_addr = nextdevice.getExtraValue().get("address").toString();
TaskDto taskDto = taskserver.findByCodeFromCache(inst.getTask_code());
@@ -485,7 +498,7 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
instructionService.create(instdto);
} catch (Exception e) {
e.printStackTrace();
log.error("指令创建失败!", e.getMessage());
log.error("指令创建失败!,{}", e.getMessage());
return false;
}
taskdto.setTask_status("1");

View File

@@ -622,13 +622,13 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
map.put("to_task", inst.getInstruction_code());
if (StrUtil.equals(startDevice.getDevice_type(), DeviceType.conveyor.name())) {
if (ObjectUtil.isNotEmpty(startDevice.getExtraValue().get("x"))) {
map.put("to_x", startDevice.getExtraValue().get("x"));
if (ObjectUtil.isNotEmpty(startDevice.getExtraValue().get("z")) ) {
map.put("to_x", startDevice.getExtraValue().get("z"));
}
if (ObjectUtil.isNotEmpty(startDevice.getExtraValue().get("z"))) {
map.put("to_z", startDevice.getExtraValue().get("z"));
if (ObjectUtil.isNotEmpty(startDevice.getExtraValue().get("x")) ) {
map.put("to_z", startDevice.getExtraValue().get("x"));
}
if (ObjectUtil.isNotEmpty(startDevice.getExtraValue().get("y"))) {
if (ObjectUtil.isNotEmpty(startDevice.getExtraValue().get("y")) ) {
map.put("to_y", startDevice.getExtraValue().get("y"));
}
}

View File

@@ -154,4 +154,12 @@ public class InstructionController {
instructionService.init(id);
return new ResponseEntity<>(HttpStatus.OK);
}
@GetMapping("/downloadInstLogging")
@Log("导出指令记录")
@ApiOperation("导出指令记录")
//@PreAuthorize("@el.check('task:list')")
public void downloadInstLogging(HttpServletResponse response,@RequestParam Map whereJson) throws IOException {
instructionService.downloadInstLogging(instructionService.getInstList(whereJson), response);
}
}

View File

@@ -1,5 +1,6 @@
package org.nl.acs.instruction.service;
import com.alibaba.fastjson.JSONObject;
import org.nl.acs.instruction.domain.InstructionMybatis;
import org.nl.acs.instruction.service.dto.InstructionDto;
import org.nl.acs.instruction.service.dto.InstructionQueryParam;
@@ -327,5 +328,21 @@ public interface InstructionService extends CommonService<InstructionMybatis> {
* @param instruction1
* @return
*/
List<Instruction> findByDeviceCodes(Instruction instruction1, Boolean flay);
/**
* 根据条件查询指令
* @param whereJson
* @return
*/
List<JSONObject> getInstList(Map whereJson);
/**
* 导出指令记录
* @param instList
* @param response
*/
void downloadInstLogging(List<JSONObject> instList, HttpServletResponse response) throws IOException;
}

View File

@@ -1607,4 +1607,80 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
List<Instruction> instructions = ConvertUtil.convertList(instructionMybatis, Instruction.class);*/
return instructionList;
}
@Override
public List<JSONObject> getInstList(Map whereJson) {
String task_code = (String) whereJson.get("code");
String vehicle_code = (String) whereJson.get("vehicle_code");
String material_type = (String) whereJson.get("material_type");
String status = (String) whereJson.get("status");
String point_code = (String) whereJson.get("point_code");
String create_time = (String) whereJson.get("createTime");
String end_time = (String) whereJson.get("end_time");
LambdaQueryWrapper<InstructionMybatis> wrapper = new LambdaQueryWrapper<>();
if (!StrUtil.isEmpty(task_code)) {
wrapper.and(instructionMybatis -> instructionMybatis.like(InstructionMybatis::getInstruction_code, task_code).or().like(InstructionMybatis::getTask_code, task_code));
}
if (!StrUtil.isEmpty(vehicle_code)) {
wrapper.like(InstructionMybatis::getVehicle_code, vehicle_code);
}
if (!StrUtil.isEmpty(material_type)) {
wrapper.eq(InstructionMybatis::getMaterial, material_type);
}
if (!StrUtil.isEmpty(status)) {
wrapper.eq(InstructionMybatis::getInstruction_status, status);
}
if (!StrUtil.isEmpty(point_code)) {
wrapper.and(task -> task.like(InstructionMybatis::getStart_point_code, point_code).or().like(InstructionMybatis::getNext_point_code, point_code));
}
if (!StrUtil.isEmpty(create_time) && !StrUtil.isEmpty(end_time)) {
wrapper.between(InstructionMybatis::getCreate_time, create_time, end_time);
}
List<InstructionMybatis> instructionMybatis = instructionMapper.selectList(wrapper);
List<JSONObject> array = new ArrayList<>();
if(instructionMybatis.size() > 0){
for (InstructionMybatis inst : instructionMybatis) {
JSONObject ins = new JSONObject();
ins.put("instruction_code", inst.getInstruction_code());
ins.put("task_code", inst.getTask_code());
ins.put("vehicle_code", inst.getVehicle_code());
ins.put("task_status", inst.getInstruction_status());
ins.put("start_point_code", inst.getStart_point_code());
ins.put("next_point_code", inst.getNext_point_code());
ins.put("matarial", inst.getMaterial());
ins.put("quantity", inst.getQuantity());
ins.put("remark", inst.getRemark());
ins.put("create_by", inst.getCreate_by());
ins.put("create_time", inst.getCreate_time());
ins.put("update_by", inst.getUpdate_by());
ins.put("update_time", inst.getUpdate_time());
array.add(ins);
}
}
return array;
}
@Override
public void downloadInstLogging(List<JSONObject> instList, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (JSONObject jsonObject : instList) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("指令编码", jsonObject.getString("instruction_code"));
map.put("任务号", jsonObject.getString("task_code"));
map.put("载具号", jsonObject.getString("vehicle_code"));
map.put("指令状态", jsonObject.getString("task_status"));
map.put("起点", jsonObject.getString("start_point_code"));
map.put("终点", jsonObject.getString("next_point_code"));
map.put("物料", jsonObject.getString("matarial"));
map.put("数量", jsonObject.getString("quantity"));
map.put("备注", jsonObject.getString("remark"));
map.put("创建者", jsonObject.getString("create_by"));
map.put("创建时间", jsonObject.getString("create_time"));
map.put("修改者", jsonObject.getString("update_by"));
map.put("修改时间", jsonObject.getString("update_time"));
list.add(map);
}
FileUtil.downloadExcel(list, response);
}
}

View File

@@ -156,4 +156,22 @@ public class TaskController {
public ResponseEntity<Object> findAllTaskFromCache() {
return new ResponseEntity<>(taskService.findAllTaskFromCache(), HttpStatus.OK);
}
@GetMapping("/downloadTaskTreeLogging")
@Log("导出任务树形记录")
@ApiOperation("导出任务树形记录")
//@PreAuthorize("@el.check('task:list')")
public void downloadTaskTreeLogging(HttpServletResponse response,@RequestParam Map whereJson) throws IOException {
taskService.downloadTaskTreeLogging(taskService.getTaskAndInst(whereJson), response);
}
@GetMapping("/downloadTaskLogging")
@Log("导出任务树形记录")
@ApiOperation("导出任务树形记录")
//@PreAuthorize("@el.check('task:list')")
public void downloadTaskLogging(HttpServletResponse response,@RequestParam Map whereJson) throws IOException {
taskService.downloadTaskLogging(taskService.getTaskList(whereJson), response);
}
}

View File

@@ -372,4 +372,36 @@ public interface TaskService extends CommonService<Task> {
* @return
*/
Integer querySameDeviceReadyTask(String start_device, String next_device, String status);
/**
* 条件查询任务和指令
* @param whereJson
* @param page
* @return
*/
List<JSONObject> getTaskAndInst(Map whereJson);
/**
* 导出任务树形记录
* @param taskAndInst
* @param response
*/
void downloadTaskTreeLogging(List<JSONObject> list, HttpServletResponse response) throws IOException;
/**
* 导出任务记录
* @param all
* @param response
*/
void downloadTaskLogging(List<JSONObject> all, HttpServletResponse response) throws IOException;
/**
* 查询任务
* @param whereJson
* @return
*/
List<JSONObject> getTaskList(Map whereJson);
}

View File

@@ -1,6 +1,7 @@
package org.nl.acs.task.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.IdUtil;
@@ -11,6 +12,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.AcsConfig;
@@ -1677,6 +1679,176 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
return num;
}
@Override
public List<JSONObject> getTaskAndInst(Map whereJson) {
String task_code = (String) whereJson.get("task_code");
String vehicle_code = (String) whereJson.get("vehicle_code");
String material_type = (String) whereJson.get("material_type");
String status = (String) whereJson.get("status");
String point_code = (String) whereJson.get("point_code");
String create_time = (String) whereJson.get("createTime");
String end_time = (String) whereJson.get("end_time");
LambdaQueryWrapper<Task> wrapper = new LambdaQueryWrapper<>();
if (!StrUtil.isEmpty(task_code)) {
wrapper.eq(Task::getTask_code, task_code);
}
if (!StrUtil.isEmpty(vehicle_code)) {
wrapper.like(Task::getVehicle_code, vehicle_code);
}
if (!StrUtil.isEmpty(material_type)) {
wrapper.eq(Task::getMaterial, material_type);
}
if (!StrUtil.isEmpty(status)) {
wrapper.eq(Task::getTask_status, status);
}
if (!StrUtil.isEmpty(point_code)) {
wrapper.and(task -> task.like(Task::getStart_point_code, point_code).or().like(Task::getNext_point_code, point_code));
}
if (!StrUtil.isEmpty(create_time) && !StrUtil.isEmpty(end_time)) {
wrapper.between(Task::getCreate_time, create_time, end_time);
}
List<Task> taskList = taskMapper.selectList(wrapper);
List<JSONObject> array = new ArrayList<>();
if (CollUtil.isNotEmpty(taskList) && taskList.size() > 0) {
for (Task task : taskList) {
JSONObject ins = new JSONObject();
//ins.put("task_id", task.getTask_id());
ins.put("task_code", task.getTask_code());
ins.put("vehicle_code", task.getVehicle_code());
ins.put("task_status", task.getTask_status());
ins.put("priority", task.getPriority());
ins.put("start_point_code", task.getStart_point_code());
ins.put("next_point_code", task.getNext_point_code());
ins.put("start_point_code2", task.getStart_point_code2());
ins.put("next_point_code2", task.getNext_point_code2());
ins.put("matarial", task.getMaterial());
ins.put("quantity", task.getQuantity());
ins.put("remark", task.getRemark());
ins.put("create_by", task.getCreate_by());
ins.put("create_time", task.getCreate_time());
array.add(ins);
List<InstructionMybatis> list = instructionService.list(Wrappers.lambdaQuery(InstructionMybatis.class));
if (CollUtil.isNotEmpty(list) && list.size() > 0) {
for (InstructionMybatis inst : list) {
if(task.getTask_id().equals(inst.getTask_id())){
JSONObject ins1 = new JSONObject();
//ins1.put("task_id", inst.getInstruction_id());
ins1.put("task_code", inst.getInstruction_code());
ins1.put("vehicle_code", inst.getVehicle_code());
ins1.put("task_status", inst.getInstruction_status());
ins1.put("start_point_code", inst.getStart_point_code());
ins1.put("next_point_code", inst.getNext_point_code());
ins1.put("matarial", inst.getMaterial());
ins1.put("remark", inst.getRemark());
ins1.put("create_by", inst.getCreate_by());
ins1.put("create_time", inst.getCreate_time());
array.add(ins1);
}
}
}
}
}
return array;
}
@Override
public void downloadTaskTreeLogging(List<JSONObject> taskAndInst, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (JSONObject jsonObject : taskAndInst) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("任务号(指令编码)", jsonObject.getString("task_code"));
map.put("载具号", jsonObject.getString("vehicle_code"));
map.put("状态", jsonObject.getString("task_status"));
map.put("任务优先级", jsonObject.getString("priority"));
map.put("起点", jsonObject.getString("start_point_code"));
map.put("终点", jsonObject.getString("next_point_code"));
map.put("起点2", jsonObject.getString("start_point_code2"));
map.put("终点2", jsonObject.getString("next_point_code2"));
map.put("物料", jsonObject.getString("matarial"));
map.put("数量", jsonObject.getString("quantity"));
map.put("备注", jsonObject.getString("remark"));
map.put("创建者", jsonObject.getString("create_by"));
map.put("创建时间", jsonObject.getString("create_time"));
list.add(map);
}
FileUtil.downloadExcel(list, response);
}
@Override
public void downloadTaskLogging(List<JSONObject> taskAndInst, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (JSONObject jsonObject : taskAndInst) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("任务号", jsonObject.getString("task_code"));
map.put("载具号", jsonObject.getString("vehicle_code"));
map.put("任务状态", jsonObject.getString("task_status"));
map.put("任务优先级", jsonObject.getString("priority"));
map.put("起点", jsonObject.getString("start_point_code"));
map.put("终点", jsonObject.getString("next_point_code"));
map.put("物料", jsonObject.getString("matarial"));
map.put("数量", jsonObject.getString("quantity"));
map.put("备注", jsonObject.getString("remark"));
map.put("创建者", jsonObject.getString("create_by"));
map.put("创建时间", jsonObject.getString("create_time"));
list.add(map);
}
FileUtil.downloadExcel(list, response);
}
@Override
public List<JSONObject> getTaskList(Map whereJson) {
String task_code = (String) whereJson.get("task_code");
String vehicle_code = (String) whereJson.get("vehicle_code");
String material_type = (String) whereJson.get("material_type");
String status = (String) whereJson.get("status");
String point_code = (String) whereJson.get("point_code");
String create_time = (String) whereJson.get("createTime");
String end_time = (String) whereJson.get("end_time");
LambdaQueryWrapper<Task> wrapper = new LambdaQueryWrapper<>();
if (!StrUtil.isEmpty(task_code)) {
wrapper.eq(Task::getTask_code, task_code);
}
if (!StrUtil.isEmpty(vehicle_code)) {
wrapper.like(Task::getVehicle_code, vehicle_code);
}
if (!StrUtil.isEmpty(material_type)) {
wrapper.eq(Task::getMaterial, material_type);
}
if (!StrUtil.isEmpty(status)) {
wrapper.eq(Task::getTask_status, status);
}
if (!StrUtil.isEmpty(point_code)) {
wrapper.and(task -> task.like(Task::getStart_point_code, point_code).or().like(Task::getNext_point_code, point_code));
}
if (!StrUtil.isEmpty(create_time) && !StrUtil.isEmpty(end_time)) {
wrapper.between(Task::getCreate_time, create_time, end_time);
}
List<Task> taskList = taskMapper.selectList(wrapper);
List<JSONObject> array = new ArrayList<>();
if (CollUtil.isNotEmpty(taskList) && taskList.size() > 0) {
for (Task task : taskList) {
JSONObject ins = new JSONObject();
//ins.put("task_id", task.getTask_id());
ins.put("task_code", task.getTask_code());
ins.put("vehicle_code", task.getVehicle_code());
ins.put("task_status", task.getTask_status());
ins.put("priority", task.getPriority());
ins.put("start_point_code", task.getStart_point_code());
ins.put("next_point_code", task.getNext_point_code());
ins.put("matarial", task.getMaterial());
ins.put("quantity", task.getQuantity());
ins.put("remark", task.getRemark());
ins.put("create_by", task.getCreate_by());
ins.put("create_time", task.getCreate_time());
array.add(ins);
}
}
return array;
}
@Override
public Integer querySameTaskByType(String taskType) {

View File

@@ -60,7 +60,7 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
* linux: /temp
* </pre>
*/
public static final String SYS_TEM_DIR = System.getProperty("java.io.tmpdir") + File.separator;
public static final String SYS_TEM_DIR = System.getProperty("java.io.tmpdir");
/**
* 定义GB的计算常量
*/
@@ -210,7 +210,9 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
File file = new File(tempPath);
BigExcelWriter writer = ExcelUtil.getBigWriter(file);
// 一次性写出内容,使用默认样式,强制输出标题
writer.write(list, true);
for (Object item : list) {
writer.writeRow(item, true);
}
SXSSFSheet sheet = (SXSSFSheet)writer.getSheet();
//上面需要强转SXSSFSheet 不然没有trackAllColumnsForAutoSizing方法
sheet.trackAllColumnsForAutoSizing();

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

View File

@@ -1,17 +1,17 @@
export default {
'Auto': {
'table': {
'name': '名称',
'code': '编号',
'status': '状态',
'thread_name': '线程名',
'thread_state': '线程状态',
'usedStatus': '使用状态',
'stopMessage': '停止信息',
'operate': '操作',
},
'msg': {
'stop_msg': '确定停止该线程吗?'
}
'Auto': {
'table': {
'name': '名称',
'code': '编号',
'status': '状态',
'thread_name': '线程名',
'thread_state': '线程状态',
'usedStatus': '使用状态',
'stopMessage': '停止信息',
'operate': '操作'
},
'msg': {
'stop_msg': '确定停止该线程吗?'
}
}
}
}

View File

@@ -15,7 +15,8 @@ export default {
'inst_nextdevice_code': 'Command destination device',
'destination_configuration': 'Destination configuration',
'operation': 'Operation',
'device_is_not_null': 'Device code cannot be empty'
'device_is_not_null': 'Device code cannot be empty',
'mapping_relationship': 'Mapping relationship'
},
'rules': {
}

View File

@@ -15,7 +15,8 @@ export default {
'inst_nextdevice_code': 'Perangkat tujuan perintah',
'destination_configuration': 'Konfigurasi tujuan',
'operation': 'Operasi',
'device_is_not_null': 'Kode perangkat tidak boleh kosong'
'device_is_not_null': 'Kode perangkat tidak boleh kosong',
'mapping_relationship': 'Hubungan pemetaan'
},
'rules': {
}

View File

@@ -15,7 +15,8 @@ export default {
'inst_nextdevice_code': '指令终点设备',
'destination_configuration': '终点配置',
'operation': '操作',
'device_is_not_null': '设备编码不能为空'
'device_is_not_null': '设备编码不能为空',
'mapping_relationship': '映射关系'
},
'rules': {
}

View File

@@ -134,6 +134,7 @@ import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
import deviceCrud from '@/api/acs/device/device'
import i18n from '@/i18n'
const defaultForm = {
assigned_id: null,
@@ -149,7 +150,7 @@ export default {
mixins: [presenter(), header(), form(defaultForm), crud()],
cruds() {
return CRUD({
title: '映射关系', url: 'api/deviceAssigned', idField: 'assigned_id', sort: 'assignned_id', optShow: {
title: i18n.t('config.table.mapping_relationship'), url: 'api/deviceAssigned', idField: 'assigned_id', sort: 'assignned_id', optShow: {
add: true,
edit: true,
del: true

View File

@@ -134,6 +134,7 @@ import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
import deviceCrud from '@/api/acs/device/device'
import i18n from '@/i18n'
const defaultForm = {
assigned_id: null,
@@ -149,7 +150,7 @@ export default {
mixins: [presenter(), header(), form(defaultForm), crud()],
cruds() {
return CRUD({
title: '映射关系', url: 'api/deviceAssigned', idField: 'assigned_id', sort: 'assignned_id', optShow: {
title: i18n.t('config.table.mapping_relationship'), url: 'api/deviceAssigned', idField: 'assigned_id', sort: 'assignned_id', optShow: {
add: true,
edit: true,
del: true

View File

@@ -58,12 +58,24 @@
<Search />
</div>
<!--如果想在工具栏加入更多按钮可以使用插槽方式 slot = 'left' or 'right'-->
<crudOperation :permission="permission" />
<crudOperation :permission="permission">
<el-button
slot="left"
class="filter-item"
type="warning"
icon="el-icon-download"
size="mini"
:loading="downLoadInstLogging"
@click="doExportInstLogging()"
>
{{ $t('common.Export') }}
</el-button>
</crudOperation>
<!--表单组件-->
<el-dialog
:close-on-click-modal="false"
:before-close="crud.cancelCU"
:visible.sync="crud.status.cu > 0"
:visible.sync="crud.status.cu"
:title="crud.status.title"
width="500px"
>
@@ -129,6 +141,8 @@ import crudInstruction from '@/api/acs/instruction/instruction'
import CRUD, { crud, form, header, presenter } from '@crud/crud'
import crudOperation from '@crud/CRUD.operation'
import { getDicts } from '@/views/system/dict/dict'
import { download } from '@/api/data'
import { downloadFile } from '@/utils'
const defaultForm = {
instruction_id: null,
@@ -241,7 +255,25 @@ export default {
console.log(err.response.data.message)
})
},
doExportInstLogging() {
this.downLoadTaskLogging = true
const params = {
code: this.query.task_code,
vehicle_code: this.query.vehicle_code,
material_type: this.query.material_type,
status: this.query.status,
point_code: this.crud.pointCode,
createTime: this.crud.createTime,
end_time: this.crud.endTime // 假设 this.crud.endTime 是你的结束时间
}
const url = '/api/instruction/downloadInstLogging'
download(url, params).then(result => {
downloadFile(result, this.crud.title + '数据', 'csv')
this.downLoadTaskTreeLogging = false
}).catch(() => {
this.downLoadTaskTreeLogging = false
})
},
beforeHandleCommand(index, row, command) {
return {
'index': index,

View File

@@ -69,7 +69,19 @@
<Search />
</div>
<!--如果想在工具栏加入更多按钮可以使用插槽方式 slot = 'left' or 'right'-->
<crudOperation :permission="permission" />
<crudOperation :permission="permission">
<el-button
slot="left"
class="filter-item"
type="warning"
icon="el-icon-download"
size="mini"
:loading="downLoadTaskLogging"
@click="doExportTaskLogging()"
>
{{ $t('common.Export') }}
</el-button>
</crudOperation>
<!--表单组件-->
<el-dialog
:close-on-click-modal="false"
@@ -263,6 +275,8 @@ import pagination from '@crud/Pagination'
import deviceCrud from '@/api/acs/device/device'
import routeCurd from '@/api/acs/route/routePlan'
import { getDicts } from '@/views/system/dict/dict'
import { download } from '@/api/data'
import { downloadFile } from '@/utils'
const defaultForm = {
task_id: null,
@@ -427,7 +441,25 @@ export default {
console.log(err.response.data.message)
})
},
doExportTaskLogging() {
this.downLoadTaskLogging = true
const params = {
task_code: this.query.task_code,
vehicle_code: this.query.vehicle_code,
material_type: this.query.material_type,
status: this.query.status,
point_code: this.crud.pointCode,
createTime: this.crud.createTime,
end_time: this.crud.endTime // 假设 this.crud.endTime 是你的结束时间
}
const url = 'api/task/downloadTaskLogging'
download(url, params).then(result => {
downloadFile(result, this.crud.title + '数据', 'csv')
this.downLoadTaskTreeLogging = false
}).catch(() => {
this.downLoadTaskTreeLogging = false
})
},
beforeHandleCommand(index, row, command) {
return {
'index': index,

View File

@@ -69,7 +69,19 @@
<Search />
</div>
<!--如果想在工具栏加入更多按钮可以使用插槽方式 slot = 'left' or 'right'-->
<crudOperation :permission="permission" />
<crudOperation :permission="permission">
<el-button
slot="left"
class="filter-item"
type="warning"
icon="el-icon-download"
size="mini"
:loading="downLoadTaskTreeLogging"
@click="doExportTaskTreeLogging()"
>
{{ $t('common.Export') }}
</el-button>
</crudOperation>
<!--表格渲染-->
<el-table
ref="table"
@@ -123,6 +135,8 @@ import pagination from '@crud/Pagination'
import deviceCrud from '@/api/acs/device/device'
import routeCurd from '@/api/acs/route/routePlan'
import { getDicts } from '@/views/system/dict/dict'
import { download } from '@/api/data'
import { downloadFile } from '@/utils'
const defaultForm = {
task_id: null,
@@ -141,11 +155,16 @@ export default {
dicts: ['task_status'],
mixins: [presenter(), header(), form(defaultForm), crud()],
cruds() {
return CRUD({ title: '任务', url: 'api/task/getAll', idField: 'task_id', sort: 'task_id,desc', crudMethod: { ...crudTask }, optShow: {
}})
return [
CRUD({ title: '任务', url: 'api/task/getAll', idField: 'task_id', sort: 'task_id,desc', crudMethod: { ...crudTask }, optShow: {
// ...
}})/* ,
CRUD({ title: '设备协议', url: 'api/device/protocol', idField: 'id', sort: 'id,desc', optShow: { download: false }}) */
]
},
data() {
return {
downLoadTaskTreeLogging: false,
deviceList: [],
materialList: [],
statusList: [],
@@ -196,6 +215,25 @@ export default {
resolve(res.content)
})
}, 100)
},
doExportTaskTreeLogging() {
this.downLoadTaskTreeLogging = true
const params = {
task_code: this.query.task_code,
vehicle_code: this.query.vehicle_code,
material_type: this.query.material_type,
status: this.query.is_over,
point_code: this.crud.pointCode,
createTime: this.crud.createTime,
end_time: this.crud.endTime // 假设 this.crud.endTime 是你的结束时间
}
const url = 'api/task/downloadTaskTreeLogging'
download(url, params).then(result => {
downloadFile(result, this.crud.title + '数据', 'csv')
this.downLoadTaskTreeLogging = false
}).catch(() => {
this.downLoadTaskTreeLogging = false
})
}
}
}