| | |
| | | }) |
| | | } |
| | | |
| | | // æ¥è¯¢ |
| | | export function allList (data) { |
| | | return request.post('/visitsAdmin/cloudService/business/jkSketchCustomer/allList', data, { |
| | | trim: true |
| | | }) |
| | | } |
| | | |
| | | // 导åºExcel |
| | | export function exportExcel (data) { |
| | | return request.post('/visitsAdmin/cloudService/business/jkSketchCustomer/exportExcel', data, { |
| | |
| | | <template> |
| | | <GlobalWindow |
| | | :title="title" |
| | | width="85%" |
| | | :visible.sync="visible" |
| | | :confirm-working="isWorking" |
| | | @confirm="confirm" |
| | | > |
| | | <el-form :model="form" ref="form" :rules="rules"> |
| | | <el-form-item label="å建人ç¼ç " prop="creator"> |
| | | <el-input v-model="form.creator" placeholder="请è¾å
¥å建人ç¼ç " v-trim/> |
| | | <TableLayout > |
| | | <!-- æç´¢è¡¨å --> |
| | | <el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="100px" inline> |
| | | <el-form-item label="客æ·åç§°" prop="name"> |
| | | <el-input v-model="searchForm.name" placeholder="请è¾å
¥å®¢æ·åç§°" @keypress.enter.native="search"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="å建æ¶é´" prop="createDate"> |
| | | <el-date-picker v-model="form.createDate" value-format="yyyy-MM-dd" placeholder="请è¾å
¥å建æ¶é´"></el-date-picker> |
| | | <el-form-item label="客æ·ç®ç " prop="code"> |
| | | <el-input v-model="searchForm.code" placeholder="请è¾å
¥å®¢æ·ç®ç " @keypress.enter.native="search"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="æ´æ°äººç¼ç " prop="editor"> |
| | | <el-input v-model="form.editor" placeholder="请è¾å
¥æ´æ°äººç¼ç " v-trim/> |
| | | </el-form-item> |
| | | <el-form-item label="æ´æ°æ¶é´" prop="editDate"> |
| | | <el-date-picker v-model="form.editDate" value-format="yyyy-MM-dd" placeholder="请è¾å
¥æ´æ°æ¶é´"></el-date-picker> |
| | | </el-form-item> |
| | | <el-form-item label="æ¯å¦å é¤0å¦ 1æ¯" prop="isdeleted"> |
| | | <el-input v-model="form.isdeleted" placeholder="请è¾å
¥æ¯å¦å é¤0å¦ 1æ¯" v-trim/> |
| | | </el-form-item> |
| | | <el-form-item label="夿³¨" prop="info"> |
| | | <el-input v-model="form.info" placeholder="请è¾å
¥å¤æ³¨" v-trim/> |
| | | </el-form-item> |
| | | <el-form-item label="线路ç¼ç ï¼å
³èjk_sketch_line)" prop="sketchLineId"> |
| | | <el-input v-model="form.sketchLineId" placeholder="请è¾å
¥çº¿è·¯ç¼ç ï¼å
³èjk_sketch_line)" v-trim/> |
| | | </el-form-item> |
| | | <el-form-item label="线路ä¼åç¼ç ï¼å
³èjk_sketch)" prop="sketchId"> |
| | | <el-input v-model="form.sketchId" placeholder="请è¾å
¥çº¿è·¯ä¼åç¼ç ï¼å
³èjk_sketch)" v-trim/> |
| | | </el-form-item> |
| | | <el-form-item label="éè´§é" prop="totalNum"> |
| | | <el-input v-model="form.totalNum" placeholder="请è¾å
¥éè´§é" v-trim/> |
| | | </el-form-item> |
| | | <el-form-item label="å®¢æ·æ°" prop="orderNum"> |
| | | <el-input v-model="form.orderNum" placeholder="请è¾å
¥å®¢æ·æ°" v-trim/> |
| | | </el-form-item> |
| | | <el-form-item label="æåºç " prop="sortnum"> |
| | | <el-input v-model="form.sortnum" placeholder="请è¾å
¥æåºç " v-trim/> |
| | | </el-form-item> |
| | | <el-form-item label="æ¥æ" prop="dateInfo"> |
| | | <el-date-picker v-model="form.dateInfo" value-format="yyyy-MM-dd" placeholder="请è¾å
¥æ¥æ"></el-date-picker> |
| | | </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> |
| | | <el-table |
| | | :height="tableHeightNew" |
| | | v-loading="isWorking.search" |
| | | :data="tableData.list" |
| | | stripe |
| | | @selection-change="handleSelectionChange" |
| | | > |
| | | <el-table-column prop="sortnum" label="客æ·åºå·" min-width="100px"></el-table-column> |
| | | <el-table-column prop="code" label="客æ·ç®ç " min-width="120px"></el-table-column> |
| | | <el-table-column prop="name" label="客æ·åç§°" min-width="120px"></el-table-column> |
| | | <el-table-column prop="lineName" label="线路åç§°" min-width="180px" show-tooltip-when-overflow></el-table-column> |
| | | <el-table-column prop="totalNum" label="éè´§é(æ¡)" min-width="120px"></el-table-column> |
| | | <el-table-column prop="dateInfo" label="éè´§æ¥æ" min-width="120px"></el-table-column> |
| | | </el-table> |
| | | <pagination |
| | | @size-change="handleSizeChange" |
| | | @current-change="handlePageChange" |
| | | :pagination="tableData.pagination" |
| | | > |
| | | </pagination> |
| | | </template> |
| | | </TableLayout> |
| | | <template v-slot:footer> |
| | | <el-button @click="visible=false">è¿å</el-button> |
| | | </template> |
| | | </GlobalWindow> |
| | | </template> |
| | | |
| | | <script> |
| | | import BaseOpera from '@/components/base/BaseOpera' |
| | | import BaseTable from '@/components/base/BaseTable' |
| | | import TableLayout from '@/layouts/TableLayout' |
| | | import Pagination from '@/components/common/Pagination' |
| | | import GlobalWindow from '@/components/common/GlobalWindow' |
| | | export default { |
| | | name: 'OperaJkSketchCustomerWindow', |
| | | extends: BaseOpera, |
| | | components: { GlobalWindow }, |
| | | extends: BaseTable, |
| | | components: { GlobalWindow, TableLayout, Pagination }, |
| | | data () { |
| | | return { |
| | | // è¡¨åæ°æ® |
| | | form: { |
| | | id: null, |
| | | creator: '', |
| | | createDate: '', |
| | | editor: '', |
| | | editDate: '', |
| | | isdeleted: '', |
| | | info: '', |
| | | visible: false, |
| | | title: '', |
| | | searchForm: { |
| | | sketchLineId: '', |
| | | sketchId: '', |
| | | totalNum: '', |
| | | orderNum: '', |
| | | sortnum: '', |
| | | dateInfo: '' |
| | | }, |
| | | // éªè¯è§å |
| | | rules: { |
| | | name: '', |
| | | code: '' |
| | | } |
| | | } |
| | | }, |
| | | created () { |
| | | this.config({ |
| | | module: '交æ§-线路ä¼å线路客æ·è®°å½ä¿¡æ¯è¡¨', |
| | | api: '/business/jkSketchCustomer', |
| | | 'field.id': 'id' |
| | | 'field.id': 'id', |
| | | 'field.main': 'id' |
| | | }) |
| | | this.search() |
| | | }, |
| | | methods: { |
| | | open (title, row) { |
| | | this.title = title + (row.lineName) |
| | | this.searchForm.sketchLineId = row.id |
| | | this.visible = true |
| | | this.tableData = { |
| | | // å·²éä¸çæ°æ® |
| | | selectedRows: [], |
| | | // æåºçåæ®µ |
| | | sorts: [], |
| | | // å½åé¡µæ°æ® |
| | | list: [], |
| | | // å页 |
| | | pagination: { |
| | | pageIndex: 1, |
| | | pageSize: 10, |
| | | total: 0 |
| | | } |
| | | } |
| | | this.search() |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | |
| | | <el-table-column prop="totalNum" label="éè´§é(æ¡)" min-width="130px"></el-table-column> |
| | | <el-table-column prop="carCode" label="车çå·" min-width="100px"></el-table-column> |
| | | <el-table-column prop="memberName" label="éè´§å¸æº" min-width="100px"></el-table-column> |
| | | <el-table-column prop="distance" label="æ»è·¯ç¨(å
Ž)" min-width="100px"> |
| | | <template slot-scope="{row}"> |
| | | {{((row.distance ||0)/1000).toFixed(2)}} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column |
| | | label="æä½" |
| | | min-width="120" |
| | | align="center" |
| | | fixed="right" |
| | | > |
| | | <template slot-scope="{row}"> |
| | | <el-button type="text" @click="$refs.operaJkSketchCustomerWindow.open('çº¿è·¯å®¢æ·æç»ââ', row)" icon="el-icon-view" >æ¥ç客æ·</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | </div> |
| | | </div> |
| | | <template v-slot:footer> |
| | | <el-button @click="visible=false">è¿å</el-button> |
| | | </template> |
| | | <OperaJkSketchCustomerWindow ref="operaJkSketchCustomerWindow" /> |
| | | </GlobalWindow> |
| | | </template> |
| | | |
| | | <script> |
| | | import BaseOpera from '@/components/base/BaseOpera' |
| | | import GlobalWindow from '@/components/common/GlobalWindow' |
| | | import OperaJkSketchCustomerWindow from '@/components/business/OperaJkSketchCustomerWindow' |
| | | export default { |
| | | name: 'OperaJkSketchLineWindow', |
| | | extends: BaseOpera, |
| | | components: { GlobalWindow }, |
| | | components: { GlobalWindow, OperaJkSketchCustomerWindow}, |
| | | data () { |
| | | return { |
| | | // è¡¨åæ°æ® |
| | | model: { |
| | | }, |
| | | dataList:[], |
| | | dataList:[] |
| | | } |
| | | }, |
| | | created () { |
| | |
| | | this.dataList = res |
| | | }) |
| | | }, |
| | | viewCustomer(row){ |
| | | |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | |
| | | <template> |
| | | <el-dialog |
| | | class="center-title" |
| | | <GlobalWindow |
| | | :title="title" |
| | | width="500px" |
| | | top="30vh" |
| | | width="100%" |
| | | :visible.sync="visible" |
| | | :confirm-working="isWorking" |
| | | @confirm="confirm" |
| | | > |
| | | <p class="tip-warn"><i class="el-icon-warning"></i>导å
¥è¯´æï¼<br> |
| | | 1.请å
ä¸è½½æä»¶æ¨¡æ¿ï¼å¹¶æç
§æ¨¡æ¿è¦å»å¡«åè¡¨æ ¼å
容;<br> |
| | | 2.æ¯æ¬¡å¯¼å
¥éå®è®¢å表示å³å é¤ä¹å导å
¥æ¤æ¬¡ç¸åºæ¥æç订åè®°å½ï¼ä»¥æ¤æ¬¡å¯¼å
¥çæ°æ®ä¸ºä¸»;<br> |
| | | </p> |
| | | <el-form class="demo-form-inline" > |
| | | <el-form-item label="线路信æ¯" required> |
| | | <div style="width: 100%;display: flex;align-items: center;"> |
| | | <el-button type="primary" @click="clickRef">ç¹å»ä¸ä¼ </el-button> |
| | | <el-button type="text" @click="exportTemplate">ç¹å»ä¸è½½æ¨¡ç.EXCEL</el-button> |
| | | <div style="display: block;margin-bottom: 30px;"> |
| | | <div style="display: block;font-size: 16px;font-weight: 600;margin-bottom: 20px;">主线路信æ¯</div> |
| | | <div style="display: flex;"> |
| | | <div style="flex: 1">éè´§æ¥æï¼{{model.dateInfo ||''}}</div> |
| | | <div style="flex: 1">主线路ï¼{{model.categoryName ||''}}</div> |
| | | <div style="flex: 1">å®¢æ·æ°ï¼{{model.orderNum ||'-'}}</div> |
| | | <div style="flex: 1">éè´§é(æ¡)ï¼{{model.totalNum ||'-'}}</div> |
| | | </div> |
| | | <div style="font-size: 14px; color: black;" v-if="fileName">{{fileName}}</div> |
| | | </el-form-item> |
| | | </el-form> |
| | | <input type="file" style="position: fixed; left: 0; top: -50px;" accept=".xlsx" ref="fileExcel" @change="result" /> |
| | | <div style="display: flex;margin-top: 30px"> |
| | | <div style="flex: 1">ä¼åæ¶é´ï¼{{model.planLineDate ||''}} - {{model.planLineEndDate ||''}}</div> |
| | | </div> |
| | | <div style="display: flex;margin-top: 20px" class="orange"> |
| | | <div style="flex: 1">ä¼åç»æï¼ä¼ååæ»è·¯ç¨ <span class="red" style="font-weight: bold"> {{((model.originDistance ||0)/1000).toFixed(2)}}</span> å
¬éï¼ä¼ååæ»è·¯ç¨<span class="green" style="font-weight: bold"> {{((model.distance ||0)/1000).toFixed(2)}} </span> å
Ž</div> |
| | | </div> |
| | | </div> |
| | | <div style="display: block"> |
| | | <div style="display: block;font-size: 16px;font-weight: 600;margin-bottom: 10px;">线路æç»</div> |
| | | <div> |
| | | <el-table :data="dataList" stripe :row-class-name="tableRowClassName"> |
| | | <el-table-column prop="dateInfo" label="éè´§æ¥æ" min-width="130px"></el-table-column> |
| | | <el-table-column prop="lineName" label="é货线路" min-width="130px"> </el-table-column> |
| | | <el-table-column prop="orderNum" label="å®¢æ·æ°(æ·)" min-width="130px"> </el-table-column> |
| | | <el-table-column prop="totalNum" label="éè´§é(æ¡)" min-width="130px"></el-table-column> |
| | | <el-table-column prop="carCode" label="车çå·" min-width="100px"></el-table-column> |
| | | <el-table-column prop="memberName" label="éè´§å¸æº" min-width="100px"></el-table-column> |
| | | <el-table-column prop="distance" label="æ»è·¯ç¨(å
Ž)" min-width="100px"> |
| | | <template slot-scope="{row}"> |
| | | {{((row.distance ||0)/1000).toFixed(2)}} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column |
| | | label="æä½" |
| | | min-width="120" |
| | | align="left" |
| | | fixed="right" |
| | | > |
| | | <template slot-scope="{row}"> |
| | | <el-button type="text" @click="updateDo(row)" icon="el-icon-edit" style="color: #0d68ff" v-if="!updating" >å¾®è°</el-button> |
| | | <template v-else-if="updating && currentRow.id ===row.id" > |
| | | <el-button type="text" style="color: #13ce66" >æ¬è½¦</el-button> |
| | | <el-button type="text" @click="cancelDo(row)" icon="el-icon-delete" style="color: red" >åæ¶</el-button> |
| | | </template> |
| | | <el-button type="text" @click="addDo(row)" icon="el-icon-plus" style="color: red" v-else-if="updating && currentRow.id !==row.id" >å å
¥</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | </div> |
| | | </div> |
| | | |
| | | <div style="display: block;margin-top: 30px;border: 1px solid #f2f2f2;padding: 10px" v-if="updating"> |
| | | <div style="display: block;font-size: 16px;font-weight: 600;margin-bottom: 10px;">{{currentRow.lineName}} - å®¢æ·æç»</div> |
| | | <div> |
| | | <p class="tip-warn"><i class="el-icon-warning"></i>æä½è¯´æï¼<br> |
| | | 1.è¯·éæ©è¥å¹²å®¢æ·ä¿¡æ¯ï¼ç¹å»ä¸è¿°å
¶ä»çº¿è·¯åç<span class="red">ãå å
¥ã</span>æé®ï¼å°éä¸ç客æ·ç§»å å°å¯¹åºçº¿è·¯ä¸;<br> |
| | | 2.ç¹å»æ¬è½¦çº¿è·¯åç<span class="red">ãåæ¶ã</span>æé®ï¼å¯æ¤éæ¬è½¦å¾®è°æä½;<br> |
| | | </p> |
| | | <el-table :data="paginatedData" stripe @selection-change="handleSelectionChange">> |
| | | <el-table-column type="selection" width="55"></el-table-column> |
| | | <el-table-column prop="code" label="客æ·ç®ç " min-width="130px"></el-table-column> |
| | | <el-table-column prop="name" label="客æ·åç§°" min-width="130px"> </el-table-column> |
| | | <el-table-column prop="totalNum" label="éè´§é(æ¡)" min-width="130px"></el-table-column> |
| | | <el-table-column prop="location" label="客æ·å°å" min-width="200px" show-tooltip-when-overflow></el-table-column> |
| | | <el-table-column prop="latitude" label="ç»çº¬åº¦" min-width="200px"> |
| | | <template slot-scope="{row}"> |
| | | {{(row.longitude || 0).toFixed(6)}},{{(row.latitude || 0).toFixed(6)}} |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <div class="table-pagination"> |
| | | <el-pagination |
| | | @current-change="handleCurrentChange" |
| | | :current-page="currentPage" |
| | | :page-size="pageSize" |
| | | layout="total, prev, pager, next, jumper" |
| | | :total="totalItems"> |
| | | </el-pagination> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <template v-slot:footer> |
| | | <el-button @click="confirmDo" type="primary" v-if="buttonName!==''">{{ buttonName||'确认' }}</el-button> |
| | | <el-button @click="visible=false">è¿å</el-button> |
| | | </template> |
| | | </el-dialog> |
| | | </GlobalWindow> |
| | | </template> |
| | | |
| | | <script> |
| | | import BaseOpera from '@/components/base/BaseOpera' |
| | | import GlobalWindow from '@/components/common/GlobalWindow' |
| | | import { importExcel } from '@/api/business/jkLine' |
| | | import { allList as customerList } from '@/api/business/jkSketchCustomer' |
| | | export default { |
| | | name: 'OperaJkSketchLineWindow', |
| | | extends: BaseOpera, |
| | | // eslint-disable-next-line vue/no-unused-components |
| | | components: { GlobalWindow }, |
| | | data () { |
| | | return { |
| | | importing:false, |
| | | fileName: '' |
| | | // è¡¨åæ°æ® |
| | | updating: false, |
| | | currentRow: null, |
| | | model: { |
| | | }, |
| | | buttonName: '', |
| | | dataList: [], |
| | | currentPage: 1, |
| | | pageSize: 10, |
| | | totalItems: 0, // æ»æ°æ®æ¡ç®æ° |
| | | allCustomerList: [], |
| | | tableData: [], // æææ°æ® |
| | | selectRows: [] |
| | | } |
| | | }, |
| | | created () { |
| | | this.config({ |
| | | api: '/business/jkSketchLine', |
| | | 'field.id': 'id' |
| | | }) |
| | | }, |
| | | computed: { |
| | | paginatedData () { |
| | | const start = (this.currentPage - 1) * this.pageSize |
| | | const end = start + this.pageSize |
| | | return this.tableData.slice(start, end) |
| | | } |
| | | }, |
| | | methods: { |
| | | open (title) { |
| | | this.title = title |
| | | this.fileName = '' |
| | | confirmDo () { |
| | | |
| | | }, |
| | | open (title, target) { |
| | | this.title = title + target.categoryName |
| | | this.visible = true |
| | | this.model = target |
| | | this.updating = false |
| | | this.selectRows = [] |
| | | this.tableData = [] |
| | | this.allCustomerList = [] |
| | | this.currentRow = null |
| | | this.loadList() |
| | | }, |
| | | // å¯¼åºæ¨¡æ¿ |
| | | exportTemplate () { |
| | | // æä¿ç³è¯· |
| | | window.open('/template/jkLineTemplate.xlsx') |
| | | updateDo (row) { |
| | | this.currentRow = row |
| | | this.tableData = row.customerList || [] |
| | | this.totalItems = this.tableData.length |
| | | this.currentPage = 1 |
| | | this.selectRows = [] |
| | | this.updating = true |
| | | }, |
| | | clickRef () { |
| | | this.$refs.fileExcel.click() |
| | | cancelDo (row) { |
| | | this.selectRows = [] |
| | | this.currentRow = null |
| | | this.updating = false |
| | | }, |
| | | result (e) { |
| | | const data = new FormData() |
| | | data.append('file', e.target.files[0]) |
| | | importExcel(data) |
| | | addDo (row) { |
| | | if (!this.selectRows || !this.selectRows.length) { |
| | | this.$message.error('对ä¸èµ·ï¼è¯·è³å°éæ©æä¸æ¡å®¢æ·è®°å½å å
¥è¯¥è·¯çº¿ï¼') |
| | | return |
| | | } |
| | | const tarray = [] |
| | | let tNum = 0 |
| | | this.currentRow.customerList.forEach(item => { |
| | | let flag = false |
| | | this.selectRows.forEach(item1 => { |
| | | if (item.id === item1.id) { |
| | | flag = true |
| | | } |
| | | }) |
| | | if (!flag) { |
| | | tNum += (item.totalNum || 0) |
| | | tarray.push(item) |
| | | } |
| | | }) |
| | | if(tarray.length === 0){ |
| | | this.$message.error('对ä¸èµ·ï¼æ¬è½¦çº¿è·¯è³å°çåä¸ä¸ªå®¢æ·ä¿¡æ¯ï¼æ æ³å
¨é¨æ¸
空ï¼') |
| | | return |
| | | } |
| | | var rArray = row.customerList || [] |
| | | rArray = rArray.push(...this.selectRows) |
| | | let ttNum = 0 |
| | | rArray.forEach(item => { |
| | | ttNum += (item.totalNum || 0) |
| | | }) |
| | | if(tarray.length >= (row.maxCustomer||0)){ |
| | | this.$message.error('对ä¸èµ·ï¼å å
¥ç线路æå¤§æ¯æ'+ (row.maxOrderNum||0) + '客æ·ï¼') |
| | | return |
| | | } |
| | | if(ttNum >= (row.maxOrder||0)){ |
| | | this.$message.error('对ä¸èµ·ï¼å å
¥ç线路æå¤§æ¯æ'+ (row.maxOrder||0) + 'éè´§éï¼') |
| | | return |
| | | } |
| | | this.currentRow.customerList = tarray |
| | | this.currentRow.orderNum = this.currentRow.customerList.length |
| | | this.currentRow.totalNum = tNum |
| | | row.customerList = rArray |
| | | row.orderNum = row.customerList.length |
| | | row.totalNum = ttNum |
| | | this.currentRow = null |
| | | this.updating = false |
| | | this.buttonName = 'ä¿åè°æ´å¼å§ä¼å' |
| | | }, |
| | | handleSelectionChange (rows) { |
| | | this.selectRows = rows |
| | | }, |
| | | loadCustomerList () { |
| | | customerList({ sketchId: this.model.id }) |
| | | .then(res => { |
| | | this.$message.success('导å
¥æå') |
| | | this.$emit('success') |
| | | this.visible = false |
| | | this.allCustomerList = res |
| | | if (this.allCustomerList && this.allCustomerList.length) { |
| | | this.dataList.forEach(item => { |
| | | var tarray = [] |
| | | this.allCustomerList.forEach(item1 => { |
| | | if (item.id === item1.sketchLineId) { |
| | | tarray.push(item1) |
| | | } |
| | | }) |
| | | .catch(err => { |
| | | // this.$message.error(err) |
| | | this.fileName = '' |
| | | item.customerList = tarray |
| | | }) |
| | | .finally(() => { |
| | | this.$refs.fileExcel.value = null |
| | | } |
| | | }) |
| | | }, |
| | | loadList () { |
| | | this.api.allList({ |
| | | sketchId: this.model.id |
| | | }).then(res => { |
| | | this.dataList = res |
| | | this.loadCustomerList() |
| | | }) |
| | | }, |
| | | tableRowClassName ({ row, rowIndex }) { |
| | | if (this.currentRow && row.id === this.currentRow.id) { |
| | | return 'warning-row' |
| | | } else { |
| | | return 'success-row' |
| | | } |
| | | }, |
| | | handleCurrentChange (newPage) { |
| | | this.currentPage = newPage |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | |
| | | <style lang="scss"> |
| | | .el-table .warning-row { |
| | | background: rgba(161, 231, 20, 0.2) !important; |
| | | td{ |
| | | background: rgba(161, 231, 20, 0.2) !important; |
| | | } |
| | | } |
| | | .el-table .success-row { |
| | | background: #f0f9eb !important; |
| | | td{ |
| | | background: #f0f9eb !important; |
| | | } |
| | | } |
| | | </style> |
| | |
| | | <template> |
| | | <GlobalWindow |
| | | :title="title" |
| | | width="70%" |
| | | :visible.sync="visible" |
| | | :confirm-working="isWorking" |
| | | @confirm="confirm" |
| | | > |
| | | <p class="tip-warn"><i class="el-icon-warning"></i>ä¼å说æï¼<br> |
| | | 1ãå½åä¼å任塿夿¯æ<span class="orange">ã {{lineNum}} ã</span>æ¡çº¿è·¯;<br> |
| | | 2ãåçéæ©çº¿è·¯ï¼éæ©çº¿è·¯çæ»å®¢æ·æ°åæ»éè´§ééè¦æ»¡è¶³å½æ¥è®¢å累计å¼;<br> |
| | | 3ã强å¶ä¼å表示忽ç¥è¯¥ä¸»çº¿ä¼åä¸çä»»å¡ï¼éæ°å¼å¯ä¼åä»»å¡ï¼ä¸å»ºè®®ï¼;<br> |
| | | </p> |
| | | <!-- <el-form :model="form" ref="form" :rules="rules"> |
| | | <el-form-item label="çæçº¿è·¯æ°é" prop="planLineNum"> |
| | | <el-input type="number" disabled v-model="form.planLineNum" placeholder="请è¾å
¥çº¿è·¯æ°" v-trim/> |
| | | </el-form-item> |
| | | </el-form>--> |
| | | <div> |
| | | <el-form :model="form" ref="form" :rules="rules"> |
| | | <el-form-item label="å建人ç¼ç " prop="creator"> |
| | | <el-input v-model="form.creator" placeholder="请è¾å
¥å建人ç¼ç " v-trim/> |
| | | <el-form-item label="æ¯å¦å¼ºå¶ä¼å" prop="forceUpdate"> |
| | | <el-radio-group v-model="form.forceUpdate"> |
| | | <el-radio :label="0" :value="0">ä¸å¼ºå¶</el-radio> |
| | | <el-radio :label="1" :value="1">强å¶</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | <el-form-item label="å建æ¶é´" prop="createDate"> |
| | | <el-date-picker v-model="form.createDate" value-format="yyyy-MM-dd" placeholder="请è¾å
¥å建æ¶é´"></el-date-picker> |
| | | </el-form-item> |
| | | <el-form-item label="æ´æ°äººç¼ç " prop="editor"> |
| | | <el-input v-model="form.editor" placeholder="请è¾å
¥æ´æ°äººç¼ç " v-trim/> |
| | | </el-form-item> |
| | | <el-form-item label="æ´æ°æ¶é´" prop="editDate"> |
| | | <el-date-picker v-model="form.editDate" value-format="yyyy-MM-dd" placeholder="请è¾å
¥æ´æ°æ¶é´"></el-date-picker> |
| | | </el-form-item> |
| | | <el-form-item label="æ¯å¦å é¤0å¦ 1æ¯" prop="isdeleted"> |
| | | <el-input v-model="form.isdeleted" placeholder="请è¾å
¥æ¯å¦å é¤0å¦ 1æ¯" v-trim/> |
| | | </el-form-item> |
| | | <el-form-item label="夿³¨" prop="info"> |
| | | <el-input v-model="form.info" placeholder="请è¾å
¥å¤æ³¨" v-trim/> |
| | | </el-form-item> |
| | | <el-form-item label="主线路ç¼ç ï¼å
³ècategory)" prop="categoryId"> |
| | | <el-input v-model="form.categoryId" placeholder="请è¾å
¥ä¸»çº¿è·¯ç¼ç ï¼å
³ècategory)" v-trim/> |
| | | </el-form-item> |
| | | <el-form-item label="éè´§é" prop="totalNum"> |
| | | <el-input v-model="form.totalNum" placeholder="请è¾å
¥éè´§é" v-trim/> |
| | | </el-form-item> |
| | | <el-form-item label="å®¢æ·æ°" prop="orderNum"> |
| | | <el-input v-model="form.orderNum" placeholder="请è¾å
¥å®¢æ·æ°" v-trim/> |
| | | </el-form-item> |
| | | <el-form-item label="ç¶æ 0æªä¼å 1ä¼åä¸ 2å·²ä¼å" prop="status"> |
| | | <el-input v-model="form.status" placeholder="请è¾å
¥ç¶æ 0æªä¼å 1ä¼åä¸ 2å·²ä¼å" v-trim/> |
| | | </el-form-item> |
| | | <el-form-item label="æåºç " prop="sortnum"> |
| | | <el-input v-model="form.sortnum" placeholder="请è¾å
¥æåºç " v-trim/> |
| | | </el-form-item> |
| | | <el-form-item label="æ¥æ" prop="dateInfo"> |
| | | <el-date-picker v-model="form.dateInfo" value-format="yyyy-MM-dd" placeholder="请è¾å
¥æ¥æ"></el-date-picker> |
| | | </el-form-item> |
| | | <el-form-item label="ä¼åè®°å½ç¼ç (ä½ä¸ºkeyå¼åredisï¼" prop="jobId"> |
| | | <el-input v-model="form.jobId" placeholder="请è¾å
¥ä¼åè®°å½ç¼ç (ä½ä¸ºkeyå¼åredisï¼" v-trim/> |
| | | <el-form-item label="éæ©çæçº¿è·¯" prop="lineIdList" > |
| | | <el-table :data="lineList" stripe @selection-change="handleSelectionChange"> |
| | | <el-table-column type="selection" width="55"></el-table-column> |
| | | <el-table-column prop="name" label="é货线路" min-width="130px" show-tooltip-when-overflow> </el-table-column> |
| | | <el-table-column prop="maxCustomer" label="å®¢æ·æ°(æ·)" min-width="100px" show-tooltip-when-overflow></el-table-column> |
| | | <el-table-column prop="maxOrder" label="éè´§é(æ¡)" min-width="100px" show-tooltip-when-overflow></el-table-column> |
| | | <el-table-column prop="carCode" label="车çå·" min-width="100px"></el-table-column> |
| | | <el-table-column prop="memberName" label="éè´§å¸æº" min-width="100px"></el-table-column> |
| | | </el-table> |
| | | </el-form-item> |
| | | </el-form> |
| | | </div> |
| | | </GlobalWindow> |
| | | </template> |
| | | |
| | | <script> |
| | | import BaseOpera from '@/components/base/BaseOpera' |
| | | import GlobalWindow from '@/components/common/GlobalWindow' |
| | | import { allList } from '@/api/business/jkLine' |
| | | export default { |
| | | name: 'OperaJkSketchWindow', |
| | | extends: BaseOpera, |
| | |
| | | // è¡¨åæ°æ® |
| | | form: { |
| | | id: null, |
| | | creator: '', |
| | | createDate: '', |
| | | editor: '', |
| | | editDate: '', |
| | | isdeleted: '', |
| | | info: '', |
| | | categoryId: '', |
| | | totalNum: '', |
| | | orderNum: '', |
| | | status: '', |
| | | sortnum: '', |
| | | dateInfo: '', |
| | | jobId: '' |
| | | planLineNum: '', |
| | | forceUpdate: 0, |
| | | lineIdList: [] |
| | | }, |
| | | categoryId: null, |
| | | lineList: [], |
| | | lineNum: null, |
| | | // éªè¯è§å |
| | | rules: { |
| | | lineIdList: [{ required: true, message: 'è¯·éæ©çæçº¿è·¯æ°é' }], |
| | | forceUpdate: [{ required: true, message: 'è¯·éæ©æ¯å¦å¼ºå¶ä¼å' }] |
| | | } |
| | | } |
| | | }, |
| | |
| | | api: '/business/jkSketch', |
| | | 'field.id': 'id' |
| | | }) |
| | | }, |
| | | methods: { |
| | | handleSelectionChange (rows) { |
| | | this.form.lineIdList = [] |
| | | if (rows || rows.length) { |
| | | rows.forEach(item => { |
| | | this.form.lineIdList.push(item.id) |
| | | }) |
| | | } |
| | | }, |
| | | open (title, target) { |
| | | if (!target || !target.id) { |
| | | return |
| | | } |
| | | this.lineList = [] |
| | | this.title = title |
| | | this.visible = true |
| | | this.categoryId = target.categoryId |
| | | this.form.id = target.id |
| | | this.form.planLineNum = target.planLineNum |
| | | this.form.forceUpdate = 0 |
| | | this.form.lineIdList = [] |
| | | this.loadLines() |
| | | }, |
| | | confirm () { |
| | | this.$refs.form.validate((valid) => { |
| | | if (!valid) { |
| | | return |
| | | } |
| | | /* if (this.form.planLineNum <= 0 || this.form.planLineNum > this.lineNum) { |
| | | this.$message.error('ä¼å线路æ°å¿
é¡»å¨[1-' + this.lineNum + ']èå´å
ï¼') |
| | | return |
| | | }*/ |
| | | this.confirmDo() |
| | | }) |
| | | }, |
| | | confirmDo () { |
| | | // è°ç¨æ°å»ºæ¥å£ |
| | | this.isWorking = true |
| | | this.api.updateById({ |
| | | id: this.form.id, |
| | | lineIdList: this.form.lineIdList, |
| | | forceUpdate: this.form.forceUpdate |
| | | }) |
| | | .then(() => { |
| | | this.visible = false |
| | | this.$tip.apiSuccess('ä¼å任塿£å¨åå°æ§è¡ï¼è¯·çå¾
ä¼å宿忥çä¼åç»æï¼') |
| | | this.$emit('success') |
| | | }) |
| | | .catch(e => { |
| | | // this.$tip.apiFailed(e) |
| | | }) |
| | | .finally(() => { |
| | | this.isWorking = false |
| | | }) |
| | | }, |
| | | loadLines () { |
| | | allList({ |
| | | categoryId: this.categoryId |
| | | }).then(res => { |
| | | this.lineList = res || [] |
| | | this.lineNum = this.lineList.length |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | |
| | | <li><el-button type="danger" @click="deleteByIdInBatch" icon="el-icon-delete" v-permissions="['business:jkcustomer:delete']">å é¤</el-button></li> |
| | | </ul> |
| | | <el-table |
| | | :height="tableHeightNew" |
| | | v-loading="isWorking.search" |
| | | :data="tableData.list" |
| | | stripe |
| | |
| | | <li><el-button type="danger" @click="deleteByIdInBatch" icon="el-icon-delete" v-permissions="['business:jkline:delete']">å é¤</el-button></li> |
| | | </ul> |
| | | <el-table |
| | | |
| | | :height="tableHeightNew" |
| | | v-loading="isWorking.search" |
| | | :data="tableData.list" |
| | | stripe |
| | |
| | | <!-- |
| | | <el-table-column type="selection" width="55"></el-table-column> |
| | | --> |
| | | <el-table-column prop="dateInfo" label="éè´§æ¥æ" min-width="130px"></el-table-column> |
| | | <el-table-column prop="categoryName" label="主线路" min-width="130px"> |
| | | <el-table-column prop="dateInfo" label="éè´§æ¥æ" min-width="100px" align="center"></el-table-column> |
| | | <el-table-column prop="categoryName" label="主线路-å½å线路æ°" min-width="200px" align="center"> |
| | | <template slot-scope="{row}"> |
| | | <span class="blue" style="cursor: pointer" @click="$refs.operaJkSketchLineListWindow.open('é
é线路æç»', row)">{{ row.categoryName }}ï¼{{row.lineNum||0}}æ¡çº¿è·¯ï¼</span> |
| | | <span class="blue" style="cursor: pointer" @click="$refs.operaJkSketchLineListWindow.open('é
é线路æç»', row)">{{ row.categoryName }}</span> |
| | | <span class="orange" style="margin-left: 10px">ã {{row.lineNum||0}} ãæ¡çº¿è·¯</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="orderNum" label="å®¢æ·æ°(æ·)" min-width="130px"></el-table-column> |
| | | <el-table-column prop="totalNum" label="éè´§é(æ¡)" min-width="130px"></el-table-column> |
| | | <el-table-column prop="status" label="ä¼åç¶æ" min-width="100px"> |
| | | <el-table-column prop="orderNum" label="å®¢æ·æ°(æ·)" min-width="100px" align="center"></el-table-column> |
| | | <el-table-column prop="totalNum" label="éè´§é(æ¡)" min-width="100px" align="center"></el-table-column> |
| | | <el-table-column prop="status" label="ä¼åç¶æ" min-width="100px" align="center"> |
| | | <template slot-scope="{row}"> |
| | | <span v-if="row.status === 0" class="blue">æªä¼å</span> |
| | | <span v-if="row.status === 1" class="red">ä¼åä¸</span> |
| | | <span v-if="row.status === 1" class="red">ä¼åä¸ ã {{row.planLineNum||0}} ãæ¡çº¿è·¯</span> |
| | | <span v-if="row.status === 2" class="green">å·²ä¼å</span> |
| | | <span v-if="row.status === 3" class="green">ä¼å失败</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column |
| | | v-if="containPermissions(['business:jksketch:update', 'business:jksketch:delete'])" |
| | | label="æä½" |
| | | min-width="120" |
| | | align="left" |
| | | fixed="right" |
| | | > |
| | | <template slot-scope="{row}"> |
| | | <el-button type="text" @click="$refs.operaJkSketchWindow.open('线路ä¼å', row)" icon="el-icon-edit" v-permissions="['business:jksketch:update']">线路ä¼å</el-button> |
| | | <el-button type="text" @click="$refs.OperaJkSketchResultWindow.open('线路ä¼åç»æ', row)" icon="el-icon-view" v-if="row.status ==2" >ä¼åç»æ</el-button> |
| | | <el-button type="text" @click="$refs.OperaJkSketchResultWindow.open('ä¼åç»æå¾®è°-', row)" icon="el-icon-edit" v-if="row.status ==2" >ä¼åç»æå¾®è°</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | |
| | | <OperaJkSketchWindow ref="operaJkSketchWindow" @success="handlePageChange"/> |
| | | <OperaJkSketchResultWindow ref="OperaJkSketchResultWindow" @success="handlePageChange"/> |
| | | <OperaJkSketchImportWindow ref="OperaJkSketchImportWindow" @success="handlePageChange"/> |
| | | <OperaJkSketchLineListWindow ref="operaJkSketchLineListWindow" /> |
| | | <OperaJkSketchLineListWindow ref="operaJkSketchLineListWindow" @success="handlePageChange" /> |
| | | </TableLayout> |
| | | </template> |
| | | |
| | |
| | | <type>pom</type> |
| | | <scope>import</scope> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.google.protobuf</groupId> |
| | | <artifactId>protobuf-java</artifactId> |
| | | <version>4.31.1</version> |
| | | <type>pom</type> |
| | | <scope>import</scope> |
| | | </dependency> |
| | | <!-- Alibaba Cloud ä¾èµç®¡ç --> |
| | | <dependency> |
| | | <groupId>com.alibaba.cloud</groupId> |
| | |
| | | <mybatis.plus.version>3.5.7</mybatis.plus.version> |
| | | <apache.shiro.version>1.7.0</apache.shiro.version> |
| | | <oshi.version>5.7.0</oshi.version> |
| | | <jna.version>5.7.0</jna.version> |
| | | <jna.version>5.14.0</jna.version> |
| | | <poi.version>5.0.0</poi.version> |
| | | <spring-cloud.version>2021.0.3</spring-cloud.version> |
| | | <spring-cloud-alibaba.version>2021.0.1.0</spring-cloud-alibaba.version> |
| | |
| | | <!-- é¿éäºOSSåå¨ --> |
| | | <aliyun-oss.version>3.8.0</aliyun-oss.version> |
| | | </properties> |
| | | |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | |
| | | <groupId>com.github.oshi</groupId> |
| | | <artifactId>oshi-core</artifactId> |
| | | <version>${oshi.version}</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>net.java.dev.jna</groupId> |
| | | <artifactId>jna</artifactId> |
| | | <version>${jna.version}</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>net.java.dev.jna</groupId> |
| | | <exclusions> |
| | | <exclusion> |
| | | <artifactId>jna-platform</artifactId> |
| | | <version>${jna.version}</version> |
| | | <groupId>net.java.dev.jna</groupId> |
| | | </exclusion> |
| | | <exclusion> |
| | | <artifactId>jna</artifactId> |
| | | <groupId>net.java.dev.jna</groupId> |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | <!-- https://mvnrepository.com/artifact/com.github.yulichang/mybatis-plus-join --> |
| | | <dependency> |
| | |
| | | <type>pom</type> |
| | | <scope>import</scope> |
| | | </dependency> |
| | | |
| | | <!-- <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-dependencies</artifactId> |
| | |
| | | <type>pom</type> |
| | | <scope>import</scope> |
| | | </dependency>--> |
| | | <!-- <dependency> |
| | | <groupId>com.google.protobuf</groupId> |
| | | <artifactId>protobuf-java</artifactId> |
| | | <version>4.31.1</version> |
| | | </dependency> |
| | | --> |
| | | <!-- <dependency> |
| | | <groupId>com.google.ortools</groupId> |
| | | <artifactId>ortools-java</artifactId> |
| | | <version>9.14.6206</version> |
| | | <exclusions> |
| | | <exclusion> |
| | | <groupId>com.google.protobuf</groupId> |
| | | <artifactId>protobuf-java</artifactId> |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | --> |
| | | <dependency> |
| | | <groupId>com.google.protobuf</groupId> |
| | | <artifactId>protobuf-java</artifactId> |
| | | <version>4.31.1</version> |
| | | <scope>compile</scope> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.google.ortools</groupId> |
| | | <artifactId>ortools-java</artifactId> |
| | | <version>9.14.6206</version> |
| | | <exclusions> |
| | | <exclusion> |
| | | <groupId>com.google.protobuf</groupId> |
| | | <artifactId>protobuf-java</artifactId> |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | |
| | | </dependencies> |
| | | </project> |
| | |
| | | public static final String LIQUID_LEVEL_UNIT ="LIQUID_LEVEL_UNIT" ; |
| | | public static final String OUT_HY_LOT_TOTAL ="OUT_HY_LOT_TOTAL" ; |
| | | public static final String BANNER_IMG ="BANNER_IMG" ; |
| | | public static final String COMPANY_LOCATION = "COMPANY_LOCATION"; |
| | | public static final String GAODE_LOCATION_GEOAPI_URL = "GAODE_LOCATION_GEOAPI_URL"; |
| | | |
| | | public static boolean DEALING_HK_SYNCPRIVILEGE= false; |
| | |
| | | public interface RedisKeys { |
| | | public static final String IMPORTING_CARS ="IMPORTING_CARS"; |
| | | public static final String CHECKING_JKCUSTOMER_LOCATION ="CHECKING_JKCUSTOMER_LOCATION"; |
| | | public static final String JKLINE_JOB ="JKLINE_JOB_"; |
| | | public static final String IMPORTING_JKCUSTOMER ="IMPORTING_JKCUSTOMER"; |
| | | public static final String IMPORTING_JKORDERS ="IMPORTING_JKORDERS"; |
| | | public static final String IMPORTING_JKLINE ="IMPORTING_JKLINE"; |
| | |
| | | } |
| | | |
| | | /** |
| | | * è·åå½åæ¥ææ¯ææå <br> |
| | | * |
| | | * @param dt |
| | | * @return å½åæ¥ææ¯ææå |
| | | */ |
| | | public static String getWeekZhouOfDate(Date dt) { |
| | | String[] weekDays = { "卿¥", "å¨ä¸", "å¨äº", "å¨ä¸", "å¨å", "å¨äº", "å¨å
" }; |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.setTime(dt); |
| | | |
| | | int w = cal.get(Calendar.DAY_OF_WEEK) - 1; |
| | | if (w < 0) |
| | | { |
| | | w = 0; |
| | | } |
| | | |
| | | return weekDays[w]; |
| | | } |
| | | /** |
| | | * è·åæææ° |
| | | * |
| | | * @param dt |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.core.utils; |
| | | public class DistanceCalculator { |
| | | private static final double EARTH_RADIUS = 6371.0; // å°çåå¾ï¼åä½ï¼å
¬éï¼ |
| | | |
| | | public static void main(String[] args) { |
| | | //118.363428,31.326485 |
| | | //118.363312,31.326638 |
| | | System.out.println(calculateDistance(39.326638d,116.363312d,31.326606,118.363272)); |
| | | } |
| | | public static long calculateDistance(double lat1, double lon1, double lat2, double lon2) { |
| | | double dLat = Math.toRadians(lat2 - lat1); |
| | | double dLon = Math.toRadians(lon2 - lon1); |
| | | |
| | | double a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + |
| | | Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)) * |
| | | 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 * 1000); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.core.utils.tsp; |
| | | |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.google.ortools.Loader; |
| | | import com.google.ortools.constraintsolver.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import com.google.protobuf.Internal.IntListAdapter.IntConverter; |
| | | import com.google.ortools.constraintsolver.mainJNI; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Slf4j |
| | | public class TspSolver { |
| | | public static void main(String[] args) throws Exception { |
| | | DataModel data = new DataModel(); |
| | | data.initDataList();//æé æ°æ® |
| | | |
| | | startSearch(data); |
| | | /*// åå§åæ°æ®æ¨¡å |
| | | Loader.loadNativeLibraries(); |
| | | DataModel data = new DataModel(); |
| | | data.initDataList();//æé æ°æ® |
| | | |
| | | long start =System.currentTimeMillis(); |
| | | System.out.println("=============start=========="+start); |
| | | //å建æ±è§£å¨manager对象ï¼åå§åæ±è§£å¨æ°æ® |
| | | RoutingIndexManager manager = new RoutingIndexManager(data.distanceMatrix.length, data.vehicleNumber, data.depot); |
| | | |
| | | // åå§åæ±è§£å¨ |
| | | RoutingModel routing = new RoutingModel(manager); |
| | | |
| | | // // 注ååè°å½æ° |
| | | final int transitCallbackIndex = |
| | | routing.registerTransitCallback((long fromIndex, long toIndex) -> { |
| | | int fromNode = manager.indexToNode(fromIndex); |
| | | int toNode = manager.indexToNode(toIndex); |
| | | return data.distanceMatrix[fromNode][toNode]; |
| | | }); |
| | | |
| | | // å®ä¹åè°å½æ°è³æ¯æ¡è·¯çº¿ |
| | | routing.setArcCostEvaluatorOfAllVehicles(transitCallbackIndex); |
| | | // å¢å è·ç¦»ç»´åº¦çº¦æ |
| | | routing.addDimension(transitCallbackIndex, 0, 30000, |
| | | true, |
| | | "Distance"); |
| | | RoutingDimension distanceDimension = routing.getMutableDimension("Distance"); |
| | | distanceDimension.setGlobalSpanCostCoefficient(100); |
| | | // // æ·»å 容ééå¶ |
| | | final int demandCallbackIndex = routing.registerUnaryTransitCallback((long fromIndex) -> { |
| | | int fromNode = manager.indexToNode(fromIndex); |
| | | return data.demands[fromNode]; |
| | | }); |
| | | routing.addDimensionWithVehicleCapacity(demandCallbackIndex, 0, data.vehicleCapacities, true, "Capacity"); |
| | | |
| | | Solver solver = routing.solver(); |
| | | |
| | | |
| | | //设置æç´¢æ¹æ³ |
| | | RoutingSearchParameters searchParameters = |
| | | main.defaultRoutingSearchParameters() |
| | | .toBuilder() |
| | | .setFirstSolutionStrategy(FirstSolutionStrategy.Value.PATH_CHEAPEST_ARC) |
| | | .build(); |
| | | |
| | | // æ§è¡ç®æ³ |
| | | Assignment solution = routing.solveWithParameters(searchParameters); |
| | | |
| | | // æå°è·¯çº¿ |
| | | printSolution(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"); |
| | | */} |
| | | public static void startSearch(DataModel data) { |
| | | // åå§åæ°æ®æ¨¡å |
| | | Loader.loadNativeLibraries(); |
| | | long start =System.currentTimeMillis(); |
| | | System.out.println("=============start=========="+start); |
| | | //å建æ±è§£å¨manager对象ï¼åå§åæ±è§£å¨æ°æ® |
| | | RoutingIndexManager manager = new RoutingIndexManager(data.distanceMatrix.length, data.vehicleNumber, data.depot); |
| | | |
| | | // åå§åæ±è§£å¨ |
| | | RoutingModel routing = new RoutingModel(manager); |
| | | |
| | | // 注ååè°å½æ° |
| | | final int transitCallbackIndex = |
| | | routing.registerTransitCallback((long fromIndex, long toIndex) -> { |
| | | int fromNode = manager.indexToNode(fromIndex); |
| | | int toNode = manager.indexToNode(toIndex); |
| | | return data.distanceMatrix[fromNode][toNode]; |
| | | }); |
| | | |
| | | // å®ä¹åè°å½æ°è³æ¯æ¡è·¯çº¿ |
| | | routing.setArcCostEvaluatorOfAllVehicles(transitCallbackIndex); |
| | | // å¢å è·ç¦»ç»´åº¦çº¦æ |
| | | routing.addDimension(transitCallbackIndex, 0, 300000000, |
| | | true, |
| | | "Distance"); |
| | | RoutingDimension distanceDimension = routing.getMutableDimension("Distance"); |
| | | distanceDimension.setGlobalSpanCostCoefficient(100); |
| | | // // æ·»å 容ééå¶ |
| | | final int demandCallbackIndex = routing.registerUnaryTransitCallback((long fromIndex) -> { |
| | | int fromNode = manager.indexToNode(fromIndex); |
| | | return data.demands[fromNode]; |
| | | }); |
| | | routing.addDimensionWithVehicleCapacity(demandCallbackIndex, 0, data.vehicleCapacities, true, "Capacity"); |
| | | // routing.addDimensionWithVehicleTransits() |
| | | Solver solver = routing.solver(); |
| | | |
| | | //设置æç´¢æ¹æ³ |
| | | RoutingSearchParameters searchParameters = |
| | | main.defaultRoutingSearchParameters() |
| | | .toBuilder() |
| | | .setFirstSolutionStrategy(FirstSolutionStrategy.Value.PATH_CHEAPEST_ARC) |
| | | .build(); |
| | | |
| | | // æ§è¡ç®æ³ |
| | | Assignment solution = routing.solveWithParameters(searchParameters); |
| | | if(solution ==null){ |
| | | 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"); |
| | | } |
| | | static void resultSolution( DataModel data, RoutingModel routing, RoutingIndexManager manager, Assignment solution) { |
| | | long maxRouteDistance = 0; |
| | | List<TspSolverSolutions> mapList = new ArrayList<>(); |
| | | for (int i = 0; i < data.vehicleNumber; ++i) { |
| | | TspSolverSolutions t = new TspSolverSolutions(); |
| | | t.setLineIndex(i); |
| | | long index = routing.start(i); |
| | | log.info("Route for Vehicle " + i + ":"); |
| | | long routeDistance = 0; |
| | | int routeDemand = 0; |
| | | String route = ""; |
| | | List<Integer> routeList = new ArrayList<>(); |
| | | while (!routing.isEnd(index)) { |
| | | int tNode = manager.indexToNode(index); |
| | | routeList.add( tNode); |
| | | route += tNode+ " -> "; |
| | | routeDemand += data.demands[tNode]; |
| | | long previousIndex = index; |
| | | index = solution.value(routing.nextVar(index)); |
| | | routeDistance += routing.getArcCostForVehicle(previousIndex, index, i); |
| | | } |
| | | int tNode = manager.indexToNode(index); |
| | | routeList.add( tNode); |
| | | log.info(route + tNode); |
| | | t.setRouteIndex(routeList); |
| | | t.setDistance(routeDistance); |
| | | log.info("Distance of the route: " + routeDistance + "m"+" Capacity of the route:"+routeDemand+"/"+data.vehicleCapacities[i]); |
| | | maxRouteDistance = Math.max(routeDistance, maxRouteDistance); |
| | | mapList.add(t); |
| | | } |
| | | data.setSolutions(mapList); |
| | | log.info("Maximum of the route distances: " + maxRouteDistance + "m"); |
| | | } |
| | | static void printSolution( DataModel data, RoutingModel routing, RoutingIndexManager manager, Assignment solution) { |
| | | long maxRouteDistance = 0; |
| | | for (int i = 0; i < data.vehicleNumber; ++i) { |
| | | long index = routing.start(i); |
| | | log.info("Route for Vehicle " + i + ":"); |
| | | long routeDistance = 0; |
| | | int routeDemand = 0; |
| | | String route = ""; |
| | | List<Integer> routeList = new ArrayList<>(); |
| | | while (!routing.isEnd(index)) { |
| | | int tNode = manager.indexToNode(index); |
| | | routeList.add( tNode); |
| | | route += tNode+ " -> "; |
| | | routeDemand += data.demands[tNode]; |
| | | long previousIndex = index; |
| | | index = solution.value(routing.nextVar(index)); |
| | | routeDistance += routing.getArcCostForVehicle(previousIndex, index, i); |
| | | } |
| | | log.info(route + manager.indexToNode(index)); |
| | | log.info("Distance of the route: " + routeDistance + "m"+" Capacity of the route:"+routeDemand+"/"+data.vehicleCapacities[i]); |
| | | maxRouteDistance = Math.max(routeDistance, maxRouteDistance); |
| | | } |
| | | log.info("Maximum of the route distances: " + maxRouteDistance + "m"); |
| | | } |
| | | |
| | | public static void startOptimize(){ |
| | | |
| | | |
| | | } |
| | | |
| | | public static class DataModel { |
| | | //è·ç¦»ç©éµ |
| | | public int lenght; |
| | | //æå¤§è½¦è¾éå¶ |
| | | public int vehicleNumber; |
| | | public List<TspSolverSolutions> solutions; |
| | | //èµ·ç¹ |
| | | public static final int depot = 0; |
| | | |
| | | //æ¯ä¸ä¸ªç¹çååçæ°é |
| | | public long[] demands; |
| | | //è½¦è¾æå¤§å®¹è½½ |
| | | public long[] vehicleCapacities ; |
| | | public long[][] distanceMatrix ; |
| | | |
| | | public List<TspSolverSolutions> getSolutions() { |
| | | return solutions; |
| | | } |
| | | |
| | | public void setSolutions(List<TspSolverSolutions> solutions) { |
| | | this.solutions = solutions; |
| | | } |
| | | |
| | | public void initDataInfo(int vehicleNumber1, long[] demands1, long[] vehicleCapacities1, long[][] distanceMatrix1){ |
| | | this.demands = demands1; |
| | | this.vehicleNumber = vehicleNumber1; |
| | | this.vehicleCapacities=vehicleCapacities1; |
| | | this.distanceMatrix=distanceMatrix1; |
| | | } |
| | | public void initDataList(){ |
| | | lenght = 100; |
| | | vehicleNumber = 7; |
| | | demands = new long[lenght]; |
| | | vehicleCapacities =new long[vehicleNumber]; |
| | | distanceMatrix = new long[lenght][lenght]; |
| | | int total0 =0; |
| | | for (int i = 0; i <vehicleNumber ; i++) { |
| | | long tem = (long) (Math.random() * 1000 + 20000); |
| | | vehicleCapacities[i] = tem; |
| | | total0+=tem; |
| | | System.out.print(tem+" ,"); |
| | | } |
| | | System.out.println( "\ntotal Capacity:"+total0+"====================="); |
| | | long total = 0; |
| | | for (int i = 0; i <lenght ; i++) { |
| | | long tem = (int)(Math.random()*100+100); |
| | | demands[i] =tem; |
| | | total+=tem; |
| | | System.out.print(tem+" ,"); |
| | | for (int j = 0; j <lenght ; j++) { |
| | | if(i == j){ |
| | | distanceMatrix[i][j] =0; |
| | | } |
| | | if(i<j){ |
| | | distanceMatrix[i][j] =(int)(Math.random()*1000+1); |
| | | distanceMatrix[j][i] = distanceMatrix[i][j]; |
| | | } |
| | | } |
| | | } |
| | | |
| | | System.out.println( "\ntotal Demands:"+total+"====================="); |
| | | } |
| | | /* public final long[][] distanceMatrix = { |
| | | {0, 548, 776, 696, 582, 274, 502, 194, 308, 194, 536, 502, 388, 354, 468, 776, 662}, |
| | | {548, 0, 684, 308, 194, 502, 730, 354, 696, 742, 1084, 594, 480, 674, 1016, 868, 1210}, |
| | | {776, 684, 0, 992, 878, 502, 274, 810, 468, 742, 400, 1278, 1164, 1130, 788, 1552, 754}, |
| | | {696, 308, 992, 0, 114, 650, 878, 502, 844, 890, 1232, 514, 628, 822, 1164, 560, 1358}, |
| | | {582, 194, 878, 114, 0, 536, 764, 388, 730, 776, 1118, 400, 514, 708, 1050, 674, 1244}, |
| | | {274, 502, 502, 650, 536, 0, 228, 308, 194, 240, 582, 776, 662, 628, 514, 1050, 708}, |
| | | {502, 730, 274, 878, 764, 228, 0, 536, 194, 468, 354, 1004, 890, 856, 514, 1278, 480}, |
| | | {194, 354, 810, 502, 388, 308, 536, 0, 342, 388, 730, 468, 354, 320, 662, 742, 856}, |
| | | {308, 696, 468, 844, 730, 194, 194, 342, 0, 274, 388, 810, 696, 662, 320, 1084, 514}, |
| | | {194, 742, 742, 890, 776, 240, 468, 388, 274, 0, 342, 536, 422, 388, 274, 810, 468}, |
| | | {536, 1084, 400, 1232, 1118, 582, 354, 730, 388, 342, 0, 878, 764, 730, 388, 1152, 354}, |
| | | {502, 594, 1278, 514, 400, 776, 1004, 468, 810, 536, 878, 0, 114, 308, 650, 274, 844}, |
| | | {388, 480, 1164, 628, 514, 662, 890, 354, 696, 422, 764, 114, 0, 194, 536, 388, 730}, |
| | | {354, 674, 1130, 822, 708, 628, 856, 320, 662, 388, 730, 308, 194, 0, 342, 422, 536}, |
| | | {468, 1016, 788, 1164, 1050, 514, 514, 662, 320, 274, 388, 650, 536, 342, 0, 764, 194}, |
| | | {776, 868, 1552, 560, 674, 1050, 1278, 742, 1084, 810, 1152, 274, 388, 422, 764, 0, 798}, |
| | | {662, 1210, 754, 1358, 1244, 708, 480, 856, 514, 468, 354, 844, 730, 536, 194, 798, 0}, |
| | | };*/ |
| | | |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.core.utils.tsp; |
| | | |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.google.ortools.Loader; |
| | | import com.google.ortools.constraintsolver.*; |
| | | import lombok.Data; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Slf4j |
| | | @Data |
| | | public class TspSolverSolutions { |
| | | private int lineIndex; |
| | | private List<Integer> routeIndex; |
| | | private long distance; |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | <groupId>com.doumee</groupId> |
| | | <artifactId>dmvisit_service</artifactId> |
| | | <version>1.0.0-SNAPSHOT</version> |
| | | <exclusions> |
| | | <exclusion> |
| | | <groupId>com.google.protobuf</groupId> |
| | | <artifactId>protobuf-java</artifactId> |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.google.protobuf</groupId> |
| | | <artifactId>protobuf-java</artifactId> |
| | | <version>4.31.1</version> |
| | | <scope>compile</scope> |
| | | </dependency> |
| | | </dependencies> |
| | | <build> |
| | |
| | | @PostMapping("/updateById") |
| | | @CloudRequiredPermission("business:jksketch:update") |
| | | public ApiResponse updateById(@RequestBody JkSketch jkSketch, @RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | jkSketchService.updateById(jkSketch); |
| | | jkSketch.setLoginUserInfo(this.getLoginUser(token)); |
| | | JkSketch model = jkSketchService.updateById(jkSketch); |
| | | jkSketchService.startUpdateLineAsync(model);//弿¥ä¼å |
| | | return ApiResponse.success(null); |
| | | } |
| | | |
| | |
| | | return ApiResponse.success(jkSketchCustomerService.findPage(pageWrap)); |
| | | } |
| | | |
| | | @ApiOperation("å表æ¥è¯¢") |
| | | @PostMapping("/allList") |
| | | @CloudRequiredPermission("business:jksketchcustomer:query") |
| | | public ApiResponse<List<JkSketchCustomer>> allList (@RequestBody JkSketchCustomer pageWrap) { |
| | | return ApiResponse.success(jkSketchCustomerService.findList(pageWrap)); |
| | | } |
| | | |
| | | @ApiOperation("导åºExcel") |
| | | @PostMapping("/exportExcel") |
| | | @CloudRequiredPermission("business:jksketchcustomer:exportExcel") |
| | |
| | | @ExcelColumn(name="æå±ä¸»çº¿è·¯",index = 2,width = 10) |
| | | @TableField(exist = false) |
| | | private String categoryName; |
| | | @ApiModelProperty(value = "叿º", example = "1") |
| | | @TableField(exist = false) |
| | | private String memberName; |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 交æ§-éå®è®¢åä¿¡æ¯è¡¨ |
| | |
| | | @ApiModelProperty(value = "åçç»é´å®¢æ·ä½ç½®è·ç¦»æ°ç»ï¼[{a:12,b:100},{a:13,b:200},...],aï¼å®¢æ·ç¼ç ï¼bï¼ä¸å®¢æ·aä¹é´çè·ç¦»") |
| | | //@ExcelColumn(name="åçç»é´å®¢æ·ä½ç½®è·ç¦»æ°ç»ï¼[{a:12,b:100},{a:13,b:200},...],aï¼å®¢æ·ç¼ç ï¼bï¼ä¸å®¢æ·aä¹é´çè·ç¦»") |
| | | private String distances; |
| | | @ApiModelProperty(value = "åçç»é´å®¢æ·ä½ç½®è·ç¦»æ°ç»ï¼[{a:12,b:100},{a:13,b:200},...],aï¼å®¢æ·ç¼ç ï¼bï¼ä¸å®¢æ·aä¹é´çè·ç¦»") |
| | | @TableField(exist = false) |
| | | private List<Map<String,Object>> distanceList; |
| | | |
| | | @ApiModelProperty(value = "客æ·å§å", example = "1") |
| | | @ExcelColumn(name="客æ·å§å",index = 2,width = 10) |
| | |
| | | //@ExcelColumn(name="æå±ä¸»çº¿è·¯",index = 2,width = 10) |
| | | @TableField(exist = false) |
| | | private Integer categoryId; |
| | | @ApiModelProperty(value = "ç»åº¦", example = "1") |
| | | //@ExcelColumn(name="ç»åº¦") |
| | | @TableField(exist = false) |
| | | private BigDecimal longitude; |
| | | |
| | | @ApiModelProperty(value = "维度", example = "1") |
| | | //@ExcelColumn(name="维度") |
| | | @TableField(exist = false) |
| | | private BigDecimal latitude; |
| | | } |
| | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 交æ§-线路ä¼åè®°å½ä¿¡æ¯è¡¨ |
| | |
| | | @ApiModelProperty(value = "ææ°ä¼å线路æ°", example = "1") |
| | | //@ExcelColumn(name="主线路ç¼ç ï¼å
³ècategory)") |
| | | private Integer planLineNum; |
| | | @ApiModelProperty(value = "ä¼åç»æ", example = "1") |
| | | //@ExcelColumn(name="主线路ç¼ç ï¼å
³ècategory)") |
| | | private String planLineInfo; |
| | | @ApiModelProperty(value = "ä¼åæ¶é´", example = "1") |
| | | //@ExcelColumn(name="主线路ç¼ç ï¼å
³ècategory)") |
| | | private Date planLineDate; |
| | | @ApiModelProperty(value = "ä¼åç»ææ¶é´", example = "1") |
| | | private Date planLineEndDate; |
| | | @ApiModelProperty(value = "ä¼å人å", example = "1") |
| | | //@ExcelColumn(name="主线路ç¼ç ï¼å
³ècategory)") |
| | | private Integer planLineUserId; |
| | | |
| | | @ApiModelProperty(value = "éè´§é", example = "1") |
| | | @ExcelColumn(name="éè´§éï¼æ¡ï¼",index = 4,width = 10) |
| | |
| | | @ExcelColumn(name="å®¢æ·æ°ï¼æ·ï¼",index = 3,width = 7) |
| | | private Integer orderNum; |
| | | |
| | | @ApiModelProperty(value = "ç¶æ 0æªä¼å 1ä¼åä¸ 2å·²ä¼å", example = "1") |
| | | @ExcelColumn(name="ç¶æ",index = 5,width = 10,valueMapping = "0=æªä¼å;1=ä¼åä¸;2=å·²ä¼å;") |
| | | @ApiModelProperty(value = "ç¶æ 0æªä¼å 1ä¼åä¸ 2å·²ä¼å 3ä¼å失败", example = "1") |
| | | @ExcelColumn(name="ç¶æ",index = 5,width = 10,valueMapping = "0=æªä¼å;1=ä¼åä¸;2=å·²ä¼å;3=ä¼å失败;") |
| | | private Integer status; |
| | | |
| | | @ApiModelProperty(value = "æåºç ", example = "1") |
| | |
| | | @ApiModelProperty(value = "ä¼åè®°å½ç¼ç (ä½ä¸ºkeyå¼åredisï¼", example = "1") |
| | | //@ExcelColumn(name="çç»ç¼ç ï¼å
³ècategoryï¼") |
| | | private String jobId; |
| | | @ApiModelProperty(value = "ä¼åéç¨æ°ï¼ç±³ï¼", example = "1") |
| | | private Long distance; |
| | | @ApiModelProperty(value = "åå§éç¨æ°ï¼ç±³ï¼", example = "1") |
| | | private Long originDistance; |
| | | @ApiModelProperty(value = "æ¥æ") |
| | | @ExcelColumn(name="éè´§æ¥æ",index = 1,width = 10) |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | private Date dateInfo; |
| | | |
| | | |
| | | @ApiModelProperty(value = "æå±ä¸»çº¿è·¯", example = "1") |
| | | @ExcelColumn(name="主线路",index = 2,width = 10) |
| | | @TableField(exist = false) |
| | | private String categoryName; |
| | | @ApiModelProperty(value = "æ¯å¦å¼ºå¶ä¼å 0å¦ 1æ¯", example = "1") |
| | | @TableField(exist = false) |
| | | private Integer forceUpdate; |
| | | |
| | | @ApiModelProperty(value = "线路客æ·è®¢åä¿¡æ¯", example = "1") |
| | | @TableField(exist = false) |
| | | List<JkSketchCustomer> customerList; |
| | | @ApiModelProperty(value = "线路éå", example = "1") |
| | | @TableField(exist = false) |
| | | List<JkLine> lineList; |
| | | @ApiModelProperty(value = "线路ç¼ç éå", example = "1") |
| | | @TableField(exist = false) |
| | | List<Integer> lineIdList; |
| | | |
| | | } |
| | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 交æ§-线路ä¼å线路客æ·è®°å½ä¿¡æ¯è¡¨ |
| | |
| | | //@ExcelColumn(name="æå±ä¸»çº¿è·¯",index = 2,width = 10) |
| | | @TableField(exist = false) |
| | | private Integer categoryId; |
| | | @ApiModelProperty(value = "ç»åº¦", example = "1") |
| | | //@ExcelColumn(name="ç»åº¦") |
| | | @TableField(exist = false) |
| | | private BigDecimal longitude; |
| | | @ApiModelProperty(value = "æå¨ä½ç½®") |
| | | @TableField(exist = false) |
| | | private String location; |
| | | @ApiModelProperty(value = "维度", example = "1") |
| | | //@ExcelColumn(name="维度") |
| | | @TableField(exist = false) |
| | | private BigDecimal latitude; |
| | | |
| | | @ApiModelProperty(value = "åçç»é´å®¢æ·ä½ç½®è·ç¦»æ°ç»ï¼[{a:12,b:100},{a:13,b:200},...],aï¼å®¢æ·ç¼ç ï¼bï¼ä¸å®¢æ·aä¹é´çè·ç¦»") |
| | | @TableField(exist = false) |
| | | private List<Map<String,Object>> distanceList; |
| | | } |
| | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 交æ§-线路ä¼å线路记å½ä¿¡æ¯è¡¨ |
| | |
| | | @ApiModelProperty(value = "线路ç¼ç ï¼å
³èjk_line)", example = "1") |
| | | @ExcelColumn(name="线路ç¼ç ï¼å
³èjk_line)") |
| | | private Integer lineId; |
| | | @ApiModelProperty(value = "è·¯ç¨æ°", example = "1") |
| | | @ExcelColumn(name="è·¯ç¨æ°") |
| | | private Long distance; |
| | | |
| | | @ApiModelProperty(value = "线路ä¼åç¼ç ï¼å
³èjk_sketch)", example = "1") |
| | | @ExcelColumn(name="线路ä¼åç¼ç ï¼å
³èjk_sketch)") |
| | |
| | | @ApiModelProperty(value = "æå±ä¸»çº¿è·¯ç¼ç ", example = "1") |
| | | @TableField(exist = false) |
| | | private Integer categoryId; |
| | | @ApiModelProperty(value = "å®¢æ·æç»", example = "1") |
| | | @TableField(exist = false) |
| | | private List<JkSketchCustomer> customerList; |
| | | |
| | | @ApiModelProperty(value = "æå¤§å®¢æ·é", example = "1") |
| | | @TableField(exist = false) |
| | | private Integer maxCustomer; |
| | | |
| | | @ApiModelProperty(value = "æå¤§è®¢åé", example = "1") |
| | | @TableField(exist = false) |
| | | private Integer maxOrder; |
| | | |
| | | } |
| | |
| | | * |
| | | * @param jkSketch å®ä½å¯¹è±¡ |
| | | */ |
| | | void updateById(JkSketch jkSketch); |
| | | JkSketch updateById(JkSketch jkSketch ); |
| | | |
| | | /** |
| | | * æ¹é䏻鮿´æ° |
| | |
| | | long count(JkSketch jkSketch); |
| | | |
| | | List<JkSketch> importBatch(MultipartFile file, String dateInfo, LoginUserInfo loginUser); |
| | | |
| | | void startUpdateLineAsync(JkSketch model); |
| | | } |
| | |
| | | ); |
| | | } |
| | | }else{ |
| | | log.error("æ´æ°äº¤æ§ä¸å¿å®¢æ·ç»çº¬åº¦ä¿¡æ¯=====è·åjson=========="+json); |
| | | log.error("æ´æ°äº¤æ§ä¸å¿å®¢æ·ç»çº¬åº¦ä¿¡æ¯=====è·å失败=========="+c.getName()+"-"+c.getLocation()); |
| | | } |
| | | }catch (Exception e){ |
| | |
| | | |
| | | @Override |
| | | public List<JkLine> findList(JkLine jkLine) { |
| | | |
| | | MPJLambdaWrapper<JkLine> queryWrapper = new MPJLambdaWrapper<>(); |
| | | jkLine.setIsdeleted(Constants.ZERO); |
| | | QueryWrapper<JkLine> wrapper = new QueryWrapper<>(jkLine); |
| | | wrapper.lambda().orderByAsc(JkLine::getCode); |
| | | return jkLineMapper.selectList(wrapper); |
| | | queryWrapper.selectAll(JkLine.class ) |
| | | .selectAs(Member::getName,JkLine::getMemberName) |
| | | .selectAs(Cars::getCode,JkLine::getCarCode) |
| | | .leftJoin(Cars.class,Cars::getId,JkLine::getCarId ) |
| | | .leftJoin(Member.class,Member::getId,Cars::getMemberId ); |
| | | jkLine.setIsdeleted(Constants.ZERO); |
| | | if (jkLine.getIsdeleted() != null) { |
| | | queryWrapper.eq(JkLine::getIsdeleted, jkLine.getIsdeleted()); |
| | | } |
| | | if (jkLine.getCategoryId() != null) { |
| | | queryWrapper.eq(JkLine::getCategoryId, jkLine.getCategoryId()); |
| | | } |
| | | if (jkLine.getCarId() != null) { |
| | | queryWrapper.eq(JkLine::getCarId, jkLine.getCarId()); |
| | | } |
| | | if (jkLine.getStatus() != null) { |
| | | queryWrapper.eq(JkLine::getStatus, jkLine.getStatus()); |
| | | } |
| | | if (jkLine.getSortnum() != null) { |
| | | queryWrapper.eq(JkLine::getSortnum, jkLine.getSortnum()); |
| | | } |
| | | queryWrapper.orderByAsc(JkLine::getCode); |
| | | return jkLineMapper.selectJoinList(JkLine.class,queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public List<JkSketchCustomer> findList(JkSketchCustomer jkSketchCustomer) { |
| | | QueryWrapper<JkSketchCustomer> wrapper = new QueryWrapper<>(jkSketchCustomer); |
| | | return jkSketchCustomerMapper.selectList(wrapper); |
| | | MPJLambdaWrapper<JkSketchCustomer> queryWrapper = new MPJLambdaWrapper<>(); |
| | | jkSketchCustomer.setIsdeleted(Constants.ZERO); |
| | | queryWrapper.selectAll(JkSketchCustomer.class ) |
| | | .selectAs(JkCustomer::getName,JkSketchCustomer::getName) |
| | | .selectAs(JkCustomer::getCode,JkSketchCustomer::getCode) |
| | | .selectAs(JkCustomer::getLatitude,JkSketchCustomer::getLatitude) |
| | | .selectAs(JkCustomer::getLongitude,JkSketchCustomer::getLongitude) |
| | | .selectAs(JkCustomer::getLocation,JkSketchCustomer::getLocation) |
| | | .leftJoin(JkCustomer.class,JkCustomer::getId,JkSketchCustomer::getCustomerId ) ; |
| | | queryWrapper.like(jkSketchCustomer.getCode()!=null,JkCustomer::getCode,jkSketchCustomer.getCode()); |
| | | queryWrapper.like(jkSketchCustomer.getName()!=null,JkCustomer::getName,jkSketchCustomer.getName()); |
| | | if (jkSketchCustomer.getId() != null) { |
| | | queryWrapper.eq(JkSketchCustomer::getId,jkSketchCustomer.getId()); |
| | | } |
| | | if (jkSketchCustomer.getCreator() != null) { |
| | | queryWrapper.eq(JkSketchCustomer::getCreator,jkSketchCustomer.getCreator()); |
| | | } |
| | | if (jkSketchCustomer.getCreateDate() != null) { |
| | | queryWrapper.ge(JkSketchCustomer::getCreateDate, Utils.Date.getStart(jkSketchCustomer.getCreateDate())); |
| | | queryWrapper.le(JkSketchCustomer::getCreateDate, Utils.Date.getEnd(jkSketchCustomer.getCreateDate())); |
| | | } |
| | | if (jkSketchCustomer.getEditor() != null) { |
| | | queryWrapper.eq(JkSketchCustomer::getEditor,jkSketchCustomer.getEditor()); |
| | | } |
| | | if (jkSketchCustomer.getEditDate() != null) { |
| | | queryWrapper.ge(JkSketchCustomer::getEditDate, Utils.Date.getStart(jkSketchCustomer.getEditDate())); |
| | | queryWrapper.le(JkSketchCustomer::getEditDate, Utils.Date.getEnd(jkSketchCustomer.getEditDate())); |
| | | } |
| | | if (jkSketchCustomer.getIsdeleted() != null) { |
| | | queryWrapper.eq(JkSketchCustomer::getIsdeleted,jkSketchCustomer.getIsdeleted()); |
| | | } |
| | | if (jkSketchCustomer.getInfo() != null) { |
| | | queryWrapper.eq(JkSketchCustomer::getInfo,jkSketchCustomer.getInfo()); |
| | | } |
| | | if (jkSketchCustomer.getSketchLineId() != null) { |
| | | queryWrapper.eq(JkSketchCustomer::getSketchLineId,jkSketchCustomer.getSketchLineId()); |
| | | } |
| | | if (jkSketchCustomer.getSketchId() != null) { |
| | | queryWrapper.eq(JkSketchCustomer::getSketchId,jkSketchCustomer.getSketchId()); |
| | | } |
| | | if (jkSketchCustomer.getTotalNum() != null) { |
| | | queryWrapper.eq(JkSketchCustomer::getTotalNum,jkSketchCustomer.getTotalNum()); |
| | | } |
| | | if (jkSketchCustomer.getOrderId() != null) { |
| | | queryWrapper.eq(JkSketchCustomer::getOrderId,jkSketchCustomer.getOrderId()); |
| | | } |
| | | if (jkSketchCustomer.getSortnum() != null) { |
| | | queryWrapper.eq(JkSketchCustomer::getSortnum,jkSketchCustomer.getSortnum()); |
| | | } |
| | | |
| | | queryWrapper.orderByAsc(JkSketchCustomer::getSketchLineId,JkSketchCustomer::getSortnum); |
| | | return jkSketchCustomerMapper.selectJoinList(JkSketchCustomer.class,queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | |
| | | .selectAs(Category::getName,JkSketchCustomer::getCategoryName) |
| | | .leftJoin(JkOrders.class,JkOrders::getId,JkSketchCustomer::getOrderId ) |
| | | .leftJoin(JkCustomer.class,JkCustomer::getId,JkSketchCustomer::getCustomerId ) |
| | | .leftJoin(JkLine.class,JkLine::getId,JkOrders::getLineId ) |
| | | .leftJoin(JkSketchLine.class,JkSketchLine::getId,JkSketchCustomer::getSketchLineId ) |
| | | .leftJoin(JkLine.class,JkLine::getId,JkSketchLine::getLineId ) |
| | | .leftJoin(Category.class,Category::getId,JkLine::getCategoryId ); |
| | | queryWrapper.eq( pageWrap.getModel().getCategoryId()!=null,JkLine::getCategoryId, pageWrap.getModel().getCategoryId()); |
| | | queryWrapper.eq( pageWrap.getModel().getDateInfo()!=null,JkSketchCustomer::getDateInfo, pageWrap.getModel().getDateInfo()); |
| | | queryWrapper.like( pageWrap.getModel().getCode()!=null,JkCustomer::getCode, pageWrap.getModel().getCode()); |
| | | queryWrapper.like( pageWrap.getModel().getName()!=null,JkCustomer::getName, pageWrap.getModel().getName()); |
| | | |
| | | if (pageWrap.getModel().getId() != null) { |
| | | queryWrapper.eq(JkSketchCustomer::getId, pageWrap.getModel().getId()); |
| | |
| | | queryWrapper.eq(JkSketchCustomer::getSortnum, pageWrap.getModel().getSortnum()); |
| | | } |
| | | |
| | | queryWrapper.orderByAsc(JkSketchCustomer::getSketchLineId); |
| | | queryWrapper.orderByAsc(JkSketchCustomer::getSketchLineId,JkSketchCustomer::getSortnum); |
| | | IPage<JkSketchCustomer> result = jkSketchCustomerMapper.selectJoinPage(page, JkSketchCustomer.class,queryWrapper); |
| | | return PageData.from(result); |
| | | } |
| | |
| | | .selectAs(JkLine::getName,JkSketchLine::getLineName) |
| | | .selectAs(Category::getId,JkSketchLine::getCategoryId) |
| | | .selectAs(Category::getName,JkSketchLine::getCategoryName) |
| | | .selectAs(JkLine::getMaxOrder,JkSketchLine::getMaxOrder) |
| | | .selectAs(JkLine::getMaxCustomer,JkSketchLine::getMaxCustomer) |
| | | .leftJoin(JkLine.class,JkLine::getId,JkOrders::getLineId ) |
| | | .leftJoin(Cars.class,Cars::getId,JkLine::getCarId ) |
| | | .leftJoin(Member.class,Member::getId,Cars::getMemberId ) |
| | | .leftJoin(Category.class,Category::getId,JkLine::getCategoryId ); |
| | | wrapper.eq( jkSketchLine.getSketchId()!=null,JkSketchLine::getSketchId, jkSketchLine.getSketchId()) |
| | | .eq( JkSketchLine::getIsdeleted,Constants.ZERO); |
| | | .eq( JkSketchLine::getIsdeleted,Constants.ZERO) |
| | | .orderByAsc(JkLine::getSortnum ); |
| | | |
| | | return jkSketchLineMapper.selectJoinList(JkSketchLine.class,wrapper); |
| | | } |
| | |
| | | import com.doumee.core.annotation.excel.ExcelImporter; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.DateUtil; |
| | | import com.doumee.dao.admin.request.JkCustomerImport; |
| | | import com.doumee.core.utils.*; |
| | | import com.doumee.core.utils.tsp.TspSolver; |
| | | import com.doumee.core.utils.tsp.TspSolverSolutions; |
| | | import com.doumee.dao.admin.request.JkOrdersImport; |
| | | 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.Utils; |
| | | import com.doumee.service.business.JkSketchService; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.checkerframework.checker.units.qual.C; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.*; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | |
| | | } |
| | | jkSketchMapper.deleteBatchIds(ids); |
| | | } |
| | | //线路ä¼å |
| | | @Override |
| | | public JkSketch updateById(JkSketch jkSketch ) { |
| | | JkSketch model = jkSketchMapper.selectById(jkSketch.getId()); |
| | | if(model == null ||Constants.equalsInteger(model.getIsdeleted(),Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | if( model.getDateInfo() == null){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"è¯¥çº¿è·¯æ¥æä¿¡æ¯ä¸æ£ç¡®ï¼ä¸æ¯æä¼åï¼"); |
| | | } |
| | | if(Constants.equalsInteger(Constants.ZERO,jkSketch.getForceUpdate()) && Constants.equalsInteger(model.getStatus(),Constants.ONE)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"该线路å卿£å¨ä¼åä¸ï¼è¯·èå¿çå¾
ä¼å宿æè
éæ©å¼ºå¶ä¼åæä½ï¼"); |
| | | } |
| | | |
| | | if( jkSketch.getLineIdList() ==null || jkSketch.getLineIdList().size()==0 ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"è¯·éæ©ææåçç线路è¿è¡ä¼åæä½ï¼"); |
| | | } |
| | | //å½åææçº¿è·¯(ç¬¦åæ¡ä»¶ççº¿è·¯ï¼ |
| | | List<JkLine> lineList = jkLineMapper.selectJoinList(JkLine.class,new MPJLambdaWrapper<JkLine>() |
| | | .selectAll(JkLine.class) |
| | | .eq(JkLine::getWeeks,DateUtil.getWeekZhouOfDate(model.getDateInfo()))//åªè½éæ©å½åç线路 |
| | | .eq(JkLine::getIsdeleted,Constants.ZERO) |
| | | .in(JkLine::getId,jkSketch.getLineIdList()) |
| | | ); |
| | | Integer totalCus = 0,totalNum =0; |
| | | for(JkLine line :lineList){ |
| | | totalCus += Constants.formatIntegerNum(line.getMaxCustomer());//æ»å®¢æ·é |
| | | totalNum += Constants.formatIntegerNum(line.getMaxOrder());//æ»éè´§é |
| | | } |
| | | |
| | | if( totalCus < Constants.formatIntegerNum(model.getOrderNum()) ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"该线路订åå®¢æ·æ°éè¶
è¿äºçº¿è·¯æ»å®¢æ·ééå¶ï¼æ æ³è¿è¡ä¼åï¼"); |
| | | } |
| | | if( totalNum < Constants.formatBigdecimal(model.getTotalNum()).doubleValue()){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"该线路订åéè´§éè¶
è¿äºçº¿è·¯æ»éè´§ééå¶ï¼æ æ³è¿è¡ä¼åï¼"); |
| | | } |
| | | model.setLineList(lineList);//线路éå |
| | | model.setCustomerList(checkJketchCustomerLocation(model));//订åéå |
| | | model.setStatus(Constants.ONE); |
| | | model.setPlanLineNum(lineList.size()); |
| | | model.setEditDate(new Date()); |
| | | model.setEditor(jkSketch.getLoginUserInfo().getId()); |
| | | model.setPlanLineDate(model.getEditDate()); |
| | | model.setPlanLineUserId(jkSketch.getLoginUserInfo().getId()); |
| | | model.setJobId(UUID.randomUUID().toString()); |
| | | redisTemplate.opsForValue().set(Constants.RedisKeys.JKLINE_JOB+model.getJobId(),true );//å弿¥å¤ç |
| | | jkSketchMapper.updateById(model); |
| | | return model; |
| | | } |
| | | |
| | | @Override |
| | | public void updateById(JkSketch jkSketch) { |
| | | jkSketchMapper.updateById(jkSketch); |
| | | @Async |
| | | public void startUpdateLineAsync(JkSketch model) { |
| | | try { |
| | | List<JkSketchCustomer> customerList = model.getCustomerList(); |
| | | List<JkLine> lineList = model.getLineList(); |
| | | TspSolver.DataModel dataModel = new TspSolver.DataModel(); |
| | | int vehicleNumber1 = lineList.size();//线路æ°é |
| | | long[] vehicleCapacities1=new long[lineList.size()];//æ¯è¾è½¦çæå¤§è®¢åééå¶ |
| | | long[] demands1 = new long[customerList.size()+1]; //å个ç¹ç订åé |
| | | long[][] distanceMatrix1 = new long[customerList.size()+1][customerList.size()+1]; |
| | | demands1[0] =0;//åç¹ |
| | | double cLatitude =0; |
| | | double cLongitude =0; |
| | | String location = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.COMPANY_LOCATION).getCode(); |
| | | try { |
| | | String[] ss = location.split(","); |
| | | cLongitude = Double.parseDouble(ss[0]); |
| | | cLatitude = Double.parseDouble(ss[1]); |
| | | }catch (Exception e){ |
| | | |
| | | } |
| | | |
| | | for (int i = 0; i < customerList.size(); i++) { |
| | | distanceMatrix1[0][i] = DistanceCalculator.calculateDistance(cLatitude,cLongitude,customerList.get(i).getLatitude().doubleValue(),customerList.get(i).getLongitude().doubleValue())/1000; |
| | | distanceMatrix1[i][0] = distanceMatrix1[0][i]; |
| | | demands1[i+1] = Constants.formatBigdecimal( customerList.get(i).getTotalNum()).longValue(); //å个ç¹ç订åé |
| | | List<Map<String,Object>> disList = customerList.get(i).getDistanceList(); |
| | | for (int j = 0; j< disList.size(); j++) { |
| | | if(disList.size()>j){ |
| | | distanceMatrix1[i+1][j+1] = (Long) disList.get(j).get("b")/1000;//æé è·ç¦»ç©éµ |
| | | }else{ |
| | | distanceMatrix1[i+1][j+1] = 1l; |
| | | } |
| | | } |
| | | } |
| | | for (int i = 0; i < lineList.size(); i++) { |
| | | vehicleCapacities1[i] = lineList.get(i).getMaxOrder();//æ¯è¾è½¦çæå¤§è®¢åééå¶ |
| | | } |
| | | //æé ä¼åæ°æ®æ¨¡å |
| | | dataModel.initDataInfo(vehicleNumber1,demands1,vehicleCapacities1,distanceMatrix1); |
| | | TspSolver.startSearch(dataModel); |
| | | dealSearchSolution(model,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,"æè¿ä¸æ¬¡çº¿è·¯ä¼å失败ï¼") |
| | | .set(JkSketch::getStatus,Constants.THREE) |
| | | .set(JkSketch::getPlanLineEndDate,new Date())); |
| | | } |
| | | |
| | | } |
| | | |
| | | private void dealSearchSolution(JkSketch model, 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(); |
| | | if(routes.size() <=2) { |
| | | continue;//æ 客æ·çéææè·¯çº¿ |
| | | } |
| | | totalDistance+= so.getDistance(); |
| | | 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.setOrderNum(routes.size()-2); |
| | | tModel.setDateInfo(model.getDateInfo()); |
| | | 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 || cIndex == routes.size()-1){ |
| | | continue; //èµ·å§ç¹ä¸å¤ç |
| | | } |
| | | JkSketchCustomer customer = model.getCustomerList().get(cIndex-1); |
| | | tModel.setTotalNum(tModel.getTotalNum().add(Constants.formatBigdecimal(customer.getTotalNum())));//éè´§é |
| | | JkSketchCustomer cModel = new JkSketchCustomer(); |
| | | cModel.setCreator(tModel.getCreator()); |
| | | cModel.setOrderId(customer.getOrderId()); |
| | | cModel.setCreateDate(tModel.getCreateDate()); |
| | | 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()); |
| | | tModel.getCustomerList().add(cModel); |
| | | if(cIndex ==0 || cIndex == routes.size()-1){ |
| | | continue; //èµ·å§ç¹ä¸å¤ç |
| | | } |
| | | } |
| | | } |
| | | } |
| | | 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::getDateInfo,model.getDateInfo())); |
| | | jkSketchCustomerMapper.update(null,new UpdateWrapper<JkSketchCustomer>().lambda() |
| | | .set(JkSketchCustomer::getIsdeleted,Constants.ONE) |
| | | .eq(JkSketchCustomer::getIsdeleted,Constants.ZERO) |
| | | .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::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 List<JkSketchCustomer> checkJketchCustomerLocation(JkSketch model) { |
| | | |
| | | MPJLambdaWrapper<JkSketchCustomer> queryWrapper = new MPJLambdaWrapper<>(); |
| | | queryWrapper.selectAll(JkSketchCustomer.class ) |
| | | .selectAs(JkCustomer::getName,JkSketchCustomer::getName) |
| | | .selectAs(JkCustomer::getCode,JkSketchCustomer::getCode) |
| | | .selectAs(JkCustomer::getLongitude,JkSketchCustomer::getLongitude) |
| | | .selectAs(JkCustomer::getLatitude,JkSketchCustomer::getLatitude) |
| | | .leftJoin(JkCustomer.class,JkCustomer::getId,JkSketchCustomer::getCustomerId ) |
| | | .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(),"该线路客æ·ä¿¡æ¯ä¸ºç©ºï¼ä¸æ»¡è¶³ä¼åæ¡ä»¶ï¼"); |
| | | } |
| | | String errorMsg =""; |
| | | for(JkSketchCustomer c : customerList){ |
| | | if(c.getLatitude()==null || c.getLongitude() ==null){ |
| | | errorMsg += c.getName()+"-"+c.getName()+"ï¼"; |
| | | } |
| | | } |
| | | if(StringUtils.isNotBlank(errorMsg)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"该线路客æ·:"+errorMsg+"å®ä½ä¿¡æ¯ä¸å®æ´ï¼ä¸æ»¡è¶³ä¼åæ¡ä»¶ï¼"); |
| | | } |
| | | for(JkSketchCustomer c : customerList){ |
| | | List<Map<String,Object>> tmpList = new ArrayList<>(); |
| | | for(JkSketchCustomer cm : customerList){ |
| | | Map<String,Object> t = new HashMap<>(); |
| | | t.put("a",cm.getId()); |
| | | if(Constants.equalsInteger(c.getCustomerId(),cm.getCustomerId())){ |
| | | t.put("b",0l); |
| | | }else{ |
| | | t.put("b", DistanceCalculator.calculateDistance( |
| | | Constants.formatBigdecimal(c.getLatitude()).doubleValue(), |
| | | Constants.formatBigdecimal(c.getLatitude()).doubleValue(), |
| | | Constants.formatBigdecimal(cm.getLatitude()).doubleValue(), |
| | | Constants.formatBigdecimal(cm.getLongitude()).doubleValue())); |
| | | } |
| | | tmpList.add(t); |
| | | } |
| | | c.setDistanceList(tmpList); |
| | | } |
| | | |
| | | if(Constants.equalsInteger(Constants.ZERO,model.getStatus())){ |
| | | //å¦ææ¯æªä¼åç¶æï¼è®¡ç®åå§è·ç¦» |
| | | long totalDistance = 0; |
| | | MPJLambdaWrapper<JkSketchLine> queryWrapper1 = new MPJLambdaWrapper<>(); |
| | | queryWrapper1.selectAll(JkSketchLine.class ) |
| | | .eq(JkSketchLine::getSketchId, model.getId()) |
| | | .eq(JkSketchLine::getIsdeleted,Constants.ZERO); |
| | | List<JkSketchLine> lineList = jkSketchLineMapper.selectJoinList(JkSketchLine.class,queryWrapper1);// |
| | | if(lineList!=null ||lineList.size()>0){ |
| | | double cLatitude =0; |
| | | double cLongitude =0; |
| | | String location = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.COMPANY_LOCATION).getCode(); |
| | | try { |
| | | String[] ss = location.split(","); |
| | | cLongitude = Double.parseDouble(ss[0]); |
| | | cLatitude = Double.parseDouble(ss[1]); |
| | | }catch (Exception e){ |
| | | |
| | | } |
| | | for(JkSketchLine line : lineList){ |
| | | boolean isFirst =true; |
| | | JkSketchCustomer last = null; |
| | | for(JkSketchCustomer c : customerList){ |
| | | if(Constants.equalsInteger(c.getSketchLineId(),line.getId())){ |
| | | if(isFirst){ |
| | | totalDistance += DistanceCalculator.calculateDistance(cLatitude,cLongitude |
| | | ,Constants.formatBigdecimal(c.getLatitude()).doubleValue() |
| | | ,Constants.formatBigdecimal(c.getLongitude()).doubleValue()); |
| | | }else{ |
| | | totalDistance += DistanceCalculator.calculateDistance(Constants.formatBigdecimal(c.getLatitude()).doubleValue() |
| | | ,Constants.formatBigdecimal(c.getLongitude()).doubleValue() |
| | | ,Constants.formatBigdecimal(last.getLatitude()).doubleValue() |
| | | ,Constants.formatBigdecimal(last.getLongitude()).doubleValue()); |
| | | } |
| | | last = c; |
| | | isFirst=false; |
| | | } |
| | | if(last!=null){ |
| | | totalDistance += DistanceCalculator.calculateDistance(cLatitude,cLongitude |
| | | ,Constants.formatBigdecimal(last.getLatitude()).doubleValue() |
| | | ,Constants.formatBigdecimal(last.getLongitude()).doubleValue()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | model.setOriginDistance(totalDistance); |
| | | } |
| | | |
| | | return customerList; |
| | | } |
| | | |
| | | @Override |
| | |
| | | return jkSketchMapper.selectCount(wrapper); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class,BusinessException.class}) |
| | | public List<JkSketch> importBatch(MultipartFile file, String dateInfoStr, LoginUserInfo loginUser){ |
| | |
| | | .selectAll(JkCustomer.class) |
| | | .eq(JkCustomer::getIsdeleted,Constants.ZERO) |
| | | ); |
| | | String week = DateUtil.getWeekZhouOfDate(dateInfo); |
| | | //å½åææçº¿è·¯ |
| | | List<JkLine> lineList = jkLineMapper.selectJoinList(JkLine.class,new MPJLambdaWrapper<JkLine>() |
| | | .selectAll(JkLine.class) |
| | | .eq(JkLine::getWeeks,week)//åªè½éæ©å½åç线路 |
| | | .eq(JkLine::getIsdeleted,Constants.ZERO) |
| | | ); |
| | | List<JkOrders> newOrderList = new ArrayList<>(); |
| | |
| | | jkOrdersMapper.insert(newOrderList); |
| | | } |
| | | |
| | | List<JkSketchLine> sketchLineList = initNewSketchLineList(newList,newOrderList); |
| | | List<JkSketchLine> sketchLineList = initNewSketchLineList(newList,newOrderList,lineList); |
| | | jkSketchLineMapper.update(null,new UpdateWrapper<JkSketchLine>().lambda() |
| | | .set(JkSketchLine::getIsdeleted,Constants.ONE) |
| | | .eq(JkSketchLine::getIsdeleted,Constants.ZERO) |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | private List<JkSketchCustomer> initNewSketchCustomerList(List<JkSketchLine> sketchLineList, List<JkOrders> newOrderList) { |
| | | List<JkSketchCustomer> list =new ArrayList<>(); |
| | | for(JkOrders orders : newOrderList){ |
| | |
| | | } |
| | | return list; |
| | | } |
| | | private List<JkSketchLine> initNewSketchLineList(List<JkSketch> newList, List<JkOrders> newOrderList) { |
| | | private List<JkSketchLine> initNewSketchLineList(List<JkSketch> newList, List<JkOrders> newOrderList,List<JkLine> lineList) { |
| | | List<JkSketchLine> list =new ArrayList<>(); |
| | | for(JkOrders orders : newOrderList){ |
| | | for (JkLine line : lineList){ |
| | | JkSketchLine tModel = new JkSketchLine(); |
| | | tModel.setSketchId(getSKetchIdByyCategoryId(line.getCategoryId(),newList)); |
| | | tModel.setCreator(newList.get(0).getCreator()); |
| | | tModel.setCreateDate(newList.get(0).getCreateDate()); |
| | | tModel.setLineId(line.getId()); |
| | | initOrderAndTotalNum(tModel,line.getId(),newOrderList); |
| | | tModel.setDateInfo(newList.get(0).getDateInfo()); |
| | | tModel.setSortnum(list.size()+1); |
| | | tModel.setEditDate(tModel.getCreateDate()); |
| | | tModel.setEditor(tModel.getCreator()); |
| | | tModel.setIsdeleted(Constants.ZERO); |
| | | if(tModel.getSketchId()!=null && Constants.formatIntegerNum(tModel.getOrderNum()) >0){ |
| | | list.add(tModel); |
| | | } |
| | | } |
| | | /*for(JkOrders orders : newOrderList){ |
| | | JkSketchLine tModel = findModelFromListByLineId(orders.getLineId(),list); |
| | | if(tModel!=null){ |
| | | tModel.setTotalNum( tModel.getTotalNum().add(orders.getNum()));//订åé累计 |
| | |
| | | list.add(tModel); |
| | | } |
| | | } |
| | | } |
| | | }*/ |
| | | return list; |
| | | } |
| | | |
| | | private void initOrderAndTotalNum(JkSketchLine tModel, Integer id, List<JkOrders> newOrderList) { |
| | | for(JkOrders orders : newOrderList){ |
| | | if(Constants.equalsInteger(orders.getLineId(),id)){ |
| | | tModel.setOrderNum(Constants.formatIntegerNum(tModel.getOrderNum())+1); |
| | | tModel.setTotalNum(Constants.formatBigdecimal(tModel.getTotalNum()).add(Constants.formatBigdecimal(orders.getNum()))); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private Integer getSKetchIdByyCategoryId(Integer categoryId, List<JkSketch> newList) { |
| | |
| | | } |
| | | JkLine line = findLineFromListByName(model.getLineName(),lineList); |
| | | if(line == null){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "对ä¸èµ·ï¼ç¬¬" + (index + 3) + "è¡çº¿è·¯ã" + model.getLineName() + "ãä¸åå¨ï¼è¯·æ£æ¥è¡¨æ ¼å
容ï¼"); |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "对ä¸èµ·ï¼ç¬¬" + (index + 3) + "è¡çº¿è·¯ã" + model.getLineName() + "ãä¸å卿è
é
é卿ä¸ç¬¦åï¼è¯·æ£æ¥è¡¨æ ¼å
容ï¼"); |
| | | } |
| | | |
| | | JkOrders tModel = new JkOrders(); |
| | |
| | | tModel.setNum(getDecimalByVal(model.getNum())); |
| | | tModel.setCustomerId(customer.getId()); |
| | | tModel.setDateInfo(dateInfo); |
| | | tModel.setLatitude(customer.getLatitude()); |
| | | tModel.setLongitude(customer.getLongitude()); |
| | | tModel.setSortnum(model.getSortnum()); |
| | | tModel.setLineId(line.getId()); |
| | | tModel.setCategoryId(line.getCategoryId()); |