From 16bbe24e5bd95f3d10a67b0255edd94b9bff1b50 Mon Sep 17 00:00:00 2001 From: zhangyouji Date: Mon, 5 Feb 2024 16:16:23 +0800 Subject: [PATCH 1/4] OCR --- .../pages/components/price-select-tab.vue | 76 +++++++++++++++++++ api/user.js | 12 +++ 2 files changed, 88 insertions(+) create mode 100644 api/user.js diff --git a/BagStation/pages/components/price-select-tab.vue b/BagStation/pages/components/price-select-tab.vue index 5ee9568..3e39e21 100644 --- a/BagStation/pages/components/price-select-tab.vue +++ b/BagStation/pages/components/price-select-tab.vue @@ -188,6 +188,18 @@ + + + 车牌识别 + + + 拍照 + + + + + + 优惠 @@ -377,6 +389,7 @@ import oilOssApi from '@/api/oil-oss.js' import utils from '@/utils/encode' import oilInterfacesApi from '@/api/oil-interfaces.js' + import user from '@/api/user.js' export default { props: { channelList: { @@ -598,6 +611,69 @@ } }, methods: { + srcPhoto(){ + let _that = this + uni.chooseImage({ + count: 1, //默认9 + sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有 + sourceType: ['camera'], // 只能拍照 + success: function(res) { + console.log(res) + // uni.showLoading({ + // title: '识别中', + // mask: true + // }); + uni.saveImageToPhotosAlbum({ + filePath: res.tempFilePaths[0], + success: function (file) { + console.log('save success',res,file); + + const JSESSIONID = utils.uuid() + uni.uploadFile({ + url: 'http://uat.xingoil.com/oil-oss/obejct/uploadFile', + filePath: res.tempFilePaths[0], + formData: { + ossKey: 'xingyou', + pathKey: 'certificate', + encrypt: 'PUBLIC', + }, + name: 'file', + header: { + "Content-Type": "multipart/form-data", + "Authorization": uni.getStorageSync('Authorization'), + 'dataSources': 'MP', + "imei": uni.getStorageSync('unionid'), + "openId": uni.getStorageSync('openid'), + 'JSESSIONID': JSESSIONID, + 'token': utils.md5Salt(JSESSIONID) + }, + success(e) { + uni.hideLoading() + console.log('进入2') + console.log(e) + // let obj = JSON.parse(e.data), + // url = obj.data.publicUrl + // user.carNoIdentify(data).then((res) => { + // console.log(res) + // let obj = JSON.parse(res.data) + // console.log(obj) + // }) + },fail(res){ + uni.hideLoading() + console.log(res,'fail') + } + }) + + } + }); + + + + } + }) + + + }, typeChenk() { return this.channelList[this.activeCur]?.secondChannelCode && this.thirdPartyDynamicData.includes(this .channelList[this.activeCur].secondChannelCode) diff --git a/api/user.js b/api/user.js new file mode 100644 index 0000000..1c36a8e --- /dev/null +++ b/api/user.js @@ -0,0 +1,12 @@ +import request from '@/utils/request' +const service_name = "user" +const group_name = "oilCustomerInfo" +export default{ + carNoIdentify(data) { //图片上传-ORC识别 + return request({ + url: `/${service_name}/${group_name}/carNoIdentify`, + method: 'post', + data: data + }) + }, +} \ No newline at end of file From d7746faca31b2636b6959d8662238563f659cbc2 Mon Sep 17 00:00:00 2001 From: zhangyouji Date: Wed, 7 Feb 2024 16:52:36 +0800 Subject: [PATCH 2/4] OCR --- .../pages/components/price-select-tab.vue | 143 ++++++++++-------- api/user.js | 9 +- 2 files changed, 92 insertions(+), 60 deletions(-) diff --git a/BagStation/pages/components/price-select-tab.vue b/BagStation/pages/components/price-select-tab.vue index 3e39e21..cca9ffe 100644 --- a/BagStation/pages/components/price-select-tab.vue +++ b/BagStation/pages/components/price-select-tab.vue @@ -189,11 +189,17 @@ - - 车牌识别 - - - 拍照 + + + + 车牌识别 + + + + + + @@ -517,13 +523,16 @@ activeChannelCode: '', checkBar: [], realMoney: '', - xoilAmountGun: '' + xoilAmountGun: '', + plateNumberOcr:'', + plateNumberOcrShow:false } }, created() { let oilItem = uni.getStorageSync('oilItem'), oilSite = uni.getStorageSync(''), - otherUser = uni.getStorageSync('otherUserInfo') + otherUser = uni.getStorageSync('otherUserInfo'), + companyId = JSON.parse(uni.getStorageSync('companyCard')).companyId if (otherUser) { // console.log('这里是卡里') this.isOtherUser = true @@ -533,6 +542,8 @@ console.log('oilItem', oilItem) this.showtitles = oilItem.listTag; this.init() + console.log(companyId) + this.getCompanyConfig(companyId) }, watch: { activeChannelCode: { @@ -611,6 +622,18 @@ } }, methods: { + getCompanyConfig(companyId){ + if(companyId){ + user.getCompanyConfigByCompanyId(companyId).then(res=>{ + if(res.data.plateNumberOcr==1){ + this.plateNumberOcrShow = true + }else{ + this.plateNumberOcrShow = false + } + + }) + } + }, srcPhoto(){ let _that = this uni.chooseImage({ @@ -618,55 +641,33 @@ sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有 sourceType: ['camera'], // 只能拍照 success: function(res) { - console.log(res) - // uni.showLoading({ - // title: '识别中', - // mask: true - // }); - uni.saveImageToPhotosAlbum({ - filePath: res.tempFilePaths[0], - success: function (file) { - console.log('save success',res,file); - - const JSESSIONID = utils.uuid() - uni.uploadFile({ - url: 'http://uat.xingoil.com/oil-oss/obejct/uploadFile', - filePath: res.tempFilePaths[0], - formData: { - ossKey: 'xingyou', - pathKey: 'certificate', - encrypt: 'PUBLIC', - }, - name: 'file', - header: { - "Content-Type": "multipart/form-data", - "Authorization": uni.getStorageSync('Authorization'), - 'dataSources': 'MP', - "imei": uni.getStorageSync('unionid'), - "openId": uni.getStorageSync('openid'), - 'JSESSIONID': JSESSIONID, - 'token': utils.md5Salt(JSESSIONID) - }, - success(e) { - uni.hideLoading() - console.log('进入2') - console.log(e) - // let obj = JSON.parse(e.data), - // url = obj.data.publicUrl - // user.carNoIdentify(data).then((res) => { - // console.log(res) - // let obj = JSON.parse(res.data) - // console.log(obj) - // }) - },fail(res){ - uni.hideLoading() - console.log(res,'fail') - } - }) - - } - }); - + uni.showLoading({ + title: '识别中', + mask: true + }); + + const JSESSIONID = utils.uuid() + uni.uploadFile({ + url: 'http://uat.xingoil.com/adminapi/oil-oss/obejct/carNoIdentify', + filePath: res.tempFilePaths[0], + name: 'file', + header: { + "Content-Type": "multipart/form-data", + "Authorization": uni.getStorageSync('Authorization'), + 'dataSources': 'MP', + "imei": uni.getStorageSync('unionid'), + "openId": uni.getStorageSync('openid'), + 'JSESSIONID': JSESSIONID, + 'token': utils.md5Salt(JSESSIONID) + }, + success(e) { + uni.hideLoading() + let obj = JSON.parse(e.data) + _that.plateNumberOcr = obj.data.carNo + },fail(res){ + uni.hideLoading() + } + }) } @@ -1211,14 +1212,15 @@ 'xoilAmountGun': this.vol } } else { - var orderData = { + if(this.plateNumberOcrShow == true){ + var orderData = { amountGun: this.activeChannelCode == 'TY' ? this.ty.realMoney : '', shareCompanyQuota: 0, // 共享标识 priceId: this.oilSitePriceDetailsVo[this.radio].priceId, //类型:String 必有字段 备注:油价主键 orderType: "REAL_ORDER", //类型:String 必有字段 备注:订单类型(REAL_ORDER:真实订单 VIRTUAL_ORDER:虚拟订单) orderSource: "WECHAT_MINIAPPS", //类型:String 必有字段 备注:订单来源(WECHAT_MINIAPPS) - plateNumber: this.plateNumber ? this.plateNumber : this - .plateNumberSel, //类型:String 必有字段 备注:车牌号 + plateNumber: this.plateNumberOcrShow == true ? this.plateNumberOcr : this + .plateNumber, //类型:String 必有字段 备注:车牌号 siteUserName: this.jober, //类型:String 必有字段 备注:加油员 oilsBar: this.oilBar, //类型:Number 必有字段 备注:油枪 volume: this.activeChannelCode == 'TY' ? this.tyRes.liter : this @@ -1231,6 +1233,29 @@ 'version': 1, 'xoilAmountGun': this.vol } + }else{ + var orderData = { + amountGun: this.activeChannelCode == 'TY' ? this.ty.realMoney : '', + shareCompanyQuota: 0, // 共享标识 + priceId: this.oilSitePriceDetailsVo[this.radio].priceId, //类型:String 必有字段 备注:油价主键 + orderType: "REAL_ORDER", //类型:String 必有字段 备注:订单类型(REAL_ORDER:真实订单 VIRTUAL_ORDER:虚拟订单) + orderSource: "WECHAT_MINIAPPS", //类型:String 必有字段 备注:订单来源(WECHAT_MINIAPPS) + plateNumber: this.plateNumber ? this.plateNumber : this + .plateNumberSel, //类型:String 必有字段 备注:车牌号 + siteUserName: this.jober, //类型:String 必有字段 备注:加油员 + oilsBar: this.oilBar, //类型:Number 必有字段 备注:油枪 + volume: this.activeChannelCode == 'TY' ? this.tyRes.liter : this + .vol, //类型:Number 必有字段 备注:加油升数 + realPrice: this.oilSitePriceDetailsVo[this.radio].sitePrice, //类型:Number 必有字段 备注:实际加油价格 + suppleMark: 0, //类型:Number 必有字段 备注:补录标识(0:实时订单 1:补录订单) + createSource: "XOIL_DRIVER_COMPANY_WECHAT_APPLET", //类型:String 必有字段 备注:创建来源( XOIL_DRIVER_COMPANY_WECHAT_APPLET) + // "deviceImei": "mock", //类型:String 可有字段 备注:设备唯一码 + // "networkIp": "mock" //类型:String 可有字段 备注:ip地址 + 'version': 1, + 'xoilAmountGun': this.vol + } + } + } // console.log(orderData) let location = uni.getStorageSync('location') || { diff --git a/api/user.js b/api/user.js index 1c36a8e..a11fe2a 100644 --- a/api/user.js +++ b/api/user.js @@ -1,5 +1,5 @@ import request from '@/utils/request' -const service_name = "user" +const service_name = "oil-user" const group_name = "oilCustomerInfo" export default{ carNoIdentify(data) { //图片上传-ORC识别 @@ -9,4 +9,11 @@ export default{ data: data }) }, + // 查询企业配置 + getCompanyConfigByCompanyId(id) { + return request({ + url: `/${service_name}/oil-user/getCompanyConfigByCompanyId?companyId=${id}`, + method: 'GET' + }) + }, } \ No newline at end of file From 71a31884914898a3b6c0d82ca128a3362cede242 Mon Sep 17 00:00:00 2001 From: zhangyouji Date: Mon, 19 Feb 2024 16:54:24 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/user.js b/api/user.js index a11fe2a..2887c24 100644 --- a/api/user.js +++ b/api/user.js @@ -12,7 +12,7 @@ export default{ // 查询企业配置 getCompanyConfigByCompanyId(id) { return request({ - url: `/${service_name}/oil-user/getCompanyConfigByCompanyId?companyId=${id}`, + url: `/${service_name}/sysCompanyConfig/getCompanyConfigByCompanyId/${id}`, method: 'GET' }) }, From 1cc0753efced5f8dcc6f0b3ae98b6cd04aa27e1d Mon Sep 17 00:00:00 2001 From: zhangyouji Date: Wed, 21 Feb 2024 15:04:21 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/components/price-select-tab.vue | 74 ++++++++++++++++++- 1 file changed, 72 insertions(+), 2 deletions(-) diff --git a/BagStation/pages/components/price-select-tab.vue b/BagStation/pages/components/price-select-tab.vue index cca9ffe..cab3d30 100644 --- a/BagStation/pages/components/price-select-tab.vue +++ b/BagStation/pages/components/price-select-tab.vue @@ -385,6 +385,39 @@ + + + + + + + + + + + + + + + + 识别失败! + + + + + + + + + + + + + + + + @@ -525,7 +558,9 @@ realMoney: '', xoilAmountGun: '', plateNumberOcr:'', - plateNumberOcrShow:false + plateNumberOcrShow:false, + showPlicePhoto:'', + plateNumberImages:'' } }, created() { @@ -622,6 +657,25 @@ } }, methods: { + manualInput(){ + this.showPlicePhoto='' + this.$refs.inputDialog.open() + }, + inputClose(){ + this.$refs.inputDialog.close() + }, + inputConfirm(val){ + if(val){ + this.plateNumberOcr = val + this.$refs.inputDialog.close() + }else{ + uni.showToast({ + title: '请输入车牌号', + icon: 'none' + }) + } + + }, getCompanyConfig(companyId){ if(companyId){ user.getCompanyConfigByCompanyId(companyId).then(res=>{ @@ -635,6 +689,7 @@ } }, srcPhoto(){ + this.showPlicePhoto='' let _that = this uni.chooseImage({ count: 1, //默认9 @@ -663,9 +718,16 @@ success(e) { uni.hideLoading() let obj = JSON.parse(e.data) - _that.plateNumberOcr = obj.data.carNo + if(obj.data&&obj.data.carNo){ + _that.plateNumberOcr = obj.data.carNo + _that.plateNumberImages = obj.data.imgUrl + }else{ + _that.plateNumberOcr = '' + _that.showPlicePhoto = 'show' + } },fail(res){ uni.hideLoading() + _that.showPlicePhoto = 'show' } }) @@ -1212,6 +1274,13 @@ 'xoilAmountGun': this.vol } } else { + if(!this.plateNumberOcr){ + uni.showToast({ + icon: 'none', + title: '请上传车牌照片' + }) + return + } if(this.plateNumberOcrShow == true){ var orderData = { amountGun: this.activeChannelCode == 'TY' ? this.ty.realMoney : '', @@ -1221,6 +1290,7 @@ orderSource: "WECHAT_MINIAPPS", //类型:String 必有字段 备注:订单来源(WECHAT_MINIAPPS) plateNumber: this.plateNumberOcrShow == true ? this.plateNumberOcr : this .plateNumber, //类型:String 必有字段 备注:车牌号 + plateNumberImages: this.plateNumberImages, // 车牌照片地址 siteUserName: this.jober, //类型:String 必有字段 备注:加油员 oilsBar: this.oilBar, //类型:Number 必有字段 备注:油枪 volume: this.activeChannelCode == 'TY' ? this.tyRes.liter : this