已添加12个文件
已删除1个文件
已修改30个文件
| | |
| | | |
| | | # VUE_APP_API_URL = 'https://atwl.ahzyssl.com/zhyq_interface' |
| | | |
| | | <<<<<<< HEAD |
| | | # VUE_APP_API_URL = 'http://192.168.1.45:10010' |
| | | |
| | | VUE_APP_API_URL = 'http://192.168.0.7/system_gateway' |
| | | ======= |
| | | VUE_APP_API_URL = 'http://localhost:10010' |
| | | |
| | | #VUE_APP_API_URL = 'http://192.168.0.7/system_gateway' |
| | | >>>>>>> ce3b9c67f6b2ee83d7edf593d06221d909e9afda |
| | | |
| | | # VUE_APP_API_URL = 'http://localhost:10010' |
| | | |
| | |
| | | export function updateById (data) { |
| | | return request.post('/visitsAdmin/cloudService/business/device/updateById', data) |
| | | } |
| | | export function create (data) { |
| | | return request.post('/visitsAdmin/cloudService/business/device/create', data) |
| | | } |
| | | |
| | | // ä¿®æ¹æ¯å¦é¨ç¦å
¥å£ |
| | | export function updateEntranceById (data) { |
| | |
| | | export function setLedContent (data) { |
| | | return request.post('/visitsAdmin/cloudService/business/hksync/setLedContent', data) |
| | | } |
| | | export function sendBobao (data) { |
| | | return request.post('/visitsAdmin/cloudService/business/hksync/sendBobao', data) |
| | | } |
| | | |
| | | // å é¤ |
| | | export function deleteById (id) { |
| | | return request.get(`/visitsAdmin/cloudService/business/device/delete/${id}`) |
| | | } |
| | | |
| | | // æ¹éå é¤ |
| | | export function deleteByIdInBatch (ids) { |
| | | return request.get('/visitsAdmin/cloudService/business/device/delete/batch', { |
| | | params: { |
| | | ids |
| | | } |
| | | }) |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <GlobalWindow |
| | | :title="title" |
| | | :visible.sync="visible" |
| | | :confirm-working="isWorking" |
| | | @confirm="confirm" |
| | | > |
| | | <el-form :model="form" ref="form" :rules="rules"> |
| | | <el-form-item label="设å¤åç§°" prop="name"> |
| | | <el-input v-model="form.name" placeholder="请è¾å
¥åç§°" v-trim/> |
| | | </el-form-item> |
| | | <el-form-item label="设å¤å¯ä¸ç " prop="hkId"> |
| | | <el-input v-model="form.hkId" placeholder="请è¾å
¥è®¾å¤å¯ä¸ç " v-trim/> |
| | | </el-form-item> |
| | | <el-form-item label="设å¤åºåå·" prop="no"> |
| | | <el-input v-model="form.no" placeholder="请è¾å
¥åºåå·" v-trim/> |
| | | </el-form-item> |
| | | <el-form-item label="è¿æ¥IP" prop="ip"> |
| | | <el-input v-model="form.ip" placeholder="请è¾å
¥è®¾å¤è¿æ¥IPå°å" v-trim/> |
| | | </el-form-item> |
| | | <el-form-item label="è¿æ¥ç«¯å£" prop="port"> |
| | | <el-input v-model="form.port" placeholder="请è¾å
¥è¿æ¥ç«¯å£" v-trim/> |
| | | </el-form-item> |
| | | <el-form-item label="è¿æ¥è´¦å·" prop="doorId"> |
| | | <el-input v-model="form.doorId" placeholder="请è¾å
¥è®¾å¤è¿æ¥è´¦å·" v-trim/> |
| | | </el-form-item> |
| | | <el-form-item label="è¿æ¥å¯ç " prop="doorName"> |
| | | <el-input v-model="form.doorName" type="password" maxlength="30" show-password></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="æå¨ä½ç½®" prop="regionPathName"> |
| | | <el-input v-model="form.regionPathName" placeholder="请è¾å
¥æå¨ä½ç½®" v-trim/> |
| | | </el-form-item> |
| | | </el-form> |
| | | </GlobalWindow> |
| | | </template> |
| | | |
| | | <script> |
| | | import BaseOpera from '@/components/base/BaseOpera' |
| | | import GlobalWindow from '@/components/common/GlobalWindow' |
| | | export default { |
| | | name: 'OperaDeviceBroadcastWindow', |
| | | extends: BaseOpera, |
| | | components: { GlobalWindow }, |
| | | data () { |
| | | return { |
| | | // è¡¨åæ°æ® |
| | | form: { |
| | | id: null, |
| | | hkId: '', |
| | | name: '', |
| | | regionPathName: '', |
| | | no: '', |
| | | type: 4, |
| | | ip: '', |
| | | port: '', |
| | | doorId: '', |
| | | doorName:'' |
| | | }, |
| | | // éªè¯è§å |
| | | rules: { |
| | | name: [ |
| | | { required: true, message: '请è¾å
¥è®¾å¤åç§°' } |
| | | ], |
| | | ip: [ |
| | | { required: true, message: '请è¾å
¥è®¾å¤è¿æ¥IPå°å' } |
| | | ], |
| | | port: [ |
| | | { required: true, message: '请è¾å
¥è®¾å¤è¿æ¥ç«¯å£å·' } |
| | | ], |
| | | doorId: [ |
| | | { required: true, message: '请è¾å
¥è®¾å¤è¿æ¥è´¦å·' } |
| | | ], |
| | | doorName: [ |
| | | { required: true, message: '请è¾å
¥è®¾å¤è¿æ¥å¯ç ' } |
| | | ], |
| | | hkId: [ |
| | | { required: true, message: '请è¾å
¥è®¾å¤å¯ä¸ç ' } |
| | | ] |
| | | } |
| | | } |
| | | }, |
| | | created () { |
| | | this.config({ |
| | | api: '/business/device', |
| | | 'field.id': 'id' |
| | | }) |
| | | } |
| | | } |
| | | </script> |
| | |
| | | </el-form> |
| | | <!-- è¡¨æ ¼åå页 --> |
| | | <template v-slot:table-wrap> |
| | | <ul class="toolbar"> |
| | | <li><el-button type="primary" @click="synchronousData">忥</el-button></li> |
| | | <ul class="toolbar" v-permissions="['business:device:create', 'business:device:delete']"> |
| | | <li><el-button type="primary" :loading="isWorking.delete" @click="synchronousData">忥</el-button></li> |
| | | <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" |
| | |
| | | :data="tableData.list" |
| | | stripe |
| | | > |
| | | <el-table-column type="selection" width="55"></el-table-column> |
| | | <el-table-column label="åºå·" width="55" fixed><template slot-scope="scope" >{{scope.$index+1}}</template></el-table-column> |
| | | <el-table-column prop="name" label="åç§°"></el-table-column> |
| | | <el-table-column prop="hkId" label="广æç¹å¯ä¸æ è¯" min-width="200"></el-table-column> |
| | | <el-table-column prop="channelInfo" label="广æç¹ç±»å"></el-table-column> |
| | | <el-table-column prop="channelNo" label="ééå·"></el-table-column> |
| | | <el-table-column prop="regionName" label="åºååç§°"></el-table-column> |
| | | <el-table-column prop="hkDate" label="忥æ¶é´"></el-table-column> |
| | | <el-table-column prop="hkId" label="å¯ä¸æ è¯" ></el-table-column> |
| | | <el-table-column prop="regionPathName" label="æå¨ä½ç½®"></el-table-column> |
| | | <el-table-column prop="no" label="åºåå·" ></el-table-column> |
| | | <el-table-column prop="ip" label="IPå°å" ></el-table-column> |
| | | <el-table-column prop="port" label="端å£" ></el-table-column> |
| | | <el-table-column prop="doorId" label="è´¦å·"></el-table-column> |
| | | <el-table-column prop="doorName" label="å¯ç " align="center"> |
| | | <template slot-scope="{row}"> |
| | | <span :class=" 'blue'">{{row.showPwd?row.doorName:'******'}}</span> |
| | | <el-button style="margin-left: 10px" v-if="row.doorName!=null" |
| | | @click.native.p.prevent="showPassward(row)" type="text"> |
| | | <i class="el-icon-view" :class="row.showPwd?'red':'blue'" :title="row.showPwd?'éè':'æ¾ç¤º'"></i> |
| | | </el-button> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="editDate" label="æè¿æ´æ°æ¶é´"></el-table-column> |
| | | <el-table-column |
| | | v-if="containPermissions(['business:devicerole:update', 'business:devicerole:delete'])" |
| | | label="æä½" |
| | | align="center" |
| | | min-width="120" |
| | | 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="send(row)" icon="el-icon-edit" 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" |
| | |
| | | > |
| | | </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" > |
| | | <el-form-item label="ææ¥å
容" prop="name" required> |
| | | <el-input v-model="form.sendInfo" type="textarea" placeholder="请è¾å
¥ææ¥å
容" v-trim/> |
| | | </el-form-item> |
| | | </el-form> |
| | | <template v-slot:footer > |
| | | <el-button @click="sendBobao()" type="primary" :loading="isWorkSending">确认</el-button> |
| | | <el-button @click="sendClose()">è¿å</el-button> |
| | | </template> |
| | | </el-dialog> |
| | | <!-- æ°å»º/ä¿®æ¹ --> |
| | | <!-- <OperaDeviceWindow ref="operaDeviceWindow" @success="handlePageChange"/>--> |
| | | <OperaDeviceBroadcastWindow ref="operaDeviceWindow" @success="handlePageChange"/> |
| | | </TableLayout> |
| | | </template> |
| | | |
| | |
| | | import BaseTable from '@/components/base/BaseTable' |
| | | import TableLayout from '@/layouts/TableLayout' |
| | | import Pagination from '@/components/common/Pagination' |
| | | import OperaDeviceWindow from '@/components/business/OperaDeviceWindow' |
| | | import { syncDevices, updateEntranceById } from '@/api/business/device' |
| | | import OperaDeviceBroadcastWindow from '@/components/business/OperaDeviceBroadcastWindow' |
| | | import { syncDevices } from '@/api/business/device' |
| | | export default { |
| | | name: 'Device', |
| | | extends: BaseTable, |
| | | components: { TableLayout, Pagination, OperaDeviceWindow }, |
| | | components: { TableLayout, Pagination, OperaDeviceBroadcastWindow }, |
| | | data () { |
| | | return { |
| | | // æç´¢ |
| | |
| | | regionPathName: '', |
| | | isEntrance: '', |
| | | online: '', |
| | | type: 3 |
| | | type: 4 |
| | | }, |
| | | isWorkSending: false, |
| | | form: { |
| | | sendInfo: '', |
| | | id: '', |
| | | hkId: '', |
| | | name: '' |
| | | }, |
| | | visibleSend: false, |
| | | options: [] |
| | | } |
| | | }, |
| | |
| | | this.search() |
| | | }, |
| | | methods: { |
| | | changeManufature(e, row) { |
| | | updateEntranceById({ |
| | | id: row.id, |
| | | isEntrance: e |
| | | showPassward (row) { |
| | | if (!row.showPwd) { |
| | | this.$set(row, 'showPwd', true) |
| | | } else { |
| | | this.$set(row, 'showPwd', false) |
| | | } |
| | | }, |
| | | sendBobao () { |
| | | if (!this.form.sendInfo) { |
| | | return |
| | | } |
| | | this.$dialog.actionConfirm('确认è¿è¡å¹¿æææ¥åï¼', 'æä½ç¡®è®¤æé') |
| | | .then(() => { |
| | | this.isWorkSending = true |
| | | this.api.sendBobao(this.form) |
| | | .then(res => { |
| | | this.$tip.apiSuccess(res || 'ææ¥è¯·æ±æå') |
| | | this.sendClose() |
| | | }) |
| | | .catch(e => { |
| | | }) |
| | | .finally(() => { |
| | | this.isWorkSending = false |
| | | }) |
| | | }) |
| | | .catch(() => {}) |
| | | }, |
| | | send (row) { |
| | | this.visibleSend = true |
| | | this.form = { sendInfo: '', id: row.id, hkId: row.hkId, name: row.name } |
| | | }, |
| | | sendClose () { |
| | | this.visibleSend = false |
| | | this.isWorkSending = false |
| | | this.form = { sendInfo: '', id: '', hkId: '', name: '' } |
| | | }, |
| | | synchronousData () { |
| | | this.$dialog.actionConfirm('æä½ç¡®è®¤æé', 'æ¨ç¡®è®¤åæ¥å
¨é¨ä¿¡æ¯åï¼') |
| | | .then(() => { |
| | | this.isWorking.delete = true |
| | | syncDevices({type: 3}) |
| | | syncDevices({ type: 4 }) |
| | | .then(res => { |
| | | this.$tip.apiSuccess(res || '忥æå') |
| | | this.search() |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <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> |
| | | <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"> |
| | | <li><el-button type="primary" @click="synchronousData">忥</el-button></li> |
| | | </ul> |
| | | <el-table |
| | | :height="tableHeightNew" |
| | | v-loading="isWorking.search" |
| | | :data="tableData.list" |
| | | stripe |
| | | > |
| | | <el-table-column label="åºå·" width="55" fixed><template slot-scope="scope" >{{scope.$index+1}}</template></el-table-column> |
| | | <el-table-column prop="name" label="åç§°"></el-table-column> |
| | | <el-table-column prop="hkId" label="广æç¹å¯ä¸æ è¯" min-width="200"></el-table-column> |
| | | <el-table-column prop="channelInfo" label="广æç¹ç±»å"></el-table-column> |
| | | <el-table-column prop="channelNo" label="ééå·"></el-table-column> |
| | | <el-table-column prop="regionName" label="åºååç§°"></el-table-column> |
| | | <el-table-column prop="hkDate" label="忥æ¶é´"></el-table-column> |
| | | </el-table> |
| | | <pagination |
| | | @size-change="handleSizeChange" |
| | | @current-change="handlePageChange" |
| | | :pagination="tableData.pagination" |
| | | > |
| | | </pagination> |
| | | </template> |
| | | <!-- æ°å»º/ä¿®æ¹ --> |
| | | <!-- <OperaDeviceWindow ref="operaDeviceWindow" @success="handlePageChange"/>--> |
| | | </TableLayout> |
| | | </template> |
| | | |
| | | <script> |
| | | import BaseTable from '@/components/base/BaseTable' |
| | | import TableLayout from '@/layouts/TableLayout' |
| | | import Pagination from '@/components/common/Pagination' |
| | | import OperaDeviceWindow from '@/components/business/OperaDeviceWindow' |
| | | import { syncDevices, updateEntranceById } from '@/api/business/device' |
| | | export default { |
| | | name: 'Device', |
| | | extends: BaseTable, |
| | | components: { TableLayout, Pagination, OperaDeviceWindow }, |
| | | data () { |
| | | return { |
| | | // æç´¢ |
| | | searchForm: { |
| | | doorName: '', |
| | | regionPathName: '', |
| | | isEntrance: '', |
| | | online: '', |
| | | type: 3 |
| | | }, |
| | | options: [] |
| | | } |
| | | }, |
| | | created () { |
| | | this.config({ |
| | | module: '设å¤ä¿¡æ¯è¡¨', |
| | | api: '/business/device', |
| | | 'field.id': 'id', |
| | | 'field.main': 'id' |
| | | }) |
| | | this.search() |
| | | }, |
| | | methods: { |
| | | changeManufature(e, row) { |
| | | updateEntranceById({ |
| | | id: row.id, |
| | | isEntrance: e |
| | | }) |
| | | }, |
| | | synchronousData () { |
| | | this.$dialog.actionConfirm('æä½ç¡®è®¤æé', 'æ¨ç¡®è®¤åæ¥å
¨é¨ä¿¡æ¯åï¼') |
| | | .then(() => { |
| | | this.isWorking.delete = true |
| | | syncDevices({type: 3}) |
| | | .then(res => { |
| | | this.$tip.apiSuccess(res || '忥æå') |
| | | this.search() |
| | | }) |
| | | .catch(e => { |
| | | // this.$tip.apiFailed(e) |
| | | }) |
| | | .finally(() => { |
| | | this.isWorking.delete = false |
| | | }) |
| | | }) |
| | | .catch(() => {}) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | |
| | | <el-form-item label="éè´§æ¥æ" prop="dateInfo"> |
| | | <el-date-picker v-model="searchForm.dateInfo" value-format="yyyy-MM-dd" placeholder="请è¾å
¥æ¥æ" @change="search"/> |
| | | </el-form-item> |
| | | <el-form-item label="æå±ä¸»çº¿è·¯" prop="categoryId"> |
| | | <el-select v-model="searchForm.categoryId" clearable filterable placeholder="è¯·éæ©æå±ä¸»çº¿è·¯" @change="search"> |
| | | <el-option v-for="item in categoryList" :key="item.id" :label="item.name" :value="item.id"> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="ç¶æ" prop="status" > |
| | | <el-select v-model="searchForm.status" placeholder="è¯·éæ©" clearable @change="search"> |
| | | <el-option label="æªä¼å" value="0"></el-option> |
| | |
| | | import OperaJkSketchLineListWindow from '@/components/business/OperaJkSketchLineListWindow' |
| | | import OperaJkSketchResultWindow from '@/components/business/OperaJkSketchResultWindow' |
| | | import OperaJkSketchImportWindow from '@/components/business/OperaJkSketchImportWindow' |
| | | import {fetchCateList} from "@/api/business/category"; |
| | | export default { |
| | | name: 'JkSketch', |
| | | extends: BaseTable, |
| | |
| | | // æç´¢ |
| | | searchForm: { |
| | | status: '', |
| | | categoryId: '', |
| | | dateInfo: '' |
| | | }, |
| | | isWorking: { |
| | | export1: false, |
| | | export2: false |
| | | } |
| | | }, |
| | | categoryList: [] |
| | | } |
| | | }, |
| | | created () { |
| | |
| | | const day = now.getDate(); |
| | | this.searchForm.dateInfo = `${year}-${month}-${day}` |
| | | this.search() |
| | | this.loadCategory() |
| | | }, |
| | | methods: { |
| | | loadCategory () { |
| | | fetchCateList({ type: 4 }).then(res => { |
| | | this.categoryList = res || [] |
| | | }) |
| | | }, |
| | | exportExcel1 () { |
| | | if (!this.searchForm.dateInfo) { |
| | | this.$message.error('è¯·éæ©æå®æ¥æè¿è¡è¯¥å¯¼åºæä½ï¼') |
| | |
| | | spring: |
| | | profiles: |
| | | active: pro |
| | | active: dev |
| | | application: |
| | | name: system_gateway |
| | | # å®å
¨é
ç½® |
| | |
| | | public static final String SIGN_IN_QRCODE ="SIGN_IN_QRCODE" ; |
| | | public static final String SIGN_IN_ATTENTION ="SIGN_IN_ATTENTION" ; |
| | | public static final String SIGN_IN_QRCODE_PREFIX ="SIGN_IN_QRCODE_PREFIX" ; |
| | | public static final String JK_PLAN_MAX_CLUSTER ="JK_PLAN_MAX_CLUSTER" ; |
| | | public static final String JK_PLAN_DISTANCE_CLUSTER ="JK_PLAN_DISTANCE_CLUSTER" ; |
| | | |
| | | /** |
| | | * æä½ç±»åï¼ç¨äºåæ¥å£éªè¯åç» |
| | |
| | | package com.doumee.core.utils; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.http.HttpEntity; |
| | | import org.apache.http.ParseException; |
| | | import org.apache.http.auth.AuthScope; |
| | | import org.apache.http.auth.UsernamePasswordCredentials; |
| | | import org.apache.http.client.ClientProtocolException; |
| | | import org.apache.http.client.CredentialsProvider; |
| | | import org.apache.http.client.config.RequestConfig; |
| | | import org.apache.http.client.methods.CloseableHttpResponse; |
| | | import org.apache.http.client.methods.HttpDelete; |
| | | import org.apache.http.client.methods.HttpPost; |
| | | import org.apache.http.client.methods.HttpRequestBase; |
| | | import org.apache.http.entity.StringEntity; |
| | | import org.apache.http.impl.client.BasicCredentialsProvider; |
| | | import org.apache.http.impl.client.CloseableHttpClient; |
| | | import org.apache.http.impl.client.HttpClients; |
| | | import org.apache.http.util.EntityUtils; |
| | | import org.springframework.http.HttpMethod; |
| | | |
| | | import javax.net.ssl.*; |
| | | import java.io.*; |
| | | import java.net.HttpURLConnection; |
| | | import java.net.URI; |
| | | import java.net.URL; |
| | | import java.security.KeyManagementException; |
| | | import java.security.NoSuchAlgorithmException; |
| | | import java.security.SecureRandom; |
| | | import java.security.cert.CertificateException; |
| | | import java.security.cert.X509Certificate; |
| | | |
| | | @Slf4j |
| | | public class HttpsUtil { |
| | | |
| | | public static String get(String url,boolean ignoreSSL) { |
| | |
| | | return connectionHttp(url, "POST", data, "application/json"); |
| | | } |
| | | } |
| | | private static final int CONNECT_TIMEOUT =10000;// è®¾ç½®è¿æ¥å»ºç«çè¶
æ¶æ¶é´ä¸º10s |
| | | private static final int SOCKET_TIMEOUT = 10000;//socket读åè¶
æ¶æ¶é´(å使¯«ç§) |
| | | |
| | | private static void setRequestConfig(HttpRequestBase httpRequestBase) { |
| | | RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(CONNECT_TIMEOUT) |
| | | .setConnectTimeout(CONNECT_TIMEOUT).setSocketTimeout(SOCKET_TIMEOUT).build(); |
| | | httpRequestBase.setConfig(requestConfig); |
| | | } |
| | | |
| | | public static String doPostHk(String host,int port,String UserName,String Password,String url, String Input) { |
| | | try { |
| | | CloseableHttpResponse responseBody = null; |
| | | HttpPost httpPost = new HttpPost("http://"+host+":"+port+url); |
| | | setRequestConfig(httpPost); |
| | | httpPost.setEntity(new StringEntity(Input, "UTF-8")); |
| | | CredentialsProvider credsProvider = new BasicCredentialsProvider(); |
| | | credsProvider.setCredentials(new AuthScope(host, port), |
| | | new UsernamePasswordCredentials(UserName, Password)); |
| | | CloseableHttpClient httpClient = HttpClients.custom().setDefaultCredentialsProvider(credsProvider).build(); |
| | | |
| | | String response = ""; |
| | | |
| | | // ç±å®¢æ·ç«¯æ§è¡(åé)Postè¯·æ± |
| | | responseBody = httpClient.execute(httpPost); |
| | | // ä»ååºæ¨¡åä¸è·åååºå®ä½ |
| | | HttpEntity responseEntity = responseBody.getEntity(); |
| | | log.error("doPostHkååºç¶æä¸º:" + responseBody.getStatusLine()); |
| | | if (responseBody.getStatusLine().getStatusCode() == 302){ |
| | | String redirectLocation = responseBody.getHeaders("Location")[0].getValue(); |
| | | log.error("doPostHkRedirected to: " + redirectLocation); |
| | | // å¨è¿éï¼ä½ å¯ä»¥åéä¸ä¸ªæ°ç请æ±å°redirectLocation |
| | | httpPost.setURI(URI.create(redirectLocation)); |
| | | CloseableHttpResponse responseBody2 = httpClient.execute(httpPost); |
| | | log.error("doPostHkéå®ååååºç¶æä¸º:" + responseBody2.getStatusLine()); |
| | | HttpEntity responseEntity2 = responseBody2.getEntity(); |
| | | log.error("doPostHkéå®ååååºå
容é¿åº¦ä¸º:" + responseEntity2.getContentLength()); |
| | | response = EntityUtils.toString(responseEntity2); |
| | | log.error("doPostHkéå®ååååºå
容为:\n" + response); |
| | | responseBody2.close(); |
| | | return response; |
| | | }else { |
| | | if (responseEntity != null) { |
| | | log.error("doPostHkååºå
容é¿åº¦ä¸º:" + responseEntity.getContentLength()); |
| | | response = EntityUtils.toString(responseEntity); |
| | | log.error("doPostHkååºå
容为:\n" + response); |
| | | return response; |
| | | } |
| | | } |
| | | if (httpClient != null) { |
| | | httpClient.close(); |
| | | } |
| | | if (responseBody != null) { |
| | | responseBody.close(); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("doPostHkå起请æ±å¼å¸¸:\n" + e.getMessage()); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public static String connection(String url,String method,String data,String contentType,boolean ignoreSSL){ |
| | | HttpsURLConnection connection = null; |
| | |
| | | @PostMapping("/create") |
| | | @CloudRequiredPermission("business:device:create") |
| | | public ApiResponse create(@RequestBody Device device,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){ |
| | | device.setLoginUserInfo(this.getLoginUser(token)); |
| | | return ApiResponse.success(deviceService.create(device)); |
| | | } |
| | | |
| | |
| | | @GetMapping("/delete/{id}") |
| | | @CloudRequiredPermission("business:device:delete") |
| | | public ApiResponse deleteById(@PathVariable Integer id,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){ |
| | | deviceService.deleteById(id); |
| | | deviceService.deleteById(id,this.getLoginUser(token)); |
| | | return ApiResponse.success(null); |
| | | } |
| | | @ApiOperation("ä¿®æ¹æ¯å¦é¨ç¦å
¥å£") |
| | |
| | | for (String id : idArray) { |
| | | idList.add(Integer.valueOf(id)); |
| | | } |
| | | deviceService.deleteByIdInBatch(idList); |
| | | deviceService.deleteByIdInBatch(idList,this.getLoginUser(token)); |
| | | return ApiResponse.success(null); |
| | | } |
| | | |
| | |
| | | @PostMapping("/updateById") |
| | | @CloudRequiredPermission("business:device:update") |
| | | public ApiResponse updateById(@RequestBody Device device,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){ |
| | | |
| | | device.setLoginUserInfo(this.getLoginUser(token)); |
| | | deviceService.updateById(device); |
| | | return ApiResponse.success(null); |
| | | } |
| | |
| | | }else if(Constants.equalsInteger(param.getType(),Constants.THREE)){ |
| | | //åæ¥å¹¿æ |
| | | result = hkSyncDeviceService.syncHkBroadcast(param); |
| | | }else if(Constants.equalsInteger(param.getType(),Constants.FOUR)){ |
| | | //åæ¥å¹¿æ |
| | | result = hkSyncDeviceService.syncHkBroadcastDevice(param); |
| | | } |
| | | return ApiResponse.success(result); |
| | | } |
| | |
| | | deviceService.setLedContent(body); |
| | | return ApiResponse.success(null); |
| | | } |
| | | @ApiOperation("ãæµ·åº·ãå¹¿æææ¥") |
| | | @PostMapping("/sendBobao") |
| | | public ApiResponse<String> setBroadcaseBobao(@RequestBody Device body , HttpServletResponse response) { |
| | | return ApiResponse.success( deviceService.setBroadcaseBobaoHttp(body)); |
| | | } |
| | | @ApiOperation("ãæµ·åº·ãå¹¿æææ¥") |
| | | @PostMapping("/sendBobaoOpenapi") |
| | | public ApiResponse<List<Map<String,Object>>> sendBobaoOpenapi(@RequestBody Device body , HttpServletResponse response) { |
| | | deviceService.setBroadcaseBobao(body); |
| | | return ApiResponse.success(null); |
| | | } |
| | | |
| | | } |
| | |
| | | spring: |
| | | profiles: |
| | | active: pro |
| | | active: dev |
| | | application: |
| | | name: visitsAdmin |
| | | # å®å
¨é
ç½® |
| | |
| | | <scope>compile</scope> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.apache.commons</groupId> |
| | | <artifactId>commons-math3</artifactId> |
| | | <version>3.6.1</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.doumee</groupId> |
| | | <artifactId>emaysms</artifactId> |
| | | <version>1.0.0-SNAPSHOT</version> |
| | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | public static String startDoPostStringArtemis(String[] pathStr,Map<String, String> querys,Map<String, String> header,String body){ |
| | | Map<String, String> path = getPath(pathStr[0]); |
| | | header.put("tagId","frs"); |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.core.haikang.model.param.request; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | public class ISAPIBroadcastAddPlanSchemeRequest { |
| | | |
| | | /** |
| | | { |
| | | "terminalInfoList": [ |
| | | { |
| | | "terminalID": 1, |
| | | "audioOutID": [ |
| | | 2 |
| | | ], |
| | | "audioOutIndexList": [ |
| | | 1 |
| | | ] |
| | | } |
| | | ], |
| | | "broadcastPlanSchemeList": [ |
| | | { |
| | | "planSchemeID": "plan1", |
| | | "enabled": true, |
| | | "sourceID": "fdb4465d7aa5495884845127a8bbbe3c", |
| | | "weklyScheduleInfo": { |
| | | "startTime": "1970-01-01", |
| | | "stopTime": "1970-01-01", |
| | | "weeklyScheduleList": [ |
| | | { |
| | | "dayOfWeek": 1, |
| | | "scheduleList": [ |
| | | { |
| | | "planSchemeExecID": 0, |
| | | "beginTime": "00:00:00", |
| | | "endTime": "00:00:00", |
| | | "playNowTime": "00:00:00", |
| | | "operation": { |
| | | "audioSource": "customAudio", |
| | | "customAudioID": [ |
| | | 2 |
| | | ], |
| | | "URLIDs": [ |
| | | 1 |
| | | ], |
| | | "speechSynthesisContent": "test", |
| | | "audioLevel": 0, |
| | | "TTSLanguageType": "english", |
| | | "voiceType": "male", |
| | | "audioVolume": 1 |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | ] |
| | | }, |
| | | "dailyScheduleInfo": { |
| | | "startTime": "1970-01-01", |
| | | "stopTime": "1970-01-01", |
| | | "dailyScheduleList": [ |
| | | { |
| | | "beginTime": "00:00:00", |
| | | "endTime": "00:00:00", |
| | | "playNowTime": "00:00:00", |
| | | "operation": { |
| | | "audioSource": "customAudio", |
| | | "customAudioID": [ |
| | | 2 |
| | | ], |
| | | "URLIDs": [ |
| | | 1 |
| | | ], |
| | | "speechSynthesisContent": "test", |
| | | "audioLevel": 0, |
| | | "TTSLanguageType": "english", |
| | | "audioVolume": 1 |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | */ |
| | | } |
| | |
| | | *å页è·å广æç¹ï¼åé¡µï¼ |
| | | * @return |
| | | */ |
| | | public static BaseResponse<BaseListPageResponse<FetchAudioChannelInfoResponse>> fetchAudioDevice(FetchAudioChannelRequest param){ |
| | | log.info("ãæµ·åº·è·åå页è·å广æç¹ã================å¼å§===="+JSONObject.toJSONString(param)); |
| | | public static BaseResponse<BaseListPageResponse<FetchAudioDeviceInfoResponse>> fetchAudioDevice(FetchAudioDeviceRequest param){ |
| | | log.info("ãæµ·åº·è·åå页è·å广æè®¾å¤ã================å¼å§===="+JSONObject.toJSONString(param)); |
| | | try { |
| | | String res = HKTools.fetchAudioDevice(JSONObject.toJSONString(param)); |
| | | TypeReference typeReference = |
| | | new TypeReference< BaseResponse<BaseListPageResponse<FetchAudioChannelInfoResponse>> >(){}; |
| | | BaseResponse<BaseListPageResponse<FetchAudioChannelInfoResponse>> result = JSONObject.parseObject(res, typeReference.getType()); |
| | | logResult(result,"海康è·åå页è·å广æç¹"); |
| | | new TypeReference< BaseResponse<BaseListPageResponse<FetchAudioDeviceInfoResponse>> >(){}; |
| | | BaseResponse<BaseListPageResponse<FetchAudioDeviceInfoResponse>> result = JSONObject.parseObject(res, typeReference.getType()); |
| | | logResult(result,"海康è·åå页è·å广æè®¾å¤"); |
| | | return result; |
| | | }catch (Exception e){ |
| | | log.error("ãæµ·åº·è·åå页è·å广æç¹ã================失败====ï¼\n"+ e.getMessage()); |
| | | log.error("ãæµ·åº·è·åå页è·å广æè®¾å¤ã================失败====ï¼\n"+ e.getMessage()); |
| | | } |
| | | return null; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.core.tsp; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.dao.admin.request.SketchCateModel; |
| | | import com.doumee.dao.business.model.JkSketchCustomer; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.math3.ml.clustering.*; |
| | | import org.apache.commons.math3.ml.distance.EuclideanDistance; |
| | | /** |
| | | * |
| | | * @author xjx |
| | | * |
| | | */ |
| | | @Slf4j |
| | | public class ClusterCustomKMeans{ |
| | | //欧å¼è·ç¦» |
| | | |
| | | public List<SketchCateModel> clusterPoints(List<JkSketchCustomer> customers, int k, int d){ |
| | | List<SketchCateModel> list = new ArrayList<>(); |
| | | if(customers.size() <= k){ |
| | | int index =0; |
| | | for (JkSketchCustomer c : customers) { |
| | | SketchCateModel sketchCateModel = new SketchCateModel(); |
| | | sketchCateModel.setId(index); |
| | | List<JkSketchCustomer> cList = new ArrayList<>(); |
| | | cList.add(c); |
| | | sketchCateModel.setTotalNum(c.getTotalNum()); |
| | | sketchCateModel.setCustomerList(cList); |
| | | sketchCateModel.setStartPoint(c); |
| | | sketchCateModel.setTotalCustomer(1); |
| | | list.add(sketchCateModel); |
| | | log.error("Cluster " + index + "membersï¼"+1+"/200 "+" 客æ·ï¼"+ c.getName()); |
| | | index ++; |
| | | } |
| | | return list; |
| | | } |
| | | List<DoublePointNew> points = new ArrayList<>(); |
| | | for (int i = 0; i < customers.size(); i++) { |
| | | DoublePointNew p = new DoublePointNew(new double[]{customers.get(i).getLatitude().doubleValue(), customers.get(i).getLongitude().doubleValue()}); |
| | | p.setCustomer(customers.get(i)); |
| | | points.add(p); // 示ä¾ç¹1 |
| | | } |
| | | KMeansPlusPlusClusterer<DoublePointNew> clusterer = new KMeansPlusPlusClusterer<>(k, d, new EuclideanDistance()); |
| | | List<CentroidCluster<DoublePointNew>> clusters = clusterer.cluster(points); |
| | | |
| | | int index = 0; |
| | | int maxMembersPerCluster = 200; // 设置æ¯ä¸ªç°çæå¤§æåæ° |
| | | List<CentroidCluster<DoublePointNew>> allList = new ArrayList<>(); |
| | | for (CentroidCluster<DoublePointNew> cluster : clusters) { |
| | | if(cluster.getPoints() ==null || cluster.getPoints().size() ==0){ |
| | | log.error("Cluster " + clusters.indexOf(cluster) + "membersï¼"+cluster.getPoints().size()+"/200 æ æ°æ®"); |
| | | continue; |
| | | } |
| | | log.error("Cluster " + clusters.indexOf(cluster) + "membersï¼"+cluster.getPoints().size()+"/200 "+"ä¸å¿ç¹ï¼"+ Arrays.toString(cluster.getCenter().getPoint())+"ä¸å¿ç¹ï¼"+ cluster.getPoints().get(0).getCustomer().getName()); |
| | | if (cluster.getPoints().size() > maxMembersPerCluster) { |
| | | // è¿éå¯ä»¥éæ°è¿è¡èç±»ç®æ³æè
æå¨è°æ´ç°çåé
çç¥ |
| | | log.error("Cluster " + clusters.indexOf(cluster) + " exceeds maximum membersï¼" + cluster.getPoints().size() + "/200, re-clustering needed."); |
| | | // å¯ä»¥èè忬¡è°ç¨KMeansPlusPlusClustereræå
¶å®é»è¾æ¥å¤çè¶
éæ
åµã |
| | | } |
| | | allList.add(cluster); |
| | | } |
| | | for (CentroidCluster<DoublePointNew> cluster : allList) { |
| | | // System.out.println("Cluster " + clusters.indexOf(cluster) + "membersï¼"+cluster.getPoints().size()+"/200 "); |
| | | if (cluster.getPoints().size() > maxMembersPerCluster) { |
| | | // è¿éå¯ä»¥éæ°è¿è¡èç±»ç®æ³æè
æå¨è°æ´ç°çåé
çç¥ |
| | | // System.out.println("Cluster " + clusters.indexOf(cluster) + " exceeds maximum membersï¼"+cluster.getPoints().size()+"/200, re-clustering needed."); |
| | | // å¯ä»¥èè忬¡è°ç¨KMeansPlusPlusClustereræå
¶å®é»è¾æ¥å¤çè¶
éæ
åµã |
| | | } |
| | | SketchCateModel sketchCateModel = new SketchCateModel(); |
| | | sketchCateModel.setId(index); |
| | | List<JkSketchCustomer> cList = new ArrayList<>(); |
| | | for(DoublePointNew doublePointNew:cluster.getPoints()){ |
| | | cList.add(doublePointNew.getCustomer()); |
| | | sketchCateModel.setTotalNum(Constants.formatBigdecimal(sketchCateModel.getTotalNum()).add(Constants.formatBigdecimal(doublePointNew.getCustomer().getTotalNum()))); |
| | | } |
| | | sortPointByCenterPoint(cluster,cList); |
| | | sketchCateModel.setCustomerList(cList); |
| | | sketchCateModel.setStartPoint(cList.get(0)); |
| | | sketchCateModel.setTotalCustomer(cList.size()); |
| | | list.add(sketchCateModel); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | private void sortPointByCenterPoint(CentroidCluster<DoublePointNew> cluster, List<JkSketchCustomer> cList) { |
| | | double clat = Constants.formatBigdecimal(cList.get(0).getLatitude()).doubleValue(); |
| | | double clong = Constants.formatBigdecimal(cList.get(0).getLongitude()).doubleValue(); |
| | | if(cluster!=null || cluster.getCenter() != null || cluster.getCenter().getPoint() != null && cluster.getCenter().getPoint().length>=2){ |
| | | clong = cluster.getCenter().getPoint()[1]; |
| | | clat = cluster.getCenter().getPoint()[0]; |
| | | } |
| | | for(JkSketchCustomer c : cList){ |
| | | double latDiff = Constants.formatBigdecimal(c.getLatitude()).doubleValue() - clat; |
| | | double lonDiff = Constants.formatBigdecimal(c.getLongitude()).doubleValue() - clong; |
| | | c.setDistanceCenter(Math.sqrt(latDiff * latDiff + lonDiff * lonDiff)); // 欧æ°è·ç¦» |
| | | } |
| | | Collections.sort(cList, (p1, p2) -> Double.compare(p1.getDistanceCenter(), p2.getDistanceCenter())); |
| | | } |
| | | |
| | | public class DoublePointNew extends DoublePoint{ |
| | | private JkSketchCustomer customer; |
| | | |
| | | public DoublePointNew(double[] point) { |
| | | super(point); |
| | | } |
| | | |
| | | public JkSketchCustomer getCustomer() { |
| | | return customer; |
| | | } |
| | | |
| | | public void setCustomer(JkSketchCustomer customer) { |
| | | this.customer = customer; |
| | | } |
| | | |
| | | } |
| | | public static void main(String[] args) { |
| | | List<JkSketchCustomer> points = new ArrayList<>(); |
| | | for (int i = 0; i <10; i++) { |
| | | JkSketchCustomer a = new JkSketchCustomer(); |
| | | a.setLatitude(new BigDecimal(30.19d )); |
| | | a.setLongitude(new BigDecimal(117.40 )); |
| | | a.setName("客æ·"+i); |
| | | points.add(a); |
| | | } |
| | | for (int i = 0; i <10; i++) { |
| | | JkSketchCustomer a = new JkSketchCustomer(); |
| | | a.setLatitude(new BigDecimal(31.19d )); |
| | | a.setLongitude(new BigDecimal(118.40 )); |
| | | a.setName("客æ·"+i); |
| | | points.add(a); |
| | | } |
| | | for (int i = 10; i <3000; i++) { |
| | | JkSketchCustomer a = new JkSketchCustomer(); |
| | | a.setLatitude(new BigDecimal(31.19d-(0.1d)*Math.random())); |
| | | a.setLongitude(new BigDecimal(118.40-(0.2d)*Math.random())); |
| | | a.setName("客æ·"+i); |
| | | points.add(a); |
| | | } |
| | | |
| | | double threshold = 1000; // 设置è·ç¦»éå¼ï¼è¶
è¿è¿ä¸ªè·ç¦»å°±ä¸å±äºåä¸èç±»ã |
| | | (new ClusterCustomKMeans()).clusterPoints(points, 100,1); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.core.tsp; |
| | | |
| | | /** |
| | | * èç±»åç» |
| | | */ |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.dao.admin.request.SketchCateModel; |
| | | import com.doumee.dao.business.model.JkSketchCustomer; |
| | | import com.doumee.service.business.impl.JkSketchServiceImpl; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | public class Clustering { |
| | | public static List<SketchCateModel> clusterPoints(List<JkSketchCustomer> points, double threshold) { |
| | | |
| | | List<SketchCateModel> clusters = new ArrayList<>(); |
| | | boolean[] visited = new boolean[points.size()]; |
| | | int index =0; |
| | | for (int i = 0; i < points.size(); i++) { |
| | | if (!visited[i]) { |
| | | List<JkSketchCustomer> cluster = new ArrayList<>(); |
| | | dfs(points, visited, cluster, i, threshold); |
| | | SketchCateModel sketchCateModel = new SketchCateModel(); |
| | | sketchCateModel.setCustomerList(cluster); |
| | | sketchCateModel.setId(index); |
| | | sketchCateModel.setStartPoint(cluster.get(0)); |
| | | for (JkSketchCustomer c : cluster){ |
| | | sketchCateModel.setTotalNum(Constants.formatBigdecimal(sketchCateModel.getTotalNum()).add(Constants.formatBigdecimal(c.getTotalNum()))); |
| | | } |
| | | sketchCateModel.setTotalCustomer(cluster.size()); |
| | | clusters.add(sketchCateModel); |
| | | } |
| | | } |
| | | // æå°æ¯ä¸ªèç±»çç¹ |
| | | for (int i = 0; i < clusters.size(); i++) { |
| | | System.out.println("Cluster " + (i + 1) + ": " + clusters.get(i).getStartPoint().getName()+ ": " + clusters.get(i).getCustomerList().size()); |
| | | } |
| | | return clusters; |
| | | } |
| | | public static double distanceTo(JkSketchCustomer self, JkSketchCustomer other) { |
| | | List<DistanceMapParam> distanceMapParamList =JkSketchServiceImpl.getListFromJsonStr(self.getDistanceJson()); |
| | | DistanceMapParam param = JkSketchServiceImpl.getParamByCustomerIds( other.getId(),distanceMapParamList); |
| | | if(param!=null && param.getDistance()!=0){//妿ä¹åå·²ç»è·åè¿ |
| | | return (param.getDistance()); |
| | | } |
| | | return DistanceCalculator.calculateDistance(Constants.formatBigdecimal(self.getLatitude()).doubleValue() |
| | | ,Constants.formatBigdecimal(self.getLongitude()).doubleValue() |
| | | ,Constants.formatBigdecimal(other.getLatitude()).doubleValue() |
| | | ,Constants.formatBigdecimal(other.getLongitude()).doubleValue()); |
| | | } |
| | | private static void dfs(List<JkSketchCustomer> points, boolean[] visited, List<JkSketchCustomer> cluster, int startIndex, double threshold) { |
| | | visited[startIndex] = true; |
| | | cluster.add(points.get(startIndex)); |
| | | JkSketchCustomer startPoint = points.get(startIndex); |
| | | |
| | | for (int i = 0; i < points.size(); i++) { |
| | | if (!visited[i]) { |
| | | double distance = distanceTo(startPoint,points.get(i)); |
| | | if (distance <= threshold) { |
| | | dfs(points, visited, cluster, i, threshold); // é彿·»å å°èç±»ä¸ |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 117°40â²ï½118°44â²ãå纬30°19â²ï½31°34â² |
| | | * @param args |
| | | */ |
| | | public static void main(String[] args) { |
| | | List<JkSketchCustomer> points = new ArrayList<>(); |
| | | for (int i = 0; i <3000; i++) { |
| | | JkSketchCustomer a = new JkSketchCustomer(); |
| | | a.setLatitude(new BigDecimal(30.19d+(30.54d-30.19d)*Math.random())); |
| | | a.setLongitude(new BigDecimal(117.40+(117.74d-117.40d)*Math.random())); |
| | | a.setName("客æ·"+i); |
| | | points.add(a); |
| | | } |
| | | |
| | | double threshold = 1000; // 设置è·ç¦»éå¼ï¼è¶
è¿è¿ä¸ªè·ç¦»å°±ä¸å±äºåä¸èç±»ã |
| | | clusterPoints(points, threshold); |
| | | } |
| | | } |
| | |
| | | Math.sin(dLon / 2) * Math.sin(dLon / 2); |
| | | double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); |
| | | |
| | | return (long) (EARTH_RADIUS * c ); |
| | | return (long) (EARTH_RADIUS * c * 1000); |
| | | } |
| | | } |
| | |
| | | data.initDataList();//æé æ°æ® |
| | | |
| | | long start =System.currentTimeMillis(); |
| | | System.out.println("=============start=========="+start); |
| | | log.error("=============start=========="+start); |
| | | //å建æ±è§£å¨manager对象ï¼åå§åæ±è§£å¨æ°æ® |
| | | RoutingIndexManager manager = new RoutingIndexManager(data.distanceMatrix.length, data.vehicleNumber, data.depot); |
| | | |
| | |
| | | // æå°è·¯çº¿ |
| | | printSolution(data, routing, manager, solution); |
| | | long end =System.currentTimeMillis(); |
| | | System.out.println("=============end=========="+end); |
| | | log.error("=============end=========="+end); |
| | | |
| | | System.out.println("=============èæ¶=========="+(end -start)+"ï¼msï¼"+(end -start)/1000 +"s"+(end -start)/60/1000 +"m"); |
| | | log.error("=============èæ¶=========="+(end -start)+"ï¼msï¼"+(end -start)/1000 +"s"+(end -start)/60/1000 +"m"); |
| | | */} |
| | | public static void startSearch(DataModel data) { |
| | | // åå§åæ°æ®æ¨¡å |
| | | Loader.loadNativeLibraries(); |
| | | long start =System.currentTimeMillis(); |
| | | System.out.println("=============start=========="+start); |
| | | log.error("å¼å§è§å=============start=========="+start); |
| | | //å建æ±è§£å¨manager对象ï¼åå§åæ±è§£å¨æ°æ® |
| | | RoutingIndexManager manager = new RoutingIndexManager(data.distanceMatrix.length, data.vehicleNumber, data.depot); |
| | | |
| | |
| | | RoutingModel routing = new RoutingModel(manager); |
| | | |
| | | // 注ååè°å½æ° |
| | | /* final int transitCallbackIndex = |
| | | final int transitCallbackIndex = |
| | | routing.registerTransitCallback((long fromIndex, long toIndex) -> { |
| | | int fromNode = manager.indexToNode(fromIndex); |
| | | int toNode = manager.indexToNode(toIndex); |
| | |
| | | |
| | | // å®ä¹åè°å½æ°è³æ¯æ¡è·¯çº¿ |
| | | routing.setArcCostEvaluatorOfAllVehicles(transitCallbackIndex); |
| | | routing.addDimension(transitCallbackIndex, 0, 30000000, |
| | | /* routing.addDimension(transitCallbackIndex, 0, 30000000, |
| | | true, |
| | | "Distance"); |
| | | RoutingDimension distanceDimension = routing.getMutableDimension("Distance"); |
| | |
| | | // 注ååè°å½æ° |
| | | final int transitCallbackIndex1 = |
| | | routing.registerTransitCallback((long fromIndex, long toIndex) -> { |
| | | return 1; |
| | | int fromNode = manager.indexToNode(fromIndex); |
| | | return data.customerDemands[fromNode]; |
| | | }); |
| | | for (int d = 0; d < data.vehicleMaxNodes.length; d++) { |
| | | // å¢å è·ç¦»ç»´åº¦çº¦æ |
| | |
| | | }); |
| | | routing.addDimensionWithVehicleCapacity(demandCallbackIndex, 0, data.vehicleCapacities, true, "Capacity"); |
| | | |
| | | /* |
| | | // æ·»å 容ééå¶ |
| | | final int demandCallbackIndex1 = routing.registerUnaryTransitCallback((long fromIndex) -> { |
| | | return 1; |
| | | }); |
| | | routing.addDimensionWithVehicleCapacity(demandCallbackIndex1, 0, data.vehicleMaxNodes, true, "Capacity"); |
| | | */ |
| | | |
| | | Solver solver = routing.solver(); |
| | | //设置æç´¢æ¹æ³( |
| | | RoutingSearchParameters searchParameters = |
| | | main.defaultRoutingSearchParameters() |
| | | .toBuilder() |
| | | .setTimeLimit(Duration.newBuilder().setSeconds(60*60).build())//æä¹
1å°æ¶ |
| | | .setTimeLimit(Duration.newBuilder().setSeconds(60*60*6).build())//æä¹
1å°æ¶ |
| | | .setFirstSolutionStrategy(FirstSolutionStrategy.Value.PATH_CHEAPEST_ARC) |
| | | .build(); |
| | | |
| | | // æ§è¡ç®æ³ |
| | | Assignment solution = routing.solveWithParameters(searchParameters); |
| | | if(solution ==null){ |
| | | log.error("è§åç»æ=============æªæ¾å°æä¼è·¯çº¿ï¼" ); |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"æªæ¾å°æä¼è·¯çº¿ï¼"); |
| | | } |
| | | // æå°è·¯çº¿ |
| | | resultSolution(data, routing, manager, solution); |
| | | long end =System.currentTimeMillis(); |
| | | System.out.println("=============end=========="+end); |
| | | System.out.println("=============èæ¶=========="+(end -start)+"ï¼msï¼"+(end -start)/1000 +"s"+(end -start)/60/1000 +"m"); |
| | | log.error("è§åç»æ=============èæ¶=========="+(end -start)+"ï¼msï¼"+(end -start)/1000 +"s"+(end -start)/60/1000 +"m"); |
| | | } |
| | | static void resultSolution( DataModel data, RoutingModel routing, RoutingIndexManager manager, Assignment solution) { |
| | | long maxRouteDistance = 0; |
| | |
| | | |
| | | //æ¯ä¸ä¸ªç¹çååçæ°é |
| | | public long[] demands; |
| | | public long[] customerDemands; |
| | | //è½¦è¾æå¤§å®¹è½½ |
| | | public long[] vehicleCapacities ; |
| | | public long[] vehicleMaxNodes ; |
| | |
| | | this.solutions = solutions; |
| | | } |
| | | |
| | | public void initDataInfo(int vehicleNumber1, long[] demands1, long[] vehicleCapacities1, long[][] distanceMatrix1,long[] vehicleMaxNodes){ |
| | | public void initDataInfo(int vehicleNumber1, long[] demands1,long[] demands2, long[] vehicleCapacities1, long[][] distanceMatrix1,long[] vehicleMaxNodes){ |
| | | this.demands = demands1; |
| | | this.customerDemands = demands2; |
| | | this.vehicleNumber = vehicleNumber1; |
| | | this.vehicleCapacities=vehicleCapacities1; |
| | | this.distanceMatrix=distanceMatrix1; |
| | | this.vehicleMaxNodes =vehicleMaxNodes; |
| | | } |
| | | public void initDataList(){ |
| | | lenght = 20; |
| | | lenght = 10; |
| | | vehicleNumber = 5; |
| | | demands = new long[lenght]; |
| | | customerDemands = new long[lenght]; |
| | | vehicleCapacities =new long[vehicleNumber]; |
| | | vehicleMaxNodes =new long[vehicleNumber]; |
| | | distanceMatrix = new long[lenght][lenght]; |
| | |
| | | for (int i = 0; i <vehicleNumber ; i++) { |
| | | long tem = (long) (Math.random() * 1000 + 20000); |
| | | vehicleCapacities[i] = tem; |
| | | vehicleMaxNodes[i] =5; |
| | | vehicleMaxNodes[i] =50; |
| | | total0+=tem; |
| | | System.out.print(tem+" ,"); |
| | | } |
| | | System.out.println( "\ntotal Capacity:"+total0+"====================="); |
| | | log.error( "\ntotal Capacity:"+total0+"====================="); |
| | | long total = 0; |
| | | for (int i = 0; i <lenght ; i++) { |
| | | long tem = (int)(Math.random()*100+100); |
| | | demands[i] =tem; |
| | | customerDemands[i] =1; |
| | | total+=tem; |
| | | System.out.print(tem+" ,"); |
| | | for (int j = 0; j <lenght ; j++) { |
| | |
| | | } |
| | | } |
| | | |
| | | System.out.println( "\ntotal Demands:"+total+"====================="); |
| | | log.error( "\ntotal Demands:"+total+"====================="); |
| | | } |
| | | /* public final long[][] distanceMatrix = { |
| | | {0, 548, 776, 696, 582, 274, 502, 194, 308, 194, 536, 502, 388, 354, 468, 776, 662}, |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.dao.admin.request; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.doumee.core.annotation.excel.ExcelColumn; |
| | | import com.doumee.core.tsp.DistanceMapParam; |
| | | import com.doumee.dao.business.model.JkSketchCustomer; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * å工信æ¯å¯¼å
¥è¡¨ |
| | | * @author æ±è¹è¹ |
| | | * @date 2024/01/16 10:03 |
| | | */ |
| | | @Data |
| | | @ApiModel("线路è§åèç±»åç»éå") |
| | | public class SketchCateModel { |
| | | |
| | | private int id; |
| | | private JkSketchCustomer startPoint; |
| | | //ä¸å¿ç¹çº¬åº¦ |
| | | private BigDecimal latitude; |
| | | //ä¸å¿ç¹ç»åº¦ |
| | | private BigDecimal longitude; |
| | | @ApiModelProperty(value = "éè´§é", example = "1") |
| | | private BigDecimal totalNum; |
| | | @ApiModelProperty(value = "æ»å®¢æ·æ°", example = "1") |
| | | private int totalCustomer; |
| | | //ç¹éå |
| | | private List<JkSketchCustomer> customerList; |
| | | |
| | | } |
| | |
| | | package com.doumee.dao.business.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.doumee.core.annotation.excel.ExcelColumn; |
| | | import com.doumee.service.business.third.model.LoginUserModel; |
| | | import io.swagger.annotations.ApiModel; |
| | |
| | | @ExcelColumn(name="æåºç ") |
| | | private Integer sortnum; |
| | | |
| | | @ApiModelProperty(value = "ç±»å 0é¨ç¦ 1è½¦åº 2LED 3广æ", example = "1") |
| | | @ExcelColumn(name="ç±»å 0é¨ç¦ 1è½¦åº 2LED 3广æ") |
| | | @ApiModelProperty(value = "ç±»å 0é¨ç¦ 1è½¦åº 2LED 3广æç¹ 4广æè®¾å¤", example = "1") |
| | | @ExcelColumn(name="ç±»å 0é¨ç¦ 1è½¦åº 2LED 3广æç¹ 4广æè®¾å¤") |
| | | private Integer type; |
| | | @ApiModelProperty(value = "æ¯å¦ååºåºå
¥å£ 0䏿¯ 1æ¯", example = "1") |
| | | @ExcelColumn(name="æ¯å¦ååºåºå
¥å£ 0䏿¯ 1æ¯") |
| | |
| | | private String doorName; |
| | | |
| | | |
| | | |
| | | |
| | | @ApiModelProperty(value = "ææ¥å
容") |
| | | @TableField(exist = false) |
| | | private String sendInfo; |
| | | |
| | | |
| | | |
| | |
| | | @ApiModelProperty(value = "导å
¥å¤æ³¨") |
| | | private String importInfo; |
| | | |
| | | |
| | | @ApiModelProperty(value = "ä¸å人å", example = "1") |
| | | private Integer sendUserId; |
| | | @ApiModelProperty(value = "ä¸å次æ°", example = "1") |
| | |
| | | @ExcelColumn(name="èµ·å§ç¼ç ") |
| | | private Integer noIndex; |
| | | |
| | | @ApiModelProperty(value = "é
ç²¾æ£æµå¼å¯ï¼0=å¼å¯ï¼1=å
³é", example = "1") |
| | | private Integer alcoholStatus; |
| | | |
| | | @ApiModelProperty(value = "ç»çº¬åº¦ä¿¡æ¯ åæ°å¼ï¼ç»åº¦,纬度") |
| | | @TableField(exist = false) |
| | | private String jwd; |
| | |
| | | //@ExcelColumn(name="ç¶æ 0æ£å¸¸ ç¦ç¨") |
| | | @TableField(exist = false) |
| | | private String endSteps; |
| | | @ApiModelProperty(value = "è·ç¦»ä¸å¿ç¹è·ç¦»", example = "1") |
| | | @TableField(exist = false) |
| | | private double distanceCenter; |
| | | @ApiModelProperty(value = "åçç»é´å®¢æ·ä½ç½®è·ç¦»æ°ç»ï¼[{a:12,b:100},{a:13,b:200},...],aï¼å®¢æ·ç¼ç ï¼bï¼ä¸å®¢æ·aä¹é´çè·ç¦»") |
| | | @TableField(exist = false) |
| | | private List<DistanceMapParam> distanceMapParamList; |
| | |
| | | @ApiModelProperty(value = "æ¿æ´»æä»¶å°å") |
| | | private String activateFileUrl; |
| | | |
| | | @ApiModelProperty(value = "é
ç²¾æ£æµå¼å¯ï¼0=å¼å¯ï¼1=å
³é", example = "1") |
| | | private Integer alcoholStatus; |
| | | |
| | | @ApiModelProperty(value = "è½®æå¾å°å", example = "1") |
| | | private List<String> bannerList; |
| | |
| | | package com.doumee.service.business; |
| | | |
| | | import com.doumee.core.haikang.model.param.request.TransparentChannelSingleRequest; |
| | | import com.doumee.service.business.third.model.LoginUserInfo; |
| | | import com.doumee.service.business.third.model.PageData; |
| | | import com.doumee.service.business.third.model.PageWrap; |
| | | import com.doumee.dao.business.model.Device; |
| | |
| | | * |
| | | * @param id ä¸»é® |
| | | */ |
| | | void deleteById(Integer id); |
| | | void deleteById(Integer id, LoginUserInfo userInfo); |
| | | |
| | | /** |
| | | * å é¤ |
| | |
| | | * |
| | | * @param ids 主é®é |
| | | */ |
| | | void deleteByIdInBatch(List<Integer> ids); |
| | | void deleteByIdInBatch(List<Integer> ids, LoginUserInfo userInfo); |
| | | |
| | | /** |
| | | * 䏻鮿´æ° |
| | |
| | | |
| | | void setLedContent(TransparentChannelSingleRequest body); |
| | | void allLedDefualtContent(); |
| | | |
| | | void setBroadcaseBobao(Device body); |
| | | String setBroadcaseBobaoHttp(Device body); |
| | | } |
| | |
| | | |
| | | List<JkSketch> importBatch(MultipartFile file, String dateInfo, LoginUserInfo loginUser); |
| | | |
| | | void startUpdateLineAsyncOld(JkSketch model); |
| | | void startUpdateLineAsync(JkSketch model); |
| | | |
| | | void distanceCustomer(Category model ); |
| | |
| | | void startEditSketchLineAsync(JkSketch model); |
| | | |
| | | void startInitOriginDistanceBatch(JkSketch list); |
| | | |
| | | void startEditSketchLineAsyncOld(JkSketch model); |
| | | |
| | | /** |
| | | * 车è¾çº¿è·¯ - çµä¿¡ä½¿ç¨ |
| | |
| | | String syncHkLed(Device param); |
| | | |
| | | String syncHkBroadcast(Device param); |
| | | String syncHkBroadcastDevice(Device param); |
| | | String dealVisitEventIccm(EventVisitIccmRequest param, HttpServletResponse response); |
| | | |
| | | String dealPlatformStatusEvent(EventPlatformRequest param, HttpServletResponse response); |
| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.haikang.model.HKConstants; |
| | | import com.doumee.core.haikang.model.param.BaseResponse; |
| | | import com.doumee.core.haikang.model.param.request.CustomBroadcastRequest; |
| | | import com.doumee.core.haikang.model.param.request.TransparentChannelSingleRequest; |
| | | import com.doumee.core.haikang.service.HKService; |
| | | import com.doumee.core.utils.HttpsUtil; |
| | | import com.doumee.dao.business.*; |
| | | import com.doumee.dao.business.model.*; |
| | | import com.doumee.service.business.third.model.LoginUserInfo; |
| | | import com.doumee.service.business.third.model.PageData; |
| | | import com.doumee.service.business.third.model.PageWrap; |
| | | import com.doumee.core.utils.Constants; |
| | |
| | | |
| | | |
| | | @Override |
| | | public Integer create(Device device) { |
| | | deviceMapper.insert(device); |
| | | return device.getId(); |
| | | public Integer create(Device model) { |
| | | model.setCreator(model.getLoginUserInfo().getId()+""); |
| | | model.setEdirot(model.getCreator()); |
| | | model.setIsdeleted(Constants.ZERO); |
| | | model.setEditDate(new Date()); |
| | | model.setCreateDate(model.getEditDate()); |
| | | deviceMapper.insert(model); |
| | | return model.getId(); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteById(Integer id) { |
| | | deviceMapper.deleteById(id); |
| | | public void deleteById(Integer id, LoginUserInfo userInfo) { |
| | | Device update = new Device(); |
| | | update.setEdirot(userInfo.getId()+""); |
| | | update.setEditDate(new Date()); |
| | | update.setIsdeleted(Constants.ONE); |
| | | update.setId(id); |
| | | deviceMapper.updateById(update); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void deleteByIdInBatch(List<Integer> ids) { |
| | | public void deleteByIdInBatch(List<Integer> ids, LoginUserInfo userInfo) { |
| | | if (CollectionUtils.isEmpty(ids)) { |
| | | return; |
| | | } |
| | | deviceMapper.deleteBatchIds(ids); |
| | | for(Integer id :ids){ |
| | | deleteById(id,userInfo); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void updateById(Device device) { |
| | | device.setEdirot(device.getLoginUserInfo().getId()+""); |
| | | device.setEditDate(new Date()); |
| | | deviceMapper.updateById(device); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void setBroadcaseBobao(Device model){ |
| | | List<String> ids = new ArrayList<>(); |
| | | ids.add(model.getHkId()); |
| | | CustomBroadcastRequest request = new CustomBroadcastRequest(); |
| | | request.setAudioPointIndexCode(ids); |
| | | request.setPlayDuration(15);//åä½ç§ |
| | | request.setBroadCastMode("tts"); |
| | | request.setPriority(1); |
| | | request.setState(1);//ææ¾/忢æ è¯ 1-ææ¾ï¼0-忢 |
| | | request.setPlayTtsContent(model.getSendInfo()); |
| | | BaseResponse response = HKService.customBroadcast(request); |
| | | if(response == null || !StringUtils.equals(response.getCode(), HKConstants.RESPONSE_SUCCEE)){ |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"åé失败ï¼"+ JSONObject.toJSONString(response)); |
| | | } |
| | | } |
| | | @Override |
| | | public String setBroadcaseBobaoHttp(Device param){ |
| | | /* Device model = deviceMapper.selectById(param.getId()); |
| | | if(model ==null && Constants.equalsInteger(param.getType(),Constants.FOUR)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | String input = ""; |
| | | JSONObject objext = new JSONObject(); |
| | | |
| | | //éæ°ä¸å计å |
| | | JSONObject jsonObject = new JSONObject(); |
| | | //第ä¸å± |
| | | JSONArray firstJsonArray = new JSONArray(); |
| | | JSONObject downJson = new JSONObject(); |
| | | downJson.put("terminalID",1); |
| | | //ä¸å¡«é»è®¤å¯¹ææééä¸å |
| | | JSONArray audioJsonArray = new JSONArray(); |
| | | audioJsonArray.add(1); |
| | | downJson.put("audioOutID",audioJsonArray); |
| | | firstJsonArray.add(downJson); |
| | | jsonObject.put("TerminalInfoList",firstJsonArray); |
| | | //第ä¸å±æ°ç» |
| | | JSONArray allJsonArray = new JSONArray(); |
| | | //æ°ç»ä¸å¯¹è±¡ |
| | | for (WaterTimingBroadcastDO waterTimingBroadcastDO : searchList) { |
| | | JSONObject downArrayData = new JSONObject(); |
| | | downArrayData.put("audioOutID",audioJsonArray); |
| | | downArrayData.put("enabled",true); |
| | | downArrayData.put("planSchemeID",waterTimingBroadcastDO.getName()); |
| | | JSONObject executeJson = new JSONObject(); |
| | | executeJson.put("startTime", getDateStringByZones(waterTimingBroadcastDO.getStartDate())); |
| | | executeJson.put("stopTime",getDateStringByZones(waterTimingBroadcastDO.getEndDate())); |
| | | if (Constant.ONE.equals(waterTimingBroadcastDO.getPeriodType())){ |
| | | //æ¥è®¡å |
| | | JSONArray executeJsonArray = new JSONArray(); |
| | | JSONObject executeJsonDataItem = new JSONObject(); |
| | | executeJsonDataItem.put("beginTime",waterTimingBroadcastDO.getStartTime()+"+08:00"); |
| | | executeJsonDataItem.put("endTime",waterTimingBroadcastDO.getEndTime()+"+08:00"); |
| | | executeJsonDataItem.put("playMode","loop"); |
| | | executeJsonDataItem.put("playNowTime",""); |
| | | executeJsonDataItem.put("planSchemeExecID",0); |
| | | JSONObject secondDownOperationJson = new JSONObject(); |
| | | if (Constant.ONE.equals(waterTimingBroadcastDO.getContentType())){ |
| | | //ææ¬ |
| | | secondDownOperationJson.put("audioSource","speechSynthesis"); |
| | | secondDownOperationJson.put("speechSynthesisContent",waterTimingBroadcastDO.getContent()); |
| | | }else if (Constant.TWO.equals(waterTimingBroadcastDO.getContentType())){ |
| | | //é³é¢ |
| | | secondDownOperationJson.put("audioSource","customAudio"); |
| | | String json = waterTimingBroadcastDO.getJson(); |
| | | JSONObject jsonData = JSONObject.parseObject(json); |
| | | List<Integer> hkAudioIds = new ArrayList<>(); |
| | | hkAudioIds.add(jsonData.getIntValue(waterDeviceDO.getIp())); |
| | | secondDownOperationJson.put("customAudioID",hkAudioIds); |
| | | } |
| | | secondDownOperationJson.put("audioLevel",5); |
| | | //è¯è¨ç±»å |
| | | secondDownOperationJson.put("TTSLanguageType","chinese"); |
| | | secondDownOperationJson.put("voiceType","female"); |
| | | secondDownOperationJson.put("audioVolume",100); |
| | | executeJsonDataItem.put("Operation",secondDownOperationJson); |
| | | executeJsonArray.add(executeJsonDataItem); |
| | | executeJson.put("dailyScheduleList",executeJsonArray); |
| | | }else { |
| | | //å¨è®¡å |
| | | JSONArray executeJsonArray = new JSONArray(); |
| | | List<String> executeTime = new ArrayList<>(); |
| | | if (Constant.ONE.equals(waterTimingBroadcastDO.getPeriodType())){ |
| | | //æ¥è®¡å 循ç¯ä¸æ¬¡ |
| | | executeTime.add("1"); |
| | | }else if (Constant.TWO.equals(waterTimingBroadcastDO.getPeriodType())){ |
| | | //å¨è®¡åå¤ä¸ä¸ªå¨å |
| | | executeTime = Arrays.asList(waterTimingBroadcastDO.getExecuteTime().split(",")); |
| | | } |
| | | for (String s : executeTime) { |
| | | JSONObject executeJsonData = new JSONObject(); |
| | | if (Constant.TWO.equals(waterTimingBroadcastDO.getPeriodType())){ |
| | | //å¨è®¡åå¤ä¸ä¸ªå¨å |
| | | executeJsonData.put("dayOfWeek",Integer.parseInt(s)); |
| | | } |
| | | JSONArray executeJsonDataArray = new JSONArray(); |
| | | JSONObject executeJsonDataItem = new JSONObject(); |
| | | executeJsonDataItem.put("beginTime",waterTimingBroadcastDO.getStartTime()+"+08:00"); |
| | | executeJsonDataItem.put("endTime",waterTimingBroadcastDO.getEndTime()+"+08:00"); |
| | | executeJsonDataItem.put("playMode","loop"); |
| | | executeJsonDataItem.put("playNowTime",""); |
| | | executeJsonDataItem.put("planSchemeExecID",0); |
| | | JSONObject secondDownOperationJson = new JSONObject(); |
| | | if (Constant.ONE.equals(waterTimingBroadcastDO.getContentType())){ |
| | | //ææ¬ |
| | | secondDownOperationJson.put("audioSource","speechSynthesis"); |
| | | secondDownOperationJson.put("speechSynthesisContent",waterTimingBroadcastDO.getContent()); |
| | | }else if (Constant.TWO.equals(waterTimingBroadcastDO.getContentType())){ |
| | | //é³é¢ |
| | | secondDownOperationJson.put("audioSource","customAudio"); |
| | | String json = waterTimingBroadcastDO.getJson(); |
| | | JSONObject jsonData = JSONObject.parseObject(json); |
| | | List<Integer> hkAudioIds = new ArrayList<>(); |
| | | hkAudioIds.add(jsonData.getIntValue(waterDeviceDO.getIp())); |
| | | secondDownOperationJson.put("customAudioID",hkAudioIds); |
| | | } |
| | | secondDownOperationJson.put("audioLevel",5); |
| | | //è¯è¨ç±»å |
| | | secondDownOperationJson.put("TTSLanguageType","chinese"); |
| | | secondDownOperationJson.put("voiceType","female"); |
| | | secondDownOperationJson.put("audioVolume",10); |
| | | executeJsonDataItem.put("Operation",secondDownOperationJson); |
| | | executeJsonDataArray.add(executeJsonDataItem); |
| | | executeJsonData.put("scheduleList",executeJsonDataArray); |
| | | executeJsonArray.add(executeJsonData); |
| | | |
| | | } |
| | | executeJson.put("weeklyScheduleList",executeJsonArray); |
| | | } |
| | | |
| | | if (Constant.ONE.equals(waterTimingBroadcastDO.getPeriodType())){ |
| | | //æ¥è®¡å |
| | | downArrayData.put("dailyScheduleInfo",executeJson); |
| | | }else { |
| | | //å¨è®¡å |
| | | downArrayData.put("weklyScheduleInfo",executeJson); |
| | | } |
| | | allJsonArray.add(downArrayData); |
| | | } |
| | | jsonObject.put("broadcastPlanSchemeList",allJsonArray); |
| | | log.info("æµ·åº·ææ¾è®¡åä¸åå
¥åå
容 : " + jsonObject); |
| | | |
| | | String result = HttpsUtil.doPostHk(param.getIp(),Integer.parseInt(StringUtils.defaultString(param.getPort(),"80")) |
| | | ,"/ISAPI/VideoIntercom/broadcast/AddPlanScheme?format=json",param.getDoorId(), param.getDoorName(),jsonObject.toJSONString()); |
| | | return result;*/ |
| | | return null; |
| | | } |
| | | @Override |
| | | public void setLedContent(TransparentChannelSingleRequest model) { |
| | | Device device = findById(model.getDeviceId()); |
| | | if(device == null |
| | |
| | | || CollectionUtils.isEmpty(jkCabinet.getManagerIdList()) |
| | | || CollectionUtils.isEmpty(jkCabinet.getAuthMemberIdList()) |
| | | || Objects.isNull(jkCabinet.getDoubleAuth()) |
| | | || Objects.isNull(jkCabinet.getAlcoholStatus()) |
| | | |
| | | || Objects.isNull(jkCabinet.getRowNum()) |
| | | || jkCabinet.getRowNum() <= Constants.ZERO |
| | |
| | | || CollectionUtils.isEmpty(jkCabinet.getAuthMemberIdList()) |
| | | || Objects.isNull(jkCabinet.getPort()) |
| | | || Objects.isNull(jkCabinet.getDoubleAuth()) |
| | | || Objects.isNull(jkCabinet.getAlcoholStatus()) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | |
| | | startmodel.setSteps(allList.get(0).getStartSteps()); |
| | | if(StringUtils.isBlank(startmodel.getSteps())){ |
| | | // (BigDecimal lat1, BigDecimal lon1, BigDecimal lat2, BigDecimal lon2) |
| | | startmodel.setDistance(DistanceCalculator.calculateDistanceDecinal(startmodel.getStartLatitude(),startmodel.getStartLogitude(),startmodel.getEndLatitude(),startmodel.getEndLatitude())); |
| | | startmodel.setDistance(DistanceCalculator.calculateDistanceDecinal(startmodel.getStartLatitude(),startmodel.getStartLogitude(),startmodel.getEndLatitude(),startmodel.getEndLogitude())); |
| | | startmodel.setSteps(comLocation +";"+allList.get(0).getLongitude()+","+allList.get(0).getLatitude()); |
| | | } |
| | | list.add(startmodel); |
| | |
| | | if(param!=null && param.getDistance()!=0){//妿ä¹åå·²ç»è·åè¿ |
| | | tt.setDistance(param.getDistance()); |
| | | }else{ |
| | | tt.setDistance(DistanceCalculator.calculateDistanceDecinal(tt.getStartLatitude(),tt.getStartLogitude(),tt.getEndLatitude(),tt.getEndLatitude())); |
| | | tt.setDistance(DistanceCalculator.calculateDistanceDecinal(tt.getStartLatitude(),tt.getStartLogitude(),tt.getEndLatitude(),tt.getEndLogitude())); |
| | | } |
| | | } |
| | | tt.setLocation(allList.get(i).getLocation()); |
| | |
| | | import com.doumee.core.wms.model.response.WmsBaseDataResponse; |
| | | import com.doumee.core.wms.model.response.WmsBaseResponse; |
| | | import com.doumee.dao.admin.request.JkOrdersImport; |
| | | import com.doumee.dao.admin.request.SketchCateModel; |
| | | import com.doumee.dao.business.*; |
| | | import com.doumee.dao.business.dto.TelecomLineInfoDTO; |
| | | import com.doumee.dao.business.model.*; |
| | |
| | | c.setNeedList(Constants.equalsInteger(model.getForceUpdate(),0)?needList:customerList); |
| | | return c; |
| | | } |
| | | |
| | | /** |
| | | * å¼å§å¼æ¥æ§è¡çº¿è·¯ä¼åä»»å¡ |
| | | * @param model |
| | |
| | | @Async |
| | | public void startUpdateLineAsync(JkSketch model) { |
| | | try { |
| | | int maxnum =100,distance = 500; |
| | | try { |
| | | maxnum = Integer.parseInt(systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.JK_PLAN_MAX_CLUSTER).getCode()); |
| | | distance = Integer.parseInt(systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.JK_PLAN_DISTANCE_CLUSTER).getCode()); |
| | | }catch (Exception e){ |
| | | } |
| | | List<JkSketchCustomer> allCustomerList = model.getCustomerList(); |
| | | //两å
¬éå
æ°æ®å®¢æ·åå¹¶ |
| | | // List<SketchCateModel> customerList =Clustering.clusterPoints(allCustomerList,1000); |
| | | List<SketchCateModel> customerList = new ClusterCustomKMeans().clusterPoints(allCustomerList,maxnum,distance); |
| | | List<JkLine> lineList = model.getLineList(); |
| | | TspSolver.DataModel dataModel = new TspSolver.DataModel(); |
| | | int vehicleNumber1 = lineList.size();//线路æ°é |
| | | long[] vehicleCapacities1=new long[lineList.size()];//æ¯è¾è½¦çæå¤§è®¢åééå¶ |
| | | long[] vehicleMaxNodes=new long[lineList.size()];//æ¯è¾è½¦çæå¤§è®¢åééå¶ |
| | | long[] demands1 = new long[customerList.size()+1]; //å个ç¹ç订åé |
| | | long[] demands2 = new long[customerList.size()+1]; //å个ç¹ç客æ¶é |
| | | long[][] distanceMatrix1 = new long[customerList.size()+1][customerList.size()+1]; |
| | | distanceMatrix1[0][0] = 0; |
| | | demands1[0] =0;//åç¹ |
| | | demands2[0] =0;//åç¹ |
| | | for (int i = 0; i < customerList.size(); i++) { |
| | | List<DistanceMapParam> disList = customerList.get(i).getStartPoint().getDistanceMapParamList(); |
| | | distanceMatrix1[0][i+1] = disList.get(0).getDistance(); |
| | | distanceMatrix1[i+1][0] = disList.get(disList.size() -1).getDistance(); |
| | | demands1[i+1] = Constants.formatBigdecimal( customerList.get(i).getTotalNum()).longValue(); //å个ç¹ç订åé |
| | | demands2[i+1] = customerList.get(i).getTotalCustomer(); //å个ç¹ç订åé |
| | | for (int j = 0; j < customerList.size(); j++) { |
| | | distanceMatrix1[i+1][j+1] =disList.get(j+1).getDistance() ; |
| | | } |
| | | } |
| | | for (int i = 0; i < lineList.size(); i++) { |
| | | vehicleCapacities1[i] = lineList.get(i).getMaxOrder();//æ¯è¾è½¦çæå¤§è®¢åééå¶ |
| | | vehicleMaxNodes[i] =lineList.get(i).getMaxCustomer();//æå¤§å®¢æ·æ° |
| | | } |
| | | //æé ä¼åæ°æ®æ¨¡å |
| | | dataModel.initDataInfo(vehicleNumber1,demands1,demands2,vehicleCapacities1,distanceMatrix1,vehicleMaxNodes); |
| | | TspSolver.startSearch(dataModel); |
| | | JkSketch nowModel = jkSketchMapper.selectById(model.getId()); |
| | | if(StringUtils.equals(model.getJobId(), nowModel.getJobId())){ |
| | | log.error( "ä¼åç»æå·²å¤±æï¼éæè¿ä¸æ¬¡æä½ï¼"); |
| | | return; |
| | | } |
| | | dealSearchSolution(model, customerList,dataModel); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | jkSketchMapper.update(null,new UpdateWrapper<JkSketch>().lambda() |
| | | .eq(JkSketch::getId,model.getId() ) |
| | | .eq(JkSketch::getJobId,model.getJobId() ) |
| | | .set(JkSketch::getPlanLineInfo,"æè¿ä¸æ¬¡çº¿è·¯ä¼å失败ï¼"+e.getMessage()) |
| | | .set(JkSketch::getStatus,Constants.THREE) |
| | | .set(JkSketch::getPlanLineEndDate,new Date())); |
| | | } |
| | | } |
| | | |
| | | private List<JkSketchCustomer> getCustomerCateList(List<JkSketchCustomer> allCustomerList) { |
| | | List<JkSketchCustomer> list = new ArrayList<>(); |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * å¼å§å¼æ¥æ§è¡çº¿è·¯ä¼åä»»å¡ |
| | | * @param model |
| | | */ |
| | | @Override |
| | | @Async |
| | | public void startUpdateLineAsyncOld(JkSketch model) { |
| | | try { |
| | | List<JkSketchCustomer> customerList = model.getCustomerList(); |
| | | List<JkLine> lineList = model.getLineList(); |
| | | TspSolver.DataModel dataModel = new TspSolver.DataModel(); |
| | |
| | | long[] vehicleCapacities1=new long[lineList.size()];//æ¯è¾è½¦çæå¤§è®¢åééå¶ |
| | | long[] vehicleMaxNodes=new long[lineList.size()];//æ¯è¾è½¦çæå¤§è®¢åééå¶ |
| | | long[] demands1 = new long[customerList.size()+1]; //å个ç¹ç订åé |
| | | long[] demands2 = new long[customerList.size()+1]; //å个ç¹ç客æ·é |
| | | long[][] distanceMatrix1 = new long[customerList.size()+1][customerList.size()+1]; |
| | | distanceMatrix1[0][0] = 0; |
| | | demands1[0] =0;//åç¹ |
| | |
| | | distanceMatrix1[0][i+1] = disList.get(0).getDistance(); |
| | | distanceMatrix1[i+1][0] = disList.get(disList.size() -1).getDistance(); |
| | | demands1[i+1] = Constants.formatBigdecimal( customerList.get(i).getTotalNum()).longValue(); //å个ç¹ç订åé |
| | | demands2[i+1] =1; //å个ç¹ç订åé |
| | | for (int j = 0; j < customerList.size(); j++) { |
| | | distanceMatrix1[i+1][j+1] =disList.get(j+1).getDistance() ; |
| | | } |
| | |
| | | vehicleMaxNodes[i] =lineList.get(i).getMaxCustomer();//æå¤§å®¢æ·æ° |
| | | } |
| | | //æé ä¼åæ°æ®æ¨¡å |
| | | dataModel.initDataInfo(vehicleNumber1,demands1,vehicleCapacities1,distanceMatrix1,vehicleMaxNodes); |
| | | dataModel.initDataInfo(vehicleNumber1,demands1,demands2,vehicleCapacities1,distanceMatrix1,vehicleMaxNodes); |
| | | TspSolver.startSearch(dataModel); |
| | | dealSearchSolution(model,dataModel); |
| | | dealSearchSolutionOld(model,dataModel); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | jkSketchMapper.update(null,new UpdateWrapper<JkSketch>().lambda() |
| | |
| | | @Override |
| | | @Async |
| | | public void startEditSketchLineAsync(JkSketch model) { |
| | | boolean success = true; |
| | | int totalDistance = 0; |
| | | List<JkSketchLine> lineList = model.getSketchLineList(); |
| | | try { |
| | | MPJLambdaWrapper<JkSketchCustomer> queryWrapper = new MPJLambdaWrapper<>(); |
| | | queryWrapper.selectAll(JkSketchCustomer.class ) |
| | | .selectAs(JkCustomer::getName,JkSketchCustomer::getName) |
| | | .selectAs(JkCustomer::getCode,JkSketchCustomer::getCode) |
| | | .selectAs(JkCustomer::getDistance,JkSketchCustomer::getDistanceJson) |
| | | .selectAs(JkCustomer::getLongitude,JkSketchCustomer::getLongitude) |
| | | .selectAs(JkCustomer::getLatitude,JkSketchCustomer::getLatitude) |
| | | .selectAs(JkCustomer::getStartDistance,JkSketchCustomer::getStartDistance) |
| | | .selectAs(JkCustomer::getEndDistance,JkSketchCustomer::getEndDistance) |
| | | .leftJoin(JkCustomer.class,JkCustomer::getId,JkSketchCustomer::getCustomerId ) |
| | | .eq(JkSketchCustomer::getType, Constants.equalsInteger(model.getOptStatus(),Constants.ONE)?1:0) |
| | | .eq(JkSketchCustomer::getSketchId, model.getId()) |
| | | .eq(JkSketchCustomer::getIsdeleted,Constants.ZERO) |
| | | .orderByAsc(JkSketchCustomer::getSortnum); |
| | | List<JkSketchCustomer> customerList = jkSketchCustomerMapper.selectJoinList(JkSketchCustomer.class,queryWrapper); |
| | | if(customerList == null ||customerList.size() ==0){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"该线路客æ·ä¿¡æ¯ä¸ºç©ºï¼ä¸æ»¡è¶³ä¼åæ¡ä»¶ï¼"); |
| | | } |
| | | int maxnum =100,distance = 500; |
| | | try { |
| | | maxnum = Integer.parseInt(systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.JK_PLAN_MAX_CLUSTER).getCode()); |
| | | distance = Integer.parseInt(systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.JK_PLAN_DISTANCE_CLUSTER).getCode()); |
| | | }catch (Exception e){ |
| | | } |
| | | int totalNum = 0; |
| | | for(JkSketchLine line : lineList){ |
| | | //å®å线路客æ·ä¼ååæ° |
| | | List<JkSketchCustomer> customerListParam = line.getCustomerList() ; |
| | | if(customerListParam ==null || customerListParam.size()==0){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | initSketchCustomerListParam(line.getCustomerList(),customerList) ; |
| | | totalNum += customerListParam.size(); |
| | | } |
| | | if(totalNum != Constants.formatIntegerNum(model.getOrderNum())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | for(JkSketchLine line : lineList){ |
| | | //é个路线ä¼å |
| | | List<JkSketchCustomer> allCustomerListParam = line.getCustomerList() ; |
| | | // List<SketchCateModel> customerListParam = Clustering.clusterPoints(allCustomerListParam,1000); |
| | | List<SketchCateModel> customerListParam = new ClusterCustomKMeans().clusterPoints(allCustomerListParam,maxnum,distance); |
| | | TspSolver.DataModel dataModel = new TspSolver.DataModel(); |
| | | int vehicleNumber1 = 1;//线路æ°é |
| | | long[] vehicleCapacities1=new long[]{line.getMaxOrder()};//æ¯è¾è½¦çæå¤§è®¢åééå¶ |
| | | long[] vehicleMaxNodes=new long[]{line.getMaxCustomer()};//æ¯è¾è½¦çæå¤§è®¢åééå¶ |
| | | long[] demands1 = new long[customerListParam.size()+1]; //å个ç¹ç订åé |
| | | long[] demands2 = new long[customerListParam.size()+1]; //å个ç¹ç订åé |
| | | long[][] distanceMatrix1 = new long[customerListParam.size()+1][customerListParam.size()+1]; |
| | | distanceMatrix1[0][0] = 0; |
| | | demands1[0] =0;//åç¹ |
| | | for (int i = 0; i < customerListParam.size(); i++) { |
| | | List<DistanceMapParam> disList = customerListParam.get(i).getStartPoint().getDistanceMapParamList(); |
| | | distanceMatrix1[0][i+1] = disList.get(0).getDistance(); |
| | | distanceMatrix1[i+1][0] = disList.get(disList.size() -1).getDistance(); |
| | | demands1[i+1] = Constants.formatBigdecimal( customerListParam.get(i).getTotalNum()).longValue(); //å个ç¹ç订åé |
| | | demands2[i+1] = customerListParam.get(i).getTotalCustomer() ; //å个ç¹ç订åé |
| | | for (int j = 0; j < customerListParam.size(); j++) { |
| | | distanceMatrix1[i+1][j+1] =disList.get(j+1).getDistance() ; |
| | | } |
| | | } |
| | | //æé ä¼åæ°æ®æ¨¡å |
| | | dataModel.initDataInfo(vehicleNumber1,demands1,demands2,vehicleCapacities1,distanceMatrix1,vehicleMaxNodes); |
| | | TspSolver.startSearch(dataModel); |
| | | if(dataModel.getSolutions()==null || dataModel.getSolutions().size()==0){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"线路ã"+line.getLineName()+"ãè°æ´å¤±è´¥ ï¼æªè·å¾æä¼äº¤éè§åæ¹æ¡ï¼"); |
| | | } |
| | | JkSketch nowModel = jkSketchMapper.selectById(model.getId()); |
| | | if(StringUtils.equals(model.getJobId(), nowModel.getJobId())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"线路ã"+line.getLineName()+"ãè°æ´å¤±è´¥ ï¼éæè¿ä¸æ¬¡æä½ï¼"); |
| | | } |
| | | |
| | | TspSolverSolutions so = dataModel.getSolutions().get(0); |
| | | List<Integer> routes = so.getRouteIndex(); |
| | | totalDistance += so.getDistance(); |
| | | if(routes.size() <=2) { |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"线路ã"+line.getLineName()+"ãè°æ´å¤±è´¥ ï¼æªè·å¾æä¼äº¤éè§åæ¹æ¡ï¼"); |
| | | } |
| | | int index = 0; |
| | | line.setDistance(so.getDistance()); |
| | | //ææè·¯å¾ |
| | | for (Integer cIndex : routes){ |
| | | if(cIndex ==0){ |
| | | continue; //èµ·å§ç¹ä¸å¤ç |
| | | } |
| | | SketchCateModel cateModel = customerListParam.get(cIndex-1); |
| | | for(int t=0;t<cateModel.getCustomerList().size();t++){ |
| | | JkSketchCustomer customer = cateModel.getCustomerList().get(t); |
| | | customer.setSortnum(index++); |
| | | if(t < cateModel.getCustomerList().size()-1){ |
| | | long tdistance = (long)Clustering.distanceTo(customer, cateModel.getCustomerList().get(t+1)); |
| | | line.setDistance(Constants.formatLongNum(line.getDistance()) +tdistance); |
| | | totalDistance += tdistance; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | success =false; |
| | | }finally { |
| | | if(success){ |
| | | List<JkSketchCustomer> allList = new ArrayList<>(); |
| | | for(JkSketchLine line : lineList){ |
| | | allList.addAll(line.getCustomerList()); |
| | | } |
| | | jkSketchLineMapper.updateById(lineList); |
| | | jkSketchCustomerMapper.updateById(allList); |
| | | } |
| | | jkSketchMapper.update(null,new UpdateWrapper<JkSketch>().lambda() |
| | | .eq(JkSketch::getId,model.getId() ) |
| | | .eq(JkSketch::getJobId,model.getJobId() ) |
| | | .set(success,JkSketch::getDistance,totalDistance) |
| | | .set(JkSketch::getPlanLineInfo,success?"æè¿ä¸æ¬¡çº¿è·¯è°æ´æå":"æè¿ä¸æ¬¡çº¿è·¯è°æ´å¤±è´¥ï¼") |
| | | .set(JkSketch::getStatus,success?Constants.TWO:Constants.THREE) |
| | | .set(JkSketch::getPlanLineEndDate,new Date())); |
| | | } |
| | | } |
| | | @Override |
| | | @Async |
| | | public void startEditSketchLineAsyncOld(JkSketch model) { |
| | | boolean success = true; |
| | | int totalDistance = 0; |
| | | List<JkSketchLine> lineList = model.getSketchLineList(); |
| | |
| | | long[] vehicleCapacities1=new long[]{line.getMaxOrder()};//æ¯è¾è½¦çæå¤§è®¢åééå¶ |
| | | long[] vehicleMaxNodes=new long[]{line.getMaxCustomer()};//æ¯è¾è½¦çæå¤§è®¢åééå¶ |
| | | long[] demands1 = new long[customerListParam.size()+1]; //å个ç¹ç订åé |
| | | long[] demands2 = new long[customerListParam.size()+1]; //å个ç¹ç订åé |
| | | long[][] distanceMatrix1 = new long[customerListParam.size()+1][customerListParam.size()+1]; |
| | | distanceMatrix1[0][0] = 0; |
| | | demands1[0] =0;//åç¹ |
| | |
| | | distanceMatrix1[0][i+1] = disList.get(0).getDistance(); |
| | | distanceMatrix1[i+1][0] = disList.get(disList.size() -1).getDistance(); |
| | | demands1[i+1] = Constants.formatBigdecimal( customerListParam.get(i).getTotalNum()).longValue(); //å个ç¹ç订åé |
| | | demands2[i+1] = 1; //å个ç¹ç订åé |
| | | for (int j = 0; j < customerListParam.size(); j++) { |
| | | distanceMatrix1[i+1][j+1] =disList.get(j+1).getDistance() ; |
| | | } |
| | | } |
| | | //æé ä¼åæ°æ®æ¨¡å |
| | | dataModel.initDataInfo(vehicleNumber1,demands1,vehicleCapacities1,distanceMatrix1,vehicleMaxNodes); |
| | | dataModel.initDataInfo(vehicleNumber1,demands1,demands2,vehicleCapacities1,distanceMatrix1,vehicleMaxNodes); |
| | | TspSolver.startSearch(dataModel); |
| | | if(dataModel.getSolutions()==null || dataModel.getSolutions().size()==0){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"线路ã"+line.getLineName()+"ãè°æ´å¤±è´¥ ï¼æªè·å¾æä¼äº¤éè§åæ¹æ¡ï¼"); |
| | |
| | | DistanceMapParam t = new DistanceMapParam(); |
| | | t.setId(cm.getCustomerId()); |
| | | DistanceMapParam param = getParamByCustomerIds( cm.getCustomerId(),distanceMapParamList); |
| | | if(param!=null){//妿ä¹åå·²ç»è·åè¿ |
| | | if(param!=null && t.getDistance()>0){//妿ä¹åå·²ç»è·åè¿ |
| | | t = param; |
| | | }else{ |
| | | //妿æªè§åï¼æç
§ç´çº¿è·ç¦» |
| | |
| | | int index =0; |
| | | for(JkSketchCustomer c : customers){ |
| | | if(index ==0){ |
| | | if(Constants.formatLongNum(c.getStartDistance()) >0){ |
| | | lineDistance+= Constants.formatLongNum(c.getStartDistance()); |
| | | }else{ |
| | | lineDistance += DistanceCalculator.calculateDistanceDecinal(c.getLatitude(),c.getLongitude(),cLatitude,cLongitude); |
| | | } |
| | | } |
| | | if(index == customers.size()-1){ |
| | | if(Constants.formatLongNum(c.getEndDistance())>0){ |
| | | lineDistance+= Constants.formatLongNum(c.getEndDistance()); |
| | | }else{ |
| | | lineDistance += DistanceCalculator.calculateDistanceDecinal(c.getLatitude(),c.getLongitude(),cLatitude,cLongitude); |
| | | } |
| | | break; |
| | | } |
| | | DistanceMapParam param = getParamByCustomerIds( customers.get(index+1).getCustomerId(),getListFromJsonStr(c.getDistanceJson())); |
| | | lineDistance += param.getDistance(); |
| | | JkSketchCustomer end = customers.get(index+1); |
| | | DistanceMapParam param1 = getParamByCustomerIds(end.getCustomerId(),getListFromJsonStr(c.getDistanceJson())); |
| | | if(param1 !=null && param1.getDistance()>0){ |
| | | lineDistance += param1.getDistance(); |
| | | }else{ |
| | | lineDistance += DistanceCalculator.calculateDistanceDecinal(c.getLatitude(),c.getLongitude(),end.getLatitude(),end.getLongitude()); |
| | | } |
| | | index++; |
| | | /* for(JkSketchCustomer cm : customers){ |
| | | DistanceMapParam param = getParamByCustomerIds( cm.getCustomerId(),getListFromJsonStr(c.getDistanceJson())); |
| | |
| | | return new ArrayList<>(); |
| | | } |
| | | |
| | | private void dealSearchSolution(JkSketch model, TspSolver.DataModel dataModel) { |
| | | private void dealSearchSolution(JkSketch model, List<SketchCateModel> customerList,TspSolver.DataModel dataModel) { |
| | | Date date = new Date(); |
| | | List<TspSolverSolutions> solutions = dataModel.getSolutions(); |
| | | List<JkSketchLine> sketchLineList = new ArrayList<>(); |
| | | List<JkSketchCustomer> sketchCustomerList = new ArrayList<>(); |
| | | long totalDistance = 0l; |
| | | if(solutions!=null && solutions.size()>0){ |
| | | for(TspSolverSolutions so : solutions){ |
| | | List<Integer> routes = so.getRouteIndex(); |
| | | totalDistance+= so.getDistance(); |
| | | if(routes.size() <=2) { |
| | | continue;//æ 客æ·çéææè·¯çº¿ |
| | | } |
| | | JkLine line =model.getLineList().get(so.getLineIndex()); |
| | | JkSketchLine tModel = new JkSketchLine(); |
| | | tModel.setSketchId(model.getId()); |
| | | tModel.setCreator(model.getEditor()); |
| | | tModel.setCreateDate(date); |
| | | tModel.setLineId(line.getId()); |
| | | tModel.setTotalNum(new BigDecimal(0)); |
| | | tModel.setDateInfo(model.getDateInfo()); |
| | | tModel.setType(Constants.ONE); |
| | | tModel.setSortnum(sketchLineList.size()+1); |
| | | tModel.setEditDate(tModel.getCreateDate()); |
| | | tModel.setEditor(tModel.getCreator()); |
| | | tModel.setIsdeleted(Constants.ZERO); |
| | | tModel.setDistance(so.getDistance());// |
| | | sketchLineList.add(tModel); |
| | | tModel.setCustomerList( new ArrayList<>()); |
| | | //ææè·¯å¾ |
| | | for (Integer cIndex : routes){ |
| | | if(cIndex ==0){ |
| | | continue; //èµ·å§ç¹ä¸å¤ç |
| | | } |
| | | // JkSketchCustomer customer = model.getCustomerList().get(cIndex-1); |
| | | // tModel.setTotalNum(tModel.getTotalNum().add(Constants.formatBigdecimal(customer.getTotalNum())));//éè´§é |
| | | SketchCateModel cateModel = customerList.get(cIndex-1); |
| | | tModel.setTotalNum(tModel.getTotalNum().add(Constants.formatBigdecimal(cateModel.getTotalNum())));//éè´§é |
| | | for(int t=0;t<cateModel.getCustomerList().size();t++){ |
| | | JkSketchCustomer customer = cateModel.getCustomerList().get(t); |
| | | JkSketchCustomer cModel = new JkSketchCustomer(); |
| | | cModel.setCreator(tModel.getCreator()); |
| | | cModel.setOrderId(customer.getOrderId()); |
| | | cModel.setCreateDate(tModel.getCreateDate()); |
| | | cModel.setType(Constants.ONE); |
| | | cModel.setTotalNum(customer.getTotalNum()); |
| | | cModel.setDateInfo(model.getDateInfo()); |
| | | cModel.setSortnum(tModel.getCustomerList().size()+1); |
| | | cModel.setEditDate(tModel.getCreateDate()); |
| | | cModel.setEditor(tModel.getCreator()); |
| | | cModel.setIsdeleted(Constants.ZERO); |
| | | cModel.setSketchId(model.getId()); |
| | | cModel.setCustomerId(customer.getCustomerId()); |
| | | if(t < cateModel.getCustomerList().size()-1){ |
| | | long tdistance = (long)Clustering.distanceTo(customer, cateModel.getCustomerList().get(t+1)); |
| | | tModel.setDistance(Constants.formatLongNum(tModel.getDistance()) +tdistance); |
| | | totalDistance += tdistance; |
| | | } |
| | | tModel.getCustomerList().add(cModel); |
| | | } |
| | | tModel.setOrderNum( tModel.getCustomerList().size()); |
| | | } |
| | | } |
| | | } |
| | | if(sketchLineList!=null && sketchLineList.size()>0){ |
| | | jkSketchLineMapper.update(null,new UpdateWrapper<JkSketchLine>().lambda() |
| | | .set(JkSketchLine::getIsdeleted,Constants.ONE) |
| | | .eq(JkSketchLine::getIsdeleted,Constants.ZERO) |
| | | .eq(JkSketchLine::getType,Constants.ONE) |
| | | .eq(JkSketchLine::getSketchId,model.getId()) |
| | | .eq(JkSketchLine::getDateInfo,model.getDateInfo())); |
| | | jkSketchCustomerMapper.update(null,new UpdateWrapper<JkSketchCustomer>().lambda() |
| | | .set(JkSketchCustomer::getIsdeleted,Constants.ONE) |
| | | .eq(JkSketchCustomer::getIsdeleted,Constants.ZERO) |
| | | .eq(JkSketchCustomer::getType,Constants.ONE) |
| | | .eq(JkSketchCustomer::getSketchId,model.getId()) |
| | | .eq(JkSketchCustomer::getDateInfo,model.getDateInfo())); |
| | | if(sketchLineList.size()>0){ |
| | | jkSketchLineMapper.insert(sketchLineList); |
| | | } |
| | | for(JkSketchLine l : sketchLineList){ |
| | | if(l.getCustomerList()!=null ){ |
| | | for(JkSketchCustomer c :l.getCustomerList()){ |
| | | c.setSketchLineId(l.getId()); |
| | | } |
| | | sketchCustomerList.addAll(l.getCustomerList()); |
| | | } |
| | | } |
| | | if(sketchCustomerList.size()>0){ |
| | | jkSketchCustomerMapper.insert(sketchCustomerList); |
| | | } |
| | | jkSketchMapper.update(null,new UpdateWrapper<JkSketch>().lambda() |
| | | .eq(JkSketch::getId,model.getId() ) |
| | | // .eq(JkSketch::getJobId,model.getJobId() ) |
| | | .set(JkSketch::getLineNum,sketchLineList.size() ) |
| | | .set(JkSketch::getOptStatus,Constants.ONE)//å·²çæä¼å线路 |
| | | .set(JkSketch::getDistance,totalDistance) |
| | | .set(JkSketch::getPlanLineInfo,"æè¿ä¸æ¬¡çº¿è·¯ä¼åæåï¼ä¼ååæ»è·ç¦»ï¼"+(totalDistance/1000)+"å
¬éï¼") |
| | | .set(JkSketch::getStatus,Constants.TWO) |
| | | .set(JkSketch::getPlanLineEndDate,date)); |
| | | }else{ |
| | | jkSketchMapper.update(null,new UpdateWrapper<JkSketch>().lambda() |
| | | .eq(JkSketch::getId,model.getId() ) |
| | | // .eq(JkSketch::getJobId,model.getJobId() ) |
| | | .set(JkSketch::getPlanLineInfo,"æè¿ä¸æ¬¡çº¿è·¯ä¼å失败,æªæ¾å°æä¼è·¯çº¿ï¼") |
| | | .set(JkSketch::getStatus,Constants.THREE) |
| | | .set(JkSketch::getPlanLineEndDate,date)); |
| | | } |
| | | } |
| | | private void dealSearchSolutionOld(JkSketch model, TspSolver.DataModel dataModel) { |
| | | Date date = new Date(); |
| | | List<TspSolverSolutions> solutions = dataModel.getSolutions(); |
| | | List<JkSketchLine> sketchLineList = new ArrayList<>(); |
| | |
| | | .set(JkSketchLine::getIsdeleted,Constants.ONE) |
| | | .eq(JkSketchLine::getIsdeleted,Constants.ZERO) |
| | | .eq(JkSketchLine::getType,Constants.ONE) |
| | | .eq(JkSketchLine::getSketchId,model.getId()) |
| | | .eq(JkSketchLine::getDateInfo,model.getDateInfo())); |
| | | jkSketchCustomerMapper.update(null,new UpdateWrapper<JkSketchCustomer>().lambda() |
| | | .set(JkSketchCustomer::getIsdeleted,Constants.ONE) |
| | | .eq(JkSketchCustomer::getIsdeleted,Constants.ZERO) |
| | | .eq(JkSketchCustomer::getType,Constants.ONE) |
| | | .eq(JkSketchCustomer::getSketchId,model.getId()) |
| | | .eq(JkSketchCustomer::getDateInfo,model.getDateInfo())); |
| | | if(sketchLineList.size()>0){ |
| | | jkSketchLineMapper.insert(sketchLineList); |
| | |
| | | return null; |
| | | } |
| | | @Override |
| | | public String syncHkBroadcastDevice(Device param){ |
| | | |
| | | return null; |
| | | } |
| | | @Override |
| | | // @Async |
| | | public String syncPrivilege(PrivilegeGroupRequest param){ |
| | | |
| | |
| | | Constants.DEALING_HK_SYNCDEVICE =false; |
| | | } |
| | | } |
| | | @Override |
| | | // @Async |
| | | public String syncHkBroadcastDevice(Device param){ |
| | | if(Constants.DEALING_HK_SYNCDEVICE){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "忥任塿£å¨æ§è¡å¦ï¼è¯·ç¨åæ¥çç»æï¼") ; |
| | | } |
| | | Constants.DEALING_HK_SYNCDEVICE =true; |
| | | try { |
| | | List<Device> deleteList = new ArrayList<>(); |
| | | List<Device> addList = new ArrayList<>(); |
| | | List<Device> editList = new ArrayList<>(); |
| | | Date date = new Date(); |
| | | //æ¥è¯¢å
¨é¨å¹¿æç¹è®¾å¤æ°æ® |
| | | List<Device> allList = deviceMapper.selectList(new QueryWrapper<Device>().lambda() |
| | | .eq(Device::getType,Constants.FOUR)); |
| | | List<FetchAudioDeviceInfoResponse> allHkList = getAllBroadcastDeviceList(); |
| | | /** |
| | | * è·åå¢å æ¹æ°æ®éå |
| | | */ |
| | | getBroadcastDeviceDataChangeList(allList,allHkList,addList,editList,deleteList,date); |
| | | if(deleteList.size()>0){ |
| | | //é»è¾å é¤ |
| | | for(Device d : deleteList){ |
| | | deviceMapper.updateById(d); |
| | | } |
| | | } |
| | | if(addList.size()>0){ |
| | | deviceMapper.insert(addList); |
| | | } |
| | | if(editList.size()>0){ |
| | | for(Device d : editList){ |
| | | deviceMapper.updateById(d); |
| | | } |
| | | } |
| | | return "åæ¥æ°æ®ï¼æ°å¢ã"+addList.size()+"ãæ¡ï¼æ´æ°ã"+editList.size()+"ãæ¡ï¼å é¤ã"+deleteList.size()+"ãæ¡"; |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "åæ¥å¤±è´¥ï¼"); |
| | | }finally { |
| | | Constants.DEALING_HK_SYNCDEVICE =false; |
| | | } |
| | | } |
| | | |
| | | private void getBroadcastDataChangeList(List<Device> allList, List<FetchAudioChannelInfoResponse> allHkList, List<Device> addList, List<Device> editList, List<Device> deleteList, Date date) { |
| | | if(allHkList!=null && allHkList.size()>0){ |
| | |
| | | } |
| | | //夿è·åå é¤çé¨ç¦è®¾å¤ï¼é»è¾å é¤ |
| | | getDeleteBroadcastList(allList,allHkList,deleteList,date); |
| | | } |
| | | private void getBroadcastDeviceDataChangeList(List<Device> allList, List<FetchAudioDeviceInfoResponse> allHkList, List<Device> addList, List<Device> editList, List<Device> deleteList, Date date) { |
| | | if(allHkList!=null && allHkList.size()>0){ |
| | | //è·å海康å
¨é¨é¨ç¦ç»æ°æ® |
| | | for(FetchAudioDeviceInfoResponse device : allHkList){ |
| | | Device model = getExistedBroadcastDevice(device,allList); |
| | | if(model !=null){ |
| | | //妿已åå¨ï¼åæ´æ°æ°æ® |
| | | model = initBroadcastDeviceDataByHkData(model,device,date); |
| | | editList.add(model); |
| | | }else{ |
| | | //妿ä¸åå¨ï¼åæ°å¢æ°æ® |
| | | model = new Device(); |
| | | model = initBroadcastDeviceDataByHkData(model,device,date); |
| | | model.setIsEntrance(Constants.ZERO); |
| | | addList.add(model); |
| | | } |
| | | } |
| | | } |
| | | //夿è·åå é¤çé¨ç¦è®¾å¤ï¼é»è¾å é¤ |
| | | getDeleteBroadcastDeviceList(allList,allHkList,deleteList,date); |
| | | } |
| | | |
| | | @Override |
| | |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "对ä¸èµ·ï¼æµ·åº·åæ¥æ°æ®å¤±è´¥~"); |
| | | } |
| | | BaseListPageResponse<FetchAudioChannelInfoResponse> r = response.getData(); |
| | | curTotal += 100; |
| | | if(curTotal >= r.getTotal()){ |
| | | hasNext = false; |
| | | } |
| | | if(r.getList() == null || r.getList().size()==0){ |
| | | hasNext =false; |
| | | }else{ |
| | | allDoorList.addAll(r.getList()); |
| | | } |
| | | curPage++; |
| | | } |
| | | return allDoorList; |
| | | } |
| | | /** |
| | | * è·åå
¨é¨å¹¿æç¹æ°æ® |
| | | * @return |
| | | */ |
| | | public List<FetchAudioDeviceInfoResponse> getAllBroadcastDeviceList(){ |
| | | List<FetchAudioDeviceInfoResponse> allDoorList = new ArrayList<>(); |
| | | Date date = new Date(); |
| | | boolean hasNext = true; |
| | | int curTotal = 0; |
| | | int curPage = 1; |
| | | while (hasNext){ |
| | | //å页éåå¾ªç¯æ¥è¯¢ææé¨ç¦è®¾å¤æ°æ® |
| | | FetchAudioDeviceRequest param = new FetchAudioDeviceRequest(); |
| | | param.setPageNo(curPage); |
| | | param.setPageSize(100); |
| | | BaseResponse<BaseListPageResponse<FetchAudioDeviceInfoResponse>> response = HKService.fetchAudioDevice(param); |
| | | if(response == null || !StringUtils.equals(response.getCode(), HKConstants.RESPONSE_SUCCEE)){ |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "对ä¸èµ·ï¼æµ·åº·åæ¥æ°æ®å¤±è´¥~"); |
| | | } |
| | | BaseListPageResponse<FetchAudioDeviceInfoResponse> r = response.getData(); |
| | | curTotal += 100; |
| | | if(curTotal >= r.getTotal()){ |
| | | hasNext = false; |
| | |
| | | model.setResourceType(device.getAudioChannelType()); |
| | | model.setStatus(device.getState()); |
| | | model.setRegionName(device.getRegionName()); |
| | | return model; |
| | | } |
| | | private Device initBroadcastDeviceDataByHkData(Device model, FetchAudioDeviceInfoResponse device, Date date) { |
| | | model.setIsdeleted(Constants.ZERO); |
| | | model.setHkDate(date); |
| | | model.setHkId(device.getDeviceIndexCode()); |
| | | model.setName(device.getDeviceName()); |
| | | model.setHkStatus(Constants.ONE); |
| | | model.setType(Constants.THREE); |
| | | model.setChannelNo(device.getDeviceCode()); |
| | | model.setChannelInfo(device.getDeviceType()); |
| | | model.setResourceType(device.getDeviceType()); |
| | | model.setStatus(Constants.ZERO); |
| | | model.setRemark(device.getDesc()); |
| | | model.setRegionName(device.getRegionIndexCode()); |
| | | return model; |
| | | } |
| | | private Device initDoorDataByHkData(Device model, DoorsInfoResponse door, Date date, List<AcsDeviceInfoResponse> allHkList) { |
| | |
| | | } |
| | | return null; |
| | | } |
| | | private Device getExistedBroadcastDevice(FetchAudioDeviceInfoResponse device, List<Device> allList) { |
| | | if(allList.size()>0){ |
| | | for(Device r : allList){ |
| | | if(StringUtils.equals(r.getHkId(), device.getDeviceIndexCode())){ |
| | | //表示æªå é¤ |
| | | return r; |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | private Device getExistedDevice(AcsDeviceInfoResponse device, List<Device> allList) { |
| | | if(allList.size()>0){ |
| | | for(Device r : allList){ |
| | |
| | | private void getDeleteBroadcastList(List<Device> allList, List<FetchAudioChannelInfoResponse> allHkList,List<Device> deleteList ,Date date) { |
| | | if(allList!=null && allList.size()>0){ |
| | | for(Device device : allList){ |
| | | if(isDeletedBroadcast(device,allHkList)){ |
| | | device.setIsdeleted(Constants.ONE); |
| | | device.setEditDate(date); |
| | | deleteList.add(device); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | private void getDeleteBroadcastDeviceList(List<Device> allList, List<FetchAudioDeviceInfoResponse> allHkList,List<Device> deleteList ,Date date) { |
| | | if(allList!=null && allList.size()>0){ |
| | | for(Device device : allList){ |
| | | if(isDeletedBroadcastDevice(device,allHkList)){ |
| | | device.setIsdeleted(Constants.ONE); |
| | | device.setEditDate(date); |
| | |
| | | return true; |
| | | |
| | | } |
| | | private boolean isDeletedBroadcastDevice(Device device, List<FetchAudioChannelInfoResponse> allHkList) { |
| | | private boolean isDeletedBroadcast(Device device, List<FetchAudioChannelInfoResponse> allHkList) { |
| | | if(allHkList.size()>0){ |
| | | for(FetchAudioChannelInfoResponse r : allHkList){ |
| | | if(StringUtils.equals(device.getHkId(), r.getAudioChannelIndexCode())){ |
| | |
| | | return true; |
| | | |
| | | } |
| | | private boolean isDeletedBroadcastDevice(Device device, List<FetchAudioDeviceInfoResponse> allHkList) { |
| | | if(allHkList.size()>0){ |
| | | for(FetchAudioDeviceInfoResponse r : allHkList){ |
| | | if(StringUtils.equals(device.getHkId(), r.getDeviceIndexCode())){ |
| | | //表示æªå é¤ |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | return true; |
| | | |
| | | } |
| | | private boolean isDeletedDevice(Device device, List<AcsDeviceInfoResponse> allHkList) { |
| | | if(allHkList.size()>0){ |
| | | for(AcsDeviceInfoResponse r : allHkList){ |