| | |
| | | export function fetchList (data) { |
| | | return request.post(base + '/page', data, { trim: true }) |
| | | } |
| | | |
| | | export function queryResult (id) { |
| | | return request.get(base + '/queryResult/' + id) |
| | | } |
| | |
| | | export function exportExcel (data) { |
| | | return request.post(base + '/exportExcel', data, { trim: true, download: true }) |
| | | } |
| | | |
| | | export function syncStatus (id) { |
| | | return request.get(base + '/syncStatus/' + id) |
| | | } |
| | |
| | | <el-button type="text" :disabled="!row.responseBody" @click="openJson('ååºæ¥æ', row.responseBody)">æ¥ç</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="æä½" min-width="120" align="center" fixed="right"> |
| | | <template slot-scope="{ row }"> |
| | | <el-button |
| | | v-if="row.status === 0 && row.oprId" |
| | | type="text" |
| | | :loading="queryLoadingId === row.id" |
| | | v-permissions="['business:ywelectricalactions:queryResult']" |
| | | @click="handleQueryResult(row)" |
| | | >æå¨æ¥è¯¢ç»æ</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <pagination |
| | | @size-change="handleSizeChange" |
| | |
| | | actionTypeOptions: Object.keys(ACTION_TYPE_MAP).map(key => ({ |
| | | value: Number(key), |
| | | label: ACTION_TYPE_MAP[key] |
| | | })) |
| | | })), |
| | | queryLoadingId: null |
| | | } |
| | | }, |
| | | created () { |
| | |
| | | openJson (title, content) { |
| | | if (!content) return |
| | | this.$refs.jsonWindow.open(title, { content }) |
| | | }, |
| | | handleQueryResult (row) { |
| | | this.queryLoadingId = row.id |
| | | actionsApi.queryResult(row.id) |
| | | .then(msg => { |
| | | this.$tip.success(msg || 'æ¥è¯¢å®æ') |
| | | this.handlePageChange(this.tableData.pagination.pageIndex) |
| | | }) |
| | | .catch(e => this.$tip.apiFailed(e)) |
| | | .finally(() => { this.queryLoadingId = null }) |
| | | } |
| | | } |
| | | } |
| | |
| | | <el-table-column prop="roomNames" label="ç»å®æ¿é´" min-width="150" align="center" show-overflow-tooltip/> |
| | | <el-table-column prop="money" label="å
å¼éé¢(å
)" min-width="110" align="center"/> |
| | | <el-table-column prop="banlance" label="å
å¼åä½é¢" min-width="110" align="center"/> |
| | | <el-table-column prop="balanceAfter" label="å
å¼åä½é¢" min-width="110" align="center"/> |
| | | <el-table-column label="ç¶æ" min-width="100" align="center"> |
| | | <template slot-scope="{ row }"> |
| | | <span v-if="row.status === 0">å
å¼ä¸</span> |
| | |
| | | <el-table-column prop="statusInfo" label="ç¶æè¯´æ" min-width="140" align="center" show-overflow-tooltip/> |
| | | <el-table-column prop="createDate" label="æäº¤æ¶é´" min-width="160" align="center"/> |
| | | <el-table-column prop="statusTime" label="ç¶ææ´æ°æ¶é´" min-width="160" align="center"/> |
| | | <el-table-column label="æä½" min-width="100" align="center" fixed="right"> |
| | | <template slot-scope="{ row }"> |
| | | <el-button v-if="row.status === 0" type="text" v-permissions="['business:ywelectricalcharge:syncStatus']" @click="handleSync(row)">æå¨åæ¥</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <pagination @size-change="handleSizeChange" @current-change="handlePageChange" :pagination="tableData.pagination"/> |
| | | </template> |
| | |
| | | reset () { |
| | | this.searchForm = { meterKeyword: '', status: '', oprId: '' } |
| | | this.search() |
| | | }, |
| | | handleSync (row) { |
| | | chargeApi.syncStatus(row.id) |
| | | .then(msg => { |
| | | this.$tip.success(msg || '忥宿') |
| | | this.handlePageChange(this.tableData.pagination.pageIndex) |
| | | }) |
| | | .catch(e => this.$tip.apiFailed(e)) |
| | | } |
| | | } |
| | | } |
| | |
| | | | ééå¨ç¶æ | `0 */5 * * * ?` | `getElectricalStatus` | GET `/timer/yw/getElectricalStatus` | |
| | | | æ¹éæè¡¨ | `30 0 * * * ?` | `syncElectricalMeterData` | GET `/timer/yw/syncElectricalMeterData` | |
| | | | æ¥å¿æ¸
ç | `0 30 2 * * ?` | `cleanElectricalLog` | GET `/timer/yw/cleanElectricalLog` | |
| | | | 弿¥ä»»å¡ç¶æè¡¥å¿ | `0 5 * * * ?` | `syncElectricalAsyncStatus` | GET `/timer/yw/syncElectricalAsyncStatus` | |
| | | | 空è°ç½å
³ç¶æ | `0 */5 * * * ?` | `syncConditionerGatewayStatus` | GET `/timer/yw/syncConditionerGatewayStatus` | |
| | | | 空è°å
æºç¶æ | `0 */10 * * * ?` | `syncConditionerIndoorUnits` | GET `/timer/yw/syncConditionerIndoorUnits` | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | -- åæ·ç©ºè° GS é
ç½®ï¼æ¬ è´¹é¢åº¦ï¼å
ï¼ |
| | | SET @db := DATABASE(); |
| | | |
| | | SET @sql := IF( |
| | | (SELECT COUNT(*) FROM information_schema.COLUMNS |
| | | WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'yw_customer_gs' AND COLUMN_NAME = 'stop_money') = 0, |
| | | 'ALTER TABLE `yw_customer_gs` ADD COLUMN `stop_money` decimal(12,2) DEFAULT 0 COMMENT ''æ¬ è´¹é¢åº¦ï¼å
ï¼'' AFTER `gs_bz`', |
| | | 'SELECT 1' |
| | | ); |
| | | PREPARE stmt FROM @sql; |
| | | EXECUTE stmt; |
| | | DEALLOCATE PREPARE stmt; |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | -- åæ·å
å¼ï¼ä¸ºè¶
级管çåè§è²è¡¥å
¨æéï¼å¯é夿§è¡ï¼ |
| | | -- æ§è¡åè¯·éæ°ç»å½ä»¥å·æ° Redis ä¸çæéç¼å |
| | | |
| | | INSERT INTO `SYSTEM_ROLE_PERMISSION` (`ROLE_ID`, `PERMISSION_ID`, `CREATE_TIME`, `UPDATE_TIME`, `CREATE_USER`, `UPDATE_USER`, `DELETED`) |
| | | SELECT r.`ID`, p.`ID`, CURRENT_TIMESTAMP, NULL, 1, NULL, 0 |
| | | FROM `SYSTEM_ROLE` r |
| | | INNER JOIN `SYSTEM_PERMISSION` p ON p.`CODE` IN ( |
| | | 'business:ywcustomerrecharge:query', |
| | | 'business:ywcustomerrecharge:exportExcel', |
| | | 'business:ywcustomerrecharge:bindDevice', |
| | | 'business:ywcustomerrecharge:recharge', |
| | | 'business:ywcustomerrechargerecord:query', |
| | | 'business:ywcustomerrechargerecord:exportExcel', |
| | | 'business:ywcustomerrechargerecord:retry', |
| | | 'business:ywcustomerrechargerecord:syncStatus' |
| | | ) AND p.`DELETED` = 0 |
| | | WHERE r.`DELETED` = 0 AND (r.`CODE` = 'admin' OR r.`NAME` IN ('è¶
级管çå', '管çå')) |
| | | AND NOT EXISTS ( |
| | | SELECT 1 FROM `SYSTEM_ROLE_PERMISSION` rp |
| | | WHERE rp.`ROLE_ID` = r.`ID` AND rp.`PERMISSION_ID` = p.`ID` AND rp.`DELETED` = 0 |
| | | ); |
| | | |
| | | INSERT INTO `SYSTEM_ROLE_MENU` (`ROLE_ID`, `MENU_ID`, `CREATE_TIME`, `UPDATE_TIME`, `CREATE_USER`, `UPDATE_USER`, `DELETED`) |
| | | SELECT r.`ID`, menu.`ID`, CURRENT_TIMESTAMP, NULL, 1, NULL, 0 |
| | | FROM `SYSTEM_ROLE` r |
| | | INNER JOIN `SYSTEM_MENU` menu ON menu.`DELETED` = 0 AND ( |
| | | (menu.`NAME` = 'åæ·å
å¼' AND (menu.`PATH` IS NULL OR menu.`PATH` = '')) |
| | | OR menu.`PATH` IN ('/business/ywcustomerrecharge', '/business/ywcustomerrechargerecord') |
| | | ) |
| | | WHERE r.`DELETED` = 0 AND (r.`CODE` = 'admin' OR r.`NAME` IN ('è¶
级管çå', '管çå')) |
| | | AND NOT EXISTS ( |
| | | SELECT 1 FROM `SYSTEM_ROLE_MENU` rm |
| | | WHERE rm.`ROLE_ID` = r.`ID` AND rm.`MENU_ID` = menu.`ID` AND rm.`DELETED` = 0 |
| | | ); |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | -- åæ·å
å¼ï¼ä¸çº§èå + 2 åèå + è¶
级管çåèåææ |
| | | |
| | | INSERT INTO `SYSTEM_MENU` (`PARENT_ID`, `NAME`, `PATH`, `REMARK`, `ICON`, `DISABLED`, `SORT`, `FIXED`, `CREATE_TIME`, `UPDATE_TIME`, `CREATE_USER`, `UPDATE_USER`, `DELETED`, `PARAMS`) |
| | | SELECT 0, 'åæ·å
å¼', '', 'åæ·çµè¡¨/空è°å
å¼ç®¡ç', NULL, 0, |
| | | IFNULL((SELECT MAX(sm.`SORT`) FROM `SYSTEM_MENU` sm WHERE sm.`PARENT_ID` = 0 AND sm.`DELETED` = 0), 0) + 1, |
| | | 0, CURRENT_TIMESTAMP, NULL, 1, NULL, 0, NULL |
| | | WHERE NOT EXISTS ( |
| | | SELECT 1 FROM `SYSTEM_MENU` x WHERE x.`DELETED` = 0 AND x.`NAME` = 'åæ·å
å¼' AND (x.`PATH` IS NULL OR x.`PATH` = '') |
| | | ); |
| | | |
| | | INSERT INTO `SYSTEM_MENU` (`PARENT_ID`, `NAME`, `PATH`, `REMARK`, `ICON`, `DISABLED`, `SORT`, `FIXED`, `CREATE_TIME`, `UPDATE_TIME`, `CREATE_USER`, `UPDATE_USER`, `DELETED`, `PARAMS`) |
| | | SELECT p.`ID`, 'åæ·å
å¼', '/business/ywcustomerrecharge', 'åæ·å表ãå
³è设å¤ãå
å¼', NULL, 0, 1, 0, CURRENT_TIMESTAMP, NULL, 1, NULL, 0, NULL |
| | | FROM `SYSTEM_MENU` p WHERE p.`DELETED` = 0 AND p.`NAME` = 'åæ·å
å¼' AND (p.`PATH` IS NULL OR p.`PATH` = '') |
| | | AND NOT EXISTS (SELECT 1 FROM `SYSTEM_MENU` x WHERE x.`DELETED` = 0 AND x.`PATH` = '/business/ywcustomerrecharge') |
| | | LIMIT 1; |
| | | |
| | | INSERT INTO `SYSTEM_MENU` (`PARENT_ID`, `NAME`, `PATH`, `REMARK`, `ICON`, `DISABLED`, `SORT`, `FIXED`, `CREATE_TIME`, `UPDATE_TIME`, `CREATE_USER`, `UPDATE_USER`, `DELETED`, `PARAMS`) |
| | | SELECT p.`ID`, 'å
å¼è®°å½', '/business/ywcustomerrechargerecord', 'çµè¡¨/空è°ç»ä¸å
å¼è®°å½', NULL, 0, 2, 0, CURRENT_TIMESTAMP, NULL, 1, NULL, 0, NULL |
| | | FROM `SYSTEM_MENU` p WHERE p.`DELETED` = 0 AND p.`NAME` = 'åæ·å
å¼' AND (p.`PATH` IS NULL OR p.`PATH` = '') |
| | | AND NOT EXISTS (SELECT 1 FROM `SYSTEM_MENU` x WHERE x.`DELETED` = 0 AND x.`PATH` = '/business/ywcustomerrechargerecord') |
| | | LIMIT 1; |
| | | |
| | | INSERT INTO `SYSTEM_ROLE_MENU` (`ROLE_ID`, `MENU_ID`, `CREATE_TIME`, `UPDATE_TIME`, `CREATE_USER`, `UPDATE_USER`, `DELETED`) |
| | | SELECT r.`ID`, menu.`ID`, CURRENT_TIMESTAMP, NULL, 1, NULL, 0 |
| | | FROM `SYSTEM_ROLE` r |
| | | INNER JOIN `SYSTEM_MENU` menu ON menu.`DELETED` = 0 AND ( |
| | | (menu.`NAME` = 'åæ·å
å¼' AND (menu.`PATH` IS NULL OR menu.`PATH` = '')) |
| | | OR menu.`PATH` IN ('/business/ywcustomerrecharge', '/business/ywcustomerrechargerecord') |
| | | ) |
| | | WHERE r.`DELETED` = 0 AND (r.`CODE` = 'admin' OR r.`NAME` IN ('è¶
级管çå', '管çå')) |
| | | AND NOT EXISTS ( |
| | | SELECT 1 FROM `SYSTEM_ROLE_MENU` rm |
| | | WHERE rm.`ROLE_ID` = r.`ID` AND rm.`MENU_ID` = menu.`ID` AND rm.`DELETED` = 0 |
| | | ); |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | -- åæ·å
弿¨¡åæéï¼é²éå¤ INSERTï¼ |
| | | |
| | | INSERT INTO `SYSTEM_PERMISSION`(`CODE`, `NAME`, `REMARK`, `FIXED`, `CREATE_USER`, `CREATE_TIME`, `UPDATE_USER`, `UPDATE_TIME`, `DELETED`) |
| | | SELECT 'business:ywcustomerrecharge:query', 'æ¥è¯¢åæ·å
å¼', '', 0, 1, CURRENT_TIMESTAMP, NULL, NULL, 0 |
| | | WHERE NOT EXISTS (SELECT 1 FROM `SYSTEM_PERMISSION` WHERE `CODE` = 'business:ywcustomerrecharge:query' AND `DELETED` = 0); |
| | | |
| | | INSERT INTO `SYSTEM_PERMISSION`(`CODE`, `NAME`, `REMARK`, `FIXED`, `CREATE_USER`, `CREATE_TIME`, `UPDATE_USER`, `UPDATE_TIME`, `DELETED`) |
| | | SELECT 'business:ywcustomerrecharge:exportExcel', '导åºåæ·å
å¼', '', 0, 1, CURRENT_TIMESTAMP, NULL, NULL, 0 |
| | | WHERE NOT EXISTS (SELECT 1 FROM `SYSTEM_PERMISSION` WHERE `CODE` = 'business:ywcustomerrecharge:exportExcel' AND `DELETED` = 0); |
| | | |
| | | INSERT INTO `SYSTEM_PERMISSION`(`CODE`, `NAME`, `REMARK`, `FIXED`, `CREATE_USER`, `CREATE_TIME`, `UPDATE_USER`, `UPDATE_TIME`, `DELETED`) |
| | | SELECT 'business:ywcustomerrecharge:bindDevice', 'å
³è设å¤', '', 0, 1, CURRENT_TIMESTAMP, NULL, NULL, 0 |
| | | WHERE NOT EXISTS (SELECT 1 FROM `SYSTEM_PERMISSION` WHERE `CODE` = 'business:ywcustomerrecharge:bindDevice' AND `DELETED` = 0); |
| | | |
| | | INSERT INTO `SYSTEM_PERMISSION`(`CODE`, `NAME`, `REMARK`, `FIXED`, `CREATE_USER`, `CREATE_TIME`, `UPDATE_USER`, `UPDATE_TIME`, `DELETED`) |
| | | SELECT 'business:ywcustomerrecharge:recharge', 'åæ·å
å¼/æ¸
é¶', '', 0, 1, CURRENT_TIMESTAMP, NULL, NULL, 0 |
| | | WHERE NOT EXISTS (SELECT 1 FROM `SYSTEM_PERMISSION` WHERE `CODE` = 'business:ywcustomerrecharge:recharge' AND `DELETED` = 0); |
| | | |
| | | INSERT INTO `SYSTEM_PERMISSION`(`CODE`, `NAME`, `REMARK`, `FIXED`, `CREATE_USER`, `CREATE_TIME`, `UPDATE_USER`, `UPDATE_TIME`, `DELETED`) |
| | | SELECT 'business:ywcustomerrechargerecord:query', 'æ¥è¯¢å
å¼è®°å½', '', 0, 1, CURRENT_TIMESTAMP, NULL, NULL, 0 |
| | | WHERE NOT EXISTS (SELECT 1 FROM `SYSTEM_PERMISSION` WHERE `CODE` = 'business:ywcustomerrechargerecord:query' AND `DELETED` = 0); |
| | | |
| | | INSERT INTO `SYSTEM_PERMISSION`(`CODE`, `NAME`, `REMARK`, `FIXED`, `CREATE_USER`, `CREATE_TIME`, `UPDATE_USER`, `UPDATE_TIME`, `DELETED`) |
| | | SELECT 'business:ywcustomerrechargerecord:exportExcel', '导åºå
å¼è®°å½', '', 0, 1, CURRENT_TIMESTAMP, NULL, NULL, 0 |
| | | WHERE NOT EXISTS (SELECT 1 FROM `SYSTEM_PERMISSION` WHERE `CODE` = 'business:ywcustomerrechargerecord:exportExcel' AND `DELETED` = 0); |
| | | |
| | | INSERT INTO `SYSTEM_PERMISSION`(`CODE`, `NAME`, `REMARK`, `FIXED`, `CREATE_USER`, `CREATE_TIME`, `UPDATE_USER`, `UPDATE_TIME`, `DELETED`) |
| | | SELECT 'business:ywcustomerrechargerecord:retry', '忬¡æäº¤å
å¼', '', 0, 1, CURRENT_TIMESTAMP, NULL, NULL, 0 |
| | | WHERE NOT EXISTS (SELECT 1 FROM `SYSTEM_PERMISSION` WHERE `CODE` = 'business:ywcustomerrechargerecord:retry' AND `DELETED` = 0); |
| | | |
| | | INSERT INTO `SYSTEM_PERMISSION`(`CODE`, `NAME`, `REMARK`, `FIXED`, `CREATE_USER`, `CREATE_TIME`, `UPDATE_USER`, `UPDATE_TIME`, `DELETED`) |
| | | SELECT 'business:ywcustomerrechargerecord:syncStatus', 'æå¨åæ¥å
å¼ç¶æ', '', 0, 1, CURRENT_TIMESTAMP, NULL, NULL, 0 |
| | | WHERE NOT EXISTS (SELECT 1 FROM `SYSTEM_PERMISSION` WHERE `CODE` = 'business:ywcustomerrechargerecord:syncStatus' AND `DELETED` = 0); |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | -- åæ·å
弿¨¡åï¼å®¢æ· GS é
ç½®ãçµè¡¨/空è°å
³èãå
å¼è®°å½æ©å± |
| | | |
| | | CREATE TABLE IF NOT EXISTS `yw_customer_gs` ( |
| | | `id` int NOT NULL AUTO_INCREMENT, |
| | | `creator` int DEFAULT NULL, |
| | | `create_date` datetime DEFAULT NULL, |
| | | `editor` int DEFAULT NULL, |
| | | `edit_date` datetime DEFAULT NULL, |
| | | `isdeleted` int DEFAULT 0, |
| | | `remark` varchar(500) DEFAULT NULL, |
| | | `customer_id` int NOT NULL COMMENT 'å
³è yw_customer.id', |
| | | `platform_gs_id` int DEFAULT NULL COMMENT 'æºç²¾çµ addGs è¿åçå
¬å¸ ID', |
| | | `is_pwr` tinyint DEFAULT 1 COMMENT '计费å¼å
³ 0å
³ 1å¼', |
| | | `is_rest_stop` tinyint DEFAULT 0 COMMENT '18:00-09:00 ä¸åæº 0å¦ 1æ¯', |
| | | `gs_bz` varchar(500) DEFAULT NULL COMMENT '夿³¨', |
| | | `stop_money` decimal(12,2) DEFAULT 0 COMMENT 'æ¬ è´¹é¢åº¦ï¼å
ï¼', |
| | | `left_money` decimal(12,4) DEFAULT NULL COMMENT 'å©ä½éé¢ï¼åæ¥èª getGs', |
| | | `sync_date` datetime DEFAULT NULL COMMENT 'ä½é¢åæ¥æ¶é´', |
| | | PRIMARY KEY (`id`), |
| | | UNIQUE KEY `uk_customer_id` (`customer_id`), |
| | | KEY `idx_platform_gs_id` (`platform_gs_id`) |
| | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='åæ·ç©ºè° GS é
ç½®'; |
| | | |
| | | CREATE TABLE IF NOT EXISTS `yw_customer_electrical` ( |
| | | `id` int NOT NULL AUTO_INCREMENT, |
| | | `creator` int DEFAULT NULL, |
| | | `create_date` datetime DEFAULT NULL, |
| | | `editor` int DEFAULT NULL, |
| | | `edit_date` datetime DEFAULT NULL, |
| | | `isdeleted` int DEFAULT 0, |
| | | `remark` varchar(500) DEFAULT NULL, |
| | | `customer_id` int NOT NULL COMMENT 'å
³è yw_customer.id', |
| | | `electrical_id` int NOT NULL COMMENT 'å
³è yw_electrical.id', |
| | | PRIMARY KEY (`id`), |
| | | UNIQUE KEY `uk_customer_electrical` (`customer_id`, `electrical_id`), |
| | | KEY `idx_electrical_id` (`electrical_id`) |
| | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='åæ·å
³èçµè¡¨'; |
| | | |
| | | CREATE TABLE IF NOT EXISTS `yw_customer_conditioner` ( |
| | | `id` int NOT NULL AUTO_INCREMENT, |
| | | `creator` int DEFAULT NULL, |
| | | `create_date` datetime DEFAULT NULL, |
| | | `editor` int DEFAULT NULL, |
| | | `edit_date` datetime DEFAULT NULL, |
| | | `isdeleted` int DEFAULT 0, |
| | | `remark` varchar(500) DEFAULT NULL, |
| | | `customer_id` int NOT NULL COMMENT 'å
³è yw_customer.id', |
| | | `conditioner_id` int NOT NULL COMMENT 'å
³è yw_conditioner.id', |
| | | `dev_ratio` int DEFAULT 100 COMMENT 'çµè´¹å æ¯%', |
| | | PRIMARY KEY (`id`), |
| | | UNIQUE KEY `uk_customer_conditioner` (`customer_id`, `conditioner_id`), |
| | | KEY `idx_conditioner_id` (`conditioner_id`) |
| | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='åæ·å
³è空è°å
æº'; |
| | | |
| | | -- yw_electrical_charge æ©å±åï¼è¥å·²åå¨åè·³è¿ï¼ |
| | | SET @db := DATABASE(); |
| | | |
| | | SET @sql := IF( |
| | | (SELECT COUNT(*) FROM information_schema.COLUMNS |
| | | WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'yw_electrical_charge' AND COLUMN_NAME = 'balance_after') = 0, |
| | | 'ALTER TABLE `yw_electrical_charge` ADD COLUMN `balance_after` decimal(12,4) DEFAULT NULL COMMENT ''å
å¼åä½é¢ï¼å
ï¼'' AFTER `banlance`', |
| | | 'SELECT 1' |
| | | ); |
| | | PREPARE stmt FROM @sql; |
| | | EXECUTE stmt; |
| | | DEALLOCATE PREPARE stmt; |
| | | |
| | | SET @sql := IF( |
| | | (SELECT COUNT(*) FROM information_schema.COLUMNS |
| | | WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'yw_electrical_charge' AND COLUMN_NAME = 'device_info') = 0, |
| | | 'ALTER TABLE `yw_electrical_charge` ADD COLUMN `device_info` varchar(500) DEFAULT NULL COMMENT ''设å¤å±ç¤ºä¿¡æ¯'' AFTER `balance_after`', |
| | | 'SELECT 1' |
| | | ); |
| | | PREPARE stmt FROM @sql; |
| | | EXECUTE stmt; |
| | | DEALLOCATE PREPARE stmt; |
| | |
| | | 'business:ywelectrical:exportExcel', |
| | | 'business:ywelectricalcharge:query', |
| | | 'business:ywelectricalcharge:exportExcel', |
| | | 'business:ywelectricalcharge:syncStatus', |
| | | 'business:ywelectricalparam:query', |
| | | 'business:ywelectricalparam:create', |
| | | 'business:ywelectricalparam:update', |
| | |
| | | INSERT INTO `SYSTEM_ROLE_PERMISSION` (`ROLE_ID`, `PERMISSION_ID`, `CREATE_TIME`, `UPDATE_TIME`, `CREATE_USER`, `UPDATE_USER`, `DELETED`) |
| | | SELECT r.`ID`, p.`ID`, CURRENT_TIMESTAMP, NULL, 1, NULL, 0 |
| | | FROM `SYSTEM_ROLE` r |
| | | INNER JOIN `SYSTEM_PERMISSION` p ON p.`CODE` = 'business:ywelectricalactions:query' AND p.`DELETED` = 0 |
| | | INNER JOIN `SYSTEM_PERMISSION` p ON p.`CODE` IN ('business:ywelectricalactions:query', 'business:ywelectricalactions:queryResult') AND p.`DELETED` = 0 |
| | | WHERE r.`DELETED` = 0 AND (r.`CODE` = 'admin' OR r.`NAME` = '管çå') |
| | | AND NOT EXISTS ( |
| | | SELECT 1 FROM `SYSTEM_ROLE_PERMISSION` rp |
| | |
| | | INSERT INTO `SYSTEM_PERMISSION`(`CODE`, `NAME`, `REMARK`, `FIXED`, `CREATE_USER`, `CREATE_TIME`, `UPDATE_USER`, `UPDATE_TIME`, `DELETED`) VALUES ('business:ywelectricalactions:query', 'æ¥è¯¢çµè¡¨è¿ç¨æä½è®°å½', '', 0, 1, CURRENT_TIMESTAMP, NULL, NULL, 0); |
| | | INSERT INTO `SYSTEM_PERMISSION`(`CODE`, `NAME`, `REMARK`, `FIXED`, `CREATE_USER`, `CREATE_TIME`, `UPDATE_USER`, `UPDATE_TIME`, `DELETED`) VALUES ('business:ywelectricalactions:queryResult', 'æå¨æ¥è¯¢å¼æ¥æä½ç»æ', '', 0, 1, CURRENT_TIMESTAMP, NULL, NULL, 0); |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | -- æä½è®°å½ãæå¨æ¥è¯¢ç»æãæéï¼å·²é¨ç½²ç¯å¢è¡¥æ§è¡ï¼ |
| | | INSERT INTO `SYSTEM_PERMISSION`(`CODE`, `NAME`, `REMARK`, `FIXED`, `CREATE_USER`, `CREATE_TIME`, `UPDATE_USER`, `UPDATE_TIME`, `DELETED`) |
| | | SELECT 'business:ywelectricalactions:queryResult', 'æå¨æ¥è¯¢å¼æ¥æä½ç»æ', '', 0, 1, CURRENT_TIMESTAMP, NULL, NULL, 0 |
| | | WHERE NOT EXISTS (SELECT 1 FROM `SYSTEM_PERMISSION` WHERE `CODE` = 'business:ywelectricalactions:queryResult' AND `DELETED` = 0); |
| | | |
| | | INSERT INTO `SYSTEM_ROLE_PERMISSION` (`ROLE_ID`, `PERMISSION_ID`, `CREATE_TIME`, `UPDATE_TIME`, `CREATE_USER`, `UPDATE_USER`, `DELETED`) |
| | | SELECT r.`ID`, p.`ID`, CURRENT_TIMESTAMP, NULL, 1, NULL, 0 |
| | | FROM `SYSTEM_ROLE` r |
| | | INNER JOIN `SYSTEM_PERMISSION` p ON p.`CODE` = 'business:ywelectricalactions:queryResult' AND p.`DELETED` = 0 |
| | | WHERE r.`DELETED` = 0 AND (r.`CODE` = 'admin' OR r.`NAME` = '管çå') |
| | | AND NOT EXISTS ( |
| | | SELECT 1 FROM `SYSTEM_ROLE_PERMISSION` rp |
| | | WHERE rp.`ROLE_ID` = r.`ID` AND rp.`PERMISSION_ID` = p.`ID` AND rp.`DELETED` = 0 |
| | | ); |
| | |
| | | INSERT INTO `SYSTEM_PERMISSION`(`CODE`, `NAME`, `REMARK`, `FIXED`, `CREATE_USER`, `CREATE_TIME`, `UPDATE_USER`, `UPDATE_TIME`, `DELETED`) VALUES ('business:ywelectricalcharge:query', 'æ¥è¯¢çµè¡¨å
å¼è®°å½', '', 0, 1, CURRENT_TIMESTAMP, NULL, NULL, 0); |
| | | INSERT INTO `SYSTEM_PERMISSION`(`CODE`, `NAME`, `REMARK`, `FIXED`, `CREATE_USER`, `CREATE_TIME`, `UPDATE_USER`, `UPDATE_TIME`, `DELETED`) VALUES ('business:ywelectricalcharge:exportExcel', '导åºçµè¡¨å
å¼è®°å½(Excel)', '', 0, 1, CURRENT_TIMESTAMP, NULL, NULL, 0); |
| | | INSERT INTO `SYSTEM_PERMISSION`(`CODE`, `NAME`, `REMARK`, `FIXED`, `CREATE_USER`, `CREATE_TIME`, `UPDATE_USER`, `UPDATE_TIME`, `DELETED`) VALUES ('business:ywelectricalcharge:syncStatus', 'æå¨åæ¥çµè¡¨å
å¼ç¶æ', '', 0, 1, CURRENT_TIMESTAMP, NULL, NULL, 0); |
| | |
| | | ); |
| | | |
| | | INSERT INTO `quartz_job` (`bean_name`, `params`, `module`, `cron_expres`, `state`, `remark`, `create_time`) |
| | | SELECT 'visitServiceJob', '', 'syncElectricalAsyncStatus', '0 5 * * * ?', 1, 'æºè½çµè¡¨-弿¥ä»»å¡ç¶æè¡¥å¿æ¥è¯¢', CURRENT_TIMESTAMP |
| | | WHERE NOT EXISTS ( |
| | | SELECT 1 FROM `quartz_job` WHERE `module` = 'syncElectricalAsyncStatus' AND `bean_name` = 'visitServiceJob' |
| | | ); |
| | | |
| | | INSERT INTO `quartz_job` (`bean_name`, `params`, `module`, `cron_expres`, `state`, `remark`, `create_time`) |
| | | SELECT 'visitServiceJob', '', 'syncConditionerGatewayStatus', '0 */5 * * * ?', 1, '空è°å¤èæº-ç½å
³å¨çº¿ç¶æåæ¥', CURRENT_TIMESTAMP |
| | | WHERE NOT EXISTS ( |
| | | SELECT 1 FROM `quartz_job` WHERE `module` = 'syncConditionerGatewayStatus' AND `bean_name` = 'visitServiceJob' |
| | |
| | | @GetMapping("/timer/yw/cleanElectricalLog") |
| | | ApiResponse cleanElectricalLog(); |
| | | |
| | | @ApiOperation("ãéå®è¿ç»´ã宿¶æ¥è¯¢å¤çä¸ççµè¡¨å¼æ¥ä»»å¡ç¶æ") |
| | | @GetMapping("/timer/yw/syncElectricalAsyncStatus") |
| | | ApiResponse syncElectricalAsyncStatus(); |
| | | |
| | | @ApiOperation("ãéå®è¿ç»´ã宿¶åæ¥æºç²¾çµç½å
³å¨çº¿ç¶æ") |
| | | @GetMapping("/timer/yw/syncConditionerGatewayStatus") |
| | | ApiResponse syncConditionerGatewayStatus(); |
| | |
| | | return ApiResponse.success("çµè¡¨æ¥å£æ¥å¿æ¸
çæå"); |
| | | } |
| | | |
| | | @ApiOperation("宿¶æ¥è¯¢å¤çä¸ççµè¡¨å¼æ¥ä»»å¡ç¶æ") |
| | | @GetMapping("/syncElectricalAsyncStatus") |
| | | public ApiResponse syncElectricalAsyncStatus() { |
| | | ywElectricalBizService.syncPendingAsyncActionsScheduled(); |
| | | return ApiResponse.success("çµè¡¨å¼æ¥ä»»å¡ç¶æåæ¥æå"); |
| | | } |
| | | |
| | | @Autowired |
| | | private com.doumee.service.business.ConditionerBizService conditionerBizService; |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.cloud.admin; |
| | | |
| | | import com.doumee.api.BaseController; |
| | | import com.doumee.core.annotation.pr.PreventRepeat; |
| | | import com.doumee.core.model.ApiResponse; |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.config.annotation.CloudRequiredPermission; |
| | | import com.doumee.dao.business.dto.*; |
| | | import com.doumee.dao.business.model.YwConditioner; |
| | | import com.doumee.dao.business.model.YwCustomerGs; |
| | | import com.doumee.dao.business.model.YwElectrical; |
| | | import com.doumee.service.business.YwCustomerRechargeBizService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.Map; |
| | | |
| | | @Api(tags = "åæ·å
å¼") |
| | | @RestController |
| | | @RequestMapping(Constants.CLOUD_SERVICE_URL_INDEX + "/business/ywCustomerRecharge") |
| | | public class YwCustomerRechargeCloudController extends BaseController { |
| | | |
| | | @Autowired |
| | | private YwCustomerRechargeBizService ywCustomerRechargeBizService; |
| | | |
| | | @ApiOperation("åæ·å页å表") |
| | | @PostMapping("/merchantPage") |
| | | @CloudRequiredPermission("business:ywcustomerrecharge:query") |
| | | public ApiResponse<PageData<YwCustomerRechargeMerchantVO>> merchantPage( |
| | | @RequestBody PageWrap<YwCustomerRechargeQueryDTO> pageWrap, |
| | | @RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | return ApiResponse.success(ywCustomerRechargeBizService.findMerchantPage(pageWrap)); |
| | | } |
| | | |
| | | @ApiOperation("åæ·è¯¦æ
") |
| | | @GetMapping("/{customerId}/detail") |
| | | @CloudRequiredPermission("business:ywcustomerrecharge:query") |
| | | public ApiResponse<YwCustomerRechargeDetailVO> detail(@PathVariable Integer customerId, |
| | | @RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | return ApiResponse.success(ywCustomerRechargeBizService.getDetail(customerId)); |
| | | } |
| | | |
| | | @ApiOperation("å
³èçµè¡¨å表") |
| | | @PostMapping("/electrical/page") |
| | | @CloudRequiredPermission("business:ywcustomerrecharge:query") |
| | | public ApiResponse<PageData<YwElectrical>> electricalPage( |
| | | @RequestBody PageWrap<YwElectrical> pageWrap, |
| | | @RequestParam Integer customerId, |
| | | @RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | return ApiResponse.success(ywCustomerRechargeBizService.listCustomerElectrical(pageWrap, customerId)); |
| | | } |
| | | |
| | | @ApiOperation("å¯éçµè¡¨å表") |
| | | @PostMapping("/electrical/selectablePage") |
| | | @CloudRequiredPermission("business:ywcustomerrecharge:bindDevice") |
| | | public ApiResponse<PageData<YwElectrical>> selectableElectricalPage( |
| | | @RequestBody PageWrap<YwElectrical> pageWrap, |
| | | @RequestParam Integer customerId, |
| | | @RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | return ApiResponse.success(ywCustomerRechargeBizService.pageSelectableElectrical(pageWrap, customerId)); |
| | | } |
| | | |
| | | @PreventRepeat |
| | | @ApiOperation("ä¿åå
³èçµè¡¨") |
| | | @PostMapping("/electrical/save") |
| | | @CloudRequiredPermission("business:ywcustomerrecharge:bindDevice") |
| | | public ApiResponse saveElectrical(@RequestBody YwCustomerElectricalSaveDTO dto, |
| | | @RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | ywCustomerRechargeBizService.saveCustomerElectrical(dto, getLoginUser(token)); |
| | | return ApiResponse.success(null); |
| | | } |
| | | |
| | | @ApiOperation("å é¤å
³èçµè¡¨") |
| | | @GetMapping("/electrical/delete") |
| | | @CloudRequiredPermission("business:ywcustomerrecharge:bindDevice") |
| | | public ApiResponse deleteElectrical(@RequestParam Integer customerId, |
| | | @RequestParam Integer electricalId, |
| | | @RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | ywCustomerRechargeBizService.removeCustomerElectrical(customerId, electricalId, getLoginUser(token)); |
| | | return ApiResponse.success(null); |
| | | } |
| | | |
| | | @ApiOperation("å
³è空è°å表") |
| | | @PostMapping("/conditioner/page") |
| | | @CloudRequiredPermission("business:ywcustomerrecharge:query") |
| | | public ApiResponse<PageData<YwConditioner>> conditionerPage( |
| | | @RequestBody PageWrap<YwConditioner> pageWrap, |
| | | @RequestParam Integer customerId, |
| | | @RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | return ApiResponse.success(ywCustomerRechargeBizService.listCustomerConditioner(pageWrap, customerId)); |
| | | } |
| | | |
| | | @ApiOperation("ç©ºè° GS é
ç½®") |
| | | @GetMapping("/conditioner/gsConfig") |
| | | @CloudRequiredPermission("business:ywcustomerrecharge:query") |
| | | public ApiResponse<YwCustomerGs> gsConfig(@RequestParam Integer customerId, |
| | | @RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | return ApiResponse.success(ywCustomerRechargeBizService.getCustomerGsConfig(customerId)); |
| | | } |
| | | |
| | | @PreventRepeat |
| | | @ApiOperation("ä¿åç©ºè° GS é
ç½®") |
| | | @PostMapping("/conditioner/saveGsConfig") |
| | | @CloudRequiredPermission("business:ywcustomerrecharge:bindDevice") |
| | | public ApiResponse saveGsConfig(@RequestBody YwCustomerGsConfigDTO dto, |
| | | @RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | ywCustomerRechargeBizService.saveCustomerGsConfig(dto, getLoginUser(token)); |
| | | return ApiResponse.success(null); |
| | | } |
| | | |
| | | @PreventRepeat |
| | | @ApiOperation("çµè¡¨å
å¼") |
| | | @PostMapping("/recharge/electrical") |
| | | @CloudRequiredPermission("business:ywcustomerrecharge:recharge") |
| | | public ApiResponse<String> rechargeElectrical(@RequestBody YwCustomerRechargeElectricalDTO dto, |
| | | @RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | return ApiResponse.success(ywCustomerRechargeBizService.rechargeElectrical(dto, getLoginUser(token))); |
| | | } |
| | | |
| | | @PreventRepeat |
| | | @ApiOperation("çµè¡¨æ¸
é¶") |
| | | @PostMapping("/reset/electrical") |
| | | @CloudRequiredPermission("business:ywcustomerrecharge:recharge") |
| | | public ApiResponse<String> resetElectrical(@RequestBody YwCustomerRechargeElectricalDTO dto, |
| | | @RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | return ApiResponse.success(ywCustomerRechargeBizService.resetElectricalAccount(dto, getLoginUser(token))); |
| | | } |
| | | |
| | | @ApiOperation("çµè¡¨æè¡¨å·æ°") |
| | | @GetMapping("/readMeter") |
| | | @CloudRequiredPermission("business:ywcustomerrecharge:recharge") |
| | | public ApiResponse<Map<String, Object>> readMeter(@RequestParam Integer customerId, |
| | | @RequestParam Integer electricalId, |
| | | @RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | return ApiResponse.success(ywCustomerRechargeBizService.readMeterAndRefresh(customerId, electricalId, getLoginUser(token))); |
| | | } |
| | | |
| | | @ApiOperation("çµè¡¨è¿ç¨ä¿¡æ¯") |
| | | @GetMapping("/electrical/remoteInfo") |
| | | @CloudRequiredPermission("business:ywcustomerrecharge:recharge") |
| | | public ApiResponse<Map<String, Object>> electricalRemoteInfo(@RequestParam Integer electricalId, |
| | | @RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | return ApiResponse.success(ywCustomerRechargeBizService.getElectricalRemoteInfo(electricalId)); |
| | | } |
| | | |
| | | @ApiOperation("空è°å
å¼åä¿¡æ¯") |
| | | @GetMapping("/recharge/conditioner/info") |
| | | @CloudRequiredPermission("business:ywcustomerrecharge:recharge") |
| | | public ApiResponse<Map<String, Object>> conditionerRechargeInfo(@RequestParam Integer customerId, |
| | | @RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | return ApiResponse.success(ywCustomerRechargeBizService.getConditionerRechargeInfo(customerId)); |
| | | } |
| | | |
| | | @PreventRepeat |
| | | @ApiOperation("空è°å
å¼") |
| | | @PostMapping("/recharge/conditioner") |
| | | @CloudRequiredPermission("business:ywcustomerrecharge:recharge") |
| | | public ApiResponse<String> rechargeConditioner(@RequestBody YwCustomerRechargeConditionerDTO dto, |
| | | @RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | return ApiResponse.success(ywCustomerRechargeBizService.rechargeConditioner(dto, getLoginUser(token))); |
| | | } |
| | | |
| | | @PreventRepeat |
| | | @ApiOperation("ç©ºè°æ¸
é¶") |
| | | @PostMapping("/clean/conditioner") |
| | | @CloudRequiredPermission("business:ywcustomerrecharge:recharge") |
| | | public ApiResponse<String> cleanConditioner(@RequestParam Integer customerId, |
| | | @RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | return ApiResponse.success(ywCustomerRechargeBizService.cleanConditionerAccount(customerId, getLoginUser(token))); |
| | | } |
| | | |
| | | @ApiOperation("å
å¼è®°å½å页") |
| | | @PostMapping("/rechargeRecord/page") |
| | | @CloudRequiredPermission("business:ywcustomerrechargerecord:query") |
| | | public ApiResponse<PageData<YwCustomerRechargeRecordVO>> rechargeRecordPage( |
| | | @RequestBody PageWrap<YwCustomerRechargeRecordQueryDTO> pageWrap, |
| | | @RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | return ApiResponse.success(ywCustomerRechargeBizService.findRechargeRecordPage(pageWrap)); |
| | | } |
| | | |
| | | @PreventRepeat |
| | | @ApiOperation("忬¡æäº¤å
å¼") |
| | | @PostMapping("/rechargeRecord/retry/{id}") |
| | | @CloudRequiredPermission("business:ywcustomerrechargerecord:retry") |
| | | public ApiResponse<String> retryRecharge(@PathVariable Integer id, |
| | | @RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | return ApiResponse.success(ywCustomerRechargeBizService.retryRecharge(id, getLoginUser(token))); |
| | | } |
| | | |
| | | @PreventRepeat |
| | | @ApiOperation("æå¨åæ¥å
å¼ç¶æ") |
| | | @PostMapping("/rechargeRecord/sync/{id}") |
| | | @CloudRequiredPermission("business:ywcustomerrechargerecord:syncStatus") |
| | | public ApiResponse<String> syncRechargeStatus(@PathVariable Integer id, |
| | | @RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | return ApiResponse.success(ywCustomerRechargeBizService.syncRechargeStatus(id, getLoginUser(token))); |
| | | } |
| | | |
| | | @ApiOperation("导åºå
å¼è®°å½") |
| | | @PostMapping("/rechargeRecord/exportExcel") |
| | | @CloudRequiredPermission("business:ywcustomerrechargerecord:exportExcel") |
| | | public void exportRechargeRecord(@RequestBody PageWrap<YwCustomerRechargeRecordQueryDTO> pageWrap, |
| | | HttpServletResponse response, |
| | | @RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | ywCustomerRechargeBizService.exportRechargeRecord(pageWrap, response); |
| | | } |
| | | } |
| | |
| | | package com.doumee.cloud.admin; |
| | | |
| | | import com.doumee.core.annotation.pr.PreventRepeat; |
| | | import com.doumee.api.BaseController; |
| | | import com.doumee.config.annotation.CloudRequiredPermission; |
| | | import com.doumee.core.model.ApiResponse; |
| | |
| | | } |
| | | return ApiResponse.success(ywElectricalActionsService.findPage(pageWrap)); |
| | | } |
| | | |
| | | @PreventRepeat |
| | | @ApiOperation("æå¨æ¥è¯¢å¼æ¥æä½ç»æ") |
| | | @GetMapping("/queryResult/{id}") |
| | | @CloudRequiredPermission("business:ywelectricalactions:queryResult") |
| | | public ApiResponse<String> queryResult(@PathVariable Integer id) { |
| | | return ApiResponse.success(ywElectricalActionsService.queryAsyncResult(id)); |
| | | } |
| | | } |
| | |
| | | @Autowired |
| | | private YwElectricalChargeService ywElectricalChargeService; |
| | | |
| | | @Autowired |
| | | private com.doumee.service.business.YwElectricalBizService ywElectricalBizService; |
| | | |
| | | @PreventRepeat |
| | | @ApiOperation("æ°å»º") |
| | | @PostMapping("/create") |
| | |
| | | public ApiResponse findById(@PathVariable Integer id, @RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | return ApiResponse.success(ywElectricalChargeService.findById(id)); |
| | | } |
| | | |
| | | @PreventRepeat |
| | | @ApiOperation("æå¨åæ¥å
å¼ç¶æ") |
| | | @GetMapping("/syncStatus/{id}") |
| | | @CloudRequiredPermission("business:ywelectricalcharge:syncStatus") |
| | | public ApiResponse<String> syncStatus(@PathVariable Integer id, @RequestHeader(Constants.HEADER_USER_TOKEN) String token) { |
| | | return ApiResponse.success(ywElectricalBizService.syncChargeStatusById(id)); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | public static ConditionerBaseResponse<Object> addGs(CompanyGsManageRequest req) { |
| | | return postJson("/addGs", req, Object.class); |
| | | if (req == null) { |
| | | return null; |
| | | } |
| | | req.fillSessionDefaults(); |
| | | JSONObject body = new JSONObject(true); |
| | | putSessionFields(body, req); |
| | | body.put("is_pwr", req.getIs_pwr() != null ? req.getIs_pwr() : 1); |
| | | if (req.getLi_dev() != null && !req.getLi_dev().isEmpty()) { |
| | | body.put("li_dev", req.getLi_dev()); |
| | | } |
| | | if (req.getD_dev() != null && !req.getD_dev().isEmpty()) { |
| | | body.put("d_dev", req.getD_dev()); |
| | | } |
| | | body.put("gs_name", req.getGs_name()); |
| | | body.put("is_rest_stop", req.getIs_rest_stop() != null ? req.getIs_rest_stop() : 0); |
| | | body.put("gs_bz", StringUtils.defaultString(req.getGs_bz())); |
| | | putStopMoney(body, req.getStop_money()); |
| | | return postJsonBody("/addGs", body, Object.class); |
| | | } |
| | | |
| | | public static ConditionerBaseResponse<Object> changeGs(CompanyGsManageRequest req) { |
| | | return postJson("/changeGs", req, Object.class); |
| | | if (req == null || req.getId() == null) { |
| | | return null; |
| | | } |
| | | req.fillSessionDefaults(); |
| | | JSONObject body = new JSONObject(true); |
| | | body.put("id", req.getId()); |
| | | body.put("is_pwr", req.getIs_pwr() != null ? req.getIs_pwr() : 1); |
| | | body.put("is_rest_stop", req.getIs_rest_stop() != null ? req.getIs_rest_stop() : 0); |
| | | body.put("gs_name", req.getGs_name()); |
| | | if (req.getLeft_money() != null) { |
| | | body.put("left_money", req.getLeft_money()); |
| | | } |
| | | body.put("is_stop", req.getIs_stop() != null ? req.getIs_stop() : 0); |
| | | body.put("li_dev", req.getLi_dev()); |
| | | body.put("d_dev", req.getD_dev()); |
| | | body.put("gs_bz", StringUtils.defaultString(req.getGs_bz())); |
| | | putStopMoney(body, req.getStop_money()); |
| | | return postJsonBody("/changeGs", body, Object.class); |
| | | } |
| | | |
| | | private static void putStopMoney(JSONObject body, Object stopMoney) { |
| | | if (stopMoney != null) { |
| | | body.put("stop_money", stopMoney); |
| | | } |
| | | } |
| | | |
| | | public static ConditionerBaseResponse<Object> delGs(CompanyGsManageRequest req) { |
| | |
| | | } |
| | | |
| | | public static ConditionerBaseResponse<Object> addMoney(AddMoneyRequest req) { |
| | | return postJson("/addMoney", req, Object.class); |
| | | if (req == null) { |
| | | return null; |
| | | } |
| | | req.fillSessionDefaults(); |
| | | JSONObject body = new JSONObject(true); |
| | | putSessionFields(body, req); |
| | | body.put("id", req.getId()); |
| | | body.put("cz_money", req.getCz_money()); |
| | | return postJsonBody("/addMoney", body, Object.class); |
| | | } |
| | | |
| | | public static ConditionerBaseResponse<Object> cleanMoney(CompanyGsManageRequest req) { |
| | | return postJson("/cleanMoney", req, Object.class); |
| | | if (req == null || req.getId() == null) { |
| | | return null; |
| | | } |
| | | req.fillSessionDefaults(); |
| | | JSONObject body = new JSONObject(true); |
| | | putSessionFields(body, req); |
| | | body.put("id", req.getId()); |
| | | return postJsonBody("/cleanMoney", body, Object.class); |
| | | } |
| | | |
| | | public static ConditionerBaseResponse<List<Object>> getCzLog(LogQueryRequest req) { |
| | |
| | | } |
| | | } |
| | | |
| | | private static <T> ConditionerBaseResponse<T> postJsonBody(String path, JSONObject body, Class<T> dataClass) { |
| | | try { |
| | | String raw = doPostRaw(path, body.toJSONString()); |
| | | return parseObjectResponse(raw, dataClass); |
| | | } catch (Exception e) { |
| | | log.error("conditioner POST {} failed", path, e); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | private static void putSessionFields(JSONObject body, ConditionerSessionRequest req) { |
| | | body.put("kt_token", req.getKt_token()); |
| | | body.put("kt_dwid", req.getKt_dwid()); |
| | | body.put("kt_unit", StringUtils.defaultIfBlank(req.getKt_unit(), ConditionerConstant.DEFAULT_KT_UNIT)); |
| | | body.put("kt_sonid", req.getKt_sonid()); |
| | | } |
| | | |
| | | private static String resolveUrl(String path) { |
| | | String base = StringUtils.defaultIfBlank(ConditionerConstant.base_url, ConditionerConstant.DEFAULT_BASE_URL); |
| | | if (base.endsWith("/")) { |
| | |
| | | public static final String DEFAULT_USERNAME = "admin"; |
| | | public static final String DEFAULT_PASSWORD = "12345678"; |
| | | public static final String DEFAULT_KT_SONID = "0"; |
| | | /** åå
IDï¼addGs/addMoney ç POST æ¥å£ææ¡£ç¤ºä¾å为 "1" */ |
| | | public static final String DEFAULT_KT_UNIT = "1"; |
| | | |
| | | /** API æ ¹å°åï¼å¦ http://119.45.163.5:1125/zjl/API */ |
| | | public static String base_url = DEFAULT_BASE_URL; |
| | |
| | | public static String kt_token; |
| | | public static String kt_dwid; |
| | | public static String kt_sonid = DEFAULT_KT_SONID; |
| | | public static String kt_unit = DEFAULT_KT_UNIT; |
| | | |
| | | private ConditionerConstant() { |
| | | } |
| | |
| | | |
| | | @ApiModelProperty("夿³¨") |
| | | private String gs_bz; |
| | | |
| | | @ApiModelProperty("æ¬ è´¹é¢åº¦ï¼å
ï¼") |
| | | private Object stop_money; |
| | | } |
| | |
| | | if (StringUtils.isBlank(kt_sonid)) { |
| | | kt_sonid = ConditionerConstant.kt_sonid; |
| | | } |
| | | if (StringUtils.isBlank(kt_unit)) { |
| | | kt_unit = ConditionerConstant.kt_unit; |
| | | } |
| | | } |
| | | } |
| | |
| | | return null; |
| | | } |
| | | /** |
| | | * çµè¡¨å¼æ·_çµè¡¨å
å¼ |
| | | * çµè¡¨_çµè¡¨å
å¼ |
| | | */ |
| | | public static ElectronicBaseResponse recharger(List<OpenAccountRequest> param) { |
| | | if(param ==null || param.size()==0){ |
| | |
| | | String r = requestAsync(url, request_content); |
| | | return parseAsyncMeterResponse(r); |
| | | }catch (Exception e){ |
| | | log.error("çµè¡¨==============弿·",e); |
| | | log.error("çµè¡¨==============å
å¼",e); |
| | | } |
| | | return null; |
| | | } |
| | |
| | | if(param ==null || param.size()==0){ |
| | | return null; |
| | | } |
| | | String url = ElectronicConstant.api2_url+"/Api_v2/ele_security/ele_control"; |
| | | String url = ElectronicConstant.api2_url+"/Api_v2/ele_control"; |
| | | |
| | | try { |
| | | String request_content = JSON.toJSONString(param); |
| | |
| | | return null; |
| | | } |
| | | /** |
| | | * æ¥è¯¢å¼æ¥æä½ä»»å¡ç¶æï¼/Api_v2/request/statusï¼ã |
| | | * request_content 为 JSON æ°ç»ï¼å¯åå¹¶ä¼ å
¥å¤ä¸ª opr_id 䏿¬¡æ¥è¯¢ã |
| | | * è°ç¨æåå建议 30s 馿¬¡æ¥è¯¢ï¼åç»é´ééå¢ï¼1hã2hã4hâ¦ï¼ï¼ç¦æ¢é¢ç¹è°ç¨ã |
| | | * ååº SUCCESSãFAILãTIMEOUTãCANCELEDãRESPONSE_FAIL åæ éåæ¥è¯¢ã |
| | | */ |
| | | public static ElectronicBaseResponse requestStatus(List<RequestStatusRequest> param) { |
| | | if (param == null || param.isEmpty()) { |
| | | return null; |
| | | } |
| | | String url = ElectronicConstant.api2_url + "/Api_v2/request/status"; |
| | | try { |
| | | String request_content = JSON.toJSONString(param); |
| | | String r = request(url, request_content); |
| | | return parseAsyncMeterResponse(r); |
| | | } catch (Exception e) { |
| | | log.error("çµè¡¨==============æ¥è¯¢å¼æ¥ä»»å¡ç¶æ", e); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * æ opr_id å表åå¹¶æ¥è¯¢å¼æ¥ä»»å¡ç¶æã |
| | | */ |
| | | public static ElectronicBaseResponse requestStatusByOprIds(List<String> oprIds) { |
| | | if (oprIds == null || oprIds.isEmpty()) { |
| | | return null; |
| | | } |
| | | List<RequestStatusRequest> param = new ArrayList<>(); |
| | | for (String oprId : oprIds) { |
| | | if (StringUtils.isNotBlank(oprId)) { |
| | | RequestStatusRequest req = new RequestStatusRequest(); |
| | | req.setOpr_id(oprId.trim()); |
| | | param.add(req); |
| | | } |
| | | } |
| | | return param.isEmpty() ? null : requestStatus(param); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢åä¸ªå¼æ¥æä½ä»»å¡ç¶æã |
| | | */ |
| | | public static ElectronicBaseResponse requestStatus(String oprId) { |
| | | if (StringUtils.isBlank(oprId)) { |
| | | return null; |
| | | } |
| | | RequestStatusRequest req = new RequestStatusRequest(); |
| | | req.setOpr_id(oprId.trim()); |
| | | return requestStatus(Collections.singletonList(req)); |
| | | } |
| | | |
| | | /** |
| | | * 弿¥ä»»å¡æ¯å¦å·²å°è¾¾ç»æï¼å¹³å°åç»ä¸åå¤çï¼æ éå轮询ã |
| | | */ |
| | | public static boolean isAsyncStatusFinal(String status) { |
| | | if (StringUtils.isBlank(status)) { |
| | | return false; |
| | | } |
| | | String s = status.trim().toUpperCase(Locale.ROOT); |
| | | return "SUCCESS".equals(s) || "FAIL".equals(s) || "TIMEOUT".equals(s) |
| | | || "CANCELED".equals(s) || "RESPONSE_FAIL".equals(s); |
| | | } |
| | | |
| | | /** |
| | | * çµè¡¨_ç«å³æè¡¨ |
| | | */ |
| | | public static ElectronicBaseResponse eleRead(List<EleReadRequest> param) { |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.core.device.model.request; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * 弿¥æä½ä»»å¡ç¶ææ¥è¯¢è¯·æ±é¡¹ |
| | | */ |
| | | @ApiModel("弿¥æä½ä»»å¡ç¶ææ¥è¯¢") |
| | | @Data |
| | | public class RequestStatusRequest implements Serializable { |
| | | |
| | | @ApiModelProperty(value = "æä½IDï¼é¿åº¦16-32ï¼ä¸æäº¤å¼æ¥ä»»å¡æ¶ä¸è´") |
| | | private String opr_id; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.dao.business; |
| | | |
| | | import com.doumee.dao.business.model.YwCustomerConditioner; |
| | | import com.github.yulichang.base.MPJBaseMapper; |
| | | |
| | | public interface YwCustomerConditionerMapper extends MPJBaseMapper<YwCustomerConditioner> { |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.dao.business; |
| | | |
| | | import com.doumee.dao.business.model.YwCustomerElectrical; |
| | | import com.github.yulichang.base.MPJBaseMapper; |
| | | |
| | | public interface YwCustomerElectricalMapper extends MPJBaseMapper<YwCustomerElectrical> { |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.dao.business; |
| | | |
| | | import com.doumee.dao.business.model.YwCustomerGs; |
| | | import com.github.yulichang.base.MPJBaseMapper; |
| | | |
| | | public interface YwCustomerGsMapper extends MPJBaseMapper<YwCustomerGs> { |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.dao.business.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | @Data |
| | | public class YwCustomerElectricalBalanceItem { |
| | | |
| | | private String name; |
| | | private String address; |
| | | private BigDecimal balance; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.dao.business.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | public class YwCustomerElectricalSaveDTO { |
| | | |
| | | private Integer customerId; |
| | | private List<Integer> electricalIds; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.dao.business.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | public class YwCustomerGsConfigDTO { |
| | | |
| | | private Integer customerId; |
| | | private Integer isPwr; |
| | | private Integer isRestStop; |
| | | private String gsBz; |
| | | /** æ¬ è´¹é¢åº¦ï¼å
ï¼ */ |
| | | private BigDecimal stopMoney; |
| | | private List<ConditionerItem> conditioners; |
| | | |
| | | @Data |
| | | public static class ConditionerItem { |
| | | private Integer conditionerId; |
| | | private Integer devRatio; |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.dao.business.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | @Data |
| | | public class YwCustomerRechargeConditionerDTO { |
| | | |
| | | private Integer customerId; |
| | | private BigDecimal money; |
| | | private String remark; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.dao.business.dto; |
| | | |
| | | import com.doumee.dao.business.model.YwConditioner; |
| | | import com.doumee.dao.business.model.YwCustomerGs; |
| | | import com.doumee.dao.business.model.YwElectrical; |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | public class YwCustomerRechargeDetailVO { |
| | | |
| | | private Integer customerId; |
| | | private String customerName; |
| | | private String phone; |
| | | private YwCustomerGs gsConfig; |
| | | private List<YwElectrical> electricalList; |
| | | private List<YwConditioner> conditionerList; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.dao.business.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | @Data |
| | | public class YwCustomerRechargeElectricalDTO { |
| | | |
| | | private Integer customerId; |
| | | private Integer electricalId; |
| | | private BigDecimal money; |
| | | private String remark; |
| | | /** resetPrepay / resetPostpay */ |
| | | private String resetAction; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.dao.business.dto; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.fasterxml.jackson.annotation.JsonIgnore; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | public class YwCustomerRechargeMerchantVO { |
| | | |
| | | private Integer id; |
| | | /** 客æ·ç±»å 0个人 1ä¼ä¸ */ |
| | | private Integer type; |
| | | private String name; |
| | | private String phone; |
| | | /** é»è®¤è系人ï¼å clientListï¼ */ |
| | | private String memberName; |
| | | /** è系人çµè¯ï¼å clientListï¼ */ |
| | | private String memberPhone; |
| | | |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date createDate; |
| | | |
| | | private Integer electricalCount; |
| | | /** å
³èçµè¡¨ä½é¢æç» */ |
| | | private List<YwCustomerElectricalBalanceItem> electricalBalances; |
| | | private Integer conditionerCount; |
| | | private BigDecimal acBalance; |
| | | |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date acBalanceSyncDate; |
| | | |
| | | /** çéè¾
å©ï¼çµè¡¨æ¯å¦å
¨å¨çº¿ */ |
| | | @JsonIgnore |
| | | private Boolean electricalOnlineAll; |
| | | /** çéè¾
å©ï¼çµè¡¨æ¯å¦åå¨ç¦»çº¿ */ |
| | | @JsonIgnore |
| | | private Boolean electricalHasOffline; |
| | | /** çéè¾
å©ï¼ç©ºè°æ¯å¦å
¨å¨çº¿ */ |
| | | @JsonIgnore |
| | | private Boolean conditionerOnlineAll; |
| | | /** çéè¾
å©ï¼ç©ºè°æ¯å¦åå¨ç¦»çº¿ */ |
| | | @JsonIgnore |
| | | private Boolean conditionerHasOffline; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.dao.business.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class YwCustomerRechargeQueryDTO { |
| | | |
| | | /** 客æ·åç§°å
³é®å */ |
| | | private String nameKeyword; |
| | | /** çµè¡¨ç¶æçéï¼1å
¨å¨çº¿ 2åå¨ç¦»çº¿ 3æ è®¾å¤ */ |
| | | private Integer electricalStatusFilter; |
| | | /** 空è°ç¶æçéï¼1å
¨å¨çº¿ 2åå¨ç¦»çº¿ 3æ è®¾å¤ */ |
| | | private Integer conditionerStatusFilter; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.dao.business.dto; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | | public class YwCustomerRechargeRecordQueryDTO { |
| | | |
| | | private String customerName; |
| | | private Integer type; |
| | | private Integer status; |
| | | |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date createTimeBegin; |
| | | |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date createTimeEnd; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.dao.business.dto; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.doumee.core.annotation.excel.ExcelColumn; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | | public class YwCustomerRechargeRecordVO { |
| | | |
| | | private Integer id; |
| | | |
| | | @ExcelColumn(name = "客æ·åç§°", index = 1, width = 20) |
| | | private String customerName; |
| | | |
| | | @ExcelColumn(name = "ä¸å¡ç±»å", index = 2, width = 10) |
| | | private String typeText; |
| | | |
| | | private Integer type; |
| | | |
| | | @ExcelColumn(name = "设å¤ä¿¡æ¯", index = 3, width = 30) |
| | | private String deviceInfo; |
| | | |
| | | @ExcelColumn(name = "å
å¼éé¢(å
)", index = 4, width = 12) |
| | | private BigDecimal money; |
| | | |
| | | @ExcelColumn(name = "å
å¼åä½é¢", index = 5, width = 12) |
| | | private BigDecimal banlance; |
| | | |
| | | @ExcelColumn(name = "å
å¼åä½é¢", index = 6, width = 12) |
| | | private BigDecimal balanceAfter; |
| | | |
| | | @ExcelColumn(name = "ç¶æ", index = 7, width = 10) |
| | | private String statusText; |
| | | |
| | | private Integer status; |
| | | |
| | | @ExcelColumn(name = "ä»»å¡ID", index = 8, width = 24) |
| | | private String oprId; |
| | | |
| | | @ExcelColumn(name = "夿³¨", index = 9, width = 20) |
| | | private String remark; |
| | | |
| | | @ExcelColumn(name = "ç¶æè¯´æ", index = 10, width = 20) |
| | | private String statusInfo; |
| | | |
| | | @ExcelColumn(name = "æäº¤æ¶é´", index = 11, width = 20) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date createDate; |
| | | |
| | | @ExcelColumn(name = "ç¶ææ´æ°æ¶é´", index = 12, width = 20) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date statusTime; |
| | | |
| | | private Integer customerId; |
| | | private Integer objId; |
| | | private String address; |
| | | private String name; |
| | | } |
| | |
| | | private String action; |
| | | private BigDecimal money; |
| | | private String remark; |
| | | /** åæ·å
å¼å
¥å£ä¼ å
¥çå®¢æ· ID */ |
| | | private Integer customerId; |
| | | } |
| | |
| | | @TableField(exist = false) |
| | | @ApiModelProperty("å¡ççé-ç½å
³MAC") |
| | | private String wgMacFilter; |
| | | |
| | | @TableField(exist = false) |
| | | @ApiModelProperty("åæ·å
³è-çµè´¹å æ¯%") |
| | | private Integer devRatio; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.dao.business.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.doumee.core.model.LoginUserModel; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | | @TableName("yw_customer_conditioner") |
| | | @ApiModel("åæ·å
³è空è°å
æº") |
| | | public class YwCustomerConditioner extends LoginUserModel { |
| | | |
| | | @TableId(type = IdType.AUTO) |
| | | private Integer id; |
| | | private Integer creator; |
| | | private Date createDate; |
| | | private Integer editor; |
| | | private Date editDate; |
| | | private Integer isdeleted; |
| | | private String remark; |
| | | |
| | | @ApiModelProperty("å®¢æ· ID") |
| | | private Integer customerId; |
| | | |
| | | @ApiModelProperty("空è°å
æº ID") |
| | | private Integer conditionerId; |
| | | |
| | | @ApiModelProperty("çµè´¹å æ¯%") |
| | | private Integer devRatio; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.dao.business.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.doumee.core.model.LoginUserModel; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | | @TableName("yw_customer_electrical") |
| | | @ApiModel("åæ·å
³èçµè¡¨") |
| | | public class YwCustomerElectrical extends LoginUserModel { |
| | | |
| | | @TableId(type = IdType.AUTO) |
| | | private Integer id; |
| | | private Integer creator; |
| | | private Date createDate; |
| | | private Integer editor; |
| | | private Date editDate; |
| | | private Integer isdeleted; |
| | | private String remark; |
| | | |
| | | @ApiModelProperty("å®¢æ· ID") |
| | | private Integer customerId; |
| | | |
| | | @ApiModelProperty("çµè¡¨ ID") |
| | | private Integer electricalId; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.dao.business.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.doumee.core.model.LoginUserModel; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | | @TableName("yw_customer_gs") |
| | | @ApiModel("åæ·ç©ºè° GS é
ç½®") |
| | | public class YwCustomerGs extends LoginUserModel { |
| | | |
| | | @TableId(type = IdType.AUTO) |
| | | private Integer id; |
| | | private Integer creator; |
| | | private Date createDate; |
| | | private Integer editor; |
| | | private Date editDate; |
| | | private Integer isdeleted; |
| | | private String remark; |
| | | |
| | | @ApiModelProperty("å®¢æ· ID") |
| | | private Integer customerId; |
| | | |
| | | @ApiModelProperty("æºç²¾çµ GS å
¬å¸ ID") |
| | | private Integer platformGsId; |
| | | |
| | | @ApiModelProperty("计费å¼å
³ 0å
³ 1å¼") |
| | | private Integer isPwr; |
| | | |
| | | @ApiModelProperty("18:00-09:00 ä¸åæº 0å¦ 1æ¯") |
| | | private Integer isRestStop; |
| | | |
| | | @ApiModelProperty("夿³¨") |
| | | private String gsBz; |
| | | |
| | | @ApiModelProperty("æ¬ è´¹é¢åº¦ï¼å
ï¼") |
| | | private BigDecimal stopMoney; |
| | | |
| | | @ApiModelProperty("å©ä½éé¢") |
| | | private BigDecimal leftMoney; |
| | | |
| | | @ApiModelProperty("ä½é¢åæ¥æ¶é´") |
| | | private Date syncDate; |
| | | } |
| | |
| | | @ApiModelProperty("å
å¼åè´¦å·ä½é¢ï¼å
ï¼") |
| | | @ExcelColumn(name="å
å¼åè´¦å·ä½é¢ï¼å
ï¼",index=25 ,width=10) |
| | | private BigDecimal banlance; |
| | | @ApiModelProperty("å
å¼åä½é¢ï¼å
ï¼") |
| | | @ExcelColumn(name="å
å¼åä½é¢ï¼å
ï¼",index=26 ,width=10) |
| | | private BigDecimal balanceAfter; |
| | | @ApiModelProperty("设å¤å±ç¤ºä¿¡æ¯") |
| | | @ExcelColumn(name="设å¤å±ç¤ºä¿¡æ¯",index=27 ,width=10) |
| | | private String deviceInfo; |
| | | @ApiModelProperty("éæ©çµè¡¨åæ°ç´æ¥ï¼yw_electrical_param)") |
| | | @ExcelColumn(name="éæ©çµè¡¨åæ°ç´æ¥ï¼yw_electrical_param)",index=26 ,width=10) |
| | | @ExcelColumn(name="éæ©çµè¡¨åæ°ç´æ¥ï¼yw_electrical_param)",index=28 ,width=10) |
| | | private Integer paramId; |
| | | |
| | | @TableField(exist = false) |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.service.business; |
| | | |
| | | import com.doumee.core.model.LoginUserInfo; |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.dao.business.dto.*; |
| | | import com.doumee.dao.business.model.YwConditioner; |
| | | import com.doumee.dao.business.model.YwCustomerGs; |
| | | import com.doumee.dao.business.model.YwElectrical; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | public interface YwCustomerRechargeBizService { |
| | | |
| | | PageData<YwCustomerRechargeMerchantVO> findMerchantPage(PageWrap<YwCustomerRechargeQueryDTO> pageWrap); |
| | | |
| | | YwCustomerRechargeDetailVO getDetail(Integer customerId); |
| | | |
| | | PageData<YwElectrical> listCustomerElectrical(PageWrap<YwElectrical> pageWrap, Integer customerId); |
| | | |
| | | PageData<YwElectrical> pageSelectableElectrical(PageWrap<YwElectrical> pageWrap, Integer customerId); |
| | | |
| | | void saveCustomerElectrical(YwCustomerElectricalSaveDTO dto, LoginUserInfo user); |
| | | |
| | | void removeCustomerElectrical(Integer customerId, Integer electricalId, LoginUserInfo user); |
| | | |
| | | PageData<YwConditioner> listCustomerConditioner(PageWrap<YwConditioner> pageWrap, Integer customerId); |
| | | |
| | | YwCustomerGs getCustomerGsConfig(Integer customerId); |
| | | |
| | | void saveCustomerGsConfig(YwCustomerGsConfigDTO dto, LoginUserInfo user); |
| | | |
| | | String rechargeElectrical(YwCustomerRechargeElectricalDTO dto, LoginUserInfo user); |
| | | |
| | | String resetElectricalAccount(YwCustomerRechargeElectricalDTO dto, LoginUserInfo user); |
| | | |
| | | Map<String, Object> readMeterAndRefresh(Integer customerId, Integer electricalId, LoginUserInfo user); |
| | | |
| | | Map<String, Object> getElectricalRemoteInfo(Integer electricalId); |
| | | |
| | | Map<String, Object> getConditionerRechargeInfo(Integer customerId); |
| | | |
| | | String rechargeConditioner(YwCustomerRechargeConditionerDTO dto, LoginUserInfo user); |
| | | |
| | | String cleanConditionerAccount(Integer customerId, LoginUserInfo user); |
| | | |
| | | PageData<YwCustomerRechargeRecordVO> findRechargeRecordPage(PageWrap<YwCustomerRechargeRecordQueryDTO> pageWrap); |
| | | |
| | | String retryRecharge(Integer id, LoginUserInfo user); |
| | | |
| | | String syncRechargeStatus(Integer id, LoginUserInfo user); |
| | | |
| | | void exportRechargeRecord(PageWrap<YwCustomerRechargeRecordQueryDTO> pageWrap, HttpServletResponse response); |
| | | } |
| | |
| | | public interface YwElectricalActionsService { |
| | | |
| | | PageData<YwElectricalActions> findPage(PageWrap<YwElectricalActions> pageWrap); |
| | | |
| | | /** 䏻卿¥è¯¢å¼æ¥ä»»å¡ç¶æå¹¶åæ¥æ¬å°æä½/å
å¼ç»æ */ |
| | | String queryAsyncResult(Integer id); |
| | | } |
| | |
| | | |
| | | boolean handleElectricalNotify(String responseContent, String timestamp, String sign); |
| | | |
| | | /** 䏻卿¥è¯¢åä¸ªå¼æ¥ä»»å¡ç¶æå¹¶åæ¥æ¬å°è®°å½ */ |
| | | String syncAsyncActionStatus(String oprId); |
| | | |
| | | /** æå
å¼è®°å½ ID æå¨åæ¥ï¼ä»
å
å¼ä¸çµè¡¨è®°å½ï¼ */ |
| | | String syncChargeStatusById(Integer chargeId); |
| | | |
| | | /** 宿¶æ¹éæ¥è¯¢å¤çä¸ç弿¥ä»»å¡ç¶æï¼åè°ä¸¢å¤±æ¶çè¡¥å¿ï¼ */ |
| | | void syncPendingAsyncActionsScheduled(); |
| | | |
| | | void syncMeterDataScheduled(); |
| | | |
| | | /** æå¨ä»ç¬¬ä¸æ¹å¹³å°æåæè¡¨æ°æ®å
¥åº */ |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.doumee.core.annotation.excel.ExcelExporter; |
| | | import com.doumee.core.conditoner.ConditionerUtil; |
| | | import com.doumee.core.conditoner.model.request.AddMoneyRequest; |
| | | import com.doumee.core.conditoner.model.request.CompanyGsManageRequest; |
| | | import com.doumee.core.conditoner.model.request.LogQueryRequest; |
| | | import com.doumee.core.conditoner.model.response.CompanyGsInfoResponse; |
| | | import com.doumee.core.conditoner.model.response.ConditionerBaseResponse; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.model.LoginUserInfo; |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.business.*; |
| | | import com.doumee.dao.business.dto.*; |
| | | import com.doumee.dao.business.model.*; |
| | | import com.doumee.service.business.ConditionerBizService; |
| | | import com.doumee.service.business.YwCustomerRechargeBizService; |
| | | import com.doumee.service.business.YwElectricalBizService; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | public class YwCustomerRechargeBizServiceImpl implements YwCustomerRechargeBizService { |
| | | |
| | | private static final String ONLINE_TEXT = "å¨çº¿"; |
| | | |
| | | @Autowired |
| | | private YwCustomerMapper ywCustomerMapper; |
| | | @Autowired |
| | | private MemberMapper memberMapper; |
| | | @Autowired |
| | | private YwCustomerGsMapper ywCustomerGsMapper; |
| | | @Autowired |
| | | private YwCustomerElectricalMapper ywCustomerElectricalMapper; |
| | | @Autowired |
| | | private YwCustomerConditionerMapper ywCustomerConditionerMapper; |
| | | @Autowired |
| | | private YwElectricalMapper ywElectricalMapper; |
| | | @Autowired |
| | | private YwConditionerMapper ywConditionerMapper; |
| | | @Autowired |
| | | private YwElectricalChargeMapper ywElectricalChargeMapper; |
| | | @Autowired |
| | | private YwElectricalActionsMapper ywElectricalActionsMapper; |
| | | @Autowired |
| | | private YwElectricalBizService ywElectricalBizService; |
| | | @Autowired |
| | | private ConditionerBizService conditionerBizService; |
| | | |
| | | @Override |
| | | public PageData<YwCustomerRechargeMerchantVO> findMerchantPage(PageWrap<YwCustomerRechargeQueryDTO> pageWrap) { |
| | | YwCustomerRechargeQueryDTO query = pageWrap.getModel() != null ? pageWrap.getModel() : new YwCustomerRechargeQueryDTO(); |
| | | boolean hasDeviceFilter = query.getElectricalStatusFilter() != null || query.getConditionerStatusFilter() != null; |
| | | |
| | | if (hasDeviceFilter) { |
| | | List<YwCustomer> all = ywCustomerMapper.selectList(new QueryWrapper<YwCustomer>().lambda() |
| | | .eq(YwCustomer::getIsdeleted, Constants.ZERO) |
| | | .like(StringUtils.isNotBlank(query.getNameKeyword()), YwCustomer::getName, query.getNameKeyword()) |
| | | .orderByDesc(YwCustomer::getCreateDate)); |
| | | List<YwCustomerRechargeMerchantVO> enriched = enrichMerchantList(all); |
| | | List<YwCustomerRechargeMerchantVO> filtered = enriched.stream() |
| | | .filter(vo -> matchDeviceFilter(vo, query)) |
| | | .collect(Collectors.toList()); |
| | | return manualPage(filtered, pageWrap.getPage(), pageWrap.getCapacity()); |
| | | } |
| | | |
| | | IPage<YwCustomer> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); |
| | | IPage<YwCustomer> result = ywCustomerMapper.selectPage(page, new QueryWrapper<YwCustomer>().lambda() |
| | | .eq(YwCustomer::getIsdeleted, Constants.ZERO) |
| | | .like(StringUtils.isNotBlank(query.getNameKeyword()), YwCustomer::getName, query.getNameKeyword()) |
| | | .orderByDesc(YwCustomer::getCreateDate)); |
| | | List<YwCustomerRechargeMerchantVO> list = enrichMerchantList(result.getRecords()); |
| | | PageData<YwCustomerRechargeMerchantVO> data = new PageData<>(); |
| | | data.setRecords(list); |
| | | data.setTotal(result.getTotal()); |
| | | data.setPage(result.getCurrent()); |
| | | data.setCapacity(result.getSize()); |
| | | return data; |
| | | } |
| | | |
| | | private PageData<YwCustomerRechargeMerchantVO> manualPage(List<YwCustomerRechargeMerchantVO> list, long page, long capacity) { |
| | | int p = (int) Math.max(page, 1); |
| | | int size = (int) Math.max(capacity, 1); |
| | | int from = (p - 1) * size; |
| | | int to = Math.min(from + size, list.size()); |
| | | PageData<YwCustomerRechargeMerchantVO> data = new PageData<>(); |
| | | data.setTotal(list.size()); |
| | | data.setPage(p); |
| | | data.setCapacity(size); |
| | | data.setRecords(from >= list.size() ? Collections.emptyList() : list.subList(from, to)); |
| | | return data; |
| | | } |
| | | |
| | | private boolean matchDeviceFilter(YwCustomerRechargeMerchantVO vo, YwCustomerRechargeQueryDTO query) { |
| | | if (query.getElectricalStatusFilter() != null && !matchStatusFilter( |
| | | query.getElectricalStatusFilter(), vo.getElectricalCount(), vo.getElectricalOnlineAll(), vo.getElectricalHasOffline())) { |
| | | return false; |
| | | } |
| | | if (query.getConditionerStatusFilter() != null && !matchStatusFilter( |
| | | query.getConditionerStatusFilter(), vo.getConditionerCount(), vo.getConditionerOnlineAll(), vo.getConditionerHasOffline())) { |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | private boolean matchStatusFilter(Integer filter, Integer count, Boolean allOnline, Boolean hasOffline) { |
| | | int c = count != null ? count : 0; |
| | | if (filter == 3) { |
| | | return c == 0; |
| | | } |
| | | if (c == 0) { |
| | | return false; |
| | | } |
| | | if (filter == 1) { |
| | | return Boolean.TRUE.equals(allOnline); |
| | | } |
| | | if (filter == 2) { |
| | | return Boolean.TRUE.equals(hasOffline); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | private List<YwCustomerRechargeMerchantVO> enrichMerchantList(List<YwCustomer> customers) { |
| | | if (CollectionUtils.isEmpty(customers)) { |
| | | return Collections.emptyList(); |
| | | } |
| | | List<Integer> customerIds = customers.stream().map(YwCustomer::getId).collect(Collectors.toList()); |
| | | |
| | | Map<Integer, YwCustomerGs> gsMap = ywCustomerGsMapper.selectList(new QueryWrapper<YwCustomerGs>().lambda() |
| | | .eq(YwCustomerGs::getIsdeleted, Constants.ZERO) |
| | | .in(YwCustomerGs::getCustomerId, customerIds)) |
| | | .stream().collect(Collectors.toMap(YwCustomerGs::getCustomerId, g -> g, (a, b) -> a)); |
| | | |
| | | List<YwCustomerElectrical> relE = ywCustomerElectricalMapper.selectList(new QueryWrapper<YwCustomerElectrical>().lambda() |
| | | .eq(YwCustomerElectrical::getIsdeleted, Constants.ZERO) |
| | | .in(YwCustomerElectrical::getCustomerId, customerIds)); |
| | | Map<Integer, List<Integer>> customerElectricalIds = relE.stream() |
| | | .collect(Collectors.groupingBy(YwCustomerElectrical::getCustomerId, |
| | | Collectors.mapping(YwCustomerElectrical::getElectricalId, Collectors.toList()))); |
| | | |
| | | List<YwCustomerConditioner> relC = ywCustomerConditionerMapper.selectList(new QueryWrapper<YwCustomerConditioner>().lambda() |
| | | .eq(YwCustomerConditioner::getIsdeleted, Constants.ZERO) |
| | | .in(YwCustomerConditioner::getCustomerId, customerIds)); |
| | | Map<Integer, List<Integer>> customerConditionerIds = relC.stream() |
| | | .collect(Collectors.groupingBy(YwCustomerConditioner::getCustomerId, |
| | | Collectors.mapping(YwCustomerConditioner::getConditionerId, Collectors.toList()))); |
| | | |
| | | Set<Integer> allElectricalIds = relE.stream().map(YwCustomerElectrical::getElectricalId).collect(Collectors.toSet()); |
| | | Map<Integer, YwElectrical> electricalMap = allElectricalIds.isEmpty() ? Collections.emptyMap() |
| | | : ywElectricalMapper.selectBatchIds(allElectricalIds).stream() |
| | | .filter(e -> !Objects.equals(e.getIsdeleted(), Constants.ONE)) |
| | | .collect(Collectors.toMap(YwElectrical::getId, e -> e, (a, b) -> a)); |
| | | |
| | | Set<Integer> allConditionerIds = relC.stream().map(YwCustomerConditioner::getConditionerId).collect(Collectors.toSet()); |
| | | Map<Integer, YwConditioner> conditionerMap = allConditionerIds.isEmpty() ? Collections.emptyMap() |
| | | : ywConditionerMapper.selectBatchIds(allConditionerIds).stream() |
| | | .filter(c -> !Objects.equals(c.getIsdeleted(), Constants.ONE)) |
| | | .collect(Collectors.toMap(YwConditioner::getId, c -> c, (a, b) -> a)); |
| | | |
| | | Set<Integer> memberIds = customers.stream() |
| | | .map(YwCustomer::getMemberId) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toSet()); |
| | | Map<Integer, Member> memberMap = memberIds.isEmpty() ? Collections.emptyMap() |
| | | : memberMapper.selectBatchIds(memberIds).stream() |
| | | .filter(m -> !Objects.equals(m.getIsdeleted(), Constants.ONE)) |
| | | .collect(Collectors.toMap(Member::getId, m -> m, (a, b) -> a)); |
| | | |
| | | List<YwCustomerRechargeMerchantVO> list = new ArrayList<>(); |
| | | for (YwCustomer c : customers) { |
| | | YwCustomerRechargeMerchantVO vo = new YwCustomerRechargeMerchantVO(); |
| | | vo.setId(c.getId()); |
| | | vo.setType(c.getType()); |
| | | vo.setName(c.getName()); |
| | | vo.setPhone(c.getPhone()); |
| | | vo.setCreateDate(c.getCreateDate()); |
| | | Member member = c.getMemberId() != null ? memberMap.get(c.getMemberId()) : null; |
| | | if (member != null) { |
| | | vo.setMemberName(member.getName()); |
| | | vo.setMemberPhone(member.getPhone()); |
| | | } |
| | | |
| | | List<Integer> eIds = customerElectricalIds.getOrDefault(c.getId(), Collections.emptyList()); |
| | | vo.setElectricalCount(eIds.size()); |
| | | if (eIds.isEmpty()) { |
| | | vo.setElectricalBalances(Collections.emptyList()); |
| | | vo.setElectricalOnlineAll(false); |
| | | vo.setElectricalHasOffline(false); |
| | | } else { |
| | | List<YwCustomerElectricalBalanceItem> balanceItems = new ArrayList<>(); |
| | | boolean allOnline = true; |
| | | boolean hasOffline = false; |
| | | int index = 0; |
| | | for (Integer eid : eIds) { |
| | | YwElectrical e = electricalMap.get(eid); |
| | | if (e == null) continue; |
| | | YwCustomerElectricalBalanceItem item = new YwCustomerElectricalBalanceItem(); |
| | | index++; |
| | | item.setName(StringUtils.isNotBlank(e.getName()) ? e.getName() : ("çµè¡¨" + index)); |
| | | item.setAddress(StringUtils.isNotBlank(e.getAddress()) ? e.getAddress() : "-"); |
| | | item.setBalance(e.getBalance() != null ? e.getBalance() : BigDecimal.ZERO); |
| | | balanceItems.add(item); |
| | | if (!Objects.equals(e.getOnline(), Constants.ONE)) { |
| | | allOnline = false; |
| | | hasOffline = true; |
| | | } |
| | | } |
| | | vo.setElectricalBalances(balanceItems); |
| | | vo.setElectricalOnlineAll(allOnline && !balanceItems.isEmpty()); |
| | | vo.setElectricalHasOffline(hasOffline); |
| | | } |
| | | |
| | | List<Integer> cIds = customerConditionerIds.getOrDefault(c.getId(), Collections.emptyList()); |
| | | vo.setConditionerCount(cIds.size()); |
| | | if (cIds.isEmpty()) { |
| | | vo.setConditionerOnlineAll(false); |
| | | vo.setConditionerHasOffline(false); |
| | | } else { |
| | | boolean allOnline = true; |
| | | boolean hasOffline = false; |
| | | for (Integer cid : cIds) { |
| | | YwConditioner cond = conditionerMap.get(cid); |
| | | if (cond == null) continue; |
| | | if (!ONLINE_TEXT.equals(cond.getOnline())) { |
| | | allOnline = false; |
| | | hasOffline = true; |
| | | } |
| | | } |
| | | vo.setConditionerOnlineAll(allOnline); |
| | | vo.setConditionerHasOffline(hasOffline); |
| | | } |
| | | |
| | | YwCustomerGs gs = gsMap.get(c.getId()); |
| | | if (gs != null) { |
| | | vo.setAcBalance(gs.getLeftMoney()); |
| | | vo.setAcBalanceSyncDate(gs.getSyncDate()); |
| | | } |
| | | list.add(vo); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public YwCustomerRechargeDetailVO getDetail(Integer customerId) { |
| | | YwCustomer customer = requireCustomer(customerId); |
| | | YwCustomerRechargeDetailVO vo = new YwCustomerRechargeDetailVO(); |
| | | vo.setCustomerId(customer.getId()); |
| | | vo.setCustomerName(customer.getName()); |
| | | vo.setPhone(customer.getPhone()); |
| | | vo.setGsConfig(getCustomerGsConfig(customerId)); |
| | | vo.setElectricalList(loadCustomerElectricalList(customerId)); |
| | | vo.setConditionerList(loadCustomerConditionerList(customerId)); |
| | | return vo; |
| | | } |
| | | |
| | | @Override |
| | | public PageData<YwElectrical> listCustomerElectrical(PageWrap<YwElectrical> pageWrap, Integer customerId) { |
| | | requireCustomer(customerId); |
| | | List<Integer> ids = listBoundElectricalIds(customerId); |
| | | if (ids.isEmpty()) { |
| | | return emptyPage(pageWrap); |
| | | } |
| | | return pageElectricalByIds(pageWrap, ids); |
| | | } |
| | | |
| | | @Override |
| | | public PageData<YwElectrical> pageSelectableElectrical(PageWrap<YwElectrical> pageWrap, Integer customerId) { |
| | | requireCustomer(customerId); |
| | | Set<Integer> excluded = listAllBoundElectricalIds(); |
| | | IPage<YwElectrical> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); |
| | | YwElectrical model = pageWrap.getModel(); |
| | | QueryWrapper<YwElectrical> qw = new QueryWrapper<>(); |
| | | qw.lambda() |
| | | .eq(YwElectrical::getIsdeleted, Constants.ZERO) |
| | | .notIn(!excluded.isEmpty(), YwElectrical::getId, excluded) |
| | | .and(model != null && StringUtils.isNotBlank(model.getName()), w -> w |
| | | .like(YwElectrical::getName, model.getName()) |
| | | .or().like(YwElectrical::getAddress, model.getName())) |
| | | .orderByDesc(YwElectrical::getCreateDate); |
| | | IPage<YwElectrical> result = ywElectricalMapper.selectPage(page, qw); |
| | | ywElectricalBizService.enrichList(result.getRecords()); |
| | | return PageData.from(result); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void saveCustomerElectrical(YwCustomerElectricalSaveDTO dto, LoginUserInfo user) { |
| | | requireCustomer(dto.getCustomerId()); |
| | | if (CollectionUtils.isEmpty(dto.getElectricalIds())) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "è¯·éæ©çµè¡¨"); |
| | | } |
| | | Set<Integer> excluded = listAllBoundElectricalIdsExcept(dto.getCustomerId()); |
| | | for (Integer eid : dto.getElectricalIds()) { |
| | | if (excluded.contains(eid)) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "çµè¡¨å·²è¢«å
¶ä»åæ·ç»å®ï¼" + eid); |
| | | } |
| | | YwCustomerElectrical exist = ywCustomerElectricalMapper.selectOne(new QueryWrapper<YwCustomerElectrical>().lambda() |
| | | .eq(YwCustomerElectrical::getCustomerId, dto.getCustomerId()) |
| | | .eq(YwCustomerElectrical::getElectricalId, eid) |
| | | .eq(YwCustomerElectrical::getIsdeleted, Constants.ZERO) |
| | | .last("limit 1")); |
| | | if (exist != null) { |
| | | continue; |
| | | } |
| | | YwCustomerElectrical rel = new YwCustomerElectrical(); |
| | | rel.setCreator(user.getId()); |
| | | rel.setCreateDate(new Date()); |
| | | rel.setEditor(user.getId()); |
| | | rel.setEditDate(new Date()); |
| | | rel.setIsdeleted(Constants.ZERO); |
| | | rel.setCustomerId(dto.getCustomerId()); |
| | | rel.setElectricalId(eid); |
| | | ywCustomerElectricalMapper.insert(rel); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void removeCustomerElectrical(Integer customerId, Integer electricalId, LoginUserInfo user) { |
| | | ywCustomerElectricalMapper.update(null, new UpdateWrapper<YwCustomerElectrical>().lambda() |
| | | .set(YwCustomerElectrical::getIsdeleted, Constants.ONE) |
| | | .set(YwCustomerElectrical::getEditDate, new Date()) |
| | | .set(YwCustomerElectrical::getEditor, user.getId()) |
| | | .eq(YwCustomerElectrical::getCustomerId, customerId) |
| | | .eq(YwCustomerElectrical::getElectricalId, electricalId) |
| | | .eq(YwCustomerElectrical::getIsdeleted, Constants.ZERO)); |
| | | } |
| | | |
| | | @Override |
| | | public PageData<YwConditioner> listCustomerConditioner(PageWrap<YwConditioner> pageWrap, Integer customerId) { |
| | | requireCustomer(customerId); |
| | | List<YwConditioner> list = loadCustomerConditionerList(customerId); |
| | | if (CollectionUtils.isEmpty(list)) { |
| | | return emptyPage(pageWrap); |
| | | } |
| | | int p = (int) Math.max(pageWrap.getPage(), 1); |
| | | int size = (int) Math.max(pageWrap.getCapacity(), 1); |
| | | int from = (p - 1) * size; |
| | | int to = Math.min(from + size, list.size()); |
| | | PageData<YwConditioner> data = new PageData<>(); |
| | | data.setTotal(list.size()); |
| | | data.setPage(p); |
| | | data.setCapacity(size); |
| | | data.setRecords(from >= list.size() ? Collections.emptyList() : list.subList(from, to)); |
| | | return data; |
| | | } |
| | | |
| | | @Override |
| | | public YwCustomerGs getCustomerGsConfig(Integer customerId) { |
| | | return ywCustomerGsMapper.selectOne(new QueryWrapper<YwCustomerGs>().lambda() |
| | | .eq(YwCustomerGs::getCustomerId, customerId) |
| | | .eq(YwCustomerGs::getIsdeleted, Constants.ZERO) |
| | | .last("limit 1")); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void saveCustomerGsConfig(YwCustomerGsConfigDTO dto, LoginUserInfo user) { |
| | | YwCustomer customer = requireCustomer(dto.getCustomerId()); |
| | | if (CollectionUtils.isEmpty(dto.getConditioners())) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "请è³å°å
³èä¸å°ç©ºè°å
æº"); |
| | | } |
| | | conditionerBizService.ensureLogin(); |
| | | |
| | | List<Integer> conditionerIds = dto.getConditioners().stream() |
| | | .map(YwCustomerGsConfigDTO.ConditionerItem::getConditionerId) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toList()); |
| | | List<YwConditioner> conditioners = ywConditionerMapper.selectBatchIds(conditionerIds); |
| | | Map<Integer, YwConditioner> condMap = conditioners.stream() |
| | | .filter(c -> !Objects.equals(c.getIsdeleted(), Constants.ONE)) |
| | | .collect(Collectors.toMap(YwConditioner::getId, c -> c, (a, b) -> a)); |
| | | |
| | | List<Integer> liDev = new ArrayList<>(); |
| | | Map<String, Object> dDev = new LinkedHashMap<>(); |
| | | for (YwCustomerGsConfigDTO.ConditionerItem item : dto.getConditioners()) { |
| | | YwConditioner cond = condMap.get(item.getConditionerId()); |
| | | if (cond == null || cond.getPlatformDevId() == null) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "å
æºç¼ºå°å¹³å°è®¾å¤ ID"); |
| | | } |
| | | liDev.add(cond.getPlatformDevId()); |
| | | int ratio = item.getDevRatio() != null ? item.getDevRatio() : 100; |
| | | dDev.put(String.valueOf(cond.getPlatformDevId()), ratio); |
| | | } |
| | | |
| | | YwCustomerGs gs = getCustomerGsConfig(dto.getCustomerId()); |
| | | if (gs == null) { |
| | | gs = new YwCustomerGs(); |
| | | gs.setCreator(user.getId()); |
| | | gs.setCreateDate(new Date()); |
| | | gs.setIsdeleted(Constants.ZERO); |
| | | gs.setCustomerId(dto.getCustomerId()); |
| | | } |
| | | gs.setEditor(user.getId()); |
| | | gs.setEditDate(new Date()); |
| | | gs.setIsPwr(dto.getIsPwr() != null ? dto.getIsPwr() : Constants.ONE); |
| | | gs.setIsRestStop(dto.getIsRestStop() != null ? dto.getIsRestStop() : Constants.ZERO); |
| | | gs.setGsBz(StringUtils.defaultString(dto.getGsBz())); |
| | | gs.setStopMoney(dto.getStopMoney() != null ? dto.getStopMoney() : BigDecimal.ZERO); |
| | | |
| | | if (StringUtils.isBlank(customer.getName())) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "客æ·åç§°ä¸è½ä¸ºç©º"); |
| | | } |
| | | if (liDev.isEmpty()) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "å
³èå
æºå¹³å°è®¾å¤ ID æ æ"); |
| | | } |
| | | |
| | | CompanyGsManageRequest companyReq = new CompanyGsManageRequest(); |
| | | companyReq.fillSessionDefaults(); |
| | | companyReq.setGs_name(customer.getName().trim()); |
| | | companyReq.setIs_pwr(gs.getIsPwr()); |
| | | companyReq.setIs_rest_stop(gs.getIsRestStop()); |
| | | companyReq.setGs_bz(gs.getGsBz()); |
| | | companyReq.setStop_money(gs.getStopMoney()); |
| | | |
| | | if (gs.getPlatformGsId() == null) { |
| | | ConditionerBaseResponse<Object> addResp = ConditionerUtil.addGs(companyReq); |
| | | if (addResp == null || !addResp.isSuccess()) { |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), apiMsg(addResp, "addGs 失败")); |
| | | } |
| | | gs.setPlatformGsId(parseAddGsId(addResp.getData())); |
| | | if (gs.getPlatformGsId() == null) { |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "addGs æªè¿åå
¬å¸ ID"); |
| | | } |
| | | } |
| | | |
| | | CompanyGsManageRequest changeReq = new CompanyGsManageRequest(); |
| | | changeReq.fillSessionDefaults(); |
| | | changeReq.setId(gs.getPlatformGsId()); |
| | | changeReq.setGs_name(companyReq.getGs_name()); |
| | | changeReq.setIs_pwr(companyReq.getIs_pwr()); |
| | | changeReq.setIs_rest_stop(companyReq.getIs_rest_stop()); |
| | | changeReq.setGs_bz(companyReq.getGs_bz()); |
| | | changeReq.setStop_money(gs.getStopMoney()); |
| | | changeReq.setLi_dev(liDev); |
| | | changeReq.setD_dev(dDev); |
| | | if (gs.getLeftMoney() != null) { |
| | | changeReq.setLeft_money(gs.getLeftMoney()); |
| | | } |
| | | ConditionerBaseResponse<Object> changeResp = ConditionerUtil.changeGs(changeReq); |
| | | if (changeResp == null || !changeResp.isSuccess()) { |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), apiMsg(changeResp, "changeGs 失败")); |
| | | } |
| | | |
| | | refreshGsLeftMoney(gs); |
| | | if (gs.getId() == null) { |
| | | ywCustomerGsMapper.insert(gs); |
| | | } else { |
| | | ywCustomerGsMapper.updateById(gs); |
| | | } |
| | | |
| | | ywCustomerConditionerMapper.update(null, new UpdateWrapper<YwCustomerConditioner>().lambda() |
| | | .set(YwCustomerConditioner::getIsdeleted, Constants.ONE) |
| | | .set(YwCustomerConditioner::getEditDate, new Date()) |
| | | .set(YwCustomerConditioner::getEditor, user.getId()) |
| | | .eq(YwCustomerConditioner::getCustomerId, dto.getCustomerId()) |
| | | .eq(YwCustomerConditioner::getIsdeleted, Constants.ZERO)); |
| | | |
| | | for (YwCustomerGsConfigDTO.ConditionerItem item : dto.getConditioners()) { |
| | | YwCustomerConditioner rel = new YwCustomerConditioner(); |
| | | rel.setCreator(user.getId()); |
| | | rel.setCreateDate(new Date()); |
| | | rel.setEditor(user.getId()); |
| | | rel.setEditDate(new Date()); |
| | | rel.setIsdeleted(Constants.ZERO); |
| | | rel.setCustomerId(dto.getCustomerId()); |
| | | rel.setConditionerId(item.getConditionerId()); |
| | | rel.setDevRatio(item.getDevRatio() != null ? item.getDevRatio() : 100); |
| | | ywCustomerConditionerMapper.insert(rel); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public String rechargeElectrical(YwCustomerRechargeElectricalDTO dto, LoginUserInfo user) { |
| | | requireCustomer(dto.getCustomerId()); |
| | | assertElectricalBound(dto.getCustomerId(), dto.getElectricalId()); |
| | | YwElectricalOperateDTO op = new YwElectricalOperateDTO(); |
| | | op.setElectricalId(dto.getElectricalId()); |
| | | op.setAction("recharge"); |
| | | op.setMoney(dto.getMoney()); |
| | | op.setRemark(dto.getRemark()); |
| | | op.setCustomerId(dto.getCustomerId()); |
| | | return ywElectricalBizService.operate(op, user); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public String resetElectricalAccount(YwCustomerRechargeElectricalDTO dto, LoginUserInfo user) { |
| | | requireCustomer(dto.getCustomerId()); |
| | | assertElectricalBound(dto.getCustomerId(), dto.getElectricalId()); |
| | | String action = StringUtils.defaultIfBlank(dto.getResetAction(), "resetPrepay"); |
| | | YwElectricalOperateDTO op = new YwElectricalOperateDTO(); |
| | | op.setElectricalId(dto.getElectricalId()); |
| | | op.setAction(action); |
| | | op.setCustomerId(dto.getCustomerId()); |
| | | return ywElectricalBizService.operate(op, user); |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> getElectricalRemoteInfo(Integer electricalId) { |
| | | return ywElectricalBizService.getRemoteInfo(electricalId); |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> readMeterAndRefresh(Integer customerId, Integer electricalId, LoginUserInfo user) { |
| | | assertElectricalBound(customerId, electricalId); |
| | | YwElectricalOperateDTO op = new YwElectricalOperateDTO(); |
| | | op.setElectricalId(electricalId); |
| | | op.setAction("readMeter"); |
| | | op.setCustomerId(customerId); |
| | | String msg = ywElectricalBizService.operate(op, user); |
| | | Map<String, Object> info = ywElectricalBizService.getRemoteInfo(electricalId); |
| | | info.put("message", msg); |
| | | return info; |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> getConditionerRechargeInfo(Integer customerId) { |
| | | YwCustomerGs gs = requireGsConfig(customerId); |
| | | conditionerBizService.ensureLogin(); |
| | | refreshGsLeftMoney(gs); |
| | | ywCustomerGsMapper.updateById(gs); |
| | | |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| | | map.put("gsConfig", gs); |
| | | map.put("customerName", requireCustomer(customerId).getName()); |
| | | CompanyGsManageRequest req = new CompanyGsManageRequest(); |
| | | req.fillSessionDefaults(); |
| | | req.setId(gs.getPlatformGsId()); |
| | | ConditionerBaseResponse<List<CompanyGsInfoResponse>> resp = ConditionerUtil.getGs(req); |
| | | if (resp != null && resp.isSuccess() && !CollectionUtils.isEmpty(resp.getData())) { |
| | | CompanyGsInfoResponse info = resp.getData().get(0); |
| | | map.put("platformInfo", info); |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | @Override |
| | | public String rechargeConditioner(YwCustomerRechargeConditionerDTO dto, LoginUserInfo user) { |
| | | YwCustomerGs gs = requireGsConfig(dto.getCustomerId()); |
| | | if (dto.getMoney() == null || dto.getMoney().compareTo(BigDecimal.ZERO) <= 0) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "å
å¼éé¢é¡»å¤§äº 0"); |
| | | } |
| | | conditionerBizService.ensureLogin(); |
| | | AddMoneyRequest req = new AddMoneyRequest(); |
| | | req.fillSessionDefaults(); |
| | | req.setId(gs.getPlatformGsId()); |
| | | req.setCz_money(dto.getMoney().toPlainString()); |
| | | ConditionerBaseResponse<Object> resp = ConditionerUtil.addMoney(req); |
| | | YwElectricalCharge charge = buildConditionerCharge(dto, gs, user); |
| | | if (resp != null && resp.isSuccess()) { |
| | | refreshGsLeftMoney(gs); |
| | | ywCustomerGsMapper.updateById(gs); |
| | | charge.setStatus(Constants.ONE); |
| | | charge.setStatusInfo("å
弿å"); |
| | | charge.setBalanceAfter(gs.getLeftMoney()); |
| | | ywElectricalChargeMapper.insert(charge); |
| | | return "å
弿å"; |
| | | } |
| | | charge.setStatus(Constants.TWO); |
| | | charge.setStatusInfo(apiMsg(resp, "å
å¼å¤±è´¥")); |
| | | ywElectricalChargeMapper.insert(charge); |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), charge.getStatusInfo()); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public String cleanConditionerAccount(Integer customerId, LoginUserInfo user) { |
| | | YwCustomerGs gs = requireGsConfig(customerId); |
| | | conditionerBizService.ensureLogin(); |
| | | CompanyGsManageRequest req = new CompanyGsManageRequest(); |
| | | req.fillSessionDefaults(); |
| | | req.setId(gs.getPlatformGsId()); |
| | | ConditionerBaseResponse<Object> resp = ConditionerUtil.cleanMoney(req); |
| | | if (resp == null || !resp.isSuccess()) { |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), apiMsg(resp, "æ¸
é¶å¤±è´¥")); |
| | | } |
| | | refreshGsLeftMoney(gs); |
| | | gs.setEditor(user.getId()); |
| | | gs.setEditDate(new Date()); |
| | | ywCustomerGsMapper.updateById(gs); |
| | | return "æ¸
é¶æå"; |
| | | } |
| | | |
| | | @Override |
| | | public PageData<YwCustomerRechargeRecordVO> findRechargeRecordPage(PageWrap<YwCustomerRechargeRecordQueryDTO> pageWrap) { |
| | | Utils.MP.blankToNull(pageWrap.getModel()); |
| | | YwCustomerRechargeRecordQueryDTO query = pageWrap.getModel() != null ? pageWrap.getModel() : new YwCustomerRechargeRecordQueryDTO(); |
| | | IPage<YwCustomerRechargeRecordVO> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); |
| | | MPJLambdaWrapper<YwElectricalCharge> wrapper = new MPJLambdaWrapper<YwElectricalCharge>() |
| | | .selectAll(YwElectricalCharge.class) |
| | | .selectAs(YwCustomer::getName, YwCustomerRechargeRecordVO::getCustomerName) |
| | | .leftJoin(YwCustomer.class, YwCustomer::getId, YwElectricalCharge::getCustomerId) |
| | | .isNotNull(YwElectricalCharge::getCustomerId) |
| | | .eq(YwElectricalCharge::getIsdeleted, Constants.ZERO) |
| | | .eq(query.getType() != null, YwElectricalCharge::getType, query.getType()) |
| | | .eq(query.getStatus() != null, YwElectricalCharge::getStatus, query.getStatus()) |
| | | .like(StringUtils.isNotBlank(query.getCustomerName()), YwCustomer::getName, query.getCustomerName()) |
| | | .ge(query.getCreateTimeBegin() != null, YwElectricalCharge::getCreateDate, query.getCreateTimeBegin()) |
| | | .le(query.getCreateTimeEnd() != null, YwElectricalCharge::getCreateDate, query.getCreateTimeEnd()) |
| | | .orderByDesc(YwElectricalCharge::getCreateDate); |
| | | IPage<YwCustomerRechargeRecordVO> result = ywElectricalChargeMapper.selectJoinPage(page, YwCustomerRechargeRecordVO.class, wrapper); |
| | | result.getRecords().forEach(this::fillRecordText); |
| | | return PageData.from(result); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public String retryRecharge(Integer id, LoginUserInfo user) { |
| | | YwElectricalCharge charge = requireCharge(id); |
| | | if (!Objects.equals(charge.getStatus(), Constants.TWO)) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "ä»
失败记å½å¯å次æäº¤"); |
| | | } |
| | | if (Objects.equals(charge.getType(), Constants.ZERO)) { |
| | | YwCustomerRechargeElectricalDTO dto = new YwCustomerRechargeElectricalDTO(); |
| | | dto.setCustomerId(charge.getCustomerId()); |
| | | dto.setElectricalId(charge.getObjId()); |
| | | dto.setMoney(charge.getMoney()); |
| | | dto.setRemark(charge.getRemark()); |
| | | return rechargeElectrical(dto, user); |
| | | } |
| | | if (Objects.equals(charge.getType(), Constants.ONE)) { |
| | | YwCustomerRechargeConditionerDTO dto = new YwCustomerRechargeConditionerDTO(); |
| | | dto.setCustomerId(charge.getCustomerId()); |
| | | dto.setMoney(charge.getMoney()); |
| | | dto.setRemark(charge.getRemark()); |
| | | return rechargeConditioner(dto, user); |
| | | } |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public String syncRechargeStatus(Integer id, LoginUserInfo user) { |
| | | YwElectricalCharge charge = requireCharge(id); |
| | | if (!Objects.equals(charge.getStatus(), Constants.ZERO)) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "ä»
å
å¼ä¸è®°å½å¯åæ¥"); |
| | | } |
| | | if (Objects.equals(charge.getType(), Constants.ZERO)) { |
| | | return syncElectricalChargeStatus(charge, user); |
| | | } |
| | | if (Objects.equals(charge.getType(), Constants.ONE)) { |
| | | return syncConditionerChargeStatus(charge, user); |
| | | } |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | |
| | | @Override |
| | | public void exportRechargeRecord(PageWrap<YwCustomerRechargeRecordQueryDTO> pageWrap, HttpServletResponse response) { |
| | | pageWrap.setPage(1); |
| | | pageWrap.setCapacity(Integer.MAX_VALUE); |
| | | List<YwCustomerRechargeRecordVO> records = findRechargeRecordPage(pageWrap).getRecords(); |
| | | ExcelExporter.build(YwCustomerRechargeRecordVO.class).export(records, "åæ·å
å¼è®°å½", response); |
| | | } |
| | | |
| | | private String syncElectricalChargeStatus(YwElectricalCharge charge, LoginUserInfo user) { |
| | | return ywElectricalBizService.syncAsyncActionStatus(charge.getOprId()); |
| | | } |
| | | |
| | | private String syncConditionerChargeStatus(YwElectricalCharge charge, LoginUserInfo user) { |
| | | YwCustomerGs gs = requireGsConfig(charge.getCustomerId()); |
| | | conditionerBizService.ensureLogin(); |
| | | LogQueryRequest req = new LogQueryRequest(); |
| | | req.fillSessionDefaults(); |
| | | req.setPage(1); |
| | | req.setPageSize(50); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | if (charge.getCreateDate() != null) { |
| | | String day = sdf.format(charge.getCreateDate()); |
| | | req.setStart_time(day); |
| | | req.setEnd_time(day); |
| | | } |
| | | ConditionerBaseResponse<List<Object>> resp = ConditionerUtil.getCzLog(req); |
| | | if (resp == null || !resp.isSuccess() || CollectionUtils.isEmpty(resp.getData())) { |
| | | return "æªå¹é
å°å¹³å°å
弿¥å¿ï¼ä»ä¸ºå
å¼ä¸"; |
| | | } |
| | | for (Object row : resp.getData()) { |
| | | JSONObject o = (JSONObject) JSON.toJSON(row); |
| | | if (!matchCzLog(o, gs.getPlatformGsId(), charge)) { |
| | | continue; |
| | | } |
| | | refreshGsLeftMoney(gs); |
| | | ywCustomerGsMapper.updateById(gs); |
| | | updateChargeStatus(charge.getId(), Constants.ONE, "å
弿å", gs.getLeftMoney()); |
| | | return "å·²åæ¥ä¸ºå
弿å"; |
| | | } |
| | | return "æªå¹é
å°å¹³å°å
弿¥å¿ï¼ä»ä¸ºå
å¼ä¸"; |
| | | } |
| | | |
| | | private boolean matchCzLog(JSONObject o, Integer gsId, YwElectricalCharge charge) { |
| | | Integer logGsId = o.getInteger("gs_id"); |
| | | if (logGsId == null) { |
| | | logGsId = o.getInteger("id"); |
| | | } |
| | | if (!Objects.equals(logGsId, gsId)) { |
| | | return false; |
| | | } |
| | | String money = o.getString("cz_money"); |
| | | if (money == null) { |
| | | money = o.getString("money"); |
| | | } |
| | | if (charge.getMoney() != null && money != null) { |
| | | try { |
| | | return charge.getMoney().compareTo(new BigDecimal(money)) == 0; |
| | | } catch (NumberFormatException ignored) { |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | private void updateChargeStatus(Integer id, int status, String statusInfo, BigDecimal balanceAfter) { |
| | | UpdateWrapper<YwElectricalCharge> uw = new UpdateWrapper<>(); |
| | | uw.lambda() |
| | | .set(YwElectricalCharge::getStatus, status) |
| | | .set(YwElectricalCharge::getStatusInfo, statusInfo) |
| | | .set(YwElectricalCharge::getStatusTime, new Date()) |
| | | .set(YwElectricalCharge::getEditDate, new Date()) |
| | | .eq(YwElectricalCharge::getId, id); |
| | | if (balanceAfter != null) { |
| | | uw.lambda().set(YwElectricalCharge::getBalanceAfter, balanceAfter); |
| | | } |
| | | ywElectricalChargeMapper.update(null, uw); |
| | | } |
| | | |
| | | private YwElectricalCharge buildConditionerCharge(YwCustomerRechargeConditionerDTO dto, YwCustomerGs gs, LoginUserInfo user) { |
| | | YwCustomer customer = requireCustomer(dto.getCustomerId()); |
| | | YwElectricalCharge charge = new YwElectricalCharge(); |
| | | charge.setCreator(user.getId()); |
| | | charge.setCreateDate(new Date()); |
| | | charge.setEditor(user.getId()); |
| | | charge.setEditDate(new Date()); |
| | | charge.setIsdeleted(Constants.ZERO); |
| | | charge.setType(Constants.ONE); |
| | | charge.setCustomerId(dto.getCustomerId()); |
| | | charge.setObjId(gs.getId()); |
| | | charge.setName(customer.getName()); |
| | | charge.setMoney(dto.getMoney()); |
| | | charge.setRemark(dto.getRemark()); |
| | | charge.setBanlance(gs.getLeftMoney()); |
| | | charge.setStatus(Constants.ZERO); |
| | | charge.setStatusTime(new Date()); |
| | | charge.setStatusInfo("å
å¼ä¸"); |
| | | charge.setDeviceInfo("GS-" + gs.getPlatformGsId() + " " + customer.getName()); |
| | | return charge; |
| | | } |
| | | |
| | | private void fillRecordText(YwCustomerRechargeRecordVO vo) { |
| | | if (StringUtils.isBlank(vo.getDeviceInfo())) { |
| | | if (StringUtils.isNotBlank(vo.getAddress()) || StringUtils.isNotBlank(vo.getName())) { |
| | | vo.setDeviceInfo(StringUtils.defaultString(vo.getAddress()) + " " + StringUtils.defaultString(vo.getName())); |
| | | } |
| | | } |
| | | vo.setTypeText(Objects.equals(vo.getType(), Constants.ONE) ? "空è°" : "çµè¡¨"); |
| | | if (Objects.equals(vo.getStatus(), Constants.ZERO)) { |
| | | vo.setStatusText("å
å¼ä¸"); |
| | | } else if (Objects.equals(vo.getStatus(), Constants.ONE)) { |
| | | vo.setStatusText("å
弿å"); |
| | | } else if (Objects.equals(vo.getStatus(), Constants.TWO)) { |
| | | vo.setStatusText("å
å¼å¤±è´¥"); |
| | | } |
| | | } |
| | | |
| | | private YwElectricalCharge requireCharge(Integer id) { |
| | | YwElectricalCharge charge = ywElectricalChargeMapper.selectById(id); |
| | | if (charge == null || Objects.equals(charge.getIsdeleted(), Constants.ONE) || charge.getCustomerId() == null) { |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | return charge; |
| | | } |
| | | |
| | | private void refreshGsLeftMoney(YwCustomerGs gs) { |
| | | if (gs.getPlatformGsId() == null) { |
| | | return; |
| | | } |
| | | CompanyGsManageRequest req = new CompanyGsManageRequest(); |
| | | req.fillSessionDefaults(); |
| | | req.setId(gs.getPlatformGsId()); |
| | | ConditionerBaseResponse<List<CompanyGsInfoResponse>> resp = ConditionerUtil.getGs(req); |
| | | if (resp == null || !resp.isSuccess() || CollectionUtils.isEmpty(resp.getData())) { |
| | | return; |
| | | } |
| | | CompanyGsInfoResponse info = resp.getData().stream() |
| | | .filter(i -> Objects.equals(i.getId(), gs.getPlatformGsId())) |
| | | .findFirst().orElse(resp.getData().get(0)); |
| | | gs.setLeftMoney(toBigDecimal(info.getLeft_money())); |
| | | gs.setSyncDate(new Date()); |
| | | } |
| | | |
| | | private Integer parseAddGsId(Object data) { |
| | | if (data == null) { |
| | | return null; |
| | | } |
| | | if (data instanceof Number) { |
| | | return ((Number) data).intValue(); |
| | | } |
| | | JSONObject obj = (JSONObject) JSON.toJSON(data); |
| | | if (obj.containsKey("id")) { |
| | | return obj.getInteger("id"); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private BigDecimal toBigDecimal(Object val) { |
| | | if (val == null) { |
| | | return null; |
| | | } |
| | | if (val instanceof BigDecimal) { |
| | | return (BigDecimal) val; |
| | | } |
| | | if (val instanceof Number) { |
| | | return BigDecimal.valueOf(((Number) val).doubleValue()); |
| | | } |
| | | try { |
| | | return new BigDecimal(String.valueOf(val)); |
| | | } catch (NumberFormatException e) { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | private String apiMsg(ConditionerBaseResponse<?> resp, String def) { |
| | | return resp != null && StringUtils.isNotBlank(resp.getMessage()) ? resp.getMessage() : def; |
| | | } |
| | | |
| | | private YwCustomer requireCustomer(Integer customerId) { |
| | | YwCustomer c = ywCustomerMapper.selectById(customerId); |
| | | if (c == null || Objects.equals(c.getIsdeleted(), Constants.ONE)) { |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | return c; |
| | | } |
| | | |
| | | private YwCustomerGs requireGsConfig(Integer customerId) { |
| | | YwCustomerGs gs = getCustomerGsConfig(customerId); |
| | | if (gs == null || gs.getPlatformGsId() == null) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "请å
é
置并ä¿å空è°å
³è"); |
| | | } |
| | | return gs; |
| | | } |
| | | |
| | | private void assertElectricalBound(Integer customerId, Integer electricalId) { |
| | | Long cnt = ywCustomerElectricalMapper.selectCount(new QueryWrapper<YwCustomerElectrical>().lambda() |
| | | .eq(YwCustomerElectrical::getCustomerId, customerId) |
| | | .eq(YwCustomerElectrical::getElectricalId, electricalId) |
| | | .eq(YwCustomerElectrical::getIsdeleted, Constants.ZERO)); |
| | | if (cnt == null || cnt == 0) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "çµè¡¨æªå
³èè¯¥åæ·"); |
| | | } |
| | | } |
| | | |
| | | private List<Integer> listBoundElectricalIds(Integer customerId) { |
| | | return ywCustomerElectricalMapper.selectList(new QueryWrapper<YwCustomerElectrical>().lambda() |
| | | .eq(YwCustomerElectrical::getCustomerId, customerId) |
| | | .eq(YwCustomerElectrical::getIsdeleted, Constants.ZERO)) |
| | | .stream().map(YwCustomerElectrical::getElectricalId).collect(Collectors.toList()); |
| | | } |
| | | |
| | | private Set<Integer> listAllBoundElectricalIds() { |
| | | return ywCustomerElectricalMapper.selectList(new QueryWrapper<YwCustomerElectrical>().lambda() |
| | | .eq(YwCustomerElectrical::getIsdeleted, Constants.ZERO)) |
| | | .stream().map(YwCustomerElectrical::getElectricalId).collect(Collectors.toSet()); |
| | | } |
| | | |
| | | private Set<Integer> listAllBoundElectricalIdsExcept(Integer customerId) { |
| | | return ywCustomerElectricalMapper.selectList(new QueryWrapper<YwCustomerElectrical>().lambda() |
| | | .eq(YwCustomerElectrical::getIsdeleted, Constants.ZERO) |
| | | .ne(YwCustomerElectrical::getCustomerId, customerId)) |
| | | .stream().map(YwCustomerElectrical::getElectricalId).collect(Collectors.toSet()); |
| | | } |
| | | |
| | | private List<YwElectrical> loadCustomerElectricalList(Integer customerId) { |
| | | List<Integer> ids = listBoundElectricalIds(customerId); |
| | | if (ids.isEmpty()) { |
| | | return Collections.emptyList(); |
| | | } |
| | | List<YwElectrical> list = ywElectricalMapper.selectBatchIds(ids); |
| | | list = list.stream().filter(e -> !Objects.equals(e.getIsdeleted(), Constants.ONE)).collect(Collectors.toList()); |
| | | ywElectricalBizService.enrichList(list); |
| | | return list; |
| | | } |
| | | |
| | | private List<YwConditioner> loadCustomerConditionerList(Integer customerId) { |
| | | List<YwCustomerConditioner> rels = ywCustomerConditionerMapper.selectList(new QueryWrapper<YwCustomerConditioner>().lambda() |
| | | .eq(YwCustomerConditioner::getCustomerId, customerId) |
| | | .eq(YwCustomerConditioner::getIsdeleted, Constants.ZERO)); |
| | | if (rels.isEmpty()) { |
| | | return Collections.emptyList(); |
| | | } |
| | | Map<Integer, Integer> ratioMap = rels.stream() |
| | | .collect(Collectors.toMap(YwCustomerConditioner::getConditionerId, YwCustomerConditioner::getDevRatio, (a, b) -> a)); |
| | | List<YwConditioner> list = ywConditionerMapper.selectBatchIds(ratioMap.keySet()); |
| | | list = list.stream().filter(c -> !Objects.equals(c.getIsdeleted(), Constants.ONE)).collect(Collectors.toList()); |
| | | for (YwConditioner c : list) { |
| | | c.setDevRatio(ratioMap.get(c.getId())); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | private PageData<YwElectrical> pageElectricalByIds(PageWrap<YwElectrical> pageWrap, List<Integer> ids) { |
| | | IPage<YwElectrical> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); |
| | | YwElectrical model = pageWrap.getModel(); |
| | | QueryWrapper<YwElectrical> qw = new QueryWrapper<>(); |
| | | qw.lambda() |
| | | .in(YwElectrical::getId, ids) |
| | | .eq(YwElectrical::getIsdeleted, Constants.ZERO) |
| | | .and(model != null && StringUtils.isNotBlank(model.getName()), w -> w |
| | | .like(YwElectrical::getName, model.getName()) |
| | | .or().like(YwElectrical::getAddress, model.getName())) |
| | | .orderByDesc(YwElectrical::getCreateDate); |
| | | IPage<YwElectrical> result = ywElectricalMapper.selectPage(page, qw); |
| | | ywElectricalBizService.enrichList(result.getRecords()); |
| | | return PageData.from(result); |
| | | } |
| | | |
| | | private <T> PageData<T> emptyPage(PageWrap<?> pageWrap) { |
| | | PageData<T> data = new PageData<>(); |
| | | data.setRecords(Collections.emptyList()); |
| | | data.setTotal(0); |
| | | data.setPage(pageWrap.getPage()); |
| | | data.setCapacity(pageWrap.getCapacity()); |
| | | return data; |
| | | } |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.Constants; |
| | |
| | | import com.doumee.dao.business.model.YwElectrical; |
| | | import com.doumee.dao.business.model.YwElectricalActions; |
| | | import com.doumee.service.business.YwElectricalActionsService; |
| | | import com.doumee.service.business.YwElectricalBizService; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * çµè¡¨è¿ç¨æä½è®°å½ Service å®ç° |
| | |
| | | |
| | | @Autowired |
| | | private YwElectricalActionsMapper ywElectricalActionsMapper; |
| | | @Autowired |
| | | private YwElectricalBizService ywElectricalBizService; |
| | | |
| | | @Override |
| | | public PageData<YwElectricalActions> findPage(PageWrap<YwElectricalActions> pageWrap) { |
| | |
| | | IPage<YwElectricalActions> result = ywElectricalActionsMapper.selectJoinPage(page, YwElectricalActions.class, queryWrapper); |
| | | return PageData.from(result); |
| | | } |
| | | |
| | | @Override |
| | | public String queryAsyncResult(Integer id) { |
| | | if (id == null) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | YwElectricalActions act = ywElectricalActionsMapper.selectById(id); |
| | | if (act == null || Objects.equals(act.getIsdeleted(), Constants.ONE)) { |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "æä½è®°å½ä¸åå¨"); |
| | | } |
| | | if (!Objects.equals(act.getStatus(), Constants.ZERO)) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "ä»
å¤çä¸è®°å½å¯æ¥è¯¢"); |
| | | } |
| | | if (StringUtils.isBlank(act.getOprId())) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "缺å°ä»»å¡ ID"); |
| | | } |
| | | return ywElectricalBizService.syncAsyncActionStatus(act.getOprId().trim()); |
| | | } |
| | | } |
| | |
| | | import com.doumee.core.device.model.request.*; |
| | | import com.doumee.core.device.model.response.ElectronicBaseResponse; |
| | | import com.doumee.core.device.model.response.ElectronicDataResponse; |
| | | import com.doumee.core.device.model.response.MeterDealResponse; |
| | | import com.doumee.core.device.model.response.QueryDataInfoResponse; |
| | | import com.doumee.core.device.model.response.QueryDataV2Response; |
| | | import com.doumee.core.exception.BusinessException; |
| | |
| | | public static final int ACTION_OPEN = 6; |
| | | public static final int ACTION_RECHARGE = 7; |
| | | public static final int ACTION_READ = 8; |
| | | |
| | | private static final long FIRST_STATUS_QUERY_DELAY_MS = 30_000L; |
| | | private static final long STATUS_QUERY_MIN_INTERVAL_MS = 3_600_000L; |
| | | private static final int STATUS_QUERY_BATCH_SIZE = 50; |
| | | private static final int STATUS_QUERY_MAX_PENDING = 100; |
| | | |
| | | /** ele_read æçµè¡¨æ°æ®æä½ç±»åï¼ä¸ queryData functionids=253 ä¸åï¼ */ |
| | | private static final int ELE_READ_TYPE_METER = 3; |
| | |
| | | } |
| | | |
| | | private String doSecurityReset(YwElectrical e, String paymentMode, int actionType, LoginUserInfo user) { |
| | | assertNoPendingAsyncAction(e.getId(), actionType); |
| | | String oprId = newOprId(); |
| | | SecurityResetRequest req = new SecurityResetRequest(); |
| | | req.setOpr_id(oprId); |
| | |
| | | } |
| | | |
| | | private String doEleControl(YwElectrical e, int type, int actionType, LoginUserInfo user) { |
| | | assertNoPendingAsyncAction(e.getId(), actionType); |
| | | String oprId = newOprId(); |
| | | EleControlApiRequest req = new EleControlApiRequest(); |
| | | req.setOpr_id(oprId); |
| | |
| | | } |
| | | |
| | | private String doOpenAccount(YwElectrical e, YwElectricalOperateDTO dto, LoginUserInfo user) { |
| | | assertNoPendingAsyncAction(e.getId(), ACTION_OPEN); |
| | | String oprId = newOprId(); |
| | | OpenAccountRequest req = buildOpenAccountRequest(e, oprId, dto.getMoney(), dto.getRemark()); |
| | | String reqJson = JSON.toJSONString(Collections.singletonList(req)); |
| | |
| | | if (!Objects.equals(e.getAccountStatus(), Constants.ONE)) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "çµè¡¨æªå¼æ·ï¼è¯·å
弿·"); |
| | | } |
| | | assertNoPendingAsyncAction(e.getId(), ACTION_RECHARGE); |
| | | String oprId = newOprId(); |
| | | OpenAccountRequest req = buildOpenAccountRequest(e, oprId, dto.getMoney(), dto.getRemark()); |
| | | String reqJson = JSON.toJSONString(Collections.singletonList(req)); |
| | |
| | | } |
| | | |
| | | private String doReadMeter(YwElectrical e, LoginUserInfo user) { |
| | | assertNoPendingAsyncAction(e.getId(), ACTION_READ); |
| | | String oprId = newOprId(); |
| | | EleReadRequest req = new EleReadRequest(); |
| | | req.setOpr_id(oprId); |
| | |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), msg); |
| | | } |
| | | boolean synced = syncMeterDataForElectrical(e); |
| | | refreshBalanceFromData(e); |
| | | refreshBalanceFromData(e, null, true); |
| | | return synced ? "æè¡¨æåï¼ç¨éä½é¢å·²æ´æ°" : "æè¡¨è¯·æ±å·²æäº¤ï¼ææ æ°æè¡¨æ°æ®ï¼è¯·ç¨åå·æ°æ¥ç"; |
| | | } |
| | | |
| | |
| | | } |
| | | ywElectricalActionsMapper.insert(act); |
| | | return isSuccess(resp) ? "æäº¤æåï¼è¯·ç¨å卿ä½è®°å½æå
å¼è®°å½ä¸æ¥çç»æ" : act.getResultMsg(); |
| | | } |
| | | |
| | | /** åä¸çµè¡¨ãç¸åæä½ç±»ååå¨å¤çä¸è®°å½æ¶ï¼ç¦æ¢éå¤æäº¤å¼æ¥ä»»å¡ */ |
| | | private void assertNoPendingAsyncAction(Integer electricalId, int actionType) { |
| | | if (electricalId == null) { |
| | | return; |
| | | } |
| | | Long pending = ywElectricalActionsMapper.selectCount(new QueryWrapper<YwElectricalActions>().lambda() |
| | | .eq(YwElectricalActions::getElectricalId, electricalId) |
| | | .eq(YwElectricalActions::getActionType, actionType) |
| | | .eq(YwElectricalActions::getStatus, Constants.ZERO) |
| | | .eq(YwElectricalActions::getIsdeleted, Constants.ZERO)); |
| | | if (pending != null && pending > 0) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "éè¦çå¾
ä¸ä¸æ¬¡æä½ç»ææ§è¡ç»æ"); |
| | | } |
| | | } |
| | | |
| | | private void saveLog(YwElectrical e, String apiName, String reqJson, ElectronicBaseResponse resp, LoginUserInfo user) { |
| | |
| | | } |
| | | |
| | | private void applyNotifyItem(JSONObject item) { |
| | | if (item == null) return; |
| | | String oprId = item.getString("opr_id"); |
| | | if (StringUtils.isBlank(oprId)) return; |
| | | YwElectricalActions act = ywElectricalActionsMapper.selectOne(new QueryWrapper<YwElectricalActions>().lambda() |
| | | .eq(YwElectricalActions::getOprId, oprId) |
| | | .eq(YwElectricalActions::getIsdeleted, Constants.ZERO) |
| | | .orderByDesc(YwElectricalActions::getCreateDate) |
| | | .last("limit 1")); |
| | | if (act == null) { |
| | | log.info("electricalNotify no action for opr_id={}", oprId); |
| | | if (item == null) { |
| | | return; |
| | | } |
| | | ElectronicNotifyStatus ns = ElectronicNotifyStatus.fromCode(item.getString("status")); |
| | | String oprId = item.getString("opr_id"); |
| | | String status = item.getString("status"); |
| | | String errMsg = item.get("error_msg") != null ? String.valueOf(item.get("error_msg")) : null; |
| | | applyActionStatusItem(oprId, status, errMsg, item.toJSONString(), true); |
| | | } |
| | | |
| | | private void applyActionStatusItem(String oprId, String platformStatus, String errMsg, String responseBody, |
| | | boolean fromNotify) { |
| | | if (StringUtils.isBlank(oprId)) { |
| | | return; |
| | | } |
| | | YwElectricalActions act = findActionByOprId(oprId); |
| | | if (act == null) { |
| | | log.info("electrical action not found for opr_id={}", oprId); |
| | | return; |
| | | } |
| | | ElectronicNotifyStatus ns = ElectronicNotifyStatus.fromCode(platformStatus); |
| | | String resultMsg = ns.getLabel() + (StringUtils.isNotBlank(errMsg) ? "ï¼" + errMsg : ""); |
| | | |
| | | YwElectricalActions upd = new YwElectricalActions(); |
| | | upd.setId(act.getId()); |
| | | upd.setEditDate(new Date()); |
| | | upd.setResponseBody(item.toJSONString()); |
| | | upd.setResponseBody(responseBody); |
| | | upd.setResultMsg(resultMsg); |
| | | if (ns.isTerminalSuccess()) { |
| | | upd.setStatus(Constants.ONE); |
| | |
| | | ywElectricalActionsMapper.updateById(upd); |
| | | |
| | | YwElectrical e = ywElectricalMapper.selectById(act.getElectricalId()); |
| | | if (e == null) return; |
| | | saveNotifyLog(e, item, ns); |
| | | if (e == null) { |
| | | return; |
| | | } |
| | | if (fromNotify) { |
| | | saveNotifyLog(e, JSON.parseObject(responseBody), ns); |
| | | } |
| | | if (ns.isTerminalSuccess()) { |
| | | applyNotifySideEffect(e, act.getActionType()); |
| | | if (Objects.equals(act.getActionType(), ACTION_RECHARGE)) { |
| | |
| | | } else if (ns.isTerminalFail() && Objects.equals(act.getActionType(), ACTION_RECHARGE)) { |
| | | updateChargeByNotify(oprId, Constants.TWO, resultMsg); |
| | | } |
| | | } |
| | | |
| | | private YwElectricalActions findActionByOprId(String oprId) { |
| | | return ywElectricalActionsMapper.selectOne(new QueryWrapper<YwElectricalActions>().lambda() |
| | | .eq(YwElectricalActions::getOprId, oprId) |
| | | .eq(YwElectricalActions::getIsdeleted, Constants.ZERO) |
| | | .orderByDesc(YwElectricalActions::getCreateDate) |
| | | .last("limit 1")); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public String syncAsyncActionStatus(String oprId) { |
| | | if (StringUtils.isBlank(oprId)) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "缺å°ä»»å¡ ID"); |
| | | } |
| | | String trimmed = oprId.trim(); |
| | | if (findActionByOprId(trimmed) == null) { |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "æªæ¾å°å¯¹åºæä½è®°å½"); |
| | | } |
| | | ElectronicBaseResponse resp = ElectronicToolUtil.requestStatus(trimmed); |
| | | return handleStatusQueryResponse(resp, trimmed); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public String syncChargeStatusById(Integer chargeId) { |
| | | if (chargeId == null) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | YwElectricalCharge charge = ywElectricalChargeMapper.selectById(chargeId); |
| | | if (charge == null || !Objects.equals(charge.getIsdeleted(), Constants.ZERO)) { |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "å
å¼è®°å½ä¸åå¨"); |
| | | } |
| | | if (!Objects.equals(charge.getStatus(), Constants.ZERO)) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "ä»
å
å¼ä¸è®°å½å¯åæ¥"); |
| | | } |
| | | if (!Objects.equals(charge.getType(), Constants.ZERO)) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "ä»
çµè¡¨å
å¼è®°å½å¯åæ¥"); |
| | | } |
| | | return syncAsyncActionStatus(charge.getOprId()); |
| | | } |
| | | |
| | | @Override |
| | | public void syncPendingAsyncActionsScheduled() { |
| | | try { |
| | | Date minCreateTime = new Date(System.currentTimeMillis() - FIRST_STATUS_QUERY_DELAY_MS); |
| | | List<YwElectricalActions> pending = ywElectricalActionsMapper.selectList( |
| | | new QueryWrapper<YwElectricalActions>().lambda() |
| | | .eq(YwElectricalActions::getStatus, Constants.ZERO) |
| | | .eq(YwElectricalActions::getIsdeleted, Constants.ZERO) |
| | | .isNotNull(YwElectricalActions::getOprId) |
| | | .le(YwElectricalActions::getCreateDate, minCreateTime) |
| | | .orderByAsc(YwElectricalActions::getCreateDate) |
| | | .last("limit " + STATUS_QUERY_MAX_PENDING)); |
| | | if (CollectionUtils.isEmpty(pending)) { |
| | | return; |
| | | } |
| | | long nowMs = System.currentTimeMillis(); |
| | | List<String> oprIds = pending.stream() |
| | | .filter(act -> shouldPollAction(act, nowMs)) |
| | | .map(YwElectricalActions::getOprId) |
| | | .filter(StringUtils::isNotBlank) |
| | | .distinct() |
| | | .collect(Collectors.toList()); |
| | | if (oprIds.isEmpty()) { |
| | | return; |
| | | } |
| | | int updated = 0; |
| | | for (int i = 0; i < oprIds.size(); i += STATUS_QUERY_BATCH_SIZE) { |
| | | List<String> batch = oprIds.subList(i, Math.min(i + STATUS_QUERY_BATCH_SIZE, oprIds.size())); |
| | | ElectronicBaseResponse resp = ElectronicToolUtil.requestStatusByOprIds(batch); |
| | | updated += applyStatusQueryBatch(resp); |
| | | } |
| | | log.info("syncPendingAsyncActionsScheduled queried={}, updated={}", oprIds.size(), updated); |
| | | } catch (Exception e) { |
| | | log.warn("syncPendingAsyncActionsScheduled failed", e); |
| | | } |
| | | } |
| | | |
| | | private int applyStatusQueryBatch(ElectronicBaseResponse resp) { |
| | | if (resp == null || !"SUCCESS".equalsIgnoreCase(resp.getStatus())) { |
| | | return 0; |
| | | } |
| | | List<MeterDealResponse> items = extractMeterDealList(resp); |
| | | if (CollectionUtils.isEmpty(items)) { |
| | | return 0; |
| | | } |
| | | int updated = 0; |
| | | for (MeterDealResponse item : items) { |
| | | if (item == null || StringUtils.isBlank(item.getOpr_id())) { |
| | | continue; |
| | | } |
| | | YwElectricalActions before = findActionByOprId(item.getOpr_id()); |
| | | if (before == null || !Objects.equals(before.getStatus(), Constants.ZERO)) { |
| | | continue; |
| | | } |
| | | applyActionStatusItem(item.getOpr_id(), item.getStatus(), item.getError_msg(), |
| | | JSON.toJSONString(item), false); |
| | | YwElectricalActions after = findActionByOprId(item.getOpr_id()); |
| | | if (after != null && !Objects.equals(before.getStatus(), after.getStatus())) { |
| | | updated++; |
| | | } |
| | | } |
| | | return updated; |
| | | } |
| | | |
| | | private String handleStatusQueryResponse(ElectronicBaseResponse resp, String oprId) { |
| | | if (resp == null) { |
| | | return "平尿 ååºï¼è¯·ç¨åéè¯"; |
| | | } |
| | | if (!"SUCCESS".equalsIgnoreCase(resp.getStatus())) { |
| | | return "æ¥è¯¢å¤±è´¥ï¼" + StringUtils.defaultIfBlank(resp.getError_msg(), resp.getStatus()); |
| | | } |
| | | List<MeterDealResponse> items = extractMeterDealList(resp); |
| | | MeterDealResponse item = items.stream() |
| | | .filter(i -> i != null && oprId.equals(i.getOpr_id())) |
| | | .findFirst() |
| | | .orElse(CollectionUtils.isEmpty(items) ? null : items.get(0)); |
| | | if (item == null) { |
| | | return "æªæ¥è¯¢å°ä»»å¡ç»æï¼è¯·ç¨åéè¯"; |
| | | } |
| | | applyActionStatusItem(oprId, item.getStatus(), item.getError_msg(), JSON.toJSONString(item), false); |
| | | |
| | | YwElectricalActions act = findActionByOprId(oprId); |
| | | if (act == null) { |
| | | return "æªæ¾å°å¯¹åºæä½è®°å½"; |
| | | } |
| | | if (Objects.equals(act.getStatus(), Constants.ONE)) { |
| | | return Objects.equals(act.getActionType(), ACTION_RECHARGE) ? "å·²åæ¥ä¸ºå
弿å" : "æä½å·²æå"; |
| | | } |
| | | if (Objects.equals(act.getStatus(), Constants.TWO)) { |
| | | return Objects.equals(act.getActionType(), ACTION_RECHARGE) |
| | | ? "å·²åæ¥ä¸ºå
å¼å¤±è´¥ï¼" + StringUtils.defaultString(act.getResultMsg()) |
| | | : "æä½å·²å¤±è´¥ï¼" + StringUtils.defaultString(act.getResultMsg()); |
| | | } |
| | | if (ElectronicToolUtil.isAsyncStatusFinal(item.getStatus())) { |
| | | return "å¹³å°ç¶æï¼" + item.getStatus(); |
| | | } |
| | | return "ä»»å¡å¤çä¸ï¼è¯·ç¨åéè¯"; |
| | | } |
| | | |
| | | @SuppressWarnings("unchecked") |
| | | private List<MeterDealResponse> extractMeterDealList(ElectronicBaseResponse resp) { |
| | | Object content = resp.getResponse_content(); |
| | | if (content == null) { |
| | | return Collections.emptyList(); |
| | | } |
| | | if (content instanceof List) { |
| | | List<?> list = (List<?>) content; |
| | | List<MeterDealResponse> result = new ArrayList<>(); |
| | | for (Object o : list) { |
| | | if (o instanceof MeterDealResponse) { |
| | | result.add((MeterDealResponse) o); |
| | | } else { |
| | | result.add(JSON.parseObject(JSON.toJSONString(o), MeterDealResponse.class)); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | return JSON.parseArray(JSON.toJSONString(content), MeterDealResponse.class); |
| | | } |
| | | |
| | | private boolean shouldPollAction(YwElectricalActions act, long nowMs) { |
| | | Date create = act.getCreateDate(); |
| | | if (create == null || StringUtils.isBlank(act.getOprId())) { |
| | | return false; |
| | | } |
| | | long createMs = create.getTime(); |
| | | if (nowMs - createMs < FIRST_STATUS_QUERY_DELAY_MS) { |
| | | return false; |
| | | } |
| | | long editMs = act.getEditDate() != null ? act.getEditDate().getTime() : createMs; |
| | | if (editMs - createMs < 5_000L) { |
| | | return true; |
| | | } |
| | | return nowMs - editMs >= STATUS_QUERY_MIN_INTERVAL_MS; |
| | | } |
| | | |
| | | private void saveChargeRecord(YwElectrical e, String oprId, YwElectricalOperateDTO dto, LoginUserInfo user) { |
| | |
| | | charge.setStatusInfo("å
å¼ä¸"); |
| | | charge.setBanlance(e.getBalance()); |
| | | charge.setRoomNames(e.getRoomNames()); |
| | | if (dto.getCustomerId() != null) { |
| | | charge.setCustomerId(dto.getCustomerId()); |
| | | } |
| | | if (StringUtils.isNotBlank(e.getAddress()) || StringUtils.isNotBlank(e.getName())) { |
| | | charge.setDeviceInfo(StringUtils.defaultString(e.getAddress()) + " " + StringUtils.defaultString(e.getName())); |
| | | } |
| | | if (StringUtils.isNotBlank(e.getParamId())) { |
| | | try { |
| | | charge.setParamId(Integer.parseInt(e.getParamId())); |
| | |
| | | } |
| | | |
| | | private void updateChargeByNotify(String oprId, int status, String statusInfo) { |
| | | ywElectricalChargeMapper.update(null, new UpdateWrapper<YwElectricalCharge>().lambda() |
| | | YwElectricalCharge charge = ywElectricalChargeMapper.selectOne(new QueryWrapper<YwElectricalCharge>().lambda() |
| | | .eq(YwElectricalCharge::getOprId, oprId) |
| | | .eq(YwElectricalCharge::getIsdeleted, Constants.ZERO) |
| | | .last("limit 1")); |
| | | BigDecimal balanceAfter = null; |
| | | if (charge != null && status == Constants.ONE) { |
| | | balanceAfter = calcBalanceAfterRecharge(charge); |
| | | if (charge.getObjId() != null) { |
| | | updateElectricalBalance(charge.getObjId(), balanceAfter); |
| | | } |
| | | } |
| | | UpdateWrapper<YwElectricalCharge> uw = new UpdateWrapper<>(); |
| | | uw.lambda() |
| | | .set(YwElectricalCharge::getStatus, status) |
| | | .set(YwElectricalCharge::getStatusTime, new Date()) |
| | | .set(YwElectricalCharge::getStatusInfo, statusInfo) |
| | | .set(YwElectricalCharge::getEditDate, new Date()) |
| | | .eq(YwElectricalCharge::getOprId, oprId) |
| | | .eq(YwElectricalCharge::getIsdeleted, Constants.ZERO)); |
| | | .eq(YwElectricalCharge::getIsdeleted, Constants.ZERO); |
| | | if (balanceAfter != null) { |
| | | uw.lambda().set(YwElectricalCharge::getBalanceAfter, balanceAfter); |
| | | } |
| | | ywElectricalChargeMapper.update(null, uw); |
| | | } |
| | | |
| | | private void saveNotifyLog(YwElectrical e, JSONObject item, ElectronicNotifyStatus ns) { |
| | |
| | | ywElectricalMapper.update(null, uw); |
| | | break; |
| | | case ACTION_RECHARGE: |
| | | // å
弿ååä½é¢ç± updateChargeByNotify æãå
å¼å+å
å¼éé¢ã累计ï¼å¾
宿¶æè¡¨ååååæè¡¨ä½é¢ |
| | | break; |
| | | case ACTION_READ: |
| | | syncMeterDataForElectrical(e); |
| | | refreshBalanceFromData(e); |
| | | refreshBalanceFromData(e, null, true); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | |
| | | /** å
å¼å累计ä½é¢ = å
å¼åä½é¢ + å
å¼éé¢ */ |
| | | private BigDecimal calcBalanceAfterRecharge(YwElectricalCharge charge) { |
| | | BigDecimal before = charge.getBanlance() != null ? charge.getBanlance() : BigDecimal.ZERO; |
| | | BigDecimal money = charge.getMoney() != null ? charge.getMoney() : BigDecimal.ZERO; |
| | | return before.add(money); |
| | | } |
| | | |
| | | private void updateElectricalBalance(Integer electricalId, BigDecimal balance) { |
| | | if (electricalId == null || balance == null) { |
| | | return; |
| | | } |
| | | UpdateWrapper<YwElectrical> uw = new UpdateWrapper<>(); |
| | | uw.lambda() |
| | | .eq(YwElectrical::getId, electricalId) |
| | | .set(YwElectrical::getBalance, balance) |
| | | .set(YwElectrical::getBalanceTime, new Date()) |
| | | .set(YwElectrical::getEditDate, new Date()); |
| | | ywElectricalMapper.update(null, uw); |
| | | } |
| | | |
| | | private YwElectricalCharge findLastSuccessfulRecharge(Integer electricalId) { |
| | | if (electricalId == null) { |
| | | return null; |
| | | } |
| | | return ywElectricalChargeMapper.selectOne(new QueryWrapper<YwElectricalCharge>().lambda() |
| | | .eq(YwElectricalCharge::getObjId, electricalId) |
| | | .eq(YwElectricalCharge::getType, Constants.ZERO) |
| | | .eq(YwElectricalCharge::getStatus, Constants.ONE) |
| | | .eq(YwElectricalCharge::getIsdeleted, Constants.ZERO) |
| | | .orderByDesc(YwElectricalCharge::getStatusTime) |
| | | .orderByDesc(YwElectricalCharge::getId) |
| | | .last("limit 1")); |
| | | } |
| | | |
| | | private Date parseDataTime(YwElectricalData data) { |
| | | if (data == null) { |
| | | return null; |
| | | } |
| | | if (StringUtils.isNotBlank(data.getAddTime())) { |
| | | try { |
| | | return new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(data.getAddTime().trim()); |
| | | } catch (Exception ignored) { |
| | | } |
| | | } |
| | | return data.getCreateDate(); |
| | | } |
| | | |
| | | /** |
| | | * æè¿ä¸æ¬¡å
弿ååï¼è¥æè¡¨æ¶é´ä»æ©äºå
弿忶é´ï¼åæä¸ä»¥æè¡¨ä½é¢è¦ç累计ä½é¢ã |
| | | */ |
| | | private boolean shouldUseMeterBalance(Integer electricalId, YwElectricalData data) { |
| | | YwElectricalCharge lastRecharge = findLastSuccessfulRecharge(electricalId); |
| | | if (lastRecharge == null || lastRecharge.getStatusTime() == null) { |
| | | return true; |
| | | } |
| | | Date dataTime = parseDataTime(data); |
| | | if (dataTime == null) { |
| | | return true; |
| | | } |
| | | return !dataTime.before(lastRecharge.getStatusTime()); |
| | | } |
| | | |
| | | private void refreshBalanceFromData(YwElectrical e) { |
| | | YwElectricalData data = findLatestData(e.getId(), e.getAddress()); |
| | | if (data == null) return; |
| | | refreshBalanceFromData(e, null, false); |
| | | } |
| | | |
| | | private void refreshBalanceFromData(YwElectrical e, YwElectricalData data, boolean forceFromMeter) { |
| | | if (e == null) { |
| | | return; |
| | | } |
| | | if (data == null) { |
| | | data = findLatestData(e.getId(), e.getAddress()); |
| | | } |
| | | if (data == null) { |
| | | return; |
| | | } |
| | | UpdateWrapper<YwElectrical> uw = new UpdateWrapper<>(); |
| | | uw.lambda().eq(YwElectrical::getId, e.getId()); |
| | | if (StringUtils.isNotBlank(data.getZhygzdl())) { |
| | | uw.lambda().set(YwElectrical::getBalanceBattery, data.getZhygzdl()); |
| | | } |
| | | if (StringUtils.isNotBlank(data.getYe())) { |
| | | boolean useMeterBalance = forceFromMeter || shouldUseMeterBalance(e.getId(), data); |
| | | if (useMeterBalance && StringUtils.isNotBlank(data.getYe())) { |
| | | try { |
| | | uw.lambda().set(YwElectrical::getBalance, new BigDecimal(data.getYe())); |
| | | } catch (Exception ignored) { |
| | | } |
| | | } |
| | | uw.lambda().set(YwElectrical::getBalanceTime, new Date()); |
| | | if (isPurchaseCountPositive(data.getCountnum())) { |
| | | uw.lambda().set(YwElectrical::getAccountStatus, Constants.ONE); |
| | | } |
| | | if (useMeterBalance) { |
| | | Date dataTime = parseDataTime(data); |
| | | uw.lambda().set(YwElectrical::getBalanceTime, dataTime != null ? dataTime : new Date()); |
| | | } |
| | | uw.lambda().set(YwElectrical::getEditDate, new Date()); |
| | | ywElectricalMapper.update(null, uw); |
| | | } |
| | | |
| | | /** è´ä¹°æ¬¡æ°å¤§äº 0 è§ä¸ºå·²å¼æ· */ |
| | | private static boolean isPurchaseCountPositive(String purchaseCount) { |
| | | if (StringUtils.isBlank(purchaseCount)) { |
| | | return false; |
| | | } |
| | | try { |
| | | return new BigDecimal(purchaseCount.trim()).compareTo(BigDecimal.ZERO) > 0; |
| | | } catch (NumberFormatException e) { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | private YwElectricalData findLatestData(Integer electricalId, String address) { |
| | | QueryWrapper<YwElectricalData> q = new QueryWrapper<>(); |
| | | q.lambda().eq(YwElectricalData::getIsdeleted, Constants.ZERO) |
| | |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import com.doumee.core.model.LoginUserInfo; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.Date; |
| | |
| | | model.setName(door.getDescription()); |
| | | model.setCId(door.getCid()); |
| | | model.setDId(door.getId()); |
| | | model.setAccountStatus(Constants.TWO); |
| | | model.setPriceid(door.getPriceid()); |
| | | model.setParamId(door.getParam_id()); |
| | | model.setDeviceType(door.getDevice_type()); |
| | |
| | | model.setType(door.getType()); |
| | | model.setRelayStatus(door.getRelay_state()); |
| | | model.setCsq(door.getCsq()); |
| | | model.setAccountStatus(resolveAccountStatusByPurchaseCount(door.getCount())); |
| | | model.setRemark(JSONObject.toJSONString(device)); |
| | | return model; |
| | | } |
| | | |
| | | /** è´ä¹°æ¬¡æ°å¤§äº 0 è§ä¸ºå·²å¼æ· */ |
| | | private Integer resolveAccountStatusByPurchaseCount(String purchaseCount) { |
| | | if (StringUtils.isBlank(purchaseCount)) { |
| | | return Constants.ZERO; |
| | | } |
| | | try { |
| | | return new BigDecimal(purchaseCount.trim()).compareTo(BigDecimal.ZERO) > 0 |
| | | ? Constants.ONE : Constants.ZERO; |
| | | } catch (NumberFormatException e) { |
| | | return Constants.ZERO; |
| | | } |
| | | } |
| | | private MeterInfoResponse getDeviceByid(String indexCode, List<MeterInfoResponse> allHkList ) { |
| | | if(allHkList!=null && allHkList.size()>0){ |
| | | for(MeterInfoResponse info : allHkList){ |