add:增加agv运行时间管理功能
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package org.nl.acs.instruction.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author ldjun
|
||||
* @description /
|
||||
* @date 2021-04-01
|
||||
**/
|
||||
@Data
|
||||
public class InstructionDto2 implements Serializable {
|
||||
|
||||
/**
|
||||
* 车号
|
||||
*/
|
||||
private String carno;
|
||||
|
||||
/**
|
||||
* 秒数
|
||||
*/
|
||||
private BigDecimal last_day_second;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package org.nl.quartz.task;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.instruction.service.dto.InstructionDto2;
|
||||
import org.nl.system.service.acsagv.dao.AcsAgv;
|
||||
import org.nl.system.service.acsagv.dao.mapper.AcsAgvMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 自动统计agv运行时间
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class AutoAgvRunTime {
|
||||
|
||||
@Autowired
|
||||
private AcsAgvMapper acsAgvMapper;
|
||||
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void run() {
|
||||
//查询上次更新时间
|
||||
List<AcsAgv> dictList = acsAgvMapper.selectList(new LambdaQueryWrapper<AcsAgv>());
|
||||
|
||||
AcsAgv anyOne = dictList.get(0);
|
||||
//最后一次统计时间
|
||||
String lastDay = anyOne.getDeadline();
|
||||
|
||||
lastDay = lastDay +" 00:00:00";
|
||||
//当前时间
|
||||
String nowday = DateUtil.now();
|
||||
|
||||
nowday = nowday.substring(0,10);
|
||||
//统计lastday至Nowday直接运行的秒数
|
||||
List<InstructionDto2> list = acsAgvMapper.getListByStrs(nowday+" 00:00:00",lastDay);
|
||||
if(list.size()>0){
|
||||
Map<String,InstructionDto2> map = new HashMap<String,InstructionDto2>();
|
||||
for(int i=0;i<list.size();i++){
|
||||
if(list.get(i).getCarno() == null)
|
||||
map.put("未上报车号",list.get(i));
|
||||
else
|
||||
map.put(list.get(i).getCarno(),list.get(i));
|
||||
}
|
||||
for(int j =0;j<dictList.size();j++){
|
||||
AcsAgv agv = dictList.get(j);
|
||||
String carno = agv.getAgv_no();
|
||||
|
||||
//总运行秒数
|
||||
BigDecimal run_second = agv.getRun_second();
|
||||
if(map.containsKey(carno)){
|
||||
InstructionDto2 instdto = map.get(carno);
|
||||
//本次汇总秒数
|
||||
BigDecimal last_day_second = instdto.getLast_day_second();
|
||||
//累加描述
|
||||
run_second = run_second.add(last_day_second);
|
||||
//更新
|
||||
agv.setDeadline(nowday);
|
||||
agv.setUpdate_time(DateUtil.now());
|
||||
agv.setRun_second(run_second);
|
||||
agv.setLast_day_second(last_day_second);
|
||||
acsAgvMapper.updateById(agv);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiOperation;
|
||||
import org.nl.common.base.TableDataInfo;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
import org.nl.system.service.acsagv.IAcsAgvService;
|
||||
import org.nl.system.service.dict.ISysDictService;
|
||||
import org.nl.system.service.dict.dao.Dict;
|
||||
import org.nl.system.service.dict.dto.DictQuery;
|
||||
@@ -34,6 +35,9 @@ public class SysDictController {
|
||||
@Autowired
|
||||
private ISysDictService dictService;
|
||||
|
||||
@Autowired
|
||||
private IAcsAgvService acsAgvService;
|
||||
|
||||
@Log("查询字典")
|
||||
@GetMapping
|
||||
@ApiOperation("查询字典")
|
||||
@@ -109,6 +113,13 @@ public class SysDictController {
|
||||
return new ResponseEntity<>(dictService.getDictByName(name), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/showDetail3")
|
||||
@Log("查询agv运行时间")
|
||||
@ApiOperation("查询agv运行时间")
|
||||
public ResponseEntity<Object> showDetail3(@RequestParam String name){
|
||||
return new ResponseEntity<>(acsAgvService.getALLagv(name), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("新增字典详情")
|
||||
@ApiOperation("新增字典详情")
|
||||
@PostMapping("/dictDetail")
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package org.nl.system.service.acsagv;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.system.service.acsagv.dao.AcsAgv;
|
||||
import org.nl.system.service.dict.dao.Dict;
|
||||
import org.nl.system.service.dict.dto.DictQuery;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 字典表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2022-12-14
|
||||
*/
|
||||
public interface IAcsAgvService extends IService<AcsAgv> {
|
||||
|
||||
/**
|
||||
* 修改字典数据
|
||||
* @param name
|
||||
*/
|
||||
List<AcsAgv> getALLagv(String name);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package org.nl.system.service.acsagv.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 字典表
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2022-12-14
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("acs_agv")
|
||||
public class AcsAgv implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 字典标识
|
||||
*/
|
||||
@TableId(value = "agv_id")
|
||||
private String agv_id;
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
private String agv_no;
|
||||
|
||||
/**
|
||||
* 排序号
|
||||
*/
|
||||
private BigDecimal run_second;
|
||||
|
||||
/**
|
||||
* 排序号
|
||||
*/
|
||||
private BigDecimal last_day_second;
|
||||
|
||||
/**
|
||||
* 截至日期
|
||||
*/
|
||||
private String deadline;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private String update_time;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.nl.system.service.acsagv.dao.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.nl.acs.instruction.service.dto.InstructionDto2;
|
||||
import org.nl.system.service.acsagv.dao.AcsAgv;
|
||||
import org.nl.system.service.dict.dao.Dict;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 字典表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2022-12-14
|
||||
*/
|
||||
public interface AcsAgvMapper extends BaseMapper<AcsAgv> {
|
||||
|
||||
/**
|
||||
* 获取系统菜单
|
||||
* @param nowday
|
||||
* @param lastday
|
||||
* @return
|
||||
*/
|
||||
List<InstructionDto2> getListByStrs(@Param("nowday") String nowday, @Param("lastday") String lastday);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?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.system.service.acsagv.dao.mapper.AcsAgvMapper">
|
||||
|
||||
<select id="getListByStrs" resultType="org.nl.acs.instruction.service.dto.InstructionDto2">
|
||||
SELECT
|
||||
inst2.carno,
|
||||
sum( inst2.last_day_second ) AS last_day_second
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
TIMESTAMPDIFF( SECOND, inst.create_time, inst.update_time ) AS last_day_second,
|
||||
inst.carno,
|
||||
inst.create_time,
|
||||
inst.update_time
|
||||
FROM
|
||||
acs_instruction inst
|
||||
WHERE
|
||||
1 = 1
|
||||
AND inst.update_time <![CDATA[ <= ]]> #{nowday} AND inst.update_time <![CDATA[ >= ]]> #{lastday}
|
||||
) inst2
|
||||
GROUP BY
|
||||
inst2.carno
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,58 @@
|
||||
package org.nl.system.service.acsagv.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.nl.system.service.acsagv.IAcsAgvService;
|
||||
import org.nl.system.service.acsagv.dao.AcsAgv;
|
||||
import org.nl.system.service.acsagv.dao.mapper.AcsAgvMapper;
|
||||
import org.nl.system.service.dict.dao.Dict;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 字典表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author generator
|
||||
* @since 2022-12-14
|
||||
*/
|
||||
@Service
|
||||
public class AcsAgvServiceImpl extends ServiceImpl<AcsAgvMapper, AcsAgv> implements IAcsAgvService {
|
||||
@Autowired
|
||||
private AcsAgvMapper acsAgvMapper;
|
||||
|
||||
public void updateDict(Dict dto) {
|
||||
/* Dict dict = sysDictMapper.selectById(dto.getDict_id());
|
||||
if (ObjectUtil.isEmpty(dict)) {
|
||||
throw new BadRequestException("字典不存在");
|
||||
}
|
||||
List<Dict> dictList = sysDictMapper.selectList(new LambdaQueryWrapper<Dict>().eq(Dict::getCode, dto.getCode()));
|
||||
if (ObjectUtil.isNotEmpty(dictList) && !dto.getCode().equals(dict.getCode()))
|
||||
throw new BadRequestException("字典[" + dto.getCode() + "]已存在");
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String currentNickName = SecurityUtils.getCurrentNickName();
|
||||
// 根据code获取所有字典
|
||||
List<Dict> dicts = sysDictMapper.selectList(new LambdaQueryWrapper<Dict>().eq(Dict::getCode, dict.getCode()));
|
||||
dicts.forEach(di -> {
|
||||
di.setCode(dto.getCode());
|
||||
di.setName(dto.getName());
|
||||
di.setUpdate_id(currentUserId);
|
||||
di.setUpdate_name(currentNickName);
|
||||
di.setUpdate_time(DateUtil.now());
|
||||
sysDictMapper.updateById(di);
|
||||
});*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AcsAgv> getALLagv(String name) {
|
||||
List<AcsAgv> dictList = acsAgvMapper.selectList(
|
||||
new LambdaQueryWrapper<AcsAgv>().ne(AcsAgv::getAgv_no,"未上报车号")
|
||||
);
|
||||
return dictList;
|
||||
}
|
||||
|
||||
}
|
||||
88
acs/nladmin-ui/src/views/system/param/agvDialog.vue
Normal file
88
acs/nladmin-ui/src/views/system/param/agvDialog.vue
Normal file
@@ -0,0 +1,88 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
append-to-body
|
||||
v-loading.fullscreen.lock="fullscreenLoading"
|
||||
title="agv运行管理"
|
||||
:visible.sync="dialogVisible"
|
||||
destroy-on-close
|
||||
width="1200px"
|
||||
@close="close"
|
||||
@open="open"
|
||||
>
|
||||
<div class="grid-container">
|
||||
<el-table
|
||||
ref="table2"
|
||||
:data="tableDtl"
|
||||
style="width: 100%;"
|
||||
size="mini"
|
||||
border
|
||||
:highlight-current-row="true"
|
||||
:header-cell-style="{background:'#f5f7fa',color:'#606266'}"
|
||||
>
|
||||
<el-table-column v-if="false" prop="agv_id" label="uuid" align="center" />
|
||||
<el-table-column min-width="60" prop="agv_no" label="车辆编号" align="center" />
|
||||
<el-table-column min-width="60" prop="run_second" label="车辆运行总秒数(s)" align="center" />
|
||||
<el-table-column min-width="60" prop="run_hour" label="车辆运行总时长(h)" align="center" :formatter="Myduration" />
|
||||
<el-table-column min-width="50" prop="deadline" label="统计截至日期" align="center" />
|
||||
<el-table-column min-width="60" prop="last_day_second" label="上一次累加运行秒数(s)" align="center" />
|
||||
<el-table-column min-width="60" prop="update_time" label="更新时间" align="center" />
|
||||
</el-table>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import crudParam from '@/views/system/param/param'
|
||||
import { crud } from '@crud/crud'
|
||||
|
||||
export default {
|
||||
name: 'AgvDialog',
|
||||
components: { },
|
||||
mixins: [crud()],
|
||||
props: {
|
||||
dialogShow: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: false,
|
||||
fullscreenLoading: false,
|
||||
tableDtl: []
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
dialogShow: {
|
||||
handler(newValue) {
|
||||
this.dialogVisible = newValue
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
open() {
|
||||
this.queryTableDtl()
|
||||
},
|
||||
close() {
|
||||
this.$emit('update:dialogShow', false)
|
||||
this.tableDtl = []
|
||||
this.$emit('AddChanged')
|
||||
},
|
||||
Myduration(row, column) {
|
||||
let diffDays = 0
|
||||
if (row.run_second && row.run_second !== null) {
|
||||
diffDays = Math.floor(row.run_second / (60 * 60)) // 转换为H
|
||||
}
|
||||
return diffDays
|
||||
},
|
||||
queryTableDtl() {
|
||||
crudParam.showDetail3({ 'name': 'station' }).then(res => {
|
||||
this.tableDtl = res
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
</style>
|
||||
@@ -24,6 +24,16 @@
|
||||
>
|
||||
充电桩管理
|
||||
</el-button>
|
||||
<el-button
|
||||
slot="right"
|
||||
class="filter-item"
|
||||
type="info"
|
||||
icon="el-icon-position"
|
||||
size="mini"
|
||||
@click="divOpenAgv"
|
||||
>
|
||||
agv运行时间管理
|
||||
</el-button>
|
||||
</crudOperation>
|
||||
<!--表单组件-->
|
||||
<el-dialog
|
||||
@@ -82,6 +92,7 @@
|
||||
</div>
|
||||
<tube-dialog2 :dialog-show.sync="showView2" @AddChanged="querytable" />
|
||||
<station-dialog :dialog-show.sync="showStation" @AddChanged="querytable" />
|
||||
<agv-dialog :dialog-show.sync="showAgv" @AddChanged="querytable" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -93,6 +104,7 @@ import udOperation from '@crud/UD.operation'
|
||||
import pagination from '@crud/Pagination'
|
||||
import TubeDialog2 from '@/views/system/param/tubeDialog2.vue'
|
||||
import StationDialog from '@/views/system/param/stationDialog.vue'
|
||||
import AgvDialog from '@/views/system/param/agvDialog.vue'
|
||||
|
||||
const defaultForm = {
|
||||
id: null,
|
||||
@@ -104,7 +116,7 @@ const defaultForm = {
|
||||
}
|
||||
export default {
|
||||
name: 'Param',
|
||||
components: { pagination, crudOperation, udOperation, TubeDialog2, StationDialog },
|
||||
components: { pagination, crudOperation, udOperation, TubeDialog2, StationDialog, AgvDialog },
|
||||
mixins: [presenter(), header(), form(defaultForm), crud()],
|
||||
cruds() {
|
||||
return CRUD({ title: '系统参数', url: 'api/param', idField: 'id', sort: 'id,desc', crudMethod: { ...crudParam },
|
||||
@@ -126,6 +138,7 @@ export default {
|
||||
},
|
||||
showView2: false,
|
||||
showStation: false,
|
||||
showAgv: false,
|
||||
rules: {
|
||||
id: [
|
||||
{ required: true, message: '不能为空', trigger: 'blur' }
|
||||
@@ -160,6 +173,9 @@ export default {
|
||||
},
|
||||
divOpenStation() {
|
||||
this.showStation = true
|
||||
},
|
||||
divOpenAgv() {
|
||||
this.showAgv = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,14 @@ export function showDetail2(params) {
|
||||
})
|
||||
}
|
||||
|
||||
export function showDetail3(params) {
|
||||
return request({
|
||||
url: 'api/dict/showDetail3',
|
||||
method: 'get',
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
export function initDict(data) {
|
||||
return request({
|
||||
url: 'api/dict/initDict',
|
||||
@@ -62,4 +70,4 @@ export function initDict(data) {
|
||||
})
|
||||
}
|
||||
|
||||
export default { add, edit, del, getValueByCode, queryParam, setParam, showDetail2, initDict }
|
||||
export default { add, edit, del, getValueByCode, queryParam, setParam, showDetail2, initDict, showDetail3 }
|
||||
|
||||
Reference in New Issue
Block a user