| | |
| | | <noscript> |
| | | <strong>We're sorry but æºæ
§ååºå®æ¶ä¸ä½åç³»ç» doesn't work properly without JavaScript enabled. Please enable it to continue.</strong> |
| | | <div id="app"></div> |
| | | <!-- built files will be auto injected --> |
| | | </body> |
| | | </html> |
| | |
| | | } |
| | | // pcå·¥ä½å° |
| | | export function getWorkbenchData (data) { |
| | | return request.get('/visitsAdmin/cloudService/business/staging/pCWorkPlatformData', { |
| | | params: {...data } |
| | | }) |
| | | return request.get('/visitsAdmin/cloudService/business/staging/pCWorkPlatformData', data) |
| | | } |
| | |
| | | Vue.use(directives) |
| | | Vue.use(filters) |
| | | Vue.use(plugins) |
| | | |
| | | new Vue({ |
| | | data: { |
| | | loading: false |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import * as echarts from 'echarts' |
| | | import { getInParkUserData, getRataList, getReportList, reportExportExcel } from '@/api/business' |
| | | export default { |
| | | data() { |
| | | return { |
| | | info: null, |
| | | isGroupBy: 0, |
| | | radio: 'month', |
| | | value: '', |
| | | dateType: 'month', |
| | | date: '', |
| | | date1: '', |
| | | import * as echarts from 'echarts' |
| | | import { getInParkUserData, getRataList, getReportList, reportExportExcel } from '@/api/business' |
| | | export default { |
| | | data () { |
| | | return { |
| | | info: null, |
| | | isGroupBy: 0, |
| | | radio: 'month', |
| | | value: '', |
| | | dateType: 'month', |
| | | date: '', |
| | | date1: '', |
| | | |
| | | listZB: [], |
| | | column: [], |
| | | list: [] |
| | | } |
| | | }, |
| | | mounted() { |
| | | var now = new Date(); |
| | | var year = now.getFullYear(); |
| | | var month = now.getMonth() + 1 > 9 ? now.getMonth() + 1 : `0${now.getMonth() + 1}`; |
| | | this.value = `${year}-${month}` |
| | | this.date1 = `${year}-${month}` |
| | | listZB: [], |
| | | column: [], |
| | | list: [] |
| | | } |
| | | }, |
| | | mounted () { |
| | | var now = new Date() |
| | | var year = now.getFullYear() |
| | | var month = now.getMonth() + 1 > 9 ? now.getMonth() + 1 : `0${now.getMonth() + 1}` |
| | | this.value = `${year}-${month}` |
| | | this.date1 = `${year}-${month}` |
| | | |
| | | this.getData() |
| | | this.getRataLists() |
| | | this.getReportLists() |
| | | }, |
| | | methods: { |
| | | // å¯¼åº |
| | | daochu () { |
| | | reportExportExcel({ dateStr: this.date1, isGroupBy: this.isGroupBy, type: 1 }).then(res => { |
| | | this.download(res) |
| | | }) |
| | | }, |
| | | methods: { |
| | | // å¯¼åº |
| | | daochu() { |
| | | reportExportExcel({ dateStr: this.date1, isGroupBy: this.isGroupBy, type: 1 }).then(res => { |
| | | this.download(res) |
| | | changeBB () { |
| | | if (this.radio === 'month') { |
| | | const now = new Date() |
| | | const year = now.getFullYear() |
| | | const month = now.getMonth() + 1 > 9 ? now.getMonth() + 1 : `0${now.getMonth() + 1}` |
| | | this.date1 = `${year}-${month}` |
| | | } else { |
| | | const now = new Date() |
| | | const year = now.getFullYear() |
| | | this.date1 = `${year}` |
| | | } |
| | | this.getReportLists() |
| | | }, |
| | | // å
¥å车è¾ç»è®¡è¡¨ |
| | | getReportLists () { |
| | | getReportList({ dateStr: this.date1, isGroupBy: this.isGroupBy, type: 1 }) |
| | | .then(res => { |
| | | if (!res || res.length === 0) { |
| | | this.column = [] |
| | | this.list = [] |
| | | return |
| | | } |
| | | this.column = res[0] |
| | | this.list = res.slice(1).map(row => { |
| | | const obj = {} |
| | | this.column.forEach((header, index) => { |
| | | obj[header] = row[index] |
| | | }) |
| | | return obj |
| | | }) |
| | | // if (res.length === 0) { |
| | | // this.column = [] |
| | | // this.list = [] |
| | | // return |
| | | // } |
| | | // |
| | | // this.column = res[0] |
| | | // this.list = res.slice(1, res.length); |
| | | }) |
| | | }, |
| | | changeBB() { |
| | | if (this.radio === 'month') { |
| | | let now = new Date(); |
| | | let year = now.getFullYear(); |
| | | let month = now.getMonth() + 1 > 9 ? now.getMonth() + 1 : `0${now.getMonth() + 1}`; |
| | | this.date1 = `${year}-${month}` |
| | | } else { |
| | | let now = new Date(); |
| | | let year = now.getFullYear(); |
| | | this.date1 = `${year}` |
| | | } |
| | | this.getReportLists() |
| | | }, |
| | | // å
¥å车è¾ç»è®¡è¡¨ |
| | | getReportLists() { |
| | | getReportList({ dateStr: this.date1, isGroupBy: this.isGroupBy, type: 1 }) |
| | | .then(res => { |
| | | if (!res || res.length === 0) { |
| | | this.column = [] |
| | | this.list = [] |
| | | return |
| | | } |
| | | this.column = res[0] |
| | | this.list = res.slice(1).map(row => { |
| | | const obj = {}; |
| | | this.column.forEach((header, index) => { |
| | | obj[header] = row[index]; |
| | | }); |
| | | return obj; |
| | | }); |
| | | // if (res.length === 0) { |
| | | // this.column = [] |
| | | // this.list = [] |
| | | // return |
| | | // } |
| | | // |
| | | // this.column = res[0] |
| | | // this.list = res.slice(1, res.length); |
| | | }) |
| | | }, |
| | | changeDateType() { |
| | | if (this.dateType === 'month') { |
| | | let now = new Date(); |
| | | let year = now.getFullYear(); |
| | | let month = now.getMonth() + 1 > 9 ? now.getMonth() + 1 : `0${now.getMonth() + 1}`; |
| | | this.value = `${year}-${month}` |
| | | } else { |
| | | let now = new Date(); |
| | | let year = now.getFullYear(); |
| | | this.value = `${year}` |
| | | } |
| | | this.getRataLists() |
| | | }, |
| | | // 车è¾åç±»ç»è®¡ |
| | | getRataLists() { |
| | | getRataList({ dateStr: this.value, isGroupBy: this.isGroupBy, type: 1 }) |
| | | .then(res => { |
| | | this.listZB = res |
| | | // this.$nextTick(() => { |
| | | // this.initDept() |
| | | // }) |
| | | setTimeout(() => { |
| | | this.initDept() |
| | | }, 1000) |
| | | }) |
| | | }, |
| | | // åºç¡æ°æ® |
| | | getData() { |
| | | getInParkUserData({ isGroupBy: this.isGroupBy, type: 1 }).then(res => { |
| | | this.info = res |
| | | }, |
| | | changeDateType () { |
| | | if (this.dateType === 'month') { |
| | | const now = new Date() |
| | | const year = now.getFullYear() |
| | | const month = now.getMonth() + 1 > 9 ? now.getMonth() + 1 : `0${now.getMonth() + 1}` |
| | | this.value = `${year}-${month}` |
| | | } else { |
| | | const now = new Date() |
| | | const year = now.getFullYear() |
| | | this.value = `${year}` |
| | | } |
| | | this.getRataLists() |
| | | }, |
| | | // 车è¾åç±»ç»è®¡ |
| | | getRataLists () { |
| | | getRataList({ dateStr: this.value, isGroupBy: this.isGroupBy, type: 1 }) |
| | | .then(res => { |
| | | this.listZB = res |
| | | // this.$nextTick(() => { |
| | | // this.initType() |
| | | // this.initDept() |
| | | // }) |
| | | setTimeout(() => { |
| | | this.initType() |
| | | this.initDept() |
| | | }, 1000) |
| | | }) |
| | | }, |
| | | // å
¨å¹´å
¥å车è¾è¶å¿ |
| | | initType() { |
| | | if (!this.info.cumulativeDataList) return |
| | | }, |
| | | // åºç¡æ°æ® |
| | | getData () { |
| | | getInParkUserData({ isGroupBy: this.isGroupBy, type: 1 }).then(res => { |
| | | this.info = res |
| | | // this.$nextTick(() => { |
| | | // this.initType() |
| | | // }) |
| | | setTimeout(() => { |
| | | this.initType() |
| | | }, 1000) |
| | | }) |
| | | }, |
| | | // å
¨å¹´å
¥å车è¾è¶å¿ |
| | | initType () { |
| | | if (!this.info.cumulativeDataList) return |
| | | |
| | | const myChart = echarts.init(document.querySelector('.echart1')) |
| | | const myChart = echarts.init(document.querySelector('.echart1')) |
| | | |
| | | let names = this.info.cumulativeDataList.map(item => item.name) |
| | | let datas = this.info.cumulativeDataList.map(item => item.total) |
| | | const names = this.info.cumulativeDataList.map(item => item.name) |
| | | const datas = this.info.cumulativeDataList.map(item => item.total) |
| | | |
| | | let option = { |
| | | grid: { |
| | | left: '0%', |
| | | right: '5%', |
| | | bottom: '10%', |
| | | top: '10%', |
| | | containLabel: true |
| | | const option = { |
| | | grid: { |
| | | left: '0%', |
| | | right: '5%', |
| | | bottom: '10%', |
| | | top: '10%', |
| | | containLabel: true |
| | | }, |
| | | tooltip: { |
| | | trigger: 'axis', |
| | | axisPointer: { |
| | | type: 'line' |
| | | } |
| | | }, |
| | | xAxis: { |
| | | type: 'category', |
| | | data: names |
| | | }, |
| | | yAxis: { |
| | | type: 'value', |
| | | axisLine: { |
| | | show: true |
| | | }, |
| | | tooltip: { |
| | | trigger: 'axis', |
| | | axisPointer: { |
| | | type: 'line' |
| | | axisLabel: { |
| | | formatter: function (value) { |
| | | // åèäºå
¥å°æè¿çæ´æ° |
| | | return Math.round(value) |
| | | } |
| | | }, |
| | | xAxis: { |
| | | type: 'category', |
| | | data: names |
| | | }, |
| | | yAxis: { |
| | | type: 'value', |
| | | axisLine: { |
| | | show: true |
| | | }, |
| | | axisLabel: { |
| | | formatter: function (value) { |
| | | // åèäºå
¥å°æè¿çæ´æ° |
| | | return Math.round(value); |
| | | } |
| | | }, |
| | | graphic: { |
| | | elements: [ |
| | | { |
| | | type: 'text', |
| | | left: 'left', |
| | | top: 'top', |
| | | style: { |
| | | text: 'äººåæ°', |
| | | textAlign: 'center', |
| | | fill: '#333' |
| | | } |
| | | } |
| | | }, |
| | | graphic: { |
| | | elements: [ |
| | | { |
| | | type: 'text', |
| | | left: 'left', |
| | | top: 'top', |
| | | style: { |
| | | text: 'äººåæ°', |
| | | textAlign: 'center', |
| | | fill: '#333' |
| | | } |
| | | } |
| | | ] |
| | | }, |
| | | series: [ |
| | | { |
| | | data: datas, |
| | | type: 'line', |
| | | areaStyle: { |
| | | normal: { |
| | | color: { |
| | | x: 0, |
| | | y: 0, |
| | | x2: 0, |
| | | y2: 1, |
| | | colorStops: [{ |
| | | offset: 0, |
| | | color: '#207FF7' // 0% å¤çé¢è² |
| | | }, { |
| | | offset: 1, |
| | | color: 'rgba(255,255,255,.2)' // 100% å¤çé¢è² |
| | | }], |
| | | globalCoord: false // 缺ç为 false |
| | | } |
| | | } |
| | | }, |
| | | lineStyle: { // çº¿æ¡æ ·å¼ |
| | | ] |
| | | }, |
| | | series: [ |
| | | { |
| | | data: datas, |
| | | type: 'line', |
| | | areaStyle: { |
| | | normal: { |
| | | color: { |
| | | type: 'linear', |
| | | x: 0, |
| | | y: 0, |
| | | x2: 0, |
| | | y2: 1, |
| | | colorStops: [{ |
| | | offset: 0, color: '#207FF7' // 0% å¤çé¢è² |
| | | offset: 0, |
| | | color: '#207FF7' // 0% å¤çé¢è² |
| | | }, { |
| | | offset: 1, color: '#207FF7' // 100% å¤çé¢è² |
| | | }] |
| | | }, |
| | | width: 2 // 线æ¡ç²ç» |
| | | offset: 1, |
| | | color: 'rgba(255,255,255,.2)' // 100% å¤çé¢è² |
| | | }], |
| | | globalCoord: false // 缺ç为 false |
| | | } |
| | | } |
| | | }, |
| | | lineStyle: { // çº¿æ¡æ ·å¼ |
| | | color: { |
| | | type: 'linear', |
| | | x: 0, |
| | | y: 0, |
| | | x2: 0, |
| | | y2: 1, |
| | | colorStops: [{ |
| | | offset: 0, color: '#207FF7' // 0% å¤çé¢è² |
| | | }, { |
| | | offset: 1, color: '#207FF7' // 100% å¤çé¢è² |
| | | }] |
| | | }, |
| | | symbol: 'circle', |
| | | symbolSize: 10, |
| | | itemStyle: { |
| | | borderWidth: 1, |
| | | borderColor: '#fff', |
| | | color: '#207FF7' |
| | | }, |
| | | smooth: false |
| | | } |
| | | ] |
| | | } |
| | | myChart.setOption(option) |
| | | window.addEventListener('resize', function () { // æ§è¡ |
| | | myChart.resize() |
| | | }) |
| | | }, |
| | | // 车è¾åç±»ç»è®¡ |
| | | initDept() { |
| | | if (!this.listZB) return |
| | | |
| | | const dom = document.getElementById('echart2') |
| | | console.log(dom) |
| | | const myChart = echarts.init(dom) |
| | | |
| | | let data = this.listZB.map(item => { |
| | | return { |
| | | value: item.total, |
| | | name: item.name |
| | | width: 2 // 线æ¡ç²ç» |
| | | }, |
| | | symbol: 'circle', |
| | | symbolSize: 10, |
| | | itemStyle: { |
| | | borderWidth: 1, |
| | | borderColor: '#fff', |
| | | color: '#207FF7' |
| | | }, |
| | | smooth: false |
| | | } |
| | | }) |
| | | ] |
| | | } |
| | | myChart.setOption(option) |
| | | window.addEventListener('resize', function () { // æ§è¡ |
| | | myChart.resize() |
| | | }) |
| | | }, |
| | | // 车è¾åç±»ç»è®¡ |
| | | initDept () { |
| | | if (!this.listZB) return |
| | | |
| | | let option = { |
| | | tooltip: { |
| | | trigger: 'item', |
| | | }, |
| | | legend: { |
| | | show: false, |
| | | orient: 'vertical', |
| | | left: 'left' |
| | | }, |
| | | series : [ |
| | | { |
| | | name: 'è®¿é®æ¥æº', |
| | | type: 'pie', |
| | | radius: ['34%', '50%'], |
| | | labelLine: { |
| | | normal: { |
| | | length: 30, |
| | | length2: 70, |
| | | const dom = document.getElementById('echart2') |
| | | console.log(dom) |
| | | const myChart = echarts.init(dom) |
| | | |
| | | const data = this.listZB.map(item => { |
| | | return { |
| | | value: item.total, |
| | | name: item.name |
| | | } |
| | | }) |
| | | |
| | | const option = { |
| | | tooltip: { |
| | | trigger: 'item' |
| | | }, |
| | | legend: { |
| | | show: false, |
| | | orient: 'vertical', |
| | | left: 'left' |
| | | }, |
| | | series: [ |
| | | { |
| | | name: 'è®¿é®æ¥æº', |
| | | type: 'pie', |
| | | radius: ['34%', '50%'], |
| | | labelLine: { |
| | | normal: { |
| | | length: 30, |
| | | length2: 70 |
| | | } |
| | | }, |
| | | label: { |
| | | formatter: '{a|{b}} {d}%', |
| | | rich: { |
| | | a: { |
| | | color: '#333333', |
| | | fontSize: 14, |
| | | fontWeight: 500 |
| | | } |
| | | }, |
| | | label: { |
| | | formatter: "{a|{b}} {d}%", |
| | | rich: { |
| | | a: { |
| | | color: '#333333', |
| | | fontSize: 14, |
| | | fontWeight: 500 |
| | | } |
| | | }, |
| | | padding: [0,-50,20,-100] |
| | | }, |
| | | data: data |
| | | } |
| | | ] |
| | | } |
| | | myChart.setOption(option) |
| | | window.addEventListener('resize', function () { // æ§è¡ |
| | | myChart.resize() |
| | | }) |
| | | }, |
| | | initDept3() { |
| | | const myChart = echarts.init(document.querySelector('#echart3')) |
| | | |
| | | let option = { |
| | | grid: { |
| | | left: '5%', |
| | | right: '10%', |
| | | bottom: '0%', |
| | | top: '20%', |
| | | containLabel: true |
| | | }, |
| | | xAxis: { |
| | | type: 'category', |
| | | data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] |
| | | }, |
| | | yAxis: { |
| | | type: 'value' |
| | | }, |
| | | series: [ |
| | | { |
| | | data: [150, 230, 224, 218, 135, 147, 260], |
| | | type: 'line' |
| | | } |
| | | ] |
| | | } |
| | | myChart.setOption(option) |
| | | window.addEventListener('resize', function () { // æ§è¡ |
| | | myChart.resize() |
| | | }) |
| | | padding: [0, -50, 20, -100] |
| | | }, |
| | | data: data |
| | | } |
| | | ] |
| | | } |
| | | myChart.setOption(option) |
| | | window.addEventListener('resize', function () { // æ§è¡ |
| | | myChart.resize() |
| | | }) |
| | | }, |
| | | initDept3 () { |
| | | const myChart = echarts.init(document.querySelector('#echart3')) |
| | | |
| | | const option = { |
| | | grid: { |
| | | left: '5%', |
| | | right: '10%', |
| | | bottom: '0%', |
| | | top: '20%', |
| | | containLabel: true |
| | | }, |
| | | xAxis: { |
| | | type: 'category', |
| | | data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] |
| | | }, |
| | | yAxis: { |
| | | type: 'value' |
| | | }, |
| | | series: [ |
| | | { |
| | | data: [150, 230, 224, 218, 135, 147, 260], |
| | | type: 'line' |
| | | } |
| | | ] |
| | | } |
| | | myChart.setOption(option) |
| | | window.addEventListener('resize', function () { // æ§è¡ |
| | | myChart.resize() |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | |
| | | |
| | | .main_table { |
| | | display: flex; |
| | | align-items: start; |
| | | align-items: flex-start; |
| | | justify-content: space-between; |
| | | margin-top: 10px; |
| | | .main_table_list { |
| | |
| | | padding: 20px; |
| | | box-sizing: border-box; |
| | | /*border-right: 12px solid #f7f7f7;*/ |
| | | |
| | | |
| | | .echart1 { |
| | | width: 100%; |
| | |
| | | |
| | | .main_table { |
| | | display: flex; |
| | | align-items: start; |
| | | align-items: flex-start; |
| | | justify-content: space-between; |
| | | margin-top: 10px; |
| | | .main_table_list { |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import QueryForm from '@/components/common/QueryForm' |
| | | // import QueryForm from '@/components/common/QueryForm' |
| | | import * as echarts from 'echarts' |
| | | import { hiddenDangerDataPost } from '@/api/business/hiddenDanger' |
| | | import dayjs from 'dayjs' |
| | | export default { |
| | | components: { |
| | | QueryForm, |
| | | // QueryForm, |
| | | }, |
| | | data() { |
| | | data () { |
| | | return { |
| | | filters: { |
| | | fastdate: '29', |
| | |
| | | options: [ |
| | | { label: 'å¾
å¤ç', value: '0' }, |
| | | { label: 'å·²å¤ç', value: '1' }, |
| | | { label: 'å·²éå', value: '2' }, |
| | | { label: 'å·²éå', value: '2' } |
| | | ] |
| | | }, |
| | | { |
| | |
| | | departmentList: [] |
| | | } |
| | | }, |
| | | mounted() { |
| | | mounted () { |
| | | this.changeRadio('29') |
| | | this.initDept3() |
| | | // this.getData() |
| | | }, |
| | | methods: { |
| | | changeRadio(day) { |
| | | changeRadio (day) { |
| | | const arr = [dayjs().subtract(day, 'day').format('YYYY-MM-DD') + ' 00:00:00', dayjs().format('YYYY-MM-DD') + ' 23:59:59'] |
| | | this.filters.queryStartTime = arr[0] |
| | | this.filters.queryEndTime = arr[1] |
| | | this.getData() |
| | | }, |
| | | getData(page) { |
| | | getData (page) { |
| | | hiddenDangerDataPost({ ...this.filters }).then(res => { |
| | | if (res) { |
| | | this.totalList.total = res.total || 0 |
| | |
| | | this.initDept() |
| | | this.initDept3() |
| | | }) |
| | | |
| | | } |
| | | }) |
| | | |
| | | }, |
| | | changeForm(e) { |
| | | changeForm (e) { |
| | | this.getData() |
| | | }, |
| | | initType() { |
| | | initType () { |
| | | const myChart = echarts.init(document.querySelector('.echart1')) |
| | | let total = 0 |
| | | this.typeList.forEach(i => { |
| | | total += i.total |
| | | }) |
| | | let colors = ['#d75a44', '#e39f4d', '#f0d05f', '#7ac7f6', '#4469ee', '#698af0','#86a2f1','#a1b4f6','#a0b5f5', '#9fb5f4', '#b6c7f7', '#c8d5f8'] |
| | | let option = { |
| | | const colors = ['#d75a44', '#e39f4d', '#f0d05f', '#7ac7f6', '#4469ee', '#698af0', '#86a2f1', '#a1b4f6', '#a0b5f5', '#9fb5f4', '#b6c7f7', '#c8d5f8'] |
| | | const option = { |
| | | grid: { |
| | | left: '0%', |
| | | right: '0%', |
| | |
| | | left: '45%', |
| | | textStyle: { |
| | | color: '#666666', |
| | | fontSize: 13, |
| | | }, |
| | | fontSize: 13 |
| | | } |
| | | }, { |
| | | text: total, |
| | | top: '50%', |
| | |
| | | textStyle: { |
| | | color: '#080404', |
| | | fontSize: 16, |
| | | fontWeight: 'bold', |
| | | }, |
| | | fontWeight: 'bold' |
| | | } |
| | | }], |
| | | legend: { |
| | | left: 'center', |
| | |
| | | type: 'pie', |
| | | radius: ['34%', '50%'], |
| | | label: { |
| | | formatter: "{a|{b}}\n\n{c} | {d}%", |
| | | formatter: '{a|{b}}\n\n{c} | {d}%', |
| | | rich: { |
| | | a: { |
| | | color: '#333333', |
| | |
| | | length: 24, |
| | | length2: 64, |
| | | lineStyle: { |
| | | width: 2 // 线æ¡å®½åº¦ |
| | | width: 2 // 线æ¡å®½åº¦ |
| | | } |
| | | }, |
| | | data: this.typeList.map((i, index) => { |
| | |
| | | myChart.resize() |
| | | }) |
| | | }, |
| | | initDept() { |
| | | initDept () { |
| | | const myChart = echarts.init(document.querySelector('.echart2')) |
| | | |
| | | let option = { |
| | | const option = { |
| | | grid: { |
| | | left: '10%', |
| | | right: '10%', |
| | |
| | | name: '鿣æ°', |
| | | minInterval: 1, |
| | | axisLine: { |
| | | show: true, |
| | | show: true |
| | | } |
| | | }, |
| | | series: [ |
| | |
| | | itemStyle: { |
| | | color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ |
| | | { offset: 0, color: '#d75e45' }, // æ¸åèµ·å§è² |
| | | { offset: 1, color: '#db924c' } // æ¸åç»æ¢è² |
| | | { offset: 1, color: '#db924c' } // æ¸åç»æ¢è² |
| | | ]) |
| | | }, |
| | | |
| | | label: { |
| | | show: true, // æ¾ç¤ºæ ç¾ |
| | | show: true, // æ¾ç¤ºæ ç¾ |
| | | position: 'top', // 让æ ç¾æ¾ç¤ºå¨æ±åé¡¶é¨ |
| | | color: '#666666', // æåé¢è² |
| | | fontSize: 14, // æåå¤§å° |
| | | color: '#666666', // æåé¢è² |
| | | fontSize: 14 // æåå¤§å° |
| | | } |
| | | } |
| | | ] |
| | |
| | | myChart.resize() |
| | | }) |
| | | }, |
| | | initDept3() { |
| | | initDept3 () { |
| | | if (this.yearList.length === 0) return |
| | | |
| | | const myChart = echarts.init(document.querySelector('#echart3')) |
| | | |
| | | let names = this.yearList.map(item => item.name) |
| | | let datas = this.yearList.map(item => item.total) |
| | | const names = this.yearList.map(item => item.name) |
| | | const datas = this.yearList.map(item => item.total) |
| | | |
| | | let option = { |
| | | const option = { |
| | | tooltip: { |
| | | trigger: 'axis', |
| | | axisPointer: { |
| | |
| | | axisLabel: { |
| | | formatter: function (value) { |
| | | // åèäºå
¥å°æè¿çæ´æ° |
| | | return Math.round(value); |
| | | return Math.round(value) |
| | | } |
| | | } |
| | | }, |
| | |
| | | myChart.resize() |
| | | }) |
| | | }, |
| | | clear() { |
| | | clear () { |
| | | this.filters = {} |
| | | this.getData() |
| | | } |
| | |
| | | |
| | | .main_table { |
| | | display: flex; |
| | | align-items: start; |
| | | align-items: flex-start; |
| | | justify-content: space-between; |
| | | .main_table_echart { |
| | | width: 64%; |
| | |
| | | |
| | | .main_content { |
| | | display: flex; |
| | | align-items: start; |
| | | align-items: flex-start; |
| | | justify-content: space-between; |
| | | height: 500px; |
| | | margin-bottom: 10px; |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <TableLayout :permissions="['business:device:query']"> |
| | | <!-- æç´¢è¡¨å --> |
| | | <el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="100px" inline> |
| | | <el-form-item title="åç§°" prop="name"> |
| | | <el-input v-model="searchForm.name" placeholder="请è¾å
¥åç§°" @keypress.enter.native="search"></el-input> |
| | | </el-form-item> |
| | | <el-form-item title="æ è¯ç¬¦" prop="no"> |
| | | <el-input v-model="searchForm.no" placeholder="请è¾å
¥è®¾å¤æ è¯ç¬¦" @keypress.enter.native="search"></el-input> |
| | | </el-form-item> |
| | | <el-form-item title="设å¤å·" prop="doorNo"> |
| | | <el-input v-model="searchForm.doorNo" placeholder="请è¾å
¥è®¾å¤å·" @keypress.enter.native="search"></el-input> |
| | | </el-form-item> |
| | | <section> |
| | | <el-button type="primary" @click="search">æç´¢</el-button> |
| | | <el-button @click="reset">éç½®</el-button> |
| | | </section> |
| | | </el-form> |
| | | <!-- è¡¨æ ¼åå页 --> |
| | | <template v-slot:table-wrap> |
| | | <ul class="toolbar" v-permissions="['business:device:create', 'business:device:delete']"> |
| | | <li><el-button type="primary" @click="$refs.operaDeviceWindow.open('æ°å»ºçµè¡¨')" icon="el-icon-plus" v-permissions="['business:device:create']">æ°å»º</el-button></li> |
| | | <li><el-button @click="deleteByIdInBatch" icon="el-icon-delete" v-permissions="['business:device:delete']">å é¤</el-button></li> |
| | | </ul> |
| | | <el-table |
| | | :height="tableHeightNew" |
| | | v-loading="isWorking.search" |
| | | :data="tableData.list" |
| | | stripe > |
| | | <el-table-column type="selection" width="55"></el-table-column> |
| | | <el-table-column prop="name" label="åç§°" fixed min-width="150" align="center"></el-table-column> |
| | | <el-table-column prop="no" label="çµè¡¨å°åå" min-width="100" align="center" ></el-table-column> |
| | | <el-table-column prop="doorNo" label="设å¤å·" min-width="120" align="center" show-overflow-tooltip></el-table-column> |
| | | <el-table-column prop="channelNo" label="å¼å
³åºå·" align="center" min-width="100"></el-table-column> |
| | | <el-table-column prop="manufature" label="åå" align="center" min-width="100" show-overflow-tooltip></el-table-column> |
| | | <el-table-column prop="regionPathName" align="center" min-width="100" label="æå¨ä½ç½®"></el-table-column> |
| | | <el-table-column prop="ip" label="IP" min-width="150" align="center" show-overflow-tooltip ></el-table-column> |
| | | <el-table-column prop="port" label="端å£" align="center" ></el-table-column> |
| | | <el-table-column prop="isUsed" label="æ¯å¦ä½¿ç¨"> |
| | | <template slot-scope="{row}"> |
| | | <el-switch @change="changeUsed($event, row)" v-model="row.isUsed" active-color="#13ce66" |
| | | inactive-color="#ff4949" :active-value="0" :inactive-value="1"> |
| | | </el-switch> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="editDate" label="æè¿æ´æ°æ¶é´" align="center" min-width="150"></el-table-column> |
| | | <el-table-column |
| | | label="æä½" |
| | | align="center" |
| | | min-width="280" |
| | | fixed="right" |
| | | > |
| | | <template slot-scope="{row}"> |
| | | <el-button type="text" @click="$refs.operaDeviceWindow.open('ç¼è¾çµè¡¨', row)" icon="el-icon-edit" v-permissions="['business:device:update']">ç¼è¾</el-button> |
| | | <el-button type="text" @click="$refs.operaDeviceDataWindow.open('æ¥ççµè¡¨æ°æ®', row)" icon="el-icon-view" v-permissions="['business:device:update']">æ°æ®</el-button> |
| | | <el-button type="text" @click="send(row,1)" icon="el-icon-circle-check" v-permissions="['business:device:update']">å¼é¸</el-button> |
| | | <el-button type="text" class="red" @click="send(row,0)" icon="el-icon-circle-close" v-permissions="['business:device:update']">å
³é¸</el-button> |
| | | <el-button type="text" class="red" @click="deleteById(row)" icon="el-icon-delete" v-permissions="['business:device:delete']">å é¤</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <pagination |
| | | @size-change="handleSizeChange" |
| | | @current-change="handlePageChange" |
| | | :pagination="tableData.pagination" > |
| | | </pagination> |
| | | </template> |
| | | <el-dialog |
| | | :visible.sync="visibleSend" |
| | | style="z-index: 100000" |
| | | append-to-body |
| | | width="50%" |
| | | height="50%" |
| | | :title="'æ§å¶çµè¡¨-ã'+ form.name+'ã'" |
| | | > |
| | | <el-form :model="form" ref="form" :rules="rules"> |
| | | <el-form-item label="æ§è¡æä½ï¼" > |
| | | <b class="green" v-if="form.status ===1">å¼é¸</b> |
| | | <b class="red" v-else>å
³é¸</b> |
| | | </el-form-item> |
| | | <el-form-item label="å¼å
³åºå·" prop="channelNo"> |
| | | <el-input v-model="form.channelNo" type="text" placeholder="请è¾å
¥å¼å
³åºå· ï¼å¤ä¸ªç¨è±æéå·éå¼ï¼å¦ 1,2,3" v-trim/> |
| | | </el-form-item> |
| | | <p class="tip-warn" style="width: 100%;"><i class="el-icon-warning"></i>设å¤åå§å¼å
³åºå·ä¿¡æ¯ï¼{{form.channelNo1}}ï¼æ§å¶å¤ä¸ªå¼å
³ï¼è¯·ç¨è±æéå·éå¼ï¼å¦ 1,2;</p> |
| | | </el-form> |
| | | <template v-slot:footer > |
| | | <el-button @click="sendAction()" type="primary" v-if="form.status === 1" :loading="isWorkSending">确认å¼é¸</el-button> |
| | | <el-button @click="sendAction()" type="danger" v-if="form.status !== 1" :loading="isWorkSending">确认å
³é¸</el-button> |
| | | <el-button @click="sendClose()">è¿å</el-button> |
| | | </template> |
| | | </el-dialog> |
| | | <!-- æ°å»º/ä¿®æ¹ --> |
| | | <OperaDeviceDuanluqiWindow ref="operaDeviceWindow" @success="handlePageChange"/> |
| | | <OperaDeviceDataListWindow ref="operaDeviceDataWindow" @success="handlePageChange"/> |
| | | </TableLayout> |
| | | </template> |
| | | <script> |
| | | import BaseTable from '@/components/base/BaseTable' |
| | | import TableLayout from '@/layouts/TableLayout' |
| | | import Pagination from '@/components/common/Pagination' |
| | | import OperaDeviceDataListWindow from '@/components/business/OperaDeviceDataListWindow' |
| | | import OperaDeviceDuanluqiWindow from '@/components/business/OperaDeviceDuanluqiWindow' |
| | | export default { |
| | | name: 'DeviceDuanluqi', |
| | | extends: BaseTable, |
| | | components: { TableLayout, Pagination, OperaDeviceDuanluqiWindow ,OperaDeviceDataListWindow}, |
| | | data () { |
| | | return { |
| | | // æç´¢ |
| | | searchForm: { |
| | | doorNo: '', |
| | | no: '', |
| | | name: '', |
| | | type: 6 |
| | | }, |
| | | isWorkSending: false, |
| | | form: { |
| | | id: '', |
| | | name: '', |
| | | channelNo: '', |
| | | channelNo1: '', |
| | | status: null |
| | | }, |
| | | visibleSend: false, |
| | | options: [], |
| | | rules: { |
| | | channelNo: [{ required: true, message: '请è¾å
¥éè¦æä½çå¼å
³åºå·', trigger: 'blur' }], |
| | | } |
| | | } |
| | | }, |
| | | created () { |
| | | this.config({ |
| | | module: '设å¤ä¿¡æ¯è¡¨', |
| | | api: '/business/device', |
| | | 'field.id': 'id', |
| | | 'field.main': 'id' |
| | | }) |
| | | this.search() |
| | | }, |
| | | methods: { |
| | | changeUsed (e, row) { |
| | | this.api.updateUsedById({ |
| | | id: row.id, |
| | | isUsed: e |
| | | }) |
| | | }, |
| | | showPassward (row) { |
| | | if (!row.showPwd) { |
| | | this.$set(row, 'showPwd', true) |
| | | } else { |
| | | this.$set(row, 'showPwd', false) |
| | | } |
| | | }, |
| | | sendAction () { |
| | | if (!this.form.channelNo) { |
| | | return |
| | | } |
| | | this.$dialog.actionConfirm('确认è¿è¡çµè¡¨ã' + (this.form.status === 1 ? 'å¼é¸' : 'å
³é¸') + 'ãæä½åï¼', 'æä½ç¡®è®¤æé') |
| | | .then(() => { |
| | | this.isWorkSending = true |
| | | this.api.duanluqiCmd(this.form) |
| | | .then(res => { |
| | | this.$tip.apiSuccess(res || 'è¯·æ±æå') |
| | | this.sendClose() |
| | | }) |
| | | .catch(e => { |
| | | }) |
| | | .finally(() => { |
| | | this.isWorkSending = false |
| | | }) |
| | | }) |
| | | .catch(() => {}) |
| | | }, |
| | | send (row, type) { |
| | | this.visibleSend = true |
| | | this.form = { id: row.id, name: row.name, channelNo: row.channelNo, status: type ,channelNo1:row.channelNo} |
| | | }, |
| | | sendClose () { |
| | | this.visibleSend = false |
| | | this.isWorkSending = false |
| | | this.form = { id: '', name: '', channelNo: '', status: '',channelNo1:'' } |
| | | } |
| | | |
| | | } |
| | | } |
| | | </script> |
| | |
| | | |
| | | .main_table { |
| | | display: flex; |
| | | align-items: start; |
| | | align-items: flex-start; |
| | | justify-content: space-between; |
| | | margin-top: 10px; |
| | | .main_table_list { |
| | |
| | | ...mapState(['sysConfig']) |
| | | }, |
| | | mounted () { |
| | | alert(1) |
| | | this.username = localStorage.getItem('username') || '' |
| | | this.password = localStorage.getItem('password') || '' |
| | | this.phone = localStorage.getItem('phone') || '' |
| | |
| | | lintOnSave: false, |
| | | devServer: { |
| | | host: '0.0.0.0', |
| | | port: 10012, |
| | | port: 10085, |
| | | proxy: { |
| | | [process.env.VUE_APP_API_PREFIX]: { |
| | | target: process.env.VUE_APP_API_URL, |
| | |
| | | <version>1.0.0-SNAPSHOT</version> |
| | | <relativePath>../../pom.xml</relativePath> |
| | | </parent> |
| | | |
| | | <artifactId>device_service</artifactId> |
| | | |
| | | <properties> |
| | | <maven.compiler.source>8</maven.compiler.source> |
| | | <maven.compiler.target>8</maven.compiler.target> |
| | | <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
| | | <fastjson.version>1.2.70</fastjson.version> |
| | | </properties> |
| | | |
| | | <dependencies> |
| | |
| | | <groupId>org.projectlombok</groupId> |
| | | <artifactId>lombok</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.alibaba</groupId> |
| | | <artifactId>fastjson</artifactId> |
| | | <version>${fastjson.version}</version> |
| | | </dependency> |
| | | </dependencies> |
| | | </project> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.tcp; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.IOException; |
| | | import java.net.Socket; |
| | | import java.text.DateFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | public class WaterElectricityUtil { |
| | | |
| | | |
| | | private static double parseBcdToDouble(byte[] bcdBytes) { |
| | | StringBuilder sb = new StringBuilder(); |
| | | for (byte b : bcdBytes) { |
| | | sb.append(String.format("%02X", b)); |
| | | } |
| | | try { |
| | | return Double.parseDouble(sb.toString()); |
| | | } catch (NumberFormatException e) { |
| | | return 0.0; |
| | | } |
| | | } |
| | | |
| | | private static byte[] reverseAddress(String address) { |
| | | byte[] result = new byte[6]; |
| | | for (int i = 0; i < 6; i++) { |
| | | if (i * 2 + 1 < address.length()) { |
| | | String hex = address.substring(i * 2, Math.min((i + 1) * 2, address.length())); |
| | | result[i] = (byte) Integer.parseInt(hex, 16); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | private static byte calculateChecksum(byte[] data, int offset, int length) { |
| | | int sum = 0; |
| | | for (int i = offset; i < offset + length; i++) { |
| | | sum += data[i] & 0xFF; |
| | | } |
| | | return (byte) (sum & 0xFF); |
| | | } |
| | | |
| | | private static byte[] hexStringToByteArray(String hex) { |
| | | int len = hex.length(); |
| | | byte[] data = new byte[len / 2]; |
| | | for (int i = 0; i < len; i += 2) { |
| | | data[i / 2] = (byte) ((Character.digit(hex.charAt(i), 16) << 4) + Character.digit(hex.charAt(i + 1), 16)); |
| | | } |
| | | return data; |
| | | } |
| | | |
| | | public static byte calcCS(byte[] data) { |
| | | int sum = 0; |
| | | for (byte b : data) { |
| | | sum += b & 0xFF; |
| | | } |
| | | return (byte) (sum & 0xFF); |
| | | } |
| | | |
| | | public static byte[] getRequestParam(int feCount, byte[] address, byte control, byte[] data) throws IOException { |
| | | |
| | | ///FEFEFE 68 999999999999 68 01 02 65 F3C1 16 |
| | | // byte b = (byte) 0xFE; |
| | | // byte[] msg = {(byte) 0xFE,0x68}; |
| | | ByteArrayOutputStream frame = new ByteArrayOutputStream(); |
| | | for (int i = 0; i < feCount; i++) { |
| | | frame.write(0xFE); |
| | | } |
| | | // 2. 帧起å§ç¬¦ |
| | | frame.write(0x68); |
| | | // 3. å°åå |
| | | frame.write(address); |
| | | // 4. 忬¡å¸§èµ·å§ç¬¦ |
| | | frame.write(0x68); |
| | | // 5. æ§å¶ç |
| | | frame.write(control); |
| | | // 6. æ°æ®é¿åº¦ |
| | | frame.write(data.length); |
| | | // 7. æ°æ®å |
| | | frame.write(data); |
| | | // 8. è®¡ç® CSï¼ä»ç¬¬ä¸ä¸ª 68 å¼å§ï¼ |
| | | byte[] csData = frame.toByteArray(); |
| | | int start = feCount; // 第ä¸ä¸ª 68 çä½ç½® |
| | | byte cs = calcCS(Arrays.copyOfRange(csData, start, csData.length)); |
| | | frame.write(cs); |
| | | // 9. ç»æç¬¦ |
| | | frame.write(0x16); |
| | | return frame.toByteArray(); |
| | | } |
| | | |
| | | |
| | | private static byte[] readDeviceData(String ip, int port, byte[] data) { |
| | | Socket socket = null; |
| | | try { |
| | | socket = new Socket(ip, port); |
| | | socket.setSoTimeout(5000); |
| | | java.io.OutputStream out = socket.getOutputStream(); |
| | | java.io.InputStream in = socket.getInputStream(); |
| | | out.write(data); |
| | | out.flush(); |
| | | // 读åååº |
| | | byte[] buffer = new byte[2048]; |
| | | int bytesRead = in.read(buffer); |
| | | byte[] response = Arrays.copyOf(buffer, bytesRead); |
| | | // è§£æååºæ°æ® |
| | | return response; |
| | | } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | throw new RuntimeException("Failed to read from device", e); |
| | | } finally { |
| | | if (socket != null) { |
| | | try { |
| | | socket.close(); |
| | | } catch (IOException e) { |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private static String bytesToHex(byte[] bytes) { |
| | | StringBuilder hexString = new StringBuilder(); |
| | | for (byte b : bytes) { |
| | | String hex = String.format("%02X", b & 0xFF); |
| | | hexString.append(hex); |
| | | } |
| | | return hexString.toString(); |
| | | } |
| | | |
| | | /** |
| | | * å°12ä½åè¿å¶å°å转æ¢ä¸º6åèBCDå°ç«¯åºå°å |
| | | * |
| | | * @param decimalAddress 12ä½åè¿å¶å°åå符串 |
| | | * @return 6åèçBCDå°åï¼å°ç«¯åºï¼ |
| | | */ |
| | | private static byte[] convertToBCDAddress(String decimalAddress) { |
| | | // 1. éªè¯è¾å
¥ |
| | | if (decimalAddress == null || decimalAddress.length() != 12) { |
| | | throw new IllegalArgumentException("å°åå¿
é¡»æ¯12ä½åè¿å¶æ°"); |
| | | } |
| | | if (!decimalAddress.matches("\\d{12}")) { |
| | | throw new IllegalArgumentException("å°åå¿
é¡»å
¨é¨æ¯æ°å"); |
| | | } |
| | | // 2. åå¤ç»ææ°ç»ï¼6åèï¼ |
| | | byte[] result = new byte[6]; |
| | | // 3. ä»å³åå·¦æ¯2ä½ä¸ç»å¤çï¼å°ç«¯åºï¼ |
| | | for (int i = 0; i < 6; i++) { |
| | | // 计ç®å¨å符串ä¸çä½ç½®ï¼ä»å³åå·¦ï¼ |
| | | int strIndex = 10 - (i * 2); // å 为è¦å两ä½ï¼æä»¥æ¯10,8,6,4,2,0 |
| | | String twoDigits = decimalAddress.substring(strIndex, strIndex + 2); |
| | | // å°ä¸¤ä½åè¿å¶æ°è½¬æ¢ä¸ºBCDåè |
| | | // ä¾å¦ï¼"25" -> 0x25 |
| | | result[i] = (byte) Integer.parseInt(twoDigits, 16); |
| | | } |
| | | // 注æï¼ä¸é¢ç循ç¯é¡ºåºå·²ç»æ¯å°ç«¯åºï¼result[0]åçæ¯æä½ä¸¤ä½ |
| | | return result; |
| | | } |
| | | |
| | | |
| | | private static String subByte(String value, byte sub) { |
| | | byte b = (byte) Integer.parseInt(value, 16); |
| | | int result = (b & 0xFF) - (sub & 0xFF); |
| | | // ç¡®ä¿ç»æå¨0-255èå´å
ï¼å¤çè´æ°ï¼ |
| | | if (result < 0) { |
| | | result += 256; |
| | | } |
| | | String hexResult = String.format("%02X", result & 0xFF); |
| | | return hexResult; |
| | | |
| | | } |
| | | |
| | | |
| | | private static String[] parseSub33Reverse(String msg, int n) { |
| | | //33333333 3333 |
| | | String[] nArr = new String[n]; |
| | | |
| | | byte _33 = 0x33; |
| | | for (int i = 0; i < n; i++) { |
| | | int index = i * 2; |
| | | String twoDigits = msg.substring(index, index + 2); |
| | | String hexResult = subByte(twoDigits, _33); |
| | | // åååå¨ï¼nArr[n - i - 1] å®ç°å转 |
| | | nArr[n - i - 1] = hexResult; |
| | | } |
| | | return nArr; |
| | | } |
| | | |
| | | |
| | | public static Map<String, Object> water(String ip, int port, String address) throws IOException { |
| | | byte[] address_buf = convertToBCDAddress(address); |
| | | byte control = 0x01; |
| | | byte[] data = {0x43, (byte) 0xC3}; |
| | | byte[] bufReq = getRequestParam(3, address_buf, control, data); |
| | | byte[] resp = readDeviceData(ip, port, bufReq); |
| | | String hex = bytesToHex(resp); |
| | | |
| | | //FEFEFE6899254652010068810843C3333433333333E916 |
| | | // System.out.println(hex); |
| | | String msg = hex.substring(30, 30 + 8 + 4); |
| | | |
| | | String[] nArr = parseSub33Reverse(msg, 4); |
| | | Double total = strArrNum(nArr); |
| | | Map<String, Object> r = new HashMap<>(); |
| | | r.put("total", total); |
| | | |
| | | msg = hex.substring(40, 40 + 2); |
| | | byte sub = 0x33; |
| | | String hexResult = subByte(msg, sub); |
| | | String v = hexToBinary(hexResult); |
| | | /** |
| | | * Y0.B0ãåå¨å¨ç¶æ (1:æ
é,0:æ£å¸¸)ï¼ |
| | | * Y0.B1ãéé¨ç¶æ (1:æ
é,0:æ£å¸¸)ï¼ |
| | | * Y0.B2ãä¿¡å·ç¶æ (1:æ
é,0:æ£å¸¸)ï¼ |
| | | * Y0.B3ãçµæ± ç¶æ (1:æ
é,0:æ£å¸¸)ï¼ |
| | | * Y0.B4ãä¿çï¼ |
| | | * Y0.B5ãä¿çï¼ |
| | | * Y0.B6ãæ°´è¡¨éè®¯ç¶æï¼ 1:æ
é,0:æ£å¸¸ï¼ï¼ |
| | | * Y0.B7ãéé¨å¼å
³ç¶æ (1: å,0:å¼)ï¼ |
| | | * 注æï¼ç¶æä½æ æ¶ä¸º 0ï¼æ£å¸¸ï¼ |
| | | * 红è²ï¼æ è®°å¿ç´è¯»è¡¨çç¶æ |
| | | */ |
| | | |
| | | r.put("status", v); |
| | | return r; |
| | | } |
| | | |
| | | |
| | | private static void electricityTotal(String ip, int port, byte[] addressBuf, Map<String, Object> map) throws IOException { |
| | | byte control = 0x11; |
| | | byte[] data = {0x33, 0x33, 0x33, 0x33}; |
| | | |
| | | byte[] bufReq = getRequestParam(4, addressBuf, control, data); |
| | | byte[] respBuf = readDeviceData(ip, port, bufReq); |
| | | String resp = bytesToHex(respBuf); |
| | | String msg = resp.substring(28 + 8, 28 + 8 + 8); |
| | | String[] nArr = parseSub33Reverse(msg, 4); |
| | | Double total = strArrNum(nArr); |
| | | map.put("total", total); |
| | | } |
| | | |
| | | private static void electricityStatus(String ip, int port, byte[] addressBuf, Map<String, Object> map) throws IOException { |
| | | byte control = 0x11; |
| | | byte[] data = {0x36, 0x38, 0x33, 0x37}; |
| | | byte[] bufReq = getRequestParam(4, addressBuf, control, data); |
| | | byte[] respBuf = readDeviceData(ip, port, bufReq); |
| | | String resp = bytesToHex(respBuf); |
| | | String msg = resp.substring(36, 36 + 4); |
| | | System.out.println(resp); |
| | | String[] nArr = parseSub33Reverse(msg, 2); |
| | | String status = hexToBinary1(nArr); |
| | | // String resp = "FEFEFEFE 68 615121010000 68 91 06 36383337 3333 7916"; |
| | | map.put("status", status); |
| | | } |
| | | |
| | | private static void electricityTime(String ip, int port, byte[] addressBuf, Map<String, Object> map) throws IOException { |
| | | byte control = 0x11; |
| | | byte[] data = {0x3F, 0x34, 0x33, 0x37}; |
| | | byte[] bufReq = getRequestParam(4, addressBuf, control, data); |
| | | byte[] respBuf = readDeviceData(ip, port, bufReq); |
| | | String resp = bytesToHex(respBuf); |
| | | String msg = resp.substring(36, 36 + 14); |
| | | // System.out.println(msg); |
| | | String[] nArr = parseSub33Reverse(msg, 7); |
| | | String ts = hexToBinary1(nArr); |
| | | String time = "20"+ts.substring(0,6)+ts.substring(8); |
| | | Date date = getDateByStr(time); |
| | | // String resp = "FEFEFEFE 68 615121010000 68 91 06 36383337 3333 7916"; |
| | | map.put("currentTime", formatData(date)); |
| | | } |
| | | public static Date getDateByStr(String date) { |
| | | TimeZone tz = TimeZone.getTimeZone("Asia/Shanghai"); |
| | | if(date!=null ){ |
| | | int i = date.indexOf("+"); |
| | | if(i >0){ |
| | | date = date.substring(0,i); |
| | | } |
| | | } |
| | | DateFormat df = new SimpleDateFormat("yyyyMMddHHmmss"); |
| | | df.setTimeZone(tz); |
| | | Date dates = null; |
| | | try { |
| | | dates = df.parse(date); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return dates; |
| | | } |
| | | public static String formatData(Date date) { |
| | | DateFormat df = new SimpleDateFormat("yyyyå¹´MMæddæ¥HHæ¶mmåssç§"); |
| | | try { |
| | | return df.format(date); |
| | | } catch (Exception e) { |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public static Map<String, Object> electricity(String ip, int port, String address) throws IOException { |
| | | Map<String, Object> r = new HashMap<>(); |
| | | byte[] addressBuf = convertToBCDAddress(address); |
| | | electricityTotal(ip, port, addressBuf, r); |
| | | electricityStatus(ip, port, addressBuf, r); |
| | | electricityTime(ip, port, addressBuf, r); |
| | | return r; |
| | | } |
| | | |
| | | private static String hexToBinary(String hex) { |
| | | StringBuilder sb = new StringBuilder(); |
| | | for (char c : hex.toCharArray()) { |
| | | int val = Integer.parseInt(String.valueOf(c), 16); |
| | | sb.append(String.format("%4s", Integer.toBinaryString(val)).replace(' ', '0')); |
| | | } |
| | | return sb.toString(); |
| | | } |
| | | |
| | | private static String hexToBinary(String[] hexArr) { |
| | | StringBuilder sb = new StringBuilder(); |
| | | for (int i = 0; i < hexArr.length; i++) { |
| | | sb.append(hexToBinary(hexArr[i])); |
| | | } |
| | | return sb.toString(); |
| | | } |
| | | private static String hexToBinary1(String[] hexArr) { |
| | | StringBuilder sb = new StringBuilder(); |
| | | for (int i = 0; i < hexArr.length; i++) { |
| | | sb.append(hexArr[i]); |
| | | } |
| | | return sb.toString(); |
| | | } |
| | | |
| | | |
| | | private static String addHex(String hex1, String hex2) { |
| | | int num1 = Integer.parseInt(hex1.replace("0x", ""), 16); |
| | | int num2 = Integer.parseInt(hex2.replace("0x", ""), 16); |
| | | int sum = num1 + num2; |
| | | return "0x" + Integer.toHexString(sum).toUpperCase(); |
| | | } |
| | | |
| | | private static void testWater() throws IOException { |
| | | //"00000152462599"; 000152462599 |
| | | //FEFEFE 68 999999999999 68 01(C) 02(L) 65(DI0) F3(DI1) C1(CSæ ¡éªç ) 16(ç»æç¬¦) |
| | | //FEFEFE6899254652010068010243C33016 |
| | | //FEFEFE6899254652010068810843C3333333333333E816 |
| | | |
| | | // FEFEFE6899254652010068810843C3333333333333E816 |
| | | String ip = "192.168.1.78"; |
| | | int port = 1030; |
| | | // DeviceData d = readDeviceData(ip, port, "00000152462599"); |
| | | // System.out.println(d); |
| | | // String address = "000152462599"; |
| | | String address = "000152462599"; |
| | | //00000152462599 |
| | | byte[] address_buf = convertToBCDAddress(address); |
| | | // byte[] address_buf = hexStringToByteArray(address); |
| | | // System.out.println(buf); |
| | | /** |
| | | * |
| | | * FEFEFE 68 000152462599 68010243C33016 |
| | | * FEFEFE 68 992546520100 68010243C33016 |
| | | */ |
| | | byte control = 0x01; |
| | | byte[] data = {0x43, (byte) 0xC3}; |
| | | byte[] datas = getRequestParam(3, address_buf, control, data); |
| | | System.out.println(bytesToHex(datas)); |
| | | System.out.println("FEFEFE6899254652010068010243C33016"); |
| | | // datas = hexStringToByteArray("FEFEFE6899254652010068010243C33016"); |
| | | byte[] resp = readDeviceData(ip, port, datas); |
| | | String r = bytesToHex(resp); |
| | | System.out.println(r); |
| | | |
| | | /** |
| | | * |
| | | * FEFEFE 68 992546520100 68 01 02 43C3 30 16 |
| | | * FEFEFE 68 992546520100 68 81 08 43C3 33333333 3333 E8 16 |
| | | */ |
| | | // String r = "FEFEFE6899254652010068810843C3333333333333E816"; |
| | | String msg = r.substring(30, 30 + 8 + 4); |
| | | System.out.println(msg); |
| | | String[] nArr = parseSub33Reverse(msg, 4); |
| | | System.out.println(strArrNum(nArr)); |
| | | // byte d10 = 0x10; |
| | | // byte add = 0x33; |
| | | // String hex = String.format("%02X", (d10 + add) & 0xFF); |
| | | // System.out.println(hex); |
| | | |
| | | // r = addHex("0x10", "0x33"); |
| | | // System.out.println(r); |
| | | // |
| | | // r = addHex("0x90", "0x33"); |
| | | // System.out.println(r); |
| | | msg = r.substring(40, 40 + 2); |
| | | System.out.println(msg); |
| | | |
| | | byte sub = 0x33; |
| | | String hexResult = subByte(msg, sub); |
| | | String v = hexToBinary(hexResult); |
| | | System.out.println(v); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * æåä¸ä½æ¯å°æ°ç¹ |
| | | * |
| | | * @param nArr |
| | | * @return |
| | | */ |
| | | private static Double strArrNum(String[] nArr) { |
| | | if (nArr == null || nArr.length == 0) { |
| | | return 0.0; |
| | | } |
| | | // å°ææé¨åæ¼æ¥èµ·æ¥ |
| | | StringBuilder sb = new StringBuilder(); |
| | | for (int i = 0; i < nArr.length; i++) { |
| | | sb.append(nArr[i]); |
| | | } |
| | | |
| | | // å¨éå½ä½ç½®æå
¥å°æ°ç¹ |
| | | String combined = sb.toString(); |
| | | int totalLength = combined.length(); |
| | | int decimalLength = nArr[nArr.length - 1].length(); |
| | | // æå
¥å°æ°ç¹ |
| | | String numberStr = combined.substring(0, totalLength - decimalLength) + "." + combined.substring(totalLength - decimalLength); |
| | | return Double.parseDouble(numberStr); |
| | | } |
| | | |
| | | |
| | | public static void electricityTest() throws IOException { |
| | | //000001215161 |
| | | // FEFEFEFE 68 615121010000 68 11 04 33333333 8516 |
| | | // FEFEFEFE6861512101000068910833333333A93333334B16 |
| | | // FEFEFEFE6861512101000068910833333333AC3333334E16 |
| | | String ip = "192.168.1.78"; |
| | | int port = 1030; |
| | | |
| | | String address = "000001215161"; |
| | | byte[] addressBuf = convertToBCDAddress(address); |
| | | |
| | | // byte control = 0x11; |
| | | // byte[] data = {0x33, 0x33, 0x33, 0x33}; |
| | | //// |
| | | // byte[] bufReq = getRequestParam(4, addressBuf, control, data); |
| | | //// String req = bytesToHex(bufReq); |
| | | ////// String param = "FEFEFE68615121010000681104333333338516"; |
| | | //// System.out.println(req); |
| | | ////// System.out.println(param); |
| | | //// byte[] buf = hexStringToByteArray(param); |
| | | // byte[] respBuf = readDeviceData(ip, port, bufReq); |
| | | // String hex = bytesToHex(respBuf); |
| | | //// System.out.println(hex); |
| | | // String resp = "FEFEFEFE6861512101000068910833333333AC3333334E16"; |
| | | //// FEFEFEFE68615121010000 68 91 08 33333333 A9 333333 4B16 |
| | | // |
| | | // String msg = resp.substring(28, 28 + 8); |
| | | // System.out.println(msg); |
| | | // |
| | | // String[] nArr = parseSub33Reverse(msg, 4); |
| | | // System.out.println(strArrNum(nArr)); |
| | | // msg = resp.substring(28 + 8, 28 + 8 + 8); |
| | | // System.out.println(msg); |
| | | // |
| | | // nArr = parseSub33Reverse(msg, 4); |
| | | //// parseSub33Reverse |
| | | // System.out.println(strArrNum(nArr)); |
| | | |
| | | |
| | | // String msgStatus = "FEFEFEFE 68 379707010000 68 11 04 36383337 9316"; |
| | | // String msgStatus = "FEFEFEFE68379707010000681104363833379316"; |
| | | // byte control = 0x11; |
| | | // byte[] data = {0x36, 0x38, 0x33, 0x37}; |
| | | // byte[] bufReq = getRequestParam(4, addressBuf, control, data); |
| | | // String req = bytesToHex(bufReq); |
| | | // System.out.println(req); |
| | | // System.out.println(msgStatus); |
| | | // byte[] respBuf = readDeviceData(ip, port, bufReq); |
| | | // String resp = bytesToHex(respBuf); |
| | | // System.out.println(resp); |
| | | // FEFEFEFE 68 615121010000 68 91 06 36383337 3333 79 16 |
| | | // FEFEFEFE 68 615121010000 68 91 06 36383337 3333 79 16 |
| | | String resp = "FEFEFEFE686151210100006891063638333733337916"; |
| | | String msg = resp.substring(36, 36 + 4); |
| | | System.out.println(msg); |
| | | String[] nArr = parseSub33Reverse(msg, 2); |
| | | // System.out.println(strArrNum(nArr)); |
| | | String v = hexToBinary(nArr); |
| | | v="0000000000010000"; |
| | | System.out.println(v); |
| | | System.out.println(v.charAt(11)); |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | public static void main(String[] args) throws IOException { |
| | | // testWater(); |
| | | // electricityTest(); |
| | | water("192.168.1.78",1030,"000152462599"); |
| | | Map<String, Object> map = electricity("192.168.1.78", 1030, "000001215161"); |
| | | System.out.println(JSONObject.toJSONString(map)); |
| | | // FEFEFE6899254652010068810 843C3333433333333 E9 16 |
| | | // FEFEFE6899254652010068810 84 3C3333433333333E916 |
| | | |
| | | // Map<String, Object> map1 = water("192.168.1.78", 1030, "000152462599"); |
| | | // System.out.println(JSONObject.toJSONString(map1)); |
| | | } |
| | | |
| | | } |
| | |
| | | spring: |
| | | profiles: |
| | | active: pro |
| | | active: dev |
| | | application: |
| | | name: visitsAdmin |
| | | # å®å
¨é
ç½® |
| | |
| | | @ExcelColumn(name="æåºç ") |
| | | private Integer sortnum; |
| | | |
| | | @ApiModelProperty(value = "ç±»å 0é¨ç¦ 1è½¦åº 2LED 3广æç¹ 4广æè®¾å¤ 5æè·¯å¨ç©ºå¼", example = "1") |
| | | @ExcelColumn(name="ç±»å 0é¨ç¦ 1è½¦åº 2LED 3广æç¹ 4广æè®¾å¤ 5æè·¯å¨ç©ºå¼") |
| | | @ApiModelProperty(value = "ç±»å 0é¨ç¦ 1è½¦åº 2LED 3广æç¹ 4广æè®¾å¤ 5æè·¯å¨ç©ºå¼ 6海康çµè¡¨", example = "1") |
| | | @ExcelColumn(name="ç±»å 0é¨ç¦ 1è½¦åº 2LED 3广æç¹ 4广æè®¾å¤ 5æè·¯å¨ç©ºå¼ 6海康çµè¡¨") |
| | | private Integer type; |
| | | @ApiModelProperty(value = "æ¯å¦ååºåºå
¥å£ 0䏿¯ 1æ¯", example = "1") |
| | | @ExcelColumn(name="æ¯å¦ååºåºå
¥å£ 0䏿¯ 1æ¯") |