8个文件已删除
8 文件已重命名
49个文件已添加
56个文件已修改
| | |
| | | <scope>runtime</scope> |
| | | <optional>true</optional> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-configuration-processor</artifactId> |
| | | <optional>true</optional> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.projectlombok</groupId> |
| File was renamed from component/component-Influxdb/src/main/java/com/zy/influxdb/config/InfluxDBAutoConfiguration.java |
| | |
| | | package com.zy.influxdb.config; |
| | | package com.zy.component.influxdb.config; |
| | | |
| | | import com.influxdb.v3.client.InfluxDBClient; |
| | | import com.zy.component.influxdb.properties.InfluxDBProperties; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
| File was renamed from component/component-Influxdb/src/main/java/com/zy/influxdb/config/InfluxDBProperties.java |
| | |
| | | package com.zy.influxdb.config; |
| | | package com.zy.component.influxdb.properties; |
| | | |
| | | import lombok.Data; |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| File was renamed from component/component-Influxdb/src/main/java/com/zy/influxdb/service/InfluxDBService.java |
| | |
| | | package com.zy.influxdb.service; |
| | | package com.zy.component.influxdb.service; |
| | | |
| | | import com.influxdb.v3.client.InfluxDBClient; |
| | | import com.influxdb.v3.client.Point; |
| | | import com.influxdb.v3.client.write.WritePrecision; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | .setTimestamp(Instant.now().toEpochMilli(), WritePrecision.MS); |
| | | try { |
| | | influxDBClient.writePoint(point); |
| | | System.out.println("Data written to the database."); |
| | | } catch (Exception e) { |
| | | logger.error("Failed to write data to the database."); |
| | | e.printStackTrace(); |
| | |
| | | try { |
| | | // æ§è¡æ¥è¯¢ |
| | | Stream<Object[]> query = influxDBClient.query(sql); |
| | | logger.info("æ¥è¯¢æ°æ®ï¼{}", query); |
| | | // 转æ¢ä¸º Map å表ï¼ä¾¿äºåç»å¤çï¼ |
| | | List<Map<String, Object>> collect = query.map(record -> { |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| New file |
| | |
| | | { |
| | | "properties": [ |
| | | { |
| | | "name": "influxdb3.enabled", |
| | | "type": "java.lang.Boolean", |
| | | "description": "Enables influxdb functionality.", |
| | | "defaultValue": "true" |
| | | } |
| | | ] |
| | | } |
| | |
| | | com.zy.influxdb.service.InfluxDBService |
| | | |
| | | org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.zy.component.influxdb.service.InfluxDBService |
| New file |
| | |
| | | { |
| | | "properties": [ |
| | | { |
| | | "name": "influxdb3.enabled", |
| | | "type": "java.lang.Boolean", |
| | | "description": "Enables influxdb functionality.", |
| | | "defaultValue": "true" |
| | | } |
| | | ] |
| | | } |
| | |
| | | "sourceType": "com.zy.influxdb.config.InfluxDBProperties" |
| | | }, |
| | | { |
| | | "name": "influxdb3.enabled", |
| | | "type": "java.lang.Boolean", |
| | | "description": "Enables mqtt functionality.", |
| | | "defaultValue": "true" |
| | | }, |
| | | { |
| | | "name": "influxdb3.token", |
| | | "type": "java.lang.String", |
| | | "description": "token", |
| | |
| | | com.zy.influxdb.service.InfluxDBService |
| | | |
| | | org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.zy.component.influxdb.service.InfluxDBService |
| New file |
| | |
| | | artifactId=component-Influxdb |
| | | groupId=com.zy |
| | | version=1.0.0 |
| New file |
| | |
| | | com\zy\component\influxdb\service\InfluxDBService.class |
| | | com\zy\component\influxdb\config\InfluxDBAutoConfiguration.class |
| | | com\zy\component\influxdb\properties\InfluxDBProperties.class |
| New file |
| | |
| | | D:\office\code\rcs-flow\component\component-Influxdb\src\main\java\com\zy\influxdb\config\InfluxDBProperties.java |
| | | D:\office\code\rcs-flow\component\component-Influxdb\src\main\java\com\zy\influxdb\service\InfluxDBService.java |
| | | D:\office\code\rcs-flow\component\component-Influxdb\src\main\java\com\zy\influxdb\config\InfluxDBAutoConfiguration.java |
| | |
| | | |
| | | alter table man_sta |
| | | add outbound_wait int null comment 'è¿ç»åºåºçå¾
' after inbound_wait; |
| | | |
| | | |
| | | alter table man_task |
| | | add uplink_sts varchar(64) null comment 'ä¸è¡ç¶æ' after empty_mk; |
| | | |
| | | alter table man_task_log |
| | | add uplink_sts varchar(64) null comment 'ä¸è¡ç¶æ' after empty_mk; |
| | | |
| | | CREATE TABLE `man_integration_record` ( |
| | | `id` BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', |
| | | `uuid` VARCHAR(255) DEFAULT NULL COMMENT 'ç¼å·', |
| | | `namespace` VARCHAR(255) DEFAULT NULL COMMENT 'å称空é´(*)', |
| | | `url` VARCHAR(255) DEFAULT NULL COMMENT 'æ¥å£å°å', |
| | | `appkey` VARCHAR(255) DEFAULT NULL COMMENT 'å¹³å°å¯é¥', |
| | | `caller` VARCHAR(255) DEFAULT NULL COMMENT 'è°ç¨æ¹æ è¯', |
| | | `direction` int(1) NOT NULL DEFAULT 0 COMMENT 'æ¹å{1:被è°ç¨,2:è°ç¨å¤é¨}', |
| | | `timestamp` VARCHAR(64) DEFAULT NULL COMMENT 'æ¶é´æ³', |
| | | `client_ip` VARCHAR(64) DEFAULT NULL COMMENT '客æ·ç«¯IP', |
| | | `request` TEXT COMMENT '请æ±å
容', |
| | | `response` TEXT COMMENT 'ååºå
容', |
| | | `err` TEXT COMMENT 'å¼å¸¸å
容', |
| | | `result` int(1) DEFAULT NULL COMMENT 'ç»æ{1:æå,0:失败}', |
| | | `cost_ms` INT(11) DEFAULT NULL COMMENT 'èæ¶', |
| | | `status` int(1) DEFAULT 1 COMMENT 'ç¶æ{1:æ£å¸¸,0:å»ç»}', |
| | | `create_time` timestamp DEFAULT CURRENT_TIMESTAMP COMMENT 'æ·»å æ¶é´', |
| | | `update_time` timestamp DEFAULT CURRENT_TIMESTAMP COMMENT 'ä¿®æ¹æ¶é´', |
| | | `memo` VARCHAR(255) DEFAULT NULL COMMENT '夿³¨', |
| | | PRIMARY KEY (`id`) |
| | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; |
| | | |
| | | update man_loc set comp_direct =2 where comp_direct =0 |
| | | |
| | | alter table man_sta |
| | | add act_dir int(1) null comment 'è´§åæ¹å' after angle; |
| | |
| | | CREATE INDEX idx_task_seq_num ON man_task(seq_num); |
| | | CREATE INDEX idx_task_agv_id ON man_task(agv_id); |
| | | CREATE INDEX idx_task_agv_id_task_sts ON man_task(agv_id, task_sts); |
| | | CREATE INDEX idx_task_task_sts_uplink_sts ON man_task(task_sts, uplink_sts); |
| | | # man_zone |
| | | CREATE INDEX idx_zone_uuid ON man_zone(uuid); |
| | | # man_agv_detail |
| New file |
| | |
| | | package com.zy.acs.common.enums; |
| | | |
| | | import com.zy.acs.framework.exception.CoolException; |
| | | |
| | | public enum ActuatorDirectionType { |
| | | |
| | | LEFT(1), |
| | | RIGHT(2), |
| | | FORWARD(3), |
| | | ; |
| | | |
| | | public int val; |
| | | |
| | | ActuatorDirectionType(int val) { |
| | | this.val = val; |
| | | } |
| | | |
| | | public static ActuatorDirectionType fromVal(Integer val) { |
| | | if (null == val) { |
| | | throw new CoolException("actuator direction param val is null"); |
| | | } |
| | | for (ActuatorDirectionType type : ActuatorDirectionType.values()) { |
| | | if (type.val == val) { |
| | | return type; |
| | | } |
| | | } |
| | | throw new IllegalArgumentException("Invalid ActuatorDirectionType: " + val); |
| | | } |
| | | |
| | | } |
| | |
| | | if (job != null) { |
| | | Integer workNo = staProtocol.getWorkNo(); |
| | | Integer targetSta = inSta.getTargetSta(); |
| | | // staProtocol.setWorkNo(0); |
| | | // staProtocol.setStaNo(0); |
| | | // MessageQueue.offer(SlaveType.Devp, 1, new Task(2, staProtocol)); |
| | | // Thread.sleep(1500L); |
| | | staProtocol.setWorkNo(0); |
| | | staProtocol.setStaNo(0); |
| | | MessageQueue.offer(SlaveType.Devp, 1, new Task(2, staProtocol)); |
| | | Thread.sleep(1500L); |
| | | staProtocol.setWorkNo(workNo); |
| | | staProtocol.setStaNo(targetSta); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, 1, new Task(2, staProtocol)); |
| | |
| | | "react-router-dom": "^6.26.1", |
| | | "react-syntax-highlighter": "^15.5.0", |
| | | "three": "^0.155.0", |
| | | "tweedle.js": "^2.1.0" |
| | | "tweedle.js": "^2.1.0", |
| | | "xlsx": "^0.18.5" |
| | | }, |
| | | "devDependencies": { |
| | | "@types/node": "^20.10.7", |
| | |
| | | "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" |
| | | } |
| | | }, |
| | | "node_modules/adler-32": { |
| | | "version": "1.3.1", |
| | | "resolved": "https://registry.npmjs.org/adler-32/-/adler-32-1.3.1.tgz", |
| | | "integrity": "sha512-ynZ4w/nUUv5rrsR8UUGoe1VC9hZj6V5hU9Qw1HlMDJGEJw5S7TfTErWTjMys6M7vr0YWcPqs3qAr4ss0nDfP+A==", |
| | | "license": "Apache-2.0", |
| | | "engines": { |
| | | "node": ">=0.8" |
| | | } |
| | | }, |
| | | "node_modules/ajv": { |
| | | "version": "6.12.6", |
| | | "resolved": "https://registry.npmmirror.com/ajv/-/ajv-6.12.6.tgz", |
| | |
| | | } |
| | | ] |
| | | }, |
| | | "node_modules/cfb": { |
| | | "version": "1.2.2", |
| | | "resolved": "https://registry.npmjs.org/cfb/-/cfb-1.2.2.tgz", |
| | | "integrity": "sha512-KfdUZsSOw19/ObEWasvBP/Ac4reZvAGauZhs6S/gqNhXhI7cKwvlH7ulj+dOEYnca4bm4SGo8C1bTAQvnTjgQA==", |
| | | "license": "Apache-2.0", |
| | | "dependencies": { |
| | | "adler-32": "~1.3.0", |
| | | "crc-32": "~1.2.0" |
| | | }, |
| | | "engines": { |
| | | "node": ">=0.8" |
| | | } |
| | | }, |
| | | "node_modules/chalk": { |
| | | "version": "2.4.2", |
| | | "resolved": "https://registry.npmmirror.com/chalk/-/chalk-2.4.2.tgz", |
| | |
| | | "integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==", |
| | | "engines": { |
| | | "node": ">=6" |
| | | } |
| | | }, |
| | | "node_modules/codepage": { |
| | | "version": "1.15.0", |
| | | "resolved": "https://registry.npmjs.org/codepage/-/codepage-1.15.0.tgz", |
| | | "integrity": "sha512-3g6NUTPd/YtuuGrhMnOMRjFc+LJw/bnMp3+0r/Wcz3IXUuCosKRJvMphm5+Q+bvTVGcJJuRvVLuYba+WojaFaA==", |
| | | "license": "Apache-2.0", |
| | | "engines": { |
| | | "node": ">=0.8" |
| | | } |
| | | }, |
| | | "node_modules/color-convert": { |
| | |
| | | }, |
| | | "engines": { |
| | | "node": ">=10" |
| | | } |
| | | }, |
| | | "node_modules/crc-32": { |
| | | "version": "1.2.2", |
| | | "resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz", |
| | | "integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==", |
| | | "license": "Apache-2.0", |
| | | "bin": { |
| | | "crc32": "bin/crc32.njs" |
| | | }, |
| | | "engines": { |
| | | "node": ">=0.8" |
| | | } |
| | | }, |
| | | "node_modules/cross-spawn": { |
| | |
| | | "integrity": "sha512-wzsgA6WOq+09wrU1tsJ09udeR/YZRaeArL9e1wPbFg3GG2yDnC2ldKpxs4xunpFF9DgqCqOIra3bc1HWrJ37Ww==", |
| | | "engines": { |
| | | "node": ">=0.4.x" |
| | | } |
| | | }, |
| | | "node_modules/frac": { |
| | | "version": "1.1.2", |
| | | "resolved": "https://registry.npmjs.org/frac/-/frac-1.1.2.tgz", |
| | | "integrity": "sha512-w/XBfkibaTl3YDqASwfDUqkna4Z2p9cFSr1aHDt0WoMTECnRfBOv2WArlZILlqgWlmdIlALXGpM2AOhEk5W3IA==", |
| | | "license": "Apache-2.0", |
| | | "engines": { |
| | | "node": ">=0.8" |
| | | } |
| | | }, |
| | | "node_modules/fs.realpath": { |
| | |
| | | "node": ">=6" |
| | | } |
| | | }, |
| | | "node_modules/ssf": { |
| | | "version": "0.11.2", |
| | | "resolved": "https://registry.npmjs.org/ssf/-/ssf-0.11.2.tgz", |
| | | "integrity": "sha512-+idbmIXoYET47hH+d7dfm2epdOMUDjqcB4648sTZ+t2JwoyBFL/insLfB/racrDmsKB3diwsDA696pZMieAC5g==", |
| | | "license": "Apache-2.0", |
| | | "dependencies": { |
| | | "frac": "~1.1.2" |
| | | }, |
| | | "engines": { |
| | | "node": ">=0.8" |
| | | } |
| | | }, |
| | | "node_modules/strict-uri-encode": { |
| | | "version": "2.0.0", |
| | | "resolved": "https://registry.npmmirror.com/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz", |
| | |
| | | "url": "https://github.com/sponsors/ljharb" |
| | | } |
| | | }, |
| | | "node_modules/wmf": { |
| | | "version": "1.0.2", |
| | | "resolved": "https://registry.npmjs.org/wmf/-/wmf-1.0.2.tgz", |
| | | "integrity": "sha512-/p9K7bEh0Dj6WbXg4JG0xvLQmIadrner1bi45VMJTfnbVHsc7yIajZyoSoK60/dtVBs12Fm6WkUI5/3WAVsNMw==", |
| | | "license": "Apache-2.0", |
| | | "engines": { |
| | | "node": ">=0.8" |
| | | } |
| | | }, |
| | | "node_modules/word": { |
| | | "version": "0.3.0", |
| | | "resolved": "https://registry.npmjs.org/word/-/word-0.3.0.tgz", |
| | | "integrity": "sha512-OELeY0Q61OXpdUfTp+oweA/vtLVg5VDOXh+3he3PNzLGG/y0oylSOC1xRVj0+l4vQ3tj/bB1HVHv1ocXkQceFA==", |
| | | "license": "Apache-2.0", |
| | | "engines": { |
| | | "node": ">=0.8" |
| | | } |
| | | }, |
| | | "node_modules/word-wrap": { |
| | | "version": "1.2.5", |
| | | "resolved": "https://registry.npmmirror.com/word-wrap/-/word-wrap-1.2.5.tgz", |
| | |
| | | "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", |
| | | "dev": true |
| | | }, |
| | | "node_modules/xlsx": { |
| | | "version": "0.18.5", |
| | | "resolved": "https://registry.npmjs.org/xlsx/-/xlsx-0.18.5.tgz", |
| | | "integrity": "sha512-dmg3LCjBPHZnQp5/F/+nnTa+miPJxUXB6vtk42YjBBKayDNagxGEeIdWApkYPOf3Z3pm3k62Knjzp7lMeTEtFQ==", |
| | | "license": "Apache-2.0", |
| | | "dependencies": { |
| | | "adler-32": "~1.3.0", |
| | | "cfb": "~1.2.1", |
| | | "codepage": "~1.15.0", |
| | | "crc-32": "~1.2.1", |
| | | "ssf": "~0.11.2", |
| | | "wmf": "~1.0.1", |
| | | "word": "~0.3.0" |
| | | }, |
| | | "bin": { |
| | | "xlsx": "bin/xlsx.njs" |
| | | }, |
| | | "engines": { |
| | | "node": ">=0.8" |
| | | } |
| | | }, |
| | | "node_modules/xtend": { |
| | | "version": "4.0.2", |
| | | "resolved": "https://registry.npmmirror.com/xtend/-/xtend-4.0.2.tgz", |
| | |
| | | "react-router-dom": "^6.26.1", |
| | | "react-syntax-highlighter": "^15.5.0", |
| | | "three": "^0.155.0", |
| | | "tweedle.js": "^2.1.0" |
| | | "tweedle.js": "^2.1.0", |
| | | "xlsx": "^0.18.5" |
| | | }, |
| | | "devDependencies": { |
| | | "@types/node": "^20.10.7", |
| | |
| | | "vite": "^5.3.5" |
| | | }, |
| | | "name": "cool-admin-flow" |
| | | } |
| | | } |
| | |
| | | import: { |
| | | title: 'Import', |
| | | stop: 'Stop import', |
| | | msg: 'Here is a sample CSV file you can use as a template', |
| | | msg: 'Here is a sample file you can use as a template', |
| | | tips: 'The import is running, please do not close this tab.', |
| | | err: 'Failed to import this file, please make sure your provided a valid CSV file.', |
| | | err: 'Failed to import this file, please make sure your provided a valid file.', |
| | | download: 'Download Import Template', |
| | | result: 'Contacts import complete. Imported %{success} success, with %{error} errors', |
| | | }, |
| | |
| | | mission: 'Mission', |
| | | staReserve: 'Sta Reserve', |
| | | lane: 'Lane', |
| | | integrationRecord: 'Integration', |
| | | }, |
| | | table: { |
| | | field: { |
| | |
| | | staType: "station type", |
| | | code: "code", |
| | | offset: "offset", |
| | | height: "height", |
| | | depth: "depth", |
| | | height: "height(mm)", |
| | | depth: "depth(mm)", |
| | | angle: 'angle', |
| | | inboundWait: 'inbound wait(ms)', |
| | | outboundWait: 'outbound wait(ms)', |
| | | actDir: 'actuator direction', |
| | | inboundWait: 'in wait(ms)', |
| | | outboundWait: 'out wait(ms)', |
| | | autoing: "autoing", |
| | | loading: "loading", |
| | | inEnable: "in enable", |
| | |
| | | locNo: "loc No.", |
| | | name: "name", |
| | | code: "code", |
| | | compDirect: "code direct", |
| | | compDirect: "actuator direction", |
| | | locSts: "loc sts", |
| | | offset: "offset", |
| | | offset: "height", |
| | | row: "row", |
| | | bay: "bay", |
| | | lev: "lev", |
| | |
| | | destLoc: "dest loc", |
| | | destCode: "dest code", |
| | | emptyMk: "empty mk", |
| | | uplinkSts: "uplink status", |
| | | zpallet: "zpallet", |
| | | phase: "ideal path", |
| | | errDesc: "error", |
| | |
| | | entryAngle: "entry angle", |
| | | maximum: "maximum", |
| | | }, |
| | | integrationRecord: { |
| | | uuid: "uuid", |
| | | namespace: "namespace", |
| | | url: "url", |
| | | appkey: "appkey", |
| | | caller: "caller", |
| | | direction: "direction", |
| | | timestamp: "timestamp", |
| | | clientIp: "clientIp", |
| | | request: "request", |
| | | response: "response", |
| | | err: "error", |
| | | result: "result", |
| | | costMs: "costMs", |
| | | }, |
| | | |
| | | } |
| | | }, |
| | | page: { |
| | |
| | | }, |
| | | levOffset: 'lev offset', |
| | | bottomOffset: 'bottom offset', |
| | | enums: { |
| | | compDirect: { |
| | | left: 'Left', |
| | | right: 'Right', |
| | | forward: 'Forward', |
| | | }, |
| | | }, |
| | | }, |
| | | sta: { |
| | | depthHint: 'Set depth to 0 to keep the default value.', |
| | |
| | | reposition: 'clear path reposition', |
| | | } |
| | | }, |
| | | task: { |
| | | enums: { |
| | | uplinkSts: { |
| | | NONE: 'Unknown', |
| | | PENDING: 'Pending', |
| | | SENDING: 'Uploading', |
| | | SUCCESS: 'Success', |
| | | FAILED: 'Failed', |
| | | SKIPPED: 'Skipped', |
| | | }, |
| | | }, |
| | | }, |
| | | segment: { |
| | | enums: { |
| | | state: { |
| | |
| | | import: { |
| | | title: '导å
¥', |
| | | stop: '忢坼å
¥', |
| | | msg: 'è¿æ¯ä¸ä¸ªå¯ä»¥ç¨ä½æ¨¡æ¿çç¤ºä¾ CSV æä»¶', |
| | | msg: 'è¿æ¯ä¸ä¸ªå¯ä»¥ç¨ä½æ¨¡æ¿çç¤ºä¾æä»¶', |
| | | tips: 'æ£å¨å¯¼å
¥ä¸ï¼è¯·ä¸è¦å
³éæ¤çªå£', |
| | | err: 'æ æ³å¯¼å
¥æ¤æä»¶ï¼è¯·ç¡®ä¿æ¨æä¾äºææç CSV æä»¶', |
| | | err: 'æ æ³å¯¼å
¥æ¤æä»¶ï¼è¯·ç¡®ä¿æ¨æä¾äºææçæä»¶', |
| | | download: 'ä¸è½½å¯¼å
¥æ¨¡æ¿', |
| | | result: '导å
¥å®æã已导å
¥ %{success} æå, å %{error} 失败', |
| | | }, |
| | |
| | | mission: 'æ§è¡', |
| | | staReserve: 'ç«ç¹é¢çº¦', |
| | | lane: 'å··é管ç', |
| | | integrationRecord: 'éæäº¤äº', |
| | | }, |
| | | table: { |
| | | field: { |
| | |
| | | staType: "ç«ç¹ç±»å", |
| | | code: "å°é¢ç ", |
| | | offset: "åç§»é", |
| | | height: "ä½ä¸é«åº¦", |
| | | depth: "ä½ä¸æ·±åº¦", |
| | | angle: 'ä½ä¸è§åº¦', |
| | | inboundWait: 'å
¥åºçå¾
(毫ç§)', |
| | | outboundWait: 'åºåºçå¾
(毫ç§)', |
| | | height: "ä½ä¸é«åº¦(mm)", |
| | | depth: "ä½ä¸æ·±åº¦(mm)", |
| | | angle: '车ä½è§åº¦(°)', |
| | | actDir: 'è´§åæ¹å', |
| | | inboundWait: 'å
¥åºç(ms)', |
| | | outboundWait: 'åºåºç(ms)', |
| | | autoing: "èªå¨", |
| | | loading: "载货", |
| | | inEnable: "å¯å
¥", |
| | |
| | | locNo: "åºä½å·", |
| | | name: "åç§°", |
| | | code: "å°é¢ç ", |
| | | compDirect: "ç æ¹å", |
| | | compDirect: "è´§åæ¹å", |
| | | locSts: "åºä½ç¶æ", |
| | | offset: "åç§»é", |
| | | offset: "é«åº¦", |
| | | row: "æ", |
| | | bay: "å", |
| | | lev: "å±", |
| | |
| | | destLoc: "ç®æ åºä½", |
| | | destCode: "ç®æ å°é¢ç ", |
| | | emptyMk: "空æç®±", |
| | | uplinkSts: "ä¸è¡ç¶æ", |
| | | zpallet: "æç®±ç ", |
| | | phase: "çæ³è·¯å¾", |
| | | errDesc: "å¼å¸¸æè¿°", |
| | |
| | | entryAngle: "车ä½è§åº¦", |
| | | maximum: "æ¿è½½é", |
| | | }, |
| | | integrationRecord: { |
| | | uuid: "ç¼å·", |
| | | namespace: "å½å空é´", |
| | | url: "æ¥å£å°å", |
| | | appkey: "å¯é¥", |
| | | caller: "è°ç¨æ¹", |
| | | direction: "æ¹å", |
| | | timestamp: "æ¶é´æ³", |
| | | clientIp: "客æ·ç«¯IP", |
| | | request: "请æ±å
容", |
| | | response: "ååºå
容", |
| | | err: "å¼å¸¸", |
| | | result: "请æ±ç»æ", |
| | | costMs: "èæ¶(毫ç§)", |
| | | }, |
| | | |
| | | } |
| | | }, |
| | | page: { |
| | |
| | | }, |
| | | levOffset: 'æ¯å±é«åº¦', |
| | | bottomOffset: 'åºé¨åç§»é', |
| | | enums: { |
| | | compDirect: { |
| | | left: 'å·¦', |
| | | right: 'å³', |
| | | forward: 'å', |
| | | }, |
| | | }, |
| | | }, |
| | | sta: { |
| | | depthHint: '深度设置为 0 表示沿ç¨é»è®¤å¼ã', |
| | |
| | | reposition: 'æ¸
é¤è·¯å¾éæ°å®ä½', |
| | | } |
| | | }, |
| | | task: { |
| | | enums: { |
| | | uplinkSts: { |
| | | NONE: 'æªç¥', |
| | | PENDING: 'å¾
䏿¥', |
| | | SENDING: '䏿¥ä¸', |
| | | SUCCESS: 'æå', |
| | | FAILED: '失败', |
| | | SKIPPED: 'è·³è¿', |
| | | }, |
| | | }, |
| | | }, |
| | | segment: { |
| | | enums: { |
| | | state: { |
| | |
| | | import mission from "./mission"; |
| | | import staReserve from './staReserve'; |
| | | import lane from './lane'; |
| | | import integrationRecord from './integrationRecord'; |
| | | |
| | | const ResourceContent = (node) => { |
| | | switch (node.component) { |
| | |
| | | return staReserve; |
| | | case 'lane': |
| | | return lane; |
| | | case 'integrationRecord': |
| | | return integrationRecord; |
| | | default: |
| | | return { |
| | | list: ListGuesser, |
| | |
| | | import ImportButton from '../components/ImportButton' |
| | | import { useCodeImport } from './useCodeImport'; |
| | | |
| | | import * as importTemp from './importTemp.csv?raw'; |
| | | const IMPORT_TEMP_URL = `data:text/csv;name=crm_contacts_sample.csv;charset=utf-8,${encodeURIComponent(importTemp.default)}`; |
| | | // import * as importTemp from './importTemp.csv?raw'; |
| | | // const IMPORT_TEMP_URL = `data:text/csv;name=crm_contacts_sample.csv;charset=utf-8,${encodeURIComponent(importTemp.default)}`; |
| | | |
| | | const IMPORT_TEMP_URL = '/imports/code_import_template.xlsx'; |
| | | |
| | | const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({ |
| | | '& .css-1vooibu-MuiSvgIcon-root': { |
| | |
| | | <FilterButton /> |
| | | <MyCreateButton onClick={() => { setCreateDialog(true) }} /> |
| | | <SelectColumnsButton preferenceKey='code' /> |
| | | <ImportButton importTemp={IMPORT_TEMP_URL} useCodeImport={useCodeImport} onceBatch={10} /> |
| | | <ImportButton type="xlsx" importTemp={IMPORT_TEMP_URL} useImport={useCodeImport} onceBatch={10} /> |
| | | <MyExportButton /> |
| | | </TopToolbar> |
| | | )} |
| | |
| | | import { useState } from 'react'; |
| | | import { Button } from 'react-admin'; |
| | | import ImportModal from './ImportModal'; |
| | | import ImportTxtModal from './ImportTxtModal'; |
| | | import ImportXlsxModal from './ImportXlsxModal'; |
| | | |
| | | const ImportButton = (props) => { |
| | | const ImportButton = ({ |
| | | type = 'csv', // csv, txt, xlsx, |
| | | variant = 'text', |
| | | ...props |
| | | }) => { |
| | | const [modalOpen, setModalOpen] = useState(false); |
| | | |
| | | const handleOpenModal = () => { |
| | | const handleOpenModal = (e) => { |
| | | e.stopPropagation(); |
| | | setModalOpen(true); |
| | | }; |
| | | |
| | |
| | | return ( |
| | | <> |
| | | <Button |
| | | variant={variant} |
| | | startIcon={<UploadIcon />} |
| | | label="common.action.import.title" |
| | | onClick={handleOpenModal} |
| | | /> |
| | | |
| | | <ImportModal open={modalOpen} onClose={handleCloseModal} {...props} /> |
| | | {type === 'csv' && (<ImportModal open={modalOpen} onClose={handleCloseModal} {...props} />)} |
| | | {type === 'txt' && (<ImportTxtModal open={modalOpen} onClose={handleCloseModal} {...props} />)} |
| | | {type === 'xlsx' && (<ImportXlsxModal open={modalOpen} onClose={handleCloseModal} {...props} />)} |
| | | </> |
| | | ); |
| | | }; |
| New file |
| | |
| | | import { useEffect, useState } from 'react'; |
| | | import { Box, CircularProgress, Stack, Typography } from '@mui/material'; |
| | | import Alert from '@mui/material/Alert'; |
| | | import Dialog from '@mui/material/Dialog'; |
| | | import DialogActions from '@mui/material/DialogActions'; |
| | | import DialogContent from '@mui/material/DialogContent'; |
| | | import DialogTitle from '@mui/material/DialogTitle'; |
| | | import MuiLink from '@mui/material/Link'; |
| | | import { |
| | | Button, |
| | | FileField, |
| | | FileInput, |
| | | Form, |
| | | Toolbar, |
| | | useRefresh, |
| | | useTranslate |
| | | } from 'react-admin'; |
| | | import { Link } from 'react-router-dom'; |
| | | import DialogCloseButton from './DialogCloseButton'; |
| | | import { usePapaParse } from './usePapaParse'; |
| | | |
| | | const ImportTxtModal = ({ open, onClose, useImport, params, title = '', onceBatch = 10 }) => { |
| | | |
| | | const refresh = useRefresh(); |
| | | const translate = useTranslate(); |
| | | |
| | | const { processBatch } = useImport(); |
| | | const { importer, parseCsv, reset } = usePapaParse({ |
| | | batchSize: onceBatch, |
| | | processBatch, |
| | | params, |
| | | }); |
| | | |
| | | const [file, setFile] = useState(null); |
| | | |
| | | useEffect(() => { |
| | | if (importer.state === 'complete') { |
| | | refresh(); |
| | | } |
| | | }, [importer.state, refresh]); |
| | | |
| | | const handleFileChange = (file) => { |
| | | setFile(file); |
| | | }; |
| | | |
| | | const startImport = async () => { |
| | | if (!file) { |
| | | return; |
| | | } |
| | | |
| | | parseCsv(file); |
| | | }; |
| | | |
| | | const handleClose = () => { |
| | | reset(); |
| | | onClose(); |
| | | }; |
| | | |
| | | const handleReset = (e) => { |
| | | e.preventDefault(); |
| | | reset(); |
| | | }; |
| | | |
| | | return ( |
| | | <Dialog |
| | | open={open} |
| | | maxWidth="md" |
| | | fullWidth |
| | | onClick={(e) => e.stopPropagation()} |
| | | > |
| | | <DialogCloseButton onClose={handleClose} /> |
| | | <DialogTitle>{translate('common.action.import.title')} {title}</DialogTitle> |
| | | <DialogContent> |
| | | <Form> |
| | | <Stack spacing={2}> |
| | | {importer.state === 'running' && ( |
| | | <Stack gap={2}> |
| | | <Alert |
| | | severity="info" |
| | | action={ |
| | | <Box |
| | | sx={{ |
| | | display: 'flex', |
| | | height: '100%', |
| | | alignItems: 'center', |
| | | padding: '0', |
| | | }} |
| | | > |
| | | <CircularProgress size={20} /> |
| | | </Box> |
| | | } |
| | | sx={{ |
| | | alignItems: 'center', |
| | | '& .MuiAlert-action': { |
| | | padding: 0, |
| | | marginRight: 0, |
| | | }, |
| | | }} |
| | | > |
| | | {translate('common.action.import.tips')} |
| | | </Alert> |
| | | <Typography variant="body2"> |
| | | Imported{' '} |
| | | <strong> |
| | | {importer.importCount} /{' '} |
| | | {importer.rowCount} |
| | | </strong>{' '} |
| | | contacts, with{' '} |
| | | <strong>{importer.errorCount}</strong>{' '} |
| | | errors. |
| | | {importer.remainingTime !== null && ( |
| | | <> |
| | | {' '} |
| | | Estimated remaining time:{' '} |
| | | <strong> |
| | | {millisecondsToTime( |
| | | importer.remainingTime |
| | | )} |
| | | </strong> |
| | | .{' '} |
| | | <MuiLink |
| | | href="#" |
| | | onClick={handleReset} |
| | | color="error" |
| | | > |
| | | {translate('common.action.import.stop')} |
| | | </MuiLink> |
| | | </> |
| | | )} |
| | | </Typography> |
| | | </Stack> |
| | | )} |
| | | |
| | | {importer.state === 'error' && ( |
| | | <Alert severity="error"> |
| | | {translate('common.action.import.err')} |
| | | </Alert> |
| | | )} |
| | | |
| | | {importer.state === 'complete' && ( |
| | | <> |
| | | <Alert severity="success"> |
| | | {translate('common.action.import.result', { |
| | | success: importer.importCount, |
| | | error: importer.errorCount |
| | | })} |
| | | </Alert> |
| | | {importer.errorMsg && ( |
| | | <Alert severity="error"> |
| | | {importer.errorMsg} |
| | | </Alert> |
| | | )} |
| | | </> |
| | | )} |
| | | |
| | | {importer.state === 'idle' && ( |
| | | <> |
| | | |
| | | <FileInput |
| | | source="txt" |
| | | label="Txt File" |
| | | accept={{ 'text/plain': ['.txt'] }} |
| | | onChange={handleFileChange} |
| | | > |
| | | <FileField source="src" title="title" /> |
| | | </FileInput> |
| | | |
| | | </> |
| | | )} |
| | | </Stack> |
| | | </Form> |
| | | </DialogContent> |
| | | <DialogActions |
| | | sx={{ |
| | | p: 0, |
| | | justifyContent: 'flex-start', |
| | | }} |
| | | > |
| | | <Toolbar |
| | | sx={{ |
| | | width: '100%', |
| | | }} |
| | | > |
| | | {importer.state === 'idle' ? ( |
| | | <> |
| | | <Button |
| | | label="common.action.import.title" |
| | | variant="contained" |
| | | onClick={startImport} |
| | | disabled={!file} |
| | | /> |
| | | </> |
| | | ) : ( |
| | | <Button |
| | | label="ra.action.close" |
| | | onClick={handleClose} |
| | | disabled={importer.state === 'running'} |
| | | /> |
| | | )} |
| | | </Toolbar> |
| | | </DialogActions> |
| | | </Dialog> |
| | | ); |
| | | } |
| | | |
| | | function millisecondsToTime(ms) { |
| | | var seconds = Math.floor((ms / 1000) % 60); |
| | | var minutes = Math.floor((ms / (60 * 1000)) % 60); |
| | | |
| | | return `${minutes}m ${seconds}s`; |
| | | } |
| | | |
| | | export default ImportTxtModal; |
| New file |
| | |
| | | // ImportXlsxModal.jsx |
| | | import { useEffect, useState } from 'react'; |
| | | import { Box, CircularProgress, Stack, Typography } from '@mui/material'; |
| | | import Alert from '@mui/material/Alert'; |
| | | import Dialog from '@mui/material/Dialog'; |
| | | import DialogActions from '@mui/material/DialogActions'; |
| | | import DialogContent from '@mui/material/DialogContent'; |
| | | import DialogTitle from '@mui/material/DialogTitle'; |
| | | import MuiLink from '@mui/material/Link'; |
| | | import { |
| | | Button, |
| | | FileField, |
| | | FileInput, |
| | | Form, |
| | | Toolbar, |
| | | useRefresh, |
| | | useTranslate, |
| | | } from 'react-admin'; |
| | | import DialogCloseButton from './DialogCloseButton'; |
| | | import { useExcelParse } from './useExcelParse'; |
| | | |
| | | const ImportXlsxModal = ({ |
| | | open, |
| | | onClose, |
| | | importTemp, |
| | | useImport, |
| | | params, |
| | | title = '', |
| | | onceBatch = 10, |
| | | }) => { |
| | | const refresh = useRefresh(); |
| | | const t = useTranslate(); |
| | | |
| | | const { processBatch } = useImport(); |
| | | const { importer, parseExcel, reset } = useExcelParse({ |
| | | batchSize: onceBatch, |
| | | processBatch, |
| | | params, |
| | | }); |
| | | |
| | | const [file, setFile] = useState(null); |
| | | |
| | | useEffect(() => { |
| | | if (importer.state === 'complete') { |
| | | refresh(); |
| | | } |
| | | }, [importer.state, refresh]); |
| | | |
| | | const handleFileChange = (val) => { |
| | | const f = Array.isArray(val) ? val[0]?.rawFile ?? val[0] : val?.rawFile ?? val; |
| | | setFile(f || null); |
| | | }; |
| | | |
| | | const startImport = async () => { |
| | | if (!file) return; |
| | | parseExcel(file); |
| | | }; |
| | | |
| | | const handleClose = () => { |
| | | reset(); |
| | | setFile(null); |
| | | onClose(); |
| | | }; |
| | | |
| | | const handleReset = (e) => { |
| | | e.preventDefault(); |
| | | reset(); |
| | | }; |
| | | |
| | | const nameMatch = importTemp?.split('/').pop() || 'import_template.xlsx'; |
| | | |
| | | return ( |
| | | <Dialog open={open} maxWidth="md" fullWidth onClick={(e) => e.stopPropagation()}> |
| | | <DialogCloseButton onClose={handleClose} /> |
| | | <DialogTitle>{t('common.action.import.title')} {title}</DialogTitle> |
| | | <DialogContent> |
| | | <Form> |
| | | <Stack spacing={2}> |
| | | <Alert |
| | | severity="info" |
| | | action={ |
| | | importTemp ? ( |
| | | <Button |
| | | component="a" |
| | | label="common.action.import.download" |
| | | color="info" |
| | | href={importTemp} |
| | | download={nameMatch} |
| | | /> |
| | | ) : null |
| | | } |
| | | sx={{ |
| | | alignItems: 'center', |
| | | '& .MuiAlert-action': { p: 0, mr: 0 }, |
| | | }} |
| | | > |
| | | {t('common.action.import.msg', { _: 'è¿æ¯ä¸ä¸ªå¯ä»¥ç¨ä½æ¨¡æ¿çç¤ºä¾ Excel æä»¶' })} |
| | | </Alert> |
| | | |
| | | {importer.state === 'running' && ( |
| | | <Stack gap={2}> |
| | | <Alert |
| | | severity="info" |
| | | action={ |
| | | <Box sx={{ display: 'flex', alignItems: 'center', p: 0 }}> |
| | | <CircularProgress size={20} /> |
| | | </Box> |
| | | } |
| | | sx={{ alignItems: 'center', '& .MuiAlert-action': { p: 0, mr: 0 } }} |
| | | > |
| | | {t('common.action.import.tips')} |
| | | </Alert> |
| | | <Typography variant="body2"> |
| | | Imported <strong>{importer.importCount}</strong> /{' '} |
| | | <strong>{importer.rowCount}</strong> rows, with{' '} |
| | | <strong>{importer.errorCount}</strong> errors. |
| | | {importer.remainingTime !== null && ( |
| | | <> |
| | | {' '}ETA: <strong>{millisecondsToTime(importer.remainingTime)}</strong>.{' '} |
| | | <MuiLink href="#" onClick={handleReset} color="error"> |
| | | {t('common.action.import.stop')} |
| | | </MuiLink> |
| | | </> |
| | | )} |
| | | </Typography> |
| | | </Stack> |
| | | )} |
| | | |
| | | {importer.state === 'error' && ( |
| | | <Alert severity="error">{t('common.action.import.err')}</Alert> |
| | | )} |
| | | |
| | | {importer.state === 'complete' && ( |
| | | <> |
| | | <Alert severity="success"> |
| | | {t('common.action.import.result', { |
| | | success: importer.importCount, |
| | | error: importer.errorCount, |
| | | })} |
| | | </Alert> |
| | | {importer.errorMsg && <Alert severity="error">{importer.errorMsg}</Alert>} |
| | | </> |
| | | )} |
| | | |
| | | {importer.state === 'idle' && ( |
| | | <> |
| | | <FileInput |
| | | source="xlsx" |
| | | label="Excel File (.xlsx / .xls)" |
| | | accept={{ |
| | | 'application/vnd.ms-excel': ['.xls'], |
| | | 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': ['.xlsx'], |
| | | }} |
| | | onChange={handleFileChange} |
| | | > |
| | | <FileField source="src" title="title" /> |
| | | </FileInput> |
| | | </> |
| | | )} |
| | | </Stack> |
| | | </Form> |
| | | </DialogContent> |
| | | <DialogActions sx={{ p: 0, justifyContent: 'flex-start' }}> |
| | | <Toolbar sx={{ width: '100%' }}> |
| | | {importer.state === 'idle' ? ( |
| | | <Button |
| | | label="common.action.import.title" |
| | | variant="contained" |
| | | onClick={startImport} |
| | | disabled={!file} |
| | | /> |
| | | ) : ( |
| | | <Button |
| | | label="ra.action.close" |
| | | onClick={handleClose} |
| | | disabled={importer.state === 'running'} |
| | | /> |
| | | )} |
| | | </Toolbar> |
| | | </DialogActions> |
| | | </Dialog> |
| | | ); |
| | | }; |
| | | |
| | | function millisecondsToTime(ms) { |
| | | const seconds = Math.floor((ms / 1000) % 60); |
| | | const minutes = Math.floor((ms / (60 * 1000)) % 60); |
| | | return `${minutes}m ${seconds}s`; |
| | | } |
| | | |
| | | export default ImportXlsxModal; |
| New file |
| | |
| | | import * as XLSX from 'xlsx'; |
| | | import { useCallback, useMemo, useRef, useState } from 'react'; |
| | | |
| | | export function useExcelParse({ batchSize = 10, processBatch, params }) { |
| | | const importIdRef = useRef(0); |
| | | const [importer, setImporter] = useState({ state: 'idle' }); |
| | | |
| | | const reset = useCallback(() => { |
| | | setImporter({ state: 'idle' }); |
| | | importIdRef.current += 1; |
| | | }, []); |
| | | |
| | | const parseExcel = useCallback(async (file) => { |
| | | if (!file) return; |
| | | setImporter({ state: 'parsing' }); |
| | | |
| | | const importId = importIdRef.current; |
| | | |
| | | try { |
| | | const buf = await file.arrayBuffer(); |
| | | const wb = XLSX.read(buf, { type: 'array' }); |
| | | const sheet = wb.SheetNames[0]; |
| | | const rows = XLSX.utils.sheet_to_json(wb.Sheets[sheet], { defval: '' }); |
| | | |
| | | setImporter({ |
| | | state: 'running', |
| | | rowCount: rows.length, |
| | | importCount: 0, |
| | | errorCount: 0, |
| | | remainingTime: null, |
| | | }); |
| | | |
| | | let totalTime = 0; |
| | | for (let i = 0; i < rows.length; i += batchSize) { |
| | | if (importIdRef.current !== importId) return; |
| | | |
| | | const batch = rows.slice(i, i + batchSize); |
| | | try { |
| | | const start = Date.now(); |
| | | await processBatch(batch, params); |
| | | totalTime += Date.now() - start; |
| | | |
| | | const mean = totalTime / (i + batch.length); |
| | | setImporter((prev) => |
| | | prev.state === 'running' |
| | | ? { |
| | | ...prev, |
| | | importCount: prev.importCount + batch.length, |
| | | remainingTime: mean * (rows.length - (prev.importCount + batch.length)), |
| | | } |
| | | : prev |
| | | ); |
| | | } catch (err) { |
| | | setImporter((prev) => |
| | | prev.state === 'running' |
| | | ? { |
| | | ...prev, |
| | | errorCount: prev.errorCount + batch.length, |
| | | errorMsg: prev.errorMsg |
| | | ? `${prev.errorMsg}\n${err?.message || String(err)}` |
| | | : (err?.message || String(err)), |
| | | } |
| | | : prev |
| | | ); |
| | | } |
| | | } |
| | | |
| | | setImporter((prev) => |
| | | prev.state === 'running' ? { ...prev, state: 'complete', remainingTime: null } : prev |
| | | ); |
| | | } catch (error) { |
| | | setImporter({ state: 'error', error }); |
| | | } |
| | | }, [batchSize, processBatch, params]); |
| | | |
| | | return useMemo(() => ({ importer, parseExcel, reset }), [importer, parseExcel, reset]); |
| | | } |
| New file |
| | |
| | | import React, { useState, useRef, useEffect, useMemo } from "react"; |
| | | import { |
| | | CreateBase, |
| | | useTranslate, |
| | | TextInput, |
| | | NumberInput, |
| | | BooleanInput, |
| | | DateInput, |
| | | SaveButton, |
| | | SelectInput, |
| | | ReferenceInput, |
| | | ReferenceArrayInput, |
| | | AutocompleteInput, |
| | | Toolbar, |
| | | required, |
| | | useDataProvider, |
| | | useNotify, |
| | | Form, |
| | | useCreateController, |
| | | } from 'react-admin'; |
| | | import { |
| | | Dialog, |
| | | DialogActions, |
| | | DialogContent, |
| | | DialogTitle, |
| | | Stack, |
| | | Grid, |
| | | Box, |
| | | } from '@mui/material'; |
| | | import DialogCloseButton from "../components/DialogCloseButton"; |
| | | import StatusSelectInput from "../components/StatusSelectInput"; |
| | | import MemoInput from "../components/MemoInput"; |
| | | |
| | | const IntegrationRecordCreate = (props) => { |
| | | const { open, setOpen } = props; |
| | | |
| | | const translate = useTranslate(); |
| | | const notify = useNotify(); |
| | | |
| | | const handleClose = (event, reason) => { |
| | | if (reason !== "backdropClick") { |
| | | setOpen(false); |
| | | } |
| | | }; |
| | | |
| | | const handleSuccess = async (data) => { |
| | | setOpen(false); |
| | | notify('common.response.success'); |
| | | }; |
| | | |
| | | const handleError = async (error) => { |
| | | notify(error.message || 'common.response.fail', { type: 'error', messageArgs: { _: error.message } }); |
| | | }; |
| | | |
| | | return ( |
| | | <> |
| | | <CreateBase |
| | | record={{}} |
| | | transform={(data) => { |
| | | return data; |
| | | }} |
| | | mutationOptions={{ onSuccess: handleSuccess, onError: handleError }} |
| | | > |
| | | <Dialog |
| | | open={open} |
| | | onClose={handleClose} |
| | | aria-labelledby="form-dialog-title" |
| | | fullWidth |
| | | disableRestoreFocus |
| | | maxWidth="md" // 'xs' | 'sm' | 'md' | 'lg' | 'xl' |
| | | > |
| | | <Form> |
| | | <DialogTitle id="form-dialog-title" sx={{ |
| | | position: 'sticky', |
| | | top: 0, |
| | | backgroundColor: 'background.paper', |
| | | zIndex: 1000 |
| | | }} |
| | | > |
| | | {translate('create.title')} |
| | | <Box sx={{ position: 'absolute', top: 8, right: 8, zIndex: 1001 }}> |
| | | <DialogCloseButton onClose={handleClose} /> |
| | | </Box> |
| | | </DialogTitle> |
| | | <DialogContent> |
| | | <Grid container rowSpacing={2} columnSpacing={2}> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <TextInput |
| | | label="table.field.integrationRecord.uuid" |
| | | source="uuid" |
| | | parse={v => v} |
| | | autoFocus |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <TextInput |
| | | label="table.field.integrationRecord.namespace" |
| | | source="namespace" |
| | | parse={v => v} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <TextInput |
| | | label="table.field.integrationRecord.url" |
| | | source="url" |
| | | parse={v => v} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <TextInput |
| | | label="table.field.integrationRecord.appkey" |
| | | source="appkey" |
| | | parse={v => v} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <TextInput |
| | | label="table.field.integrationRecord.caller" |
| | | source="caller" |
| | | parse={v => v} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <SelectInput |
| | | label="table.field.integrationRecord.direction" |
| | | source="direction" |
| | | choices={[ |
| | | { id: 1, name: '被è°ç¨' }, |
| | | { id: 2, name: 'è°ç¨å¤é¨' }, |
| | | ]} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <TextInput |
| | | label="table.field.integrationRecord.timestamp" |
| | | source="timestamp" |
| | | parse={v => v} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <TextInput |
| | | label="table.field.integrationRecord.clientIp" |
| | | source="clientIp" |
| | | parse={v => v} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <TextInput |
| | | label="table.field.integrationRecord.request" |
| | | source="request" |
| | | parse={v => v} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <TextInput |
| | | label="table.field.integrationRecord.response" |
| | | source="response" |
| | | parse={v => v} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <TextInput |
| | | label="table.field.integrationRecord.err" |
| | | source="err" |
| | | parse={v => v} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <SelectInput |
| | | label="table.field.integrationRecord.result" |
| | | source="result" |
| | | choices={[ |
| | | { id: 1, name: 'æå' }, |
| | | { id: 0, name: '失败' }, |
| | | ]} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <NumberInput |
| | | label="table.field.integrationRecord.costMs" |
| | | source="costMs" |
| | | /> |
| | | </Grid> |
| | | |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <StatusSelectInput /> |
| | | </Grid> |
| | | <Grid item xs={12} display="flex" gap={1}> |
| | | <Stack direction="column" spacing={1} width={'100%'}> |
| | | <MemoInput /> |
| | | </Stack> |
| | | </Grid> |
| | | </Grid> |
| | | </DialogContent> |
| | | <DialogActions sx={{ position: 'sticky', bottom: 0, backgroundColor: 'background.paper', zIndex: 1000 }}> |
| | | <Toolbar sx={{ width: '100%', justifyContent: 'space-between' }} > |
| | | <SaveButton /> |
| | | </Toolbar> |
| | | </DialogActions> |
| | | </Form> |
| | | </Dialog> |
| | | </CreateBase> |
| | | </> |
| | | ) |
| | | } |
| | | |
| | | export default IntegrationRecordCreate; |
| New file |
| | |
| | | import React, { useState, useRef, useEffect, useMemo } from "react"; |
| | | import { |
| | | Edit, |
| | | SimpleForm, |
| | | FormDataConsumer, |
| | | useTranslate, |
| | | TextInput, |
| | | NumberInput, |
| | | BooleanInput, |
| | | DateInput, |
| | | SelectInput, |
| | | ReferenceInput, |
| | | ReferenceArrayInput, |
| | | AutocompleteInput, |
| | | SaveButton, |
| | | Toolbar, |
| | | Labeled, |
| | | NumberField, |
| | | required, |
| | | useRecordContext, |
| | | DeleteButton, |
| | | } from 'react-admin'; |
| | | import { useWatch, useFormContext } from "react-hook-form"; |
| | | import { Stack, Grid, Box, Typography } from '@mui/material'; |
| | | import * as Common from '@/utils/common'; |
| | | import { EDIT_MODE, REFERENCE_INPUT_PAGESIZE } from '@/config/setting'; |
| | | import EditBaseAside from "../components/EditBaseAside"; |
| | | import CustomerTopToolBar from "../components/EditTopToolBar"; |
| | | import MemoInput from "../components/MemoInput"; |
| | | import StatusSelectInput from "../components/StatusSelectInput"; |
| | | |
| | | const FormToolbar = () => { |
| | | const { getValues } = useFormContext(); |
| | | |
| | | return ( |
| | | <Toolbar sx={{ justifyContent: 'space-between' }}> |
| | | <SaveButton /> |
| | | <DeleteButton mutationMode="optimistic" /> |
| | | </Toolbar> |
| | | ) |
| | | } |
| | | |
| | | const IntegrationRecordEdit = () => { |
| | | const translate = useTranslate(); |
| | | |
| | | return ( |
| | | <Edit |
| | | redirect="list" |
| | | mutationMode={EDIT_MODE} |
| | | actions={<CustomerTopToolBar />} |
| | | aside={<EditBaseAside />} |
| | | > |
| | | <SimpleForm |
| | | shouldUnregister |
| | | warnWhenUnsavedChanges |
| | | toolbar={<FormToolbar />} |
| | | mode="onTouched" |
| | | defaultValues={{}} |
| | | // validate={(values) => { }} |
| | | > |
| | | <Grid container width={{ xs: '100%', xl: '80%' }} rowSpacing={3} columnSpacing={3}> |
| | | <Grid item xs={12} md={8}> |
| | | <Typography variant="h6" gutterBottom> |
| | | {translate('common.edit.title.main')} |
| | | </Typography> |
| | | <Stack direction='row' gap={2}> |
| | | <TextInput |
| | | label="table.field.integrationRecord.uuid" |
| | | source="uuid" |
| | | parse={v => v} |
| | | autoFocus |
| | | /> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | <TextInput |
| | | label="table.field.integrationRecord.namespace" |
| | | source="namespace" |
| | | parse={v => v} |
| | | /> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | <TextInput |
| | | label="table.field.integrationRecord.url" |
| | | source="url" |
| | | parse={v => v} |
| | | /> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | <TextInput |
| | | label="table.field.integrationRecord.appkey" |
| | | source="appkey" |
| | | parse={v => v} |
| | | /> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | <TextInput |
| | | label="table.field.integrationRecord.caller" |
| | | source="caller" |
| | | parse={v => v} |
| | | /> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | <SelectInput |
| | | label="table.field.integrationRecord.direction" |
| | | source="direction" |
| | | choices={[ |
| | | { id: 1, name: '被è°ç¨' }, |
| | | { id: 2, name: 'è°ç¨å¤é¨' }, |
| | | ]} |
| | | validate={required()} |
| | | /> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | <TextInput |
| | | label="table.field.integrationRecord.timestamp" |
| | | source="timestamp" |
| | | parse={v => v} |
| | | /> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | <TextInput |
| | | label="table.field.integrationRecord.clientIp" |
| | | source="clientIp" |
| | | parse={v => v} |
| | | /> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | <TextInput |
| | | label="table.field.integrationRecord.request" |
| | | source="request" |
| | | parse={v => v} |
| | | /> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | <TextInput |
| | | label="table.field.integrationRecord.response" |
| | | source="response" |
| | | parse={v => v} |
| | | /> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | <TextInput |
| | | label="table.field.integrationRecord.err" |
| | | source="err" |
| | | parse={v => v} |
| | | /> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | <SelectInput |
| | | label="table.field.integrationRecord.result" |
| | | source="result" |
| | | choices={[ |
| | | { id: 1, name: 'æå' }, |
| | | { id: 0, name: '失败' }, |
| | | ]} |
| | | /> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | <NumberInput |
| | | label="table.field.integrationRecord.costMs" |
| | | source="costMs" |
| | | /> |
| | | </Stack> |
| | | |
| | | </Grid> |
| | | <Grid item xs={12} md={4}> |
| | | <Typography variant="h6" gutterBottom> |
| | | {translate('common.edit.title.common')} |
| | | </Typography> |
| | | <StatusSelectInput /> |
| | | <Box mt="2em" /> |
| | | <MemoInput /> |
| | | </Grid> |
| | | </Grid> |
| | | </SimpleForm> |
| | | </Edit > |
| | | ) |
| | | } |
| | | |
| | | export default IntegrationRecordEdit; |
| New file |
| | |
| | | import React, { useState, useRef, useEffect, useMemo, useCallback } from "react"; |
| | | import { useNavigate } from 'react-router-dom'; |
| | | import { |
| | | List, |
| | | DatagridConfigurable, |
| | | SearchInput, |
| | | TopToolbar, |
| | | SelectColumnsButton, |
| | | EditButton, |
| | | FilterButton, |
| | | CreateButton, |
| | | ExportButton, |
| | | BulkDeleteButton, |
| | | WrapperField, |
| | | useRecordContext, |
| | | useTranslate, |
| | | useNotify, |
| | | useListContext, |
| | | FunctionField, |
| | | TextField, |
| | | NumberField, |
| | | DateField, |
| | | BooleanField, |
| | | ReferenceField, |
| | | TextInput, |
| | | DateTimeInput, |
| | | DateInput, |
| | | SelectInput, |
| | | NumberInput, |
| | | ReferenceInput, |
| | | ReferenceArrayInput, |
| | | AutocompleteInput, |
| | | DeleteButton, |
| | | } from 'react-admin'; |
| | | import { Box, Typography, Card, Stack } from '@mui/material'; |
| | | import { styled } from '@mui/material/styles'; |
| | | import IntegrationRecordCreate from "./IntegrationRecordCreate"; |
| | | import IntegrationRecordPanel from "./IntegrationRecordPanel"; |
| | | import EmptyDataLoader from "../components/EmptyDataLoader"; |
| | | import MyCreateButton from "../components/MyCreateButton"; |
| | | import MyExportButton from '../components/MyExportButton'; |
| | | import PageDrawer from "../components/PageDrawer"; |
| | | import MyField from "../components/MyField"; |
| | | import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting'; |
| | | import * as Common from '@/utils/common'; |
| | | |
| | | const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({ |
| | | '& .css-1vooibu-MuiSvgIcon-root': { |
| | | height: '.9em' |
| | | }, |
| | | '& .RaDatagrid-row': { |
| | | cursor: 'auto' |
| | | }, |
| | | '& .column-name': { |
| | | }, |
| | | '& .opt': { |
| | | width: 200 |
| | | }, |
| | | })); |
| | | |
| | | const filters = [ |
| | | <SearchInput source="condition" alwaysOn />, |
| | | <DateInput label='common.time.after' source="timeStart" alwaysOn />, |
| | | <DateInput label='common.time.before' source="timeEnd" alwaysOn />, |
| | | |
| | | <TextInput source="uuid" label="table.field.integrationRecord.uuid" />, |
| | | <TextInput source="namespace" label="table.field.integrationRecord.namespace" />, |
| | | <TextInput source="url" label="table.field.integrationRecord.url" />, |
| | | <TextInput source="appkey" label="table.field.integrationRecord.appkey" />, |
| | | <TextInput source="caller" label="table.field.integrationRecord.caller" />, |
| | | <SelectInput source="direction" label="table.field.integrationRecord.direction" |
| | | choices={[ |
| | | { id: 1, name: '被è°ç¨' }, |
| | | { id: 2, name: 'è°ç¨å¤é¨' }, |
| | | ]} |
| | | />, |
| | | <TextInput source="timestamp" label="table.field.integrationRecord.timestamp" />, |
| | | <TextInput source="clientIp" label="table.field.integrationRecord.clientIp" />, |
| | | <SelectInput source="result" label="table.field.integrationRecord.result" |
| | | choices={[ |
| | | { id: 1, name: 'æå' }, |
| | | { id: 0, name: '失败' }, |
| | | ]} |
| | | />, |
| | | |
| | | <TextInput label="common.field.memo" source="memo" />, |
| | | ] |
| | | |
| | | const IntegrationRecordList = () => { |
| | | const translate = useTranslate(); |
| | | |
| | | const [createDialog, setCreateDialog] = useState(false); |
| | | const [drawerVal, setDrawerVal] = useState(false); |
| | | |
| | | return ( |
| | | <Box display="flex"> |
| | | <List |
| | | sx={{ |
| | | flexGrow: 1, |
| | | transition: (theme) => |
| | | theme.transitions.create(['all'], { |
| | | duration: theme.transitions.duration.enteringScreen, |
| | | }), |
| | | marginRight: !!drawerVal ? `${PAGE_DRAWER_WIDTH}px` : 0, |
| | | }} |
| | | title={"menu.integrationRecord"} |
| | | empty={<EmptyDataLoader />} |
| | | filters={filters} |
| | | sort={{ field: "create_time", order: "desc" }} |
| | | actions={( |
| | | <TopToolbar> |
| | | <FilterButton /> |
| | | <MyCreateButton onClick={() => { setCreateDialog(true) }} /> |
| | | <SelectColumnsButton preferenceKey='integrationRecord' /> |
| | | <MyExportButton /> |
| | | </TopToolbar> |
| | | )} |
| | | perPage={DEFAULT_PAGE_SIZE} |
| | | > |
| | | <StyledDatagrid |
| | | preferenceKey='integrationRecord' |
| | | bulkActionButtons={() => <BulkDeleteButton mutationMode={OPERATE_MODE} />} |
| | | rowClick={(id, resource, record) => false} |
| | | expand={() => <IntegrationRecordPanel />} |
| | | expandSingle={true} |
| | | omit={['id', 'createTime', 'createBy', 'memo']} |
| | | > |
| | | <NumberField source="id" /> |
| | | <TextField source="uuid" label="table.field.integrationRecord.uuid" /> |
| | | <TextField source="namespace" label="table.field.integrationRecord.namespace" /> |
| | | <TextField source="url" label="table.field.integrationRecord.url" /> |
| | | <TextField source="appkey" label="table.field.integrationRecord.appkey" /> |
| | | <TextField source="caller" label="table.field.integrationRecord.caller" /> |
| | | <TextField source="direction$" label="table.field.integrationRecord.direction" sortable={false} /> |
| | | <TextField source="timestamp" label="table.field.integrationRecord.timestamp" /> |
| | | <TextField source="clientIp" label="table.field.integrationRecord.clientIp" /> |
| | | <TextField source="request" label="table.field.integrationRecord.request" /> |
| | | <TextField source="response" label="table.field.integrationRecord.response" /> |
| | | <TextField source="err" label="table.field.integrationRecord.err" /> |
| | | <TextField source="result$" label="table.field.integrationRecord.result" sortable={false} /> |
| | | <NumberField source="costMs" label="table.field.integrationRecord.costMs" /> |
| | | |
| | | <ReferenceField source="updateBy" label="common.field.updateBy" reference="user" link={false} sortable={false}> |
| | | <TextField source="nickname" /> |
| | | </ReferenceField> |
| | | <DateField source="updateTime" label="common.field.updateTime" showTime /> |
| | | <ReferenceField source="createBy" label="common.field.createBy" reference="user" link={false} sortable={false}> |
| | | <TextField source="nickname" /> |
| | | </ReferenceField> |
| | | <DateField source="createTime" label="common.field.createTime" showTime /> |
| | | <BooleanField source="statusBool" label="common.field.status" sortable={false} /> |
| | | <TextField source="memo" label="common.field.memo" sortable={false} /> |
| | | <WrapperField cellClassName="opt" label="common.field.opt"> |
| | | <EditButton sx={{ padding: '1px', fontSize: '.75rem' }} /> |
| | | <DeleteButton sx={{ padding: '1px', fontSize: '.75rem' }} mutationMode={OPERATE_MODE} /> |
| | | </WrapperField> |
| | | </StyledDatagrid> |
| | | </List> |
| | | <IntegrationRecordCreate |
| | | open={createDialog} |
| | | setOpen={setCreateDialog} |
| | | /> |
| | | <PageDrawer |
| | | title='IntegrationRecord Detail' |
| | | drawerVal={drawerVal} |
| | | setDrawerVal={setDrawerVal} |
| | | > |
| | | </PageDrawer> |
| | | </Box> |
| | | ) |
| | | } |
| | | |
| | | export default IntegrationRecordList; |
| New file |
| | |
| | | import React, { useState, useRef, useEffect, useMemo } from "react"; |
| | | import { Box, Card, CardContent, Grid, Typography, Tooltip } from '@mui/material'; |
| | | import { |
| | | useTranslate, |
| | | useRecordContext, |
| | | } from 'react-admin'; |
| | | import PanelTypography from "../components/PanelTypography"; |
| | | import * as Common from '@/utils/common' |
| | | |
| | | const IntegrationRecordPanel = () => { |
| | | const record = useRecordContext(); |
| | | if (!record) return null; |
| | | const translate = useTranslate(); |
| | | return ( |
| | | <> |
| | | <Card sx={{ width: { xs: 300, sm: 500, md: 600, lg: 800 }, margin: 'auto' }}> |
| | | <CardContent> |
| | | <Grid container spacing={2}> |
| | | <Grid item xs={12} sx={{ display: 'flex', justifyContent: 'space-between' }}> |
| | | <Typography variant="h6" gutterBottom align="left" sx={{ |
| | | maxWidth: { xs: '100px', sm: '180px', md: '260px', lg: '360px' }, |
| | | whiteSpace: 'nowrap', |
| | | overflow: 'hidden', |
| | | textOverflow: 'ellipsis', |
| | | }}> |
| | | {Common.camelToPascalWithSpaces(translate('table.field.integrationRecord.namespace'))}: {record.namespace} |
| | | </Typography> |
| | | {/* inherit, primary, secondary, textPrimary, textSecondary, error */} |
| | | <Typography variant="h6" gutterBottom align="right" > |
| | | ID: {record.id} |
| | | </Typography> |
| | | </Grid> |
| | | </Grid> |
| | | <Grid container spacing={2}> |
| | | <Grid item xs={12} container alignContent="flex-end"> |
| | | <Typography variant="caption" color="textSecondary" sx={{ wordWrap: 'break-word', wordBreak: 'break-all' }}> |
| | | {Common.camelToPascalWithSpaces(translate('common.field.memo'))}:{record.memo} |
| | | </Typography> |
| | | </Grid> |
| | | </Grid> |
| | | <Box height={20}> </Box> |
| | | <Grid container spacing={2}> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.integrationRecord.uuid" |
| | | property={record.uuid} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.integrationRecord.namespace" |
| | | property={record.namespace} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.integrationRecord.url" |
| | | property={record.url} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.integrationRecord.appkey" |
| | | property={record.appkey} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.integrationRecord.caller" |
| | | property={record.caller} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.integrationRecord.direction" |
| | | property={record.direction$} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.integrationRecord.timestamp" |
| | | property={record.timestamp} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.integrationRecord.clientIp" |
| | | property={record.clientIp} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.integrationRecord.request" |
| | | property={record.request} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.integrationRecord.response" |
| | | property={record.response} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.integrationRecord.err" |
| | | property={record.err} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.integrationRecord.result" |
| | | property={record.result$} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.integrationRecord.costMs" |
| | | property={record.costMs} |
| | | /> |
| | | </Grid> |
| | | |
| | | </Grid> |
| | | </CardContent> |
| | | </Card > |
| | | </> |
| | | ); |
| | | }; |
| | | |
| | | export default IntegrationRecordPanel; |
| New file |
| | |
| | | import React, { useState, useRef, useEffect, useMemo } from "react"; |
| | | import { |
| | | ListGuesser, |
| | | EditGuesser, |
| | | ShowGuesser, |
| | | } from "react-admin"; |
| | | |
| | | import IntegrationRecordList from "./IntegrationRecordList"; |
| | | import IntegrationRecordEdit from "./IntegrationRecordEdit"; |
| | | |
| | | export default { |
| | | list: IntegrationRecordList, |
| | | edit: IntegrationRecordEdit, |
| | | show: ShowGuesser, |
| | | recordRepresentation: (record) => { |
| | | return `${record.namespace}` |
| | | } |
| | | }; |
| | |
| | | import DialogCloseButton from "../components/DialogCloseButton"; |
| | | import StatusSelectInput from "../components/StatusSelectInput"; |
| | | import MemoInput from "../components/MemoInput"; |
| | | import { compDirectChoices } from "./compDirect"; |
| | | |
| | | const LocCreate = (props) => { |
| | | const { open, setOpen } = props; |
| | |
| | | <SelectInput |
| | | label="table.field.loc.compDirect" |
| | | source="compDirect" |
| | | choices={[ |
| | | { id: 1, name: '大äº' }, |
| | | { id: 0, name: 'å°äº' }, |
| | | ]} |
| | | choices={compDirectChoices} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | |
| | | import CustomerTopToolBar from "../components/EditTopToolBar"; |
| | | import MemoInput from "../components/MemoInput"; |
| | | import StatusSelectInput from "../components/StatusSelectInput"; |
| | | import { compDirectChoices } from "./compDirect"; |
| | | |
| | | const FormToolbar = () => { |
| | | const { getValues } = useFormContext(); |
| | |
| | | <SelectInput |
| | | label="table.field.loc.compDirect" |
| | | source="compDirect" |
| | | choices={[ |
| | | { id: 1, name: '大äº' }, |
| | | { id: 0, name: 'å°äº' }, |
| | | ]} |
| | | choices={compDirectChoices} |
| | | /> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | |
| | | import DialogCloseButton from "../components/DialogCloseButton"; |
| | | import CheckIcon from '@mui/icons-material/Check'; |
| | | import request from '@/utils/request' |
| | | import { compDirectChoices } from "./compDirect"; |
| | | |
| | | const LocInit = (props) => { |
| | | const { open, setOpen } = props; |
| | |
| | | <SelectInput |
| | | label="table.field.loc.compDirect" |
| | | source="compDirect" |
| | | choices={[ |
| | | { id: 1, name: '大äº' }, |
| | | { id: 0, name: 'å°äº' }, |
| | | ]} |
| | | choices={compDirectChoices} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | |
| | | ) |
| | | } |
| | | |
| | | export default LocInit; |
| | | export default LocInit; |
| | |
| | | DeleteButton, |
| | | Button, |
| | | Pagination, |
| | | FunctionField, |
| | | } from 'react-admin'; |
| | | import { Box, Typography, Card, Stack } from '@mui/material'; |
| | | import { styled } from '@mui/material/styles'; |
| | |
| | | import rowSx from "./rowSx"; |
| | | import BulkUpdateButton from "../components/BulkUpdateButton"; |
| | | import LocBulkUpdateContent from './LocBulkUpdateContent'; |
| | | import { getCompDirectLabel } from './compDirect'; |
| | | |
| | | const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({ |
| | | '& .css-1vooibu-MuiSvgIcon-root': { |
| | |
| | | })); |
| | | |
| | | const filters = [ |
| | | <SearchInput source="condition" alwaysOn />, |
| | | <TextInput source="locNo" label="table.field.loc.locNo" alwaysOn />, |
| | | <ReferenceInput source="locSts" label="table.field.loc.locSts" reference="locSts" alwaysOn> |
| | | <AutocompleteInput label="table.field.loc.locSts" optionText="name" filterToQuery={(val) => ({ name: val })} /> |
| | |
| | | <NumberInput source="row" label="table.field.loc.row" alwaysOn />, |
| | | <NumberInput source="bay" label="table.field.loc.bay" alwaysOn />, |
| | | <NumberInput source="lev" label="table.field.loc.lev" alwaysOn />, |
| | | <SearchInput source="condition" alwaysOn />, |
| | | <ReferenceInput source="code" label="table.field.loc.code" reference="code" alwaysOn> |
| | | <ReferenceInput source="code" label="table.field.loc.code" reference="code"> |
| | | <AutocompleteInput label="table.field.loc.code" optionText="data" filterToQuery={(val) => ({ data: val })} /> |
| | | </ReferenceInput>, |
| | | <DateInput label='common.time.after' source="timeStart" />, |
| | |
| | | rowClick={(id, resource, record) => false} |
| | | expand={() => <LocPanel />} |
| | | expandSingle={true} |
| | | omit={['id', 'locType', 'uuid', 'statusBool', 'updateBy', 'createTime', 'createBy', 'memo']} |
| | | omit={['id', 'locType', 'uuid', 'zpallet', 'barcode' |
| | | , 'statusBool', 'updateBy', 'createTime', 'createBy', 'memo']} |
| | | rowSx={rowSx(drawerVal || null)} |
| | | > |
| | | <NumberField source="id" /> |
| | |
| | | <ReferenceField source="code" label="table.field.loc.code" reference="code" link={false} sortable={false}> |
| | | <TextField source="data" /> |
| | | </ReferenceField> |
| | | {/* <TextField source="compDirect$" label="table.field.loc.compDirect" sortable={false} /> */} |
| | | <ReferenceField source="locSts" label="table.field.loc.locSts" reference="locSts" link={false} sortable={true}> |
| | | <TextField source="name" /> |
| | | </ReferenceField> |
| | |
| | | <NumberField source="bay" label="table.field.loc.bay" /> |
| | | <NumberField source="lev" label="table.field.loc.lev" /> |
| | | <NumberField source="offset" label="table.field.loc.offset" /> |
| | | <FunctionField |
| | | label="table.field.loc.compDirect" |
| | | sortable={false} |
| | | render={(record) => getCompDirectLabel(translate, record?.compDirect)} |
| | | /> |
| | | <TextField source="barcode" label="table.field.loc.barcode" /> |
| | | <TextField source="zpallet" label="table.field.loc.zpallet" /> |
| | | <ReferenceField source="locType" label="table.field.loc.locType" reference="locType" link={false} sortable={false}> |
| | |
| | | } from 'react-admin'; |
| | | import PanelTypography from "../components/PanelTypography"; |
| | | import * as Common from '@/utils/common' |
| | | import { getCompDirectLabel } from "./compDirect"; |
| | | |
| | | const LocPanel = () => { |
| | | const record = useRecordContext(); |
| | |
| | | <Grid item xs={6}> |
| | | <PanelTypography |
| | | title="table.field.loc.compDirect" |
| | | property={record.compDirect$} |
| | | property={getCompDirectLabel(translate, record.compDirect)} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6}> |
| New file |
| | |
| | | export const compDirectChoices = [ |
| | | { id: 1, name: 'page.loc.enums.compDirect.left' }, |
| | | { id: 2, name: 'page.loc.enums.compDirect.right' }, |
| | | { id: 3, name: 'page.loc.enums.compDirect.forward' }, |
| | | ]; |
| | | |
| | | export const getCompDirectLabel = (translate, compDirect, fallback = '-') => { |
| | | const choice = compDirectChoices.find((item) => item.id === compDirect); |
| | | if (!choice) { |
| | | return fallback; |
| | | } |
| | | return typeof translate === 'function' |
| | | ? translate(choice.name, { _: fallback }) |
| | | : choice.name; |
| | | }; |
| | |
| | | import DialogCloseButton from "../components/DialogCloseButton"; |
| | | import StatusSelectInput from "../components/StatusSelectInput"; |
| | | import MemoInput from "../components/MemoInput"; |
| | | import { compDirectChoices } from "../loc/compDirect"; |
| | | |
| | | const StaCreate = (props) => { |
| | | const { open, setOpen } = props; |
| | |
| | | /> |
| | | </ReferenceInput> |
| | | </Grid> |
| | | <Grid item xs={4} display="flex" gap={1}> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <NumberInput |
| | | label="table.field.sta.capacity" |
| | | source="capacity" |
| | |
| | | validate={required()} |
| | | /> |
| | | </Grid> */} |
| | | <Grid item xs={4} display="flex" gap={1}> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <NumberInput |
| | | label="table.field.sta.height" |
| | | source="height" |
| | |
| | | validate={[required(), greaterThanZero]} |
| | | /> |
| | | </Grid> */} |
| | | <Grid item xs={4} display="flex" gap={1}> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <NumberInput |
| | | label="table.field.sta.angle" |
| | | source="angle" |
| | |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <SelectInput |
| | | label="table.field.sta.actDir" |
| | | source="actDir" |
| | | choices={compDirectChoices} |
| | | translateChoice |
| | | validate={[required(), greaterThanZero]} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <NumberInput |
| | | label="table.field.sta.inboundWait" |
| | | source="inboundWait" |
| | |
| | | import CustomerTopToolBar from "../components/EditTopToolBar"; |
| | | import MemoInput from "../components/MemoInput"; |
| | | import StatusSelectInput from "../components/StatusSelectInput"; |
| | | import { compDirectChoices } from "../loc/compDirect"; |
| | | |
| | | const FormToolbar = () => { |
| | | const { getValues } = useFormContext(); |
| | |
| | | validate={[required(), greaterThanZero]} |
| | | /> |
| | | <NumberInput |
| | | label="table.field.sta.height" |
| | | source="height" |
| | | validate={[required(), greaterThanZero]} |
| | | /> |
| | | {/* <NumberInput |
| | | label="table.field.sta.depth" |
| | | source="depth" |
| | | helperText={translate('page.sta.depthHint')} |
| | | validate={[required(), greaterThanZero]} |
| | | /> */} |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | <NumberInput |
| | | label="table.field.sta.angle" |
| | | source="angle" |
| | | validate={[required(), greaterThanZero]} |
| | | /> |
| | | <SelectInput |
| | | label="table.field.sta.actDir" |
| | | source="actDir" |
| | | choices={compDirectChoices} |
| | | translateChoice |
| | | validate={[required(), greaterThanZero]} |
| | | /> |
| | | {/* <NumberInput |
| | | label="table.field.sta.offset" |
| | | source="offset" |
| | | validate={required()} |
| | | /> */} |
| | | <NumberInput |
| | | label="table.field.sta.height" |
| | | source="height" |
| | | validate={[required(), greaterThanZero]} |
| | | /> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | {/* <NumberInput |
| | | label="table.field.sta.depth" |
| | | source="depth" |
| | | helperText={translate('page.sta.depthHint')} |
| | | validate={[required(), greaterThanZero]} |
| | | /> */} |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | |
| | | ReferenceArrayInput, |
| | | AutocompleteInput, |
| | | DeleteButton, |
| | | FunctionField, |
| | | } from 'react-admin'; |
| | | import { Box, Typography, Card, Stack } from '@mui/material'; |
| | | import { styled } from '@mui/material/styles'; |
| | |
| | | import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting'; |
| | | import * as Common from '@/utils/common'; |
| | | import rowSx from "./rowSx"; |
| | | import { getCompDirectLabel } from "../loc/compDirect"; |
| | | |
| | | const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({ |
| | | '& .css-1vooibu-MuiSvgIcon-root': { |
| | |
| | | expand={() => <StaPanel />} |
| | | expandSingle={true} |
| | | rowSx={rowSx(drawerVal || null)} |
| | | omit={['id', 'uuid', 'name', 'offset', 'zpallet', 'depth' |
| | | omit={['id', 'uuid', 'name', 'offset', 'zpallet', 'depth', 'capacity' |
| | | , 'updateTime', 'updateBy', 'createTime', 'createBy', 'memo']} |
| | | > |
| | | <NumberField source="id" /> |
| | |
| | | <NumberField source="rsvInCnt" label="table.field.sta.rsvInCnt" /> |
| | | <NumberField source="rsvOutCnt" label="table.field.sta.rsvOutCnt" /> |
| | | <NumberField source="offset" label="table.field.sta.offset" /> |
| | | <NumberField source="height" label="table.field.sta.height" /> |
| | | <NumberField source="height" label="table.field.sta.height" sortable={false} /> |
| | | <NumberField source="depth" label="table.field.sta.depth" /> |
| | | <NumberField source="angle" label="table.field.sta.angle" /> |
| | | <NumberField source="inboundWait" label="table.field.sta.inboundWait" /> |
| | | <NumberField source="outboundWait" label="table.field.sta.outboundWait" /> |
| | | <NumberField source="angle" label="table.field.sta.angle" sortable={false} /> |
| | | <FunctionField |
| | | label="table.field.sta.actDir" |
| | | render={(record) => getCompDirectLabel(translate, record?.actDir)} |
| | | sortable={false} |
| | | /> |
| | | <NumberField source="inboundWait" label="table.field.sta.inboundWait" sortable={false} /> |
| | | <NumberField source="outboundWait" label="table.field.sta.outboundWait" sortable={false} /> |
| | | {/* <TextField source="autoing" label="table.field.sta.autoing" /> |
| | | <TextField source="loading" label="table.field.sta.loading" /> |
| | | <TextField source="inEnable" label="table.field.sta.inEnable" /> |
| | |
| | | } from 'react-admin'; |
| | | import { format } from 'date-fns'; |
| | | import * as Common from '@/utils/common' |
| | | import { getCompDirectLabel } from "../loc/compDirect"; |
| | | |
| | | const STATUS_FIELDS = [ |
| | | { key: 'autoing', labelKey: 'table.field.sta.autoing' }, |
| | |
| | | { labelKey: 'table.field.sta.zoneId', valueKey: 'zoneId$' }, |
| | | { labelKey: 'table.field.sta.staType', valueKey: 'staType$' }, |
| | | { labelKey: 'table.field.sta.code', valueKey: 'code$' }, |
| | | { labelKey: 'table.field.sta.capacity', valueKey: 'capacity' }, |
| | | // { labelKey: 'table.field.sta.capacity', valueKey: 'capacity' }, |
| | | { labelKey: 'table.field.sta.rsvInCnt', valueKey: 'rsvInCnt' }, |
| | | { labelKey: 'table.field.sta.rsvOutCnt', valueKey: 'rsvOutCnt' }, |
| | | { labelKey: 'table.field.sta.angle', valueKey: 'angle' }, |
| | | { |
| | | labelKey: 'table.field.sta.actDir', |
| | | getValue: (record, translate) => getCompDirectLabel(translate, record?.actDir), |
| | | }, |
| | | // { labelKey: 'table.field.sta.offset', valueKey: 'offset' }, |
| | | { labelKey: 'table.field.sta.height', valueKey: 'height' }, |
| | | { labelKey: 'table.field.sta.depth', valueKey: 'depth' }, |
| | |
| | | <Box height={12}> </Box> |
| | | |
| | | <Grid container spacing={2}> |
| | | {INFO_FIELDS.map(({ labelKey, valueKey }) => ( |
| | | {INFO_FIELDS.map(({ labelKey, valueKey, getValue }) => ( |
| | | <Grid item xs={12} sm={6} md={4} key={labelKey}> |
| | | <InfoItem |
| | | labelKey={labelKey} |
| | | value={getRecordValue(record, valueKey)} |
| | | value={getValue ? getValue(record, translate) : getRecordValue(record, valueKey)} |
| | | /> |
| | | </Grid> |
| | | ))} |
| | |
| | | import { styled } from '@mui/material/styles'; |
| | | import StaReserveCreate from "./StaReserveCreate"; |
| | | import StaReservePanel from "./StaReservePanel"; |
| | | import EmptyData from "../components/EmptyData"; |
| | | import EmptyDataLoader from "../components/EmptyDataLoader"; |
| | | import MyCreateButton from "../components/MyCreateButton"; |
| | | import MyExportButton from '../components/MyExportButton'; |
| | | import PageDrawer from "../components/PageDrawer"; |
| | |
| | | marginRight: !!drawerVal ? `${PAGE_DRAWER_WIDTH}px` : 0, |
| | | }} |
| | | title={"menu.staReserve"} |
| | | empty={<EmptyData onClick={() => { setCreateDialog(true) }} />} |
| | | empty={<EmptyDataLoader />} |
| | | filters={filters} |
| | | sort={{ field: "create_time", order: "desc" }} |
| | | actions={( |
| | |
| | | useNotify, |
| | | useRefresh, |
| | | } from 'react-admin'; |
| | | import { Box, Chip, Card, Stack } from '@mui/material'; |
| | | import { Box, Chip, Card, Stack, LinearProgress } from '@mui/material'; |
| | | import { styled } from '@mui/material/styles'; |
| | | import TaskCreate from "./TaskCreate"; |
| | | import TaskPanel from "./TaskPanel"; |
| | |
| | | width: 200 |
| | | }, |
| | | })); |
| | | |
| | | const UPLINK_STATUS_CHOICES = [ |
| | | { id: 'NONE', name: 'page.task.enums.uplinkSts.NONE', color: 'default' }, |
| | | { id: 'PENDING', name: 'page.task.enums.uplinkSts.PENDING', color: 'warning' }, |
| | | { id: 'SENDING', name: 'page.task.enums.uplinkSts.SENDING', color: 'info' }, |
| | | { id: 'SUCCESS', name: 'page.task.enums.uplinkSts.SUCCESS', color: 'success' }, |
| | | { id: 'FAILED', name: 'page.task.enums.uplinkSts.FAILED', color: 'error' }, |
| | | { id: 'SKIPPED', name: 'page.task.enums.uplinkSts.SKIPPED', color: 'secondary' }, |
| | | ]; |
| | | |
| | | const UPLINK_STATUS_MAP = UPLINK_STATUS_CHOICES.reduce((acc, item) => { |
| | | acc[item.id] = item; |
| | | return acc; |
| | | }, {}); |
| | | |
| | | const filters = [ |
| | | // <SearchInput source="condition" alwaysOn />, |
| | |
| | | <AutocompleteInput label="table.field.task.destCode" optionText="data" filterToQuery={(val) => ({ data: val })} /> |
| | | </ReferenceInput>, |
| | | <TextInput source="emptyMk" label="table.field.task.emptyMk" />, |
| | | <SelectInput source="uplinkSts" label="table.field.task.uplinkSts" choices={UPLINK_STATUS_CHOICES} />, |
| | | <TextInput source="zpallet" label="table.field.task.zpallet" />, |
| | | // <TextInput source="phase" label="table.field.task.phase" />, |
| | | <TextInput source="errDesc" label="table.field.task.errDesc" />, |
| | |
| | | />, |
| | | ] |
| | | |
| | | const TaskList = () => { |
| | | const TaskListContent = () => { |
| | | const translate = useTranslate(); |
| | | const notify = useNotify(); |
| | | const refresh = useRefresh(); |
| | | const [createDialog, setCreateDialog] = useState(false); |
| | | const [drawerVal, setDrawerVal] = useState(false); |
| | | |
| | | const { isLoading } = useListContext(); |
| | | |
| | | const [taskStsByComplete, setTaskStsByComplete] = useState(null); |
| | | const [taskStsByCancel, setTaskStsByCancel] = useState(null); |
| | |
| | | setTaskStsByCancel(res.data.data[0]?.id); |
| | | }) |
| | | }, []); |
| | | |
| | | |
| | | const onComplete = (taskId) => { |
| | | request.get("/task/complete/" + taskId).then(res => { |
| | |
| | | } |
| | | |
| | | return ( |
| | | <Box sx={{ position: 'relative' }}> |
| | | {isLoading && ( |
| | | <LinearProgress |
| | | sx={{ |
| | | height: "2px", |
| | | position: 'absolute', |
| | | top: 0, |
| | | left: 0, |
| | | right: 0, |
| | | }} |
| | | /> |
| | | )} |
| | | <StyledDatagrid |
| | | preferenceKey='task' |
| | | bulkActionButtons={false} |
| | | rowClick={(id, resource, record) => false} |
| | | expand={() => <TaskPanel />} |
| | | expandSingle={true} |
| | | omit={['id', 'uuid', 'startTime', 'endTime', 'errTime', 'emptyMk', 'zpallet', |
| | | 'oriSta', 'oriLoc', 'oriCode', 'destSta', 'destLoc', 'destCode', 'errDesc', |
| | | 'updateTime', 'updateBy', 'ioTime', 'createBy', 'statusBool', 'memo']} |
| | | > |
| | | <NumberField source="id" /> |
| | | <TextField source="uuid" label="table.field.task.uuid" sortable={false} /> |
| | | <TextField source="seqNum" label="table.field.task.seqNum" sortable={false} /> |
| | | <ReferenceField source="busId" label="table.field.task.busId" reference="bus" link={false} sortable={false}> |
| | | <TextField source="busNo" /> |
| | | </ReferenceField> |
| | | <ReferenceField source="agvId" label="table.field.task.agvId" reference="agv" link={false} sortable={false}> |
| | | <TextField source="uuid" /> |
| | | </ReferenceField> |
| | | {/* <TextField source="name" label="table.field.task.name" /> */} |
| | | <ReferenceField source="taskType" label="table.field.task.taskType" reference="taskType" link={false} sortable={false}> |
| | | <TextField source="name" /> |
| | | </ReferenceField> |
| | | {/* <ReferenceField source="taskSts" label="table.field.task.taskSts" reference="taskSts" link={false} sortable={false}> |
| | | <TextField source="name" /> |
| | | </ReferenceField> */} |
| | | <ReferenceField source="taskSts" label="table.field.task.taskSts" reference="taskSts" link={false} sortable={true}> |
| | | <FunctionField render={record => ( |
| | | <Chip |
| | | label={record.name} |
| | | variant="outlined" |
| | | size="small" |
| | | color={getTaskStsChipColor(record.name)} |
| | | sx={{ fontSize: '0.75rem' }} |
| | | /> |
| | | )} /> |
| | | {/* <TextField source="name" /> */} |
| | | </ReferenceField> |
| | | <DateField source="ioTime" label="table.field.task.ioTime" showTime sortable={false} /> |
| | | <DateField source="startTime" label="table.field.task.startTime" showTime sortable={false} /> |
| | | <DateField source="endTime" label="table.field.task.endTime" showTime sortable={false} /> |
| | | <DateField source="errTime" label="table.field.task.errTime" showTime sortable={false} /> |
| | | <ReferenceField source="oriSta" label="table.field.task.oriSta" reference="sta" link={false} sortable={false}> |
| | | <TextField source="staNo" /> |
| | | </ReferenceField> |
| | | <ReferenceField source="oriLoc" label="table.field.task.oriLoc" reference="loc" link={false} sortable={false}> |
| | | <TextField source="locNo" /> |
| | | </ReferenceField> |
| | | <ReferenceField source="oriCode" label="table.field.task.oriCode" reference="code" link={false} sortable={false}> |
| | | <TextField source="data" /> |
| | | </ReferenceField> |
| | | <ReferenceField source="destSta" label="table.field.task.destSta" reference="sta" link={false} sortable={false}> |
| | | <TextField source="staNo" /> |
| | | </ReferenceField> |
| | | <ReferenceField source="destLoc" label="table.field.task.destLoc" reference="loc" link={false} sortable={false}> |
| | | <TextField source="locNo" /> |
| | | </ReferenceField> |
| | | <ReferenceField source="destCode" label="table.field.task.destCode" reference="code" link={false} sortable={false}> |
| | | <TextField source="data" /> |
| | | </ReferenceField> |
| | | <TextField source="oriDesc" label="table.field.task.oriDesc" sortable={false} /> |
| | | <TextField source="destDesc" label="table.field.task.destDesc" sortable={false} /> |
| | | <NumberField source="priority" label="table.field.task.priority" sortable={false} /> |
| | | <FunctionField |
| | | label="table.field.task.uplinkSts" |
| | | sortable={false} |
| | | render={record => { |
| | | const meta = UPLINK_STATUS_MAP[record?.uplinkSts]; |
| | | return ( |
| | | <Chip |
| | | label={meta?.name ? translate(meta.name) : translate('common.enums.na')} |
| | | variant="outlined" |
| | | size="small" |
| | | color={meta?.color ?? 'default'} |
| | | sx={{ fontSize: '0.75rem' }} |
| | | /> |
| | | ); |
| | | }} |
| | | /> |
| | | <TextField source="emptyMk" label="table.field.task.emptyMk" sortable={false} /> |
| | | <TextField source="zpallet" label="table.field.task.zpallet" sortable={false} /> |
| | | <TextField source="errDesc" label="table.field.task.errDesc" sortable={false} /> |
| | | |
| | | <ReferenceField source="updateBy" label="common.field.updateBy" reference="user" link={false} sortable={false}> |
| | | <TextField source="nickname" /> |
| | | </ReferenceField> |
| | | <DateField source="updateTime" label="common.field.updateTime" showTime /> |
| | | <ReferenceField source="createBy" label="common.field.createBy" reference="user" link={false} sortable={false}> |
| | | <TextField source="nickname" /> |
| | | </ReferenceField> |
| | | <DateField source="createTime" label="common.field.createTime" showTime sortable={false} /> |
| | | <BooleanField source="statusBool" label="common.field.status" sortable={false} /> |
| | | <TextField source="memo" label="common.field.memo" sortable={false} /> |
| | | <FunctionField label="common.field.opt" cellClassName="opt" render={record => ( |
| | | (record.taskSts !== taskStsByComplete && record.taskSts !== taskStsByCancel) && ( |
| | | <> |
| | | <ConfirmButton |
| | | label="common.action.complete" |
| | | size="small" |
| | | color="primary" |
| | | startIcon={<CheckIcon />} |
| | | sx={{ |
| | | padding: '1px', |
| | | fontSize: '.75rem', |
| | | '& .MuiButton-startIcon': { |
| | | marginRight: '2px' |
| | | }, |
| | | mr: 1 |
| | | }} |
| | | data={record.seqNum} |
| | | onConfirm={() => { |
| | | onComplete(record.id); |
| | | }} |
| | | /> |
| | | <ConfirmButton |
| | | label="ra.action.cancel" |
| | | size="small" |
| | | color="error" |
| | | startIcon={<ClearIcon />} |
| | | sx={{ |
| | | padding: '1px', |
| | | fontSize: '.75rem', |
| | | '& .MuiButton-startIcon': { |
| | | marginRight: '1.5px' |
| | | }, |
| | | }} |
| | | data={record.seqNum} |
| | | onConfirm={() => { |
| | | onCancel(record.id); |
| | | }} |
| | | /> |
| | | </> |
| | | ) |
| | | )} /> |
| | | </StyledDatagrid> |
| | | </Box> |
| | | ) |
| | | } |
| | | |
| | | |
| | | const TaskList = () => { |
| | | const [createDialog, setCreateDialog] = useState(false); |
| | | const [drawerVal, setDrawerVal] = useState(false); |
| | | |
| | | return ( |
| | | <Box display="flex"> |
| | | <List |
| | | sx={{ |
| | |
| | | perPage={25} |
| | | aside={<TaskListAside />} |
| | | > |
| | | <StyledDatagrid |
| | | preferenceKey='task' |
| | | bulkActionButtons={false} |
| | | rowClick={(id, resource, record) => false} |
| | | expand={() => <TaskPanel />} |
| | | expandSingle={true} |
| | | omit={['id', 'uuid', 'startTime', 'endTime', 'errTime', 'emptyMk', 'zpallet', |
| | | 'oriSta', 'oriLoc', 'oriCode', 'destSta', 'destLoc', 'destCode', 'errDesc', |
| | | 'updateTime', 'updateBy', 'ioTime', 'createBy', 'statusBool', 'memo']} |
| | | > |
| | | <NumberField source="id" /> |
| | | <TextField source="uuid" label="table.field.task.uuid" sortable={false} /> |
| | | <TextField source="seqNum" label="table.field.task.seqNum" sortable={false} /> |
| | | <ReferenceField source="busId" label="table.field.task.busId" reference="bus" link={false} sortable={false}> |
| | | <TextField source="busNo" /> |
| | | </ReferenceField> |
| | | <ReferenceField source="agvId" label="table.field.task.agvId" reference="agv" link={false} sortable={false}> |
| | | <TextField source="uuid" /> |
| | | </ReferenceField> |
| | | {/* <TextField source="name" label="table.field.task.name" /> */} |
| | | <ReferenceField source="taskType" label="table.field.task.taskType" reference="taskType" link={false} sortable={false}> |
| | | <TextField source="name" /> |
| | | </ReferenceField> |
| | | {/* <ReferenceField source="taskSts" label="table.field.task.taskSts" reference="taskSts" link={false} sortable={false}> |
| | | <TextField source="name" /> |
| | | </ReferenceField> */} |
| | | <ReferenceField source="taskSts" label="table.field.task.taskSts" reference="taskSts" link={false} sortable={true}> |
| | | <FunctionField render={record => ( |
| | | <Chip |
| | | label={record.name} |
| | | variant="outlined" |
| | | size="small" |
| | | color={getTaskStsChipColor(record.name)} |
| | | sx={{ fontSize: '0.75rem' }} |
| | | /> |
| | | )} /> |
| | | {/* <TextField source="name" /> */} |
| | | </ReferenceField> |
| | | <DateField source="ioTime" label="table.field.task.ioTime" showTime sortable={false} /> |
| | | <DateField source="startTime" label="table.field.task.startTime" showTime sortable={false} /> |
| | | <DateField source="endTime" label="table.field.task.endTime" showTime sortable={false} /> |
| | | <DateField source="errTime" label="table.field.task.errTime" showTime sortable={false} /> |
| | | <ReferenceField source="oriSta" label="table.field.task.oriSta" reference="sta" link={false} sortable={false}> |
| | | <TextField source="staNo" /> |
| | | </ReferenceField> |
| | | <ReferenceField source="oriLoc" label="table.field.task.oriLoc" reference="loc" link={false} sortable={false}> |
| | | <TextField source="locNo" /> |
| | | </ReferenceField> |
| | | <ReferenceField source="oriCode" label="table.field.task.oriCode" reference="code" link={false} sortable={false}> |
| | | <TextField source="data" /> |
| | | </ReferenceField> |
| | | <ReferenceField source="destSta" label="table.field.task.destSta" reference="sta" link={false} sortable={false}> |
| | | <TextField source="staNo" /> |
| | | </ReferenceField> |
| | | <ReferenceField source="destLoc" label="table.field.task.destLoc" reference="loc" link={false} sortable={false}> |
| | | <TextField source="locNo" /> |
| | | </ReferenceField> |
| | | <ReferenceField source="destCode" label="table.field.task.destCode" reference="code" link={false} sortable={false}> |
| | | <TextField source="data" /> |
| | | </ReferenceField> |
| | | <TextField source="oriDesc" label="table.field.task.oriDesc" sortable={false} /> |
| | | <TextField source="destDesc" label="table.field.task.destDesc" sortable={false} /> |
| | | <NumberField source="priority" label="table.field.task.priority" sortable={false} /> |
| | | <TextField source="emptyMk" label="table.field.task.emptyMk" sortable={false} /> |
| | | <TextField source="zpallet" label="table.field.task.zpallet" sortable={false} /> |
| | | <TextField source="errDesc" label="table.field.task.errDesc" sortable={false} /> |
| | | |
| | | <ReferenceField source="updateBy" label="common.field.updateBy" reference="user" link={false} sortable={false}> |
| | | <TextField source="nickname" /> |
| | | </ReferenceField> |
| | | <DateField source="updateTime" label="common.field.updateTime" showTime /> |
| | | <ReferenceField source="createBy" label="common.field.createBy" reference="user" link={false} sortable={false}> |
| | | <TextField source="nickname" /> |
| | | </ReferenceField> |
| | | <DateField source="createTime" label="common.field.createTime" showTime sortable={false} /> |
| | | <BooleanField source="statusBool" label="common.field.status" sortable={false} /> |
| | | <TextField source="memo" label="common.field.memo" sortable={false} /> |
| | | <FunctionField label="common.field.opt" cellClassName="opt" render={record => ( |
| | | (record.taskSts !== taskStsByComplete && record.taskSts !== taskStsByCancel) && ( |
| | | <> |
| | | <ConfirmButton |
| | | label="common.action.complete" |
| | | size="small" |
| | | color="primary" |
| | | startIcon={<CheckIcon />} |
| | | sx={{ |
| | | padding: '1px', |
| | | fontSize: '.75rem', |
| | | '& .MuiButton-startIcon': { |
| | | marginRight: '2px' |
| | | }, |
| | | mr: 1 |
| | | }} |
| | | data={record.seqNum} |
| | | onConfirm={() => { |
| | | onComplete(record.id); |
| | | }} |
| | | /> |
| | | <ConfirmButton |
| | | label="ra.action.cancel" |
| | | size="small" |
| | | color="error" |
| | | startIcon={<ClearIcon />} |
| | | sx={{ |
| | | padding: '1px', |
| | | fontSize: '.75rem', |
| | | '& .MuiButton-startIcon': { |
| | | marginRight: '1.5px' |
| | | }, |
| | | }} |
| | | data={record.seqNum} |
| | | onConfirm={() => { |
| | | onCancel(record.id); |
| | | }} |
| | | /> |
| | | </> |
| | | ) |
| | | )} /> |
| | | </StyledDatagrid> |
| | | <TaskListContent drawerVal={drawerVal} /> |
| | | </List> |
| | | <TaskCreate |
| | | open={createDialog} |
| | |
| | | mt: 8, |
| | | alignSelf: 'flex-start', |
| | | border: theme[0] === 'light' && '1px solid #e0e0e3', |
| | | width: 255 |
| | | width: 210 |
| | | }} |
| | | > |
| | | <CardContent> |
| New file |
| | |
| | | package com.zy.acs.framework.annotations; |
| | | |
| | | import java.lang.annotation.ElementType; |
| | | import java.lang.annotation.Retention; |
| | | import java.lang.annotation.RetentionPolicy; |
| | | import java.lang.annotation.Target; |
| | | |
| | | @Target({ElementType.TYPE,ElementType.METHOD}) |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | public @interface IntegrationAuth { |
| | | |
| | | Auth value() default Auth.CHECK; |
| | | |
| | | String memo() default ""; |
| | | |
| | | public enum Auth{ |
| | | CHECK, |
| | | NONE |
| | | } |
| | | |
| | | } |
| | |
| | | <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> |
| | | <spring-boot.version>2.5.3</spring-boot.version> |
| | | <fastjson.version>1.2.58</fastjson.version> |
| | | <!-- Dependency Versions --> |
| | | <influxdb-java.version>1.7.0</influxdb-java.version> |
| | | </properties> |
| | | |
| | | |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>com.zy</groupId> |
| | | <artifactId>acs-common</artifactId> |
| | | <version>1.0.0</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.zy</groupId> |
| | | <artifactId>acs-common</artifactId> |
| | | <version>1.0.0</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.zy</groupId> |
| | | <artifactId>component-Influxdb</artifactId> |
| | | <version>1.0.0</version> |
| | | </dependency> |
| | | |
| | | <!-- SpringBoot Web --> |
| | | <dependency> |
| | |
| | | </dependency> |
| | | |
| | | |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-starter-web</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-starter-web</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- Lombok --> |
| | | <dependency> |
| | |
| | | |
| | | import org.springframework.boot.SpringApplication; |
| | | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| | | import org.springframework.context.annotation.ComponentScan; |
| | | |
| | | @ComponentScan(basePackages = {"com.zy.component", "com.zy.acs"}) |
| | | @SpringBootApplication |
| | | public class HexApplication { |
| | | |
| New file |
| | |
| | | package com.zy.acs.hex.config; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.amqp.rabbit.connection.CachingConnectionFactory; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | @Slf4j |
| | | @Configuration |
| | | public class RabbitConfig { |
| | | |
| | | @Bean |
| | | public RabbitTemplate rabbitTemplate(CachingConnectionFactory connectionFactory) { |
| | | RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory); |
| | | rabbitTemplate.setConfirmCallback((correlationData, ack, cause) -> { |
| | | if (ack) { |
| | | log.info("æ¶æ¯æååéå°Exchange"); |
| | | } else { |
| | | log.info("æ¶æ¯åé失败ï¼" + cause); |
| | | } |
| | | }); |
| | | // ä¹å¯ä»¥è®¾ç½®è¿åç±»å为mandatoryï¼è¿æ ·å½æ¶æ¯æ æ³è·¯ç±å°ä»»ä½éåæ¶ï¼ä¼è¿åç»ç产è
ä¸ä¸ªBasic.Returnã |
| | | rabbitTemplate.setMandatory(true); |
| | | rabbitTemplate.setReturnCallback((message, replyCode, replyText, exchange, routingKey) -> { |
| | | log.info("æ¶æ¯æ æ³è·¯ç±å°éå: " + replyText); |
| | | }); |
| | | return rabbitTemplate; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package com.zy.acs.hex.constant; |
| | | |
| | | |
| | | /** |
| | | * æ¶åºæ°æ®åºå¸¸éç±» |
| | | * |
| | | * @author ken |
| | | */ |
| | | |
| | | public class InfluxDBConstant { |
| | | |
| | | public static final String DEVICE_MEASUREMENT = "device"; |
| | | |
| | | public static final String DEVICE_MEASUREMENT_TAG_DEVICEID = "deviceId"; |
| | | |
| | | public static final String DEVICE_MEASUREMENT_TAG_EVENT = "event"; |
| | | |
| | | public static final String DEVICE_MEASUREMENT_TAG_TYPE = "type"; |
| | | |
| | | public static class DEVICE_MEASUREMENT_TAG_TYPE_FLAG { |
| | | |
| | | public static final String DEVICE_MEASUREMENT_TAG_TYPE_UP = "up"; |
| | | |
| | | public static final String DEVICE_MEASUREMENT_TAG_TYPE_DOWN = "down"; |
| | | } |
| | | |
| | | |
| | | } |
| File was renamed from zy-acs-hex/src/main/java/com/zy/acs/hex/config/RabbitMQConfig.java |
| | |
| | | package com.zy.acs.hex.config; |
| | | |
| | | |
| | | import org.springframework.amqp.core.*; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | package com.zy.acs.hex.constant; |
| | | |
| | | |
| | | /** |
| | |
| | | * |
| | | * @author ken |
| | | */ |
| | | @Configuration |
| | | public class RabbitMQConfig { |
| | | |
| | | public class RabbitConstant { |
| | | |
| | | public static final String DURABLE = "true"; |
| | | |
| | | public static final String TOPIC_EXCHANGE_TYPE = "topic"; |
| | | |
| | | // ========================== 䏻颿¨¡å¼ ========================== |
| | | /** |
| New file |
| | |
| | | package com.zy.acs.hex.consumer; |
| | | |
| | | import com.rabbitmq.client.Channel; |
| | | import com.zy.acs.hex.constant.InfluxDBConstant; |
| | | import com.zy.acs.hex.constant.RabbitConstant; |
| | | import com.zy.acs.hex.consumer.listener.AbstractListener; |
| | | import com.zy.acs.hex.domain.Device; |
| | | import com.zy.acs.hex.utils.ReflectionUtils; |
| | | import com.zy.acs.hex.utils.StrUtils; |
| | | import com.zy.component.influxdb.service.InfluxDBService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.amqp.rabbit.annotation.*; |
| | | import org.springframework.amqp.support.AmqpHeaders; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.messaging.handler.annotation.Header; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * æ¶è´¹è
|
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | @RabbitListener(bindings = @QueueBinding( |
| | | value = @Queue(name = RabbitConstant.TOPIC_QUEUE_DOWN, durable = RabbitConstant.DURABLE), |
| | | exchange = @Exchange(name = RabbitConstant.TOPIC_EXCHANGE, type = RabbitConstant.TOPIC_EXCHANGE_TYPE), |
| | | key = RabbitConstant.ROUTING_KEY_DOWN |
| | | )) |
| | | public class DownMessageListener implements AbstractListener { |
| | | |
| | | |
| | | @Autowired |
| | | private InfluxDBService influxDBService; |
| | | |
| | | |
| | | @RabbitHandler |
| | | public void handle(Device msg, @Header(AmqpHeaders.RECEIVED_ROUTING_KEY) String routingKey, Channel channel) { |
| | | log.info("routingKey:{},receive down message:{}", routingKey, msg); |
| | | influxDBService.writeData(InfluxDBConstant.DEVICE_MEASUREMENT, StrUtils.getTagsByRoutingKey(routingKey), ReflectionUtils.convertBean2Map(msg)); |
| | | } |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package com.zy.acs.hex.consumer; |
| | | |
| | | import com.rabbitmq.client.Channel; |
| | | import com.zy.acs.hex.constant.InfluxDBConstant; |
| | | import com.zy.acs.hex.constant.RabbitConstant; |
| | | import com.zy.acs.hex.consumer.listener.AbstractListener; |
| | | import com.zy.acs.hex.domain.Device; |
| | | import com.zy.acs.hex.utils.ReflectionUtils; |
| | | import com.zy.acs.hex.utils.StrUtils; |
| | | import com.zy.component.influxdb.service.InfluxDBService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.amqp.rabbit.annotation.*; |
| | | import org.springframework.amqp.support.AmqpHeaders; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.messaging.handler.annotation.Header; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * æ¶è´¹è
|
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | @RabbitListener(bindings = @QueueBinding( |
| | | value = @Queue(name = RabbitConstant.TOPIC_QUEUE_UP, durable = RabbitConstant.DURABLE), |
| | | exchange = @Exchange(name = RabbitConstant.TOPIC_EXCHANGE, type = RabbitConstant.TOPIC_EXCHANGE_TYPE), |
| | | key = RabbitConstant.ROUTING_KEY_UP |
| | | )) |
| | | public class UpMessageListener implements AbstractListener { |
| | | |
| | | |
| | | @Autowired |
| | | private InfluxDBService influxDBService; |
| | | |
| | | |
| | | @RabbitHandler |
| | | public void handle(Device msg, @Header(AmqpHeaders.RECEIVED_ROUTING_KEY) String routingKey, Channel channel) { |
| | | log.info("routingKey:{},receive up message:{}", routingKey, msg); |
| | | influxDBService.writeData(InfluxDBConstant.DEVICE_MEASUREMENT, StrUtils.getTagsByRoutingKey(routingKey), ReflectionUtils.convertBean2Map(msg)); |
| | | } |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package com.zy.acs.hex.consumer.listener; |
| | | |
| | | import com.rabbitmq.client.Channel; |
| | | import com.zy.acs.hex.domain.Device; |
| | | import org.springframework.amqp.support.AmqpHeaders; |
| | | import org.springframework.messaging.handler.annotation.Header; |
| | | |
| | | public interface AbstractListener { |
| | | void handle(Device event, @Header(AmqpHeaders.RECEIVED_ROUTING_KEY) String routingKey, Channel channel); |
| | | } |
| New file |
| | |
| | | package com.zy.acs.hex.controller; |
| | | |
| | | import com.zy.acs.hex.constant.RabbitConstant; |
| | | import com.zy.acs.hex.domain.Device; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | @RestController |
| | | @Slf4j |
| | | @RequestMapping(value = "/message") |
| | | public class TestController { |
| | | |
| | | @Autowired |
| | | private RabbitTemplate rabbitTemplate; |
| | | |
| | | /** |
| | | * åéæ¶æ¯test1 |
| | | * |
| | | * @return |
| | | */ |
| | | @GetMapping(value = "/test1") |
| | | public void sendTest1() { |
| | | Device device = new Device(); |
| | | //device.setEvent("online"); |
| | | //device.setDeviceId("123"); |
| | | device.setProtocol("212121212121212"); |
| | | String router = RabbitConstant.ROUTING_KEY_UP.replaceFirst("\\*", "123").replaceFirst("\\*", "online"); |
| | | rabbitTemplate.convertAndSend(RabbitConstant.TOPIC_EXCHANGE, router, device); |
| | | } |
| | | |
| | | /** |
| | | * åéæ¶æ¯test2 |
| | | * |
| | | * @return |
| | | */ |
| | | @GetMapping(value = "/test2") |
| | | public void sendTest2() { |
| | | rabbitTemplate.convertAndSend(RabbitConstant.TOPIC_EXCHANGE, RabbitConstant.ROUTING_KEY_DOWN, "qswaqsaasas"); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package com.zy.acs.hex.domain; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | @Data |
| | | public class Device implements Serializable { |
| | | private String protocol; |
| | | } |
| New file |
| | |
| | | package com.zy.acs.hex.utils; |
| | | |
| | | import com.zy.acs.framework.common.Cools; |
| | | |
| | | import java.beans.PropertyDescriptor; |
| | | import java.lang.reflect.Field; |
| | | import java.lang.reflect.Method; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | public class ReflectionUtils { |
| | | /** |
| | | * è·åä¸ä¸ªç±»åå
¶ç¶ç±»çææå±æ§ |
| | | * |
| | | * @param clazz |
| | | * @return |
| | | */ |
| | | public static List<Field> findAllFieldsOfSelfAndSuperClass(Class clazz) { |
| | | Field[] fields = null; |
| | | List fieldList = new ArrayList(); |
| | | while (true) { |
| | | if (clazz == null) { |
| | | break; |
| | | } else { |
| | | fields = clazz.getDeclaredFields(); |
| | | for (int i = 0; i < fields.length; i++) { |
| | | fieldList.add(fields[i]); |
| | | } |
| | | clazz = clazz.getSuperclass(); |
| | | } |
| | | } |
| | | return fieldList; |
| | | } |
| | | |
| | | /** |
| | | * æä¸ä¸ªBeanå¯¹è±¡è½¬æ¢æMap对象</br> |
| | | * |
| | | * @param obj |
| | | * @param ignores |
| | | * @return |
| | | * @throws IllegalAccessException |
| | | */ |
| | | public static Map convertBean2Map(Object obj, String[] ignores) { |
| | | Map map = new HashMap(); |
| | | Class clazz = obj.getClass(); |
| | | List<Field> fieldList = findAllFieldsOfSelfAndSuperClass(clazz); |
| | | Field field = null; |
| | | try { |
| | | for (int i = 0; i < fieldList.size(); i++) { |
| | | field = fieldList.get(i); |
| | | // å®ä¹fieldNameæ¯å¦å¨æ·è´å¿½ç¥çèç´å
|
| | | boolean flag = false; |
| | | if (ignores != null && ignores.length != 0) { |
| | | flag = isExistOfIgnores(field.getName(), ignores); |
| | | } |
| | | if (!flag) { |
| | | Object value = getProperty(obj, field.getName()); |
| | | if (null != value |
| | | && !Cools.isEmpty(value.toString())) { |
| | | map.put(field.getName(), |
| | | getProperty(obj, field.getName())); |
| | | } |
| | | } |
| | | } |
| | | } catch (SecurityException e) { |
| | | e.printStackTrace(); |
| | | } catch (IllegalArgumentException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | | * æä¸ä¸ªBeanå¯¹è±¡è½¬æ¢æMap对象</br> |
| | | * |
| | | * @param obj |
| | | * @return |
| | | */ |
| | | public static Map convertBean2Map(Object obj) { |
| | | return convertBean2Map(obj, null); |
| | | } |
| | | |
| | | public static Map convertBean2MapForIngoreserialVersionUID(Object obj) { |
| | | return convertBean2Map(obj, new String[]{"serialVersionUID"}); |
| | | } |
| | | |
| | | /** |
| | | * 夿fieldNameæ¯å¦æ¯ignores䏿é¤ç |
| | | * |
| | | * @param fieldName |
| | | * @param ignores |
| | | * @return |
| | | */ |
| | | private static boolean isExistOfIgnores(String fieldName, |
| | | String[] ignores) { |
| | | boolean flag = false; |
| | | for (String str : ignores) { |
| | | if (str.equals(fieldName)) { |
| | | flag = true; |
| | | break; |
| | | } |
| | | } |
| | | return flag; |
| | | } |
| | | |
| | | public static PropertyDescriptor getPropertyDescriptor(Class clazz, |
| | | String propertyName) { |
| | | StringBuffer sb = new StringBuffer();// æå»ºä¸ä¸ªå¯ååç¬¦ä¸²ç¨æ¥æå»ºæ¹æ³åç§° |
| | | Method setMethod = null; |
| | | Method getMethod = null; |
| | | PropertyDescriptor pd = null; |
| | | try { |
| | | Field f = clazz.getDeclaredField(propertyName);// æ ¹æ®åæ®µåæ¥è·ååæ®µ |
| | | if (f != null) { |
| | | // æå»ºæ¹æ³çåç¼ |
| | | String methodEnd = propertyName.substring(0, 1).toUpperCase() |
| | | + propertyName.substring(1); |
| | | sb.append("set" + methodEnd);// æå»ºsetæ¹æ³ |
| | | setMethod = clazz.getDeclaredMethod(sb.toString(), |
| | | new Class[]{f.getType()}); |
| | | sb.delete(0, sb.length());// æ¸
空æ´ä¸ªå¯åå符串 |
| | | sb.append("get" + methodEnd);// æå»ºgetæ¹æ³ |
| | | // æå»ºget æ¹æ³ |
| | | getMethod = |
| | | clazz.getDeclaredMethod(sb.toString(), new Class[]{}); |
| | | // æå»ºä¸ä¸ªå±æ§æè¿°å¨ æå¯¹åºå±æ§ propertyName ç get å set æ¹æ³ä¿åå°å±æ§æè¿°å¨ä¸ |
| | | pd = new PropertyDescriptor(propertyName, getMethod, setMethod); |
| | | } |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | } |
| | | |
| | | return pd; |
| | | } |
| | | |
| | | @SuppressWarnings("unchecked") |
| | | public static void setProperty(Object obj, String propertyName, |
| | | Object value) { |
| | | Class clazz = obj.getClass();// è·å对象çç±»å |
| | | PropertyDescriptor pd = getPropertyDescriptor(clazz, propertyName);// è·å clazz |
| | | // ç±»åä¸ç |
| | | // propertyName |
| | | // ç屿§æè¿°å¨ |
| | | Method setMethod = pd.getWriteMethod();// ä»å±æ§æè¿°å¨ä¸è·å set æ¹æ³ |
| | | try { |
| | | setMethod.invoke(obj, new Object[]{value});// è°ç¨ set æ¹æ³å°ä¼ å
¥çvalueå¼ä¿å屿§ä¸å» |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | @SuppressWarnings({"unchecked", "rawtypes"}) |
| | | public static Object getProperty(Object obj, String propertyName) { |
| | | Class clazz = obj.getClass();// è·å对象çç±»å |
| | | PropertyDescriptor pd = getPropertyDescriptor(clazz, propertyName);// è·å clazz |
| | | // ç±»åä¸ç |
| | | // propertyName |
| | | // ç屿§æè¿°å¨ |
| | | Method getMethod = pd.getReadMethod();// ä»å±æ§æè¿°å¨ä¸è·å get æ¹æ³ |
| | | Object value = null; |
| | | try { |
| | | value = getMethod.invoke(obj, new Object[]{});// è°ç¨æ¹æ³è·åæ¹æ³çè¿åå¼ |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return value;// è¿åå¼ |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package com.zy.acs.hex.utils; |
| | | |
| | | import com.zy.acs.hex.constant.InfluxDBConstant; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | public class StrUtils { |
| | | |
| | | public static Map<String, String> getTagsByRoutingKey(String routingKey) { |
| | | |
| | | // æ£å表达å¼å¹é
rcs.up. å¼å¤´ï¼åé¢è·çä¸¤ä¸ªçæ¬å·é¨å |
| | | String regex = "^rcs\\.up\\.(\\*|[a-zA-Z0-9]+)\\.(\\*|[a-zA-Z0-9]+)$"; |
| | | if (routingKey.matches(regex)) { |
| | | // åå²å符串并è¿åçæ¬å·é¨å |
| | | String[] parts = routingKey.split("\\."); |
| | | if (parts.length == 4) { |
| | | Map<String, String> data = new HashMap<>(); |
| | | data.put(InfluxDBConstant.DEVICE_MEASUREMENT_TAG_TYPE, parts[1]); |
| | | data.put(InfluxDBConstant.DEVICE_MEASUREMENT_TAG_DEVICEID, parts[2]); |
| | | data.put(InfluxDBConstant.DEVICE_MEASUREMENT_TAG_EVENT, parts[3]); |
| | | return data; |
| | | } |
| | | } |
| | | // å¦ææ ¼å¼ä¸ç¬¦åï¼è¿å空æ°ç» |
| | | return null; |
| | | } |
| | | |
| | | public static String getDeviceIdByRoutingKey(String routingKey) { |
| | | |
| | | // æ£å表达å¼å¹é
rcs.up. å¼å¤´ï¼åé¢è·çä¸¤ä¸ªçæ¬å·é¨å |
| | | String regex = "^rcs\\.up\\.(\\*|[a-zA-Z0-9]+)\\.(\\*|[a-zA-Z0-9]+)$"; |
| | | if (routingKey.matches(regex)) { |
| | | // åå²å符串并è¿åçæ¬å·é¨å |
| | | String[] parts = routingKey.split("\\."); |
| | | if (parts.length == 4) { |
| | | return parts[2]; |
| | | } |
| | | } |
| | | // å¦ææ ¼å¼ä¸ç¬¦åï¼è¿å空æ°ç» |
| | | return null; |
| | | } |
| | | |
| | | public static String getEventByRoutingKey(String routingKey) { |
| | | |
| | | // æ£å表达å¼å¹é
rcs.up. å¼å¤´ï¼åé¢è·çä¸¤ä¸ªçæ¬å·é¨å |
| | | String regex = "^rcs\\.up\\.(\\*|[a-zA-Z0-9]+)\\.(\\*|[a-zA-Z0-9]+)$"; |
| | | if (routingKey.matches(regex)) { |
| | | // åå²å符串并è¿åçæ¬å·é¨å |
| | | String[] parts = routingKey.split("\\."); |
| | | if (parts.length == 4) { |
| | | return parts[2]; |
| | | } |
| | | } |
| | | // å¦ææ ¼å¼ä¸ç¬¦åï¼è¿å空æ°ç» |
| | | return null; |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | System.out.println(StrUtils.getDeviceIdByRoutingKey("rcs.up.ds1233.2aads")); |
| | | } |
| | | } |
| | |
| | | |
| | | spring: |
| | | application: |
| | | name: rcs-hex |
| | |
| | | rabbitmq: |
| | | host: localhost |
| | | port: 5672 |
| | | username: admin |
| | | password: 123456 |
| | | username: root |
| | | password: xltys1995 |
| | | # èæhostå¯ä»¥ä¸è®¾ç½®ï¼é»è®¤/ |
| | | virtual-host: / |
| | | # ç产è
确认é
ç½® |
| | | publisher-confirm-type: correlated |
| | | publisher-returns: true |
| | | # æ¶è´¹è
é
ç½® |
| | | listener: |
| | | simple: |
| | | # æå¨ç¡®è®¤æ¨¡å¼ |
| | | acknowledge-mode: manual |
| | | # æ¶è´¹è
çº¿ç¨æ° |
| | | concurrency: 1 |
| | | # æå¤§æ¶è´¹è
çº¿ç¨æ° |
| | | max-concurrency: 5 |
| | | # æ¯æ¬¡ä»éåä¸è·åçæ¶æ¯æ°é |
| | | prefetch: 1 |
| | | direct: |
| | | acknowledge-mode: manual |
| | | # listener: |
| | | # direct: |
| | | # 确认æºå¶ |
| | | # acknowledge-mode: manual |
| | | |
| | | influxdb3: |
| | | enabled: true |
| | | url: http://127.0.0.1:8181 |
| | | token: apiv3_Jx1SvmBMV_kikGhc4eZJQbeGmNYN7KX1GdpoR9MClkKzMxSJ0MPKM_O2Xt3o1hVyRikMmlxZ_h9zfy6ybC5Idg |
| | | database: rcs |
| | |
| | | // generator.username="sa";priority |
| | | // generator.password="Zoneyung@zy56$"; |
| | | |
| | | generator.table="man_lane"; |
| | | generator.tableDesc="Lane"; |
| | | generator.table="man_integration_record"; |
| | | generator.tableDesc="Integration Record"; |
| | | generator.packagePath="com.zy.acs.manager.manager"; |
| | | |
| | | generator.build(); |
| | |
| | | * TRUNCATE man_jam; |
| | | * TRUNCATE man_action; |
| | | * TRUNCATE man_sta_reserve; |
| | | * TRUNCATE man_integration_record; |
| | | * |
| | | * TRUNCATE man_code; |
| | | * TRUNCATE man_code_gap; |
| | |
| | | package com.zy.acs.manager.common.config; |
| | | |
| | | import lombok.Data; |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | |
| | | * è¾é线plcç³»ç»é
ç½® |
| | | * Created by luxiaotao on 2018/10/15 |
| | | */ |
| | | @Data |
| | | @Configuration |
| | | @ConfigurationProperties(prefix = "convey-plc") |
| | | public class ConveyorProperties { |
| | |
| | | |
| | | private Integer port; |
| | | |
| | | public static String getHostName() { |
| | | return HOST_NAME; |
| | | } |
| | | private String url; |
| | | |
| | | public static void setHostName(String hostName) { |
| | | HOST_NAME = hostName; |
| | | } |
| | | // millisecond |
| | | private Integer timeout = 15 * 1000; |
| | | |
| | | public String getHost() { |
| | | return host; |
| | | } |
| | | |
| | | public void setHost(String host) { |
| | | this.host = host; |
| | | } |
| | | |
| | | public Integer getPort() { |
| | | return port; |
| | | } |
| | | |
| | | public void setPort(Integer port) { |
| | | this.port = port; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.zy.acs.manager.common.config; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.framework.common.R; |
| | | import com.zy.acs.manager.common.utils.IpTools; |
| | | import com.zy.acs.manager.manager.service.IntegrationRecordService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.jetbrains.annotations.NotNull; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.core.MethodParameter; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.http.converter.HttpMessageConverter; |
| | | import org.springframework.http.server.ServerHttpRequest; |
| | | import org.springframework.http.server.ServerHttpResponse; |
| | | import org.springframework.http.server.ServletServerHttpRequest; |
| | | import org.springframework.web.bind.annotation.ControllerAdvice; |
| | | import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.BufferedReader; |
| | | import java.io.InputStreamReader; |
| | | import java.nio.charset.StandardCharsets; |
| | | |
| | | @Slf4j |
| | | //@ControllerAdvice |
| | | public class IntegrationRecordAdvice implements ResponseBodyAdvice<Object> { |
| | | |
| | | @Autowired |
| | | private IntegrationRecordService integrationRecordService; |
| | | |
| | | @Override |
| | | public boolean supports(@NotNull MethodParameter methodParameter, @NotNull Class<? extends HttpMessageConverter<?>> aClass) { |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public Object beforeBodyWrite(Object o |
| | | , @NotNull MethodParameter methodParameter |
| | | , @NotNull MediaType mediaType |
| | | , @NotNull Class<? extends HttpMessageConverter<?>> aClass |
| | | , @NotNull ServerHttpRequest serverHttpRequest |
| | | , @NotNull ServerHttpResponse serverHttpResponse) { |
| | | if (serverHttpRequest instanceof ServletServerHttpRequest) { |
| | | HttpServletRequest request = ((ServletServerHttpRequest) serverHttpRequest).getServletRequest(); |
| | | Object appAuth = request.getAttribute("appAuth"); |
| | | if (appAuth != null) { |
| | | if (o instanceof R) { |
| | | String appkey = request.getHeader("appkey"); |
| | | Object reqCache = request.getAttribute("cache"); |
| | | if (!Cools.isEmpty(appkey)) { |
| | | // ä¿åæ¥å£æ¥å¿ |
| | | // apiLogService.save( |
| | | // String.valueOf(appAuth), |
| | | // request.getRequestURI(), |
| | | // appkey, |
| | | // IpTools.gainRealIp(request), |
| | | // reqCache==null?"": JSON.toJSONString(reqCache), |
| | | // JSON.toJSONString(o), |
| | | // String.valueOf(((R) o).get("code")).equalsIgnoreCase("200") |
| | | // ); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return o; |
| | | } |
| | | |
| | | public static String json(HttpServletRequest request) { |
| | | try { |
| | | BufferedReader streamReader = new BufferedReader( new InputStreamReader(request.getInputStream(), StandardCharsets.UTF_8)); |
| | | StringBuilder sb = new StringBuilder(); |
| | | String inputStr; |
| | | while ((inputStr = streamReader.readLine()) != null) { |
| | | sb.append(inputStr); |
| | | } |
| | | return sb.toString(); |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage()); |
| | | return ""; |
| | | } |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package com.zy.acs.manager.common.config; |
| | | |
| | | import lombok.Data; |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | import java.net.InetAddress; |
| | | import java.net.UnknownHostException; |
| | | |
| | | /** |
| | | * 䏿¸¸æå¡ç³»ç»é
ç½® |
| | | * Created by luxiaotao on 2018/10/15 |
| | | */ |
| | | @Data |
| | | @Configuration |
| | | @ConfigurationProperties(prefix = "uplink") |
| | | public class UplinkProperties { |
| | | |
| | | public static String HOST_NAME; |
| | | |
| | | static { |
| | | try { |
| | | HOST_NAME = InetAddress.getLocalHost().getHostName(); |
| | | } catch (UnknownHostException e) { |
| | | System.err.println("find hostname err"); |
| | | } |
| | | } |
| | | |
| | | private Boolean enabled; |
| | | |
| | | private String host; |
| | | |
| | | private Integer port; |
| | | |
| | | private String url; |
| | | |
| | | // millisecond |
| | | private Integer timeout = 60 * 1000; |
| | | |
| | | } |
| | |
| | | */ |
| | | public class Constants { |
| | | |
| | | public static final String UPLINK = "UPLINK"; |
| | | |
| | | public static final String HANDLE = "HANDLE"; |
| | | |
| | | public static final String LIMIT_ONE = "limit 1"; |
| | | |
| | | public static final String RCS = "RCS"; |
| | | |
| | | /** |
| | | * é»è®¤æåç |
| | | */ |
| New file |
| | |
| | | package com.zy.acs.manager.common.domain; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class TaskBoolDto { |
| | | |
| | | private String taskNo; |
| | | |
| | | private Boolean success; |
| | | |
| | | private String msg; |
| | | |
| | | public TaskBoolDto() { |
| | | } |
| | | |
| | | public TaskBoolDto(String taskNo, Boolean success) { |
| | | this.taskNo = taskNo; |
| | | this.success = success; |
| | | } |
| | | |
| | | public TaskBoolDto(String taskNo, Boolean success, String msg) { |
| | | this.taskNo = taskNo; |
| | | this.success = success; |
| | | this.msg = msg; |
| | | } |
| | | |
| | | } |
| | |
| | | @Data |
| | | public class TaskDto { |
| | | |
| | | private String seqNum; |
| | | private String taskNo; |
| | | |
| | | private String oriLoc; |
| | | |
| | |
| | | |
| | | import com.zy.acs.framework.common.Cools; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
| | | import org.apache.poi.ss.usermodel.Row; |
| | | import org.apache.poi.ss.usermodel.Sheet; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | |
| | | public static void build(Workbook workbook, HttpServletResponse response) { |
| | | response.reset(); |
| | | Http.cors(response); |
| | | response.setContentType("application/octet-stream; charset=utf-8"); |
| | | |
| | | response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=utf-8"); |
| | | |
| | | try { |
| | | response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode("export", "UTF-8")); |
| | | response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode("export.xlsx", "UTF-8")); |
| | | workbook.write(response.getOutputStream()); |
| | | workbook.close(); |
| | | |
| | | } catch (IOException ignore) {} |
| | | } |
| | | |
| | | public static <T> Workbook create(List<T> list, Class<T> clz) { |
| | | HSSFWorkbook workbook = new HSSFWorkbook(); |
| | | XSSFWorkbook workbook = new XSSFWorkbook(); |
| | | Sheet sheet = workbook.createSheet(clz.getSimpleName()); |
| | | |
| | | Row header = sheet.createRow(0); |
| | | Field[] fields = Cools.getAllFields(clz); |
| | | |
| | | int headerIdx = 0; |
| | | for (Field field : fields) { |
| | | if (Modifier.isFinal(field.getModifiers()) |
| | |
| | | || Modifier.isTransient(field.getModifiers())) { |
| | | continue; |
| | | } |
| | | |
| | | String memo = "Undefined"; |
| | | if (field.isAnnotationPresent(ApiModelProperty.class)) { |
| | | memo = field.getAnnotation(ApiModelProperty.class).value(); |
| | |
| | | } |
| | | } |
| | | |
| | | for (int i = 0; i <= fields.length; i++) { |
| | | for (int i = 0; i <= headerIdx; i++) { |
| | | sheet.autoSizeColumn(i); |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | // ======================== tools ======================== |
| | | public String buildUrl(String host, Integer port, String path) { |
| | | return buildUrl(host, port, path, false); |
| | | } |
| | | |
| | | public String buildUrl(String host, Integer port, String path, boolean ssl) { |
| | | String p = (path == null) ? "" : (path.startsWith("/") ? path : ("/" + path)); |
| | | return (ssl ? "https" : "http") + "://" + host + ":" + port + p; |
| | | } |
| | | |
| | | // ===================== Demo (main) ===================== |
| | | |
| | | public static void main(String[] args) throws Exception { |
| | |
| | | import com.zy.acs.framework.common.R; |
| | | import com.zy.acs.framework.common.SnowflakeIdWorker; |
| | | import com.zy.acs.manager.common.annotation.OperationLog; |
| | | import com.zy.acs.manager.common.config.UplinkProperties; |
| | | import com.zy.acs.manager.common.domain.param.HandlerPublishParam; |
| | | import com.zy.acs.manager.common.exception.BusinessException; |
| | | import com.zy.acs.manager.core.service.*; |
| | |
| | | import com.zy.acs.manager.manager.enums.*; |
| | | import com.zy.acs.manager.manager.service.*; |
| | | import com.zy.acs.manager.system.controller.BaseController; |
| | | import com.zy.acs.manager.system.service.ConfigService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.jdbc.core.JdbcTemplate; |
| | |
| | | @Autowired |
| | | private StaService staService; |
| | | @Autowired |
| | | private TrafficService trafficService; |
| | | private UplinkProperties uplinkProperties; |
| | | @Autowired |
| | | private ThreadPoolRegulator threadPoolRegulator; |
| | | @Autowired |
| | |
| | | private StaReserveService staReserveService; |
| | | @Autowired |
| | | private AgvAreaDispatcher agvAreaDispatcher; |
| | | @Autowired |
| | | private ConfigService configService; |
| | | |
| | | @PreAuthorize("hasAuthority('manager:agv:update')") |
| | | @OperationLog("Locate All Agv") |
| | |
| | | return R.error(); |
| | | } |
| | | |
| | | Boolean maintainLocSts = configService.getVal("maintainLocSts", Boolean.class); |
| | | Date now = new Date(); |
| | | Agv agv = agvService.selectByUuid(param.getAgvNo()); |
| | | AgvDetail agvDetail = agvDetailService.selectByAgvId(agv.getId()); |
| | |
| | | Task task = new Task(); |
| | | task.setAgvId(agv.getId()); |
| | | task.setUuid(String.valueOf(snowflakeIdWorker.nextId()).substring(3)); |
| | | List<Task> lastTasks = taskService.list(new LambdaQueryWrapper<Task>().orderByDesc(Task::getId)); |
| | | // List<Task> lastTasks = taskService.list(new LambdaQueryWrapper<Task>().orderByDesc(Task::getId)); |
| | | // task.setSeqNum(Utils.generateSeqNum(Cools.isEmpty(lastTasks)?null:lastTasks.get(0).getSeqNum())); |
| | | task.setSeqNum(Base62.encode(snowflakeIdWorker.nextId())); |
| | | |
| | | task.setTaskType(param.getTaskMode().val()); |
| | | task.setTaskSts(TaskStsType.WAITING.val()); |
| | | |
| | | task.setUplinkSts(uplinkProperties.getEnabled() ? TaskUplinkStateType.PENDING.toString() : TaskUplinkStateType.SKIPPED.toString()); |
| | | task.setPriority(999); |
| | | task.setIoTime(now); |
| | | task.setStartTime(now); |
| | |
| | | // throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + oriLoc.getCode$()); |
| | | throw new BusinessException("AGVã" + agv.getUuid() + "ãæ æ³å°è¾¾èµ·å§åºä½ã" + oriLoc.getLocNo() + "ã"); |
| | | } |
| | | if (!oriLoc.getLocSts().equals(LocStsType.STOCK.val())) { |
| | | throw new BusinessException("oriLocï¼" + oriLoc.getLocNo() + " 䏿¯å¨åºç¶æ"); |
| | | } |
| | | oriLoc.setLocSts(LocStsType.PAKOUT.val()); |
| | | oriLoc.setUpdateTime(now); |
| | | if (!locService.updateById(oriLoc)) { |
| | | throw new BusinessException("oriLocï¼" + oriLoc.getLocNo() + " ä¿®æ¹åºä½ç¶æå¤±è´¥"); |
| | | if (maintainLocSts) { |
| | | if (!oriLoc.getLocSts().equals(LocStsType.STOCK.val())) { |
| | | throw new BusinessException("oriLocï¼" + oriLoc.getLocNo() + " 䏿¯å¨åºç¶æ"); |
| | | } |
| | | oriLoc.setLocSts(LocStsType.PAKOUT.val()); |
| | | oriLoc.setUpdateTime(now); |
| | | if (!locService.updateById(oriLoc)) { |
| | | throw new BusinessException("oriLocï¼" + oriLoc.getLocNo() + " ä¿®æ¹åºä½ç¶æå¤±è´¥"); |
| | | } |
| | | } |
| | | |
| | | // destLoc |
| | |
| | | // throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + destLoc.getCode$()); |
| | | throw new BusinessException("AGVã" + agv.getUuid() + "ãæ æ³å°è¾¾ç®æ åºä½ã" + destLoc.getLocNo() + "ã"); |
| | | } |
| | | if (!destLoc.getLocSts().equals(LocStsType.IDLE.val())) { |
| | | throw new BusinessException("destLocï¼" + destLoc.getLocNo() + " 䏿¯ç©ºé²ç¶æ"); |
| | | } |
| | | destLoc.setLocSts(LocStsType.PAKIN.val()); |
| | | destLoc.setUpdateTime(now); |
| | | if (!locService.updateById(destLoc)) { |
| | | throw new BusinessException("destLocï¼" + destLoc.getLocNo() + " ä¿®æ¹åºä½ç¶æå¤±è´¥"); |
| | | if (maintainLocSts) { |
| | | if (!destLoc.getLocSts().equals(LocStsType.IDLE.val())) { |
| | | throw new BusinessException("destLocï¼" + destLoc.getLocNo() + " 䏿¯ç©ºé²ç¶æ"); |
| | | } |
| | | destLoc.setLocSts(LocStsType.PAKIN.val()); |
| | | destLoc.setUpdateTime(now); |
| | | if (!locService.updateById(destLoc)) { |
| | | throw new BusinessException("destLocï¼" + destLoc.getLocNo() + " ä¿®æ¹åºä½ç¶æå¤±è´¥"); |
| | | } |
| | | } |
| | | |
| | | // task |
| | |
| | | // throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + oriLoc.getCode$()); |
| | | throw new BusinessException("AGVã" + agv.getUuid() + "ãæ æ³å°è¾¾èµ·å§åºä½ã" + oriLoc.getLocNo() + "ã"); |
| | | } |
| | | if (!oriLoc.getLocSts().equals(LocStsType.STOCK.val())) { |
| | | throw new BusinessException("oriLocï¼" + oriLoc.getLocNo() + " 䏿¯å¨åºç¶æ"); |
| | | } |
| | | oriLoc.setLocSts(LocStsType.PAKOUT.val()); |
| | | oriLoc.setUpdateTime(now); |
| | | if (!locService.updateById(oriLoc)) { |
| | | throw new BusinessException("oriLocï¼" + oriLoc.getLocNo() + " ä¿®æ¹åºä½ç¶æå¤±è´¥"); |
| | | if (maintainLocSts) { |
| | | if (!oriLoc.getLocSts().equals(LocStsType.STOCK.val())) { |
| | | throw new BusinessException("oriLocï¼" + oriLoc.getLocNo() + " 䏿¯å¨åºç¶æ"); |
| | | } |
| | | oriLoc.setLocSts(LocStsType.PAKOUT.val()); |
| | | oriLoc.setUpdateTime(now); |
| | | if (!locService.updateById(oriLoc)) { |
| | | throw new BusinessException("oriLocï¼" + oriLoc.getLocNo() + " ä¿®æ¹åºä½ç¶æå¤±è´¥"); |
| | | } |
| | | } |
| | | |
| | | // destSta |
| | |
| | | // throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + destLoc.getCode$()); |
| | | throw new BusinessException("AGVã" + agv.getUuid() + "ãæ æ³å°è¾¾ç®æ åºä½ã" + destLoc.getLocNo() + "ã"); |
| | | } |
| | | if (!destLoc.getLocSts().equals(LocStsType.IDLE.val())) { |
| | | throw new BusinessException("destLocï¼" + destLoc.getLocNo() + " 䏿¯ç©ºé²ç¶æ"); |
| | | } |
| | | destLoc.setLocSts(LocStsType.PAKIN.val()); |
| | | destLoc.setUpdateTime(now); |
| | | if (!locService.updateById(destLoc)) { |
| | | throw new BusinessException("destLocï¼" + destLoc.getLocNo() + " ä¿®æ¹åºä½ç¶æå¤±è´¥"); |
| | | if (maintainLocSts) { |
| | | if (!destLoc.getLocSts().equals(LocStsType.IDLE.val())) { |
| | | throw new BusinessException("destLocï¼" + destLoc.getLocNo() + " 䏿¯ç©ºé²ç¶æ"); |
| | | } |
| | | destLoc.setLocSts(LocStsType.PAKIN.val()); |
| | | destLoc.setUpdateTime(now); |
| | | if (!locService.updateById(destLoc)) { |
| | | throw new BusinessException("destLocï¼" + destLoc.getLocNo() + " ä¿®æ¹åºä½ç¶æå¤±è´¥"); |
| | | } |
| | | } |
| | | |
| | | // task |
| New file |
| | |
| | | package com.zy.acs.manager.core.domain.type; |
| | | |
| | | public enum NamespaceType { |
| | | |
| | | RCS_TASK_REPORT("ä»»å¡å®æä¸æ¥"), |
| | | |
| | | ; |
| | | |
| | | public String name; |
| | | |
| | | NamespaceType(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | } |
| | |
| | | import com.zy.acs.manager.manager.entity.Task; |
| | | import com.zy.acs.manager.manager.enums.StatusType; |
| | | import com.zy.acs.manager.manager.service.StaService; |
| | | import com.zy.acs.manager.system.controller.BaseController; |
| | | import io.swagger.annotations.Api; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | |
| | | @Api(tags = "Open Api") |
| | | @RestController |
| | | @RequestMapping("/api/open") |
| | | public class ConveyorController extends BaseController { |
| | | public class ConveyorController { |
| | | |
| | | @Autowired |
| | | private StaService staService; |
| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.TypeReference; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.framework.common.SnowflakeIdWorker; |
| | | import com.zy.acs.manager.common.config.ConveyorProperties; |
| | | import com.zy.acs.manager.common.constant.Constants; |
| | | import com.zy.acs.manager.common.utils.HttpGo; |
| | | import com.zy.acs.manager.core.domain.type.NamespaceType; |
| | | import com.zy.acs.manager.core.integrate.dto.ConveyorStaDto; |
| | | import com.zy.acs.manager.core.integrate.dto.HttpResult; |
| | | import com.zy.acs.manager.manager.entity.IntegrationRecord; |
| | | import com.zy.acs.manager.manager.entity.Segment; |
| | | import com.zy.acs.manager.manager.entity.Sta; |
| | | import com.zy.acs.manager.manager.entity.Task; |
| | | import com.zy.acs.manager.manager.enums.IntegrationDirectionType; |
| | | import com.zy.acs.manager.manager.enums.StaReserveType; |
| | | import com.zy.acs.manager.manager.enums.StatusType; |
| | | import com.zy.acs.manager.manager.service.IntegrationRecordService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import java.time.Duration; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | @Slf4j |
| | | @Service |
| | |
| | | |
| | | @Autowired |
| | | private ConveyorProperties conveyorProperties; |
| | | @Autowired |
| | | private SnowflakeIdWorker snowflakeIdWorker; |
| | | @Autowired |
| | | private IntegrationRecordService integrationRecordService; |
| | | |
| | | private HttpGo http; |
| | | |
| | | @PostConstruct |
| | | public void init() { |
| | | int timeoutSeconds = conveyorProperties.getTimeout() / 1000; |
| | | this.http = HttpGo.builder() |
| | | .connectTimeout(Duration.ofSeconds(8)) |
| | | .readTimeout(Duration.ofSeconds(15)) |
| | | .connectTimeout(Duration.ofSeconds(timeoutSeconds)) |
| | | .readTimeout(Duration.ofSeconds(timeoutSeconds)) |
| | | // .defaultHeader("User-Agent", "HttpGo/1.0") |
| | | // .trustAllSsl(true) // ONLY if you really need it (self-signed internal) |
| | | // .trustAllSsl(true) // ONLY if you really need it (self-signed internal) |
| | | .build(); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public boolean allowAgvWork(Sta sta, Task task, Segment seg, StaReserveType type) { |
| | | final String staNo = sta.getStaNo(); |
| | | Date now = new Date(); |
| | | |
| | | // url |
| | | String url = this.buildUrl("/cv/station/query"); |
| | | String url = this.http.buildUrl(conveyorProperties.getHost(), conveyorProperties.getPort(), conveyorProperties.getUrl()); |
| | | // headers |
| | | Map<String, String> headers = new HashMap<>(); |
| | | // params |
| | |
| | | List<String> list = new ArrayList<>(); |
| | | list.add(staNo); |
| | | params.put("staNos", list); |
| | | |
| | | IntegrationRecord integrationRecord = new IntegrationRecord( |
| | | String.valueOf(snowflakeIdWorker.nextId()).substring(3), // ç¼å· |
| | | NamespaceType.RCS_TASK_REPORT.name, // åç§°ç©ºé´ |
| | | conveyorProperties.getUrl(), // æ¥å£å°å |
| | | null, // å¹³å°å¯é¥ |
| | | Constants.RCS, // è°ç¨æ¹æ è¯ |
| | | IntegrationDirectionType.OUTBOUND.value, // æ¹å[é空] |
| | | String.valueOf(now.getTime()), // æ¶é´æ³ |
| | | conveyorProperties.getHost(), // 客æ·ç«¯IP |
| | | JSON.toJSONString(params), // 请æ±å
容 |
| | | null, // ååºå
容 |
| | | null, // å¼å¸¸å
容 |
| | | 0, // ç»æ |
| | | null, // èæ¶ |
| | | StatusType.ENABLE.val, // ç¶æ |
| | | now, // æ·»å æ¶é´[é空] |
| | | now, // ä¿®æ¹æ¶é´[é空] |
| | | null // 夿³¨ |
| | | ); |
| | | |
| | | // do request |
| | | HttpResult<List<ConveyorStaDto>> result; |
| | | try { |
| | | result = postForResult(url, headers, params); |
| | | integrationRecord.setResponse(JSON.toJSONString(result)); |
| | | |
| | | Integer code = result.getCode(); |
| | | if (null == code || 200 != code) { |
| | | return false; |
| | |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | integrationRecord.setResult(1); |
| | | } catch (Exception e) { |
| | | log.error("Conveyor query failed, FAIL-OPEN. staNo={}, taskId={}, type={}", |
| | | sta.getStaNo(), |
| | | task.getSeqNum(), |
| | | type, |
| | | e); |
| | | integrationRecord.setErr(e.getMessage()); |
| | | return false; |
| | | } finally { |
| | | integrationRecord.setCostMs((int) (System.currentTimeMillis() - now.getTime())); |
| | | integrationRecordService.syncRecord(integrationRecord); |
| | | } |
| | | // ok |
| | | return true; |
| | | } |
| | | |
| | | private String buildUrl(String path) { |
| | | String host = conveyorProperties.getHost(); |
| | | Integer port = conveyorProperties.getPort(); |
| | | |
| | | String p = (path == null) ? "" : (path.startsWith("/") ? path : ("/" + path)); |
| | | return "http://" + host + ":" + port + p; |
| | | } |
| | | |
| | | private HttpResult<List<ConveyorStaDto>> postForResult(String url |
| | | , Map<String, String> headers, Map<String, Object> params) throws Exception { |
| | | private HttpResult<List<ConveyorStaDto>> postForResult(String url, Map<String, String> headers, Map<String, Object> params) throws Exception { |
| | | String json = JSON.toJSONString(params); |
| | | HttpGo.HttpResponse response = this.http.postJson(url, headers, json); |
| | | |
| New file |
| | |
| | | package com.zy.acs.manager.core.integrate.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Created by vincent on 2023/6/12 |
| | | */ |
| | | @Data |
| | | public class OpenBusCancelParam { |
| | | |
| | | private String batchNo; |
| | | |
| | | private List<String> tasks = new ArrayList<>(); |
| | | |
| | | } |
| New file |
| | |
| | | package com.zy.acs.manager.core.integrate.dto; |
| | | |
| | | import com.zy.acs.manager.common.domain.TaskBoolDto; |
| | | import lombok.Data; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Created by vincent on 2023/6/12 |
| | | */ |
| | | @Data |
| | | public class OpenBusCancelResult { |
| | | |
| | | private String batchNo; |
| | | |
| | | private List<TaskBoolDto> tasks = new ArrayList<>(); |
| | | |
| | | } |
| File was renamed from zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/param/OpenBusSubmitParam.java |
| | |
| | | package com.zy.acs.manager.manager.controller.param; |
| | | package com.zy.acs.manager.core.integrate.dto; |
| | | |
| | | import com.zy.acs.manager.common.domain.TaskDto; |
| | | import lombok.Data; |
| | |
| | | @Data |
| | | public class OpenBusSubmitParam { |
| | | |
| | | private String batch; |
| | | private String batchNo; |
| | | |
| | | private List<TaskDto> taskList = new ArrayList<>(); |
| | | private List<TaskDto> tasks = new ArrayList<>(); |
| | | |
| | | } |
| New file |
| | |
| | | package com.zy.acs.manager.core.integrate.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class TaskUplinkParam { |
| | | |
| | | private String batchNo; |
| | | |
| | | private String taskNo; |
| | | |
| | | private Long timestamp; |
| | | |
| | | } |
| | |
| | | package com.zy.acs.manager.core.integrate.wms; |
| | | |
| | | import com.zy.acs.manager.common.annotation.OperationLog; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.framework.common.R; |
| | | import com.zy.acs.manager.system.controller.BaseController; |
| | | import com.zy.acs.manager.common.annotation.OperationLog; |
| | | import com.zy.acs.manager.common.constant.Constants; |
| | | import com.zy.acs.manager.common.domain.TaskBoolDto; |
| | | import com.zy.acs.manager.core.integrate.dto.OpenBusCancelParam; |
| | | import com.zy.acs.manager.core.integrate.dto.OpenBusCancelResult; |
| | | import com.zy.acs.manager.core.integrate.dto.OpenBusSubmitParam; |
| | | import com.zy.acs.manager.core.service.MainService; |
| | | import com.zy.acs.manager.manager.controller.param.OpenBusSubmitParam; |
| | | import com.zy.acs.manager.manager.entity.Bus; |
| | | import com.zy.acs.manager.manager.entity.IntegrationRecord; |
| | | import com.zy.acs.manager.manager.entity.Task; |
| | | import com.zy.acs.manager.manager.enums.TaskStsType; |
| | | import com.zy.acs.manager.manager.service.BusService; |
| | | import com.zy.acs.manager.manager.service.TaskService; |
| | | import io.swagger.annotations.Api; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | /** |
| | | * Created by vincent on 2023/6/12 |
| | | */ |
| | | @Slf4j |
| | | @Api(tags = "Open Api") |
| | | @RestController |
| | | @RequestMapping("/api/open") |
| | | public class OpenController extends BaseController { |
| | | public class OpenController { |
| | | |
| | | @Autowired |
| | | private MainService mainService; |
| | | @Autowired |
| | | private TaskService taskService; |
| | | @Autowired |
| | | private BusService busService; |
| | | |
| | | // @PreAuthorize("hasAuthority('open:bus:submit')") |
| | | @PostMapping("/bus/submit") |
| | | @OperationLog("generate task from open api") |
| | | public R save(@RequestBody OpenBusSubmitParam param) { |
| | | public R submit(@RequestBody OpenBusSubmitParam param, HttpServletRequest request) { |
| | | IntegrationRecord integrationRecord = new IntegrationRecord( |
| | | null, // ç¼å· |
| | | null, // åç§°ç©ºé´ |
| | | null, // æ¥å£å°å |
| | | null, // å¹³å°å¯é¥ |
| | | null, // è°ç¨æ¹æ è¯ |
| | | null, // æ¹å[é空] |
| | | null, // æ¶é´æ³ |
| | | null, // 客æ·ç«¯IP |
| | | null, // 请æ±å
容 |
| | | null, // ååºå
容 |
| | | null, // å¼å¸¸å
容 |
| | | null, // ç»æ |
| | | null, // èæ¶ |
| | | null, // ç¶æ |
| | | null, // æ·»å æ¶é´[é空] |
| | | null, // ä¿®æ¹æ¶é´[é空] |
| | | null // 夿³¨ |
| | | ); |
| | | request.setAttribute("integrationRecord", integrationRecord); |
| | | |
| | | mainService.generateBusAndTask(param, null); |
| | | return R.ok("generate tasks success"); |
| | | } |
| | | |
| | | @PostMapping("/task/cancel") |
| | | @OperationLog("cancel task from open api") |
| | | public R cancel(@RequestBody OpenBusCancelParam param) { |
| | | if (Cools.isEmpty(param.getBatchNo())) { |
| | | return R.error("batchNo is empty"); |
| | | } |
| | | if (Cools.isEmpty(param.getTasks())) { |
| | | return R.error("tasks is empty"); |
| | | } |
| | | Bus bus = busService.selectByBusNo(param.getBatchNo()); |
| | | if (null == bus) { |
| | | return R.error("batchNo is not exist"); |
| | | } |
| | | OpenBusCancelResult result = new OpenBusCancelResult(); |
| | | result.setBatchNo(param.getBatchNo()); |
| | | for (String taskNo : param.getTasks()) { |
| | | Task task = taskService.selectBySeqNum(bus.getId(), taskNo); |
| | | if (null == task) { |
| | | result.getTasks().add(new TaskBoolDto(taskNo, Boolean.FALSE, "task " + taskNo + " is not exist")); |
| | | continue; |
| | | } |
| | | if (!task.getTaskSts().equals(TaskStsType.INIT.val())) { |
| | | result.getTasks().add(new TaskBoolDto(taskNo, Boolean.FALSE, "task " + taskNo + " has already been assigned")); |
| | | continue; |
| | | } |
| | | Boolean cancel = false; |
| | | try { |
| | | cancel = taskService.cancel(task.getId(), null, Constants.UPLINK); |
| | | } catch (Exception e) { |
| | | log.error("failed to cancel task {}", taskNo, e); |
| | | } |
| | | result.getTasks().add(new TaskBoolDto(taskNo, cancel, "failed to cancel task " + taskNo)); |
| | | } |
| | | return R.ok("cancel tasks success").add(result); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package com.zy.acs.manager.core.integrate.wms; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.TypeReference; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.framework.common.R; |
| | | import com.zy.acs.framework.common.SnowflakeIdWorker; |
| | | import com.zy.acs.manager.common.config.UplinkProperties; |
| | | import com.zy.acs.manager.common.constant.Constants; |
| | | import com.zy.acs.manager.common.utils.HttpGo; |
| | | import com.zy.acs.manager.core.domain.type.NamespaceType; |
| | | import com.zy.acs.manager.core.integrate.dto.HttpResult; |
| | | import com.zy.acs.manager.core.integrate.dto.TaskUplinkParam; |
| | | import com.zy.acs.manager.core.service.ThreadPoolRegulator; |
| | | import com.zy.acs.manager.manager.entity.Bus; |
| | | import com.zy.acs.manager.manager.entity.IntegrationRecord; |
| | | import com.zy.acs.manager.manager.entity.Task; |
| | | import com.zy.acs.manager.manager.enums.IntegrationDirectionType; |
| | | import com.zy.acs.manager.manager.enums.StatusType; |
| | | import com.zy.acs.manager.manager.enums.TaskStsType; |
| | | import com.zy.acs.manager.manager.enums.TaskUplinkStateType; |
| | | import com.zy.acs.manager.manager.service.BusService; |
| | | import com.zy.acs.manager.manager.service.IntegrationRecordService; |
| | | import com.zy.acs.manager.manager.service.TaskService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import java.time.Duration; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.concurrent.CompletableFuture; |
| | | |
| | | @Slf4j |
| | | @Service |
| | | public class TaskReportService { |
| | | |
| | | @Autowired |
| | | private UplinkProperties uplinkProperties; |
| | | @Autowired |
| | | private TaskService taskService; |
| | | @Autowired |
| | | private ThreadPoolRegulator threadPoolRegulator; |
| | | @Autowired |
| | | private BusService busService; |
| | | @Autowired |
| | | private SnowflakeIdWorker snowflakeIdWorker; |
| | | @Autowired |
| | | private IntegrationRecordService integrationRecordService; |
| | | |
| | | private HttpGo http; |
| | | |
| | | @PostConstruct |
| | | public void init() { |
| | | int timeoutSeconds = uplinkProperties.getTimeout() / 1000; |
| | | this.http = HttpGo.builder() |
| | | .connectTimeout(Duration.ofSeconds(timeoutSeconds)) |
| | | .readTimeout(Duration.ofSeconds(timeoutSeconds)) |
| | | // .defaultHeader("User-Agent", "HttpGo/1.0") |
| | | // .trustAllSsl(true) // ONLY if you really need it (self-signed internal) |
| | | .build(); |
| | | } |
| | | |
| | | public boolean reportFinished(Task task) { |
| | | if (Cools.isEmpty(task)) { |
| | | return false; |
| | | } |
| | | if (!uplinkProperties.getEnabled()) { |
| | | return false; |
| | | } |
| | | if (!task.getTaskSts().equals(TaskStsType.COMPLETE.val())) { |
| | | return false; |
| | | } |
| | | TaskUplinkStateType uplinkStateType = TaskUplinkStateType.of(task.getUplinkSts()); |
| | | if (!uplinkStateType.equals(TaskUplinkStateType.PENDING) |
| | | && !uplinkStateType.equals(TaskUplinkStateType.SENDING) |
| | | && !uplinkStateType.equals(TaskUplinkStateType.FAILED) |
| | | ) { |
| | | return false; |
| | | } |
| | | Date now = new Date(); |
| | | // block |
| | | // Future<R> future = threadPoolRegulator.getInstance().submit(() -> { |
| | | // mapDataDispatcher.modifyDynamicMatrix(null, null, param.getAgvNo(), true); |
| | | // return success(); |
| | | // }); |
| | | // System.out.println(JSON.toJSONString(future.get())); |
| | | |
| | | // non-block |
| | | CompletableFuture<?> completableFuture = CompletableFuture.supplyAsync(() -> { |
| | | // mapDataDispatcher.modifyDynamicMatrix(null, null, param.getAgvNo(), true); |
| | | // avoidWaveCalculator.calcDynamicNodeByVehicle(agv, null); |
| | | return R.ok(); |
| | | }, threadPoolRegulator.getInstance()); |
| | | |
| | | // url |
| | | String url = this.http.buildUrl(uplinkProperties.getHost(), uplinkProperties.getPort(), uplinkProperties.getUrl()); |
| | | // headers |
| | | Map<String, String> headers = new HashMap<>(); |
| | | // params |
| | | TaskUplinkParam param = new TaskUplinkParam(); |
| | | if (null != task.getBusId()) { |
| | | Bus bus = busService.getById(task.getBusId()); |
| | | param.setBatchNo(bus.getBusNo()); |
| | | } |
| | | param.setTaskNo(task.getSeqNum()); |
| | | param.setTimestamp(null == task.getEndTime() ? System.currentTimeMillis() : task.getEndTime().getTime()); |
| | | |
| | | IntegrationRecord integrationRecord = new IntegrationRecord( |
| | | String.valueOf(snowflakeIdWorker.nextId()).substring(3), // ç¼å· |
| | | NamespaceType.RCS_TASK_REPORT.name, // åç§°ç©ºé´ |
| | | uplinkProperties.getUrl(), // æ¥å£å°å |
| | | null, // å¹³å°å¯é¥ |
| | | Constants.RCS, // è°ç¨æ¹æ è¯ |
| | | IntegrationDirectionType.OUTBOUND.value, // æ¹å[é空] |
| | | String.valueOf(now.getTime()), // æ¶é´æ³ |
| | | uplinkProperties.getHost(), // 客æ·ç«¯IP |
| | | JSON.toJSONString(param), // 请æ±å
容 |
| | | null, // ååºå
容 |
| | | null, // å¼å¸¸å
容 |
| | | 0, // ç»æ |
| | | null, // èæ¶ |
| | | StatusType.ENABLE.val, // ç¶æ |
| | | now, // æ·»å æ¶é´[é空] |
| | | now, // ä¿®æ¹æ¶é´[é空] |
| | | null // 夿³¨ |
| | | ); |
| | | HttpResult<?> result; |
| | | try { |
| | | result = postForResult(url, headers, param); |
| | | integrationRecord.setResponse(JSON.toJSONString(result)); |
| | | |
| | | Integer code = result.getCode(); |
| | | if (null == code || 200 != code) { |
| | | return false; |
| | | } |
| | | // Object data = result.getData(); |
| | | // if (Cools.isEmpty(data)) { |
| | | // return false; |
| | | // } |
| | | |
| | | integrationRecord.setResult(1); |
| | | } catch (Exception e) { |
| | | log.error("Uplink report failed, taskId={}", |
| | | JSON.toJSONString(task), |
| | | e); |
| | | integrationRecord.setErr(e.getMessage()); |
| | | return false; |
| | | } finally { |
| | | integrationRecord.setCostMs((int) (System.currentTimeMillis() - now.getTime())); |
| | | integrationRecordService.syncRecord(integrationRecord); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | private HttpResult<?> postForResult(String url, Map<String, String> headers, TaskUplinkParam param) throws Exception { |
| | | String json = JSON.toJSONString(param); |
| | | HttpGo.HttpResponse response = this.http.postJson(url, headers, json); |
| | | |
| | | int status = response.statusCode(); |
| | | if (status != 200) { |
| | | throw new RuntimeException("Uplink HTTP error: status=" + status + ", body=" + response.body()); |
| | | } |
| | | |
| | | String body = response.body(); |
| | | if (Cools.isEmpty(body)) { |
| | | throw new RuntimeException("Uplink empty response body."); |
| | | } |
| | | |
| | | HttpResult<?> result = JSON.parseObject(body, new TypeReference<HttpResult<?>>() {}); |
| | | if (result == null) { |
| | | throw new RuntimeException("Uplink parse HttpResult failed: body=" + body); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.acs.common.enums.AgvStatusType; |
| | | import com.zy.acs.common.utils.RedisSupport; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.framework.common.DateUtils; |
| | | import com.zy.acs.manager.common.config.UplinkProperties; |
| | | import com.zy.acs.manager.core.integrate.wms.TaskReportService; |
| | | import com.zy.acs.manager.core.service.MainLockWrapService; |
| | | import com.zy.acs.manager.core.service.MainService; |
| | | import com.zy.acs.manager.manager.entity.*; |
| | | import com.zy.acs.manager.manager.enums.*; |
| | | import com.zy.acs.manager.manager.service.*; |
| | |
| | | @Autowired |
| | | private FuncStaService funcStaService; |
| | | @Autowired |
| | | private MainService mainService; |
| | | private UplinkProperties uplinkProperties; |
| | | @Autowired |
| | | private MainLockWrapService mainLockWrapService; |
| | | @Autowired |
| | |
| | | private AgvModelService agvModelService; |
| | | @Autowired |
| | | private SegmentService segmentService; |
| | | @Autowired |
| | | private TaskReportService taskReportService; |
| | | |
| | | @Scheduled(cron = "0/5 * * * * ? ") |
| | | private synchronized void autoCharge(){ |
| | |
| | | } |
| | | } |
| | | |
| | | @Scheduled(cron = "0/3 * * * * ? ") |
| | | private void reportTaskToUplink() { |
| | | if (!uplinkProperties.getEnabled()) { return; } |
| | | List<Task> taskList = taskService.list(new LambdaQueryWrapper<Task>() |
| | | .in(Task::getUplinkSts, TaskUplinkStateType.PENDING.toString(), TaskUplinkStateType.FAILED.toString()) |
| | | .eq(Task::getTaskSts, TaskStsType.COMPLETE.val()) |
| | | .isNotNull(Task::getBusId) |
| | | ); |
| | | if (Cools.isEmpty(taskList)) { return; } |
| | | for (Task task : taskList) { |
| | | boolean finished = taskReportService.reportFinished(task); |
| | | if (finished) { |
| | | task.setUplinkSts(TaskUplinkStateType.SUCCESS.toString()); |
| | | } else { |
| | | log.error("failed to report task to uplink: {}", task.getSeqNum()); |
| | | task.setUplinkSts(TaskUplinkStateType.FAILED.toString()); |
| | | } |
| | | taskService.updateById(task); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Scheduled(cron = "0/5 * * * * ? ") |
| | | private synchronized void releaseFuncSta(){ |
| | | private synchronized void releaseFuncSta() { |
| | | List<FuncSta> funcStaList = funcStaService.list(new LambdaQueryWrapper<FuncSta>().eq(FuncSta::getState, FuncStaStateType.OCCUPIED.toString())); |
| | | for (FuncSta funcSta : funcStaList) { |
| | | boolean beIdle = funcStaService.isCanBeIdle(funcSta); |
| File was renamed from zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/AutoRunRebootScheduler.java |
| | |
| | | package com.zy.acs.manager.core.scheduler; |
| | | package com.zy.acs.manager.core.scheduler.test; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.acs.common.constant.RedisConstant; |
| | |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.framework.common.SnowflakeIdWorker; |
| | | import com.zy.acs.manager.common.domain.TaskDto; |
| | | import com.zy.acs.manager.core.integrate.dto.OpenBusSubmitParam; |
| | | import com.zy.acs.manager.core.service.AreaGovernService; |
| | | import com.zy.acs.manager.core.service.MainLockWrapService; |
| | | import com.zy.acs.manager.core.service.MainService; |
| | | import com.zy.acs.manager.manager.controller.param.OpenBusSubmitParam; |
| | | import com.zy.acs.manager.manager.entity.*; |
| | | import com.zy.acs.manager.manager.enums.*; |
| | | import com.zy.acs.manager.manager.service.*; |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.*; |
| | | |
| | | @Slf4j |
| | | @Component |
| | | //@Component |
| | | public class AutoRunRebootScheduler { |
| | | |
| | | private static final AgvModelType DEFAULT_AGV_MODEL = AgvModelType.HEAVY_LOAD_STACKING_ROBOT; |
| | |
| | | // @Scheduled(cron = "0/1 * * * * ? ") |
| | | private void execute() { |
| | | if (!configService.getVal("TaskAssignRebootMode", Boolean.class)) { return; } |
| | | Boolean maintainLocSts = configService.getVal("maintainLocSts", Boolean.class); |
| | | if (!maintainLocSts) { |
| | | log.error("failed to run auto agv task, the maintainLocSts is false"); |
| | | return; |
| | | } |
| | | |
| | | AgvModel agvModel = agvModelService.getOne(new LambdaQueryWrapper<AgvModel>().eq(AgvModel::getType, DEFAULT_AGV_MODEL.toString())); |
| | | if (null == agvModel) { return; } |
| | | |
| | |
| | | Collections.shuffle(stockList); |
| | | |
| | | OpenBusSubmitParam param = new OpenBusSubmitParam(); |
| | | param.setBatch(String.valueOf(snowflakeIdWorker.nextId()).substring(13, 19)); |
| | | param.setBatchNo(String.valueOf(snowflakeIdWorker.nextId()).substring(13, 19)); |
| | | for (int i = 0; i < Math.min(agvModel.getBackpack(), stockList.size()) ; i++) { |
| | | Sta stockSta = stockList.get(i); |
| | | String staCode = codeService.getCacheById(stockSta.getCode()).getData(); |
| | |
| | | taskDto.setOriSta(stockSta.getStaNo()); |
| | | taskDto.setDestLoc(idleLoc.getLocNo()); |
| | | taskDto.setPriority(100); |
| | | taskDto.setSeqNum(String.valueOf(snowflakeIdWorker.nextId()).substring(15, 19)); |
| | | taskDto.setTaskNo(String.valueOf(snowflakeIdWorker.nextId()).substring(15, 19)); |
| | | |
| | | param.getTaskList().add(taskDto); |
| | | param.getTasks().add(taskDto); |
| | | } |
| | | if (Cools.isEmpty(param.getTaskList())) { return; } |
| | | if (Cools.isEmpty(param.getTasks())) { return; } |
| | | |
| | | mainService.generateBusAndTask(param, memo); |
| | | } |
| | |
| | | Collections.shuffle(idleList); |
| | | |
| | | OpenBusSubmitParam param = new OpenBusSubmitParam(); |
| | | param.setBatch(String.valueOf(snowflakeIdWorker.nextId()).substring(13, 19)); |
| | | param.setBatchNo(String.valueOf(snowflakeIdWorker.nextId()).substring(13, 19)); |
| | | for (int i = 0; i < Math.min(agvModel.getBackpack(), idleList.size()) ; i++) { |
| | | Sta idleSta = idleList.get(i); |
| | | String staCode = codeService.getCacheById(idleSta.getCode()).getData(); |
| | |
| | | taskDto.setOriLoc(stockLoc.getLocNo()); |
| | | taskDto.setDestSta(idleSta.getStaNo()); |
| | | taskDto.setPriority(100); |
| | | taskDto.setSeqNum(String.valueOf(snowflakeIdWorker.nextId()).substring(15, 19)); |
| | | taskDto.setTaskNo(String.valueOf(snowflakeIdWorker.nextId()).substring(15, 19)); |
| | | |
| | | param.getTaskList().add(taskDto); |
| | | param.getTasks().add(taskDto); |
| | | } |
| | | if (Cools.isEmpty(param.getTaskList())) { return; } |
| | | if (Cools.isEmpty(param.getTasks())) { return; } |
| | | |
| | | mainService.generateBusAndTask(param, memo); |
| | | } |
| | |
| | | Collections.shuffle(idleLocList); |
| | | |
| | | OpenBusSubmitParam param = new OpenBusSubmitParam(); |
| | | param.setBatch(String.valueOf(snowflakeIdWorker.nextId()).substring(13, 19)); |
| | | param.setBatchNo(String.valueOf(snowflakeIdWorker.nextId()).substring(13, 19)); |
| | | for (int i = 0; i < Math.min(maxCapacity, Math.min(stockLocList.size(), idleLocList.size())); i++) { |
| | | Loc stockLoc = stockLocList.get(i); |
| | | Loc idleLoc = idleLocList.get(i); |
| | |
| | | TaskDto taskDto = new TaskDto(); |
| | | taskDto.setOriLoc(stockLoc.getLocNo()); |
| | | taskDto.setDestLoc(idleLoc.getLocNo()); |
| | | taskDto.setSeqNum(String.valueOf(snowflakeIdWorker.nextId()).substring(15, 19)); |
| | | taskDto.setTaskNo(String.valueOf(snowflakeIdWorker.nextId()).substring(15, 19)); |
| | | |
| | | param.getTaskList().add(taskDto); |
| | | param.getTasks().add(taskDto); |
| | | } |
| | | if (Cools.isEmpty(param.getTaskList())) { return; } |
| | | if (Cools.isEmpty(param.getTasks())) { return; } |
| | | |
| | | mainService.generateBusAndTask(param, memo); |
| | | } |
| File was renamed from zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/AutoRunScheduler.java |
| | |
| | | package com.zy.acs.manager.core.scheduler; |
| | | package com.zy.acs.manager.core.scheduler.test; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.acs.common.constant.RedisConstant; |
| | |
| | | import com.zy.acs.framework.common.SnowflakeIdWorker; |
| | | import com.zy.acs.manager.common.domain.TaskDto; |
| | | import com.zy.acs.manager.core.service.*; |
| | | import com.zy.acs.manager.manager.controller.param.OpenBusSubmitParam; |
| | | import com.zy.acs.manager.core.integrate.dto.OpenBusSubmitParam; |
| | | import com.zy.acs.manager.manager.entity.*; |
| | | import com.zy.acs.manager.manager.enums.*; |
| | | import com.zy.acs.manager.manager.service.*; |
| | |
| | | // @Scheduled(cron = "0/1 * * * * ? ") |
| | | private void execute() { |
| | | if (!configService.getVal("TaskAssignMode", Boolean.class)) { return; } |
| | | Boolean maintainLocSts = configService.getVal("maintainLocSts", Boolean.class); |
| | | if (!maintainLocSts) { |
| | | log.error("failed to run auto agv task, the maintainLocSts is false"); |
| | | return; |
| | | } |
| | | AgvModel agvModel = agvModelService.getOne(new LambdaQueryWrapper<AgvModel>().eq(AgvModel::getType, DEFAULT_AGV_MODEL.toString())); |
| | | if (null == agvModel) { return; } |
| | | |
| | |
| | | Collections.shuffle(stockList); |
| | | |
| | | OpenBusSubmitParam param = new OpenBusSubmitParam(); |
| | | param.setBatch(String.valueOf(snowflakeIdWorker.nextId()).substring(13, 19)); |
| | | param.setBatchNo(String.valueOf(snowflakeIdWorker.nextId()).substring(13, 19)); |
| | | for (int i = 0; i < Math.min(agvModel.getBackpack(), stockList.size()) ; i++) { |
| | | Sta stockSta = stockList.get(i); |
| | | String staCode = codeService.getCacheById(stockSta.getCode()).getData(); |
| | |
| | | taskDto.setOriSta(stockSta.getStaNo()); |
| | | taskDto.setDestLoc(idleLoc.getLocNo()); |
| | | taskDto.setPriority(100); |
| | | taskDto.setSeqNum(String.valueOf(snowflakeIdWorker.nextId()).substring(15, 19)); |
| | | taskDto.setTaskNo(String.valueOf(snowflakeIdWorker.nextId()).substring(15, 19)); |
| | | |
| | | param.getTaskList().add(taskDto); |
| | | param.getTasks().add(taskDto); |
| | | } |
| | | if (Cools.isEmpty(param.getTaskList())) { return; } |
| | | if (Cools.isEmpty(param.getTasks())) { return; } |
| | | |
| | | mainService.generateBusAndTask(param, memo); |
| | | } |
| | |
| | | Collections.shuffle(idleList); |
| | | |
| | | OpenBusSubmitParam param = new OpenBusSubmitParam(); |
| | | param.setBatch(String.valueOf(snowflakeIdWorker.nextId()).substring(13, 19)); |
| | | param.setBatchNo(String.valueOf(snowflakeIdWorker.nextId()).substring(13, 19)); |
| | | for (int i = 0; i < Math.min(agvModel.getBackpack(), idleList.size()) ; i++) { |
| | | Sta idleSta = idleList.get(i); |
| | | String staCode = codeService.getCacheById(idleSta.getCode()).getData(); |
| | |
| | | taskDto.setOriLoc(stockLoc.getLocNo()); |
| | | taskDto.setDestSta(idleSta.getStaNo()); |
| | | taskDto.setPriority(100); |
| | | taskDto.setSeqNum(String.valueOf(snowflakeIdWorker.nextId()).substring(15, 19)); |
| | | taskDto.setTaskNo(String.valueOf(snowflakeIdWorker.nextId()).substring(15, 19)); |
| | | |
| | | param.getTaskList().add(taskDto); |
| | | param.getTasks().add(taskDto); |
| | | } |
| | | if (Cools.isEmpty(param.getTaskList())) { return; } |
| | | if (Cools.isEmpty(param.getTasks())) { return; } |
| | | |
| | | mainService.generateBusAndTask(param, memo); |
| | | } |
| | |
| | | Collections.shuffle(idleLocList); |
| | | |
| | | OpenBusSubmitParam param = new OpenBusSubmitParam(); |
| | | param.setBatch(String.valueOf(snowflakeIdWorker.nextId()).substring(13, 19)); |
| | | param.setBatchNo(String.valueOf(snowflakeIdWorker.nextId()).substring(13, 19)); |
| | | for (int i = 0; i < Math.min(maxCapacity, Math.min(stockLocList.size(), idleLocList.size())); i++) { |
| | | Loc stockLoc = stockLocList.get(i); |
| | | Loc idleLoc = idleLocList.get(i); |
| | |
| | | TaskDto taskDto = new TaskDto(); |
| | | taskDto.setOriLoc(stockLoc.getLocNo()); |
| | | taskDto.setDestLoc(idleLoc.getLocNo()); |
| | | taskDto.setSeqNum(String.valueOf(snowflakeIdWorker.nextId()).substring(15, 19)); |
| | | taskDto.setTaskNo(String.valueOf(snowflakeIdWorker.nextId()).substring(15, 19)); |
| | | |
| | | param.getTaskList().add(taskDto); |
| | | param.getTasks().add(taskDto); |
| | | } |
| | | if (Cools.isEmpty(param.getTaskList())) { return; } |
| | | if (Cools.isEmpty(param.getTasks())) { return; } |
| | | |
| | | mainService.generateBusAndTask(param, memo); |
| | | } |
| File was renamed from zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/ConveyorAutoRunScheduler.java |
| | |
| | | package com.zy.acs.manager.core.scheduler; |
| | | package com.zy.acs.manager.core.scheduler.test; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.acs.common.constant.RedisConstant; |
| | |
| | | import com.zy.acs.manager.common.domain.TaskDto; |
| | | import com.zy.acs.manager.core.service.AreaGovernService; |
| | | import com.zy.acs.manager.core.service.MainService; |
| | | import com.zy.acs.manager.manager.controller.param.OpenBusSubmitParam; |
| | | import com.zy.acs.manager.core.integrate.dto.OpenBusSubmitParam; |
| | | import com.zy.acs.manager.manager.entity.*; |
| | | import com.zy.acs.manager.manager.enums.AgvModelType; |
| | | import com.zy.acs.manager.manager.enums.BusStsType; |
| | |
| | | import java.util.*; |
| | | |
| | | @Slf4j |
| | | @Component |
| | | //@Component |
| | | public class ConveyorAutoRunScheduler { |
| | | |
| | | private static final AgvModelType DEFAULT_AGV_MODEL = AgvModelType.CTU_BOX_TRANSPORT_AGV; |
| | |
| | | Collections.shuffle(idleList); |
| | | |
| | | OpenBusSubmitParam param = new OpenBusSubmitParam(); |
| | | param.setBatch(String.valueOf(snowflakeIdWorker.nextId()).substring(13, 19)); |
| | | param.setBatchNo(String.valueOf(snowflakeIdWorker.nextId()).substring(13, 19)); |
| | | for (int i = 0; i < agvModel.getBackpack() ; i++) { |
| | | Sta idleSta = idleList.get(i); |
| | | String staCode = codeService.getCacheById(idleSta.getCode()).getData(); |
| | |
| | | taskDto.setOriLoc(stockLoc.getLocNo()); |
| | | taskDto.setDestSta(idleSta.getStaNo()); |
| | | taskDto.setPriority(100); |
| | | taskDto.setSeqNum(String.valueOf(snowflakeIdWorker.nextId()).substring(15, 19)); |
| | | taskDto.setTaskNo(String.valueOf(snowflakeIdWorker.nextId()).substring(15, 19)); |
| | | |
| | | param.getTaskList().add(taskDto); |
| | | param.getTasks().add(taskDto); |
| | | } |
| | | if (Cools.isEmpty(param.getTaskList())) { return; } |
| | | if (Cools.isEmpty(param.getTasks())) { return; } |
| | | |
| | | mainService.generateBusAndTask(param, memo); |
| | | } |
| | |
| | | import com.zy.acs.manager.core.domain.TaskPosDto; |
| | | import com.zy.acs.manager.core.integrate.conveyor.ConveyorStationService; |
| | | import com.zy.acs.manager.core.service.astart.MapDataDispatcher; |
| | | import com.zy.acs.manager.manager.controller.param.OpenBusSubmitParam; |
| | | import com.zy.acs.manager.core.integrate.dto.OpenBusSubmitParam; |
| | | import com.zy.acs.manager.manager.entity.*; |
| | | import com.zy.acs.manager.manager.enums.*; |
| | | import com.zy.acs.manager.manager.service.*; |
| | |
| | | @Transactional |
| | | public Bus generateBusAndTask(OpenBusSubmitParam busSubmitParam, String memo) { |
| | | String errorMsg = busService.checkoutValid(busSubmitParam); |
| | | Boolean maintainLocSts = configService.getVal("maintainLocSts", Boolean.class); |
| | | if (!Cools.isEmpty(errorMsg)) { |
| | | throw new BusinessException(errorMsg); |
| | | } |
| | | String batch = busSubmitParam.getBatch(); |
| | | List<TaskDto> taskDtoList = busSubmitParam.getTaskList(); |
| | | String batchNo = busSubmitParam.getBatchNo(); |
| | | List<TaskDto> taskDtoList = busSubmitParam.getTasks(); |
| | | if (Cools.isEmpty(taskDtoList)) { |
| | | throw new BusinessException("taskList can't be empty!"); |
| | | } |
| | |
| | | Date now = new Date(); |
| | | Bus bus = new Bus(); |
| | | bus.setUuid(String.valueOf(snowflakeIdWorker.nextId()).substring(3)); |
| | | bus.setBusNo(batch); |
| | | bus.setBusNo(batchNo); |
| | | bus.setStartTime(now); |
| | | bus.setBusSts(BusStsType.RECEIVE.val()); |
| | | bus.setMemo(memo); |
| | |
| | | Sta destSta = null; |
| | | switch (TaskTypeType.get(task.getTaskTypeEl())) { |
| | | case LOC_TO_LOC: |
| | | oriLoc = locService.getById(task.getOriLoc()); |
| | | if (!oriLoc.getLocSts().equals(LocStsType.STOCK.val())) { |
| | | throw new BusinessException("oriLocï¼" + task.getOriLoc$() + " is not in STOCK status"); |
| | | } |
| | | oriLoc.setLocSts(LocStsType.PAKOUT.val()); |
| | | oriLoc.setUpdateTime(now); |
| | | if (!locService.updateById(oriLoc)) { |
| | | throw new BusinessException("oriLocï¼" + task.getOriLoc$() + " failed to update"); |
| | | } |
| | | if (maintainLocSts) { |
| | | oriLoc = locService.getById(task.getOriLoc()); |
| | | if (!oriLoc.getLocSts().equals(LocStsType.STOCK.val())) { |
| | | throw new BusinessException("oriLocï¼" + task.getOriLoc$() + " is not in STOCK status"); |
| | | } |
| | | oriLoc.setLocSts(LocStsType.PAKOUT.val()); |
| | | oriLoc.setUpdateTime(now); |
| | | if (!locService.updateById(oriLoc)) { |
| | | throw new BusinessException("oriLocï¼" + task.getOriLoc$() + " failed to update"); |
| | | } |
| | | |
| | | destLoc = locService.getById(task.getDestLoc()); |
| | | if (!destLoc.getLocSts().equals(LocStsType.IDLE.val())) { |
| | | throw new BusinessException("destLocï¼" + task.getDestLoc$() + " is not in IDLE status"); |
| | | } |
| | | destLoc.setLocSts(LocStsType.PAKIN.val()); |
| | | destLoc.setUpdateTime(now); |
| | | if (!locService.updateById(destLoc)) { |
| | | throw new BusinessException("destLocï¼" + task.getDestLoc$() + " failed to update"); |
| | | destLoc = locService.getById(task.getDestLoc()); |
| | | if (!destLoc.getLocSts().equals(LocStsType.IDLE.val())) { |
| | | throw new BusinessException("destLocï¼" + task.getDestLoc$() + " is not in IDLE status"); |
| | | } |
| | | destLoc.setLocSts(LocStsType.PAKIN.val()); |
| | | destLoc.setUpdateTime(now); |
| | | if (!locService.updateById(destLoc)) { |
| | | throw new BusinessException("destLocï¼" + task.getDestLoc$() + " failed to update"); |
| | | } |
| | | } |
| | | break; |
| | | case LOC_TO_STA: |
| | | oriLoc = locService.getById(task.getOriLoc()); |
| | | if (!oriLoc.getLocSts().equals(LocStsType.STOCK.val())) { |
| | | throw new BusinessException("oriLocï¼" + task.getOriLoc$() + " is not in STOCK status"); |
| | | } |
| | | oriLoc.setLocSts(LocStsType.PAKOUT.val()); |
| | | oriLoc.setUpdateTime(now); |
| | | if (!locService.updateById(oriLoc)) { |
| | | throw new BusinessException("oriLocï¼" + task.getOriLoc$() + " failed to update"); |
| | | if (maintainLocSts) { |
| | | oriLoc = locService.getById(task.getOriLoc()); |
| | | if (!oriLoc.getLocSts().equals(LocStsType.STOCK.val())) { |
| | | throw new BusinessException("oriLocï¼" + task.getOriLoc$() + " is not in STOCK status"); |
| | | } |
| | | oriLoc.setLocSts(LocStsType.PAKOUT.val()); |
| | | oriLoc.setUpdateTime(now); |
| | | if (!locService.updateById(oriLoc)) { |
| | | throw new BusinessException("oriLocï¼" + task.getOriLoc$() + " failed to update"); |
| | | } |
| | | } |
| | | |
| | | destSta = staService.getById(task.getDestSta()); |
| | |
| | | throw new BusinessException("oriStaï¼" + task.getOriSta$() + " failed to reserve"); |
| | | } |
| | | |
| | | destLoc = locService.getById(task.getDestLoc()); |
| | | if (!destLoc.getLocSts().equals(LocStsType.IDLE.val())) { |
| | | throw new BusinessException("destLocï¼" + task.getDestLoc$() + " is not in IDLE status"); |
| | | } |
| | | destLoc.setLocSts(LocStsType.PAKIN.val()); |
| | | destLoc.setUpdateTime(now); |
| | | if (!locService.updateById(destLoc)) { |
| | | throw new BusinessException("destLocï¼" + task.getDestLoc$() + " failed to update"); |
| | | if (maintainLocSts) { |
| | | destLoc = locService.getById(task.getDestLoc()); |
| | | if (!destLoc.getLocSts().equals(LocStsType.IDLE.val())) { |
| | | throw new BusinessException("destLocï¼" + task.getDestLoc$() + " is not in IDLE status"); |
| | | } |
| | | destLoc.setLocSts(LocStsType.PAKIN.val()); |
| | | destLoc.setUpdateTime(now); |
| | | if (!locService.updateById(destLoc)) { |
| | | throw new BusinessException("destLocï¼" + task.getDestLoc$() + " failed to update"); |
| | | } |
| | | } |
| | | break; |
| | | case STA_TO_STA: |
| | |
| | | task.setPriority(taskType.equals(TaskTypeType.TO_CHARGE)?2:1); |
| | | task.setTaskSts(TaskStsType.ASSIGN.val()); |
| | | task.setTaskType(taskType.val()); |
| | | task.setUplinkSts(TaskUplinkStateType.SKIPPED.toString()); |
| | | task.setIoTime(now); |
| | | task.setStartTime(now); |
| | | if (!taskService.save(task)) { |
| | |
| | | } |
| | | |
| | | // ä½ä¸ç¹å¨ä½ |
| | | AgvDirectionType agvDirectionType; |
| | | ActuatorDirectionType actuatorDirectionType; |
| | | Double staWorkDirection; |
| | | AgvBackpackType backpackType = AgvBackpackType.query(segment.getBackpack()); |
| | | switch (Objects.requireNonNull(TaskPosDto.queryPosType(segment.getPosType()))) { |
| | |
| | | // è´§æ¶åè´§ |
| | | Loc oriLoc = locService.getById(task.getOriLoc()); |
| | | // 计ç®å·¦å³æ¹å |
| | | agvDirectionType = mapService.calculateAgvWorkDirectionByShelf(oriLoc, lastCode); |
| | | actuatorDirectionType = ActuatorDirectionType.fromVal(oriLoc.getCompDirect()); |
| | | // actuatorDirectionType = mapService.calculateAgvWorkDirectionByShelf(oriLoc, lastCode); |
| | | actionList.add(new Action( |
| | | null, // ç¼å· |
| | | task.getBusId(), // æ»çº¿ |
| | |
| | | null, // å¨ä½å· |
| | | null, // ä¼å
级 |
| | | ActionTypeType.ReadyTakeFromShelvesLoc.desc, // åç§° |
| | | (double) agvDirectionType.val, // 屿§å¼ |
| | | (double) actuatorDirectionType.val, // 屿§å¼ |
| | | lastCode.getData(), // å°é¢ç |
| | | JSON.toJSONString(new HeightDepthDto(oriLoc.getOffset())), // å¨ä½åæ° |
| | | ActionTypeType.ReadyTakeFromShelvesLoc.val(), // å¨ä½ç±»å |
| | |
| | | // è´§æ¶æ¾è´§ |
| | | Loc destLoc = locService.getById(task.getDestLoc()); |
| | | // 计ç®å·¦å³æ¹å |
| | | agvDirectionType = mapService.calculateAgvWorkDirectionByShelf(destLoc, lastCode); |
| | | actuatorDirectionType = ActuatorDirectionType.fromVal(destLoc.getCompDirect()); |
| | | // actuatorDirectionType = mapService.calculateAgvWorkDirectionByShelf(destLoc, lastCode); |
| | | actionList.add(new Action( |
| | | null, // ç¼å· |
| | | task.getBusId(), // æ»çº¿ |
| | |
| | | null, // å¨ä½å· |
| | | null, // ä¼å
级 |
| | | ActionTypeType.ReadyReleaseToShelvesLoc.desc, // åç§° |
| | | (double) agvDirectionType.val, // 屿§å¼ |
| | | (double) actuatorDirectionType.val, // 屿§å¼ |
| | | lastCode.getData(), // å°é¢ç |
| | | JSON.toJSONString(new HeightDepthDto(destLoc.getOffset())), // å¨ä½åæ° |
| | | ActionTypeType.ReadyReleaseToShelvesLoc.val(), // å¨ä½ç±»å |
| | |
| | | lastDirection = oriStaWorkDirection; |
| | | } |
| | | // 计ç®è´§å工使¹å |
| | | staWorkDirection = mapService.calculateAgvWorkDirectionByStation(oriStaWorkDirection, lastDirection); |
| | | actuatorDirectionType = ActuatorDirectionType.fromVal(oriSta.getActDir()); |
| | | // staWorkDirection = mapService.calculateAgvWorkDirectionByStation(oriStaWorkDirection, lastDirection); |
| | | actionList.add(new Action( |
| | | null, // ç¼å· |
| | | task.getBusId(), // æ»çº¿ |
| | |
| | | null, // å¨ä½å· |
| | | null, // ä¼å
级 |
| | | ActionTypeType.ReadyTakeFromConveyorSta.desc, // åç§° |
| | | staWorkDirection, // 屿§å¼ |
| | | (double) actuatorDirectionType.val, // 屿§å¼ |
| | | lastCode.getData(), // å°é¢ç |
| | | JSON.toJSONString(new HeightDepthDto(oriSta.getHeight(), Optional.ofNullable(oriSta.getDepth()).orElse((double) 0))), // å¨ä½åæ° |
| | | ActionTypeType.ReadyTakeFromConveyorSta.val(), // å¨ä½ç±»å |
| | |
| | | )); |
| | | } |
| | | // 计ç®è´§å工使¹å |
| | | staWorkDirection = mapService.calculateAgvWorkDirectionByStation(destStaWorkDirection, lastDirection); |
| | | // staWorkDirection = mapService.calculateAgvWorkDirectionByStation(destStaWorkDirection, lastDirection); |
| | | actuatorDirectionType = ActuatorDirectionType.fromVal(destSta.getActDir()); |
| | | actionList.add(new Action( |
| | | null, // ç¼å· |
| | | task.getBusId(), // æ»çº¿ |
| | |
| | | null, // å¨ä½å· |
| | | null, // ä¼å
级 |
| | | ActionTypeType.ReadyReleaseToConveyorSta.desc, // åç§° |
| | | staWorkDirection, // 屿§å¼ |
| | | (double) actuatorDirectionType.val, // 屿§å¼ |
| | | lastCode.getData(), // å°é¢ç |
| | | JSON.toJSONString(new HeightDepthDto(destSta.getHeight(), Optional.ofNullable(destSta.getDepth()).orElse((double) 0))), // å¨ä½åæ° |
| | | ActionTypeType.ReadyReleaseToConveyorSta.val(), // å¨ä½ç±»å |
| | |
| | | package com.zy.acs.manager.core.service; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.zy.acs.common.enums.AgvDirectionType; |
| | | import com.zy.acs.common.enums.ActuatorDirectionType; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.manager.core.constant.MapDataConstant; |
| | | import com.zy.acs.manager.core.domain.DirectionDto; |
| | |
| | | return angle; |
| | | } |
| | | |
| | | // åæ è´§æ¶éå¼ todo:luxiaotao |
| | | public AgvDirectionType calculateAgvWorkDirectionByShelf(Loc loc, Code code) { |
| | | // åæ è´§æ¶éå¼ |
| | | public ActuatorDirectionType calculateAgvWorkDirectionByShelf(Loc loc, Code code) { |
| | | Integer compDirect = loc.getCompDirect(); |
| | | AgvDirectionType agvDirectionType = null; |
| | | if (compDirect == 0) { |
| | | agvDirectionType = AgvDirectionType.RIGHT; |
| | | } |
| | | if (compDirect == 1) { |
| | | agvDirectionType = AgvDirectionType.LEFT; |
| | | } |
| | | return agvDirectionType; |
| | | return ActuatorDirectionType.fromVal(compDirect); |
| | | } |
| | | |
| | | public Double getStaAngle(Sta sta, Double workDirection) { |
| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.framework.common.SnowflakeIdWorker; |
| | | import com.zy.acs.manager.common.config.UplinkProperties; |
| | | import com.zy.acs.manager.common.domain.TaskDto; |
| | | import com.zy.acs.manager.common.exception.BusinessException; |
| | | import com.zy.acs.manager.manager.entity.Code; |
| | |
| | | import com.zy.acs.manager.manager.entity.Sta; |
| | | import com.zy.acs.manager.manager.entity.Task; |
| | | import com.zy.acs.manager.manager.enums.TaskTypeType; |
| | | import com.zy.acs.manager.manager.enums.TaskUplinkStateType; |
| | | import com.zy.acs.manager.manager.service.CodeService; |
| | | import com.zy.acs.manager.manager.service.LocService; |
| | | import com.zy.acs.manager.manager.service.StaService; |
| | |
| | | private MapService mapService; |
| | | @Autowired |
| | | private SnowflakeIdWorker snowflakeIdWorker; |
| | | @Autowired |
| | | private UplinkProperties uplinkProperties; |
| | | |
| | | public List<Task> validTaskDtoList(List<TaskDto> taskDtoList) { |
| | | List<Task> taskList = new ArrayList<>(); |
| | | String uplinkSts = uplinkProperties.getEnabled() ? TaskUplinkStateType.PENDING.toString() : TaskUplinkStateType.SKIPPED.toString(); |
| | | for (TaskDto taskDto : taskDtoList) { |
| | | if (Cools.isEmpty(taskDto.getSeqNum())) { |
| | | if (Cools.isEmpty(taskDto.getTaskNo())) { |
| | | throw new BusinessException("Task seqNum can't be empty!"); |
| | | } |
| | | Task task = new Task(); |
| | | taskList.add(task); |
| | | task.setUuid(String.valueOf(snowflakeIdWorker.nextId()).substring(3)); |
| | | task.setSeqNum(taskDto.getSeqNum()); |
| | | task.setSeqNum(taskDto.getTaskNo()); |
| | | task.setPriority(taskDto.getPriority()); |
| | | |
| | | // ori -------------------------- |
| | |
| | | throw new BusinessException("seqNum:" + task.getSeqNum() + " is wrongï¼oriLocï¼" + task.getOriLoc() + " is unable to reach destLoc" + task.getDestLoc()); |
| | | } |
| | | task.setPhase(JSON.toJSONString(pathList)); |
| | | task.setUplinkSts(uplinkSts); |
| | | break; |
| | | case LOC_TO_STA: |
| | | oriLoc = locService.getById(task.getOriLoc()); |
| | |
| | | throw new BusinessException("seqNum:" + task.getSeqNum() + " is wrongï¼oriLocï¼" + task.getOriLoc() + " can't move to destSta" + task.getDestSta()); |
| | | } |
| | | task.setPhase(JSON.toJSONString(pathList)); |
| | | task.setUplinkSts(uplinkSts); |
| | | break; |
| | | case STA_TO_LOC: |
| | | oriSta = staService.getById(task.getOriSta()); |
| | |
| | | throw new BusinessException("seqNum:" + task.getSeqNum() + " is wrongï¼oriStaï¼" + task.getOriSta() + " is unable to react destLoc" + task.getDestLoc()); |
| | | } |
| | | task.setPhase(JSON.toJSONString(pathList)); |
| | | task.setUplinkSts(uplinkSts); |
| | | break; |
| | | case STA_TO_STA: |
| | | oriSta = staService.getById(task.getOriSta()); |
| | |
| | | throw new BusinessException("seqNum:" + task.getSeqNum() + " is wrongï¼oriStaï¼" + task.getOriSta() + " can't move to destSta" + task.getDestSta()); |
| | | } |
| | | task.setPhase(JSON.toJSONString(pathList)); |
| | | task.setUplinkSts(uplinkSts); |
| | | break; |
| | | default: |
| | | throw new BusinessException("seqNum:" + task.getSeqNum() + " is wrongï¼ cause this type not exist"); |
| | |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.framework.common.R; |
| | | import com.zy.acs.manager.common.annotation.OperationLog; |
| | | import com.zy.acs.manager.common.constant.Constants; |
| | | import com.zy.acs.manager.common.domain.*; |
| | | import com.zy.acs.manager.common.utils.BusinessSortService; |
| | | import com.zy.acs.manager.common.utils.ExcelUtil; |
| | | import com.zy.acs.manager.core.service.MainService; |
| | | import com.zy.acs.manager.manager.controller.param.BusCreateParam; |
| | | import com.zy.acs.manager.manager.controller.param.OpenBusSubmitParam; |
| | | import com.zy.acs.manager.core.integrate.dto.OpenBusSubmitParam; |
| | | import com.zy.acs.manager.manager.entity.Bus; |
| | | import com.zy.acs.manager.manager.entity.Task; |
| | | import com.zy.acs.manager.manager.enums.BusStsType; |
| | |
| | | @PostMapping("/bus/save") |
| | | public R save(@RequestBody BusCreateParam param) { |
| | | OpenBusSubmitParam submitParam = new OpenBusSubmitParam(); |
| | | submitParam.setBatch(param.getBusNo()); |
| | | submitParam.setBatchNo(param.getBusNo()); |
| | | for (TaskIdByLongDto dto : param.getTaskList()) { |
| | | TaskDto taskDto = new TaskDto(); |
| | | taskDto.setSeqNum(dto.getSeqNum()); |
| | | taskDto.setTaskNo(dto.getSeqNum()); |
| | | taskDto.setPriority(dto.getPriority()); |
| | | if (!Cools.isEmpty(dto.getOriSta())) { |
| | | taskDto.setOriSta(staService.getById(dto.getOriSta()).getStaNo()); |
| | |
| | | if (!Cools.isEmpty(dto.getDestLoc())) { |
| | | taskDto.setDestLoc(locService.getById(dto.getDestLoc()).getLocNo()); |
| | | } |
| | | submitParam.getTaskList().add(taskDto); |
| | | submitParam.getTasks().add(taskDto); |
| | | } |
| | | Bus bus = mainService.generateBusAndTask(submitParam, param.getMemo()); |
| | | return R.ok("Save Success").add(bus); |
| | |
| | | .in(Task::getTaskSts, TaskStsType.INIT.val(), TaskStsType.WAITING.val())); |
| | | if (!Cools.isEmpty(taskList)) { |
| | | for (Task task : taskList) { |
| | | taskService.cancel(task.getId(), getLoginUserId()); |
| | | taskService.cancel(task.getId(), getLoginUserId(), Constants.HANDLE); |
| | | } |
| | | } |
| | | if (0 == taskService.count(new LambdaQueryWrapper<Task>().eq(Task::getBusId, bus.getId()).eq(Task::getTaskSts, TaskStsType.COMPLETE.val()))) { |
| | |
| | | import com.zy.acs.manager.manager.entity.Code; |
| | | import com.zy.acs.manager.manager.entity.CodeGap; |
| | | import com.zy.acs.manager.manager.entity.Route; |
| | | import com.zy.acs.manager.manager.enums.StatusType; |
| | | import com.zy.acs.manager.manager.service.CodeGapService; |
| | | import com.zy.acs.manager.manager.service.CodeService; |
| | | import com.zy.acs.manager.manager.service.RouteService; |
| | |
| | | code.setUuid("code".concat(code.getData())); |
| | | // code.setCorner(0); |
| | | code.setScale(GsonUtils.toJson(Cools.add("x", 1).add("y", 1))); |
| | | code.setStatus(StatusType.ENABLE.val); |
| | | code.setCreateBy(userId); |
| | | code.setCreateTime(now); |
| | | code.setUpdateBy(userId); |
| New file |
| | |
| | | package com.zy.acs.manager.manager.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.framework.common.R; |
| | | import com.zy.acs.manager.common.utils.ExcelUtil; |
| | | import com.zy.acs.manager.common.annotation.OperationLog; |
| | | import com.zy.acs.manager.common.domain.BaseParam; |
| | | import com.zy.acs.manager.common.domain.KeyValVo; |
| | | import com.zy.acs.manager.common.domain.PageParam; |
| | | import com.zy.acs.manager.manager.entity.IntegrationRecord; |
| | | import com.zy.acs.manager.manager.service.IntegrationRecordService; |
| | | import com.zy.acs.manager.system.controller.BaseController; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.*; |
| | | |
| | | @RestController |
| | | @RequestMapping("/api") |
| | | public class IntegrationRecordController extends BaseController { |
| | | |
| | | @Autowired |
| | | private IntegrationRecordService integrationRecordService; |
| | | |
| | | @PreAuthorize("hasAuthority('manager:integrationRecord:list')") |
| | | @PostMapping("/integrationRecord/page") |
| | | public R page(@RequestBody Map<String, Object> map) { |
| | | BaseParam baseParam = buildParam(map, BaseParam.class); |
| | | PageParam<IntegrationRecord, BaseParam> pageParam = new PageParam<>(baseParam, IntegrationRecord.class); |
| | | return R.ok().add(integrationRecordService.page(pageParam, pageParam.buildWrapper(true))); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:integrationRecord:list')") |
| | | @PostMapping("/integrationRecord/list") |
| | | public R list(@RequestBody Map<String, Object> map) { |
| | | return R.ok().add(integrationRecordService.list()); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:integrationRecord:list')") |
| | | @PostMapping({"/integrationRecord/many/{ids}", "/integrationRecords/many/{ids}"}) |
| | | public R many(@PathVariable Long[] ids) { |
| | | return R.ok().add(integrationRecordService.listByIds(Arrays.asList(ids))); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:integrationRecord:list')") |
| | | @GetMapping("/integrationRecord/{id}") |
| | | public R get(@PathVariable("id") Long id) { |
| | | return R.ok().add(integrationRecordService.getById(id)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:integrationRecord:save')") |
| | | @OperationLog("Create Integration Record") |
| | | @PostMapping("/integrationRecord/save") |
| | | public R save(@RequestBody IntegrationRecord integrationRecord) { |
| | | integrationRecord.setCreateTime(new Date()); |
| | | integrationRecord.setUpdateTime(new Date()); |
| | | if (!integrationRecordService.save(integrationRecord)) { |
| | | return R.error("Save Fail"); |
| | | } |
| | | return R.ok("Save Success").add(integrationRecord); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:integrationRecord:update')") |
| | | @OperationLog("Update Integration Record") |
| | | @PostMapping("/integrationRecord/update") |
| | | public R update(@RequestBody IntegrationRecord integrationRecord) { |
| | | integrationRecord.setUpdateTime(new Date()); |
| | | if (!integrationRecordService.updateById(integrationRecord)) { |
| | | return R.error("Update Fail"); |
| | | } |
| | | return R.ok("Update Success").add(integrationRecord); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:integrationRecord:remove')") |
| | | @OperationLog("Delete Integration Record") |
| | | @PostMapping("/integrationRecord/remove/{ids}") |
| | | public R remove(@PathVariable Long[] ids) { |
| | | if (!integrationRecordService.removeByIds(Arrays.asList(ids))) { |
| | | return R.error("Delete Fail"); |
| | | } |
| | | return R.ok("Delete Success").add(ids); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:integrationRecord:list')") |
| | | @PostMapping("/integrationRecord/query") |
| | | public R query(@RequestParam(required = false) String condition) { |
| | | List<KeyValVo> vos = new ArrayList<>(); |
| | | LambdaQueryWrapper<IntegrationRecord> wrapper = new LambdaQueryWrapper<>(); |
| | | if (!Cools.isEmpty(condition)) { |
| | | wrapper.like(IntegrationRecord::getNamespace, condition); |
| | | } |
| | | integrationRecordService.page(new Page<>(1, 30), wrapper).getRecords().forEach( |
| | | item -> vos.add(new KeyValVo(item.getId(), item.getNamespace())) |
| | | ); |
| | | return R.ok().add(vos); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:integrationRecord:list')") |
| | | @PostMapping("/integrationRecord/export") |
| | | public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { |
| | | ExcelUtil.build(ExcelUtil.create(integrationRecordService.list(), IntegrationRecord.class), response); |
| | | } |
| | | |
| | | } |
| | |
| | | package com.zy.acs.manager.manager.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.framework.common.R; |
| | | import com.zy.acs.manager.common.annotation.OperationLog; |
| | | import com.zy.acs.manager.common.constant.Constants; |
| | | import com.zy.acs.manager.common.domain.BaseParam; |
| | | import com.zy.acs.manager.common.domain.KeyValVo; |
| | | import com.zy.acs.manager.common.domain.PageParam; |
| | |
| | | import com.zy.acs.manager.manager.entity.Task; |
| | | import com.zy.acs.manager.manager.service.TaskService; |
| | | import com.zy.acs.manager.system.controller.BaseController; |
| | | import com.zy.acs.manager.system.entity.User; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | @OperationLog("Complete Task") |
| | | @GetMapping("/task/complete/{id}") |
| | | public R complete(@PathVariable Long id) { |
| | | return taskService.complete(id, getLoginUserId()) ? R.ok("Complete Success") : R.error("Complete Fail"); |
| | | return taskService.complete(id, getLoginUserId(), Constants.HANDLE) ? R.ok("Complete Success") : R.error("Complete Fail"); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:task:update')") |
| | | @OperationLog("Cancel Task") |
| | | @GetMapping("/task/cancel/{id}") |
| | | public R cancel(@PathVariable Long id) { |
| | | return taskService.cancel(id, getLoginUserId()) ? R.ok("Cancel Success") : R.error("Cancel Fail"); |
| | | return taskService.cancel(id, getLoginUserId(), Constants.HANDLE) ? R.ok("Cancel Success") : R.error("Cancel Fail"); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package com.zy.acs.manager.manager.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | | @TableName("man_integration_record") |
| | | public class IntegrationRecord implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * ID |
| | | */ |
| | | @ApiModelProperty(value= "ID") |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | /** |
| | | * ç¼å· |
| | | */ |
| | | @ApiModelProperty(value= "ç¼å·") |
| | | private String uuid; |
| | | |
| | | /** |
| | | * åç§°ç©ºé´ |
| | | */ |
| | | @ApiModelProperty(value= "å称空é´") |
| | | private String namespace; |
| | | |
| | | /** |
| | | * æ¥å£å°å |
| | | */ |
| | | @ApiModelProperty(value= "æ¥å£å°å") |
| | | private String url; |
| | | |
| | | /** |
| | | * å¹³å°å¯é¥ |
| | | */ |
| | | @ApiModelProperty(value= "å¹³å°å¯é¥") |
| | | private String appkey; |
| | | |
| | | /** |
| | | * è°ç¨æ¹æ è¯ |
| | | */ |
| | | @ApiModelProperty(value= "è°ç¨æ¹æ è¯") |
| | | private String caller; |
| | | |
| | | /** |
| | | * æ¹å 1: 被è°ç¨ 2: è°ç¨å¤é¨ |
| | | */ |
| | | @ApiModelProperty(value= "æ¹å 1: 被è°ç¨ 2: è°ç¨å¤é¨ ") |
| | | private Integer direction; |
| | | |
| | | /** |
| | | * æ¶é´æ³ |
| | | */ |
| | | @ApiModelProperty(value= "æ¶é´æ³") |
| | | private String timestamp; |
| | | |
| | | /** |
| | | * 客æ·ç«¯IP |
| | | */ |
| | | @ApiModelProperty(value= "客æ·ç«¯IP") |
| | | private String clientIp; |
| | | |
| | | /** |
| | | * 请æ±å
容 |
| | | */ |
| | | @ApiModelProperty(value= "请æ±å
容") |
| | | private String request; |
| | | |
| | | /** |
| | | * ååºå
容 |
| | | */ |
| | | @ApiModelProperty(value= "ååºå
容") |
| | | private String response; |
| | | |
| | | /** |
| | | * å¼å¸¸å
容 |
| | | */ |
| | | @ApiModelProperty(value= "å¼å¸¸å
容") |
| | | private String err; |
| | | |
| | | /** |
| | | * ç»æ 1: æå 0: 失败 |
| | | */ |
| | | @ApiModelProperty(value= "ç»æ 1: æå 0: 失败 ") |
| | | private Integer result; |
| | | |
| | | /** |
| | | * èæ¶ |
| | | */ |
| | | @ApiModelProperty(value= "èæ¶") |
| | | private Integer costMs; |
| | | |
| | | /** |
| | | * ç¶æ 1: æ£å¸¸ 0: å»ç» |
| | | */ |
| | | @ApiModelProperty(value= "ç¶æ 1: æ£å¸¸ 0: å»ç» ") |
| | | private Integer status; |
| | | |
| | | /** |
| | | * æ·»å æ¶é´ |
| | | */ |
| | | @ApiModelProperty(value= "æ·»å æ¶é´") |
| | | @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * ä¿®æ¹æ¶é´ |
| | | */ |
| | | @ApiModelProperty(value= "ä¿®æ¹æ¶é´") |
| | | @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") |
| | | private Date updateTime; |
| | | |
| | | /** |
| | | * 夿³¨ |
| | | */ |
| | | @ApiModelProperty(value= "夿³¨") |
| | | private String memo; |
| | | |
| | | public IntegrationRecord() {} |
| | | |
| | | public IntegrationRecord(String uuid,String namespace,String url,String appkey,String caller,Integer direction,String timestamp,String clientIp,String request,String response,String err,Integer result,Integer costMs,Integer status,Date createTime,Date updateTime,String memo) { |
| | | this.uuid = uuid; |
| | | this.namespace = namespace; |
| | | this.url = url; |
| | | this.appkey = appkey; |
| | | this.caller = caller; |
| | | this.direction = direction; |
| | | this.timestamp = timestamp; |
| | | this.clientIp = clientIp; |
| | | this.request = request; |
| | | this.response = response; |
| | | this.err = err; |
| | | this.result = result; |
| | | this.costMs = costMs; |
| | | this.status = status; |
| | | this.createTime = createTime; |
| | | this.updateTime = updateTime; |
| | | this.memo = memo; |
| | | } |
| | | |
| | | // IntegrationRecord integrationRecord = new IntegrationRecord( |
| | | // null, // ç¼å· |
| | | // null, // åç§°ç©ºé´ |
| | | // null, // æ¥å£å°å |
| | | // null, // å¹³å°å¯é¥ |
| | | // null, // è°ç¨æ¹æ è¯ |
| | | // null, // æ¹å[é空] |
| | | // null, // æ¶é´æ³ |
| | | // null, // 客æ·ç«¯IP |
| | | // null, // 请æ±å
容 |
| | | // null, // ååºå
容 |
| | | // null, // å¼å¸¸å
容 |
| | | // null, // ç»æ |
| | | // null, // èæ¶ |
| | | // null, // ç¶æ |
| | | // null, // æ·»å æ¶é´[é空] |
| | | // null, // ä¿®æ¹æ¶é´[é空] |
| | | // null // 夿³¨ |
| | | // ); |
| | | |
| | | public Boolean getResultBool(){ |
| | | if (null == this.result){ return null; } |
| | | switch (this.result){ |
| | | case 1: |
| | | return true; |
| | | case 0: |
| | | return false; |
| | | default: |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | public Boolean getStatusBool(){ |
| | | if (null == this.status){ return null; } |
| | | switch (this.status){ |
| | | case 1: |
| | | return true; |
| | | case 0: |
| | | return false; |
| | | default: |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | private Long code; |
| | | |
| | | /** |
| | | * æ¯ç æ¹åé 1: å¤§äº 0 å°äº |
| | | * æ¯ç æ¹åé |
| | | */ |
| | | @ApiModelProperty(value= "æ¯ç æ¹åé 1: å¤§äº 0 å°äº") |
| | | @ApiModelProperty(value= "æ¯ç æ¹åé") |
| | | private Integer compDirect; |
| | | |
| | | /** |
| | |
| | | @ApiModelProperty(value= "ä½ä¸è§åº¦") |
| | | private String angle; |
| | | |
| | | @ApiModelProperty(value= "è´§åæ¹å") |
| | | private Integer actDir; |
| | | |
| | | @ApiModelProperty(value= "è¿ç»å
¥åºçå¾
(ms)") |
| | | private Integer inboundWait; |
| | | |
| | |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * ID |
| | | */ |
| | | @ApiModelProperty(value= "ID") |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | /** |
| | | * ç¼å· |
| | | */ |
| | | @ApiModelProperty(value= "ç¼å·") |
| | | private String uuid; |
| | | |
| | | /** |
| | | * æ»çº¿ |
| | | */ |
| | | @ApiModelProperty(value= "æ»çº¿") |
| | | private Long busId; |
| | | |
| | | /** |
| | | * ä»»å¡å· |
| | | */ |
| | | @ApiModelProperty(value= "ä»»å¡å·") |
| | | private String seqNum; |
| | | |
| | | /** |
| | | * ä¼å
级 |
| | | */ |
| | | @ApiModelProperty(value= "ä¼å
级") |
| | | private Integer priority; |
| | | |
| | | /** |
| | | * åç§° |
| | | */ |
| | | @ApiModelProperty(value= "åç§°") |
| | | private String name; |
| | | |
| | | /** |
| | | * ä»»å¡è¿åº¦ |
| | | */ |
| | | @ApiModelProperty(value= "ä»»å¡è¿åº¦") |
| | | private Long taskSts; |
| | | |
| | | /** |
| | | * ä»»å¡ç±»å |
| | | */ |
| | | @ApiModelProperty(value= "ä»»å¡ç±»å") |
| | | private Long taskType; |
| | | |
| | | /** |
| | | * AGV |
| | | */ |
| | | @ApiModelProperty(value= "AGV") |
| | | private Long agvId; |
| | | |
| | | /** |
| | | * 工使¶é´ |
| | | */ |
| | | @ApiModelProperty(value= "工使¶é´") |
| | | private Date ioTime; |
| | | |
| | | /** |
| | | * å¼å§æ¶é´ |
| | | */ |
| | | @ApiModelProperty(value= "å¼å§æ¶é´") |
| | | private Date startTime; |
| | | |
| | | /** |
| | | * ç»ææ¶é´ |
| | | */ |
| | | @ApiModelProperty(value= "ç»ææ¶é´") |
| | | private Date endTime; |
| | | |
| | | /** |
| | | * å¼å¸¸æ¶é´ |
| | | */ |
| | | @ApiModelProperty(value= "å¼å¸¸æ¶é´") |
| | | private Date errTime; |
| | | |
| | | /** |
| | | * èµ·å§ç« |
| | | */ |
| | | @ApiModelProperty(value= "èµ·å§ç«") |
| | | private Long oriSta; |
| | | |
| | | /** |
| | | * èµ·å§åºä½ |
| | | */ |
| | | @ApiModelProperty(value= "èµ·å§åºä½") |
| | | private Long oriLoc; |
| | | |
| | | /** |
| | | * èµ·å§ç |
| | | */ |
| | | @ApiModelProperty(value= "èµ·å§ç ") |
| | | private Long oriCode; |
| | | |
| | | /** |
| | | * èµ·å§å··éåå¸ |
| | | */ |
| | | @ApiModelProperty(value= "èµ·å§å··éåå¸") |
| | | private String oriLaneHash; |
| | | |
| | | /** |
| | | * ç®æ ç« |
| | | */ |
| | | @ApiModelProperty(value= "ç®æ ç«") |
| | | private Long destSta; |
| | | |
| | | /** |
| | | * ç®æ åºä½ |
| | | */ |
| | | @ApiModelProperty(value= "ç®æ åºä½") |
| | | private Long destLoc; |
| | | |
| | | /** |
| | | * ç®æ ç |
| | | */ |
| | | @ApiModelProperty(value= "ç®æ ç ") |
| | | private Long destCode; |
| | | |
| | | /** |
| | | * ç®æ å··éåå¸ |
| | | */ |
| | | @ApiModelProperty(value= "ç®æ å··éåå¸") |
| | | private String destLaneHash; |
| | | |
| | | /** |
| | | * ç©ºæ¿ |
| | | */ |
| | | @ApiModelProperty(value= "空æ¿") |
| | | private String emptyMk; |
| | | |
| | | /** |
| | | * æçç |
| | | */ |
| | | @ApiModelProperty(value= "ä¸è¡ç¶æ") |
| | | private String uplinkSts; |
| | | |
| | | @ApiModelProperty(value= "æçç ") |
| | | private String zpallet; |
| | | |
| | | /** |
| | | * ç¯è |
| | | */ |
| | | @ApiModelProperty(value= "ç¯è") |
| | | private String phase; |
| | | |
| | | /** |
| | | * å¼å¸¸æè¿° |
| | | */ |
| | | @ApiModelProperty(value= "å¼å¸¸æè¿°") |
| | | private String errDesc; |
| | | |
| | | /** |
| | | * ç¶æ 1: æ£å¸¸ 0: å»ç» |
| | | */ |
| | | @ApiModelProperty(value= "ç¶æ 1: æ£å¸¸ 0: å»ç» ") |
| | | private Integer status; |
| | | |
| | | /** |
| | | * æ¯å¦å é¤ 1: æ¯ 0: å¦ |
| | | */ |
| | | @ApiModelProperty(value= "æ¯å¦å é¤ 1: æ¯ 0: å¦ ") |
| | | private Integer deleted; |
| | | |
| | | /** |
| | | * ç§æ· |
| | | */ |
| | | @ApiModelProperty(value= "ç§æ·") |
| | | private Long tenantId; |
| | | |
| | | /** |
| | | * æ·»å 人å |
| | | */ |
| | | @ApiModelProperty(value= "æ·»å 人å") |
| | | private Long createBy; |
| | | |
| | | /** |
| | | * æ·»å æ¶é´ |
| | | */ |
| | | @ApiModelProperty(value= "æ·»å æ¶é´") |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * ä¿®æ¹äººå |
| | | */ |
| | | @ApiModelProperty(value= "ä¿®æ¹äººå") |
| | | private Long updateBy; |
| | | |
| | | /** |
| | | * ä¿®æ¹æ¶é´ |
| | | */ |
| | | @ApiModelProperty(value= "ä¿®æ¹æ¶é´") |
| | | private Date updateTime; |
| | | |
| | | /** |
| | | * 夿³¨ |
| | | */ |
| | | @ApiModelProperty(value= "夿³¨") |
| | | private String memo; |
| | | |
| New file |
| | |
| | | package com.zy.acs.manager.manager.enums; |
| | | |
| | | public enum IntegrationDirectionType { |
| | | |
| | | NONE(0), // æªç¥ |
| | | INBOUND(1), // æ¥æ¶ |
| | | OUTBOUND(2), // è°ç¨ |
| | | ; |
| | | |
| | | public int value; |
| | | |
| | | IntegrationDirectionType(int value) { |
| | | this.value = value; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package com.zy.acs.manager.manager.enums; |
| | | |
| | | import com.zy.acs.framework.common.Cools; |
| | | |
| | | public enum TaskUplinkStateType { |
| | | |
| | | NONE, // æªç¥ |
| | | PENDING, // å¾
䏿¥ |
| | | SENDING, // 䏿¥ä¸ |
| | | SUCCESS, // æå |
| | | FAILED, // 失败 |
| | | |
| | | SKIPPED, // è·³è¿ |
| | | ; |
| | | |
| | | public static TaskUplinkStateType of(String state) { |
| | | if (Cools.isEmpty(state)) { |
| | | return NONE; |
| | | } |
| | | for (TaskUplinkStateType type : TaskUplinkStateType.values()) { |
| | | if (type.toString().equals(state)) { |
| | | return type; |
| | | } |
| | | } |
| | | return NONE; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package com.zy.acs.manager.manager.mapper; |
| | | |
| | | import com.zy.acs.manager.manager.entity.IntegrationRecord; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | @Mapper |
| | | @Repository |
| | | public interface IntegrationRecordMapper extends BaseMapper<IntegrationRecord> { |
| | | |
| | | } |
| | |
| | | package com.zy.acs.manager.manager.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.zy.acs.manager.manager.controller.param.OpenBusSubmitParam; |
| | | import com.zy.acs.manager.core.integrate.dto.OpenBusSubmitParam; |
| | | import com.zy.acs.manager.manager.entity.Bus; |
| | | import com.zy.acs.manager.manager.enums.BusStsType; |
| | | |
| | |
| | | |
| | | public interface BusService extends IService<Bus> { |
| | | |
| | | Bus selectByBusNo(String busNo); |
| | | |
| | | Bus selectByUuid(String uuid); |
| | | |
| | | String checkoutValid(OpenBusSubmitParam param); |
| New file |
| | |
| | | package com.zy.acs.manager.manager.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.zy.acs.manager.manager.entity.IntegrationRecord; |
| | | |
| | | public interface IntegrationRecordService extends IService<IntegrationRecord> { |
| | | |
| | | Boolean syncRecord(IntegrationRecord record); |
| | | |
| | | } |
| | |
| | | |
| | | Task pick(TaskStsType taskStsType); |
| | | |
| | | Task selectByUuid(String uuid); |
| | | Task selectBySeqNum(Long busId, String seqNum); |
| | | |
| | | List<Task> selectBySts(TaskStsType taskStsType); |
| | | |
| | |
| | | |
| | | List<Map<String, Object>> selectStatByLastSevenDays(); |
| | | |
| | | Boolean complete(Long taskId, Long userId); |
| | | Boolean complete(Long taskId, Long userId, String from); |
| | | |
| | | Boolean cancel(Long taskId, Long userId); |
| | | Boolean cancel(Long taskId, Long userId, String from); |
| | | |
| | | LaneDto checkoutOriginLane(Task task); |
| | | |
| | |
| | | import com.zy.acs.framework.common.BaseRes; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.framework.exception.CoolException; |
| | | import com.zy.acs.manager.common.constant.Constants; |
| | | import com.zy.acs.manager.common.domain.TaskDto; |
| | | import com.zy.acs.manager.manager.controller.param.OpenBusSubmitParam; |
| | | import com.zy.acs.manager.core.integrate.dto.OpenBusSubmitParam; |
| | | import com.zy.acs.manager.manager.entity.Bus; |
| | | import com.zy.acs.manager.manager.entity.Loc; |
| | | import com.zy.acs.manager.manager.entity.Task; |
| | |
| | | private LocService locService; |
| | | |
| | | @Override |
| | | public Bus selectByBusNo(String busNo) { |
| | | if (Cools.isEmpty(busNo)) { |
| | | return null; |
| | | } |
| | | return this.getOne(new LambdaQueryWrapper<Bus>().eq(Bus::getBusNo, busNo).last(Constants.LIMIT_ONE)); |
| | | } |
| | | |
| | | @Override |
| | | public Bus selectByUuid(String uuid) { |
| | | return this.getOne(new LambdaQueryWrapper<Bus>().eq(Bus::getUuid, uuid)); |
| | | } |
| | |
| | | if (Cools.isEmpty(param)) { |
| | | return; |
| | | } |
| | | List<TaskDto> taskList = param.getTaskList(); |
| | | List<TaskDto> taskList = param.getTasks(); |
| | | if (Cools.isEmpty(taskList)) { |
| | | return; |
| | | } |
| | |
| | | if (null == param) { |
| | | return BaseRes.PARAM; |
| | | } |
| | | if (Cools.isEmpty(param.getBatch())) { |
| | | if (Cools.isEmpty(param.getBatchNo())) { |
| | | return "Batch cannot be empty!"; |
| | | } |
| | | this.test(param); |
| | |
| | | Set<String> oriLocNoSet = new HashSet<>(); |
| | | Set<String> destStaNoSet = new HashSet<>(); |
| | | Set<String> destLocNoSet = new HashSet<>(); |
| | | for (TaskDto dto : param.getTaskList()) { |
| | | for (TaskDto dto : param.getTasks()) { |
| | | if (!Cools.isEmpty(dto.getOriSta()) && !Cools.isEmpty(dto.getOriLoc())) { |
| | | return "OriSta and OriLoc cannot exist at the same time!"; |
| | | } |
| | |
| | | destLocNoSet.add(dto.getDestLoc()); |
| | | } |
| | | } |
| | | if (Cools.isEmpty(dto.getSeqNum())) { |
| | | dto.setSeqNum(taskService.generateSeqNum()); |
| | | if (Cools.isEmpty(dto.getTaskNo())) { |
| | | dto.setTaskNo(taskService.generateSeqNum()); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package com.zy.acs.manager.manager.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.zy.acs.framework.common.R; |
| | | import com.zy.acs.manager.core.service.ThreadPoolRegulator; |
| | | import com.zy.acs.manager.manager.mapper.IntegrationRecordMapper; |
| | | import com.zy.acs.manager.manager.entity.IntegrationRecord; |
| | | import com.zy.acs.manager.manager.service.IntegrationRecordService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.concurrent.CompletableFuture; |
| | | |
| | | @Slf4j |
| | | @Service("integrationRecordService") |
| | | public class IntegrationRecordServiceImpl extends ServiceImpl<IntegrationRecordMapper, IntegrationRecord> implements IntegrationRecordService { |
| | | |
| | | @Autowired |
| | | private ThreadPoolRegulator threadPoolRegulator; |
| | | |
| | | @Override |
| | | public Boolean syncRecord(IntegrationRecord record) { |
| | | CompletableFuture<?> completableFuture = CompletableFuture.supplyAsync(() -> { |
| | | |
| | | if (!this.save(record)) { |
| | | log.error("failed to save record {}", JSON.toJSONString(record)); |
| | | } |
| | | // mapDataDispatcher.modifyDynamicMatrix(null, null, param.getAgvNo(), true); |
| | | // avoidWaveCalculator.calcDynamicNodeByVehicle(agv, null); |
| | | return R.ok(); |
| | | }, threadPoolRegulator.getInstance()); |
| | | |
| | | return true; |
| | | } |
| | | |
| | | } |
| | |
| | | import com.zy.acs.manager.manager.enums.*; |
| | | import com.zy.acs.manager.manager.mapper.TaskMapper; |
| | | import com.zy.acs.manager.manager.service.*; |
| | | import com.zy.acs.manager.system.service.ConfigService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | private ActionService actionService; |
| | | @Autowired |
| | | private TravelService travelService; |
| | | @Autowired |
| | | private ConfigService configService; |
| | | |
| | | @Override |
| | | public PageResult<Task> pageRel(PageParam<Task, BaseParam> pageParam) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Task selectByUuid(String uuid) { |
| | | return this.getOne(new LambdaQueryWrapper<Task>().eq(Task::getUuid, uuid)); |
| | | public Task selectBySeqNum(Long busId, String seqNum) { |
| | | if (Cools.isEmpty(seqNum)) { |
| | | return null; |
| | | } |
| | | LambdaQueryWrapper<Task> wrapper = new LambdaQueryWrapper<>(); |
| | | if (null != busId) { |
| | | wrapper.eq(Task::getBusId, busId); |
| | | } |
| | | wrapper.eq(Task::getSeqNum, seqNum); |
| | | return this.getOne(wrapper.last(Constants.LIMIT_ONE)); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public Boolean complete(Long taskId, Long userId) { |
| | | public Boolean complete(Long taskId, Long userId, String from) { |
| | | Task task = this.getById(taskId); |
| | | if (null == task) { |
| | | return Boolean.FALSE; |
| | |
| | | task.setTaskSts(TaskStsType.COMPLETE.val()); |
| | | task.setUpdateTime(now); |
| | | task.setUpdateBy(userId); |
| | | task.setMemo(Constants.HANDLE + " " + TaskStsType.COMPLETE); |
| | | task.setMemo(from + " " + TaskStsType.COMPLETE); |
| | | if (!this.updateById(task)) { |
| | | throw new CoolException(BaseRes.ERROR); |
| | | } |
| | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public Boolean cancel(Long taskId, Long userId) { |
| | | public Boolean cancel(Long taskId, Long userId, String from) { |
| | | Task task = this.getById(taskId); |
| | | if (null == task) { |
| | | return Boolean.FALSE; |
| | |
| | | task.setTaskSts(TaskStsType.CANCEL.val()); |
| | | task.setUpdateTime(now); |
| | | task.setUpdateBy(userId); |
| | | task.setMemo(Constants.HANDLE + " " + TaskStsType.CANCEL); |
| | | task.setMemo(from + " " + TaskStsType.CANCEL); |
| | | if (!this.updateById(task)) { |
| | | throw new CoolException(BaseRes.ERROR); |
| | | } |
| | |
| | | if (!task.getTaskSts().equals(TaskStsType.COMPLETE.val())) { |
| | | return; |
| | | } |
| | | Boolean maintainLocSts = configService.getVal("maintainLocSts", Boolean.class); |
| | | Date now = new Date(); |
| | | // loc status |
| | | Loc oriLoc = null; |
| | |
| | | Sta destSta = null; |
| | | switch (Objects.requireNonNull(TaskTypeType.get(task.getTaskTypeEl()))) { |
| | | case LOC_TO_LOC: |
| | | oriLoc = locService.getById(task.getOriLoc()); |
| | | if (oriLoc.getLocSts().equals(LocStsType.PAKOUT.val())) { |
| | | oriLoc.setLocSts(LocStsType.IDLE.val()); |
| | | oriLoc.setUpdateTime(now); |
| | | if (!locService.updateById(oriLoc)) { |
| | | log.error("Loc [{}] åºä½ä¿®æ¹ç¶æå¤±è´¥", task.getOriLoc$()); |
| | | if (maintainLocSts) { |
| | | oriLoc = locService.getById(task.getOriLoc()); |
| | | if (oriLoc.getLocSts().equals(LocStsType.PAKOUT.val())) { |
| | | oriLoc.setLocSts(LocStsType.IDLE.val()); |
| | | oriLoc.setUpdateTime(now); |
| | | if (!locService.updateById(oriLoc)) { |
| | | log.error("Loc [{}] åºä½ä¿®æ¹ç¶æå¤±è´¥", task.getOriLoc$()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | destLoc = locService.getById(task.getDestLoc()); |
| | | if (destLoc.getLocSts().equals(LocStsType.PAKIN.val())) { |
| | | destLoc.setLocSts(LocStsType.STOCK.val()); |
| | | destLoc.setUpdateTime(now); |
| | | if (!locService.updateById(destLoc)) { |
| | | log.error("Loc [{}] åºä½ä¿®æ¹ç¶æå¤±è´¥", task.getDestLoc$()); |
| | | destLoc = locService.getById(task.getDestLoc()); |
| | | if (destLoc.getLocSts().equals(LocStsType.PAKIN.val())) { |
| | | destLoc.setLocSts(LocStsType.STOCK.val()); |
| | | destLoc.setUpdateTime(now); |
| | | if (!locService.updateById(destLoc)) { |
| | | log.error("Loc [{}] åºä½ä¿®æ¹ç¶æå¤±è´¥", task.getDestLoc$()); |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | case LOC_TO_STA: |
| | | oriLoc = locService.getById(task.getOriLoc()); |
| | | if (oriLoc.getLocSts().equals(LocStsType.PAKOUT.val())) { |
| | | oriLoc.setLocSts(LocStsType.IDLE.val()); |
| | | oriLoc.setUpdateTime(now); |
| | | if (!locService.updateById(oriLoc)) { |
| | | log.error("Loc [{}] åºä½ä¿®æ¹ç¶æå¤±è´¥", task.getOriLoc$()); |
| | | if (maintainLocSts) { |
| | | oriLoc = locService.getById(task.getOriLoc()); |
| | | if (oriLoc.getLocSts().equals(LocStsType.PAKOUT.val())) { |
| | | oriLoc.setLocSts(LocStsType.IDLE.val()); |
| | | oriLoc.setUpdateTime(now); |
| | | if (!locService.updateById(oriLoc)) { |
| | | log.error("Loc [{}] åºä½ä¿®æ¹ç¶æå¤±è´¥", task.getOriLoc$()); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | oriSta = staService.getById(task.getOriSta()); |
| | | staReserveService.confirmStaReserve(oriSta, task, 1, StaReserveType.OUT); |
| | | |
| | | destLoc = locService.getById(task.getDestLoc()); |
| | | if (destLoc.getLocSts().equals(LocStsType.PAKIN.val())) { |
| | | destLoc.setLocSts(LocStsType.STOCK.val()); |
| | | destLoc.setUpdateTime(now); |
| | | if (!locService.updateById(destLoc)) { |
| | | log.error("Loc [{}] åºä½ä¿®æ¹ç¶æå¤±è´¥", task.getDestLoc$()); |
| | | if (maintainLocSts) { |
| | | destLoc = locService.getById(task.getDestLoc()); |
| | | if (destLoc.getLocSts().equals(LocStsType.PAKIN.val())) { |
| | | destLoc.setLocSts(LocStsType.STOCK.val()); |
| | | destLoc.setUpdateTime(now); |
| | | if (!locService.updateById(destLoc)) { |
| | | log.error("Loc [{}] åºä½ä¿®æ¹ç¶æå¤±è´¥", task.getDestLoc$()); |
| | | } |
| | | } |
| | | } |
| | | break; |
| | |
| | | public void maintainLocAndStaHandler(Task task, Boolean complete) { |
| | | Loc oriLoc = null; Loc destLoc = null; |
| | | Sta oriSta = null; Sta destSta = null; |
| | | Boolean maintainLocSts = configService.getVal("maintainLocSts", Boolean.class); |
| | | Date now = new Date(); |
| | | TaskTypeType typeType = TaskTypeType.get(task.getTaskTypeEl()); |
| | | switch (Objects.requireNonNull(typeType)) { |
| | | case LOC_TO_LOC: |
| | | oriLoc = locService.getById(task.getOriLoc()); |
| | | destLoc = locService.getById(task.getDestLoc()); |
| | | if (maintainLocSts) { |
| | | oriLoc = locService.getById(task.getOriLoc()); |
| | | destLoc = locService.getById(task.getDestLoc()); |
| | | |
| | | oriLoc.setLocSts(complete?LocStsType.IDLE.val():LocStsType.STOCK.val()); |
| | | oriLoc.setUpdateTime(now); |
| | | if (!locService.updateById(oriLoc)) { |
| | | throw new BusinessException("Loc [" + oriLoc.getLocNo() + "] åºä½ä¿®æ¹ç¶æå¤±è´¥ ï¼ï¼ï¼"); |
| | | } |
| | | oriLoc.setLocSts(complete?LocStsType.IDLE.val():LocStsType.STOCK.val()); |
| | | oriLoc.setUpdateTime(now); |
| | | if (!locService.updateById(oriLoc)) { |
| | | throw new BusinessException("Loc [" + oriLoc.getLocNo() + "] åºä½ä¿®æ¹ç¶æå¤±è´¥ ï¼ï¼ï¼"); |
| | | } |
| | | |
| | | destLoc.setLocSts(complete?LocStsType.STOCK.val():LocStsType.IDLE.val()); |
| | | destLoc.setUpdateTime(now); |
| | | if (!locService.updateById(destLoc)) { |
| | | throw new BusinessException("Loc [" + destLoc.getLocNo() + "] åºä½ä¿®æ¹ç¶æå¤±è´¥ ï¼ï¼ï¼"); |
| | | destLoc.setLocSts(complete?LocStsType.STOCK.val():LocStsType.IDLE.val()); |
| | | destLoc.setUpdateTime(now); |
| | | if (!locService.updateById(destLoc)) { |
| | | throw new BusinessException("Loc [" + destLoc.getLocNo() + "] åºä½ä¿®æ¹ç¶æå¤±è´¥ ï¼ï¼ï¼"); |
| | | } |
| | | } |
| | | break; |
| | | case LOC_TO_STA: |
| | | oriLoc = locService.getById(task.getOriLoc()); |
| | | oriLoc.setLocSts(complete?LocStsType.IDLE.val():LocStsType.STOCK.val()); |
| | | oriLoc.setUpdateTime(now); |
| | | if (!locService.updateById(oriLoc)) { |
| | | throw new BusinessException("Loc [" + oriLoc.getLocNo() + "] åºä½ä¿®æ¹ç¶æå¤±è´¥ ï¼ï¼ï¼"); |
| | | if (maintainLocSts) { |
| | | oriLoc = locService.getById(task.getOriLoc()); |
| | | oriLoc.setLocSts(complete?LocStsType.IDLE.val():LocStsType.STOCK.val()); |
| | | oriLoc.setUpdateTime(now); |
| | | if (!locService.updateById(oriLoc)) { |
| | | throw new BusinessException("Loc [" + oriLoc.getLocNo() + "] åºä½ä¿®æ¹ç¶æå¤±è´¥ ï¼ï¼ï¼"); |
| | | } |
| | | } |
| | | |
| | | destSta = staService.getById(task.getDestSta()); |
| | |
| | | staReserveService.cancelStaReserve(oriSta, task, 1, StaReserveType.OUT); |
| | | } |
| | | |
| | | destLoc = locService.getById(task.getDestLoc()); |
| | | destLoc.setLocSts(complete?LocStsType.STOCK.val():LocStsType.IDLE.val()); |
| | | destLoc.setUpdateTime(now); |
| | | if (!locService.updateById(destLoc)) { |
| | | throw new BusinessException("Loc [" + destLoc.getLocNo() + "] åºä½ä¿®æ¹ç¶æå¤±è´¥ ï¼ï¼ï¼"); |
| | | if (maintainLocSts) { |
| | | destLoc = locService.getById(task.getDestLoc()); |
| | | destLoc.setLocSts(complete?LocStsType.STOCK.val():LocStsType.IDLE.val()); |
| | | destLoc.setUpdateTime(now); |
| | | if (!locService.updateById(destLoc)) { |
| | | throw new BusinessException("Loc [" + destLoc.getLocNo() + "] åºä½ä¿®æ¹ç¶æå¤±è´¥ ï¼ï¼ï¼"); |
| | | } |
| | | } |
| | | break; |
| | | case STA_TO_STA: |
| New file |
| | |
| | | -- save integrationRecord record |
| | | -- mysql |
| | | -- SwapHorizontalCircle |
| | | insert into `sys_menu` ( `name`, `parent_id`, `route`, `component`, `type`, `sort`, `tenant_id`, `status`) values ( 'menu.integrationRecord', '0', '/manager/integrationRecord', 'integrationRecord', '0' , '5', '1' , '1'); |
| | | |
| | | insert into `sys_menu` ( `name`, `parent_id`, `type`, `authority`, `sort`, `tenant_id`, `status`) values ( 'Query Integration Record', '', '1', 'manager:integrationRecord:list', '0', '1', '1'); |
| | | insert into `sys_menu` ( `name`, `parent_id`, `type`, `authority`, `sort`, `tenant_id`, `status`) values ( 'Delete Integration Record', '', '1', 'manager:integrationRecord:remove', '3', '1', '1'); |
| | |
| | | convey-plc: |
| | | host: 10.10.10.222 |
| | | port: 9090 |
| | | timeout: 15000 |
| | | url: /cv/station/query |
| | | |
| | | uplink: |
| | | enabled: true |
| | | host: 10.10.10.251 |
| | | port: 8082 |
| | | timeout: 30000 |
| | | url: /rsf-open-api/rcs/api/open/task/report |
| | | |
| | | floyd: |
| | | enable: false |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.zy.acs.manager.manager.mapper.IntegrationRecordMapper"> |
| | | |
| | | </mapper> |
| | |
| | | <if test="param.timeEnd != null"> |
| | | and a.create_time < #{param.timeEnd} |
| | | </if> |
| | | <if test="param.uplinkSts != null"> |
| | | AND a.uplink_sts = #{param.uplinkSts} |
| | | </if> |
| | | <if test="param.keywords != null"> |
| | | AND ( |
| | | a.memo LIKE CONCAT('%', #{param.keywords}, '%') |