1、update framework
2、转移数据平台和模型管理代码
对比新文件 |
| | |
| | | version: '1.0' |
| | | services: |
| | | #项目名称,用docker-compose做管理时,每个项目用这里配置的名称进行单独管理 |
| | | ## mysql |
| | | mysql-db: |
| | | # 指定容器的名称 |
| | | container_name: mysql |
| | | # 指定镜像和版本 |
| | | image: mysql:8.0 |
| | | ports: |
| | | - "3306:3306" |
| | | restart: always |
| | | environment: |
| | | # 配置root密码 |
| | | MYSQL_ROOT_PASSWORD: 123456 |
| | | volumes: |
| | | # 挂载数据目录 |
| | | - "/sda2/mysql/data:/var/lib/mysql" |
| | | # 挂载配置文件目录 |
| | | - "/sda2/mysql/conf:/etc/mysql/conf.d" |
| | | ## redis |
| | | redis: |
| | | image: redis:latest |
| | | container_name: redis |
| | | restart: always |
| | | ports: |
| | | - 6379:6379 |
| | | volumes: |
| | | - ./redis-data:/data:rw |
| | | ## nacos |
| | | nacos: |
| | | # 根据需要修改版本 |
| | | image: nacos/nacos-server:2.3.2 |
| | | container_name: nacos-standalone |
| | | restart: always |
| | | environment: |
| | | - PREFER_HOST_MODE=hostname |
| | | - MODE=standalone |
| | | volumes: |
| | | - ./nacos/logs/:/home/nacos/logs |
| | | - ./nacos/data/:/home/nacos/data |
| | | ports: |
| | | - "8848:8848" |
| | | depends_on: |
| | | - mysql |
| | | healthcheck: |
| | | test: ["CMD","curl","-f","http://localhost:8848/nacos"] |
| | | interval: 10s |
| | | timeout: 30s |
| | | retries: 3 |
| | | ## xxl-job |
| | | xxl-job: |
| | | # 根据需要修改版本 |
| | | image: xxl-job:latest |
| | | container_name: xxl-job |
| | | restart: always |
| | | volumes: |
| | | - /sda2/iailab/iailab-platform/xxl-job/logs/:/data/applogs |
| | | ports: |
| | | - "9090:9090" |
| | | depends_on: |
| | | - mysql |
| | | # gateway: |
| | | # #镜像名,拉取镜像时也是用这个名字作为地址 |
| | | # image: ic-gateway |
| | | # container_name: ic-gateway |
| | | # #打包路径,即docker build的路径 |
| | | # build: ./api/gateway/ |
| | | # restart: always |
| | | # #环境变量 |
| | | # environment: |
| | | # CONFIG_SERVER: 172.19.188.43:8848 #配置中心地址 |
| | | # #挂载目录 |
| | | # volumes: |
| | | # - /etc/localtime:/etc/localtime:ro #时间同步 |
| | | # - ./api/gateway-lib:/home/beex-gateway/lib |
| | | # - ./api/gateway/:/home/beex-gateway |
| | | # - ./logs:/logs |
| | | # #开放端口 |
| | | # ports: |
| | | # - "9990:9000" |
| | | # - "9777:8777" |
| | | # networks: |
| | | # - 246-multi-tenant |
| | | # depends_on: |
| | | # nacos: |
| | | # condition: service_healthy |
| | | # healthcheck: |
| | | # test: ["CMD","curl","-S","http://localhost:9000/doc.html#/beex-api-gateway/authenticate-controller/authenticateUsingGET"] |
| | | # interval: 20s |
| | | # timeout: 30s |
| | | # retries: 3 |
| | | # start_period: 20s |
对比新文件 |
| | |
| | | --- #################### 注册中心 + 配置中心相关配置 #################### |
| | | spring: |
| | | cloud: |
| | | nacos: |
| | | server-addr: 127.0.0.1:8848 # Nacos 服务器地址 |
| | | username: nacos |
| | | password: nacos |
| | | discovery: # 【配置中心】配置项 |
| | | namespace: a7112341-c9e2-4177-bc5b-0d2e8cf0b3bb # 命名空间。这里使用 dev 开发环境 |
| | | group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP |
| | | config: # 【注册中心】配置项 |
| | | namespace: a7112341-c9e2-4177-bc5b-0d2e8cf0b3bb # 命名空间。这里使用 dev 开发环境 |
| | | group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP |
对比新文件 |
| | |
| | | .idea |
| | | .classpath |
| | | .project |
| | | *.iml |
| | | target/ |
| | | .DS_Store |
| | | .gitattributes |
对比新文件 |
| | |
| | | --- #################### 注册中心 + 配置中心相关配置 #################### |
| | | spring: |
| | | cloud: |
| | | nacos: |
| | | server-addr: @nacos.server@ # Nacos 服务器地址 |
| | | username: @nacos.username@ |
| | | password: @nacos.password@ |
| | | discovery: # 【配置中心】配置项 |
| | | namespace: @nacos.namespace@ # 命名空间。这里使用 dev 开发环境 |
| | | group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP |
| | | metadata: |
| | | version: @nacos.metadata.version@ # 服务实例的版本号,可用于灰度发布 |
| | | management.context-path: ${server.servlet.context-path}/actuator |
| | | config: # 【注册中心】配置项 |
| | | namespace: @nacos.namespace@ # 命名空间。这里使用 dev 开发环境 |
| | | group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP |
| | |
| | | admin_name=任务调度中心 |
| | | admin_name_full=分布式任务调度平台XXL-JOB |
| | | admin_name=\u4EFB\u52A1\u8C03\u5EA6\u4E2D\u5FC3 |
| | | admin_name_full=\u5206\u5E03\u5F0F\u4EFB\u52A1\u8C03\u5EA6\u5E73\u53F0XXL-JOB |
| | | admin_version=2.4.2-SNAPSHOT |
| | | admin_i18n= |
| | | |
| | | ## system |
| | | system_tips=系统提示 |
| | | system_ok=确定 |
| | | system_close=关闭 |
| | | system_save=保存 |
| | | system_cancel=取消 |
| | | system_search=搜索 |
| | | system_status=状态 |
| | | system_opt=操作 |
| | | system_please_input=请输入 |
| | | system_please_choose=请选择 |
| | | system_success=成功 |
| | | system_fail=失败 |
| | | system_add_suc=新增成功 |
| | | system_add_fail=新增失败 |
| | | system_update_suc=更新成功 |
| | | system_update_fail=更新失败 |
| | | system_all=全部 |
| | | system_api_error=接口异常 |
| | | system_show=查看 |
| | | system_empty=无 |
| | | system_opt_suc=操作成功 |
| | | system_opt_fail=操作失败 |
| | | system_opt_edit=编辑 |
| | | system_opt_del=删除 |
| | | system_opt_copy=复制 |
| | | system_unvalid=非法 |
| | | system_not_found=不存在 |
| | | system_nav=导航 |
| | | system_digits=整数 |
| | | system_lengh_limit=长度限制 |
| | | system_permission_limit=权限拦截 |
| | | system_welcome=欢迎 |
| | | system_tips=\u7CFB\u7EDF\u63D0\u793A |
| | | system_ok=\u786E\u5B9A |
| | | system_close=\u5173\u95ED |
| | | system_save=\u4FDD\u5B58 |
| | | system_cancel=\u53D6\u6D88 |
| | | system_search=\u641C\u7D22 |
| | | system_status=\u72B6\u6001 |
| | | system_opt=\u64CD\u4F5C |
| | | system_please_input=\u8BF7\u8F93\u5165 |
| | | system_please_choose=\u8BF7\u9009\u62E9 |
| | | system_success=\u6210\u529F |
| | | system_fail=\u5931\u8D25 |
| | | system_add_suc=\u65B0\u589E\u6210\u529F |
| | | system_add_fail=\u65B0\u589E\u5931\u8D25 |
| | | system_update_suc=\u66F4\u65B0\u6210\u529F |
| | | system_update_fail=\u66F4\u65B0\u5931\u8D25 |
| | | system_all=\u5168\u90E8 |
| | | system_api_error=\u63A5\u53E3\u5F02\u5E38 |
| | | system_show=\u67E5\u770B |
| | | system_empty=\u65E0 |
| | | system_opt_suc=\u64CD\u4F5C\u6210\u529F |
| | | system_opt_fail=\u64CD\u4F5C\u5931\u8D25 |
| | | system_opt_edit=\u7F16\u8F91 |
| | | system_opt_del=\u5220\u9664 |
| | | system_opt_copy=\u590D\u5236 |
| | | system_unvalid=\u975E\u6CD5 |
| | | system_not_found=\u4E0D\u5B58\u5728 |
| | | system_nav=\u5BFC\u822A |
| | | system_digits=\u6574\u6570 |
| | | system_lengh_limit=\u957F\u5EA6\u9650\u5236 |
| | | system_permission_limit=\u6743\u9650\u62E6\u622A |
| | | system_welcome=\u6B22\u8FCE |
| | | |
| | | ## daterangepicker |
| | | daterangepicker_ranges_recent_hour=最近一小时 |
| | | daterangepicker_ranges_today=今日 |
| | | daterangepicker_ranges_yesterday=昨日 |
| | | daterangepicker_ranges_this_month=本月 |
| | | daterangepicker_ranges_last_month=上个月 |
| | | daterangepicker_ranges_recent_week=最近一周 |
| | | daterangepicker_ranges_recent_month=最近一月 |
| | | daterangepicker_custom_name=自定义 |
| | | daterangepicker_custom_starttime=起始时间 |
| | | daterangepicker_custom_endtime=结束时间 |
| | | daterangepicker_custom_daysofweek=日,一,二,三,四,五,六 |
| | | daterangepicker_custom_monthnames=一月,二月,三月,四月,五月,六月,七月,八月,九月,十月,十一月,十二月 |
| | | daterangepicker_ranges_recent_hour=\u6700\u8FD1\u4E00\u5C0F\u65F6 |
| | | daterangepicker_ranges_today=\u4ECA\u65E5 |
| | | daterangepicker_ranges_yesterday=\u6628\u65E5 |
| | | daterangepicker_ranges_this_month=\u672C\u6708 |
| | | daterangepicker_ranges_last_month=\u4E0A\u4E2A\u6708 |
| | | daterangepicker_ranges_recent_week=\u6700\u8FD1\u4E00\u5468 |
| | | daterangepicker_ranges_recent_month=\u6700\u8FD1\u4E00\u6708 |
| | | daterangepicker_custom_name=\u81EA\u5B9A\u4E49 |
| | | daterangepicker_custom_starttime=\u8D77\u59CB\u65F6\u95F4 |
| | | daterangepicker_custom_endtime=\u7ED3\u675F\u65F6\u95F4 |
| | | daterangepicker_custom_daysofweek=\u65E5,\u4E00,\u4E8C,\u4E09,\u56DB,\u4E94,\u516D |
| | | daterangepicker_custom_monthnames=\u4E00\u6708,\u4E8C\u6708,\u4E09\u6708,\u56DB\u6708,\u4E94\u6708,\u516D\u6708,\u4E03\u6708,\u516B\u6708,\u4E5D\u6708,\u5341\u6708,\u5341\u4E00\u6708,\u5341\u4E8C\u6708 |
| | | |
| | | ## dataTable |
| | | dataTable_sProcessing=处理中... |
| | | dataTable_sLengthMenu=每页 _MENU_ 条记录 |
| | | dataTable_sZeroRecords=没有匹配结果 |
| | | dataTable_sInfo=第 _PAGE_ 页 ( 总共 _PAGES_ 页,_TOTAL_ 条记录 ) |
| | | dataTable_sInfoEmpty=无记录 |
| | | dataTable_sInfoFiltered=(由 _MAX_ 项结果过滤) |
| | | dataTable_sSearch=搜索 |
| | | dataTable_sEmptyTable=表中数据为空 |
| | | dataTable_sLoadingRecords=载入中... |
| | | dataTable_sFirst=首页 |
| | | dataTable_sPrevious=上页 |
| | | dataTable_sNext=下页 |
| | | dataTable_sLast=末页 |
| | | dataTable_sSortAscending=: 以升序排列此列 |
| | | dataTable_sSortDescending=: 以降序排列此列 |
| | | dataTable_sProcessing=\u5904\u7406\u4E2D... |
| | | dataTable_sLengthMenu=\u6BCF\u9875 _MENU_ \u6761\u8BB0\u5F55 |
| | | dataTable_sZeroRecords=\u6CA1\u6709\u5339\u914D\u7ED3\u679C |
| | | dataTable_sInfo=\u7B2C _PAGE_ \u9875 ( \u603B\u5171 _PAGES_ \u9875\uFF0C_TOTAL_ \u6761\u8BB0\u5F55 ) |
| | | dataTable_sInfoEmpty=\u65E0\u8BB0\u5F55 |
| | | dataTable_sInfoFiltered=(\u7531 _MAX_ \u9879\u7ED3\u679C\u8FC7\u6EE4) |
| | | dataTable_sSearch=\u641C\u7D22 |
| | | dataTable_sEmptyTable=\u8868\u4E2D\u6570\u636E\u4E3A\u7A7A |
| | | dataTable_sLoadingRecords=\u8F7D\u5165\u4E2D... |
| | | dataTable_sFirst=\u9996\u9875 |
| | | dataTable_sPrevious=\u4E0A\u9875 |
| | | dataTable_sNext=\u4E0B\u9875 |
| | | dataTable_sLast=\u672B\u9875 |
| | | dataTable_sSortAscending=: \u4EE5\u5347\u5E8F\u6392\u5217\u6B64\u5217 |
| | | dataTable_sSortDescending=: \u4EE5\u964D\u5E8F\u6392\u5217\u6B64\u5217 |
| | | |
| | | ## login |
| | | login_btn=登录 |
| | | login_remember_me=记住密码 |
| | | login_username_placeholder=请输入登录账号 |
| | | login_password_placeholder=请输入登录密码 |
| | | login_username_empty=请输入登录账号 |
| | | login_username_lt_4=登录账号不应低于4位 |
| | | login_password_empty=请输入登录密码 |
| | | login_password_lt_4=登录密码不应低于4位 |
| | | login_success=登录成功 |
| | | login_fail=登录失败 |
| | | login_param_empty=账号或密码为空 |
| | | login_param_unvalid=账号或密码错误 |
| | | login_btn=\u767B\u5F55 |
| | | login_remember_me=\u8BB0\u4F4F\u5BC6\u7801 |
| | | login_username_placeholder=\u8BF7\u8F93\u5165\u767B\u5F55\u8D26\u53F7 |
| | | login_password_placeholder=\u8BF7\u8F93\u5165\u767B\u5F55\u5BC6\u7801 |
| | | login_username_empty=\u8BF7\u8F93\u5165\u767B\u5F55\u8D26\u53F7 |
| | | login_username_lt_4=\u767B\u5F55\u8D26\u53F7\u4E0D\u5E94\u4F4E\u4E8E4\u4F4D |
| | | login_password_empty=\u8BF7\u8F93\u5165\u767B\u5F55\u5BC6\u7801 |
| | | login_password_lt_4=\u767B\u5F55\u5BC6\u7801\u4E0D\u5E94\u4F4E\u4E8E4\u4F4D |
| | | login_success=\u767B\u5F55\u6210\u529F |
| | | login_fail=\u767B\u5F55\u5931\u8D25 |
| | | login_param_empty=\u8D26\u53F7\u6216\u5BC6\u7801\u4E3A\u7A7A |
| | | login_param_unvalid=\u8D26\u53F7\u6216\u5BC6\u7801\u9519\u8BEF |
| | | |
| | | ## logout |
| | | logout_btn=注销 |
| | | logout_confirm=确认注销登录? |
| | | logout_success=注销成功 |
| | | logout_fail=注销失败 |
| | | logout_btn=\u6CE8\u9500 |
| | | logout_confirm=\u786E\u8BA4\u6CE8\u9500\u767B\u5F55? |
| | | logout_success=\u6CE8\u9500\u6210\u529F |
| | | logout_fail=\u6CE8\u9500\u5931\u8D25 |
| | | |
| | | ## change pwd |
| | | change_pwd=修改密码 |
| | | change_pwd_suc_to_logout=修改密码成功,即将注销登陆 |
| | | change_pwd_field_newpwd=新密码 |
| | | change_pwd=\u4FEE\u6539\u5BC6\u7801 |
| | | change_pwd_suc_to_logout=\u4FEE\u6539\u5BC6\u7801\u6210\u529F\uFF0C\u5373\u5C06\u6CE8\u9500\u767B\u9646 |
| | | change_pwd_field_newpwd=\u65B0\u5BC6\u7801 |
| | | |
| | | ## dashboard |
| | | job_dashboard_name=运行报表 |
| | | job_dashboard_job_num=任务数量 |
| | | job_dashboard_job_num_tip=调度中心运行的任务数量 |
| | | job_dashboard_trigger_num=调度次数 |
| | | job_dashboard_trigger_num_tip=调度中心触发的调度次数 |
| | | job_dashboard_jobgroup_num=执行器数量 |
| | | job_dashboard_jobgroup_num_tip=调度中心在线的执行器机器数量 |
| | | job_dashboard_report=调度报表 |
| | | job_dashboard_report_loaddata_fail=调度报表数据加载异常 |
| | | job_dashboard_date_report=日期分布图 |
| | | job_dashboard_rate_report=成功比例图 |
| | | job_dashboard_name=\u8FD0\u884C\u62A5\u8868 |
| | | job_dashboard_job_num=\u4EFB\u52A1\u6570\u91CF |
| | | job_dashboard_job_num_tip=\u8C03\u5EA6\u4E2D\u5FC3\u8FD0\u884C\u7684\u4EFB\u52A1\u6570\u91CF |
| | | job_dashboard_trigger_num=\u8C03\u5EA6\u6B21\u6570 |
| | | job_dashboard_trigger_num_tip=\u8C03\u5EA6\u4E2D\u5FC3\u89E6\u53D1\u7684\u8C03\u5EA6\u6B21\u6570 |
| | | job_dashboard_jobgroup_num=\u6267\u884C\u5668\u6570\u91CF |
| | | job_dashboard_jobgroup_num_tip=\u8C03\u5EA6\u4E2D\u5FC3\u5728\u7EBF\u7684\u6267\u884C\u5668\u673A\u5668\u6570\u91CF |
| | | job_dashboard_report=\u8C03\u5EA6\u62A5\u8868 |
| | | job_dashboard_report_loaddata_fail=\u8C03\u5EA6\u62A5\u8868\u6570\u636E\u52A0\u8F7D\u5F02\u5E38 |
| | | job_dashboard_date_report=\u65E5\u671F\u5206\u5E03\u56FE |
| | | job_dashboard_rate_report=\u6210\u529F\u6BD4\u4F8B\u56FE |
| | | |
| | | ## job info |
| | | jobinfo_name=任务管理 |
| | | jobinfo_job=任务 |
| | | jobinfo_field_add=新增 |
| | | jobinfo_field_update=更新任务 |
| | | jobinfo_field_id=任务ID |
| | | jobinfo_field_jobgroup=执行器 |
| | | jobinfo_field_jobdesc=任务描述 |
| | | jobinfo_field_gluetype=运行模式 |
| | | jobinfo_field_executorparam=任务参数 |
| | | jobinfo_field_author=负责人 |
| | | jobinfo_field_timeout=任务超时时间 |
| | | jobinfo_field_alarmemail=报警邮件 |
| | | jobinfo_field_alarmemail_placeholder=请输入报警邮件,多个邮件地址则逗号分隔 |
| | | jobinfo_field_executorRouteStrategy=路由策略 |
| | | jobinfo_field_childJobId=子任务ID |
| | | jobinfo_field_childJobId_placeholder=请输入子任务的任务ID,如存在多个则逗号分隔 |
| | | jobinfo_field_executorBlockStrategy=阻塞处理策略 |
| | | jobinfo_field_executorFailRetryCount=失败重试次数 |
| | | jobinfo_field_executorFailRetryCount_placeholder=失败重试次数,大于零时生效 |
| | | jobinfo_script_location=脚本位置 |
| | | jobinfo_shard_index=分片序号 |
| | | jobinfo_shard_total=分片总数 |
| | | jobinfo_opt_stop=停止 |
| | | jobinfo_opt_start=启动 |
| | | jobinfo_opt_log=查询日志 |
| | | jobinfo_opt_run=执行一次 |
| | | jobinfo_opt_run_tips=请输入本次执行的机器地址,为空则从执行器获取 |
| | | jobinfo_opt_registryinfo=注册节点 |
| | | jobinfo_opt_next_time=下次执行时间 |
| | | jobinfo_glue_remark=源码备注 |
| | | jobinfo_glue_remark_limit=源码备注长度限制为4~100 |
| | | jobinfo_glue_rollback=版本回溯 |
| | | jobinfo_glue_jobid_unvalid=任务ID非法 |
| | | jobinfo_glue_gluetype_unvalid=该任务非GLUE模式 |
| | | jobinfo_field_executorTimeout_placeholder=任务超时时间,单位秒,大于零时生效 |
| | | schedule_type=调度类型 |
| | | schedule_type_none=无 |
| | | jobinfo_name=\u4EFB\u52A1\u7BA1\u7406 |
| | | jobinfo_job=\u4EFB\u52A1 |
| | | jobinfo_field_add=\u65B0\u589E |
| | | jobinfo_field_update=\u66F4\u65B0\u4EFB\u52A1 |
| | | jobinfo_field_id=\u4EFB\u52A1ID |
| | | jobinfo_field_jobgroup=\u6267\u884C\u5668 |
| | | jobinfo_field_jobdesc=\u4EFB\u52A1\u63CF\u8FF0 |
| | | jobinfo_field_gluetype=\u8FD0\u884C\u6A21\u5F0F |
| | | jobinfo_field_executorparam=\u4EFB\u52A1\u53C2\u6570 |
| | | jobinfo_field_author=\u8D1F\u8D23\u4EBA |
| | | jobinfo_field_timeout=\u4EFB\u52A1\u8D85\u65F6\u65F6\u95F4 |
| | | jobinfo_field_alarmemail=\u62A5\u8B66\u90AE\u4EF6 |
| | | jobinfo_field_alarmemail_placeholder=\u8BF7\u8F93\u5165\u62A5\u8B66\u90AE\u4EF6\uFF0C\u591A\u4E2A\u90AE\u4EF6\u5730\u5740\u5219\u9017\u53F7\u5206\u9694 |
| | | jobinfo_field_executorRouteStrategy=\u8DEF\u7531\u7B56\u7565 |
| | | jobinfo_field_childJobId=\u5B50\u4EFB\u52A1ID |
| | | jobinfo_field_childJobId_placeholder=\u8BF7\u8F93\u5165\u5B50\u4EFB\u52A1\u7684\u4EFB\u52A1ID,\u5982\u5B58\u5728\u591A\u4E2A\u5219\u9017\u53F7\u5206\u9694 |
| | | jobinfo_field_executorBlockStrategy=\u963B\u585E\u5904\u7406\u7B56\u7565 |
| | | jobinfo_field_executorFailRetryCount=\u5931\u8D25\u91CD\u8BD5\u6B21\u6570 |
| | | jobinfo_field_executorFailRetryCount_placeholder=\u5931\u8D25\u91CD\u8BD5\u6B21\u6570\uFF0C\u5927\u4E8E\u96F6\u65F6\u751F\u6548 |
| | | jobinfo_script_location=\u811A\u672C\u4F4D\u7F6E |
| | | jobinfo_shard_index=\u5206\u7247\u5E8F\u53F7 |
| | | jobinfo_shard_total=\u5206\u7247\u603B\u6570 |
| | | jobinfo_opt_stop=\u505C\u6B62 |
| | | jobinfo_opt_start=\u542F\u52A8 |
| | | jobinfo_opt_log=\u67E5\u8BE2\u65E5\u5FD7 |
| | | jobinfo_opt_run=\u6267\u884C\u4E00\u6B21 |
| | | jobinfo_opt_run_tips=\u8BF7\u8F93\u5165\u672C\u6B21\u6267\u884C\u7684\u673A\u5668\u5730\u5740\uFF0C\u4E3A\u7A7A\u5219\u4ECE\u6267\u884C\u5668\u83B7\u53D6 |
| | | jobinfo_opt_registryinfo=\u6CE8\u518C\u8282\u70B9 |
| | | jobinfo_opt_next_time=\u4E0B\u6B21\u6267\u884C\u65F6\u95F4 |
| | | jobinfo_glue_remark=\u6E90\u7801\u5907\u6CE8 |
| | | jobinfo_glue_remark_limit=\u6E90\u7801\u5907\u6CE8\u957F\u5EA6\u9650\u5236\u4E3A4~100 |
| | | jobinfo_glue_rollback=\u7248\u672C\u56DE\u6EAF |
| | | jobinfo_glue_jobid_unvalid=\u4EFB\u52A1ID\u975E\u6CD5 |
| | | jobinfo_glue_gluetype_unvalid=\u8BE5\u4EFB\u52A1\u975EGLUE\u6A21\u5F0F |
| | | jobinfo_field_executorTimeout_placeholder=\u4EFB\u52A1\u8D85\u65F6\u65F6\u95F4\uFF0C\u5355\u4F4D\u79D2\uFF0C\u5927\u4E8E\u96F6\u65F6\u751F\u6548 |
| | | schedule_type=\u8C03\u5EA6\u7C7B\u578B |
| | | schedule_type_none=\u65E0 |
| | | schedule_type_cron=CRON |
| | | schedule_type_fix_rate=固定速度 |
| | | schedule_type_fix_delay=固定延迟 |
| | | schedule_type_none_limit_start=当前调度类型禁止启动 |
| | | misfire_strategy=调度过期策略 |
| | | misfire_strategy_do_nothing=忽略 |
| | | misfire_strategy_fire_once_now=立即执行一次 |
| | | jobinfo_conf_base=基础配置 |
| | | jobinfo_conf_schedule=调度配置 |
| | | jobinfo_conf_job=任务配置 |
| | | jobinfo_conf_advanced=高级配置 |
| | | schedule_type_fix_rate=\u56FA\u5B9A\u901F\u5EA6 |
| | | schedule_type_fix_delay=\u56FA\u5B9A\u5EF6\u8FDF |
| | | schedule_type_none_limit_start=\u5F53\u524D\u8C03\u5EA6\u7C7B\u578B\u7981\u6B62\u542F\u52A8 |
| | | misfire_strategy=\u8C03\u5EA6\u8FC7\u671F\u7B56\u7565 |
| | | misfire_strategy_do_nothing=\u5FFD\u7565 |
| | | misfire_strategy_fire_once_now=\u7ACB\u5373\u6267\u884C\u4E00\u6B21 |
| | | jobinfo_conf_base=\u57FA\u7840\u914D\u7F6E |
| | | jobinfo_conf_schedule=\u8C03\u5EA6\u914D\u7F6E |
| | | jobinfo_conf_job=\u4EFB\u52A1\u914D\u7F6E |
| | | jobinfo_conf_advanced=\u9AD8\u7EA7\u914D\u7F6E |
| | | |
| | | ## job log |
| | | joblog_name=调度日志 |
| | | joblog_status=状态 |
| | | joblog_status_all=全部 |
| | | joblog_status_suc=成功 |
| | | joblog_status_fail=失败 |
| | | joblog_status_running=进行中 |
| | | joblog_field_triggerTime=调度时间 |
| | | joblog_field_triggerCode=调度结果 |
| | | joblog_field_triggerMsg=调度备注 |
| | | joblog_field_handleTime=执行时间 |
| | | joblog_field_handleCode=执行结果 |
| | | joblog_field_handleMsg=执行备注 |
| | | joblog_field_executorAddress=执行器地址 |
| | | joblog_clean=清理 |
| | | joblog_clean_log=日志清理 |
| | | joblog_clean_type=清理方式 |
| | | joblog_clean_type_1=清理一个月之前日志数据 |
| | | joblog_clean_type_2=清理三个月之前日志数据 |
| | | joblog_clean_type_3=清理六个月之前日志数据 |
| | | joblog_clean_type_4=清理一年之前日志数据 |
| | | joblog_clean_type_5=清理一千条以前日志数据 |
| | | joblog_clean_type_6=清理一万条以前日志数据 |
| | | joblog_clean_type_7=清理三万条以前日志数据 |
| | | joblog_clean_type_8=清理十万条以前日志数据 |
| | | joblog_clean_type_9=清理所有日志数据 |
| | | joblog_clean_type_unvalid=清理类型参数异常 |
| | | joblog_handleCode_200=成功 |
| | | joblog_handleCode_500=失败 |
| | | joblog_handleCode_502=失败(超时) |
| | | joblog_kill_log=终止任务 |
| | | joblog_kill_log_limit=调度失败,无法终止日志 |
| | | joblog_kill_log_byman=人为操作,主动终止 |
| | | joblog_lost_fail=任务结果丢失,标记失败 |
| | | joblog_rolling_log=执行日志 |
| | | joblog_rolling_log_refresh=刷新 |
| | | joblog_rolling_log_triggerfail=任务发起调度失败,无法查看执行日志 |
| | | joblog_rolling_log_failoften=终止请求Rolling日志,请求失败次数超上限,可刷新页面重新加载日志 |
| | | joblog_logid_unvalid=日志ID非法 |
| | | joblog_name=\u8C03\u5EA6\u65E5\u5FD7 |
| | | joblog_status=\u72B6\u6001 |
| | | joblog_status_all=\u5168\u90E8 |
| | | joblog_status_suc=\u6210\u529F |
| | | joblog_status_fail=\u5931\u8D25 |
| | | joblog_status_running=\u8FDB\u884C\u4E2D |
| | | joblog_field_triggerTime=\u8C03\u5EA6\u65F6\u95F4 |
| | | joblog_field_triggerCode=\u8C03\u5EA6\u7ED3\u679C |
| | | joblog_field_triggerMsg=\u8C03\u5EA6\u5907\u6CE8 |
| | | joblog_field_handleTime=\u6267\u884C\u65F6\u95F4 |
| | | joblog_field_handleCode=\u6267\u884C\u7ED3\u679C |
| | | joblog_field_handleMsg=\u6267\u884C\u5907\u6CE8 |
| | | joblog_field_executorAddress=\u6267\u884C\u5668\u5730\u5740 |
| | | joblog_clean=\u6E05\u7406 |
| | | joblog_clean_log=\u65E5\u5FD7\u6E05\u7406 |
| | | joblog_clean_type=\u6E05\u7406\u65B9\u5F0F |
| | | joblog_clean_type_1=\u6E05\u7406\u4E00\u4E2A\u6708\u4E4B\u524D\u65E5\u5FD7\u6570\u636E |
| | | joblog_clean_type_2=\u6E05\u7406\u4E09\u4E2A\u6708\u4E4B\u524D\u65E5\u5FD7\u6570\u636E |
| | | joblog_clean_type_3=\u6E05\u7406\u516D\u4E2A\u6708\u4E4B\u524D\u65E5\u5FD7\u6570\u636E |
| | | joblog_clean_type_4=\u6E05\u7406\u4E00\u5E74\u4E4B\u524D\u65E5\u5FD7\u6570\u636E |
| | | joblog_clean_type_5=\u6E05\u7406\u4E00\u5343\u6761\u4EE5\u524D\u65E5\u5FD7\u6570\u636E |
| | | joblog_clean_type_6=\u6E05\u7406\u4E00\u4E07\u6761\u4EE5\u524D\u65E5\u5FD7\u6570\u636E |
| | | joblog_clean_type_7=\u6E05\u7406\u4E09\u4E07\u6761\u4EE5\u524D\u65E5\u5FD7\u6570\u636E |
| | | joblog_clean_type_8=\u6E05\u7406\u5341\u4E07\u6761\u4EE5\u524D\u65E5\u5FD7\u6570\u636E |
| | | joblog_clean_type_9=\u6E05\u7406\u6240\u6709\u65E5\u5FD7\u6570\u636E |
| | | joblog_clean_type_unvalid=\u6E05\u7406\u7C7B\u578B\u53C2\u6570\u5F02\u5E38 |
| | | joblog_handleCode_200=\u6210\u529F |
| | | joblog_handleCode_500=\u5931\u8D25 |
| | | joblog_handleCode_502=\u5931\u8D25(\u8D85\u65F6) |
| | | joblog_kill_log=\u7EC8\u6B62\u4EFB\u52A1 |
| | | joblog_kill_log_limit=\u8C03\u5EA6\u5931\u8D25\uFF0C\u65E0\u6CD5\u7EC8\u6B62\u65E5\u5FD7 |
| | | joblog_kill_log_byman=\u4EBA\u4E3A\u64CD\u4F5C\uFF0C\u4E3B\u52A8\u7EC8\u6B62 |
| | | joblog_lost_fail=\u4EFB\u52A1\u7ED3\u679C\u4E22\u5931\uFF0C\u6807\u8BB0\u5931\u8D25 |
| | | joblog_rolling_log=\u6267\u884C\u65E5\u5FD7 |
| | | joblog_rolling_log_refresh=\u5237\u65B0 |
| | | joblog_rolling_log_triggerfail=\u4EFB\u52A1\u53D1\u8D77\u8C03\u5EA6\u5931\u8D25\uFF0C\u65E0\u6CD5\u67E5\u770B\u6267\u884C\u65E5\u5FD7 |
| | | joblog_rolling_log_failoften=\u7EC8\u6B62\u8BF7\u6C42Rolling\u65E5\u5FD7,\u8BF7\u6C42\u5931\u8D25\u6B21\u6570\u8D85\u4E0A\u9650,\u53EF\u5237\u65B0\u9875\u9762\u91CD\u65B0\u52A0\u8F7D\u65E5\u5FD7 |
| | | joblog_logid_unvalid=\u65E5\u5FD7ID\u975E\u6CD5 |
| | | |
| | | ## job group |
| | | jobgroup_name=执行器管理 |
| | | jobgroup_list=执行器列表 |
| | | jobgroup_add=新增执行器 |
| | | jobgroup_edit=编辑执行器 |
| | | jobgroup_del=删除执行器 |
| | | jobgroup_field_title=名称 |
| | | jobgroup_field_addressType=注册方式 |
| | | jobgroup_field_addressType_0=自动注册 |
| | | jobgroup_field_addressType_1=手动录入 |
| | | jobgroup_field_addressType_limit=手动录入注册方式,机器地址不可为空 |
| | | jobgroup_field_registryList=机器地址 |
| | | jobgroup_field_registryList_unvalid=机器地址格式非法 |
| | | jobgroup_field_registryList_placeholder=请输入执行器地址列表,多地址逗号分隔 |
| | | jobgroup_field_appname_limit=限制以小写字母开头,由小写字母、数字和中划线组成 |
| | | jobgroup_field_appname_length=AppName长度限制为4~64 |
| | | jobgroup_field_title_length=名称长度限制为4~12 |
| | | jobgroup_field_order_digits=请输入整数 |
| | | jobgroup_field_orderrange=取值范围为1~1000 |
| | | jobgroup_del_limit_0=拒绝删除,该执行器使用中 |
| | | jobgroup_del_limit_1=拒绝删除, 系统至少保留一个执行器 |
| | | jobgroup_empty=不存在有效执行器,请联系管理员 |
| | | jobgroup_name=\u6267\u884C\u5668\u7BA1\u7406 |
| | | jobgroup_list=\u6267\u884C\u5668\u5217\u8868 |
| | | jobgroup_add=\u65B0\u589E\u6267\u884C\u5668 |
| | | jobgroup_edit=\u7F16\u8F91\u6267\u884C\u5668 |
| | | jobgroup_del=\u5220\u9664\u6267\u884C\u5668 |
| | | jobgroup_field_title=\u540D\u79F0 |
| | | jobgroup_field_addressType=\u6CE8\u518C\u65B9\u5F0F |
| | | jobgroup_field_addressType_0=\u81EA\u52A8\u6CE8\u518C |
| | | jobgroup_field_addressType_1=\u624B\u52A8\u5F55\u5165 |
| | | jobgroup_field_addressType_limit=\u624B\u52A8\u5F55\u5165\u6CE8\u518C\u65B9\u5F0F\uFF0C\u673A\u5668\u5730\u5740\u4E0D\u53EF\u4E3A\u7A7A |
| | | jobgroup_field_registryList=\u673A\u5668\u5730\u5740 |
| | | jobgroup_field_registryList_unvalid=\u673A\u5668\u5730\u5740\u683C\u5F0F\u975E\u6CD5 |
| | | jobgroup_field_registryList_placeholder=\u8BF7\u8F93\u5165\u6267\u884C\u5668\u5730\u5740\u5217\u8868\uFF0C\u591A\u5730\u5740\u9017\u53F7\u5206\u9694 |
| | | jobgroup_field_appname_limit=\u9650\u5236\u4EE5\u5C0F\u5199\u5B57\u6BCD\u5F00\u5934\uFF0C\u7531\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u548C\u4E2D\u5212\u7EBF\u7EC4\u6210 |
| | | jobgroup_field_appname_length=AppName\u957F\u5EA6\u9650\u5236\u4E3A4~64 |
| | | jobgroup_field_title_length=\u540D\u79F0\u957F\u5EA6\u9650\u5236\u4E3A4~12 |
| | | jobgroup_field_order_digits=\u8BF7\u8F93\u5165\u6574\u6570 |
| | | jobgroup_field_orderrange=\u53D6\u503C\u8303\u56F4\u4E3A1~1000 |
| | | jobgroup_del_limit_0=\u62D2\u7EDD\u5220\u9664\uFF0C\u8BE5\u6267\u884C\u5668\u4F7F\u7528\u4E2D |
| | | jobgroup_del_limit_1=\u62D2\u7EDD\u5220\u9664, \u7CFB\u7EDF\u81F3\u5C11\u4FDD\u7559\u4E00\u4E2A\u6267\u884C\u5668 |
| | | jobgroup_empty=\u4E0D\u5B58\u5728\u6709\u6548\u6267\u884C\u5668,\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458 |
| | | |
| | | ## job conf |
| | | jobconf_block_SERIAL_EXECUTION=单机串行 |
| | | jobconf_block_DISCARD_LATER=丢弃后续调度 |
| | | jobconf_block_COVER_EARLY=覆盖之前调度 |
| | | jobconf_route_first=第一个 |
| | | jobconf_route_last=最后一个 |
| | | jobconf_route_round=轮询 |
| | | jobconf_route_random=随机 |
| | | jobconf_route_consistenthash=一致性HASH |
| | | jobconf_route_lfu=最不经常使用 |
| | | jobconf_route_lru=最近最久未使用 |
| | | jobconf_route_failover=故障转移 |
| | | jobconf_route_busyover=忙碌转移 |
| | | jobconf_route_shard=分片广播 |
| | | jobconf_idleBeat=空闲检测 |
| | | jobconf_beat=心跳检测 |
| | | jobconf_monitor=任务调度中心监控报警 |
| | | jobconf_monitor_detail=监控告警明细 |
| | | jobconf_monitor_alarm_title=告警类型 |
| | | jobconf_monitor_alarm_type=调度失败 |
| | | jobconf_monitor_alarm_content=告警内容 |
| | | jobconf_trigger_admin_adress=调度机器 |
| | | jobconf_trigger_exe_regtype=执行器-注册方式 |
| | | jobconf_trigger_exe_regaddress=执行器-地址列表 |
| | | jobconf_trigger_address_empty=调度失败:执行器地址为空 |
| | | jobconf_trigger_run=触发调度 |
| | | jobconf_trigger_child_run=触发子任务 |
| | | jobconf_callback_child_msg1={0}/{1} [任务ID={2}], 触发{3}, 触发备注: {4} <br> |
| | | jobconf_callback_child_msg2={0}/{1} [任务ID={2}], 触发失败, 触发备注: 任务ID格式错误 <br> |
| | | jobconf_trigger_type=任务触发类型 |
| | | jobconf_trigger_type_cron=Cron触发 |
| | | jobconf_trigger_type_manual=手动触发 |
| | | jobconf_trigger_type_parent=父任务触发 |
| | | jobconf_trigger_type_api=API触发 |
| | | jobconf_trigger_type_retry=失败重试触发 |
| | | jobconf_trigger_type_misfire=调度过期补偿 |
| | | jobconf_block_SERIAL_EXECUTION=\u5355\u673A\u4E32\u884C |
| | | jobconf_block_DISCARD_LATER=\u4E22\u5F03\u540E\u7EED\u8C03\u5EA6 |
| | | jobconf_block_COVER_EARLY=\u8986\u76D6\u4E4B\u524D\u8C03\u5EA6 |
| | | jobconf_route_first=\u7B2C\u4E00\u4E2A |
| | | jobconf_route_last=\u6700\u540E\u4E00\u4E2A |
| | | jobconf_route_round=\u8F6E\u8BE2 |
| | | jobconf_route_random=\u968F\u673A |
| | | jobconf_route_consistenthash=\u4E00\u81F4\u6027HASH |
| | | jobconf_route_lfu=\u6700\u4E0D\u7ECF\u5E38\u4F7F\u7528 |
| | | jobconf_route_lru=\u6700\u8FD1\u6700\u4E45\u672A\u4F7F\u7528 |
| | | jobconf_route_failover=\u6545\u969C\u8F6C\u79FB |
| | | jobconf_route_busyover=\u5FD9\u788C\u8F6C\u79FB |
| | | jobconf_route_shard=\u5206\u7247\u5E7F\u64AD |
| | | jobconf_idleBeat=\u7A7A\u95F2\u68C0\u6D4B |
| | | jobconf_beat=\u5FC3\u8DF3\u68C0\u6D4B |
| | | jobconf_monitor=\u4EFB\u52A1\u8C03\u5EA6\u4E2D\u5FC3\u76D1\u63A7\u62A5\u8B66 |
| | | jobconf_monitor_detail=\u76D1\u63A7\u544A\u8B66\u660E\u7EC6 |
| | | jobconf_monitor_alarm_title=\u544A\u8B66\u7C7B\u578B |
| | | jobconf_monitor_alarm_type=\u8C03\u5EA6\u5931\u8D25 |
| | | jobconf_monitor_alarm_content=\u544A\u8B66\u5185\u5BB9 |
| | | jobconf_trigger_admin_adress=\u8C03\u5EA6\u673A\u5668 |
| | | jobconf_trigger_exe_regtype=\u6267\u884C\u5668-\u6CE8\u518C\u65B9\u5F0F |
| | | jobconf_trigger_exe_regaddress=\u6267\u884C\u5668-\u5730\u5740\u5217\u8868 |
| | | jobconf_trigger_address_empty=\u8C03\u5EA6\u5931\u8D25\uFF1A\u6267\u884C\u5668\u5730\u5740\u4E3A\u7A7A |
| | | jobconf_trigger_run=\u89E6\u53D1\u8C03\u5EA6 |
| | | jobconf_trigger_child_run=\u89E6\u53D1\u5B50\u4EFB\u52A1 |
| | | jobconf_callback_child_msg1={0}/{1} [\u4EFB\u52A1ID={2}], \u89E6\u53D1{3}, \u89E6\u53D1\u5907\u6CE8: {4} <br> |
| | | jobconf_callback_child_msg2={0}/{1} [\u4EFB\u52A1ID={2}], \u89E6\u53D1\u5931\u8D25, \u89E6\u53D1\u5907\u6CE8: \u4EFB\u52A1ID\u683C\u5F0F\u9519\u8BEF <br> |
| | | jobconf_trigger_type=\u4EFB\u52A1\u89E6\u53D1\u7C7B\u578B |
| | | jobconf_trigger_type_cron=Cron\u89E6\u53D1 |
| | | jobconf_trigger_type_manual=\u624B\u52A8\u89E6\u53D1 |
| | | jobconf_trigger_type_parent=\u7236\u4EFB\u52A1\u89E6\u53D1 |
| | | jobconf_trigger_type_api=API\u89E6\u53D1 |
| | | jobconf_trigger_type_retry=\u5931\u8D25\u91CD\u8BD5\u89E6\u53D1 |
| | | jobconf_trigger_type_misfire=\u8C03\u5EA6\u8FC7\u671F\u8865\u507F |
| | | |
| | | ## user |
| | | user_manage=用户管理 |
| | | user_username=账号 |
| | | user_password=密码 |
| | | user_role=角色 |
| | | user_role_admin=管理员 |
| | | user_role_normal=普通用户 |
| | | user_permission=权限 |
| | | user_add=新增用户 |
| | | user_update=更新用户 |
| | | user_username_repeat=账号重复 |
| | | user_username_valid=限制以小写字母开头,由小写字母、数字组成 |
| | | user_password_update_placeholder=请输入新密码,为空则不更新密码 |
| | | user_update_loginuser_limit=禁止操作当前登录账号 |
| | | user_manage=\u7528\u6237\u7BA1\u7406 |
| | | user_username=\u8D26\u53F7 |
| | | user_password=\u5BC6\u7801 |
| | | user_role=\u89D2\u8272 |
| | | user_role_admin=\u7BA1\u7406\u5458 |
| | | user_role_normal=\u666E\u901A\u7528\u6237 |
| | | user_permission=\u6743\u9650 |
| | | user_add=\u65B0\u589E\u7528\u6237 |
| | | user_update=\u66F4\u65B0\u7528\u6237 |
| | | user_username_repeat=\u8D26\u53F7\u91CD\u590D |
| | | user_username_valid=\u9650\u5236\u4EE5\u5C0F\u5199\u5B57\u6BCD\u5F00\u5934\uFF0C\u7531\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u7EC4\u6210 |
| | | user_password_update_placeholder=\u8BF7\u8F93\u5165\u65B0\u5BC6\u7801\uFF0C\u4E3A\u7A7A\u5219\u4E0D\u66F4\u65B0\u5BC6\u7801 |
| | | user_update_loginuser_limit=\u7981\u6B62\u64CD\u4F5C\u5F53\u524D\u767B\u5F55\u8D26\u53F7 |
| | | |
| | | ## help |
| | | job_help=使用教程 |
| | | job_help_document=官方文档 |
| | | job_help=\u4F7F\u7528\u6559\u7A0B |
| | | job_help_document=\u5B98\u65B9\u6587\u6863 |
| | |
| | | <li class="nav-click <#if pageName == "jobgroup">active</#if>" ><a href="${request.contextPath}/jobgroup"><i class="fa fa-circle-o text-red"></i><span>${I18n.jobgroup_name}</span></a></li> |
| | | <li class="nav-click <#if pageName == "user">active</#if>" ><a href="${request.contextPath}/user"><i class="fa fa-circle-o text-purple"></i><span>${I18n.user_manage}</span></a></li> |
| | | </#if> |
| | | <li class="nav-click <#if pageName == "help">active</#if>" ><a href="${request.contextPath}/help"><i class="fa fa-circle-o text-gray"></i><span>${I18n.job_help}</span></a></li> |
| | | <#-- <li class="nav-click <#if pageName == "help">active</#if>" ><a href="${request.contextPath}/help"><i class="fa fa-circle-o text-gray"></i><span>${I18n.job_help}</span></a></li>--> |
| | | </ul> |
| | | </section> |
| | | <!-- /.sidebar --> |
| | |
| | | <#--<!DOCTYPE html>--> |
| | | <#--<html>--> |
| | | <#--<head>--> |
| | | <#-- <#import "./common/common.macro.ftl" as netCommon>--> |
| | | <#-- <@netCommon.commonStyle />--> |
| | | <#-- <title>${I18n.admin_name}</title>--> |
| | | <#--</head>--> |
| | | <#--<body class="hold-transition skin-blue sidebar-mini <#if cookieMap?exists && cookieMap["xxljob_adminlte_settings"]?exists && "off" == cookieMap["xxljob_adminlte_settings"].value >sidebar-collapse</#if> ">--> |
| | | <#--<div class="wrapper">--> |
| | | <#-- <!-- header –>--> |
| | | <#-- <@netCommon.commonHeader />--> |
| | | <#-- <!-- left –>--> |
| | | <#-- <@netCommon.commonLeft "help" />--> |
| | | <#-- --> |
| | | <#-- <!-- Content Wrapper. Contains page content –>--> |
| | | <#-- <div class="content-wrapper">--> |
| | | <#-- <!-- Content Header (Page header) –>--> |
| | | <#-- <section class="content-header">--> |
| | | <#-- <h1>${I18n.job_help}</h1>--> |
| | | <#-- </section>--> |
| | | <!DOCTYPE html> |
| | | <html> |
| | | <head> |
| | | <#import "./common/common.macro.ftl" as netCommon> |
| | | <@netCommon.commonStyle /> |
| | | <title>${I18n.admin_name}</title> |
| | | </head> |
| | | <body class="hold-transition skin-blue sidebar-mini <#if cookieMap?exists && cookieMap["xxljob_adminlte_settings"]?exists && "off" == cookieMap["xxljob_adminlte_settings"].value >sidebar-collapse</#if> "> |
| | | <div class="wrapper"> |
| | | <!-- header --> |
| | | <@netCommon.commonHeader /> |
| | | <!-- left --> |
| | | <@netCommon.commonLeft "help" /> |
| | | |
| | | <#-- <!-- Main content –>--> |
| | | <#-- <section class="content">--> |
| | | <#-- <div class="callout callout-info">--> |
| | | <#-- <h4>${I18n.admin_name_full}</h4>--> |
| | | <#-- <br>--> |
| | | <#-- <p>--> |
| | | <#-- <a target="_blank" href="https://github.com/xuxueli/xxl-job">Github</a> --> |
| | | <#-- <iframe src="https://ghbtns.com/github-btn.html?user=xuxueli&repo=xxl-job&type=star&count=true" frameborder="0" scrolling="0" width="170px" height="20px" style="margin-bottom:-5px;"></iframe> --> |
| | | <#-- <br><br>--> |
| | | <#-- <a target="_blank" href="https://www.xuxueli.com/xxl-job/">${I18n.job_help_document}</a>--> |
| | | <#-- <br><br>--> |
| | | <!-- Content Wrapper. Contains page content --> |
| | | <div class="content-wrapper"> |
| | | <!-- Content Header (Page header) --> |
| | | <section class="content-header"> |
| | | <h1>${I18n.job_help}</h1> |
| | | </section> |
| | | |
| | | <#-- </p>--> |
| | | <#-- <p></p>--> |
| | | <#-- </div>--> |
| | | <#-- </section>--> |
| | | <#-- <!-- /.content –>--> |
| | | <#-- </div>--> |
| | | <#-- <!-- /.content-wrapper –>--> |
| | | <#-- --> |
| | | <#-- <!-- footer –>--> |
| | | <#-- <@netCommon.commonFooter />--> |
| | | <#--</div>--> |
| | | <#--<@netCommon.commonScript />--> |
| | | <#--</body>--> |
| | | <#--</html>--> |
| | | <#--<!DOCTYPE html>--> |
| | | <#--<html>--> |
| | | <#--<head>--> |
| | | <#-- <#import "./common/common.macro.ftl" as netCommon>--> |
| | | <#-- <@netCommon.commonStyle />--> |
| | | <#-- <title>${I18n.admin_name}</title>--> |
| | | <#--</head>--> |
| | | <#--<body class="hold-transition skin-blue sidebar-mini <#if cookieMap?exists && cookieMap["xxljob_adminlte_settings"]?exists && "off" == cookieMap["xxljob_adminlte_settings"].value >sidebar-collapse</#if> ">--> |
| | | <#--<div class="wrapper">--> |
| | | <#-- <!-- header –>--> |
| | | <#-- <@netCommon.commonHeader />--> |
| | | <#-- <!-- left –>--> |
| | | <#-- <@netCommon.commonLeft "help" />--> |
| | | <#-- --> |
| | | <#-- <!-- Content Wrapper. Contains page content –>--> |
| | | <#-- <div class="content-wrapper">--> |
| | | <#-- <!-- Content Header (Page header) –>--> |
| | | <#-- <section class="content-header">--> |
| | | <#-- <h1>${I18n.job_help}</h1>--> |
| | | <#-- </section>--> |
| | | <!-- Main content --> |
| | | <section class="content"> |
| | | <div class="callout callout-info"> |
| | | <h4>${I18n.admin_name_full}</h4> |
| | | <br> |
| | | <p> |
| | | <a target="_blank" href="https://github.com/xuxueli/xxl-job">Github</a> |
| | | <iframe src="https://ghbtns.com/github-btn.html?user=xuxueli&repo=xxl-job&type=star&count=true" frameborder="0" scrolling="0" width="170px" height="20px" style="margin-bottom:-5px;"></iframe> |
| | | <br><br> |
| | | <a target="_blank" href="https://www.xuxueli.com/xxl-job/">${I18n.job_help_document}</a> |
| | | <br><br> |
| | | |
| | | <#-- <!-- Main content –>--> |
| | | <#-- <section class="content">--> |
| | | <#-- <div class="callout callout-info">--> |
| | | <#-- <h4>${I18n.admin_name_full}</h4>--> |
| | | <#-- <br>--> |
| | | <#-- <p>--> |
| | | <#-- <a target="_blank" href="https://github.com/xuxueli/xxl-job">Github</a> --> |
| | | <#-- <iframe src="https://ghbtns.com/github-btn.html?user=xuxueli&repo=xxl-job&type=star&count=true" frameborder="0" scrolling="0" width="170px" height="20px" style="margin-bottom:-5px;"></iframe> --> |
| | | <#-- <br><br>--> |
| | | <#-- <a target="_blank" href="https://www.xuxueli.com/xxl-job/">${I18n.job_help_document}</a>--> |
| | | <#-- <br><br>--> |
| | | </p> |
| | | <p></p> |
| | | </div> |
| | | </section> |
| | | <!-- /.content --> |
| | | </div> |
| | | <!-- /.content-wrapper --> |
| | | |
| | | <#-- </p>--> |
| | | <#-- <p></p>--> |
| | | <#-- </div>--> |
| | | <#-- </section>--> |
| | | <#-- <!-- /.content –>--> |
| | | <#-- </div>--> |
| | | <#-- <!-- /.content-wrapper –>--> |
| | | <#-- --> |
| | | <#-- <!-- footer –>--> |
| | | <#-- <@netCommon.commonFooter />--> |
| | | <#--</div>--> |
| | | <#--<@netCommon.commonScript />--> |
| | | <#--</body>--> |
| | | <#--</html>--> |
| | | <!-- footer --> |
| | | <@netCommon.commonFooter /> |
| | | </div> |
| | | <@netCommon.commonScript /> |
| | | </body> |
| | | </html> |
| | | <!DOCTYPE html> |
| | | <html> |
| | | <head> |
| | | <#import "./common/common.macro.ftl" as netCommon> |
| | | <@netCommon.commonStyle /> |
| | | <title>${I18n.admin_name}</title> |
| | | </head> |
| | | <body class="hold-transition skin-blue sidebar-mini <#if cookieMap?exists && cookieMap["xxljob_adminlte_settings"]?exists && "off" == cookieMap["xxljob_adminlte_settings"].value >sidebar-collapse</#if> "> |
| | | <div class="wrapper"> |
| | | <!-- header --> |
| | | <@netCommon.commonHeader /> |
| | | <!-- left --> |
| | | <@netCommon.commonLeft "help" /> |
| | | |
| | | <!-- Content Wrapper. Contains page content --> |
| | | <div class="content-wrapper"> |
| | | <!-- Content Header (Page header) --> |
| | | <section class="content-header"> |
| | | <h1>${I18n.job_help}</h1> |
| | | </section> |
| | | |
| | | <!-- Main content --> |
| | | <section class="content"> |
| | | <div class="callout callout-info"> |
| | | <h4>${I18n.admin_name_full}</h4> |
| | | <br> |
| | | <p> |
| | | <a target="_blank" href="https://github.com/xuxueli/xxl-job">Github</a> |
| | | <iframe src="https://ghbtns.com/github-btn.html?user=xuxueli&repo=xxl-job&type=star&count=true" frameborder="0" scrolling="0" width="170px" height="20px" style="margin-bottom:-5px;"></iframe> |
| | | <br><br> |
| | | <a target="_blank" href="https://www.xuxueli.com/xxl-job/">${I18n.job_help_document}</a> |
| | | <br><br> |
| | | |
| | | </p> |
| | | <p></p> |
| | | </div> |
| | | </section> |
| | | <!-- /.content --> |
| | | </div> |
| | | <!-- /.content-wrapper --> |
| | | |
| | | <!-- footer --> |
| | | <@netCommon.commonFooter /> |
| | | </div> |
| | | <@netCommon.commonScript /> |
| | | </body> |
| | | </html> |
对比新文件 |
| | |
| | | package com.iailab.framework.datapermission.core.db; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.baomidou.mybatisplus.extension.plugins.handler.MultiDataPermissionHandler; |
| | | import com.iailab.framework.datapermission.core.rule.DataPermissionRule; |
| | | import com.iailab.framework.datapermission.core.rule.DataPermissionRuleFactory; |
| | | import com.iailab.framework.mybatis.core.util.MyBatisUtils; |
| | | import lombok.RequiredArgsConstructor; |
| | | import net.sf.jsqlparser.expression.Expression; |
| | | import net.sf.jsqlparser.expression.operators.conditional.AndExpression; |
| | | import net.sf.jsqlparser.schema.Table; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 基于 {@link DataPermissionRule} 的数据权限处理器 |
| | | * |
| | | * 它的底层,是基于 MyBatis Plus 的 <a href="https://baomidou.com/plugins/data-permission/">数据权限插件</a> |
| | | * 核心原理:它会在 SQL 执行前拦截 SQL 语句,并根据用户权限动态添加权限相关的 SQL 片段。这样,只有用户有权限访问的数据才会被查询出来 |
| | | * |
| | | * @author 芋道源码 |
| | | */ |
| | | @RequiredArgsConstructor |
| | | public class DataPermissionRuleHandler implements MultiDataPermissionHandler { |
| | | |
| | | private final DataPermissionRuleFactory ruleFactory; |
| | | |
| | | @Override |
| | | public Expression getSqlSegment(Table table, Expression where, String mappedStatementId) { |
| | | // 获得 Mapper 对应的数据权限的规则 |
| | | List<DataPermissionRule> rules = ruleFactory.getDataPermissionRule(mappedStatementId); |
| | | if (CollUtil.isEmpty(rules)) { |
| | | return null; |
| | | } |
| | | |
| | | // 生成条件 |
| | | Expression allExpression = null; |
| | | for (DataPermissionRule rule : rules) { |
| | | // 判断表名是否匹配 |
| | | String tableName = MyBatisUtils.getTableName(table); |
| | | if (!rule.getTableNames().contains(tableName)) { |
| | | continue; |
| | | } |
| | | |
| | | // 单条规则的条件 |
| | | Expression oneExpress = rule.getExpression(tableName, table.getAlias()); |
| | | if (oneExpress == null) { |
| | | continue; |
| | | } |
| | | // 拼接到 allExpression 中 |
| | | allExpression = allExpression == null ? oneExpress |
| | | : new AndExpression(allExpression, oneExpress); |
| | | } |
| | | return allExpression; |
| | | } |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.framework.datapermission.core.db; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.inner.DataPermissionInterceptor; |
| | | import com.iailab.framework.datapermission.core.rule.DataPermissionRule; |
| | | import com.iailab.framework.datapermission.core.rule.DataPermissionRuleFactory; |
| | | import com.iailab.framework.mybatis.core.util.MyBatisUtils; |
| | | import com.iailab.framework.test.core.ut.BaseMockitoUnitTest; |
| | | import net.sf.jsqlparser.expression.Alias; |
| | | import net.sf.jsqlparser.expression.Expression; |
| | | import net.sf.jsqlparser.expression.LongValue; |
| | | import net.sf.jsqlparser.expression.Parenthesis; |
| | | import net.sf.jsqlparser.expression.operators.relational.EqualsTo; |
| | | import net.sf.jsqlparser.expression.operators.relational.ExpressionList; |
| | | import net.sf.jsqlparser.expression.operators.relational.InExpression; |
| | | import net.sf.jsqlparser.schema.Column; |
| | | import org.junit.jupiter.api.BeforeEach; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.mockito.InjectMocks; |
| | | import org.mockito.Mock; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Set; |
| | | |
| | | import static com.iailab.framework.common.util.collection.SetUtils.asSet; |
| | | import static org.junit.jupiter.api.Assertions.assertEquals; |
| | | import static org.mockito.ArgumentMatchers.any; |
| | | import static org.mockito.Mockito.when; |
| | | |
| | | /** |
| | | * {@link DataPermissionRuleHandler} 的单元测试 |
| | | * 主要复用了 MyBatis Plus 的 TenantLineInnerInterceptorTest 的单元测试 |
| | | * 不过它的单元测试不是很规范,考虑到是复用的,所以暂时不进行修改~ |
| | | * |
| | | * @author 芋道源码 |
| | | */ |
| | | public class DataPermissionRuleHandlerTest extends BaseMockitoUnitTest { |
| | | |
| | | @InjectMocks |
| | | private DataPermissionRuleHandler handler; |
| | | |
| | | @Mock |
| | | private DataPermissionRuleFactory ruleFactory; |
| | | |
| | | private DataPermissionInterceptor interceptor; |
| | | |
| | | @BeforeEach |
| | | public void setUp() { |
| | | interceptor = new DataPermissionInterceptor(handler); |
| | | |
| | | // 租户的数据权限规则 |
| | | DataPermissionRule tenantRule = new DataPermissionRule() { |
| | | |
| | | private static final String COLUMN = "tenant_id"; |
| | | |
| | | @Override |
| | | public Set<String> getTableNames() { |
| | | return asSet("entity", "entity1", "entity2", "entity3", "t1", "t2", "sys_dict_item", // 支持 MyBatis Plus 的单元测试 |
| | | "t_user", "t_role"); // 满足自己的单元测试 |
| | | } |
| | | |
| | | @Override |
| | | public Expression getExpression(String tableName, Alias tableAlias) { |
| | | Column column = MyBatisUtils.buildColumn(tableName, tableAlias, COLUMN); |
| | | LongValue value = new LongValue(1L); |
| | | return new EqualsTo(column, value); |
| | | } |
| | | |
| | | }; |
| | | // 部门的数据权限规则 |
| | | DataPermissionRule deptRule = new DataPermissionRule() { |
| | | |
| | | private static final String COLUMN = "dept_id"; |
| | | |
| | | @Override |
| | | public Set<String> getTableNames() { |
| | | return asSet("t_user"); // 满足自己的单元测试 |
| | | } |
| | | |
| | | @Override |
| | | public Expression getExpression(String tableName, Alias tableAlias) { |
| | | Column column = MyBatisUtils.buildColumn(tableName, tableAlias, COLUMN); |
| | | ExpressionList<LongValue> values = new ExpressionList<>(new LongValue(10L), |
| | | new LongValue(20L)); |
| | | return new InExpression(column, new Parenthesis((values))); |
| | | } |
| | | |
| | | }; |
| | | // 设置到上下文 |
| | | when(ruleFactory.getDataPermissionRule(any())).thenReturn(Arrays.asList(tenantRule, deptRule)); |
| | | } |
| | | |
| | | @Test |
| | | void delete() { |
| | | assertSql("delete from entity where id = ?", |
| | | "DELETE FROM entity WHERE id = ? AND entity.tenant_id = 1"); |
| | | } |
| | | |
| | | @Test |
| | | void update() { |
| | | assertSql("update entity set name = ? where id = ?", |
| | | "UPDATE entity SET name = ? WHERE id = ? AND entity.tenant_id = 1"); |
| | | } |
| | | |
| | | @Test |
| | | void selectSingle() { |
| | | // 单表 |
| | | assertSql("select * from entity where id = ?", |
| | | "SELECT * FROM entity WHERE id = ? AND entity.tenant_id = 1"); |
| | | |
| | | assertSql("select * from entity where id = ? or name = ?", |
| | | "SELECT * FROM entity WHERE (id = ? OR name = ?) AND entity.tenant_id = 1"); |
| | | |
| | | assertSql("SELECT * FROM entity WHERE (id = ? OR name = ?)", |
| | | "SELECT * FROM entity WHERE (id = ? OR name = ?) AND entity.tenant_id = 1"); |
| | | |
| | | /* not */ |
| | | assertSql("SELECT * FROM entity WHERE not (id = ? OR name = ?)", |
| | | "SELECT * FROM entity WHERE NOT (id = ? OR name = ?) AND entity.tenant_id = 1"); |
| | | } |
| | | |
| | | @Test |
| | | void selectSubSelectIn() { |
| | | /* in */ |
| | | assertSql("SELECT * FROM entity e WHERE e.id IN (select e1.id from entity1 e1 where e1.id = ?)", |
| | | "SELECT * FROM entity e WHERE e.id IN (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.tenant_id = 1"); |
| | | // 在最前 |
| | | assertSql("SELECT * FROM entity e WHERE e.id IN " + |
| | | "(select e1.id from entity1 e1 where e1.id = ?) and e.id = ?", |
| | | "SELECT * FROM entity e WHERE e.id IN " + |
| | | "(SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.id = ? AND e.tenant_id = 1"); |
| | | // 在最后 |
| | | assertSql("SELECT * FROM entity e WHERE e.id = ? and e.id IN " + |
| | | "(select e1.id from entity1 e1 where e1.id = ?)", |
| | | "SELECT * FROM entity e WHERE e.id = ? AND e.id IN " + |
| | | "(SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.tenant_id = 1"); |
| | | // 在中间 |
| | | assertSql("SELECT * FROM entity e WHERE e.id = ? and e.id IN " + |
| | | "(select e1.id from entity1 e1 where e1.id = ?) and e.id = ?", |
| | | "SELECT * FROM entity e WHERE e.id = ? AND e.id IN " + |
| | | "(SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.id = ? AND e.tenant_id = 1"); |
| | | } |
| | | |
| | | @Test |
| | | void selectSubSelectEq() { |
| | | /* = */ |
| | | assertSql("SELECT * FROM entity e WHERE e.id = (select e1.id from entity1 e1 where e1.id = ?)", |
| | | "SELECT * FROM entity e WHERE e.id = (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.tenant_id = 1"); |
| | | } |
| | | |
| | | @Test |
| | | void selectSubSelectInnerNotEq() { |
| | | /* inner not = */ |
| | | assertSql("SELECT * FROM entity e WHERE not (e.id = (select e1.id from entity1 e1 where e1.id = ?))", |
| | | "SELECT * FROM entity e WHERE NOT (e.id = (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1)) AND e.tenant_id = 1"); |
| | | |
| | | assertSql("SELECT * FROM entity e WHERE not (e.id = (select e1.id from entity1 e1 where e1.id = ?) and e.id = ?)", |
| | | "SELECT * FROM entity e WHERE NOT (e.id = (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.id = ?) AND e.tenant_id = 1"); |
| | | } |
| | | |
| | | @Test |
| | | void selectSubSelectExists() { |
| | | /* EXISTS */ |
| | | assertSql("SELECT * FROM entity e WHERE EXISTS (select e1.id from entity1 e1 where e1.id = ?)", |
| | | "SELECT * FROM entity e WHERE EXISTS (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.tenant_id = 1"); |
| | | |
| | | |
| | | /* NOT EXISTS */ |
| | | assertSql("SELECT * FROM entity e WHERE NOT EXISTS (select e1.id from entity1 e1 where e1.id = ?)", |
| | | "SELECT * FROM entity e WHERE NOT EXISTS (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.tenant_id = 1"); |
| | | } |
| | | |
| | | @Test |
| | | void selectSubSelect() { |
| | | /* >= */ |
| | | assertSql("SELECT * FROM entity e WHERE e.id >= (select e1.id from entity1 e1 where e1.id = ?)", |
| | | "SELECT * FROM entity e WHERE e.id >= (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.tenant_id = 1"); |
| | | |
| | | |
| | | /* <= */ |
| | | assertSql("SELECT * FROM entity e WHERE e.id <= (select e1.id from entity1 e1 where e1.id = ?)", |
| | | "SELECT * FROM entity e WHERE e.id <= (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.tenant_id = 1"); |
| | | |
| | | |
| | | /* <> */ |
| | | assertSql("SELECT * FROM entity e WHERE e.id <> (select e1.id from entity1 e1 where e1.id = ?)", |
| | | "SELECT * FROM entity e WHERE e.id <> (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.tenant_id = 1"); |
| | | } |
| | | |
| | | @Test |
| | | void selectFromSelect() { |
| | | assertSql("SELECT * FROM (select e.id from entity e WHERE e.id = (select e1.id from entity1 e1 where e1.id = ?))", |
| | | "SELECT * FROM (SELECT e.id FROM entity e WHERE e.id = (SELECT e1.id FROM entity1 e1 WHERE e1.id = ? AND e1.tenant_id = 1) AND e.tenant_id = 1)"); |
| | | } |
| | | |
| | | @Test |
| | | void selectBodySubSelect() { |
| | | assertSql("select t1.col1,(select t2.col2 from t2 t2 where t1.col1=t2.col1) from t1 t1", |
| | | "SELECT t1.col1, (SELECT t2.col2 FROM t2 t2 WHERE t1.col1 = t2.col1 AND t2.tenant_id = 1) FROM t1 t1 WHERE t1.tenant_id = 1"); |
| | | } |
| | | |
| | | @Test |
| | | void selectLeftJoin() { |
| | | // left join |
| | | assertSql("SELECT * FROM entity e " + |
| | | "left join entity1 e1 on e1.id = e.id " + |
| | | "WHERE e.id = ? OR e.name = ?", |
| | | "SELECT * FROM entity e " + |
| | | "LEFT JOIN entity1 e1 ON e1.id = e.id AND e1.tenant_id = 1 " + |
| | | "WHERE (e.id = ? OR e.name = ?) AND e.tenant_id = 1"); |
| | | |
| | | assertSql("SELECT * FROM entity e " + |
| | | "left join entity1 e1 on e1.id = e.id " + |
| | | "WHERE (e.id = ? OR e.name = ?)", |
| | | "SELECT * FROM entity e " + |
| | | "LEFT JOIN entity1 e1 ON e1.id = e.id AND e1.tenant_id = 1 " + |
| | | "WHERE (e.id = ? OR e.name = ?) AND e.tenant_id = 1"); |
| | | |
| | | assertSql("SELECT * FROM entity e " + |
| | | "left join entity1 e1 on e1.id = e.id " + |
| | | "left join entity2 e2 on e1.id = e2.id", |
| | | "SELECT * FROM entity e " + |
| | | "LEFT JOIN entity1 e1 ON e1.id = e.id AND e1.tenant_id = 1 " + |
| | | "LEFT JOIN entity2 e2 ON e1.id = e2.id AND e2.tenant_id = 1 " + |
| | | "WHERE e.tenant_id = 1"); |
| | | } |
| | | |
| | | @Test |
| | | void selectRightJoin() { |
| | | // right join |
| | | assertSql("SELECT * FROM entity e " + |
| | | "right join entity1 e1 on e1.id = e.id", |
| | | "SELECT * FROM entity e " + |
| | | "RIGHT JOIN entity1 e1 ON e1.id = e.id AND e.tenant_id = 1 " + |
| | | "WHERE e1.tenant_id = 1"); |
| | | |
| | | assertSql("SELECT * FROM with_as_1 e " + |
| | | "right join entity1 e1 on e1.id = e.id", |
| | | "SELECT * FROM with_as_1 e " + |
| | | "RIGHT JOIN entity1 e1 ON e1.id = e.id " + |
| | | "WHERE e1.tenant_id = 1"); |
| | | |
| | | assertSql("SELECT * FROM entity e " + |
| | | "right join entity1 e1 on e1.id = e.id " + |
| | | "WHERE e.id = ? OR e.name = ?", |
| | | "SELECT * FROM entity e " + |
| | | "RIGHT JOIN entity1 e1 ON e1.id = e.id AND e.tenant_id = 1 " + |
| | | "WHERE (e.id = ? OR e.name = ?) AND e1.tenant_id = 1"); |
| | | |
| | | assertSql("SELECT * FROM entity e " + |
| | | "right join entity1 e1 on e1.id = e.id " + |
| | | "right join entity2 e2 on e1.id = e2.id ", |
| | | "SELECT * FROM entity e " + |
| | | "RIGHT JOIN entity1 e1 ON e1.id = e.id AND e.tenant_id = 1 " + |
| | | "RIGHT JOIN entity2 e2 ON e1.id = e2.id AND e1.tenant_id = 1 " + |
| | | "WHERE e2.tenant_id = 1"); |
| | | } |
| | | |
| | | @Test |
| | | void selectMixJoin() { |
| | | assertSql("SELECT * FROM entity e " + |
| | | "right join entity1 e1 on e1.id = e.id " + |
| | | "left join entity2 e2 on e1.id = e2.id", |
| | | "SELECT * FROM entity e " + |
| | | "RIGHT JOIN entity1 e1 ON e1.id = e.id AND e.tenant_id = 1 " + |
| | | "LEFT JOIN entity2 e2 ON e1.id = e2.id AND e2.tenant_id = 1 " + |
| | | "WHERE e1.tenant_id = 1"); |
| | | |
| | | assertSql("SELECT * FROM entity e " + |
| | | "left join entity1 e1 on e1.id = e.id " + |
| | | "right join entity2 e2 on e1.id = e2.id", |
| | | "SELECT * FROM entity e " + |
| | | "LEFT JOIN entity1 e1 ON e1.id = e.id AND e1.tenant_id = 1 " + |
| | | "RIGHT JOIN entity2 e2 ON e1.id = e2.id AND e.tenant_id = 1 " + |
| | | "WHERE e2.tenant_id = 1"); |
| | | |
| | | assertSql("SELECT * FROM entity e " + |
| | | "left join entity1 e1 on e1.id = e.id " + |
| | | "inner join entity2 e2 on e1.id = e2.id", |
| | | "SELECT * FROM entity e " + |
| | | "LEFT JOIN entity1 e1 ON e1.id = e.id AND e1.tenant_id = 1 " + |
| | | "INNER JOIN entity2 e2 ON e1.id = e2.id AND e.tenant_id = 1 AND e2.tenant_id = 1"); |
| | | } |
| | | |
| | | |
| | | @Test |
| | | void selectJoinSubSelect() { |
| | | assertSql("select * from (select * from entity) e1 " + |
| | | "left join entity2 e2 on e1.id = e2.id", |
| | | "SELECT * FROM (SELECT * FROM entity WHERE entity.tenant_id = 1) e1 " + |
| | | "LEFT JOIN entity2 e2 ON e1.id = e2.id AND e2.tenant_id = 1"); |
| | | |
| | | assertSql("select * from entity1 e1 " + |
| | | "left join (select * from entity2) e2 " + |
| | | "on e1.id = e2.id", |
| | | "SELECT * FROM entity1 e1 " + |
| | | "LEFT JOIN (SELECT * FROM entity2 WHERE entity2.tenant_id = 1) e2 " + |
| | | "ON e1.id = e2.id " + |
| | | "WHERE e1.tenant_id = 1"); |
| | | } |
| | | |
| | | @Test |
| | | void selectSubJoin() { |
| | | |
| | | assertSql("select * FROM " + |
| | | "(entity1 e1 right JOIN entity2 e2 ON e1.id = e2.id)", |
| | | "SELECT * FROM " + |
| | | "(entity1 e1 RIGHT JOIN entity2 e2 ON e1.id = e2.id AND e1.tenant_id = 1) " + |
| | | "WHERE e2.tenant_id = 1"); |
| | | |
| | | assertSql("select * FROM " + |
| | | "(entity1 e1 LEFT JOIN entity2 e2 ON e1.id = e2.id)", |
| | | "SELECT * FROM " + |
| | | "(entity1 e1 LEFT JOIN entity2 e2 ON e1.id = e2.id AND e2.tenant_id = 1) " + |
| | | "WHERE e1.tenant_id = 1"); |
| | | |
| | | |
| | | assertSql("select * FROM " + |
| | | "(entity1 e1 LEFT JOIN entity2 e2 ON e1.id = e2.id) " + |
| | | "right join entity3 e3 on e1.id = e3.id", |
| | | "SELECT * FROM " + |
| | | "(entity1 e1 LEFT JOIN entity2 e2 ON e1.id = e2.id AND e2.tenant_id = 1) " + |
| | | "RIGHT JOIN entity3 e3 ON e1.id = e3.id AND e1.tenant_id = 1 " + |
| | | "WHERE e3.tenant_id = 1"); |
| | | |
| | | |
| | | assertSql("select * FROM entity e " + |
| | | "LEFT JOIN (entity1 e1 right join entity2 e2 ON e1.id = e2.id) " + |
| | | "on e.id = e2.id", |
| | | "SELECT * FROM entity e " + |
| | | "LEFT JOIN (entity1 e1 RIGHT JOIN entity2 e2 ON e1.id = e2.id AND e1.tenant_id = 1) " + |
| | | "ON e.id = e2.id AND e2.tenant_id = 1 " + |
| | | "WHERE e.tenant_id = 1"); |
| | | |
| | | assertSql("select * FROM entity e " + |
| | | "LEFT JOIN (entity1 e1 left join entity2 e2 ON e1.id = e2.id) " + |
| | | "on e.id = e2.id", |
| | | "SELECT * FROM entity e " + |
| | | "LEFT JOIN (entity1 e1 LEFT JOIN entity2 e2 ON e1.id = e2.id AND e2.tenant_id = 1) " + |
| | | "ON e.id = e2.id AND e1.tenant_id = 1 " + |
| | | "WHERE e.tenant_id = 1"); |
| | | |
| | | assertSql("select * FROM entity e " + |
| | | "RIGHT JOIN (entity1 e1 left join entity2 e2 ON e1.id = e2.id) " + |
| | | "on e.id = e2.id", |
| | | "SELECT * FROM entity e " + |
| | | "RIGHT JOIN (entity1 e1 LEFT JOIN entity2 e2 ON e1.id = e2.id AND e2.tenant_id = 1) " + |
| | | "ON e.id = e2.id AND e.tenant_id = 1 " + |
| | | "WHERE e1.tenant_id = 1"); |
| | | } |
| | | |
| | | |
| | | @Test |
| | | void selectLeftJoinMultipleTrailingOn() { |
| | | // 多个 on 尾缀的 |
| | | assertSql("SELECT * FROM entity e " + |
| | | "LEFT JOIN entity1 e1 " + |
| | | "LEFT JOIN entity2 e2 ON e2.id = e1.id " + |
| | | "ON e1.id = e.id " + |
| | | "WHERE (e.id = ? OR e.NAME = ?)", |
| | | "SELECT * FROM entity e " + |
| | | "LEFT JOIN entity1 e1 " + |
| | | "LEFT JOIN entity2 e2 ON e2.id = e1.id AND e2.tenant_id = 1 " + |
| | | "ON e1.id = e.id AND e1.tenant_id = 1 " + |
| | | "WHERE (e.id = ? OR e.NAME = ?) AND e.tenant_id = 1"); |
| | | |
| | | assertSql("SELECT * FROM entity e " + |
| | | "LEFT JOIN entity1 e1 " + |
| | | "LEFT JOIN with_as_A e2 ON e2.id = e1.id " + |
| | | "ON e1.id = e.id " + |
| | | "WHERE (e.id = ? OR e.NAME = ?)", |
| | | "SELECT * FROM entity e " + |
| | | "LEFT JOIN entity1 e1 " + |
| | | "LEFT JOIN with_as_A e2 ON e2.id = e1.id " + |
| | | "ON e1.id = e.id AND e1.tenant_id = 1 " + |
| | | "WHERE (e.id = ? OR e.NAME = ?) AND e.tenant_id = 1"); |
| | | } |
| | | |
| | | @Test |
| | | void selectInnerJoin() { |
| | | // inner join |
| | | assertSql("SELECT * FROM entity e " + |
| | | "inner join entity1 e1 on e1.id = e.id " + |
| | | "WHERE e.id = ? OR e.name = ?", |
| | | "SELECT * FROM entity e " + |
| | | "INNER JOIN entity1 e1 ON e1.id = e.id AND e.tenant_id = 1 AND e1.tenant_id = 1 " + |
| | | "WHERE e.id = ? OR e.name = ?"); |
| | | |
| | | assertSql("SELECT * FROM entity e " + |
| | | "inner join entity1 e1 on e1.id = e.id " + |
| | | "WHERE (e.id = ? OR e.name = ?)", |
| | | "SELECT * FROM entity e " + |
| | | "INNER JOIN entity1 e1 ON e1.id = e.id AND e.tenant_id = 1 AND e1.tenant_id = 1 " + |
| | | "WHERE (e.id = ? OR e.name = ?)"); |
| | | |
| | | // 隐式内连接 |
| | | assertSql("SELECT * FROM entity,entity1 " + |
| | | "WHERE entity.id = entity1.id", |
| | | "SELECT * FROM entity, entity1 " + |
| | | "WHERE entity.id = entity1.id AND entity.tenant_id = 1 AND entity1.tenant_id = 1"); |
| | | |
| | | // 隐式内连接 |
| | | assertSql("SELECT * FROM entity a, with_as_entity1 b " + |
| | | "WHERE a.id = b.id", |
| | | "SELECT * FROM entity a, with_as_entity1 b " + |
| | | "WHERE a.id = b.id AND a.tenant_id = 1"); |
| | | |
| | | assertSql("SELECT * FROM with_as_entity a, with_as_entity1 b " + |
| | | "WHERE a.id = b.id", |
| | | "SELECT * FROM with_as_entity a, with_as_entity1 b " + |
| | | "WHERE a.id = b.id"); |
| | | |
| | | // SubJoin with 隐式内连接 |
| | | assertSql("SELECT * FROM (entity,entity1) " + |
| | | "WHERE entity.id = entity1.id", |
| | | "SELECT * FROM (entity, entity1) " + |
| | | "WHERE entity.id = entity1.id " + |
| | | "AND entity.tenant_id = 1 AND entity1.tenant_id = 1"); |
| | | |
| | | assertSql("SELECT * FROM ((entity,entity1),entity2) " + |
| | | "WHERE entity.id = entity1.id and entity.id = entity2.id", |
| | | "SELECT * FROM ((entity, entity1), entity2) " + |
| | | "WHERE entity.id = entity1.id AND entity.id = entity2.id " + |
| | | "AND entity.tenant_id = 1 AND entity1.tenant_id = 1 AND entity2.tenant_id = 1"); |
| | | |
| | | assertSql("SELECT * FROM (entity,(entity1,entity2)) " + |
| | | "WHERE entity.id = entity1.id and entity.id = entity2.id", |
| | | "SELECT * FROM (entity, (entity1, entity2)) " + |
| | | "WHERE entity.id = entity1.id AND entity.id = entity2.id " + |
| | | "AND entity.tenant_id = 1 AND entity1.tenant_id = 1 AND entity2.tenant_id = 1"); |
| | | |
| | | // 沙雕的括号写法 |
| | | assertSql("SELECT * FROM (((entity,entity1))) " + |
| | | "WHERE entity.id = entity1.id", |
| | | "SELECT * FROM (((entity, entity1))) " + |
| | | "WHERE entity.id = entity1.id " + |
| | | "AND entity.tenant_id = 1 AND entity1.tenant_id = 1"); |
| | | |
| | | } |
| | | |
| | | |
| | | @Test |
| | | void selectWithAs() { |
| | | assertSql("with with_as_A as (select * from entity) select * from with_as_A", |
| | | "WITH with_as_A AS (SELECT * FROM entity WHERE entity.tenant_id = 1) SELECT * FROM with_as_A"); |
| | | } |
| | | |
| | | |
| | | @Test |
| | | void selectIgnoreTable() { |
| | | assertSql(" SELECT dict.dict_code, item.item_text AS \"text\", item.item_value AS \"value\" FROM sys_dict_item item INNER JOIN sys_dict dict ON dict.id = item.dict_id WHERE dict.dict_code IN (1, 2, 3) AND item.item_value IN (1, 2, 3)", |
| | | "SELECT dict.dict_code, item.item_text AS \"text\", item.item_value AS \"value\" FROM sys_dict_item item INNER JOIN sys_dict dict ON dict.id = item.dict_id AND item.tenant_id = 1 WHERE dict.dict_code IN (1, 2, 3) AND item.item_value IN (1, 2, 3)"); |
| | | } |
| | | |
| | | private void assertSql(String sql, String targetSql) { |
| | | assertEquals(targetSql, interceptor.parserSingle(sql, null)); |
| | | } |
| | | |
| | | // ========== 额外的测试 ========== |
| | | |
| | | @Test |
| | | public void testSelectSingle() { |
| | | // 单表 |
| | | assertSql("select * from t_user where id = ?", |
| | | "SELECT * FROM t_user WHERE id = ? AND t_user.tenant_id = 1 AND t_user.dept_id IN (10, 20)"); |
| | | |
| | | assertSql("select * from t_user where id = ? or name = ?", |
| | | "SELECT * FROM t_user WHERE (id = ? OR name = ?) AND t_user.tenant_id = 1 AND t_user.dept_id IN (10, 20)"); |
| | | |
| | | assertSql("SELECT * FROM t_user WHERE (id = ? OR name = ?)", |
| | | "SELECT * FROM t_user WHERE (id = ? OR name = ?) AND t_user.tenant_id = 1 AND t_user.dept_id IN (10, 20)"); |
| | | |
| | | /* not */ |
| | | assertSql("SELECT * FROM t_user WHERE not (id = ? OR name = ?)", |
| | | "SELECT * FROM t_user WHERE NOT (id = ? OR name = ?) AND t_user.tenant_id = 1 AND t_user.dept_id IN (10, 20)"); |
| | | } |
| | | |
| | | @Test |
| | | public void testSelectLeftJoin() { |
| | | // left join |
| | | assertSql("SELECT * FROM t_user e " + |
| | | "left join t_role e1 on e1.id = e.id " + |
| | | "WHERE e.id = ? OR e.name = ?", |
| | | "SELECT * FROM t_user e " + |
| | | "LEFT JOIN t_role e1 ON e1.id = e.id AND e1.tenant_id = 1 " + |
| | | "WHERE (e.id = ? OR e.name = ?) AND e.tenant_id = 1 AND e.dept_id IN (10, 20)"); |
| | | |
| | | // 条件 e.id = ? OR e.name = ? 带括号 |
| | | assertSql("SELECT * FROM t_user e " + |
| | | "left join t_role e1 on e1.id = e.id " + |
| | | "WHERE (e.id = ? OR e.name = ?)", |
| | | "SELECT * FROM t_user e " + |
| | | "LEFT JOIN t_role e1 ON e1.id = e.id AND e1.tenant_id = 1 " + |
| | | "WHERE (e.id = ? OR e.name = ?) AND e.tenant_id = 1 AND e.dept_id IN (10, 20)"); |
| | | } |
| | | |
| | | @Test |
| | | public void testSelectRightJoin() { |
| | | // right join |
| | | assertSql("SELECT * FROM t_user e " + |
| | | "right join t_role e1 on e1.id = e.id " + |
| | | "WHERE e.id = ? OR e.name = ?", |
| | | "SELECT * FROM t_user e " + |
| | | "RIGHT JOIN t_role e1 ON e1.id = e.id AND e.tenant_id = 1 AND e.dept_id IN (10, 20) " + |
| | | "WHERE (e.id = ? OR e.name = ?) AND e1.tenant_id = 1"); |
| | | |
| | | // 条件 e.id = ? OR e.name = ? 带括号 |
| | | assertSql("SELECT * FROM t_user e " + |
| | | "right join t_role e1 on e1.id = e.id " + |
| | | "WHERE (e.id = ? OR e.name = ?)", |
| | | "SELECT * FROM t_user e " + |
| | | "RIGHT JOIN t_role e1 ON e1.id = e.id AND e.tenant_id = 1 AND e.dept_id IN (10, 20) " + |
| | | "WHERE (e.id = ? OR e.name = ?) AND e1.tenant_id = 1"); |
| | | } |
| | | |
| | | @Test |
| | | public void testSelectInnerJoin() { |
| | | // inner join |
| | | assertSql("SELECT * FROM t_user e " + |
| | | "inner join entity1 e1 on e1.id = e.id " + |
| | | "WHERE e.id = ? OR e.name = ?", |
| | | "SELECT * FROM t_user e " + |
| | | "INNER JOIN entity1 e1 ON e1.id = e.id AND e.tenant_id = 1 AND e.dept_id IN (10, 20) AND e1.tenant_id = 1 " + |
| | | "WHERE e.id = ? OR e.name = ?"); |
| | | |
| | | // 条件 e.id = ? OR e.name = ? 带括号 |
| | | assertSql("SELECT * FROM t_user e " + |
| | | "inner join entity1 e1 on e1.id = e.id " + |
| | | "WHERE (e.id = ? OR e.name = ?)", |
| | | "SELECT * FROM t_user e " + |
| | | "INNER JOIN entity1 e1 ON e1.id = e.id AND e.tenant_id = 1 AND e.dept_id IN (10, 20) AND e1.tenant_id = 1 " + |
| | | "WHERE (e.id = ? OR e.name = ?)"); |
| | | |
| | | // 没有 On 的 inner join |
| | | assertSql("SELECT * FROM entity,entity1 " + |
| | | "WHERE entity.id = entity1.id", |
| | | "SELECT * FROM entity, entity1 " + |
| | | "WHERE entity.id = entity1.id AND entity.tenant_id = 1 AND entity1.tenant_id = 1"); |
| | | } |
| | | |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | * Copyright (c) 2018 人人开源 All rights reserved. |
| | | * |
| | | * https://www.renren.io |
| | | * |
| | | * 版权所有,侵权必究! |
| | | */ |
| | | |
| | | package com.iailab.framework.common.dao; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | |
| | | /** |
| | | * 基础Dao |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | * @since 1.0.0 |
| | | */ |
| | | public interface BaseDao<T> extends BaseMapper<T> { |
| | | |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | * Copyright (c) 2018 人人开源 All rights reserved. |
| | | * |
| | | * https://www.renren.io |
| | | * |
| | | * 版权所有,侵权必究! |
| | | */ |
| | | |
| | | package com.iailab.framework.common.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 基础实体类,所有实体都需要继承 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | */ |
| | | @Data |
| | | public abstract class BaseEntity implements Serializable { |
| | | /** |
| | | * id |
| | | */ |
| | | @TableId |
| | | private Long id; |
| | | /** |
| | | * 创建者 |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Long creator; |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Date createDate; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.framework.common; |
对比新文件 |
| | |
| | | /** |
| | | * Copyright (c) 2018 人人开源 All rights reserved. |
| | | * |
| | | * https://www.renren.io |
| | | * |
| | | * 版权所有,侵权必究! |
| | | */ |
| | | |
| | | package com.iailab.framework.common.page; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 分页工具类 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | */ |
| | | @Data |
| | | @Tag(name = "分页数据") |
| | | public class PageData<T> implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @Schema(description = "总记录数") |
| | | private int total; |
| | | |
| | | @Schema(description = "列表数据") |
| | | private List<T> list; |
| | | |
| | | /** |
| | | * 分页 |
| | | * @param list 列表数据 |
| | | * @param total 总记录数 |
| | | */ |
| | | public PageData(List<T> list, long total) { |
| | | this.list = list; |
| | | this.total = (int)total; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | * Copyright (c) 2018 人人开源 All rights reserved. |
| | | * |
| | | * https://www.renren.io |
| | | * |
| | | * 版权所有,侵权必究! |
| | | */ |
| | | |
| | | package com.iailab.framework.common.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Collection; |
| | | |
| | | /** |
| | | * 基础服务接口,所有Service接口都要继承 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | */ |
| | | public interface BaseService<T> { |
| | | Class<T> currentModelClass(); |
| | | |
| | | /** |
| | | * <p> |
| | | * 插入一条记录(选择字段,策略插入) |
| | | * </p> |
| | | * |
| | | * @param entity 实体对象 |
| | | */ |
| | | boolean insert(T entity); |
| | | |
| | | /** |
| | | * <p> |
| | | * 插入(批量),该方法不支持 Oracle、SQL Server |
| | | * </p> |
| | | * |
| | | * @param entityList 实体对象集合 |
| | | */ |
| | | boolean insertBatch(Collection<T> entityList); |
| | | |
| | | /** |
| | | * <p> |
| | | * 插入(批量),该方法不支持 Oracle、SQL Server |
| | | * </p> |
| | | * |
| | | * @param entityList 实体对象集合 |
| | | * @param batchSize 插入批次数量 |
| | | */ |
| | | boolean insertBatch(Collection<T> entityList, int batchSize); |
| | | |
| | | /** |
| | | * <p> |
| | | * 根据 ID 选择修改 |
| | | * </p> |
| | | * |
| | | * @param entity 实体对象 |
| | | */ |
| | | boolean updateById(T entity); |
| | | |
| | | /** |
| | | * <p> |
| | | * 根据 whereEntity 条件,更新记录 |
| | | * </p> |
| | | * |
| | | * @param entity 实体对象 |
| | | * @param updateWrapper 实体对象封装操作类 {@link com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper} |
| | | */ |
| | | boolean update(T entity, Wrapper<T> updateWrapper); |
| | | |
| | | /** |
| | | * <p> |
| | | * 根据ID 批量更新 |
| | | * </p> |
| | | * |
| | | * @param entityList 实体对象集合 |
| | | */ |
| | | boolean updateBatchById(Collection<T> entityList); |
| | | |
| | | /** |
| | | * <p> |
| | | * 根据ID 批量更新 |
| | | * </p> |
| | | * |
| | | * @param entityList 实体对象集合 |
| | | * @param batchSize 更新批次数量 |
| | | */ |
| | | boolean updateBatchById(Collection<T> entityList, int batchSize); |
| | | |
| | | /** |
| | | * <p> |
| | | * 根据 ID 查询 |
| | | * </p> |
| | | * |
| | | * @param id 主键ID |
| | | */ |
| | | T selectById(Serializable id); |
| | | |
| | | /** |
| | | * <p> |
| | | * 根据 ID 删除 |
| | | * </p> |
| | | * |
| | | * @param id 主键ID |
| | | */ |
| | | boolean deleteById(Serializable id); |
| | | |
| | | /** |
| | | * <p> |
| | | * 删除(根据ID 批量删除) |
| | | * </p> |
| | | * |
| | | * @param idList 主键ID列表 |
| | | */ |
| | | boolean deleteBatchIds(Collection<? extends Serializable> idList); |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | * Copyright (c) 2018 人人开源 All rights reserved. |
| | | * <p> |
| | | * https://www.renren.io |
| | | * <p> |
| | | * 版权所有,侵权必究! |
| | | */ |
| | | |
| | | package com.iailab.framework.common.service; |
| | | |
| | | import com.iailab.framework.common.page.PageData; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * CRUD基础服务接口 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | */ |
| | | public interface CrudService<T, D> extends BaseService<T> { |
| | | |
| | | PageData<D> page(Map<String, Object> params); |
| | | |
| | | List<D> list(Map<String, Object> params); |
| | | |
| | | D get(Long id); |
| | | |
| | | void save(D dto); |
| | | |
| | | void update(D dto); |
| | | |
| | | void delete(Long[] ids); |
| | | |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | * Copyright (c) 2018 人人开源 All rights reserved. |
| | | * |
| | | * https://www.renren.io |
| | | * |
| | | * 版权所有,侵权必究! |
| | | */ |
| | | |
| | | package com.iailab.framework.common.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.enums.SqlMethod; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.metadata.OrderItem; |
| | | import com.baomidou.mybatisplus.core.toolkit.Constants; |
| | | import com.baomidou.mybatisplus.core.toolkit.ReflectionKit; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.toolkit.SqlHelper; |
| | | import com.iailab.framework.common.constant.Constant; |
| | | import com.iailab.framework.common.page.PageData; |
| | | import com.iailab.framework.common.service.BaseService; |
| | | import com.iailab.framework.common.util.object.BeanUtils; |
| | | import org.apache.ibatis.binding.MapperMethod; |
| | | import org.apache.ibatis.logging.Log; |
| | | import org.apache.ibatis.logging.LogFactory; |
| | | import org.apache.ibatis.session.SqlSession; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.function.BiConsumer; |
| | | |
| | | /** |
| | | * 基础服务类,所有Service都要继承 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | */ |
| | | public abstract class BaseServiceImpl<M extends BaseMapper<T>, T> implements BaseService<T> { |
| | | @Autowired |
| | | protected M baseDao; |
| | | protected Log log = LogFactory.getLog(getClass()); |
| | | |
| | | /** |
| | | * 获取分页对象 |
| | | * @param params 分页查询参数 |
| | | * @param defaultOrderField 默认排序字段 |
| | | * @param isAsc 排序方式 |
| | | */ |
| | | protected IPage<T> getPage(Map<String, Object> params, String defaultOrderField, boolean isAsc) { |
| | | //分页参数 |
| | | long curPage = 1; |
| | | long limit = 10; |
| | | |
| | | if(params.get(Constant.PAGE) != null){ |
| | | curPage = Long.parseLong((String)params.get(Constant.PAGE)); |
| | | } |
| | | if(params.get(Constant.LIMIT) != null){ |
| | | limit = Long.parseLong((String)params.get(Constant.LIMIT)); |
| | | } |
| | | |
| | | //分页对象 |
| | | Page<T> page = new Page<>(curPage, limit); |
| | | |
| | | //分页参数 |
| | | params.put(Constant.PAGE, page); |
| | | |
| | | //排序字段 |
| | | String orderField = (String)params.get(Constant.ORDER_FIELD); |
| | | String order = (String)params.get(Constant.ORDER); |
| | | |
| | | //前端字段排序 |
| | | if(StringUtils.isNotBlank(orderField) && StringUtils.isNotBlank(order)){ |
| | | if(Constant.ASC.equalsIgnoreCase(order)) { |
| | | return page.addOrder(OrderItem.asc(orderField)); |
| | | }else { |
| | | return page.addOrder(OrderItem.desc(orderField)); |
| | | } |
| | | } |
| | | |
| | | //没有排序字段,则不排序 |
| | | if(StringUtils.isBlank(defaultOrderField)){ |
| | | return page; |
| | | } |
| | | |
| | | //默认排序 |
| | | if(isAsc) { |
| | | page.addOrder(OrderItem.asc(defaultOrderField)); |
| | | }else { |
| | | page.addOrder(OrderItem.desc(defaultOrderField)); |
| | | } |
| | | |
| | | return page; |
| | | } |
| | | |
| | | protected <T> PageData<T> getPageData(List<?> list, long total, Class<T> target){ |
| | | List<T> targetList = BeanUtils.toBean(list, target); |
| | | |
| | | return new PageData<>(targetList, total); |
| | | } |
| | | |
| | | protected <T> PageData<T> getPageData(IPage page, Class<T> target){ |
| | | return getPageData(page.getRecords(), page.getTotal(), target); |
| | | } |
| | | |
| | | protected void paramsToLike(Map<String, Object> params, String... likes){ |
| | | for (String like : likes){ |
| | | String val = (String)params.get(like); |
| | | if (StringUtils.isNotBlank(val)){ |
| | | params.put(like, "%" + val + "%"); |
| | | }else { |
| | | params.put(like, null); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * <p> |
| | | * 判断数据库操作是否成功 |
| | | * </p> |
| | | * <p> |
| | | * 注意!! 该方法为 Integer 判断,不可传入 int 基本类型 |
| | | * </p> |
| | | * |
| | | * @param result 数据库操作返回影响条数 |
| | | * @return boolean |
| | | */ |
| | | protected static boolean retBool(Integer result) { |
| | | return SqlHelper.retBool(result); |
| | | } |
| | | |
| | | protected Class<M> currentMapperClass() { |
| | | return (Class<M>) ReflectionKit.getSuperClassGenericType(this.getClass(), BaseServiceImpl.class, 0); |
| | | } |
| | | |
| | | @Override |
| | | public Class<T> currentModelClass() { |
| | | return (Class<T>)ReflectionKit.getSuperClassGenericType(this.getClass(), BaseServiceImpl.class, 1); |
| | | } |
| | | |
| | | protected String getSqlStatement(SqlMethod sqlMethod) { |
| | | return SqlHelper.getSqlStatement(this.currentMapperClass(), sqlMethod); |
| | | } |
| | | |
| | | @Override |
| | | public boolean insert(T entity) { |
| | | return BaseServiceImpl.retBool(baseDao.insert(entity)); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean insertBatch(Collection<T> entityList) { |
| | | return insertBatch(entityList, 100); |
| | | } |
| | | |
| | | /** |
| | | * 批量插入 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean insertBatch(Collection<T> entityList, int batchSize) { |
| | | String sqlStatement = getSqlStatement(SqlMethod.INSERT_ONE); |
| | | return executeBatch(entityList, batchSize, (sqlSession, entity) -> sqlSession.insert(sqlStatement, entity)); |
| | | } |
| | | |
| | | /** |
| | | * 执行批量操作 |
| | | */ |
| | | protected <E> boolean executeBatch(Collection<E> list, int batchSize, BiConsumer<SqlSession, E> consumer) { |
| | | return SqlHelper.executeBatch(this.currentModelClass(), this.log, list, batchSize, consumer); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public boolean updateById(T entity) { |
| | | return BaseServiceImpl.retBool(baseDao.updateById(entity)); |
| | | } |
| | | |
| | | @Override |
| | | public boolean update(T entity, Wrapper<T> updateWrapper) { |
| | | return BaseServiceImpl.retBool(baseDao.update(entity, updateWrapper)); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean updateBatchById(Collection<T> entityList) { |
| | | return updateBatchById(entityList, 30); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean updateBatchById(Collection<T> entityList, int batchSize) { |
| | | String sqlStatement = getSqlStatement(SqlMethod.UPDATE_BY_ID); |
| | | return executeBatch(entityList, batchSize, (sqlSession, entity) -> { |
| | | MapperMethod.ParamMap<T> param = new MapperMethod.ParamMap<>(); |
| | | param.put(Constants.ENTITY, entity); |
| | | sqlSession.update(sqlStatement, param); |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public T selectById(Serializable id) { |
| | | return baseDao.selectById(id); |
| | | } |
| | | |
| | | @Override |
| | | public boolean deleteById(Serializable id) { |
| | | return SqlHelper.retBool(baseDao.deleteById(id)); |
| | | } |
| | | |
| | | @Override |
| | | public boolean deleteBatchIds(Collection<? extends Serializable> idList) { |
| | | return SqlHelper.retBool(baseDao.deleteBatchIds(idList)); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | * Copyright (c) 2018 人人开源 All rights reserved. |
| | | * <p> |
| | | * https://www.renren.io |
| | | * <p> |
| | | * 版权所有,侵权必究! |
| | | */ |
| | | |
| | | package com.iailab.framework.common.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.ReflectionKit; |
| | | import com.iailab.framework.common.page.PageData; |
| | | import com.iailab.framework.common.service.CrudService; |
| | | import com.iailab.framework.common.util.object.ConvertUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * CRUD基础服务类 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | */ |
| | | public abstract class CrudServiceImpl<M extends BaseMapper<T>, T, D> extends BaseServiceImpl<M, T> implements CrudService<T, D> { |
| | | |
| | | protected Class<D> currentDtoClass() { |
| | | return (Class<D>)ReflectionKit.getSuperClassGenericType(getClass(), CrudServiceImpl.class, 2); |
| | | } |
| | | |
| | | @Override |
| | | public PageData<D> page(Map<String, Object> params) { |
| | | IPage<T> page = baseDao.selectPage( |
| | | getPage(params, null, false), |
| | | getWrapper(params) |
| | | ); |
| | | |
| | | return getPageData(page, currentDtoClass()); |
| | | } |
| | | |
| | | @Override |
| | | public List<D> list(Map<String, Object> params) { |
| | | List<T> entityList = baseDao.selectList(getWrapper(params)); |
| | | |
| | | return ConvertUtils.sourceToTarget(entityList, currentDtoClass()); |
| | | } |
| | | |
| | | public abstract QueryWrapper<T> getWrapper(Map<String, Object> params); |
| | | |
| | | @Override |
| | | public D get(Long id) { |
| | | T entity = baseDao.selectById(id); |
| | | |
| | | return ConvertUtils.sourceToTarget(entity, currentDtoClass()); |
| | | } |
| | | |
| | | @Override |
| | | public void save(D dto) { |
| | | T entity = ConvertUtils.sourceToTarget(dto, currentModelClass()); |
| | | insert(entity); |
| | | |
| | | //copy主键值到dto |
| | | BeanUtils.copyProperties(entity, dto); |
| | | } |
| | | |
| | | @Override |
| | | public void update(D dto) { |
| | | T entity = ConvertUtils.sourceToTarget(dto, currentModelClass()); |
| | | updateById(entity); |
| | | } |
| | | |
| | | @Override |
| | | public void delete(Long[] ids) { |
| | | baseDao.deleteBatchIds(Arrays.asList(ids)); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.framework.mybatis.core.enums; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.annotation.DbType; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Map; |
| | | import java.util.Optional; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 针对 MyBatis Plus 的 {@link DbType} 增强,补充更多信息 |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum DbTypeEnum { |
| | | |
| | | /** |
| | | * MySQL |
| | | */ |
| | | MY_SQL( DbType.MYSQL, "MySQL", "FIND_IN_SET('#{value}', #{column}) <> 0"), |
| | | |
| | | /** |
| | | * Oracle |
| | | */ |
| | | ORACLE(DbType.ORACLE, "Oracle", "FIND_IN_SET('#{value}', #{column}) <> 0"), |
| | | |
| | | /** |
| | | * PostgreSQL |
| | | * |
| | | * 华为 openGauss 使用 ProductName 与 PostgreSQL 相同 |
| | | */ |
| | | POSTGRE_SQL(DbType.POSTGRE_SQL,"PostgreSQL", "POSITION('#{value}' IN #{column}) <> 0"), |
| | | |
| | | /** |
| | | * SQL Server |
| | | */ |
| | | SQL_SERVER(DbType.SQL_SERVER, "Microsoft SQL Server", "CHARINDEX(',' + #{value} + ',', ',' + #{column} + ',') <> 0"), |
| | | |
| | | /** |
| | | * 达梦 |
| | | */ |
| | | DM(DbType.DM, "DM DBMS", "FIND_IN_SET('#{value}', #{column}) <> 0"), |
| | | |
| | | /** |
| | | * 人大金仓 |
| | | */ |
| | | KINGBASE_ES(DbType.KINGBASE_ES, "KingbaseES", "POSITION('#{value}' IN #{column}) <> 0"), |
| | | ; |
| | | |
| | | public static final Map<String, DbTypeEnum> MAP_BY_NAME = Arrays.stream(values()) |
| | | .collect(Collectors.toMap(DbTypeEnum::getProductName, Function.identity())); |
| | | |
| | | public static final Map<DbType, DbTypeEnum> MAP_BY_MP = Arrays.stream(values()) |
| | | .collect(Collectors.toMap(DbTypeEnum::getMpDbType, Function.identity())); |
| | | |
| | | /** |
| | | * MyBatis Plus 类型 |
| | | */ |
| | | private final DbType mpDbType; |
| | | /** |
| | | * 数据库产品名 |
| | | */ |
| | | private final String productName; |
| | | /** |
| | | * SQL FIND_IN_SET 模板 |
| | | */ |
| | | private final String findInSetTemplate; |
| | | |
| | | public static DbType find(String databaseProductName) { |
| | | if (StrUtil.isBlank(databaseProductName)) { |
| | | return null; |
| | | } |
| | | return MAP_BY_NAME.get(databaseProductName).getMpDbType(); |
| | | } |
| | | |
| | | public static String getFindInSetTemplate(DbType dbType) { |
| | | return Optional.of(MAP_BY_MP.get(dbType).getFindInSetTemplate()) |
| | | .orElseThrow(() -> new IllegalArgumentException("FIND_IN_SET not supported")); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | * Copyright (c) 2018 人人开源 All rights reserved. |
| | | * |
| | | * https://www.renren.io |
| | | * |
| | | * 版权所有,侵权必究! |
| | | */ |
| | | |
| | | package com.iailab.framework.mybatis.interceptor; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.toolkit.PluginUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor; |
| | | import net.sf.jsqlparser.JSQLParserException; |
| | | import net.sf.jsqlparser.expression.Expression; |
| | | import net.sf.jsqlparser.expression.StringValue; |
| | | import net.sf.jsqlparser.expression.operators.conditional.AndExpression; |
| | | import net.sf.jsqlparser.parser.CCJSqlParserUtil; |
| | | import net.sf.jsqlparser.statement.select.PlainSelect; |
| | | import net.sf.jsqlparser.statement.select.Select; |
| | | import org.apache.ibatis.executor.Executor; |
| | | import org.apache.ibatis.mapping.BoundSql; |
| | | import org.apache.ibatis.mapping.MappedStatement; |
| | | import org.apache.ibatis.session.ResultHandler; |
| | | import org.apache.ibatis.session.RowBounds; |
| | | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 数据过滤 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | */ |
| | | public class DataFilterInterceptor implements InnerInterceptor { |
| | | |
| | | @Override |
| | | public void beforeQuery(Executor executor, MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler, BoundSql boundSql) { |
| | | DataScope scope = getDataScope(parameter); |
| | | // 不进行数据过滤 |
| | | if(scope == null || StrUtil.isBlank(scope.getSqlFilter())){ |
| | | return; |
| | | } |
| | | |
| | | // 拼接新SQL |
| | | String buildSql = getSelect(boundSql.getSql(), scope); |
| | | |
| | | // 重写SQL |
| | | PluginUtils.mpBoundSql(boundSql).sql(buildSql); |
| | | } |
| | | |
| | | private DataScope getDataScope(Object parameter){ |
| | | if (parameter == null){ |
| | | return null; |
| | | } |
| | | |
| | | // 判断参数里是否有DataScope对象 |
| | | if (parameter instanceof Map) { |
| | | Map<?, ?> parameterMap = (Map<?, ?>) parameter; |
| | | for (Map.Entry entry : parameterMap.entrySet()) { |
| | | if (entry.getValue() != null && entry.getValue() instanceof DataScope) { |
| | | return (DataScope) entry.getValue(); |
| | | } |
| | | } |
| | | } else if (parameter instanceof DataScope) { |
| | | return (DataScope) parameter; |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | private String getSelect(String buildSql, DataScope scope){ |
| | | try { |
| | | Select select = (Select) CCJSqlParserUtil.parse(buildSql); |
| | | PlainSelect plainSelect = (PlainSelect) select.getSelectBody(); |
| | | |
| | | Expression expression = plainSelect.getWhere(); |
| | | if(expression == null){ |
| | | plainSelect.setWhere(new StringValue(scope.getSqlFilter())); |
| | | }else{ |
| | | AndExpression andExpression = new AndExpression(expression, new StringValue(scope.getSqlFilter())); |
| | | plainSelect.setWhere(andExpression); |
| | | } |
| | | |
| | | return select.toString().replaceAll("'", ""); |
| | | }catch (JSQLParserException e){ |
| | | return buildSql; |
| | | } |
| | | } |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | * Copyright (c) 2018 人人开源 All rights reserved. |
| | | * |
| | | * https://www.renren.io |
| | | * |
| | | * 版权所有,侵权必究! |
| | | */ |
| | | |
| | | package com.iailab.framework.mybatis.interceptor; |
| | | |
| | | /** |
| | | * 数据范围 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | * @since 1.0.0 |
| | | */ |
| | | public class DataScope { |
| | | private String sqlFilter; |
| | | |
| | | public DataScope(String sqlFilter) { |
| | | this.sqlFilter = sqlFilter; |
| | | } |
| | | |
| | | public String getSqlFilter() { |
| | | return sqlFilter; |
| | | } |
| | | |
| | | public void setSqlFilter(String sqlFilter) { |
| | | this.sqlFilter = sqlFilter; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return this.sqlFilter; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.framework.common.annotation; |
| | | |
| | | import java.lang.annotation.*; |
| | | |
| | | /** |
| | | * 业务流程 |
| | | * |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年12月20日 16:10:00 |
| | | */ |
| | | @Target(ElementType.METHOD) |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | @Documented |
| | | public @interface AutoBpm { |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.framework.common.annotation; |
| | | |
| | | import java.lang.annotation.*; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年05月21日 10:59:00 |
| | | */ |
| | | @Target(ElementType.METHOD) |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | @Documented |
| | | public @interface AutoDict { |
| | | |
| | | /** |
| | | * 暂时无用 |
| | | * @return |
| | | */ |
| | | String value() default ""; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.framework.common.annotation; |
| | | |
| | | import java.lang.annotation.*; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2023年06月07日 11:35:00 |
| | | */ |
| | | @Target(ElementType.METHOD) |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | @Documented |
| | | public @interface AutoUser { |
| | | |
| | | /** |
| | | * 暂时无用 |
| | | * @return |
| | | */ |
| | | String value() default ""; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.framework.common.annotation; |
| | | |
| | | import java.lang.annotation.ElementType; |
| | | import java.lang.annotation.Retention; |
| | | import java.lang.annotation.RetentionPolicy; |
| | | import java.lang.annotation.Target; |
| | | |
| | | /** |
| | | * 业务流程ID |
| | | * |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年12月20日 16:17:00 |
| | | */ |
| | | @Target(ElementType.FIELD) |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | public @interface BpmProcess { |
| | | |
| | | /** |
| | | * 业务ID |
| | | * |
| | | * @return |
| | | */ |
| | | String businessKey(); |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.framework.common.annotation; |
| | | |
| | | import java.lang.annotation.ElementType; |
| | | import java.lang.annotation.Retention; |
| | | import java.lang.annotation.RetentionPolicy; |
| | | import java.lang.annotation.Target; |
| | | |
| | | /** |
| | | * 业务流程状态 |
| | | * |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年12月20日 16:14:00 |
| | | */ |
| | | @Target(ElementType.FIELD) |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | public @interface BpmStatus { |
| | | |
| | | /** |
| | | * 业务ID |
| | | * |
| | | * @return |
| | | */ |
| | | String businessKey(); |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.framework.common.annotation; |
| | | |
| | | import java.lang.annotation.ElementType; |
| | | import java.lang.annotation.Retention; |
| | | import java.lang.annotation.RetentionPolicy; |
| | | import java.lang.annotation.Target; |
| | | |
| | | /** |
| | | * 字典注解 |
| | | * |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年05月20日 17:36:00 |
| | | */ |
| | | @Target(ElementType.FIELD) |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | public @interface Dict { |
| | | |
| | | /** |
| | | * 数据code |
| | | * |
| | | * @return |
| | | */ |
| | | String dicCode(); |
| | | |
| | | /** |
| | | * 数据itemValue |
| | | * |
| | | * @return |
| | | */ |
| | | String itemValue(); |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.framework.common.annotation; |
| | | |
| | | import java.lang.annotation.ElementType; |
| | | import java.lang.annotation.Retention; |
| | | import java.lang.annotation.RetentionPolicy; |
| | | import java.lang.annotation.Target; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2023年06月07日 11:37:00 |
| | | */ |
| | | @Target(ElementType.FIELD) |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | public @interface UserRealName { |
| | | |
| | | /** |
| | | * 用户ID |
| | | * |
| | | * @return |
| | | */ |
| | | String userid() default ""; |
| | | |
| | | /** |
| | | * 用户账号 |
| | | * |
| | | * @return |
| | | */ |
| | | String username() default ""; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.framework.common.constant; |
| | | |
| | | /** |
| | | * @author: huangxutao |
| | | * @date: 2019-06-14 |
| | | * @description: 缓存常量 |
| | | */ |
| | | public interface CacheConstant { |
| | | |
| | | /** |
| | | * 字典信息缓存(含禁用的字典项) |
| | | */ |
| | | public static final String SYS_DICT_CACHE = "sys:cache:dict"; |
| | | |
| | | /** |
| | | * 字典信息缓存 status为有效的 |
| | | */ |
| | | public static final String SYS_ENABLE_DICT_CACHE = "sys:cache:dictEnable"; |
| | | /** |
| | | * 表字典信息缓存 |
| | | */ |
| | | public static final String SYS_DICT_TABLE_CACHE = "sys:cache:dictTable"; |
| | | public static final String SYS_DICT_TABLE_BY_KEYS_CACHE = SYS_DICT_TABLE_CACHE + "ByKeys"; |
| | | |
| | | /** |
| | | * 数据权限配置缓存 |
| | | */ |
| | | public static final String SYS_DATA_PERMISSIONS_CACHE = "sys:cache:permission:datarules"; |
| | | |
| | | /** |
| | | * 缓存用户信息 |
| | | */ |
| | | public static final String SYS_USERS_CACHE = "sys:cache:user"; |
| | | |
| | | /** |
| | | * 全部部门信息缓存 |
| | | */ |
| | | public static final String SYS_DEPARTS_CACHE = "sys:cache:depart:alldata"; |
| | | |
| | | |
| | | /** |
| | | * 全部部门ids缓存 |
| | | */ |
| | | public static final String SYS_DEPART_IDS_CACHE = "sys:cache:depart:allids"; |
| | | |
| | | |
| | | /** |
| | | * 测试缓存key |
| | | */ |
| | | public static final String TEST_DEMO_CACHE = "test:demo"; |
| | | |
| | | /** |
| | | * 字典信息缓存 |
| | | */ |
| | | public static final String SYS_DYNAMICDB_CACHE = "sys:cache:dbconnect:dynamic:"; |
| | | |
| | | /** |
| | | * gateway路由缓存 |
| | | */ |
| | | public static final String GATEWAY_ROUTES = "sys:cache:cloud:gateway_routes"; |
| | | |
| | | |
| | | /** |
| | | * gatewayAPI缓存 |
| | | */ |
| | | public static final String GATEWAY_APIS = "sys:cache:cloud:gateway_apis"; |
| | | |
| | | /** |
| | | * gateway路由 reload key |
| | | */ |
| | | public static final String ROUTE_JVM_RELOAD_TOPIC = "gateway_jvm_route_reload_topic"; |
| | | |
| | | /** |
| | | * TODO 冗余代码 待删除 |
| | | *插件商城排行榜 |
| | | */ |
| | | public static final String PLUGIN_MALL_RANKING = "pluginMall::rankingList"; |
| | | /** |
| | | * TODO 冗余代码 待删除 |
| | | *插件商城排行榜 |
| | | */ |
| | | public static final String PLUGIN_MALL_PAGE_LIST = "pluginMall::queryPageList"; |
| | | |
| | | |
| | | /** |
| | | * online列表页配置信息缓存key |
| | | */ |
| | | public static final String ONLINE_LIST = "sys:cache:online:list"; |
| | | |
| | | /** |
| | | * online表单页配置信息缓存key |
| | | */ |
| | | public static final String ONLINE_FORM = "sys:cache:online:form"; |
| | | |
| | | /** |
| | | * online报表 |
| | | */ |
| | | public static final String ONLINE_RP = "sys:cache:online:rp"; |
| | | |
| | | /** |
| | | * online图表 |
| | | */ |
| | | public static final String ONLINE_GRAPH = "sys:cache:online:graph"; |
| | | /** |
| | | * 拖拽页面信息缓存 |
| | | */ |
| | | public static final String DRAG_PAGE_CACHE = "drag:cache:param"; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.framework.common.constant; |
| | | |
| | | /** |
| | | * @Description: 通用常量 |
| | | */ |
| | | public interface CommonConstant { |
| | | |
| | | /** |
| | | * 正常状态 |
| | | */ |
| | | public static final Integer STATUS_NORMAL = 0; |
| | | |
| | | /** |
| | | * 禁用状态 |
| | | */ |
| | | public static final Integer STATUS_DISABLE = -1; |
| | | |
| | | /** |
| | | * 删除标志 |
| | | */ |
| | | public static final Integer DEL_FLAG_1 = 1; |
| | | |
| | | /** |
| | | * 未删除 |
| | | */ |
| | | public static final Integer DEL_FLAG_0 = 0; |
| | | |
| | | /** |
| | | * 未提交 |
| | | */ |
| | | public static final Integer SUBMINT_STATUS_0 = 0; |
| | | |
| | | /** |
| | | * 系统日志类型: 登录 |
| | | */ |
| | | public static final int LOG_TYPE_1 = 1; |
| | | |
| | | /** |
| | | * 系统日志类型: 操作 |
| | | */ |
| | | public static final int LOG_TYPE_2 = 2; |
| | | |
| | | /** |
| | | * 操作日志类型: 查询 |
| | | */ |
| | | public static final int OPERATE_TYPE_1 = 1; |
| | | |
| | | /** |
| | | * 操作日志类型: 添加 |
| | | */ |
| | | public static final int OPERATE_TYPE_2 = 2; |
| | | |
| | | /** |
| | | * 操作日志类型: 更新 |
| | | */ |
| | | public static final int OPERATE_TYPE_3 = 3; |
| | | |
| | | /** |
| | | * 操作日志类型: 删除 |
| | | */ |
| | | public static final int OPERATE_TYPE_4 = 4; |
| | | |
| | | /** |
| | | * 操作日志类型: 倒入 |
| | | */ |
| | | public static final int OPERATE_TYPE_5 = 5; |
| | | |
| | | /** |
| | | * 操作日志类型: 导出 |
| | | */ |
| | | public static final int OPERATE_TYPE_6 = 6; |
| | | |
| | | /** |
| | | * 提交 |
| | | */ |
| | | public static final int SUBMIT_FLAG_1 = 1; |
| | | |
| | | /** |
| | | * 提交 |
| | | */ |
| | | public static final int SUBMIT_FLAG_0 = 0; |
| | | |
| | | /** |
| | | * 启用 |
| | | */ |
| | | public static final int IS_ENABLE = 1; |
| | | |
| | | /** |
| | | * 常量点类型 |
| | | */ |
| | | public static final String POINT_TYPE_NAME_CONSTANT = "CONSTANT"; |
| | | |
| | | |
| | | /** {@code 500 Server Error} (HTTP/1.0 - RFC 1945) */ |
| | | public static final Integer SC_INTERNAL_SERVER_ERROR_500 = 500; |
| | | /** {@code 200 OK} (HTTP/1.0 - RFC 1945) */ |
| | | public static final Integer SC_OK_200 = 200; |
| | | |
| | | /**访问权限认证未通过 510*/ |
| | | public static final Integer SC_JEECG_NO_AUTHZ=510; |
| | | |
| | | /** 登录用户Shiro权限缓存KEY前缀 */ |
| | | public static String PREFIX_USER_SHIRO_CACHE = "shiro:cache:org.jeecg.config.shiro.ShiroRealm.authorizationCache:"; |
| | | /** 登录用户Token令牌缓存KEY前缀 */ |
| | | public static final String PREFIX_USER_TOKEN = "prefix_user_token_"; |
| | | // /** Token缓存时间:3600秒即一小时 */ |
| | | // public static final int TOKEN_EXPIRE_TIME = 3600; |
| | | |
| | | /** 登录二维码 */ |
| | | public static final String LOGIN_QRCODE_PRE = "QRCODELOGIN:"; |
| | | public static final String LOGIN_QRCODE = "LQ:"; |
| | | /** 登录二维码token */ |
| | | public static final String LOGIN_QRCODE_TOKEN = "LQT:"; |
| | | |
| | | |
| | | /** |
| | | * 0:一级菜单 |
| | | */ |
| | | public static final Integer MENU_TYPE_0 = 0; |
| | | /** |
| | | * 1:子菜单 |
| | | */ |
| | | public static final Integer MENU_TYPE_1 = 1; |
| | | /** |
| | | * 2:按钮权限 |
| | | */ |
| | | public static final Integer MENU_TYPE_2 = 2; |
| | | |
| | | /**通告对象类型(USER:指定用户,ALL:全体用户)*/ |
| | | public static final String MSG_TYPE_UESR = "USER"; |
| | | public static final String MSG_TYPE_ALL = "ALL"; |
| | | |
| | | /**发布状态(0未发布,1已发布,2已撤销)*/ |
| | | public static final String NO_SEND = "0"; |
| | | public static final String HAS_SEND = "1"; |
| | | public static final String HAS_CANCLE = "2"; |
| | | |
| | | /**阅读状态(0未读,1已读)*/ |
| | | public static final String HAS_READ_FLAG = "1"; |
| | | public static final String NO_READ_FLAG = "0"; |
| | | |
| | | /**优先级(L低,M中,H高)*/ |
| | | public static final String PRIORITY_L = "L"; |
| | | public static final String PRIORITY_M = "M"; |
| | | public static final String PRIORITY_H = "H"; |
| | | |
| | | /** |
| | | * 短信模板方式 0 .登录模板、1.注册模板、2.忘记密码模板 |
| | | */ |
| | | public static final String SMS_TPL_TYPE_0 = "0"; |
| | | public static final String SMS_TPL_TYPE_1 = "1"; |
| | | public static final String SMS_TPL_TYPE_2 = "2"; |
| | | |
| | | /** |
| | | * 状态(0无效1有效) |
| | | */ |
| | | public static final String STATUS_0 = "0"; |
| | | public static final String STATUS_1 = "1"; |
| | | |
| | | /** |
| | | * 同步工作流引擎1同步0不同步 |
| | | */ |
| | | public static final Integer ACT_SYNC_1 = 1; |
| | | public static final Integer ACT_SYNC_0 = 0; |
| | | |
| | | /** |
| | | * 消息类型1:通知公告2:系统消息 |
| | | */ |
| | | public static final String MSG_CATEGORY_1 = "1"; |
| | | public static final String MSG_CATEGORY_2 = "2"; |
| | | |
| | | /** |
| | | * 是否配置菜单的数据权限 1是0否 |
| | | */ |
| | | public static final Integer RULE_FLAG_0 = 0; |
| | | public static final Integer RULE_FLAG_1 = 1; |
| | | |
| | | /** |
| | | * 是否用户已被冻结 1正常(解冻) 2冻结 |
| | | */ |
| | | public static final Integer USER_UNFREEZE = 1; |
| | | public static final Integer USER_FREEZE = 2; |
| | | |
| | | /**字典翻译文本后缀*/ |
| | | public static final String DICT_TEXT_SUFFIX = "_dictText"; |
| | | |
| | | /** |
| | | * 表单设计器主表类型 |
| | | */ |
| | | public static final Integer DESIGN_FORM_TYPE_MAIN = 1; |
| | | |
| | | /** |
| | | * 表单设计器子表表类型 |
| | | */ |
| | | public static final Integer DESIGN_FORM_TYPE_SUB = 2; |
| | | |
| | | /** |
| | | * 表单设计器URL授权通过 |
| | | */ |
| | | public static final Integer DESIGN_FORM_URL_STATUS_PASSED = 1; |
| | | |
| | | /** |
| | | * 表单设计器URL授权未通过 |
| | | */ |
| | | public static final Integer DESIGN_FORM_URL_STATUS_NOT_PASSED = 2; |
| | | |
| | | /** |
| | | * 表单设计器新增 Flag |
| | | */ |
| | | public static final String DESIGN_FORM_URL_TYPE_ADD = "add"; |
| | | /** |
| | | * 表单设计器修改 Flag |
| | | */ |
| | | public static final String DESIGN_FORM_URL_TYPE_EDIT = "edit"; |
| | | /** |
| | | * 表单设计器详情 Flag |
| | | */ |
| | | public static final String DESIGN_FORM_URL_TYPE_DETAIL = "detail"; |
| | | /** |
| | | * 表单设计器复用数据 Flag |
| | | */ |
| | | public static final String DESIGN_FORM_URL_TYPE_REUSE = "reuse"; |
| | | /** |
| | | * 表单设计器编辑 Flag (已弃用) |
| | | */ |
| | | public static final String DESIGN_FORM_URL_TYPE_VIEW = "view"; |
| | | |
| | | /** |
| | | * online参数值设置(是:Y, 否:N) |
| | | */ |
| | | public static final String ONLINE_PARAM_VAL_IS_TURE = "Y"; |
| | | public static final String ONLINE_PARAM_VAL_IS_FALSE = "N"; |
| | | |
| | | /** |
| | | * 文件上传类型(本地:local,Minio:minio,阿里云:alioss) |
| | | */ |
| | | public static final String UPLOAD_TYPE_LOCAL = "local"; |
| | | public static final String UPLOAD_TYPE_MINIO = "minio"; |
| | | public static final String UPLOAD_TYPE_OSS = "alioss"; |
| | | |
| | | /** |
| | | * 文档上传自定义桶名称 |
| | | */ |
| | | public static final String UPLOAD_CUSTOM_BUCKET = "eoafile"; |
| | | /** |
| | | * 文档上传自定义路径 |
| | | */ |
| | | public static final String UPLOAD_CUSTOM_PATH = "eoafile"; |
| | | /** |
| | | * 文件外链接有效天数 |
| | | */ |
| | | public static final Integer UPLOAD_EFFECTIVE_DAYS = 1; |
| | | |
| | | /** |
| | | * 员工身份 (1:普通员工 2:上级) |
| | | */ |
| | | public static final Integer USER_IDENTITY_1 = 1; |
| | | public static final Integer USER_IDENTITY_2 = 2; |
| | | |
| | | /** sys_user 表 username 唯一键索引 */ |
| | | public static final String SQL_INDEX_UNIQ_SYS_USER_USERNAME = "uniq_sys_user_username"; |
| | | /** sys_user 表 work_no 唯一键索引 */ |
| | | public static final String SQL_INDEX_UNIQ_SYS_USER_WORK_NO = "uniq_sys_user_work_no"; |
| | | /** sys_user 表 phone 唯一键索引 */ |
| | | public static final String SQL_INDEX_UNIQ_SYS_USER_PHONE = "uniq_sys_user_phone"; |
| | | /** 达梦数据库升提示。违反表[SYS_USER]唯一性约束 */ |
| | | public static final String SQL_INDEX_UNIQ_SYS_USER = "唯一性约束"; |
| | | |
| | | /** sys_user 表 email 唯一键索引 */ |
| | | public static final String SQL_INDEX_UNIQ_SYS_USER_EMAIL = "uniq_sys_user_email"; |
| | | /** sys_quartz_job 表 job_class_name 唯一键索引 */ |
| | | public static final String SQL_INDEX_UNIQ_JOB_CLASS_NAME = "uniq_job_class_name"; |
| | | /** sys_position 表 code 唯一键索引 */ |
| | | public static final String SQL_INDEX_UNIQ_CODE = "uniq_code"; |
| | | /** sys_role 表 code 唯一键索引 */ |
| | | public static final String SQL_INDEX_UNIQ_SYS_ROLE_CODE = "uniq_sys_role_role_code"; |
| | | /** sys_depart 表 code 唯一键索引 */ |
| | | public static final String SQL_INDEX_UNIQ_DEPART_ORG_CODE = "uniq_depart_org_code"; |
| | | /** sys_category 表 code 唯一键索引 */ |
| | | public static final String SQL_INDEX_UNIQ_CATEGORY_CODE = "idx_sc_code"; |
| | | /** |
| | | * 在线聊天 是否为默认分组 |
| | | */ |
| | | public static final String IM_DEFAULT_GROUP = "1"; |
| | | /** |
| | | * 在线聊天 图片文件保存路径 |
| | | */ |
| | | public static final String IM_UPLOAD_CUSTOM_PATH = "imfile"; |
| | | /** |
| | | * 在线聊天 用户状态 |
| | | */ |
| | | public static final String IM_STATUS_ONLINE = "online"; |
| | | |
| | | /** |
| | | * 在线聊天 SOCKET消息类型 |
| | | */ |
| | | public static final String IM_SOCKET_TYPE = "chatMessage"; |
| | | |
| | | /** |
| | | * 在线聊天 是否开启默认添加好友 1是 0否 |
| | | */ |
| | | public static final String IM_DEFAULT_ADD_FRIEND = "1"; |
| | | |
| | | /** |
| | | * 在线聊天 用户好友缓存前缀 |
| | | */ |
| | | public static final String IM_PREFIX_USER_FRIEND_CACHE = "sys:cache:im:im_prefix_user_friend_"; |
| | | |
| | | /** |
| | | * 考勤补卡业务状态 (1:同意 2:不同意) |
| | | */ |
| | | public static final String SIGN_PATCH_BIZ_STATUS_1 = "1"; |
| | | public static final String SIGN_PATCH_BIZ_STATUS_2 = "2"; |
| | | |
| | | /** |
| | | * 公文文档上传自定义路径 |
| | | */ |
| | | public static final String UPLOAD_CUSTOM_PATH_OFFICIAL = "officialdoc"; |
| | | /** |
| | | * 公文文档下载自定义路径 |
| | | */ |
| | | public static final String DOWNLOAD_CUSTOM_PATH_OFFICIAL = "officaldown"; |
| | | |
| | | /** |
| | | * WPS存储值类别(1 code文号 2 text(WPS模板还是公文发文模板)) |
| | | */ |
| | | public static final String WPS_TYPE_1="1"; |
| | | public static final String WPS_TYPE_2="2"; |
| | | |
| | | |
| | | public final static String X_ACCESS_TOKEN = "X-Access-Token"; |
| | | public final static String X_SIGN = "X-Sign"; |
| | | public final static String X_TIMESTAMP = "X-TIMESTAMP"; |
| | | public final static String TOKEN_IS_INVALID_MSG = "Token失效,请重新登录!"; |
| | | |
| | | /** |
| | | * 多租户 请求头 |
| | | */ |
| | | public final static String TENANT_ID = "tenant-id"; |
| | | |
| | | /** |
| | | * 微服务读取配置文件属性 服务地址 |
| | | */ |
| | | public final static String CLOUD_SERVER_KEY = "spring.cloud.nacos.discovery.server-addr"; |
| | | |
| | | /** |
| | | * 第三方登录 验证密码/创建用户 都需要设置一个操作码 防止被恶意调用 |
| | | */ |
| | | public final static String THIRD_LOGIN_CODE = "third_login_code"; |
| | | |
| | | /** |
| | | * 第三方APP同步方向:本地 --> 第三方APP |
| | | */ |
| | | String THIRD_SYNC_TO_APP = "SYNC_TO_APP"; |
| | | /** |
| | | * 第三方APP同步方向:第三方APP --> 本地 |
| | | */ |
| | | String THIRD_SYNC_TO_LOCAL = "SYNC_TO_LOCAL"; |
| | | |
| | | /** 系统通告消息状态:0=未发布 */ |
| | | String ANNOUNCEMENT_SEND_STATUS_0 = "0"; |
| | | /** 系统通告消息状态:1=已发布 */ |
| | | String ANNOUNCEMENT_SEND_STATUS_1 = "1"; |
| | | /** 系统通告消息状态:2=已撤销 */ |
| | | String ANNOUNCEMENT_SEND_STATUS_2 = "2"; |
| | | |
| | | /**ONLINE 报表权限用 从request中获取地址栏后的参数*/ |
| | | String ONL_REP_URL_PARAM_STR="onlRepUrlParamStr"; |
| | | |
| | | /**POST请求*/ |
| | | String HTTP_POST = "POST"; |
| | | |
| | | /**PUT请求*/ |
| | | String HTTP_PUT = "PUT"; |
| | | |
| | | /**PATCH请求*/ |
| | | String HTTP_PATCH = "PATCH"; |
| | | |
| | | /**未知的*/ |
| | | String UNKNOWN = "unknown"; |
| | | |
| | | /**字符串http*/ |
| | | String STR_HTTP = "http"; |
| | | |
| | | /**String 类型的空值*/ |
| | | String STRING_NULL = "null"; |
| | | |
| | | /**java.util.Date 包*/ |
| | | String JAVA_UTIL_DATE = "java.util.Date"; |
| | | |
| | | /**.do*/ |
| | | String SPOT_DO = ".do"; |
| | | |
| | | |
| | | /**前端vue版本标识*/ |
| | | String VERSION="X-Version"; |
| | | |
| | | /**前端vue版本*/ |
| | | String VERSION_VUE3="vue3"; |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | * Copyright (c) 2018 人人开源 All rights reserved. |
| | | * |
| | | * https://www.renren.io |
| | | * |
| | | * 版权所有,侵权必究! |
| | | */ |
| | | |
| | | package com.iailab.framework.common.constant; |
| | | |
| | | /** |
| | | * 常量 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | */ |
| | | public interface Constant { |
| | | /** |
| | | * 成功 |
| | | */ |
| | | int SUCCESS = 1; |
| | | /** |
| | | * 失败 |
| | | */ |
| | | int FAIL = 0; |
| | | /** |
| | | * 菜单根节点标识 |
| | | */ |
| | | Long MENU_ROOT = 0L; |
| | | /** |
| | | * 部门根节点标识 |
| | | */ |
| | | Long DEPT_ROOT = 0L; |
| | | /** |
| | | * 升序 |
| | | */ |
| | | String ASC = "asc"; |
| | | /** |
| | | * 降序 |
| | | */ |
| | | String DESC = "desc"; |
| | | /** |
| | | * 创建时间字段名 |
| | | */ |
| | | String CREATE_DATE = "create_date"; |
| | | |
| | | String CREATE_TIME = "create_time"; |
| | | |
| | | /** |
| | | * 数据权限过滤 |
| | | */ |
| | | String SQL_FILTER = "sqlFilter"; |
| | | /** |
| | | * 当前页码 |
| | | */ |
| | | String PAGE = "page"; |
| | | /** |
| | | * 每页显示记录数 |
| | | */ |
| | | String LIMIT = "limit"; |
| | | /** |
| | | * 排序字段 |
| | | */ |
| | | String ORDER_FIELD = "orderField"; |
| | | /** |
| | | * 排序方式 |
| | | */ |
| | | String ORDER = "order"; |
| | | /** |
| | | * token header |
| | | */ |
| | | String TOKEN_HEADER = "token"; |
| | | |
| | | /** |
| | | * 云存储配置KEY |
| | | */ |
| | | String CLOUD_STORAGE_CONFIG_KEY = "CLOUD_STORAGE_CONFIG_KEY"; |
| | | |
| | | Integer DEL_FLAG_0 = 0; |
| | | |
| | | enum EnableStatus { |
| | | DISABLED(0), |
| | | NORMAL(1); |
| | | |
| | | private int value; |
| | | |
| | | private EnableStatus(int value) { |
| | | this.value = value; |
| | | } |
| | | |
| | | public int getValue() { |
| | | return this.value; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 定时任务状态 |
| | | */ |
| | | enum ScheduleStatus { |
| | | /** |
| | | * 暂停 |
| | | */ |
| | | PAUSE(0), |
| | | /** |
| | | * 正常 |
| | | */ |
| | | NORMAL(1); |
| | | |
| | | private int value; |
| | | |
| | | ScheduleStatus(int value) { |
| | | this.value = value; |
| | | } |
| | | |
| | | public int getValue() { |
| | | return value; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 云服务商 |
| | | */ |
| | | enum CloudService { |
| | | /** |
| | | * 七牛云 |
| | | */ |
| | | QINIU(1), |
| | | /** |
| | | * 阿里云 |
| | | */ |
| | | ALIYUN(2), |
| | | /** |
| | | * 腾讯云 |
| | | */ |
| | | QCLOUD(3); |
| | | |
| | | private int value; |
| | | |
| | | CloudService(int value) { |
| | | this.value = value; |
| | | } |
| | | |
| | | public int getValue() { |
| | | return value; |
| | | } |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.framework.common.constant; |
| | | |
| | | /** |
| | | * @Description: GlobalConstants |
| | | * @author: scott |
| | | * @date: 2020/01/01 16:01 |
| | | */ |
| | | public class GlobalConstants { |
| | | |
| | | /** |
| | | * 业务处理器beanName传递参数 |
| | | */ |
| | | public static final String HANDLER_NAME = "handlerName"; |
| | | |
| | | /** |
| | | * 路由刷新触发器 |
| | | */ |
| | | public static final String LODER_ROUDER_HANDLER = "loderRouderHandler"; |
| | | |
| | | /** |
| | | * API刷新触发器 |
| | | */ |
| | | public static final String LODER_API_HANDLER = "loderApiHandler"; |
| | | |
| | | /** |
| | | * redis消息通道名称 |
| | | */ |
| | | public static final String REDIS_TOPIC_NAME="redis_topic"; |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | * Copyright (c) 2018 人人开源 All rights reserved. |
| | | * |
| | | * https://www.renren.io |
| | | * |
| | | * 版权所有,侵权必究! |
| | | */ |
| | | |
| | | package com.iailab.framework.common.enums; |
| | | |
| | | /** |
| | | * 错误编码,由5位数字组成,前2位为模块编码,后3位为业务编码 |
| | | * <p> |
| | | * 如:10001(10代表系统模块,001代表业务代码) |
| | | * </p> |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | * @since 1.0.0 |
| | | */ |
| | | public interface ErrorCode { |
| | | int INTERNAL_SERVER_ERROR = 500; |
| | | int UNAUTHORIZED = 401; |
| | | |
| | | int NOT_NULL = 10001; |
| | | int DB_RECORD_EXISTS = 10002; |
| | | int PARAMS_GET_ERROR = 10003; |
| | | int ACCOUNT_PASSWORD_ERROR = 10004; |
| | | int ACCOUNT_DISABLE = 10005; |
| | | int IDENTIFIER_NOT_NULL = 10006; |
| | | int CAPTCHA_ERROR = 10007; |
| | | int SUB_MENU_EXIST = 10008; |
| | | int PASSWORD_ERROR = 10009; |
| | | int SUPERIOR_DEPT_ERROR = 10011; |
| | | int SUPERIOR_MENU_ERROR = 10012; |
| | | int DATA_SCOPE_PARAMS_ERROR = 10013; |
| | | int DEPT_SUB_DELETE_ERROR = 10014; |
| | | int DEPT_USER_DELETE_ERROR = 10015; |
| | | int UPLOAD_FILE_EMPTY = 10019; |
| | | int TOKEN_NOT_EMPTY = 10020; |
| | | int TOKEN_INVALID = 10021; |
| | | int ACCOUNT_LOCK = 10022; |
| | | int OSS_UPLOAD_FILE_ERROR = 10024; |
| | | int REDIS_ERROR = 10027; |
| | | int JOB_ERROR = 10028; |
| | | int INVALID_SYMBOL = 10029; |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | * Copyright (c) 2018 人人开源 All rights reserved. |
| | | * |
| | | * https://www.renren.io |
| | | * |
| | | * 版权所有,侵权必究! |
| | | */ |
| | | |
| | | package com.iailab.framework.common.exception; |
| | | |
| | | import java.io.IOException; |
| | | import java.io.PrintWriter; |
| | | import java.io.StringWriter; |
| | | |
| | | /** |
| | | * Exception工具类 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | */ |
| | | public class ExceptionUtils { |
| | | |
| | | /** |
| | | * 获取异常信息 |
| | | * @param ex 异常 |
| | | * @return 返回异常信息 |
| | | */ |
| | | public static String getErrorStackTrace(Exception ex){ |
| | | StringWriter sw = null; |
| | | PrintWriter pw = null; |
| | | try { |
| | | sw = new StringWriter(); |
| | | pw = new PrintWriter(sw, true); |
| | | ex.printStackTrace(pw); |
| | | }finally { |
| | | try { |
| | | if(pw != null) { |
| | | pw.close(); |
| | | } |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | try { |
| | | if(sw != null) { |
| | | sw.close(); |
| | | } |
| | | } catch (IOException e) { |
| | | |
| | | } |
| | | } |
| | | |
| | | return sw.toString(); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | * Copyright (c) 2018 人人开源 All rights reserved. |
| | | * |
| | | * https://www.renren.io |
| | | * |
| | | * 版权所有,侵权必究! |
| | | */ |
| | | |
| | | package com.iailab.framework.common.util.object; |
| | | |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.BeanUtils; |
| | | |
| | | import java.lang.reflect.Field; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 转换工具类 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | */ |
| | | public class ConvertUtils { |
| | | private static Logger logger = LoggerFactory.getLogger(ConvertUtils.class); |
| | | |
| | | public static <T> T sourceToTarget(Object source, Class<T> target){ |
| | | if(source == null){ |
| | | return null; |
| | | } |
| | | T targetObject = null; |
| | | try { |
| | | targetObject = target.newInstance(); |
| | | BeanUtils.copyProperties(source, targetObject); |
| | | } catch (Exception e) { |
| | | logger.error("convert error ", e); |
| | | } |
| | | |
| | | return targetObject; |
| | | } |
| | | |
| | | public static <T> List<T> sourceToTarget(Collection<?> sourceList, Class<T> target){ |
| | | if(sourceList == null){ |
| | | return null; |
| | | } |
| | | |
| | | List targetList = new ArrayList<>(sourceList.size()); |
| | | try { |
| | | for(Object source : sourceList){ |
| | | T targetObject = target.newInstance(); |
| | | BeanUtils.copyProperties(source, targetObject); |
| | | targetList.add(targetObject); |
| | | } |
| | | }catch (Exception e){ |
| | | logger.error("convert error ", e); |
| | | } |
| | | |
| | | return targetList; |
| | | } |
| | | /** |
| | | * 获取类的所有属性,包括父类 |
| | | * |
| | | * @param object |
| | | * @return |
| | | */ |
| | | public static Field[] getAllFields(Object object) { |
| | | Class<?> clazz = object.getClass(); |
| | | List<Field> fieldList = new ArrayList<>(); |
| | | while (clazz != null) { |
| | | fieldList.addAll(new ArrayList<>(Arrays.asList(clazz.getDeclaredFields()))); |
| | | clazz = clazz.getSuperclass(); |
| | | } |
| | | Field[] fields = new Field[fieldList.size()]; |
| | | fieldList.toArray(fields); |
| | | return fields; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | * Copyright (c) 2018 人人开源 All rights reserved. |
| | | * |
| | | * https://www.renren.io |
| | | * |
| | | * 版权所有,侵权必究! |
| | | */ |
| | | |
| | | package com.iailab.framework.common.util.spring; |
| | | |
| | | import org.springframework.beans.BeansException; |
| | | import org.springframework.context.ApplicationContext; |
| | | import org.springframework.context.ApplicationContextAware; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * Spring Context 工具类 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | */ |
| | | @Component |
| | | public class SpringContextUtils implements ApplicationContextAware { |
| | | public static ApplicationContext applicationContext; |
| | | |
| | | @Override |
| | | public void setApplicationContext(ApplicationContext applicationContext) |
| | | throws BeansException { |
| | | SpringContextUtils.applicationContext = applicationContext; |
| | | } |
| | | |
| | | public static Object getBean(String name) { |
| | | return applicationContext.getBean(name); |
| | | } |
| | | |
| | | public static <T> T getBean(Class<T> requiredType) { |
| | | return applicationContext.getBean(requiredType); |
| | | } |
| | | |
| | | public static <T> T getBean(String name, Class<T> requiredType) { |
| | | return applicationContext.getBean(name, requiredType); |
| | | } |
| | | |
| | | public static boolean containsBean(String name) { |
| | | return applicationContext.containsBean(name); |
| | | } |
| | | |
| | | public static boolean isSingleton(String name) { |
| | | return applicationContext.isSingleton(name); |
| | | } |
| | | |
| | | public static Class<? extends Object> getType(String name) { |
| | | return applicationContext.getType(name); |
| | | } |
| | | |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | * Copyright (c) 2018 人人开源 All rights reserved. |
| | | * |
| | | * https://www.renren.io |
| | | * |
| | | * 版权所有,侵权必究! |
| | | */ |
| | | |
| | | package com.iailab.framework.common.validation.group; |
| | | |
| | | /** |
| | | * 新增 Group |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | * @since 1.0.0 |
| | | */ |
| | | public interface AddGroup { |
| | | |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | * Copyright (c) 2018 人人开源 All rights reserved. |
| | | * |
| | | * https://www.renren.io |
| | | * |
| | | * 版权所有,侵权必究! |
| | | */ |
| | | |
| | | package com.iailab.framework.common.validation.group; |
| | | |
| | | /** |
| | | * 默认 Group |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | * @since 1.0.0 |
| | | */ |
| | | public interface DefaultGroup { |
| | | |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | * Copyright (c) 2018 人人开源 All rights reserved. |
| | | * |
| | | * https://www.renren.io |
| | | * |
| | | * 版权所有,侵权必究! |
| | | */ |
| | | |
| | | package com.iailab.framework.common.validation.group; |
| | | |
| | | import javax.validation.GroupSequence; |
| | | |
| | | /** |
| | | * 定义校验顺序,如果AddGroup组失败,则UpdateGroup组不会再校验 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | * @since 1.0.0 |
| | | */ |
| | | @GroupSequence({AddGroup.class, UpdateGroup.class}) |
| | | public interface Group { |
| | | |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | * Copyright (c) 2018 人人开源 All rights reserved. |
| | | * |
| | | * https://www.renren.io |
| | | * |
| | | * 版权所有,侵权必究! |
| | | */ |
| | | |
| | | package com.iailab.framework.common.validation.group; |
| | | |
| | | /** |
| | | * 修改 Group |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | * @since 1.0.0 |
| | | */ |
| | | public interface UpdateGroup { |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.api; |
| | | |
| | | import com.iailab.module.data.dto.*; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author DongYukun |
| | | * @Description |
| | | * @createTime 2024年03月01日 18:37:00 |
| | | */ |
| | | @FeignClient(value = "iailab-ntt-data", path = "/") |
| | | public interface IFeignDataApi { |
| | | @Parameter(name = "map", description = "查询InfluxDB", required = true) |
| | | @Operation(summary = "Feign接口-查询PointValue") |
| | | @PostMapping("/api/feign/influx-point-value") |
| | | List<ApiDataDTO> queryPointValues(@RequestBody FeignQueryPointDTO dto); |
| | | |
| | | @Parameter(name = "map", description = "查询InfluxDB", required = true) |
| | | @Operation(summary = "Feign接口-查询PointValue") |
| | | @PostMapping("/api/feign/sim-tag-value") |
| | | List<ApiDataDTO> querySimTagValues(@RequestBody FeignQueryPointDTO dto); |
| | | |
| | | @Parameter(name = "map", description = "查询InfluxDB", required = true) |
| | | @Operation(summary = "Feign接口-查询PointValue") |
| | | @PostMapping("/api/feign/currentValue") |
| | | Map<String, Object> getCurrentValue(@RequestParam("pointNos") List<String> pointNos); |
| | | |
| | | @Parameter(name = "map", description = "查询point", required = true) |
| | | @Operation(summary = "Feign接口-查询point") |
| | | @PostMapping("/api/feign/point/{pointNo}") |
| | | ApiDataPointDTO getPoint(@PathVariable("pointNo") String pointNo); |
| | | |
| | | @Parameter(name = "map", description = "查询HttpApi", required = true) |
| | | @Operation(summary = "Feign接口-查询HttpApi") |
| | | @GetMapping("/api/feign/http-api/{code}") |
| | | FeignHttpApiDTO getHttpApi(@PathVariable("code") String code); |
| | | |
| | | @Parameter(name = "map", description = "查询指标数据", required = true) |
| | | @Operation(summary = "Feign接口-查询指标数据") |
| | | @PostMapping("/api/feign/ind-item-values") |
| | | List<ApiDataDTO> queryIndItemValues(@RequestBody FeignQueryPointDTO dto); |
| | | |
| | | @Parameter(name = "map", description = "查询指标数据", required = true) |
| | | @Operation(summary = "Feign接口-查询指标数据") |
| | | @PostMapping("/api/feign/ind-item-values-range") |
| | | List<ApiIndValueDTO> queryIndItemValuesRange(@RequestBody FeignQueryPointDTO dto); |
| | | |
| | | @Parameter(name = "map", description = "设置测点值", required = true) |
| | | @Operation(summary = "Feign接口-设置测点值") |
| | | @PostMapping("/api/feign/set-point-value") |
| | | FeignResultDTO setPointValue(@RequestBody FeignWritePointValueDTO writePointValue); |
| | | |
| | | @Parameter(name = "map", description = "查询指标数据", required = true) |
| | | @Operation(summary = "Feign接口-查询指标数据") |
| | | @PostMapping("/api/feign/get-inditem-values") |
| | | List<ApiIndValueDTO> getIndItemValues(@RequestBody FeignQueryPointDTO dto); |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @author Lujiaxin |
| | | * @Description |
| | | * @createTime 2023年03月09日 10:05:00 |
| | | */ |
| | | |
| | | @Data |
| | | public class AlarmTaskDto { |
| | | |
| | | private String id; |
| | | |
| | | /** |
| | | * 设备编号 |
| | | */ |
| | | private String equipmentNumber; |
| | | |
| | | /** |
| | | * 设备名称 |
| | | */ |
| | | private String equipmentName; |
| | | |
| | | /** |
| | | * 报警场所 |
| | | */ |
| | | private String alarmPlace; |
| | | |
| | | /** |
| | | * 报警内容 |
| | | */ |
| | | private String alarmContent; |
| | | |
| | | /** |
| | | * 报警时间 |
| | | */ |
| | | private Date alarmTime; |
| | | |
| | | /** |
| | | * 推送对象 |
| | | */ |
| | | private String acceptBy; |
| | | |
| | | /** |
| | | * 工单创建方式(自动:auto 手动:manual) |
| | | */ |
| | | private String orderCreateType; |
| | | |
| | | /** |
| | | * 工单创建状态(未创建:0 已创建:1) |
| | | */ |
| | | private String orderCreateStatus; |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | | public class ApiDataDTO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | private Date timeStamp; |
| | | |
| | | private String dataTime; |
| | | |
| | | private double dataValue; |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.dto; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年05月21日 |
| | | */ |
| | | @Data |
| | | @Schema(description = "测点") |
| | | public class ApiDataPointDTO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @Schema(description = "测点编码", required = true) |
| | | private String pointNo; |
| | | |
| | | @Schema(description = "测点名称", required = true) |
| | | private String pointName; |
| | | |
| | | @Schema(description = "采集频率", required = true) |
| | | private String minfreqid; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.dto; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年06月17日 |
| | | */ |
| | | @Data |
| | | public class ApiIndValueDTO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @Schema(description = "数据时间") |
| | | private String dataTime; |
| | | |
| | | @Schema(description = "数据值") |
| | | private BigDecimal dataValue; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.dto; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.constraints.NotNull; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2023年05月05日 16:08:00 |
| | | */ |
| | | @Data |
| | | @Schema(name = "测点值查询") |
| | | public class ApiPointValueQueryDTO { |
| | | @Schema(name = "pointNos") |
| | | @NotNull(message="pointNos不能为空") |
| | | private List<String> pointNos; |
| | | |
| | | @Schema(name = "开始时间") |
| | | @NotNull(message="start不能为空") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date start; |
| | | |
| | | @Schema(name = "结束时间") |
| | | @NotNull(message="end不能为空") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date end; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.dto; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2023年08月21日 13:50:00 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @Schema(name = "文件") |
| | | public class FeignFileQueryDto { |
| | | private String businessId; |
| | | |
| | | private String type; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.dto; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2023年08月16日 13:26:00 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @Schema(name = "文件") |
| | | public class FeignFileSaveDto { |
| | | |
| | | private String businessId; |
| | | |
| | | private String type; |
| | | |
| | | private List<FileDto> fileList; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.dto; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2023年12月09日 09:49:00 |
| | | */ |
| | | public class FeignFixDetDTO { |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.dto; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年05月26日 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @Schema(description = "http接口") |
| | | public class FeignHttpApiDTO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | private String id; |
| | | private String name; |
| | | private String code; |
| | | private String url; |
| | | private String method; |
| | | private String collectType; |
| | | private String param; |
| | | private String descp; |
| | | private Integer status; |
| | | private Date createTime; |
| | | private Date updateTime; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.dto; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author Lujiaxin |
| | | * @Description |
| | | * @createTime 2023年03月09日 10:05:00 |
| | | */ |
| | | |
| | | @Data |
| | | public class FeignOrderTaskDTO { |
| | | |
| | | @Schema(name = "工单编号") |
| | | private String orderNumber; |
| | | |
| | | @Schema(name = "工单类型") |
| | | private String orderType; |
| | | |
| | | @Schema(name = "工单类型名") |
| | | private String orderTypeName; |
| | | |
| | | @Schema(name = "工单来源") |
| | | private String orderSource; |
| | | |
| | | @Schema(name = "优先级") |
| | | private Integer priority; |
| | | |
| | | @Schema(name = "优先级") |
| | | private String priorityName; |
| | | |
| | | @Schema(name = "标题") |
| | | private String title; |
| | | |
| | | @Schema(name = "内容") |
| | | private String content; |
| | | |
| | | @Schema(name = "工单状态") |
| | | private String status; |
| | | |
| | | @Schema(name = "工单状态名称") |
| | | private String statusName; |
| | | |
| | | @Schema(name = "完成期限") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") |
| | | private Date deadline; |
| | | |
| | | @Schema(name = "发布人") |
| | | private String publisher; |
| | | |
| | | @Schema(name = "发布人姓名") |
| | | private String publisherName; |
| | | |
| | | @Schema(name = "发布人部门") |
| | | private String publisherDept; |
| | | |
| | | @Schema(name = "发布时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") |
| | | private Date publishTime; |
| | | |
| | | @Schema(name = "审核人") |
| | | private String reviewer; |
| | | |
| | | @Schema(name = "审核人姓名") |
| | | private String reviewerName; |
| | | |
| | | @Schema(name = "审核时间") |
| | | private Date reviewTime; |
| | | |
| | | @Schema(name = "审核结果") |
| | | private String reviewResult; |
| | | |
| | | @Schema(name = "办理人") |
| | | private String assigner; |
| | | |
| | | @Schema(name = "办理人姓名") |
| | | private String assignerName; |
| | | |
| | | @Schema(name = "办理人部门") |
| | | private String assignerDept; |
| | | |
| | | @Schema(name = "指派时间") |
| | | private Date assignTime; |
| | | |
| | | @Schema(name = "开始处理时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") |
| | | private Date processStartTime; |
| | | |
| | | @Schema(name = "处理完成时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date processCompletedTime; |
| | | |
| | | @Schema(name = "已耗时(毫秒)") |
| | | private Long timeConsuming; |
| | | |
| | | @Schema(name = "已耗时(HH小时mm分钟)") |
| | | private String consuming; |
| | | |
| | | @Schema(name = "是否超时") |
| | | private Integer isTimeout; |
| | | |
| | | @Schema(name = "是否超时") |
| | | private String isTimeoutName; |
| | | |
| | | @Schema(name = "超时时长(毫秒)") |
| | | private Long timeoutLength; |
| | | |
| | | @Schema(name = "超时时长(HH小时mm分钟)") |
| | | private String timeoutHHmm; |
| | | |
| | | @Schema(name = "创建人") |
| | | private String createBy; |
| | | |
| | | @Schema(name = "创建人姓名") |
| | | private String createByName; |
| | | |
| | | @Schema(name = "抄送人") |
| | | private List<String> copyPerson; |
| | | |
| | | @Schema(name = "检修类型") |
| | | private String checkFixType; |
| | | |
| | | @Schema(name = "反馈内容") |
| | | private String backContent; |
| | | |
| | | @Schema(name = "创建时间") |
| | | private Date createDate; |
| | | |
| | | @Schema(name = "修改人") |
| | | private String updateBy; |
| | | |
| | | @Schema(name = "修改时间") |
| | | private Date updateDate; |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.dto; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2023年06月28日 09:19:00 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @Schema(description = "运行时长") |
| | | public class FeignQueryPointDTO implements Serializable { |
| | | |
| | | @Schema(description = "测点编号") |
| | | private String pointCode; |
| | | |
| | | @Schema(description = "类型") |
| | | private String type; |
| | | |
| | | @Schema(description = "开始时间") |
| | | private Date startTime; |
| | | |
| | | @Schema(description = "结束时间") |
| | | private Date endTime; |
| | | |
| | | @Schema(description = "开始日期") |
| | | private String startDate; |
| | | |
| | | @Schema(description = "结束日期") |
| | | private String endDate; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.dto; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年06月05日 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @Schema(description = "结果") |
| | | public class FeignResultDTO implements Serializable { |
| | | |
| | | private Integer code; |
| | | |
| | | private String msg; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.dto; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年06月05日 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @Schema(description = "写入测点值") |
| | | public class FeignWritePointValueDTO implements Serializable { |
| | | |
| | | @Schema(description = "测点编号") |
| | | private String pointCode; |
| | | |
| | | @Schema(description = "测点值") |
| | | private Object pointValue; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2023年03月05日 17:52:00 |
| | | */ |
| | | @Data |
| | | public class FileDto { |
| | | |
| | | private String uid; |
| | | |
| | | private String name; |
| | | |
| | | private String url; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.enums; |
| | | |
| | | import com.iailab.framework.common.enums.RpcConstants; |
| | | |
| | | /** |
| | | * API 相关的枚举 |
| | | * |
| | | * @author iailab |
| | | */ |
| | | public class ApiConstants { |
| | | |
| | | /** |
| | | * 服务名 |
| | | * |
| | | * 注意,需要保证和 spring.application.name 保持一致 |
| | | */ |
| | | public static final String NAME = "data-server"; |
| | | |
| | | public static final String PREFIX = RpcConstants.RPC_API_PREFIX + "/data"; |
| | | |
| | | public static final String VERSION = "1.0.0"; |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module; |
对比新文件 |
| | |
| | | package com.iailab; |
| | | |
| | | import org.springframework.boot.SpringApplication; |
| | | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| | | |
| | | @SpringBootApplication |
| | | public class DataWebApplication { |
| | | |
| | | |
| | | public static void main(String[] args) { |
| | | SpringApplication.run(DataWebApplication.class, args); |
| | | } |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.api.controller; |
| | | |
| | | import com.iailab.api.IFeignModelApi; |
| | | import com.iailab.framework.common.pojo.CommonResult; |
| | | import com.iailab.framework.common.util.date.DateUtils; |
| | | import com.iailab.module.data.common.dto.IndexQueryDTO; |
| | | import com.iailab.module.data.common.dto.echarts.BarLineDTO; |
| | | import com.iailab.module.data.common.dto.echarts.SeriesItem; |
| | | import com.iailab.module.data.common.utils.R; |
| | | import com.iailab.module.data.api.dto.ApiPointValueQueryDTO; |
| | | import com.iailab.module.data.point.collection.PointCollector; |
| | | import com.iailab.module.data.point.common.PointDataTypeEnum; |
| | | import com.iailab.module.data.point.dto.DaPointDTO; |
| | | import com.iailab.module.data.point.service.DaPointService; |
| | | import com.iailab.module.data.point.service.DaPointValueService; |
| | | import com.iailab.module.data.ind.collection.IndItemCollector; |
| | | import com.iailab.module.data.influxdb.pojo.InfluxPointValuePOJO; |
| | | import com.iailab.module.data.influxdb.service.InfluxDBService; |
| | | import com.iailab.module.data.api.dto.DeviceValueDTO; |
| | | import com.iailab.module.data.api.utils.ApiSecurityUtils; |
| | | import com.iailab.module.data.ind.dto.IndItemValueDTO; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2023年05月02日 10:58:00 |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/api/data") |
| | | @Tag(name = "数据") |
| | | public class DataController { |
| | | |
| | | @Resource |
| | | private DaPointService daPointService; |
| | | |
| | | @Resource |
| | | private ApiSecurityUtils apiSecurityUtils; |
| | | |
| | | @Resource |
| | | private DaPointValueService daPointValueService; |
| | | |
| | | @Resource |
| | | private InfluxDBService influxDBService; |
| | | |
| | | @Resource |
| | | private PointCollector pointCollector; |
| | | |
| | | @Resource |
| | | private IndItemCollector indItemCollector; |
| | | |
| | | @Resource |
| | | private IFeignModelApi feignModelApi; |
| | | |
| | | @PostMapping("/point/history") |
| | | @Operation(summary = "point历史数据") |
| | | public R pointHistory(HttpServletResponse response, HttpServletRequest |
| | | request, @RequestBody ApiPointValueQueryDTO queryDto) { |
| | | try { |
| | | apiSecurityUtils.validate(request); |
| | | Map<String, List<Map<String, Object>>> data = new HashMap<>(); |
| | | if (CollectionUtils.isEmpty(queryDto.getPointNos())) { |
| | | return R.ok().put("data", data); |
| | | } |
| | | if (queryDto.getStart() == null) { |
| | | queryDto.setStart(new Date()); |
| | | } |
| | | if (queryDto.getEnd() == null) { |
| | | queryDto.setEnd(new Date()); |
| | | } |
| | | Map<String, Object> params = new HashMap<>(1); |
| | | params.put("pointNos", queryDto.getPointNos()); |
| | | List<DaPointDTO> pointList = daPointService.list(params); |
| | | if (CollectionUtils.isEmpty(pointList)) { |
| | | return R.ok().put("data", data); |
| | | } |
| | | List<InfluxPointValuePOJO> influxParams = pointList.stream().map(item -> { |
| | | InfluxPointValuePOJO pojo = new InfluxPointValuePOJO(); |
| | | pojo.setPoint(item.getPointNo()); |
| | | pojo.setType(item.getDataType()); |
| | | return pojo; |
| | | }).collect(Collectors.toList()); |
| | | data = influxDBService.queryPointsValues(influxParams, queryDto.getStart(), queryDto.getEnd()); |
| | | return R.ok().put("data", data); |
| | | |
| | | } catch (Exception ex) { |
| | | return R.error(ex.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @PostMapping("/point/current") |
| | | @Operation(summary = "point当前实时数据") |
| | | public R pointCurrent(HttpServletResponse response, HttpServletRequest |
| | | request, @RequestBody List<String> pointNos) { |
| | | try { |
| | | // apiSecurityUtils.validate(request); |
| | | Map<String, Object> data = pointCollector.getCurrentValue(pointNos); |
| | | return R.ok().put("data", data); |
| | | } catch (Exception ex) { |
| | | return R.error(ex.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @PostMapping("/point/chart") |
| | | public CommonResult<BarLineDTO> pointChart(@RequestBody IndexQueryDTO dto) { |
| | | BarLineDTO CommonResult = new BarLineDTO(); |
| | | try { |
| | | List<String> legend = new ArrayList<>(); |
| | | List<SeriesItem> series = new ArrayList<>(); |
| | | String endDateStr = dto.getEndDate() == null ? DateUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss") : DateUtils.format(dto.getEndDate(), "yyyy-MM-dd HH:mm:ss"); |
| | | Date endDate = DateUtils.parse(endDateStr, "yyyy-MM-dd HH:mm"); |
| | | Date startDate = dto.getStartDate() == null ? DateUtils.addDateHours(endDate, -2) : dto.getStartDate(); |
| | | List<String> categories = DateUtils.getTimeScale(startDate, endDate, dto.getGranularity() == null ? 10 : dto.getGranularity()); |
| | | if (CollectionUtils.isEmpty(dto.getCodes())) { |
| | | return new CommonResult<BarLineDTO>().setData(CommonResult); |
| | | } |
| | | List<DaPointDTO> pointList = new ArrayList<>(); |
| | | dto.getCodes().forEach(item -> { |
| | | pointList.add(daPointService.getByNo(item)); |
| | | }); |
| | | pointList.forEach(item -> { |
| | | legend.add(item.getPointName()); |
| | | SeriesItem seriesItem = new SeriesItem(); |
| | | seriesItem.setName(item.getPointName()); |
| | | InfluxPointValuePOJO pojo = new InfluxPointValuePOJO(); |
| | | pojo.setPoint(item.getPointNo()); |
| | | pojo.setType(item.getDataType()); |
| | | List<Map<String, Object>> list = influxDBService.queryPointValues(pojo, startDate, endDate); |
| | | List<Object[]> sData = list.stream().map(dataItem -> { |
| | | Object[] valueArray = new Object[]{dataItem.get("time"), |
| | | getFormatValue(item.getDataType(), dataItem.get("value"))}; |
| | | return valueArray; |
| | | }).collect(Collectors.toList()); |
| | | seriesItem.setData(sData); |
| | | series.add(seriesItem); |
| | | }); |
| | | CommonResult.setLegend(legend); |
| | | CommonResult.setCategories(categories); |
| | | CommonResult.setSeries(series); |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | } |
| | | return new CommonResult<BarLineDTO>().setData(CommonResult); |
| | | } |
| | | |
| | | private Object getFormatValue(String dataType, Object value) { |
| | | if (!PointDataTypeEnum.BOOLEAN.getCode().equals(dataType)) { |
| | | BigDecimal decValue = new BigDecimal(value.toString()); |
| | | if (PointDataTypeEnum.FLOAT.getCode().equals(dataType)) { |
| | | return decValue.setScale(2, BigDecimal.ROUND_HALF_UP); |
| | | } else if (PointDataTypeEnum.INT.getCode().equals(dataType)) { |
| | | decValue = decValue.setScale(0, BigDecimal.ROUND_HALF_UP); |
| | | } |
| | | } |
| | | return value; |
| | | } |
| | | |
| | | |
| | | @PostMapping("/pointRelation/history") |
| | | @Operation(summary = "pointRelation历史数据") |
| | | public R pointRelationHistory(HttpServletResponse response, HttpServletRequest |
| | | request, @RequestBody ApiPointValueQueryDTO queryDto) { |
| | | try { |
| | | Map<String, List<Map<String, Object>>> data = new HashMap<>(); |
| | | if (CollectionUtils.isEmpty(queryDto.getPointNos())) { |
| | | return R.ok().put("data", data); |
| | | } |
| | | if (queryDto.getStart() == null) { |
| | | queryDto.setStart(new Date()); |
| | | } |
| | | if (queryDto.getEnd() == null) { |
| | | queryDto.setEnd(new Date()); |
| | | } |
| | | data = daPointValueService.getHistoryList(queryDto); |
| | | if (CollectionUtils.isEmpty(data)) { |
| | | return R.ok().put("data", data); |
| | | } |
| | | return R.ok().put("data", data); |
| | | } catch (Exception ex) { |
| | | return R.error(ex.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @GetMapping("/device-value") |
| | | public List<DeviceValueDTO> getDeviceValue(@RequestParam Map<String, Object> params) { |
| | | List<DeviceValueDTO> CommonResult = new ArrayList<>(); |
| | | if (params.get("pointNos") == null) { |
| | | return CommonResult; |
| | | } |
| | | List<String> pointNos = Arrays.asList(params.get("pointNos").toString().split(",")); |
| | | Map<String, Object> data = pointCollector.getCurrentValue(pointNos); |
| | | if (!CollectionUtils.isEmpty(data)) { |
| | | data.forEach((k, v) -> { |
| | | DeviceValueDTO dto = new DeviceValueDTO(); |
| | | dto.setDataId(k); |
| | | dto.setValue(new BigDecimal(v.toString())); |
| | | CommonResult.add(dto); |
| | | }); |
| | | } |
| | | return CommonResult; |
| | | } |
| | | |
| | | @PostMapping("/ind-item/values") |
| | | @Operation(summary = "point当前实时数据") |
| | | public R indItemValues(HttpServletResponse response, HttpServletRequest |
| | | request, @RequestBody List<String> itemNos) { |
| | | try { |
| | | // apiSecurityUtils.validate(request); |
| | | Map<String, List<IndItemValueDTO>> data = indItemCollector.getValueList(itemNos); |
| | | return R.ok().put("data", data); |
| | | } catch (Exception ex) { |
| | | return R.error(ex.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @PostMapping("/ind-item/current-value") |
| | | @Operation(summary = "point当前实时数据") |
| | | public R indItemCurrentValue(HttpServletResponse response, HttpServletRequest |
| | | request, @RequestBody List<String> itemNos) { |
| | | try { |
| | | Map<String, BigDecimal> data = new HashMap<>(); |
| | | // apiSecurityUtils.validate(request); |
| | | Map<String, List<IndItemValueDTO>> dataList = indItemCollector.getValueList(itemNos); |
| | | dataList.forEach((k, v) -> { |
| | | data.put(k, CollectionUtils.isEmpty(v) ? null : v.get(0).getDataValue()); |
| | | }); |
| | | return R.ok().put("data", data); |
| | | } catch (Exception ex) { |
| | | return R.error(ex.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @PostMapping("/ind-item/values-trend") |
| | | @Operation(summary = "point当前实时数据") |
| | | public R indItemValuesTrend(HttpServletResponse response, HttpServletRequest |
| | | request, @RequestBody List<String> itemNos) { |
| | | try { |
| | | apiSecurityUtils.validate(request); |
| | | Map<String, Object> CommonResult = new HashMap<>(); |
| | | Map<String, List<IndItemValueDTO>> values = indItemCollector.getValueList(itemNos); |
| | | CommonResult.put("values", values); |
| | | |
| | | Map<String, Map<String, Object>> trend = new HashMap<>(); |
| | | Map<String, Object> params = new HashMap<>(1); |
| | | params.put("modelCode", "trend_analysis"); |
| | | values.forEach((k, v) -> { |
| | | try { |
| | | List<double[][]> sampleDataList = new ArrayList<>(); |
| | | List<IndItemValueDTO> nv = v.stream().filter(dto -> { |
| | | return dto.getDataValue() != null; |
| | | }).collect(Collectors.toList()); |
| | | double[][] mix = new double[nv.size()][1]; |
| | | for (int i = 0; i < nv.size(); i++) { |
| | | mix[i][0] = nv.get(i).getDataValue().doubleValue(); |
| | | } |
| | | sampleDataList.add(mix); |
| | | Map<String, Object> trendItem = feignModelApi.runModel(params, sampleDataList); |
| | | trend.put(k, trendItem); |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | } |
| | | }); |
| | | CommonResult.put("trend", trend); |
| | | return R.ok().put("data", CommonResult); |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | return R.error(ex.getMessage()); |
| | | } |
| | | } |
| | | } |
对比新文件 |
| | |
| | | //package com.iailab.module.api.controller; |
| | | // |
| | | //import cn.hutool.jwt.JWTUtil; |
| | | //import com.iailab.common.utils.R; |
| | | //import com.iailab.module.gateway.entity.ApiAppEntity; |
| | | //import com.iailab.module.gateway.form.AppLoginForm; |
| | | //import com.iailab.module.gateway.service.ApiAppService; |
| | | //import io.swagger.v3.oas.annotations.tags.Tag; |
| | | //import javax.annotation.Resource; |
| | | //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 java.util.Date; |
| | | // |
| | | ///** |
| | | // * @author PanZhibao |
| | | // * @Description |
| | | // * @createTime 2023年12月06日 15:42:00 |
| | | // */ |
| | | //@RestController |
| | | //@RequestMapping("/api/token") |
| | | //@Tag(name = "授权") |
| | | //public class TokenController { |
| | | // |
| | | // @Resource |
| | | // private ApiAppService apiAppService; |
| | | // |
| | | // @PostMapping("/authenticate") |
| | | // public R authenticate(@RequestBody AppLoginForm form) { |
| | | // String username = form.getAppKey(); |
| | | // String password = form.getAppSecret(); |
| | | // |
| | | // //1. 校验用户是否有效 |
| | | // ApiAppEntity apiAppEntity = apiAppService.getInfoByAppKey(username); |
| | | // if (apiAppEntity == null) { |
| | | // return R.error("无效的用户"); |
| | | // } |
| | | // |
| | | // //2. 校验用户名或密码是否正确 |
| | | // if (!apiAppEntity.getAppSecret().equals(password)) { |
| | | // return R.error("Secret错误"); |
| | | // } |
| | | // //3. 生成token |
| | | // String token = com.iailab.common.utils.JwtUtils.generateToken(username, password); |
| | | // Date now = new Date(); |
| | | // Date expireTime = new Date(now.getTime() + com.iailab.common.utils.JwtUtils.EXPIRE_TIME); |
| | | // R r = R.ok().put("token", token).put("expire", expireTime); |
| | | // return r; |
| | | // } |
| | | //} |
对比新文件 |
| | |
| | | package com.iailab.module.data.api.dto; |
| | | |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2023年08月28日 13:57:00 |
| | | */ |
| | | @Data |
| | | @Tag(name = "值导出") |
| | | public class ApiExportValueDTO { |
| | | |
| | | /** |
| | | * 值 |
| | | */ |
| | | private String dataValue; |
| | | |
| | | /** |
| | | * 时间 |
| | | */ |
| | | private String dataTime; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.api.dto; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.constraints.NotNull; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2023年05月05日 16:08:00 |
| | | */ |
| | | @Data |
| | | @Tag(name = "测点值查询") |
| | | public class ApiPointValueQueryDTO { |
| | | @Schema(description = "pointNos") |
| | | @NotNull(message="pointNos不能为空") |
| | | private List<String> pointNos; |
| | | |
| | | @Schema(description = "开始时间") |
| | | @NotNull(message="start不能为空") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date start; |
| | | |
| | | @Schema(description = "结束时间") |
| | | @NotNull(message="end不能为空") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date end; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.api.dto; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.constraints.NotNull; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2023年05月02日 12:24:00 |
| | | */ |
| | | @Data |
| | | @Tag(name = "实时值查询") |
| | | public class ApiTagValueQueryDTO { |
| | | |
| | | @Schema(description = "tags") |
| | | @NotNull(message="不能为空") |
| | | private List<String> tagIds; |
| | | |
| | | @Schema(description = "tagId") |
| | | private String tagId; |
| | | |
| | | @Schema(description = "dataType") |
| | | private String dataType; |
| | | |
| | | @Schema(description = "开始时间") |
| | | @NotNull(message="不能为空") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date start; |
| | | |
| | | @Schema(description = "结束时间") |
| | | @NotNull(message="不能为空") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date end; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.api.dto; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2023年09月11日 08:50:00 |
| | | */ |
| | | @Data |
| | | @Tag(name = "设备值") |
| | | public class DeviceValueDTO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @Schema(description = "设备ID") |
| | | private String dataId; |
| | | |
| | | @Schema(description = "值") |
| | | private BigDecimal value; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.api.utils; |
| | | |
| | | |
| | | import com.iailab.framework.common.constant.Constant; |
| | | import com.iailab.framework.common.pojo.CommonResult; |
| | | import com.iailab.framework.security.core.LoginUser; |
| | | import com.iailab.framework.security.core.util.SecurityFrameworkUtils; |
| | | import com.iailab.module.data.gateway.entity.ApiAppEntity; |
| | | import com.iailab.module.data.gateway.service.ApiAppService; |
| | | import com.iailab.module.data.gateway.entity.ApiAppEntity; |
| | | import com.iailab.module.data.gateway.service.ApiAppService; |
| | | import com.iailab.module.system.api.user.AdminUserApi; |
| | | import com.iailab.module.system.api.user.dto.AdminUserRespDTO; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.regex.Pattern; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2023年12月06日 15:55:00 |
| | | */ |
| | | @Component |
| | | public class ApiSecurityUtils { |
| | | |
| | | @Resource |
| | | private ApiAppService apiAppService; |
| | | |
| | | @Resource |
| | | private AdminUserApi adminUserApi; |
| | | |
| | | private Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$"); |
| | | |
| | | private String getRequestToken(HttpServletRequest httpRequest) { |
| | | //从header中获取token |
| | | String token = httpRequest.getHeader(Constant.TOKEN_HEADER); |
| | | |
| | | //如果header中不存在token,则从参数中获取token |
| | | if (StringUtils.isBlank(token)) { |
| | | token = httpRequest.getParameter(Constant.TOKEN_HEADER); |
| | | } |
| | | |
| | | return token; |
| | | } |
| | | |
| | | |
| | | public void validate(HttpServletRequest httpRequest) throws Exception { |
| | | String token = getRequestToken(httpRequest); |
| | | if (StringUtils.isBlank(token)) { |
| | | throw new Exception("token 不能为空!"); |
| | | } |
| | | LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); |
| | | if (ObjectUtils.isEmpty(loginUser)) { |
| | | throw new RuntimeException("用户不能为空"); |
| | | } |
| | | CommonResult<AdminUserRespDTO> user = adminUserApi.getUser(loginUser.getId()); |
| | | if(ObjectUtils.isEmpty(user)) { |
| | | throw new RuntimeException("用户不存在"); |
| | | } |
| | | AdminUserRespDTO userData = user.getData(); |
| | | String username = userData.getUsername(); |
| | | ApiAppEntity appInfo = apiAppService.getInfoByAppKey(username); |
| | | if (appInfo == null) { |
| | | throw new RuntimeException("应用未授权"); |
| | | } |
| | | //TODO 验证签名 |
| | | // if(!com.iailab.common.utils.JwtUtils.verify(token, appInfo.getAppSecret())){ |
| | | // throw new RuntimeException("签名错误"); |
| | | // } |
| | | } |
| | | |
| | | private boolean isInteger(String str) { |
| | | return pattern.matcher(str).matches(); |
| | | } |
| | | |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.kio.collector; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.iailab.module.data.common.utils.HttpRequest; |
| | | import com.iailab.module.data.channel.kio.dto.*; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年06月04日 |
| | | */ |
| | | public class KingIOClient { |
| | | |
| | | private boolean bLogin = false; |
| | | |
| | | private boolean bConnect = false; |
| | | |
| | | private String ip; |
| | | |
| | | private int port; |
| | | |
| | | private String username; |
| | | |
| | | private String password; |
| | | |
| | | private String instanceName; |
| | | |
| | | private String authorization; |
| | | |
| | | private String url; |
| | | |
| | | private String chartset = "utf-8"; |
| | | |
| | | private final String R_CODE = "code"; |
| | | |
| | | private final String R_MSG = "message"; |
| | | |
| | | private final String R_DATA = "data"; |
| | | |
| | | private final int S_CODE = 0; |
| | | |
| | | private final String DATA_V = "V"; |
| | | |
| | | private long exp_login = 1000 * 60; |
| | | |
| | | private long logint_time = 0; |
| | | |
| | | private long heartbeat_last = 0; |
| | | |
| | | private int Q_192 = 192; |
| | | |
| | | private Logger logger = LoggerFactory.getLogger(getClass()); |
| | | |
| | | KingIOClient(String instanceName) { |
| | | this.instanceName = instanceName; |
| | | } |
| | | |
| | | /** |
| | | * 登录设备 |
| | | * |
| | | * @param ip |
| | | * @param port |
| | | * @param username |
| | | * @param password |
| | | */ |
| | | public boolean login(String ip, int port, String username, String password) { |
| | | if ((System.currentTimeMillis() - this.logint_time) < exp_login) { |
| | | return bLogin; |
| | | } |
| | | this.ip = ip; |
| | | this.port = port; |
| | | this.username = username; |
| | | this.password = password; |
| | | this.url = "http://" + ip + ":" + port + "/api/v1"; |
| | | Map<String, String> form = new HashMap<>(2); |
| | | form.put("username", username); |
| | | form.put("password", password); |
| | | this.logint_time = System.currentTimeMillis(); |
| | | String responseStr = HttpRequest.sendPost(this.url + "/login", JSON.toJSONString(form)); |
| | | JSONObject responseObj = JSON.parseObject(responseStr); |
| | | if (S_CODE != Integer.parseInt(responseObj.get(R_CODE).toString())) { |
| | | bLogin = false; |
| | | return false; |
| | | } |
| | | this.authorization = responseObj.getJSONObject(R_DATA).get("Authorization").toString(); |
| | | bLogin = true; |
| | | return bLogin; |
| | | } |
| | | |
| | | public boolean reLogin() { |
| | | return login(this.ip, this.port, this.username, this.password); |
| | | } |
| | | |
| | | public boolean isExpLogin() { |
| | | /*if ((System.currentTimeMillis() - logint_time) > exp_login) { |
| | | return true; |
| | | } else { |
| | | return false; |
| | | }*/ |
| | | if ((System.currentTimeMillis() - logint_time) > exp_login) { |
| | | this.bLogin = false; |
| | | return true; |
| | | }return false; |
| | | |
| | | } |
| | | |
| | | public boolean isConnect() { |
| | | try { |
| | | if ((System.currentTimeMillis() - heartbeat_last) < 10000) { |
| | | return bConnect; |
| | | } |
| | | Map<String, String> map = new HashMap<>(); |
| | | String responseStr = HttpRequest.sendPost(this.url + "/heartbeat", "", this.authorization); |
| | | JSONObject responseObj = JSON.parseObject(responseStr); |
| | | if (S_CODE != Integer.parseInt(responseObj.get(R_CODE).toString())) { |
| | | bConnect = false; |
| | | } else { |
| | | logger.info("KIO心跳正常。"); |
| | | bConnect = true; |
| | | } |
| | | heartbeat_last = System.currentTimeMillis(); |
| | | } catch (Exception ex) { |
| | | logger.info("KIO心跳异常!" + ex.getMessage()); |
| | | bConnect = false; |
| | | } |
| | | return bConnect; |
| | | } |
| | | |
| | | public String getTagValue(String tagName) { |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("projectInstanceName", this.instanceName); |
| | | map.put("TagName", tagName); |
| | | String responseStr = HttpRequest.sendGet(this.url + "/realvalue", map, this.authorization); |
| | | JSONObject responseObj = JSON.parseObject(responseStr); |
| | | if (S_CODE != Integer.parseInt(responseObj.get(R_CODE).toString())) { |
| | | return null; |
| | | } |
| | | JSONObject data = responseObj.getJSONObject(R_DATA); |
| | | Object dataV = data.get(DATA_V); |
| | | return dataV.toString(); |
| | | } |
| | | |
| | | public Map<String, String> getTagsValue(List<String> tagNames) { |
| | | Map<String, String> result = new HashMap<>(); |
| | | KIOWriteObjDTO queryDto = new KIOWriteObjDTO(); |
| | | List<KIOWriteDTO> objs = new ArrayList<>(); |
| | | tagNames.forEach(item -> { |
| | | KIOWriteDTO dto = new KIOWriteDTO(); |
| | | dto.setN(item); |
| | | objs.add(dto); |
| | | }); |
| | | queryDto.setObjs(objs); |
| | | String responseStr = HttpRequest.sendPost(this.url + "/batchrealvalue", JSONObject.toJSONString(queryDto), this.authorization); |
| | | JSONObject responseObj = JSON.parseObject(responseStr); |
| | | if (S_CODE != Integer.parseInt(responseObj.get(R_CODE).toString())) { |
| | | return null; |
| | | } |
| | | JSONArray data = responseObj.getJSONArray(R_DATA); |
| | | for (int i = 0; i < data.size(); i++) { |
| | | JSONObject obj = data.getJSONObject(i); |
| | | if (obj.getInteger("Q") != Q_192) { |
| | | continue; |
| | | } |
| | | result.put(obj.getString("N"), obj.get(DATA_V).toString()); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | public void writeFloatValue(String tagName, Float newValue) throws Exception { |
| | | KIOWriteObjDTO writeObj = new KIOWriteObjDTO(); |
| | | List<KIOWriteDTO> objs = new ArrayList<>(); |
| | | KIOWriteFloatDTO writeDTO = new KIOWriteFloatDTO(); |
| | | writeDTO.setN(tagName); |
| | | writeDTO.setV(newValue); |
| | | objs.add(writeDTO); |
| | | writeObj.setObjs(objs); |
| | | String writeStr = JSONObject.toJSONString(writeObj); |
| | | String responseStr = HttpRequest.sendPost(this.url + "/realvariables", writeStr, this.authorization); |
| | | JSONObject responseObj = JSON.parseObject(responseStr); |
| | | if (S_CODE != Integer.parseInt(responseObj.get(R_CODE).toString())) { |
| | | throw new Exception(responseObj.getString(R_MSG)); |
| | | } |
| | | |
| | | } |
| | | |
| | | public void writeIntValue(String tagName, Integer newValue) throws Exception { |
| | | KIOWriteObjDTO writeObj = new KIOWriteObjDTO(); |
| | | List<KIOWriteDTO> objs = new ArrayList<>(); |
| | | KIOWriteIntDTO writeDTO = new KIOWriteIntDTO(); |
| | | writeDTO.setN(tagName); |
| | | writeDTO.setV(newValue); |
| | | objs.add(writeDTO); |
| | | writeObj.setObjs(objs); |
| | | String responseStr = HttpRequest.sendPost(this.url + "/realvariables", JSONObject.toJSONString(writeObj), this.authorization); |
| | | JSONObject responseObj = JSON.parseObject(responseStr); |
| | | if (S_CODE != Integer.parseInt(responseObj.get(R_CODE).toString())) { |
| | | throw new Exception(responseObj.getString(R_MSG)); |
| | | } |
| | | } |
| | | |
| | | public void writeBooleanValue(String tagName, Boolean newValue) throws Exception { |
| | | KIOWriteObjDTO writeObj = new KIOWriteObjDTO(); |
| | | List<KIOWriteDTO> objs = new ArrayList<>(); |
| | | KIOWriteBooleanDTO writeDTO = new KIOWriteBooleanDTO(); |
| | | writeDTO.setN(tagName); |
| | | writeDTO.setV(newValue); |
| | | objs.add(writeDTO); |
| | | writeObj.setObjs(objs); |
| | | String responseStr = HttpRequest.sendPost(this.url + "/realvariables", JSONObject.toJSONString(writeObj), this.authorization); |
| | | JSONObject responseObj = JSON.parseObject(responseStr); |
| | | if (S_CODE != Integer.parseInt(responseObj.get(R_CODE).toString())) { |
| | | throw new Exception(responseObj.getString(R_MSG)); |
| | | } |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.kio.collector; |
| | | |
| | | import com.iailab.module.data.common.enums.DataSourceType; |
| | | import com.iailab.module.data.common.utils.TagUtils; |
| | | import com.iailab.module.data.channel.kio.dto.ChannelKioDeviceDTO; |
| | | import com.iailab.module.data.channel.kio.service.ChannelKioDeviceService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年06月04日 |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class KingIOCollector { |
| | | |
| | | @Resource |
| | | private ChannelKioDeviceService channelKioDeviceService; |
| | | |
| | | private Map<String, KingIOClient> clientMap = new ConcurrentHashMap<>(); |
| | | |
| | | private Map<String, ChannelKioDeviceDTO> deviceMap = new HashMap<>(); |
| | | |
| | | public synchronized KingIOClient getClient(String sourceId) throws Exception { |
| | | if (!clientMap.containsKey(sourceId)) { |
| | | ChannelKioDeviceDTO deviceDto = channelKioDeviceService.get(sourceId); |
| | | deviceMap.put(sourceId, deviceDto); |
| | | KingIOClient kingIOClient = new KingIOClient(deviceDto.getInstanceName()); |
| | | clientMap.put(sourceId, kingIOClient); |
| | | if (!kingIOClient.login(deviceDto.getAddress(), deviceDto.getPort(), deviceDto.getUsername(), deviceDto.getPassword())) { |
| | | throw new Exception("登录异常"); |
| | | } |
| | | } |
| | | KingIOClient kingIOClient = clientMap.get(sourceId); |
| | | if (!kingIOClient.isConnect()) { |
| | | kingIOClient.reLogin(); |
| | | } |
| | | return kingIOClient; |
| | | } |
| | | |
| | | public String getTagValue(String sourceId, String tagName) throws Exception { |
| | | KingIOClient client = this.getClient(sourceId); |
| | | String value = client.getTagValue(tagName); |
| | | return value; |
| | | } |
| | | |
| | | public void setTagValue(String sourceId, String tagName, String newValue, String dataType) throws Exception { |
| | | try { |
| | | KingIOClient client = this.getClient(sourceId); |
| | | switch (dataType) { |
| | | case "float": |
| | | log.debug("Float,tagName=" + tagName + ",Value=" + Float.parseFloat(newValue)); |
| | | client.writeFloatValue(tagName, Float.parseFloat(newValue)); |
| | | break; |
| | | case "int": |
| | | log.debug("Int,tagName=" + tagName + ",Value=" + new BigDecimal(newValue).intValue()); |
| | | client.writeIntValue(tagName, new BigDecimal(newValue).intValue()); |
| | | break; |
| | | case "boolean": |
| | | log.debug("Boolean,tagName=" + tagName + ",Value=" + newValue); |
| | | client.writeBooleanValue(tagName, Boolean.parseBoolean(newValue)); |
| | | break; |
| | | default: |
| | | log.warn("##################### No DataType ####################"); |
| | | break; |
| | | } |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | throw ex; |
| | | } |
| | | } |
| | | |
| | | public Map<String, Object> getTagValues(List<String[]> params) { |
| | | if (CollectionUtils.isEmpty(params)) { |
| | | return new HashMap<>(); |
| | | } |
| | | Map<String, Object> result = new HashMap<>(params.size()); |
| | | |
| | | /*params.forEach(item -> { |
| | | try { |
| | | KingIOClient client = this.getClient(item[0]); |
| | | String value = client.getTagValue(item[1]); |
| | | result.put(TagUtils.genTagId(DataSourceType.KIO.getCode(), deviceMap.get(item[0]).getInstanceName(), item[1]), value); |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | result.put(TagUtils.genTagId(DataSourceType.KIO.getCode(), deviceMap.get(item[0]).getInstanceName(), item[1]), CommonConstant.BAD_VALUE); |
| | | } |
| | | });*/ |
| | | |
| | | Map<String, List<String[]>> sourceGroup = new HashMap<>(); |
| | | params.forEach(item -> { |
| | | if (sourceGroup.containsKey(item[0])) { |
| | | sourceGroup.get(item[0]).add(item); |
| | | } else { |
| | | List<String[]> list = new ArrayList<>(); |
| | | list.add(item); |
| | | sourceGroup.put(item[0], list); |
| | | } |
| | | }); |
| | | sourceGroup.forEach((k, v) -> { |
| | | try { |
| | | KingIOClient client = this.getClient(k); |
| | | List<String> tagNames = v.stream().map(t -> { |
| | | return t[1]; |
| | | }).collect(Collectors.toList()); |
| | | Map<String, String> tagsValue = client.getTagsValue(tagNames); |
| | | for (Map.Entry<String, String> tagValue : tagsValue.entrySet()) { |
| | | result.put(TagUtils.genTagId(DataSourceType.KIO.getCode(), deviceMap.get(k).getInstanceName(), tagValue.getKey()), tagValue.getValue()); |
| | | } |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | } |
| | | |
| | | }); |
| | | return result; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.kio.controller.admin; |
| | | |
| | | import com.iailab.framework.common.constant.Constant; |
| | | import com.iailab.framework.common.page.PageData; |
| | | import com.iailab.framework.common.pojo.CommonResult; |
| | | import com.iailab.framework.common.util.validation.ValidationUtils; |
| | | import com.iailab.framework.common.validation.group.AddGroup; |
| | | import com.iailab.framework.common.validation.group.DefaultGroup; |
| | | import com.iailab.module.data.channel.kio.service.ChannelKioDeviceService; |
| | | import com.iailab.module.data.channel.kio.dto.ChannelKioDeviceDTO; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.Parameters; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.Map; |
| | | import java.util.UUID; |
| | | |
| | | import static com.iailab.framework.common.pojo.CommonResult.success; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年06月04日 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/data/channel/kio/device") |
| | | @Tag(name = "KIO") |
| | | public class ChannelKioDeviceController { |
| | | |
| | | @Resource |
| | | private ChannelKioDeviceService channelKioDeviceService; |
| | | |
| | | @GetMapping("page") |
| | | @Operation(summary = "分页") |
| | | @Parameters({ |
| | | @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true) , |
| | | @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true) , |
| | | @Parameter(name = Constant.ORDER_FIELD, description = "排序字段") , |
| | | @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") |
| | | }) |
| | | public CommonResult<PageData<ChannelKioDeviceDTO>> list(@RequestParam Map<String, Object> params) { |
| | | PageData<ChannelKioDeviceDTO> page = channelKioDeviceService.page(params); |
| | | return success(page); |
| | | } |
| | | |
| | | @GetMapping("{id}") |
| | | @Operation(summary = "信息") |
| | | public CommonResult<ChannelKioDeviceDTO> get(@PathVariable("id") String id) { |
| | | ChannelKioDeviceDTO data = channelKioDeviceService.get(id); |
| | | return success(data); |
| | | } |
| | | |
| | | @PostMapping |
| | | @Operation(summary = "保存") |
| | | public CommonResult save(@RequestBody ChannelKioDeviceDTO dto) { |
| | | //效验数据 |
| | | ValidationUtils.validate(dto, AddGroup.class, DefaultGroup.class); |
| | | String id = UUID.randomUUID().toString(); |
| | | dto.setId(id); |
| | | channelKioDeviceService.save(dto); |
| | | return new CommonResult(); |
| | | } |
| | | |
| | | /** |
| | | * 修改kio配置 |
| | | * |
| | | */ |
| | | @PutMapping |
| | | @Operation(summary = "修改") |
| | | public CommonResult update(@RequestBody ChannelKioDeviceDTO dto) { |
| | | //效验数据 |
| | | ValidationUtils.validate(dto, AddGroup.class, DefaultGroup.class); |
| | | channelKioDeviceService.update(dto); |
| | | return new CommonResult(); |
| | | } |
| | | |
| | | @DeleteMapping |
| | | @Operation(summary = "删除") |
| | | public CommonResult delete(@RequestBody String[] ids){ |
| | | channelKioDeviceService.delete(ids); |
| | | return new CommonResult(); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.kio.controller.admin; |
| | | |
| | | import com.iailab.framework.common.constant.Constant; |
| | | import com.iailab.framework.common.page.PageData; |
| | | import com.iailab.framework.common.pojo.CommonResult; |
| | | import com.iailab.framework.common.util.validation.ValidationUtils; |
| | | import com.iailab.framework.common.validation.group.AddGroup; |
| | | import com.iailab.framework.common.validation.group.DefaultGroup; |
| | | import com.iailab.module.data.channel.kio.dto.ChannelKioTagDTO; |
| | | import com.iailab.module.data.channel.kio.service.ChannelKioTagService; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.Parameters; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.Map; |
| | | import java.util.UUID; |
| | | |
| | | /** |
| | | * 操作opcua tag配置 |
| | | * |
| | | * @author DongYukun |
| | | * @createTime 2023年05月6日 17:44:00 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/data/channel/kio/tag") |
| | | public class ChannelKioTagController { |
| | | @Resource |
| | | private ChannelKioTagService channelKioTagService; |
| | | |
| | | /** |
| | | * 分页查询tag |
| | | * */ |
| | | @GetMapping("page") |
| | | @Operation(summary = "分页") |
| | | @Parameters({ |
| | | @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true) , |
| | | @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true) , |
| | | @Parameter(name = Constant.ORDER_FIELD, description = "排序字段") , |
| | | @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") |
| | | }) |
| | | public CommonResult<PageData<ChannelKioTagDTO>> page(@RequestParam Map<String, Object> params){ |
| | | PageData<ChannelKioTagDTO> page = channelKioTagService.page(params); |
| | | return new CommonResult<PageData<ChannelKioTagDTO>>().setData(page); |
| | | } |
| | | |
| | | @GetMapping("{id}") |
| | | @Operation(summary = "信息") |
| | | public CommonResult<ChannelKioTagDTO> get(@PathVariable("id") String id){ |
| | | ChannelKioTagDTO data= channelKioTagService.get(id); |
| | | return new CommonResult<ChannelKioTagDTO>().setData(data); |
| | | } |
| | | |
| | | @PostMapping |
| | | @Operation(summary = "保存") |
| | | public CommonResult save(@RequestBody ChannelKioTagDTO entity){ |
| | | entity.setId(UUID.randomUUID().toString()); |
| | | channelKioTagService.save(entity); |
| | | return new CommonResult(); |
| | | } |
| | | |
| | | /** |
| | | * 修改tag |
| | | */ |
| | | @PutMapping |
| | | @Operation(summary = "修改") |
| | | public CommonResult update(@RequestBody ChannelKioTagDTO dto) { |
| | | //效验数据 |
| | | ValidationUtils.validate(dto, AddGroup.class, DefaultGroup.class); |
| | | channelKioTagService.update(dto); |
| | | return new CommonResult(); |
| | | } |
| | | |
| | | @DeleteMapping |
| | | @Operation(summary = "删除") |
| | | public CommonResult tagDelete(@RequestBody String[] ids) { |
| | | channelKioTagService.delete(ids); |
| | | return new CommonResult(); |
| | | } |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.kio.controller; |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.kio.dao; |
| | | |
| | | import com.iailab.framework.common.dao.BaseDao; |
| | | import com.iailab.module.data.channel.kio.entity.ChannelKioDeviceEntity; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年06月04日 |
| | | */ |
| | | @Mapper |
| | | public interface ChannelKioDeviceDao extends BaseDao<ChannelKioDeviceEntity> { |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.kio.dao; |
| | | |
| | | import com.iailab.framework.common.dao.BaseDao; |
| | | import com.iailab.module.data.channel.kio.entity.ChannelKioTagEntity; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年06月05日 |
| | | */ |
| | | @Mapper |
| | | public interface ChannelKioTagDao extends BaseDao<ChannelKioTagEntity> { |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.kio.dto; |
| | | |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年06月04日 |
| | | */ |
| | | @Data |
| | | @Tag(name = "KIO实例") |
| | | public class ChannelKioDeviceDTO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @Schema(description = "ID") |
| | | private String id; |
| | | |
| | | @Schema(description = "实例名称") |
| | | private String instanceName; |
| | | |
| | | @Schema(description = "IP地址") |
| | | private String address; |
| | | |
| | | @Schema(description = "端口") |
| | | private Integer port; |
| | | |
| | | @Schema(description = "用户名") |
| | | private String username; |
| | | |
| | | @Schema(description = "密码") |
| | | private String password; |
| | | |
| | | |
| | | @Schema(description = "创建时间") |
| | | private Date createTime; |
| | | |
| | | |
| | | @Schema(description = "修改时间") |
| | | private Date updateTime; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.kio.dto; |
| | | |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年06月05日 |
| | | */ |
| | | @Data |
| | | @Tag(name = "KIO测点") |
| | | public class ChannelKioTagDTO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | |
| | | @Schema(description = "ID") |
| | | private String id; |
| | | |
| | | @Schema(description = "名称") |
| | | private String tagName; |
| | | |
| | | @Schema(description = "数据类型") |
| | | private String dataType; |
| | | |
| | | @Schema(description = "顺序号") |
| | | private Integer tagId; |
| | | |
| | | @Schema(description = "测点描述") |
| | | private String tagDesc; |
| | | |
| | | @Schema(description = "是否可以tag") |
| | | private Boolean enabled; |
| | | |
| | | @Schema(description = "关联设备") |
| | | private String device; |
| | | |
| | | @Schema(description = "采集频率") |
| | | private Integer samplingRate; |
| | | |
| | | @Schema(description = "创建时间") |
| | | private Date createTime; |
| | | |
| | | @Schema(description = "修改时间") |
| | | private Date updateTime; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.kio.dto; |
| | | |
| | | import com.alibaba.fastjson.annotation.JSONField; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年06月05日 |
| | | */ |
| | | @Data |
| | | public class KIOWriteBooleanDTO extends KIOWriteDTO { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @JSONField(name="V") |
| | | private Boolean V; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.kio.dto; |
| | | |
| | | import com.alibaba.fastjson.annotation.JSONField; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年06月05日 |
| | | */ |
| | | @Data |
| | | public class KIOWriteDTO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @JSONField(name="N") |
| | | private String N; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.kio.dto; |
| | | |
| | | import com.alibaba.fastjson.annotation.JSONField; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年06月05日 |
| | | */ |
| | | @Data |
| | | public class KIOWriteFloatDTO extends KIOWriteDTO { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @JSONField(name="V") |
| | | private Float V; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.kio.dto; |
| | | |
| | | import com.alibaba.fastjson.annotation.JSONField; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年06月05日 |
| | | */ |
| | | @Data |
| | | public class KIOWriteIntDTO extends KIOWriteDTO { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @JSONField(name="V") |
| | | private Integer V; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.kio.dto; |
| | | |
| | | import com.alibaba.fastjson.annotation.JSONField; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年06月05日 |
| | | */ |
| | | @Data |
| | | public class KIOWriteObjDTO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @JSONField(name="objs") |
| | | private List<KIOWriteDTO> objs; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.kio.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年06月04日 |
| | | */ |
| | | @Data |
| | | @TableName("t_channel_kio_device") |
| | | public class ChannelKioDeviceEntity implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @Schema(description = "主键") |
| | | @TableId(value = "id",type = IdType.INPUT) |
| | | private String id; |
| | | |
| | | /** |
| | | * 实例名称 |
| | | */ |
| | | private String instanceName; |
| | | |
| | | /** |
| | | * IP地址 |
| | | */ |
| | | private String address; |
| | | |
| | | /** |
| | | * 端口 |
| | | */ |
| | | private Integer port; |
| | | |
| | | /** |
| | | * 用户名 |
| | | */ |
| | | private String username; |
| | | |
| | | /** |
| | | * 密码 |
| | | */ |
| | | private String password; |
| | | |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | private Date createTime; |
| | | |
| | | |
| | | /** |
| | | * 修改时间 |
| | | */ |
| | | private Date updateTime; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.kio.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年06月05日 |
| | | */ |
| | | @Data |
| | | @TableName("t_channel_kio_tag") |
| | | public class ChannelKioTagEntity implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @Schema(description = "主键") |
| | | @TableId(value = "id",type = IdType.INPUT) |
| | | private String id; |
| | | |
| | | /** |
| | | * 名称 |
| | | */ |
| | | private String tagName; |
| | | |
| | | |
| | | /** |
| | | * 数据类型 |
| | | */ |
| | | private String dataType; |
| | | |
| | | /** |
| | | * 顺序号 |
| | | */ |
| | | private Integer tagId; |
| | | |
| | | /** |
| | | * 测点描述 |
| | | */ |
| | | private String tagDesc; |
| | | |
| | | /** |
| | | * 是否可以tag |
| | | */ |
| | | private Boolean enabled; |
| | | |
| | | /** |
| | | * 关联设备 |
| | | */ |
| | | private String device; |
| | | |
| | | /** |
| | | * 采集频率 |
| | | */ |
| | | private Integer samplingRate; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * 修改时间 |
| | | */ |
| | | private Date updateTime; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.kio.service; |
| | | |
| | | import com.iailab.framework.common.page.PageData; |
| | | import com.iailab.framework.common.service.BaseService; |
| | | import com.iailab.module.data.channel.kio.dto.ChannelKioDeviceDTO; |
| | | import com.iailab.module.data.channel.kio.entity.ChannelKioDeviceEntity; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年06月04日 |
| | | */ |
| | | public interface ChannelKioDeviceService extends BaseService<ChannelKioDeviceEntity> { |
| | | |
| | | PageData<ChannelKioDeviceDTO> page(Map<String, Object> params); |
| | | |
| | | List<ChannelKioDeviceDTO> list(Map<String, Object> params); |
| | | |
| | | ChannelKioDeviceDTO get(String id); |
| | | |
| | | void save(ChannelKioDeviceDTO dto); |
| | | |
| | | void update(ChannelKioDeviceDTO dto); |
| | | |
| | | void delete(String[] ids); |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.kio.service; |
| | | |
| | | import com.iailab.framework.common.page.PageData; |
| | | import com.iailab.framework.common.service.BaseService; |
| | | import com.iailab.module.data.channel.kio.dto.ChannelKioTagDTO; |
| | | import com.iailab.module.data.channel.kio.entity.ChannelKioTagEntity; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年06月05日 |
| | | */ |
| | | public interface ChannelKioTagService extends BaseService<ChannelKioTagEntity> { |
| | | |
| | | PageData<ChannelKioTagDTO> page(Map<String, Object> params); |
| | | |
| | | ChannelKioTagDTO get(String id); |
| | | |
| | | void save(ChannelKioTagDTO dto); |
| | | |
| | | void update(ChannelKioTagDTO dto); |
| | | |
| | | void delete(String[] ids); |
| | | List<ChannelKioTagDTO> getByDevice(String instanceName); |
| | | |
| | | ChannelKioTagDTO getByTagName(String tagName); |
| | | |
| | | void deleteByDeviceName(String name); |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.kio.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.iailab.framework.common.constant.Constant; |
| | | import com.iailab.framework.common.page.PageData; |
| | | import com.iailab.framework.common.service.impl.BaseServiceImpl; |
| | | import com.iailab.framework.common.util.object.ConvertUtils; |
| | | import com.iailab.module.data.channel.kio.service.ChannelKioTagService; |
| | | import com.iailab.module.data.channel.kio.dao.ChannelKioDeviceDao; |
| | | import com.iailab.module.data.channel.kio.dto.ChannelKioDeviceDTO; |
| | | import com.iailab.module.data.channel.kio.entity.ChannelKioDeviceEntity; |
| | | import com.iailab.module.data.channel.kio.service.ChannelKioDeviceService; |
| | | import com.iailab.module.data.channel.kio.service.ChannelKioTagService; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年06月04日 |
| | | */ |
| | | @Service |
| | | public class ChannelKioDeviceServiceImpl extends BaseServiceImpl<ChannelKioDeviceDao, ChannelKioDeviceEntity> implements ChannelKioDeviceService { |
| | | |
| | | @Resource |
| | | ChannelKioTagService channelKioTagService; |
| | | |
| | | @Override |
| | | public PageData<ChannelKioDeviceDTO> page(Map<String, Object> params) { |
| | | IPage<ChannelKioDeviceEntity> page = baseDao.selectPage( |
| | | getPage(params, Constant.CREATE_TIME, false), |
| | | getWrapper(params) |
| | | ); |
| | | return getPageData(page, ChannelKioDeviceDTO.class); |
| | | } |
| | | |
| | | @Override |
| | | public List<ChannelKioDeviceDTO> list(Map<String, Object> params) { |
| | | List<ChannelKioDeviceEntity> list = baseDao.selectList(getWrapper(params)); |
| | | return ConvertUtils.sourceToTarget(list, ChannelKioDeviceDTO.class); |
| | | } |
| | | |
| | | private QueryWrapper<ChannelKioDeviceEntity> getWrapper(Map<String, Object> params){ |
| | | String instanceName = (String)params.get("instanceName"); |
| | | QueryWrapper<ChannelKioDeviceEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.like(StringUtils.isNotBlank(instanceName), "instance_name", instanceName); |
| | | return wrapper; |
| | | } |
| | | |
| | | @Override |
| | | public ChannelKioDeviceDTO get(String id) { |
| | | ChannelKioDeviceEntity entity = baseDao.selectById(id); |
| | | return ConvertUtils.sourceToTarget(entity, ChannelKioDeviceDTO.class); |
| | | } |
| | | |
| | | @Override |
| | | public void save(ChannelKioDeviceDTO dto) { |
| | | ChannelKioDeviceEntity entity = ConvertUtils.sourceToTarget(dto, ChannelKioDeviceEntity.class); |
| | | insert(entity); |
| | | } |
| | | |
| | | @Override |
| | | public void update(ChannelKioDeviceDTO dto) { |
| | | ChannelKioDeviceEntity entity = ConvertUtils.sourceToTarget(dto, ChannelKioDeviceEntity.class); |
| | | updateById(entity); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void delete(String[] ids) { |
| | | Arrays.asList(ids).forEach(id -> { |
| | | channelKioTagService.deleteByDeviceName(get(id).getInstanceName()); |
| | | }); |
| | | baseDao.deleteBatchIds(Arrays.asList(ids)); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.kio.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.iailab.framework.common.constant.Constant; |
| | | import com.iailab.framework.common.page.PageData; |
| | | import com.iailab.framework.common.service.impl.BaseServiceImpl; |
| | | import com.iailab.framework.common.util.object.ConvertUtils; |
| | | import com.iailab.module.data.channel.kio.dao.ChannelKioTagDao; |
| | | import com.iailab.module.data.channel.kio.dto.ChannelKioTagDTO; |
| | | import com.iailab.module.data.channel.kio.entity.ChannelKioTagEntity; |
| | | import com.iailab.module.data.channel.kio.service.ChannelKioTagService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年06月05日 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class ChannelKioTagServiceImpl extends BaseServiceImpl<ChannelKioTagDao, ChannelKioTagEntity> implements ChannelKioTagService { |
| | | @Resource |
| | | private ChannelKioTagDao channelKioTagDao; |
| | | |
| | | @Value("${iems.upload-dir}") |
| | | private String uploadDir; |
| | | |
| | | @Override |
| | | public PageData<ChannelKioTagDTO> page(Map<String, Object> params) { |
| | | IPage<ChannelKioTagEntity> page = baseDao.selectPage( |
| | | getPage(params, Constant.CREATE_TIME, false), |
| | | getWrapper(params) |
| | | ); |
| | | return getPageData(page, ChannelKioTagDTO.class); |
| | | } |
| | | |
| | | @Override |
| | | public ChannelKioTagDTO get(String id) { |
| | | ChannelKioTagEntity entity = baseDao.selectById(id); |
| | | return ConvertUtils.sourceToTarget(entity, ChannelKioTagDTO.class); |
| | | } |
| | | |
| | | @Override |
| | | public void save(ChannelKioTagDTO dto) { |
| | | ChannelKioTagEntity entity = ConvertUtils.sourceToTarget(dto, ChannelKioTagEntity.class); |
| | | entity.setCreateTime(new Date()); |
| | | entity.setUpdateTime(new Date()); |
| | | insert(entity); |
| | | } |
| | | |
| | | @Override |
| | | public void update(ChannelKioTagDTO dto) { |
| | | ChannelKioTagEntity entity = ConvertUtils.sourceToTarget(dto, ChannelKioTagEntity.class); |
| | | entity.setUpdateTime(new Date()); |
| | | updateById(entity); |
| | | } |
| | | |
| | | @Override |
| | | public void delete(String[] ids) { |
| | | baseDao.deleteBatchIds(Arrays.asList(ids)); |
| | | } |
| | | |
| | | @Override |
| | | public List<ChannelKioTagDTO> getByDevice(String device) { |
| | | QueryWrapper<ChannelKioTagEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.like(StringUtils.isNotBlank(device), "device", device) |
| | | .orderByAsc("tag_id"); |
| | | List<ChannelKioTagEntity> list = baseDao.selectList(wrapper); |
| | | return ConvertUtils.sourceToTarget(list, ChannelKioTagDTO.class); |
| | | } |
| | | |
| | | @Override |
| | | public ChannelKioTagDTO getByTagName(String tagName) { |
| | | QueryWrapper<ChannelKioTagEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("tag_name", tagName); |
| | | ChannelKioTagEntity entity = baseDao.selectOne(wrapper); |
| | | return ConvertUtils.sourceToTarget(entity, ChannelKioTagDTO.class); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteByDeviceName(String name) { |
| | | baseDao.delete(new QueryWrapper<ChannelKioTagEntity>().eq("device",name)); |
| | | } |
| | | |
| | | private QueryWrapper<ChannelKioTagEntity> getWrapper(Map<String, Object> params){ |
| | | String tagName = (String) params.get("tagName"); |
| | | String device = (String) params.get("device"); |
| | | QueryWrapper<ChannelKioTagEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq(StringUtils.isNotBlank(device), "device", device); |
| | | wrapper.like(StringUtils.isNotBlank(tagName), "tag_name", tagName); |
| | | wrapper.orderByDesc("create_time"); |
| | | return wrapper; |
| | | } |
| | | |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.modbus.collector; |
| | | |
| | | import com.iailab.module.data.common.enums.CommonConstant; |
| | | import com.iailab.module.data.common.enums.DataSourceType; |
| | | import com.iailab.framework.common.util.object.ConvertUtils; |
| | | import com.iailab.module.data.common.utils.TagUtils; |
| | | import com.iailab.module.data.channel.modbus.dto.ChannelModBusDeviceDTO; |
| | | import com.iailab.module.data.channel.modbus.entity.ChannelModBusDeviceEntity; |
| | | import com.iailab.module.data.channel.modbus.service.ChannelModbusDeviceService; |
| | | import com.serotonin.modbus4j.ModbusMaster; |
| | | import com.serotonin.modbus4j.code.DataType; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年05月12日 |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class ModBusCollector { |
| | | |
| | | @Resource |
| | | private ChannelModbusDeviceService channelModbusDeviceService; |
| | | |
| | | private Map<String, ModbusMaster> clientMap = new ConcurrentHashMap<>(); |
| | | |
| | | private Map<String, ChannelModBusDeviceEntity> deviceMap = new HashMap<>(); |
| | | |
| | | private synchronized ModbusMaster getMaster(String sourceId) throws Exception { |
| | | log.info("=========Modbus============"); |
| | | try { |
| | | if (!clientMap.containsKey(sourceId)) { |
| | | ChannelModBusDeviceEntity entity = channelModbusDeviceService.info(sourceId); |
| | | ChannelModBusDeviceDTO tModbusDTO = ConvertUtils.sourceToTarget(entity, ChannelModBusDeviceDTO.class); |
| | | ModbusMaster modbusMaster = ModbusUtils.getMaster(tModbusDTO); |
| | | if (modbusMaster != null) { |
| | | clientMap.put(sourceId, modbusMaster); |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error("=========Modbus Exception============"); |
| | | log.error("ex.message+" + ex.getMessage()); |
| | | throw new Exception(ex.getMessage()); |
| | | } |
| | | return clientMap.get(sourceId); |
| | | } |
| | | |
| | | public Double getTagValue(String sourceId, String tagNo) { |
| | | Double result = CommonConstant.BAD_VALUE.doubleValue(); |
| | | try { |
| | | ModbusMaster modbusMaster = this.getMaster(sourceId); |
| | | // 获取寄存器类型 |
| | | String type = tagNo.substring(0, 1); |
| | | int slaveId = 1; |
| | | int offset = Integer.parseInt(tagNo.substring(1)) - 1; |
| | | switch (type) { |
| | | case "0": |
| | | // 读线圈寄存器 |
| | | result = ModbusUtils.readCoilStatus(modbusMaster, slaveId, offset) ? 1d : 0; |
| | | break; |
| | | case "1": |
| | | // 读离散输入寄存器 |
| | | result = ModbusUtils.inputStatus(modbusMaster, slaveId, offset) ? 1d : 0; |
| | | break; |
| | | case "3": |
| | | // 读输入寄存器 |
| | | result = ModbusUtils.inputRegister(modbusMaster, slaveId, offset, DataType.TWO_BYTE_INT_SIGNED) |
| | | .doubleValue(); |
| | | break; |
| | | case "4": |
| | | // 读输入寄存器数据 |
| | | result = ModbusUtils.holdingRegister(modbusMaster, slaveId, offset, DataType.TWO_BYTE_INT_SIGNED) |
| | | .doubleValue(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | return result; |
| | | } catch (Exception ex) { |
| | | log.error("TagNo========" + tagNo); |
| | | ex.printStackTrace(); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | public void setTagValue(String sourceId, String tagNo, String newValue) { |
| | | try { |
| | | ModbusMaster modbusMaster = this.getMaster(sourceId); |
| | | // 获取寄存器类型 |
| | | String type = tagNo.substring(0, 1); |
| | | int slaveId = 1; |
| | | int offset = Integer.parseInt(tagNo.substring(1)) - 1; |
| | | switch (type) { |
| | | case "0": |
| | | // 写单个线圈寄存器 |
| | | ModbusUtils.writeCoilStatus(modbusMaster, slaveId, offset, Integer.parseInt(newValue) > 0 ); |
| | | break; |
| | | case "4": |
| | | // 写单个保持寄存器 |
| | | ModbusUtils.writeRegister(modbusMaster, slaveId, offset, Integer.parseInt(newValue)); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | public Map<String, Object> getTagValues(List<String[]> params) { |
| | | if (CollectionUtils.isEmpty(params)) { |
| | | return new HashMap<>(); |
| | | } |
| | | Map<String, Object> result = new HashMap<>(params.size()); |
| | | params.forEach(item -> { |
| | | try { |
| | | Double value = this.getTagValue(item[0], item[1]); |
| | | result.put(TagUtils.genTagId(DataSourceType.ModBus.getCode(), deviceMap.get(item[0]).getName(), item[1]), value); |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | result.put(TagUtils.genTagId(DataSourceType.ModBus.getCode(), deviceMap.get(item[0]).getName(), item[1]), CommonConstant.BAD_VALUE); |
| | | } |
| | | }); |
| | | return result; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.modbus.collector; |
| | | |
| | | import com.iailab.module.data.channel.modbus.dto.ChannelModBusDeviceDTO; |
| | | import com.serotonin.modbus4j.ModbusFactory; |
| | | import com.serotonin.modbus4j.ModbusMaster; |
| | | import com.serotonin.modbus4j.exception.ErrorResponseException; |
| | | import com.serotonin.modbus4j.exception.ModbusInitException; |
| | | import com.serotonin.modbus4j.exception.ModbusTransportException; |
| | | import com.serotonin.modbus4j.ip.IpParameters; |
| | | import com.serotonin.modbus4j.locator.BaseLocator; |
| | | import com.serotonin.modbus4j.msg.*; |
| | | |
| | | /** |
| | | * Modbus 工具类 |
| | | */ |
| | | public class ModbusUtils { |
| | | |
| | | /** |
| | | * 工厂 |
| | | */ |
| | | static ModbusFactory modbusFactory; |
| | | static ModbusMaster modbusMaster; |
| | | |
| | | static { |
| | | if (modbusFactory == null) { |
| | | modbusFactory = new ModbusFactory(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取master |
| | | * |
| | | * @param tModbusDTO |
| | | * @return |
| | | */ |
| | | public static ModbusMaster getMaster(ChannelModBusDeviceDTO tModbusDTO) throws ModbusInitException { |
| | | if (modbusMaster == null) { |
| | | IpParameters ipParameters = new IpParameters(); |
| | | ipParameters.setHost(tModbusDTO.getAddress()); |
| | | ipParameters.setPort(tModbusDTO.getPort()); |
| | | modbusMaster = modbusFactory.createTcpMaster(ipParameters, true); |
| | | //设置超时时间 |
| | | modbusMaster.setTimeout(tModbusDTO.getReadTimeout()); |
| | | //设置重连次数 |
| | | modbusMaster.setRetries(tModbusDTO.getAttemptsBeforeTimeout()); |
| | | modbusMaster.init(); |
| | | return modbusMaster; |
| | | } |
| | | return modbusMaster; |
| | | } |
| | | |
| | | /** |
| | | * 测试用 |
| | | * |
| | | * @return |
| | | */ |
| | | public static ModbusMaster getMaster() throws ModbusInitException { |
| | | if (modbusMaster == null) { |
| | | IpParameters ipParameters = new IpParameters(); |
| | | ipParameters.setHost("127.0.0.1"); |
| | | ipParameters.setPort(502); |
| | | modbusMaster = modbusFactory.createTcpMaster(ipParameters, true); |
| | | modbusMaster.init(); |
| | | return modbusMaster; |
| | | } |
| | | return modbusMaster; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 读取线圈开关状态数据 0x01 |
| | | * |
| | | * @param slaveId |
| | | * @param offset |
| | | * @return |
| | | * @throws ModbusInitException |
| | | * @throws ModbusTransportException |
| | | * @throws ErrorResponseException |
| | | */ |
| | | public static Boolean readCoilStatus(ModbusMaster modbusMaster, int slaveId, int offset) throws ModbusInitException, ModbusTransportException, ErrorResponseException { |
| | | BaseLocator<Boolean> coilStatus = BaseLocator.coilStatus(slaveId, offset); |
| | | Boolean res = modbusMaster.getValue(coilStatus); |
| | | return res; |
| | | } |
| | | |
| | | /** |
| | | * 读离散输入寄存器状态数据 0x02 |
| | | * |
| | | * @param slaveId |
| | | * @param offset |
| | | * @return |
| | | * @throws ModbusInitException |
| | | * @throws ModbusTransportException |
| | | * @throws ErrorResponseException |
| | | */ |
| | | public static Boolean inputStatus(ModbusMaster modbusMaster, int slaveId, int offset) throws ModbusInitException, ModbusTransportException, ErrorResponseException { |
| | | BaseLocator<Boolean> inputStatus = BaseLocator.inputStatus(slaveId, offset); |
| | | Boolean res = modbusMaster.getValue(inputStatus); |
| | | return res; |
| | | } |
| | | |
| | | /** |
| | | * 读保持寄存器数据 0x03 |
| | | * |
| | | * @param modbusMaster |
| | | * @param slaveId |
| | | * @param offset |
| | | * @param dataType |
| | | * @return |
| | | * @throws ModbusInitException |
| | | * @throws ModbusTransportException |
| | | * @throws ErrorResponseException |
| | | */ |
| | | public static Number holdingRegister(ModbusMaster modbusMaster, int slaveId, int offset, int dataType) throws ModbusInitException, ModbusTransportException, ErrorResponseException { |
| | | BaseLocator<Number> holdingRegister = BaseLocator.holdingRegister(slaveId, offset, dataType); |
| | | Number value = modbusMaster.getValue(holdingRegister); |
| | | return value; |
| | | } |
| | | |
| | | /** |
| | | * 测试用 |
| | | * |
| | | * @return |
| | | */ |
| | | public static Number holdingRegister(int slaveId, int offset, int dataType) throws ModbusInitException, ModbusTransportException, ErrorResponseException { |
| | | BaseLocator<Number> holdingRegister = BaseLocator.holdingRegister(slaveId, offset, dataType); |
| | | Number value = getMaster().getValue(holdingRegister); |
| | | return value; |
| | | } |
| | | |
| | | /** |
| | | * 读输入寄存器数据 0x04 |
| | | * |
| | | * @param slaveId |
| | | * @param offset |
| | | * @param dataType |
| | | * @return |
| | | * @throws ModbusInitException |
| | | * @throws ModbusTransportException |
| | | * @throws ErrorResponseException |
| | | */ |
| | | public static Number inputRegister(ModbusMaster modbusMaster, int slaveId, int offset, int dataType) throws ModbusInitException, ModbusTransportException, ErrorResponseException { |
| | | BaseLocator<Number> inputRegister = BaseLocator.inputRegister(slaveId, offset, dataType); |
| | | Number value = modbusMaster.getValue(inputRegister); |
| | | return value; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 写线圈开关状态数据 0x05 |
| | | * |
| | | * @param slaveId |
| | | * @param offset |
| | | * @param status |
| | | * @return |
| | | * @throws ModbusTransportException |
| | | * @throws ModbusInitException |
| | | */ |
| | | public static Boolean writeCoilStatus(ModbusMaster modbusMaster, int slaveId, int offset, boolean status) throws ModbusTransportException, ModbusInitException { |
| | | boolean coilValue = status; |
| | | WriteCoilRequest coilRequest = new WriteCoilRequest(slaveId, offset, coilValue); |
| | | WriteCoilResponse coilResponse = (WriteCoilResponse) modbusMaster.send(coilRequest); |
| | | return !coilResponse.isException(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 写单个保持寄存器数据 0x06 |
| | | * |
| | | * @param slaveId |
| | | * @param offset |
| | | * @param value |
| | | * @return |
| | | * @throws ModbusTransportException |
| | | * @throws ModbusInitException |
| | | */ |
| | | public static Boolean writeRegister(ModbusMaster modbusMaster, int slaveId, int offset, int value) throws ModbusTransportException, ModbusInitException { |
| | | WriteRegisterRequest registerRequest = new WriteRegisterRequest(slaveId, offset, value); |
| | | WriteRegisterResponse registerResponse = (WriteRegisterResponse) modbusMaster.send(registerRequest); |
| | | return !registerResponse.isException(); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 测试用 |
| | | * |
| | | * @return |
| | | */ |
| | | public static Boolean writeRegister(int slaveId, int offset, int value) throws ModbusTransportException, ModbusInitException { |
| | | WriteRegisterRequest registerRequest = new WriteRegisterRequest(slaveId, offset, value); |
| | | WriteRegisterResponse registerResponse = (WriteRegisterResponse) getMaster().send(registerRequest); |
| | | return !registerResponse.isException(); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 写线圈开关状态数据【多】 0x0f |
| | | * |
| | | * @param slaveId |
| | | * @param offset |
| | | * @param booleans |
| | | * @return |
| | | * @throws ModbusTransportException |
| | | * @throws ModbusInitException |
| | | */ |
| | | public static Boolean writeCoils(ModbusMaster modbusMaster, int slaveId, int offset, boolean[] booleans) throws ModbusTransportException, ModbusInitException { |
| | | WriteCoilsRequest writeCoils = new WriteCoilsRequest(slaveId, offset, booleans); |
| | | WriteCoilsResponse coilsResponse = (WriteCoilsResponse) modbusMaster.send(writeCoils); |
| | | return !coilsResponse.isException(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 写保存寄存器数据【多】 0x10 |
| | | * |
| | | * @param slaveId |
| | | * @param offset |
| | | * @param nums |
| | | * @return |
| | | * @throws ModbusTransportException |
| | | * @throws ModbusInitException |
| | | */ |
| | | public static Boolean writeRegisters(ModbusMaster modbusMaster, int slaveId, int offset, short[] nums) throws ModbusTransportException, ModbusInitException { |
| | | WriteRegistersRequest writeRegisters = new WriteRegistersRequest(slaveId, offset, nums); |
| | | WriteRegistersResponse registersResponse = (WriteRegistersResponse) modbusMaster.send(writeRegisters); |
| | | return !registersResponse.isException(); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.modbus.controller.admin; |
| | | |
| | | import com.iailab.module.data.common.utils.PageUtils; |
| | | import com.iailab.module.data.common.utils.R; |
| | | import com.iailab.module.data.channel.modbus.entity.ChannelModBusDeviceEntity; |
| | | import com.iailab.module.data.channel.modbus.service.ChannelModbusDeviceService; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.Map; |
| | | import java.util.UUID; |
| | | |
| | | /** |
| | | * 操作modbus配置 |
| | | * |
| | | * @author DongYukun |
| | | * @createTime 2023年04月24日 14:10:00 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/data/channel/modbus/device") |
| | | public class ChannelModbusDeviceController { |
| | | @Resource |
| | | private ChannelModbusDeviceService channelModbusDeviceService; |
| | | |
| | | /** |
| | | * 分页查询设备 |
| | | * |
| | | * @param params |
| | | */ |
| | | @GetMapping("/list") |
| | | public R list(@RequestParam Map<String, Object> params){ |
| | | PageUtils page = channelModbusDeviceService.queryPage(params); |
| | | |
| | | return R.ok().put("page", page); |
| | | } |
| | | /** |
| | | * 根据id查询设备详情 |
| | | * |
| | | * @param id |
| | | */ |
| | | @GetMapping("/info/{id}") |
| | | public R info(@PathVariable("id") String id){ |
| | | ChannelModBusDeviceEntity info= channelModbusDeviceService.info(id); |
| | | return R.ok().put("data", info); |
| | | } |
| | | /** |
| | | * 添加设备 |
| | | * |
| | | * @param channelModBusDeviceEntity |
| | | */ |
| | | @PostMapping("/add") |
| | | public R add(@RequestBody ChannelModBusDeviceEntity channelModBusDeviceEntity){ |
| | | String id = UUID.randomUUID().toString(); |
| | | channelModBusDeviceEntity.setId(id); |
| | | channelModbusDeviceService.add(channelModBusDeviceEntity); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 修改设备 |
| | | * |
| | | * @param channelModBusDeviceEntity |
| | | */ |
| | | @PostMapping("/update") |
| | | public R update(@RequestBody ChannelModBusDeviceEntity channelModBusDeviceEntity) { |
| | | channelModbusDeviceService.update(channelModBusDeviceEntity); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 删除设备 |
| | | * |
| | | * @param params |
| | | * |
| | | */ |
| | | @PostMapping("/delete") |
| | | public R delete(@RequestBody Map<String, Object> params) { |
| | | String id = (String)params.get("id"); |
| | | channelModbusDeviceService.delete(id); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.modbus.controller.admin; |
| | | |
| | | import com.iailab.module.data.common.utils.PageUtils; |
| | | import com.iailab.module.data.common.utils.R; |
| | | import com.iailab.module.data.channel.modbus.entity.ChannelModBusTagEntity; |
| | | import com.iailab.module.data.channel.modbus.service.ChannelModbusTagService; |
| | | import com.sun.xml.internal.messaging.saaj.util.Base64; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.Map; |
| | | import java.util.UUID; |
| | | |
| | | /** |
| | | * 操作modbus tag配置 |
| | | * |
| | | * @author DongYukun |
| | | * @createTime 2023年04月25日 10:31:00 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/data/channel/modbus/tag") |
| | | public class ChannelModbusTagController { |
| | | @Resource |
| | | private ChannelModbusTagService channelModbusTagService; |
| | | /** |
| | | * 分页查询tag |
| | | * |
| | | * @param params |
| | | */ |
| | | @GetMapping("/list") |
| | | public R tagList(@RequestParam Map<String, Object> params){ |
| | | PageUtils page = channelModbusTagService.queryPage(params); |
| | | |
| | | return R.ok().put("page", page); |
| | | } |
| | | /** |
| | | * 根据id查询tag详情 |
| | | * |
| | | * @param id |
| | | */ |
| | | @GetMapping("/info/{id}") |
| | | public R tagInfo(@PathVariable("id") String id){ |
| | | ChannelModBusTagEntity info= channelModbusTagService.info(Base64.base64Decode(id)); |
| | | return R.ok().put("data", info); |
| | | } |
| | | /** |
| | | * 添加tag |
| | | * |
| | | * @param entity |
| | | */ |
| | | @PostMapping("/add") |
| | | public R tagAdd(@RequestBody ChannelModBusTagEntity entity){ |
| | | entity.setId(UUID.randomUUID().toString()); |
| | | channelModbusTagService.add(entity); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 修改tag |
| | | * |
| | | * @param channelModBusTagEntity |
| | | */ |
| | | @PostMapping("/update") |
| | | public R tagUpdate(@RequestBody ChannelModBusTagEntity channelModBusTagEntity) { |
| | | channelModbusTagService.update(channelModBusTagEntity); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 删除tag |
| | | * @param params |
| | | * |
| | | */ |
| | | @PostMapping("/delete") |
| | | public R tagDelete(@RequestBody Map<String, Object> params) { |
| | | String id = (String)params.get("id"); |
| | | channelModbusTagService.delete(id); |
| | | return R.ok(); |
| | | } |
| | | |
| | | // /** |
| | | // * 导入 |
| | | // * |
| | | // * @param device |
| | | // * @param file |
| | | // * @return |
| | | // */ |
| | | // @PostMapping("/import/{device}") |
| | | // public R importTag(@PathVariable("device") String device, @RequestParam("file") MultipartFile file) { |
| | | // try { |
| | | // if (file.isEmpty()) { |
| | | // throw new RRException("上传文件不能为空"); |
| | | // } |
| | | // channelModbusTagService.importTag(device, file); |
| | | // } catch (Exception ex) { |
| | | // return R.error(ex.getMessage()); |
| | | // } |
| | | // return R.ok(); |
| | | // } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.modbus.controller; |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.modbus.dao; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.iailab.module.data.channel.modbus.entity.ChannelModBusDeviceEntity; |
| | | import com.iailab.module.data.channel.modbus.entity.ChannelModBusDeviceEntity; |
| | | import com.iailab.module.data.channel.modbus.entity.ChannelModBusDeviceEntity; |
| | | import com.iailab.module.data.channel.modbus.entity.ChannelModBusDeviceEntity; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2023年04月24日 11:33:00 |
| | | */ |
| | | @Mapper |
| | | public interface ChannelModBusDeviceDao extends BaseMapper<ChannelModBusDeviceEntity> { |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.modbus.dao; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.iailab.module.data.channel.modbus.entity.ChannelModBusTagEntity; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author DongYukun |
| | | * @Description |
| | | * @createTime 2023年04月25日 15:12:00 |
| | | */ |
| | | @Mapper |
| | | public interface ChannelModBusTagDao extends BaseMapper<ChannelModBusTagEntity> { |
| | | |
| | | void insertList(List<ChannelModBusTagEntity> list); |
| | | |
| | | String selectIdByName(@Param("name") String name); |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.modbus.dto; |
| | | |
| | | import com.alibaba.fastjson.annotation.JSONField; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2023年04月23日 14:24:00 |
| | | */ |
| | | @Data |
| | | public class ChannelModBusDeviceDTO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 用于标识该设备的名字 |
| | | */ |
| | | @JSONField(name="Name")//该注解防止属性名转化成json时变成小写 |
| | | private String Name; |
| | | |
| | | /** |
| | | * 要访问设备的 IP 地址 |
| | | */ |
| | | @JSONField(name="Address") |
| | | private String Address; |
| | | |
| | | /** |
| | | * 设备端口号 |
| | | */ |
| | | @JSONField(name="Port") |
| | | private Integer Port; |
| | | |
| | | /** |
| | | * 设备不活动超时时间 |
| | | */ |
| | | @JSONField(name="ConnectInactivityTimeout") |
| | | private Integer ConnectInactivityTimeout; |
| | | |
| | | /** |
| | | * 设备不在线或者连接异常时,系统进行重试连接的超时时间。默认值5000(5s) |
| | | */ |
| | | @JSONField(name="ReconnectInterval") |
| | | private Integer ReconnectInterval; |
| | | |
| | | /** |
| | | * 请求超时之前的重试次数,默认值为3 |
| | | */ |
| | | @JSONField(name="AttemptsBeforeTimeout") |
| | | private Integer AttemptsBeforeTimeout; |
| | | |
| | | /** |
| | | * 请求超时之前重试时间间隔,默认值250 (250ms) |
| | | */ |
| | | @JSONField(name="WaitToRetryMilliseconds") |
| | | private Integer WaitToRetryMilliseconds; |
| | | |
| | | /** |
| | | * 读请求超时时间,默认3000(3s) |
| | | */ |
| | | @JSONField(name="ReadTimeout") |
| | | private Integer ReadTimeout; |
| | | |
| | | /** |
| | | * 写请求超时时间,默认3000(3s) |
| | | */ |
| | | @JSONField(name="WriteTimeout") |
| | | private Integer WriteTimeout; |
| | | |
| | | /** |
| | | * 是否使用优化方式读取数据,默认true。使能后,多个读请求可能放在一个数据包中对设备进行一次请求 |
| | | */ |
| | | @JSONField(name="UseOptimizedBlockRead") |
| | | private Boolean UseOptimizedBlockRead; |
| | | |
| | | /** |
| | | * 系统内部用,默认空字符串 |
| | | */ |
| | | @JSONField(name="ProjectReference") |
| | | private String ProjectReference; |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.modbus.dto; |
| | | |
| | | import com.alibaba.fastjson.annotation.JSONField; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2023年04月23日 14:24:00 |
| | | */ |
| | | @Data |
| | | public class ChannelModbusTagDTO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * TagName |
| | | */ |
| | | @JSONField(name="TagName") |
| | | private String TagName; |
| | | |
| | | /** |
| | | * tag的数据类型 |
| | | */ |
| | | @JSONField(name="DataType") |
| | | private String DataType; |
| | | |
| | | /** |
| | | * 是否是能tag,如果为false,即使定义了但是runtime不会读取该数据 |
| | | */ |
| | | @JSONField(name="Enabled") |
| | | private Boolean Enabled; |
| | | |
| | | /** |
| | | * 定义大小端 |
| | | */ |
| | | @JSONField(name="Format") |
| | | private String Format; |
| | | |
| | | /** |
| | | * 关联的设备名字 |
| | | */ |
| | | @JSONField(name="Device") |
| | | private String Device; |
| | | |
| | | /** |
| | | * Modbus地址 00001 ~49999 |
| | | */ |
| | | @JSONField(name="Address") |
| | | private String Address; |
| | | |
| | | /** |
| | | * 系统采集频率,只对订阅模式有效 |
| | | */ |
| | | @JSONField(name="SamplingRate") |
| | | private Integer SamplingRate; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.modbus.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * ModBus设备表 |
| | | * |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2023年04月24日 10:31:00 |
| | | */ |
| | | @Data |
| | | @TableName("t_channel_modbus_device") |
| | | public class ChannelModBusDeviceEntity implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @Schema(description = "主键") |
| | | @TableId(value = "id",type = IdType.INPUT) |
| | | private String id; |
| | | |
| | | /** |
| | | * 设备名称 |
| | | */ |
| | | private String name; |
| | | |
| | | /** |
| | | * IP地址 |
| | | */ |
| | | private String address; |
| | | |
| | | /** |
| | | * 端口 |
| | | */ |
| | | private Integer port; |
| | | |
| | | /** |
| | | * 不活动超时(ms) |
| | | */ |
| | | private Integer connectInactivityTimeout; |
| | | |
| | | /** |
| | | * 重连超时(ms) |
| | | */ |
| | | private Integer reconnectInterval; |
| | | |
| | | /** |
| | | * 重试次数 |
| | | */ |
| | | private Integer attemptsBeforeTimeout; |
| | | |
| | | /** |
| | | * 重试间隔(ms) |
| | | */ |
| | | private Integer waitToRetryMilliseconds; |
| | | |
| | | /** |
| | | * 读超时(ms) |
| | | */ |
| | | private Integer readTimeout; |
| | | |
| | | /** |
| | | * 写超时(ms) |
| | | */ |
| | | private Integer writeTimeout; |
| | | |
| | | /** |
| | | * 是否使用优化 |
| | | */ |
| | | private Boolean useOptimizedBlockRead; |
| | | |
| | | /** |
| | | * 系统内部用,默认空字符串 |
| | | */ |
| | | private String projectReference; |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.modbus.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * mofbus点表 |
| | | * @author DongYuKun |
| | | * @Description |
| | | * @createTime 2023年04月25日 14:47:00 |
| | | */ |
| | | @Data |
| | | @TableName("t_channel_modbus_tag") |
| | | public class ChannelModBusTagEntity implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @Schema(description = "主键") |
| | | @TableId(value = "id",type = IdType.INPUT) |
| | | private String id; |
| | | /** |
| | | * TagName |
| | | */ |
| | | private String tagName; |
| | | |
| | | /** |
| | | * 数据类型 |
| | | */ |
| | | private String dataType; |
| | | |
| | | /** |
| | | * 是否可以tag,如果为false,即使定义了但是runtime不会读取该数据 |
| | | */ |
| | | private Boolean enabled; |
| | | |
| | | /** |
| | | * 大小端 |
| | | */ |
| | | private String format; |
| | | |
| | | /** |
| | | * 关联设备 |
| | | */ |
| | | private String device; |
| | | |
| | | /** |
| | | * Modbus地址 00001 ~49999 |
| | | */ |
| | | private String address; |
| | | |
| | | /** |
| | | * 采集频率 |
| | | */ |
| | | private Integer samplingRate; |
| | | |
| | | /** |
| | | * 描述 |
| | | */ |
| | | private String tagDesc; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * 修改时间 |
| | | */ |
| | | private Date updateTime; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.modbus.service; |
| | | |
| | | import com.iailab.module.data.common.utils.PageUtils; |
| | | import com.iailab.module.data.channel.modbus.dto.ChannelModBusDeviceDTO; |
| | | import com.iailab.module.data.channel.modbus.entity.ChannelModBusDeviceEntity; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2023年04月23日 17:42:00 |
| | | */ |
| | | public interface ChannelModbusDeviceService { |
| | | /** |
| | | * 分页查询设备 |
| | | * |
| | | * @param params |
| | | */ |
| | | PageUtils queryPage(Map<String, Object> params); |
| | | /** |
| | | * 添加设备 |
| | | * |
| | | * @param channelModBusDeviceEntity |
| | | */ |
| | | void add(ChannelModBusDeviceEntity channelModBusDeviceEntity); |
| | | /** |
| | | * 修改设备 |
| | | * |
| | | * @param channelModBusDeviceEntity |
| | | */ |
| | | void update(ChannelModBusDeviceEntity channelModBusDeviceEntity); |
| | | /** |
| | | * 删除设备 |
| | | * @param id |
| | | * |
| | | */ |
| | | void delete(String id); |
| | | /** |
| | | * 查询设备详情 |
| | | * @param id |
| | | * |
| | | */ |
| | | ChannelModBusDeviceEntity info(String id); |
| | | |
| | | /** |
| | | * 查询设备详情 |
| | | * |
| | | */ |
| | | List<ChannelModBusDeviceDTO> selectAll(); |
| | | |
| | | /** |
| | | * 列表 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | | List<ChannelModBusDeviceEntity> list(Map<String, Object> params); |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.modbus.service; |
| | | |
| | | import com.iailab.module.data.common.utils.PageUtils; |
| | | import com.iailab.module.data.channel.modbus.dto.ChannelModbusTagDTO; |
| | | import com.iailab.module.data.channel.modbus.entity.ChannelModBusTagEntity; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author DongYukun |
| | | * @Description |
| | | * @createTime 2023年05月08日 15:04:00 |
| | | */ |
| | | public interface ChannelModbusTagService { |
| | | /** |
| | | * 分页查询tag |
| | | * |
| | | * @param params |
| | | */ |
| | | PageUtils queryPage(Map<String, Object> params); |
| | | |
| | | /** |
| | | * 查询tag详情 |
| | | * @param id |
| | | * |
| | | */ |
| | | ChannelModBusTagEntity info(String id); |
| | | |
| | | /** |
| | | * 添加tag |
| | | * |
| | | * @param channelModBusTagEntity |
| | | */ |
| | | void add(ChannelModBusTagEntity channelModBusTagEntity); |
| | | |
| | | /** |
| | | * 修改tag |
| | | * |
| | | * @param channelModBusTagEntity |
| | | */ |
| | | void update(ChannelModBusTagEntity channelModBusTagEntity); |
| | | |
| | | /** |
| | | * 删除tag |
| | | * @param id |
| | | * |
| | | */ |
| | | void delete(String id); |
| | | |
| | | /** |
| | | * 查询全部 |
| | | * |
| | | */ |
| | | List<ChannelModbusTagDTO> selectAll(); |
| | | |
| | | List<ChannelModBusTagEntity> getByDevice(String device); |
| | | |
| | | /** |
| | | * listByIds |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | List<ChannelModBusTagEntity> listByIds(List<String> ids); |
| | | |
| | | /** |
| | | * 通过deviceName删除 |
| | | * |
| | | */ |
| | | void deleteByDeviceName(String name); |
| | | |
| | | // /** |
| | | // * 导入Tag |
| | | // * |
| | | // * @param device |
| | | // * @param file |
| | | // * @throws Exception |
| | | // */ |
| | | // void importTag(String device, MultipartFile file) throws Exception; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.modbus.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.iailab.framework.common.util.object.ConvertUtils; |
| | | import com.iailab.module.data.common.utils.PageUtils; |
| | | import com.iailab.module.data.common.utils.Query; |
| | | import com.iailab.module.data.channel.modbus.dao.ChannelModBusDeviceDao; |
| | | import com.iailab.module.data.channel.modbus.dto.ChannelModBusDeviceDTO; |
| | | import com.iailab.module.data.channel.modbus.entity.ChannelModBusDeviceEntity; |
| | | import com.iailab.module.data.channel.modbus.service.ChannelModbusDeviceService; |
| | | import com.iailab.module.data.channel.modbus.service.ChannelModbusTagService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2023年04月23日 17:45:00 |
| | | */ |
| | | @Service |
| | | public class ChannelModbusDeviceServiceImpl extends ServiceImpl<ChannelModBusDeviceDao, ChannelModBusDeviceEntity> implements ChannelModbusDeviceService { |
| | | @Resource |
| | | private ChannelModBusDeviceDao channelModBusDeviceDao; |
| | | @Resource |
| | | private ChannelModbusTagService channelModbusTagService; |
| | | |
| | | /** |
| | | * 分页查询设备 |
| | | * |
| | | * @param params |
| | | */ |
| | | @Override |
| | | public PageUtils queryPage(Map<String, Object> params) { |
| | | |
| | | String name = (String) params.get("name"); |
| | | |
| | | IPage<ChannelModBusDeviceEntity> page = this.page( |
| | | new Query<ChannelModBusDeviceEntity>().getPage(params), |
| | | new QueryWrapper<ChannelModBusDeviceEntity>() |
| | | .like(StringUtils.isNotBlank(name), "name", name) |
| | | .orderByDesc("create_time") |
| | | ); |
| | | return new PageUtils(page); |
| | | } |
| | | |
| | | /** |
| | | * 列表 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<ChannelModBusDeviceEntity> list(Map<String, Object> params) { |
| | | return channelModBusDeviceDao.selectList(new QueryWrapper<ChannelModBusDeviceEntity>().orderByAsc("name")); |
| | | } |
| | | |
| | | /** |
| | | * 添加设备 |
| | | * |
| | | * @param channelModBusDeviceEntity |
| | | */ |
| | | @Override |
| | | public void add(ChannelModBusDeviceEntity channelModBusDeviceEntity) { |
| | | |
| | | channelModBusDeviceDao.insert(channelModBusDeviceEntity); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 修改设备 |
| | | * |
| | | * @param channelModBusDeviceEntity |
| | | */ |
| | | @Override |
| | | public void update(ChannelModBusDeviceEntity channelModBusDeviceEntity) { |
| | | |
| | | channelModBusDeviceDao.updateById(channelModBusDeviceEntity); |
| | | } |
| | | |
| | | /** |
| | | * 删除设备 |
| | | * |
| | | * @param id |
| | | */ |
| | | @Override |
| | | public void delete(String id) { |
| | | //先删除device下的tag |
| | | channelModbusTagService.deleteByDeviceName(info(id).getName()); |
| | | |
| | | channelModBusDeviceDao.deleteById(id); |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 查询设备详情 |
| | | * |
| | | * @param id |
| | | */ |
| | | @Override |
| | | public ChannelModBusDeviceEntity info(String id) { |
| | | |
| | | return channelModBusDeviceDao.selectById(id); |
| | | } |
| | | |
| | | @Override |
| | | public List<ChannelModBusDeviceDTO> selectAll() { |
| | | |
| | | List<ChannelModBusDeviceEntity> entityList = baseMapper.selectList( |
| | | null); |
| | | |
| | | return ConvertUtils.sourceToTarget(entityList, ChannelModBusDeviceDTO.class); |
| | | |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.modbus.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.iailab.module.data.common.utils.PageUtils; |
| | | import com.iailab.module.data.common.utils.Query; |
| | | import com.iailab.framework.common.util.object.ConvertUtils; |
| | | import com.iailab.module.data.channel.modbus.dto.ChannelModbusTagDTO; |
| | | import com.iailab.module.data.channel.modbus.dao.ChannelModBusTagDao; |
| | | import com.iailab.module.data.channel.modbus.entity.ChannelModBusTagEntity; |
| | | import com.iailab.module.data.channel.modbus.service.ChannelModbusTagService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author DongYukun |
| | | * @Description |
| | | * @createTime 2023年05月08日 15:04:00 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class ChannelModbusTagServiceImpl extends ServiceImpl<ChannelModBusTagDao, ChannelModBusTagEntity> implements ChannelModbusTagService { |
| | | @Resource |
| | | private ChannelModBusTagDao channelModBusTagDao; |
| | | |
| | | @Value("${iems.upload-dir}") |
| | | private String uploadDir; |
| | | |
| | | /** |
| | | * 分页查询tag |
| | | * |
| | | * @param params |
| | | */ |
| | | @Override |
| | | public PageUtils queryPage(Map<String, Object> params) { |
| | | String tagName = (String) params.get("tagName"); |
| | | String address = (String) params.get("address"); |
| | | String tagDesc = (String) params.get("tagDesc"); |
| | | String device = (String) params.get("device"); |
| | | |
| | | IPage<ChannelModBusTagEntity> page = this.page( |
| | | new Query<ChannelModBusTagEntity>().getPage(params), |
| | | new QueryWrapper<ChannelModBusTagEntity>() |
| | | .like(StringUtils.isNotBlank(tagName), "tag_name", tagName) |
| | | .like(StringUtils.isNotBlank(address), "address", address) |
| | | .like(StringUtils.isNotBlank(tagDesc), "tag_desc", tagDesc) |
| | | .eq(StringUtils.isNotBlank(device), "device", device) |
| | | .orderByDesc("create_time") |
| | | ); |
| | | return new PageUtils(page); |
| | | } |
| | | |
| | | /** |
| | | * 查询tag详情 |
| | | * |
| | | * @param id |
| | | */ |
| | | @Override |
| | | public ChannelModBusTagEntity info(String id) { |
| | | return channelModBusTagDao.selectById(id); |
| | | } |
| | | |
| | | /** |
| | | * 添加tag |
| | | * |
| | | * @param channelModBusTagEntity |
| | | */ |
| | | @Override |
| | | public void add(ChannelModBusTagEntity channelModBusTagEntity) { |
| | | channelModBusTagDao.insert(channelModBusTagEntity); |
| | | } |
| | | |
| | | /** |
| | | * 修改tag |
| | | * |
| | | * @param channelModBusTagEntity |
| | | */ |
| | | @Override |
| | | public void update(ChannelModBusTagEntity channelModBusTagEntity) { |
| | | channelModBusTagDao.updateById(channelModBusTagEntity); |
| | | } |
| | | |
| | | /** |
| | | * 删除tag |
| | | * |
| | | * @param id |
| | | */ |
| | | @Override |
| | | public void delete(String id) { |
| | | channelModBusTagDao.deleteById(id); |
| | | } |
| | | |
| | | @Override |
| | | public List<ChannelModBusTagEntity> getByDevice(String device) { |
| | | QueryWrapper<ChannelModBusTagEntity> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("device", device); |
| | | queryWrapper.orderByDesc("create_time"); |
| | | return channelModBusTagDao.selectList(queryWrapper); |
| | | } |
| | | |
| | | /** |
| | | * 查询全部 |
| | | * |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<ChannelModbusTagDTO> selectAll() { |
| | | List<ChannelModBusTagEntity> entityList = baseMapper.selectList( |
| | | null |
| | | ); |
| | | return ConvertUtils.sourceToTarget(entityList, ChannelModbusTagDTO.class); |
| | | } |
| | | |
| | | /** |
| | | * listByIds |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<ChannelModBusTagEntity> listByIds(List<String> ids) { |
| | | return baseMapper.selectList(new QueryWrapper<ChannelModBusTagEntity>().in("id", ids)); |
| | | } |
| | | |
| | | /** |
| | | * deleteByDeviceName |
| | | * |
| | | * @param name |
| | | */ |
| | | @Override |
| | | public void deleteByDeviceName(String name) { |
| | | baseMapper.delete(new QueryWrapper<ChannelModBusTagEntity>().eq("device", name)); |
| | | } |
| | | |
| | | //TODO 使用easyExcel重写 |
| | | // /** |
| | | // * 导入Tag |
| | | // * |
| | | // * @param device |
| | | // * @param file |
| | | // * @throws Exception |
| | | // */ |
| | | // @Override |
| | | // @Transactional(rollbackFor = Exception.class) |
| | | // public void importTag(String device, MultipartFile file) throws Exception { |
| | | // try { |
| | | // String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")); |
| | | // String fileName = UUID.randomUUID().toString() + suffix; |
| | | // String path = uploadDir + fileName; |
| | | // file.transferTo(new File(path)); |
| | | // |
| | | // XSSFWorkbook hssfWorkbook = new XSSFWorkbook(new FileInputStream(path)); |
| | | // XSSFSheet sheet = hssfWorkbook.getSheetAt(0); |
| | | // int lastRowNum = sheet.getLastRowNum(); |
| | | // log.info("最后一行:" + lastRowNum); |
| | | // int lastCellNum = 6; |
| | | // List<ChannelModBusTagEntity> dangerList = new ArrayList<>(); |
| | | // for (int i = 1; i <= lastRowNum; i++) { |
| | | // XSSFRow row = sheet.getRow(i); |
| | | // for (int j = row.getFirstCellNum(); j < lastCellNum; j++) { |
| | | // row.getCell(j).setCellType(CellType.STRING); |
| | | // } |
| | | // ChannelModBusTagEntity tagEntity = new ChannelModBusTagEntity(); |
| | | // tagEntity.setId(UUID.randomUUID().toString()); |
| | | // tagEntity.setTagName(row.getCell(1).getStringCellValue()); |
| | | // tagEntity.setDataType(row.getCell(2).getStringCellValue()); |
| | | // tagEntity.setEnabled(true); |
| | | // tagEntity.setFormat(""); |
| | | // tagEntity.setDevice(device); |
| | | // tagEntity.setSamplingRate(0); |
| | | // row.getCell(4).setCellType(CellType.STRING); |
| | | // System.out.println(row.getCell(3).getStringCellValue()); |
| | | // if(row.getCell(3).getStringCellValue().equals("1")){ |
| | | // tagEntity.setAddress(String.format("1%04d",Integer.parseInt(row.getCell(4).getStringCellValue()))); |
| | | // }else if(row.getCell(3).getStringCellValue().equals("3")){ |
| | | // tagEntity.setAddress(String.format("4%04d",Integer.parseInt(row.getCell(4).getStringCellValue()))); |
| | | // } |
| | | // tagEntity.setTagDesc(row.getCell(5).getStringCellValue()); |
| | | // dangerList.add(tagEntity); |
| | | // } |
| | | // if (CollectionUtils.isEmpty(dangerList)) { |
| | | // return; |
| | | // } |
| | | // //getBaseMapper().insertList(dangerList); |
| | | // dangerList.forEach(item -> { |
| | | // try { |
| | | // getBaseMapper().insert(item); |
| | | // } catch (Exception ex) { |
| | | // log.warn("插入异常:" + item.getTagName()); |
| | | // } |
| | | // }); |
| | | // } catch (Exception ex) { |
| | | // ex.printStackTrace(); |
| | | // log.warn("导入失败!"); |
| | | // throw ex; |
| | | // } |
| | | // } |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.opcua.collector; |
| | | |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | | import java.io.InputStream; |
| | | import java.nio.file.Files; |
| | | import java.nio.file.Path; |
| | | import java.security.*; |
| | | import java.security.cert.X509Certificate; |
| | | import java.util.regex.Pattern; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年07月22日 14:44:00 |
| | | */ |
| | | public class KeyStoreLoader { |
| | | |
| | | private static final Pattern IP_ADDR_PATTERN = Pattern.compile( |
| | | "^(([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.){3}([01]?\\d\\d?|2[0-4]\\d|25[0-5])$"); |
| | | |
| | | private static final String CLIENT_ALIAS = "mykey"; |
| | | private static final char[] PASSWORD = "keystore".toCharArray(); |
| | | |
| | | private final Logger logger = LoggerFactory.getLogger(getClass()); |
| | | |
| | | private X509Certificate clientCertificate; |
| | | private KeyPair clientKeyPair; |
| | | |
| | | KeyStoreLoader load(Path baseDir) throws Exception { |
| | | KeyStore keyStore = KeyStore.getInstance("PKCS12"); |
| | | |
| | | Path serverKeyStore = baseDir.resolve("mykey.pfx"); |
| | | |
| | | logger.info("Loading KeyStore at {}", serverKeyStore); |
| | | |
| | | if (Files.exists(serverKeyStore)) { |
| | | try (InputStream in = Files.newInputStream(serverKeyStore)) { |
| | | keyStore.load(in, PASSWORD); |
| | | } |
| | | } |
| | | |
| | | Key serverPrivateKey = keyStore.getKey(CLIENT_ALIAS, PASSWORD); |
| | | if (serverPrivateKey instanceof PrivateKey) { |
| | | clientCertificate = (X509Certificate) keyStore.getCertificate(CLIENT_ALIAS); |
| | | PublicKey serverPublicKey = clientCertificate.getPublicKey(); |
| | | clientKeyPair = new KeyPair(serverPublicKey, (PrivateKey) serverPrivateKey); |
| | | } |
| | | return this; |
| | | } |
| | | X509Certificate getClientCertificate() { |
| | | return clientCertificate; |
| | | } |
| | | KeyPair getClientKeyPair() { |
| | | return clientKeyPair; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.opcua.collector; |
| | | |
| | | import com.iailab.module.data.common.enums.CommonConstant; |
| | | import com.iailab.module.data.common.enums.DataSourceType; |
| | | import com.iailab.framework.common.util.object.ConvertUtils; |
| | | import com.iailab.module.data.common.utils.TagUtils; |
| | | import com.iailab.module.data.channel.opcua.entity.ChannelOPCUADeviceEntity; |
| | | import com.iailab.module.data.channel.opcua.service.ChannelOPCUADeviceService; |
| | | import com.iailab.module.data.channel.opcua.dto.ChannelOPCUADeviceDTO; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.eclipse.milo.opcua.sdk.client.OpcUaClient; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年05月12日 |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class OpcUaCollector { |
| | | |
| | | @Resource |
| | | private OpcUaUtils opcUaUtils; |
| | | |
| | | @Resource |
| | | private ChannelOPCUADeviceService channelOPCUADeviceService; |
| | | |
| | | private Map<String, OpcUaClient> clientMap = new ConcurrentHashMap<>(); |
| | | |
| | | private Map<String, ChannelOPCUADeviceEntity> deviceMap = new HashMap<>(); |
| | | |
| | | |
| | | private OpcUaClient getClient(String sourceId) throws Exception { |
| | | try { |
| | | if (!clientMap.containsKey(sourceId)) { |
| | | log.info("根据数据源获取Client,sourceId=" + sourceId); |
| | | ChannelOPCUADeviceEntity opcuaDevice = channelOPCUADeviceService.info(sourceId); |
| | | deviceMap.put(sourceId, opcuaDevice); |
| | | ChannelOPCUADeviceDTO configDto = ConvertUtils.sourceToTarget(opcuaDevice, ChannelOPCUADeviceDTO.class); |
| | | OpcUaClient opcUaClient = opcUaUtils.createClient(configDto); |
| | | if (opcUaClient != null) { |
| | | clientMap.put(sourceId, opcUaClient); |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | log.info("=========getClient Exception============"); |
| | | log.info("ex.message+" + ex.getMessage()); |
| | | ex.printStackTrace(); |
| | | throw new Exception(ex.getMessage()); |
| | | } |
| | | OpcUaClient opcUaClient = clientMap.get(sourceId); |
| | | if (!opcUaClient.connect().isDone()) { |
| | | opcUaClient.connect().get(); |
| | | } |
| | | return opcUaClient; |
| | | } |
| | | |
| | | public String getTagValue(String sourceId, String tagNo) throws Exception { |
| | | OpcUaClient opcUaClient = this.getClient(sourceId); |
| | | String value = OpcUaUtils.readNode(opcUaClient, tagNo); |
| | | return value; |
| | | } |
| | | |
| | | public void setTagData(String sourceId, String tagNo, String newValue, String dataType) { |
| | | try { |
| | | OpcUaClient opcUaClient = this.getClient(sourceId); |
| | | switch (dataType) { |
| | | case "float": |
| | | log.debug("Float,TagNo=" + tagNo + ",Value=" + Float.parseFloat(newValue)); |
| | | OpcUaUtils.writeFloatValue(opcUaClient, tagNo, Float.parseFloat(newValue)); |
| | | break; |
| | | case "int": |
| | | log.debug("Int,TagNo=" + tagNo + ",Value=" + new BigDecimal(newValue).intValue()); |
| | | OpcUaUtils.writeIntValue(opcUaClient, tagNo, new BigDecimal(newValue).intValue()); |
| | | break; |
| | | case "boolean": |
| | | log.debug("Boolean,TagNo=" + tagNo + ",Value=" + newValue); |
| | | OpcUaUtils.writeBooleanValue(opcUaClient, tagNo, Boolean.parseBoolean(newValue)); |
| | | break; |
| | | default: |
| | | log.warn("##################### No DataType ####################"); |
| | | break; |
| | | } |
| | | |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | public Map<String, Object> getTagValues(List<String[]> params) { |
| | | if (CollectionUtils.isEmpty(params)) { |
| | | return new HashMap<>(); |
| | | } |
| | | Map<String, Object> result = new HashMap<>(params.size()); |
| | | params.forEach(item -> { |
| | | |
| | | try { |
| | | OpcUaClient opcUaClient = this.getClient(item[0]); |
| | | String value = OpcUaUtils.readNode(opcUaClient, item[1]); |
| | | result.put(TagUtils.genTagId(DataSourceType.OPCUA.getCode(), deviceMap.get(item[0]).getServerName(), item[1]), value); |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | result.put(TagUtils.genTagId(DataSourceType.OPCUA.getCode(), deviceMap.get(item[0]).getServerName(), item[1]), CommonConstant.BAD_VALUE); |
| | | } |
| | | }); |
| | | return result; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.opcua.collector; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.iailab.module.data.channel.opcua.dto.ChannelOPCUADeviceDTO; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.eclipse.milo.opcua.sdk.client.OpcUaClient; |
| | | import org.eclipse.milo.opcua.sdk.client.api.config.OpcUaClientConfig; |
| | | import org.eclipse.milo.opcua.sdk.client.api.identity.AnonymousProvider; |
| | | import org.eclipse.milo.opcua.sdk.client.api.identity.IdentityProvider; |
| | | import org.eclipse.milo.opcua.sdk.client.api.identity.UsernameProvider; |
| | | import org.eclipse.milo.opcua.sdk.client.nodes.UaNode; |
| | | import org.eclipse.milo.opcua.stack.client.DiscoveryClient; |
| | | import org.eclipse.milo.opcua.stack.core.Identifiers; |
| | | import org.eclipse.milo.opcua.stack.core.security.SecurityPolicy; |
| | | import org.eclipse.milo.opcua.stack.core.types.builtin.*; |
| | | import org.eclipse.milo.opcua.stack.core.types.enumerated.TimestampsToReturn; |
| | | import org.eclipse.milo.opcua.stack.core.types.structured.EndpointDescription; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.net.URI; |
| | | import java.net.URISyntaxException; |
| | | import java.nio.file.Files; |
| | | import java.nio.file.Path; |
| | | import java.nio.file.Paths; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2023年05月12日 15:36:00 |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class OpcUaUtils { |
| | | |
| | | private final String CONNECTION_TYPE_USER = "1"; |
| | | |
| | | private final String SECURITY_POLICY_BASIC256 = "Basic256"; |
| | | |
| | | private final String SECURITY_POLICY_BASIC128RSA15 = "Basic128Rsa15"; |
| | | |
| | | private final String SECURITY_POLICY_BASIC256SHA256 = "Basic256Sha256"; |
| | | |
| | | public synchronized OpcUaClient createClient(ChannelOPCUADeviceDTO configDto) throws Exception { |
| | | OpcUaClient opcUaClient = null; |
| | | try { |
| | | log.info("OpcuaDTO" + JSONObject.toJSONString(configDto)); |
| | | |
| | | // 加载秘钥 |
| | | // Path securityTempDir = Paths.get(System.getProperty("java.io.tmpdir"), "security"); |
| | | log.info("加载秘钥"); |
| | | Path securityTempDir = Paths.get("D:\\DLUT\\pfx"); |
| | | Files.createDirectories(securityTempDir); |
| | | if (!Files.exists(securityTempDir)) { |
| | | throw new Exception("没有创建安全目录: " + securityTempDir); |
| | | } |
| | | KeyStoreLoader loader = new KeyStoreLoader().load(securityTempDir); |
| | | |
| | | // 安全策略 |
| | | log.info("安全策略"); |
| | | SecurityPolicy securityPolicy = getSecurityPolicy(configDto.getSecurityPolicy()); |
| | | |
| | | // 验证方式 |
| | | log.info("验证方式"); |
| | | IdentityProvider identityProvider = getIdentityProvider(configDto); |
| | | |
| | | // opc.tcp://DESKTOP-D7CDEIF:53530/OPCUA/SimulationServer |
| | | // String endpointUrl = "opc.tcp://127.0.0.1:53530"; |
| | | log.info("连接端点"); |
| | | List<EndpointDescription> endpoints = DiscoveryClient.getEndpoints(configDto.getEndpointUrl()).get(); |
| | | endpoints.forEach(item -> { |
| | | log.info("EndpointUrl=" + item.getEndpointUrl()); |
| | | }); |
| | | EndpointDescription endpoint = endpoints.stream() |
| | | .filter(e -> e.getSecurityPolicyUri().equals(securityPolicy.getUri())) |
| | | .findFirst() |
| | | .orElseThrow(() -> new Exception("没有连接上端点")); |
| | | |
| | | EndpointDescription newEndpoint = updateEndpointUrl(endpoint, getHostFromEndPointUrl(configDto.getEndpointUrl())); |
| | | log.info("NewEndpointUrl=" + newEndpoint.getEndpointUrl()); |
| | | |
| | | OpcUaClientConfig config = OpcUaClientConfig.builder() |
| | | .setApplicationName(LocalizedText.english("eclipse milo opc-ua client")) |
| | | .setApplicationUri("") |
| | | .setCertificate(loader.getClientCertificate()) |
| | | .setKeyPair(loader.getClientKeyPair()) |
| | | .setEndpoint(newEndpoint) |
| | | .setIdentityProvider(identityProvider) |
| | | .setRequestTimeout(uint(5000)) |
| | | .build(); |
| | | |
| | | opcUaClient = OpcUaClient.create(config); |
| | | log.info("创建客户端完成"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error("创建客户端失败" + e.getMessage()); |
| | | throw new Exception(e.getMessage()); |
| | | } |
| | | return opcUaClient; |
| | | } |
| | | |
| | | private String getHostFromEndPointUrl (String endPointUrl) { |
| | | int indexStart = endPointUrl.lastIndexOf("//"); |
| | | int indexEnd = endPointUrl.lastIndexOf(":"); |
| | | String host = endPointUrl.substring(indexStart, indexEnd).replace("//",""); |
| | | log.info(host); |
| | | return host; |
| | | } |
| | | |
| | | private EndpointDescription updateEndpointUrl(EndpointDescription original, String hostname) throws URISyntaxException { |
| | | |
| | | URI uri = new URI(original.getEndpointUrl()).parseServerAuthority(); |
| | | |
| | | String endpointUrl = String.format( |
| | | "%s://%s:%s%s", |
| | | uri.getScheme(), |
| | | hostname, |
| | | uri.getPort(), |
| | | uri.getPath() |
| | | ); |
| | | |
| | | return new EndpointDescription( |
| | | endpointUrl, |
| | | original.getServer(), |
| | | original.getServerCertificate(), |
| | | original.getSecurityMode(), |
| | | original.getSecurityPolicyUri(), |
| | | original.getUserIdentityTokens(), |
| | | original.getTransportProfileUri(), |
| | | original.getSecurityLevel() |
| | | ); |
| | | } |
| | | |
| | | private IdentityProvider getIdentityProvider(ChannelOPCUADeviceDTO configDto) { |
| | | switch (configDto.getConnectionType()) { |
| | | case CONNECTION_TYPE_USER: |
| | | return new UsernameProvider(configDto.getUserName(), configDto.getPassword()); |
| | | default: |
| | | return new AnonymousProvider(); |
| | | } |
| | | } |
| | | |
| | | private SecurityPolicy getSecurityPolicy(String type) { |
| | | switch (type) { |
| | | case SECURITY_POLICY_BASIC256: |
| | | return SecurityPolicy.Basic256; |
| | | case SECURITY_POLICY_BASIC128RSA15: |
| | | return SecurityPolicy.Basic128Rsa15; |
| | | case SECURITY_POLICY_BASIC256SHA256: |
| | | return SecurityPolicy.Basic256Sha256; |
| | | default: |
| | | return SecurityPolicy.None; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 遍历树形节点 |
| | | * |
| | | * @param client OPC UA客户端 |
| | | * @param uaNode 节点 |
| | | * @throws Exception |
| | | */ |
| | | private static void browseNode(OpcUaClient client, UaNode uaNode) throws Exception { |
| | | List<? extends UaNode> nodes; |
| | | if (uaNode == null) { |
| | | nodes = client.getAddressSpace().browseNodes(Identifiers.ObjectsFolder); |
| | | } else { |
| | | nodes = client.getAddressSpace().browseNodes(uaNode); |
| | | } |
| | | for (UaNode nd : nodes) { |
| | | //排除系统行性节点,这些系统性节点名称一般都是以"_"开头 |
| | | if (Objects.requireNonNull(nd.getBrowseName().getName()).contains("_")) { |
| | | continue; |
| | | } |
| | | System.out.println("Node= " + nd.getBrowseName().getName()); |
| | | browseNode(client, nd); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 读取节点数据 |
| | | * namespaceIndex可以通过UaExpert客户端去查询,一般来说这个值是2。 |
| | | * identifier也可以通过UaExpert客户端去查询,这个值=通道名称.设备名称.标记名称 |
| | | * |
| | | * @param client OPC UA客户端 |
| | | * @param nodeIdStr 标识符 |
| | | * @throws Exception |
| | | */ |
| | | public static String readNode(OpcUaClient client, String nodeIdStr) throws Exception { |
| | | String[] nodeIdArr = nodeIdStr.split(";"); |
| | | |
| | | int namespaceIndex = Integer.parseInt(nodeIdArr[0].split("=")[1]); |
| | | String identifier = nodeIdArr[1].split("=")[1]; |
| | | //节点 |
| | | NodeId nodeId = new NodeId(namespaceIndex, identifier); |
| | | //读取节点数据 |
| | | DataValue value = client.readValue(0.0, TimestampsToReturn.Neither, nodeId).get(); |
| | | identifier = String.valueOf(nodeId.getIdentifier()); |
| | | System.out.println(identifier + ": " + String.valueOf(value.getValue().getValue())); |
| | | return value.getValue().getValue().toString(); |
| | | } |
| | | |
| | | /** |
| | | * 写入节点数据 |
| | | * |
| | | * @param client |
| | | * @param nodeIdStr |
| | | * @param nodeValue |
| | | */ |
| | | public static void writeIntValue(OpcUaClient client, String nodeIdStr, Integer nodeValue) { |
| | | String[] nodeIdArr = nodeIdStr.split(";"); |
| | | |
| | | int namespaceIndex = Integer.parseInt(nodeIdArr[0].split("=")[1]); |
| | | String identifier = nodeIdArr[1].split("=")[1]; |
| | | NodeId nodeId = new NodeId(namespaceIndex, identifier); |
| | | DataValue newValue = new DataValue(new Variant(nodeValue), null, null); |
| | | //写入节点数据 |
| | | StatusCode statusCode = client.writeValue(nodeId, newValue).join(); |
| | | System.out.println("结果:" + statusCode.isGood()); |
| | | } |
| | | |
| | | /** |
| | | * 写入节点数据 |
| | | * |
| | | * @param client |
| | | * @param nodeIdStr |
| | | * @param nodeValue |
| | | */ |
| | | public static void writeFloatValue(OpcUaClient client, String nodeIdStr, Float nodeValue) { |
| | | String[] nodeIdArr = nodeIdStr.split(";"); |
| | | |
| | | int namespaceIndex = Integer.parseInt(nodeIdArr[0].split("=")[1]); |
| | | String identifier = nodeIdArr[1].split("=")[1]; |
| | | NodeId nodeId = new NodeId(namespaceIndex, identifier); |
| | | DataValue newValue = new DataValue(new Variant(nodeValue), null, null); |
| | | //写入节点数据 |
| | | StatusCode statusCode = client.writeValue(nodeId, newValue).join(); |
| | | System.out.println("结果:" + statusCode.isGood()); |
| | | } |
| | | |
| | | /** |
| | | * 写入节点数据 |
| | | * |
| | | * @param client |
| | | * @param nodeIdStr |
| | | * @param nodeValue |
| | | */ |
| | | public static void writeBooleanValue(OpcUaClient client, String nodeIdStr, Boolean nodeValue) { |
| | | String[] nodeIdArr = nodeIdStr.split(";"); |
| | | |
| | | int namespaceIndex = Integer.parseInt(nodeIdArr[0].split("=")[1]); |
| | | String identifier = nodeIdArr[1].split("=")[1]; |
| | | NodeId nodeId = new NodeId(namespaceIndex, identifier); |
| | | DataValue newValue = new DataValue(new Variant(nodeValue), null, null); |
| | | //写入节点数据 |
| | | StatusCode statusCode = client.writeValue(nodeId, newValue).join(); |
| | | System.out.println("结果:" + statusCode.isGood()); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.opcua.collector; |
| | | |
| | | import com.sun.org.apache.xerces.internal.impl.dv.util.Base64; |
| | | |
| | | import java.io.FileInputStream; |
| | | import java.io.FileNotFoundException; |
| | | import java.io.FileOutputStream; |
| | | import java.security.Key; |
| | | import java.security.KeyStore; |
| | | import java.security.PublicKey; |
| | | import java.security.cert.Certificate; |
| | | import java.security.cert.CertificateException; |
| | | import java.security.cert.CertificateFactory; |
| | | |
| | | /** |
| | | * @Author: zhangsong |
| | | * @Date: 2019/5/28 20:21 |
| | | * @Version 1.0 |
| | | * 首先需要通过jdk的keytool生成秘钥库等,需确保机器中安装有jdk |
| | | * 0.在本代码环境下,执行1命令时,秘钥库的密码和证书的密码须一致,请自行修改路径 |
| | | * 请确保路径下无名为mykeystore.keystore的文件,否则可能会报密码错等 |
| | | * 1.keytool -genkey -alias mykey -keyalg RSA -keystore C:/Users/Lenovo/AppData/Local/Temp/security/mykeystore.keystore -keysize 1024 -validity 3650 |
| | | 2.keytool -export -alias mykey -keystore C:/Users/Lenovo/AppData/Local/Temp/security/mykeystore.keystore -file C:/Users/Lenovo/AppData/Local/Temp/security/mykey.cer |
| | | 3.代码中的秘钥库密码为keystore,请自行修改 |
| | | 4.查看信息 keytool -list -v -keystore C:/Users/Lenovo/AppData/Local/Temp/security/mykeystore.keystore -storepass "keystore" |
| | | * |
| | | */ |
| | | public class RSACertHelper { |
| | | |
| | | public static void main(String[] args) { |
| | | String path = "C:/Users/Lenovo/AppData/Local/Temp/security/"; |
| | | String keyStoreFile = "mykeystore.keystore"; |
| | | String passwd = "keystore"; |
| | | String keyAlias = "mykey"; |
| | | String pfxFile = "mykey.pfx"; |
| | | String cerFile = "mykey.cer"; |
| | | |
| | | System.out.println("请确保已执行完注释中的两条命令再执行本代码\n\n"); |
| | | System.out.println("1.开始生成PFX文件"); |
| | | coverToPfx(path + keyStoreFile, passwd, keyAlias, path + pfxFile); |
| | | System.out.println("==============================================================="); |
| | | System.out.println("2.开始提取.cer中的公钥字符串"); |
| | | String cerStr = getPubStr(path + cerFile); |
| | | System.out.println("从.cer文件中提取的公钥字符串如下:"); |
| | | System.out.println(cerStr); |
| | | } |
| | | |
| | | //1生成pfx文件 |
| | | public static void coverToPfx(String keyStoreFile, String passwd, String keyAlias, String pfxFile) { |
| | | try { |
| | | KeyStore inputKeyStore = KeyStore.getInstance("JKS"); |
| | | FileInputStream fis = new FileInputStream(keyStoreFile); |
| | | char[] nPassword = null; |
| | | if ((passwd == null) |
| | | || passwd.trim().equals("")) { |
| | | nPassword = null; |
| | | } else { |
| | | nPassword = passwd.toCharArray(); |
| | | } |
| | | inputKeyStore.load(fis, nPassword); |
| | | fis.close(); |
| | | KeyStore outputKeyStore = KeyStore.getInstance("PKCS12"); |
| | | outputKeyStore.load(null, passwd.toCharArray()); |
| | | |
| | | if (inputKeyStore.isKeyEntry(keyAlias)) { |
| | | Key key = inputKeyStore.getKey(keyAlias, passwd.toCharArray()); |
| | | Certificate[] certChain = inputKeyStore |
| | | .getCertificateChain(keyAlias); |
| | | outputKeyStore.setKeyEntry(keyAlias, key, passwd |
| | | .toCharArray(), certChain); |
| | | } |
| | | |
| | | FileOutputStream out = new FileOutputStream(pfxFile); |
| | | outputKeyStore.store(out, nPassword); |
| | | out.close(); |
| | | System.out.println("已生成PFX文件" + pfxFile); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | //2获取公钥字符串 |
| | | public static String getPubStr(String cerFile) { |
| | | String key = ""; |
| | | // 读取证书文件 |
| | | try { |
| | | CertificateFactory cf = CertificateFactory.getInstance("X.509"); |
| | | FileInputStream in = new FileInputStream(cerFile); |
| | | |
| | | //生成一个证书对象并使用从输入流 inStream 中读取的数据对它进行初始化。 |
| | | Certificate c = cf.generateCertificate(in); |
| | | PublicKey publicKey = c.getPublicKey(); |
| | | key = Base64.encode(publicKey.getEncoded()); |
| | | } catch (CertificateException e) { |
| | | e.printStackTrace(); |
| | | } catch (FileNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return key; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.opcua.controller.admin; |
| | | |
| | | import com.iailab.module.data.common.utils.PageUtils; |
| | | import com.iailab.module.data.common.utils.R; |
| | | import com.iailab.module.data.channel.opcua.entity.ChannelOPCUADeviceEntity; |
| | | import com.iailab.module.data.channel.opcua.service.ChannelOPCUADeviceService; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.util.Map; |
| | | import java.util.UUID; |
| | | |
| | | /** |
| | | * 操作opc ua配置 |
| | | * |
| | | * @author DongYukun |
| | | * @createTime 2023年04月26日 10:33:00 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/data/channel/opcua/device") |
| | | public class ChannelOPCUADeviceController { |
| | | @Resource |
| | | private ChannelOPCUADeviceService channelOPCUADeviceService; |
| | | |
| | | /** |
| | | * 分页查询opc ua 配置 |
| | | * |
| | | * @param params |
| | | */ |
| | | @GetMapping("/list") |
| | | public R list(@RequestParam Map<String, Object> params) { |
| | | PageUtils page = channelOPCUADeviceService.queryPage(params); |
| | | |
| | | return R.ok().put("page", page); |
| | | } |
| | | |
| | | /** |
| | | * 根据id查询opc ua配置详情 |
| | | * |
| | | * @param id |
| | | */ |
| | | @GetMapping("/info/{id}") |
| | | public R info(@PathVariable("id") String id) { |
| | | ChannelOPCUADeviceEntity info = channelOPCUADeviceService.info(id); |
| | | return R.ok().put("data", info); |
| | | } |
| | | |
| | | /** |
| | | * 添加opc ua配置 |
| | | * |
| | | * @param channelOPCUADeviceEntity |
| | | */ |
| | | @PostMapping("/add") |
| | | public R add(@RequestBody ChannelOPCUADeviceEntity channelOPCUADeviceEntity) { |
| | | String id = UUID.randomUUID().toString(); |
| | | channelOPCUADeviceEntity.setId(id); |
| | | channelOPCUADeviceService.add(channelOPCUADeviceEntity); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 修改opc ua配置 |
| | | * |
| | | * @param channelOPCUADeviceEntity |
| | | */ |
| | | @PostMapping("/update") |
| | | public R update(@RequestBody ChannelOPCUADeviceEntity channelOPCUADeviceEntity) { |
| | | channelOPCUADeviceService.update(channelOPCUADeviceEntity); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 删除opc ua配置 |
| | | * |
| | | * @param params |
| | | */ |
| | | @PostMapping("/delete") |
| | | public R delete(@RequestBody Map<String, Object> params) { |
| | | String id = (String) params.get("id"); |
| | | channelOPCUADeviceService.delete(id); |
| | | return R.ok(); |
| | | } |
| | | /** |
| | | * 上传安全证书 |
| | | * |
| | | * @param file |
| | | */ |
| | | @PostMapping("/upload") |
| | | public R uploadFile(@RequestParam("file") MultipartFile file) { |
| | | String fileName = file.getOriginalFilename(); |
| | | String filePath = ""; |
| | | try { |
| | | File dir = new File(filePath); |
| | | if (!dir.exists()) { |
| | | dir.mkdirs(); |
| | | } |
| | | File saveFile = new File(filePath + fileName); |
| | | file.transferTo(saveFile); |
| | | return R.ok().put("data",saveFile.getAbsolutePath()); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | return R.error(); |
| | | } |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.opcua.controller.admin; |
| | | |
| | | import com.iailab.module.data.common.exception.RRException; |
| | | import com.iailab.module.data.common.utils.PageUtils; |
| | | import com.iailab.module.data.common.utils.R; |
| | | import com.iailab.module.data.channel.opcua.entity.ChannelOPCUATagEntity; |
| | | import com.iailab.module.data.channel.opcua.service.ChannelOPCUATagService; |
| | | import com.sun.xml.internal.messaging.saaj.util.Base64; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.Map; |
| | | import java.util.UUID; |
| | | |
| | | /** |
| | | * 操作opcua tag配置 |
| | | * |
| | | * @author DongYukun |
| | | * @createTime 2023年05月6日 17:44:00 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/data/channel/opcua/tag") |
| | | public class ChannelOPCUATagController { |
| | | @Resource |
| | | private ChannelOPCUATagService channelOpcuaTagService; |
| | | /** |
| | | * 分页查询tag |
| | | * |
| | | * @param params |
| | | */ |
| | | @GetMapping("/list") |
| | | public R tagList(@RequestParam Map<String, Object> params){ |
| | | PageUtils page = channelOpcuaTagService.queryPage(params); |
| | | |
| | | return R.ok().put("page", page); |
| | | } |
| | | /** |
| | | * 根据id查询tag详情 |
| | | * |
| | | * @param id |
| | | */ |
| | | @GetMapping("/info/{id}") |
| | | public R tagInfo(@PathVariable("id") String id){ |
| | | ChannelOPCUATagEntity info= channelOpcuaTagService.info(Base64.base64Decode(id)); |
| | | return R.ok().put("data", info); |
| | | } |
| | | /** |
| | | * 添加tag |
| | | * |
| | | * @param entity |
| | | */ |
| | | @PostMapping("/add") |
| | | public R tagAdd(@RequestBody ChannelOPCUATagEntity entity){ |
| | | entity.setId(UUID.randomUUID().toString()); |
| | | channelOpcuaTagService.add(entity); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 修改tag |
| | | * |
| | | * @param channelOPCUATagEntity |
| | | */ |
| | | @PostMapping("/update") |
| | | public R tagUpdate(@RequestBody ChannelOPCUATagEntity channelOPCUATagEntity) { |
| | | channelOpcuaTagService.update(channelOPCUATagEntity); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 删除tag |
| | | * @param params |
| | | * |
| | | */ |
| | | @PostMapping("/delete") |
| | | public R tagDelete(@RequestBody Map<String, Object> params) { |
| | | String id = (String)params.get("id"); |
| | | channelOpcuaTagService.delete(id); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 导入 |
| | | * |
| | | * @param device |
| | | * @param file |
| | | * @return |
| | | */ |
| | | @PostMapping("/import/{device}") |
| | | public R importTag(@PathVariable("device") String device, @RequestParam("file") MultipartFile file) { |
| | | try { |
| | | if (file.isEmpty()) { |
| | | throw new RRException("上传文件不能为空"); |
| | | } |
| | | channelOpcuaTagService.importTag(device, file); |
| | | } catch (Exception ex) { |
| | | return R.error(ex.getMessage()); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.opcua.controller; |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.opcua.dao; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.iailab.module.data.channel.opcua.entity.ChannelOPCUADeviceEntity; |
| | | import com.iailab.module.data.channel.opcua.entity.ChannelOPCUADeviceEntity; |
| | | import com.iailab.module.data.channel.opcua.entity.ChannelOPCUADeviceEntity; |
| | | import com.iailab.module.data.channel.opcua.entity.ChannelOPCUADeviceEntity; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2023年04月26日 11:31:00 |
| | | */ |
| | | @Mapper |
| | | public interface ChannelOPCUADeviceDao extends BaseMapper<ChannelOPCUADeviceEntity> { |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.opcua.dao; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.iailab.module.data.channel.opcua.entity.ChannelOPCUATagEntity; |
| | | import com.iailab.module.data.channel.opcua.entity.ChannelOPCUATagEntity; |
| | | import com.iailab.module.data.channel.opcua.entity.ChannelOPCUATagEntity; |
| | | import com.iailab.module.data.channel.opcua.entity.ChannelOPCUATagEntity; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @author DongYukun |
| | | * @Description |
| | | * @createTime 2023年05月8日 15:01:00 |
| | | */ |
| | | @Mapper |
| | | public interface ChannelOPCUATagDao extends BaseMapper<ChannelOPCUATagEntity> { |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.opcua.dto; |
| | | |
| | | import com.alibaba.fastjson.annotation.JSONField; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2023年04月23日 14:25:00 |
| | | */ |
| | | @Data |
| | | public class ChannelOPCUADeviceDTO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * ServerName |
| | | */ |
| | | @JSONField(name="ServerName") |
| | | private String ServerName; |
| | | |
| | | |
| | | /** |
| | | * EndpointUrl |
| | | */ |
| | | @JSONField(name="EndpointUrl") |
| | | private String EndpointUrl; |
| | | |
| | | /** |
| | | * SecurityPolicy |
| | | */ |
| | | @JSONField(name="SecurityPolicy") |
| | | private String SecurityPolicy; |
| | | |
| | | /** |
| | | * SecurityMode |
| | | */ |
| | | @JSONField(name="SecurityMode") |
| | | private String SecurityMode; |
| | | |
| | | /** |
| | | * 连接方式(0,匿名;1,用户名密码; 2,安全证书) |
| | | */ |
| | | @JSONField(name="ConnectionType") |
| | | private String ConnectionType; |
| | | |
| | | /** |
| | | * 用户名 |
| | | */ |
| | | @JSONField(name="UserName") |
| | | private String UserName; |
| | | |
| | | /** |
| | | * 密码 |
| | | */ |
| | | @JSONField(name="Password") |
| | | private String Password; |
| | | |
| | | /** |
| | | * 安全证书路径 |
| | | */ |
| | | @JSONField(name="CertificatePath") |
| | | private String CertificatePath; |
| | | |
| | | /** |
| | | * 设备不活动超时时间 |
| | | */ |
| | | @JSONField(name="ConnectInactivityTimeout") |
| | | private Integer ConnectInactivityTimeout; |
| | | /** |
| | | * 重连超时 |
| | | */ |
| | | @JSONField(name="ConnectInactivityTimeout") |
| | | private Integer ReconnectInterval; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.opcua.dto; |
| | | |
| | | import com.alibaba.fastjson.annotation.JSONField; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @author DongYukun |
| | | * @Description |
| | | * @createTime 2023年05月8日 15:01:00 |
| | | */ |
| | | @Data |
| | | public class ChannelOPCUATagDTO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * TagName |
| | | */ |
| | | @JSONField(name="TagName") |
| | | private String TagName; |
| | | |
| | | /** |
| | | * tag的数据类型 |
| | | */ |
| | | @JSONField(name="DataType") |
| | | private String DataType; |
| | | |
| | | /** |
| | | * 是否是能tag,如果为false,即使定义了但是runtime不会读取该数据 |
| | | */ |
| | | @JSONField(name="Enabled") |
| | | private Boolean Enabled; |
| | | |
| | | /** |
| | | * 关联的设备名字 |
| | | */ |
| | | @JSONField(name="Device") |
| | | private String Device; |
| | | |
| | | /** |
| | | * Modbus地址 00001 ~49999 |
| | | */ |
| | | @JSONField(name="Address") |
| | | private String Address; |
| | | |
| | | /** |
| | | * 系统采集频率,只对订阅模式有效 |
| | | */ |
| | | @JSONField(name="SamplingRate") |
| | | private Integer SamplingRate; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.opcua.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @author DongYuKun |
| | | * @Description OPC UA |
| | | * @createTime 2023年04月26日 9:30:00 |
| | | */ |
| | | @Data |
| | | @TableName("t_channel_opcua_device") |
| | | public class ChannelOPCUADeviceEntity implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @Schema(description = "主键") |
| | | @TableId(value = "id",type = IdType.INPUT) |
| | | private String id; |
| | | /** |
| | | * ServerName 服务名 |
| | | */ |
| | | private String serverName; |
| | | |
| | | |
| | | /** |
| | | * EndpointUrl 端点URL |
| | | */ |
| | | private String endpointUrl; |
| | | |
| | | /** |
| | | * SecurityPolicy 安全策略 |
| | | */ |
| | | private String securityPolicy; |
| | | |
| | | /** |
| | | * SecurityMode 安全模式 |
| | | */ |
| | | private String securityMode; |
| | | |
| | | /** |
| | | * 连接方式(0,匿名;1,用户名密码; 2,安全证书) |
| | | */ |
| | | private String connectionType; |
| | | |
| | | /** |
| | | * 用户名 |
| | | */ |
| | | private String userName; |
| | | |
| | | /** |
| | | * 密码 |
| | | */ |
| | | private String password; |
| | | |
| | | /** |
| | | * 安全证书路径 |
| | | */ |
| | | private String certificatePath; |
| | | |
| | | /** |
| | | * 设备不活动超时时间 |
| | | */ |
| | | private Integer connectInactivityTimeout; |
| | | /** |
| | | * 重连超时 |
| | | */ |
| | | private Integer reconnectInterval; |
| | | } |
| | | |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.opcua.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * opc ua点表 |
| | | * |
| | | * @author DongYukun |
| | | * @Description |
| | | * @createTime 2023年05月8日 15:01:00 |
| | | */ |
| | | @Data |
| | | @TableName("t_channel_opcda_tag") |
| | | public class ChannelOPCUATagEntity implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @Schema(description = "主键") |
| | | @TableId(value = "id",type = IdType.INPUT) |
| | | private String id; |
| | | /** |
| | | * TagName |
| | | */ |
| | | private String tagName; |
| | | |
| | | /** |
| | | * 数据类型 |
| | | */ |
| | | private String dataType; |
| | | |
| | | /** |
| | | * 是否可以tag,如果为false,即使定义了但是runtime不会读取该数据 |
| | | */ |
| | | private Boolean enabled; |
| | | |
| | | /** |
| | | * 关联设备 |
| | | */ |
| | | private String device; |
| | | |
| | | /** |
| | | * Modbus地址 00001 ~49999 |
| | | */ |
| | | private String address; |
| | | |
| | | /** |
| | | * 采集频率 |
| | | */ |
| | | private Integer samplingRate; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * 修改时间 |
| | | */ |
| | | private Date updateTime; |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.opcua.service; |
| | | |
| | | import com.iailab.module.data.common.utils.PageUtils; |
| | | import com.iailab.module.data.channel.opcua.entity.ChannelOPCUADeviceEntity; |
| | | import com.iailab.module.data.channel.opcua.dto.ChannelOPCUADeviceDTO; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author DongYukun |
| | | * @Description |
| | | * @createTime 2023年05月08日 15:04:00 |
| | | */ |
| | | public interface ChannelOPCUADeviceService { |
| | | /** |
| | | * 分页查询设备 |
| | | * |
| | | * @param params |
| | | */ |
| | | PageUtils queryPage(Map<String, Object> params); |
| | | /** |
| | | * 查询设备详情 |
| | | * |
| | | * @param id |
| | | */ |
| | | ChannelOPCUADeviceEntity info(String id); |
| | | |
| | | /** |
| | | * 列表 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | | List<ChannelOPCUADeviceEntity> list(Map<String, Object> params); |
| | | |
| | | /** |
| | | * 添加设备 |
| | | * |
| | | * @param channelOPCUADeviceEntity |
| | | */ |
| | | void add(ChannelOPCUADeviceEntity channelOPCUADeviceEntity); |
| | | /** |
| | | * 修改设备 |
| | | * |
| | | * @param channelOPCUADeviceEntity |
| | | */ |
| | | void update(ChannelOPCUADeviceEntity channelOPCUADeviceEntity); |
| | | /** |
| | | * 删除设备 |
| | | * |
| | | * @param id |
| | | */ |
| | | void delete(String id); |
| | | /** |
| | | * 查询全部设备 |
| | | * |
| | | */ |
| | | List<ChannelOPCUADeviceDTO> selectAll(); |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.opcua.service; |
| | | |
| | | import com.iailab.module.data.common.utils.PageUtils; |
| | | import com.iailab.module.data.channel.opcua.dto.ChannelOPCUATagDTO; |
| | | import com.iailab.module.data.channel.opcua.entity.ChannelOPCUATagEntity; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author DongYukun |
| | | * @Description |
| | | * @createTime 2023年05月08日 15:04:00 |
| | | */ |
| | | public interface ChannelOPCUATagService { |
| | | /** |
| | | * 分页查询tag |
| | | * |
| | | * @param params |
| | | */ |
| | | PageUtils queryPage(Map<String, Object> params); |
| | | |
| | | /** |
| | | * 查询tag详情 |
| | | * @param id |
| | | * |
| | | */ |
| | | ChannelOPCUATagEntity info(String id); |
| | | /** |
| | | * 添加tag |
| | | * |
| | | * @param channelOPCUATagEntity |
| | | */ |
| | | void add(ChannelOPCUATagEntity channelOPCUATagEntity); |
| | | /** |
| | | * 修改tag |
| | | * |
| | | * @param channelOPCUATagEntity |
| | | */ |
| | | void update(ChannelOPCUATagEntity channelOPCUATagEntity); |
| | | /** |
| | | * 删除tag |
| | | * @param id |
| | | * |
| | | */ |
| | | void delete(String id); |
| | | |
| | | List<ChannelOPCUATagEntity> getByDevice(String device); |
| | | |
| | | |
| | | List<ChannelOPCUATagDTO> selectAll(); |
| | | |
| | | List<ChannelOPCUATagEntity> listByIds(List<String> ids); |
| | | |
| | | /** |
| | | * 通过deviceName删除 |
| | | * |
| | | */ |
| | | void deleteByDeviceName(String name); |
| | | |
| | | /** |
| | | * 导入Tag |
| | | * |
| | | * @param device |
| | | * @param file |
| | | * @throws Exception |
| | | */ |
| | | void importTag(String device, MultipartFile file) throws Exception; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.opcua.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.iailab.framework.common.util.object.ConvertUtils; |
| | | import com.iailab.module.data.common.utils.PageUtils; |
| | | import com.iailab.module.data.common.utils.Query; |
| | | import com.iailab.module.data.channel.opcua.dao.ChannelOPCUADeviceDao; |
| | | import com.iailab.module.data.channel.opcua.entity.ChannelOPCUADeviceEntity; |
| | | import com.iailab.module.data.channel.opcua.service.ChannelOPCUADeviceService; |
| | | import com.iailab.module.data.channel.opcua.service.ChannelOPCUATagService; |
| | | import com.iailab.module.data.channel.opcua.dto.ChannelOPCUADeviceDTO; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author DongYukun |
| | | * @Description |
| | | * @createTime 2023年05月08日 15:04:00 |
| | | */ |
| | | @Service |
| | | public class ChannelOPCUADeviceServiceImpl extends ServiceImpl<ChannelOPCUADeviceDao, ChannelOPCUADeviceEntity> implements ChannelOPCUADeviceService { |
| | | @Resource |
| | | private ChannelOPCUADeviceDao channelOPCUADeviceDao; |
| | | |
| | | @Resource |
| | | private ChannelOPCUATagService channelOPCUATagService; |
| | | /** |
| | | * 分页查询opc ua配置 |
| | | * |
| | | * @param params |
| | | */ |
| | | @Override |
| | | public PageUtils queryPage(Map<String, Object> params) { |
| | | String serverName = (String) params.get("serverName"); |
| | | |
| | | IPage<ChannelOPCUADeviceEntity> page = this.page( |
| | | new Query<ChannelOPCUADeviceEntity>().getPage(params), |
| | | new QueryWrapper<ChannelOPCUADeviceEntity>() |
| | | .like(StringUtils.isNotBlank(serverName), "server_name", serverName) |
| | | .orderByDesc("create_time") |
| | | ); |
| | | return new PageUtils(page); |
| | | } |
| | | |
| | | /** |
| | | * 查询opc ua配置详情 |
| | | * |
| | | * @param id |
| | | */ |
| | | @Override |
| | | public ChannelOPCUADeviceEntity info(String id) { |
| | | return channelOPCUADeviceDao.selectById(id); |
| | | } |
| | | |
| | | /** |
| | | * 列表 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<ChannelOPCUADeviceEntity> list(Map<String, Object> params) { |
| | | return channelOPCUADeviceDao.selectList(new QueryWrapper<ChannelOPCUADeviceEntity>().orderByAsc("server_name")); |
| | | } |
| | | |
| | | /** |
| | | * 添加opc ua配置 |
| | | * |
| | | * @param channelOPCUADeviceEntity |
| | | */ |
| | | @Override |
| | | public void add(ChannelOPCUADeviceEntity channelOPCUADeviceEntity) { |
| | | channelOPCUADeviceDao.insert(channelOPCUADeviceEntity); |
| | | } |
| | | |
| | | /** |
| | | * 修改opc ua配置 |
| | | * |
| | | * @param channelOPCUADeviceEntity |
| | | */ |
| | | @Override |
| | | public void update(ChannelOPCUADeviceEntity channelOPCUADeviceEntity) { |
| | | channelOPCUADeviceDao.updateById(channelOPCUADeviceEntity); |
| | | } |
| | | |
| | | /** |
| | | * 删除opc ua配置 |
| | | * |
| | | * @param id |
| | | */ |
| | | @Override |
| | | public void delete(String id) { |
| | | |
| | | //先删除device下的tag |
| | | channelOPCUATagService.deleteByDeviceName(info(id).getServerName()); |
| | | |
| | | channelOPCUADeviceDao.deleteById(id); |
| | | } |
| | | |
| | | @Override |
| | | public List<ChannelOPCUADeviceDTO> selectAll() { |
| | | |
| | | List<ChannelOPCUADeviceEntity> entityList = baseMapper.selectList( |
| | | null |
| | | ); |
| | | return ConvertUtils.sourceToTarget(entityList, ChannelOPCUADeviceDTO.class); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.opcua.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.iailab.framework.common.util.object.ConvertUtils; |
| | | import com.iailab.module.data.common.utils.PageUtils; |
| | | import com.iailab.module.data.common.utils.Query; |
| | | import com.iailab.module.data.channel.opcua.dao.ChannelOPCUATagDao; |
| | | import com.iailab.module.data.channel.opcua.dto.ChannelOPCUATagDTO; |
| | | import com.iailab.module.data.channel.opcua.entity.ChannelOPCUATagEntity; |
| | | import com.iailab.module.data.channel.opcua.service.ChannelOPCUATagService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.poi.ss.usermodel.CellType; |
| | | import org.apache.poi.xssf.usermodel.XSSFRow; |
| | | import org.apache.poi.xssf.usermodel.XSSFSheet; |
| | | import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.UUID; |
| | | |
| | | /** |
| | | * @author DongYukun |
| | | * @Description |
| | | * @createTime 2023年05月08日 15:04:00 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class ChannelOPCUATagServiceImpl extends ServiceImpl<ChannelOPCUATagDao, ChannelOPCUATagEntity> implements ChannelOPCUATagService { |
| | | @Resource |
| | | private ChannelOPCUATagDao channelOPCUATagDao; |
| | | |
| | | @Value("${iems.upload-dir}") |
| | | private String uploadDir; |
| | | |
| | | /** |
| | | * 分页查询tag |
| | | * |
| | | * @param params |
| | | */ |
| | | @Override |
| | | public PageUtils queryPage(Map<String, Object> params) { |
| | | String tagName = (String) params.get("tagName"); |
| | | String device = (String) params.get("device"); |
| | | |
| | | IPage<ChannelOPCUATagEntity> page = this.page( |
| | | new Query<ChannelOPCUATagEntity>().getPage(params), |
| | | new QueryWrapper<ChannelOPCUATagEntity>() |
| | | .like(StringUtils.isNotBlank(tagName), "tag_name", tagName) |
| | | .eq(StringUtils.isNotBlank(device), "device", device) |
| | | .orderByDesc("create_time") |
| | | ); |
| | | return new PageUtils(page); |
| | | } |
| | | |
| | | /** |
| | | * 查询tag详情 |
| | | * |
| | | * @param id |
| | | */ |
| | | @Override |
| | | public ChannelOPCUATagEntity info(String id) { |
| | | return channelOPCUATagDao.selectById(id); |
| | | } |
| | | |
| | | @Override |
| | | public List<ChannelOPCUATagEntity> getByDevice(String device) { |
| | | QueryWrapper<ChannelOPCUATagEntity> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("device", device).orderByDesc ("create_time"); |
| | | return channelOPCUATagDao.selectList(queryWrapper); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 添加tag |
| | | * |
| | | * @param channelOPCUATagEntity |
| | | */ |
| | | @Override |
| | | public void add(ChannelOPCUATagEntity channelOPCUATagEntity) { |
| | | channelOPCUATagDao.insert(channelOPCUATagEntity); |
| | | } |
| | | |
| | | /** |
| | | * 修改tag |
| | | * |
| | | * @param channelOPCUATagEntity |
| | | */ |
| | | @Override |
| | | public void update(ChannelOPCUATagEntity channelOPCUATagEntity) { |
| | | channelOPCUATagDao.updateById(channelOPCUATagEntity); |
| | | } |
| | | |
| | | /** |
| | | * 删除tag |
| | | * |
| | | * @param id |
| | | */ |
| | | @Override |
| | | public void delete(String id) { |
| | | channelOPCUATagDao.deleteById(id); |
| | | } |
| | | |
| | | @Override |
| | | public List<ChannelOPCUATagDTO> selectAll() { |
| | | |
| | | List<ChannelOPCUATagEntity> entityList = baseMapper.selectList( |
| | | null |
| | | ); |
| | | return ConvertUtils.sourceToTarget(entityList, ChannelOPCUATagDTO.class); |
| | | } |
| | | |
| | | @Override |
| | | public List<ChannelOPCUATagEntity> listByIds(List<String> ids) { |
| | | return baseMapper.selectList(new QueryWrapper<ChannelOPCUATagEntity>().in("id", ids)); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteByDeviceName(String name) { |
| | | baseMapper.delete(new QueryWrapper<ChannelOPCUATagEntity>().eq("device",name)); |
| | | } |
| | | |
| | | /** |
| | | * 导入Tag |
| | | * |
| | | * @param device |
| | | * @param file |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void importTag(String device, MultipartFile file) throws Exception { |
| | | try { |
| | | String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")); |
| | | String fileName = UUID.randomUUID().toString() + suffix; |
| | | String path = uploadDir + fileName; |
| | | file.transferTo(new File(path)); |
| | | |
| | | XSSFWorkbook hssfWorkbook = new XSSFWorkbook(new FileInputStream(path)); |
| | | XSSFSheet sheet = hssfWorkbook.getSheetAt(0); |
| | | int lastRowNum = sheet.getLastRowNum(); |
| | | log.info("最后一行:" + lastRowNum); |
| | | int lastCellNum = 4; |
| | | List<ChannelOPCUATagEntity> dangerList = new ArrayList<>(); |
| | | for (int i = 2; i <= lastRowNum; i++) { |
| | | XSSFRow row = sheet.getRow(i); |
| | | for (int j = row.getFirstCellNum(); j < lastCellNum; j++) { |
| | | row.getCell(j).setCellType(CellType.STRING); |
| | | } |
| | | ChannelOPCUATagEntity tagEntity = new ChannelOPCUATagEntity(); |
| | | tagEntity.setId(UUID.randomUUID().toString()); |
| | | tagEntity.setTagName(row.getCell(1).getStringCellValue()); |
| | | tagEntity.setDataType(row.getCell(2).getStringCellValue()); |
| | | row.getCell(4).setCellType(CellType.STRING); |
| | | if(row.getCell(3).getStringCellValue().equals("1")){ |
| | | tagEntity.setAddress(String.format("1%04d",Integer.parseInt(row.getCell(4).getStringCellValue()))); |
| | | }else if(row.getCell(3).getStringCellValue().equals("3")){ |
| | | tagEntity.setAddress(String.format("4%04d",Integer.parseInt(row.getCell(4).getStringCellValue()))); |
| | | } |
| | | tagEntity.setEnabled(true); |
| | | tagEntity.setDevice(device); |
| | | tagEntity.setSamplingRate(1); |
| | | dangerList.add(tagEntity); |
| | | } |
| | | if (CollectionUtils.isEmpty(dangerList)) { |
| | | return; |
| | | } |
| | | //getBaseMapper().insertList(dangerList); |
| | | dangerList.forEach(item -> { |
| | | try { |
| | | getBaseMapper().insert(item); |
| | | } catch (Exception ex) { |
| | | log.warn("插入异常:" + item.getTagName()); |
| | | } |
| | | }); |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | log.warn("导入失败!"); |
| | | throw ex; |
| | | } |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.tag.controller; |
| | | |
| | | import com.iailab.module.data.common.enums.DataSourceType; |
| | | import com.iailab.framework.common.pojo.CommonResult; |
| | | import com.iailab.module.data.channel.kio.dto.ChannelKioDeviceDTO; |
| | | import com.iailab.module.data.channel.kio.service.ChannelKioDeviceService; |
| | | import com.iailab.module.data.channel.kio.service.ChannelKioTagService; |
| | | import com.iailab.module.data.channel.modbus.entity.ChannelModBusDeviceEntity; |
| | | import com.iailab.module.data.channel.modbus.entity.ChannelModBusTagEntity; |
| | | import com.iailab.module.data.channel.modbus.service.ChannelModbusDeviceService; |
| | | import com.iailab.module.data.channel.modbus.service.ChannelModbusTagService; |
| | | import com.iailab.module.data.channel.opcua.entity.ChannelOPCUADeviceEntity; |
| | | import com.iailab.module.data.channel.opcua.service.ChannelOPCUADeviceService; |
| | | import com.iailab.module.data.channel.opcua.service.ChannelOPCUATagService; |
| | | import com.iailab.module.data.channel.tag.dto.TagOptionDTO; |
| | | import com.iailab.module.data.http.entity.HttpApiEntity; |
| | | import com.iailab.module.data.http.entity.HttpTagEntity; |
| | | import com.iailab.module.data.http.service.HttpApiService; |
| | | import com.iailab.module.data.channel.kio.dto.ChannelKioTagDTO; |
| | | import com.iailab.module.data.channel.opcua.entity.ChannelOPCUATagEntity; |
| | | import com.iailab.module.data.http.service.HttpTagService; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年05月16日 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/channel/tag") |
| | | public class TagController { |
| | | |
| | | @Resource |
| | | private ChannelOPCUADeviceService channelOPCUADeviceService; |
| | | |
| | | @Resource |
| | | private ChannelOPCUATagService channelOPCUATagService; |
| | | |
| | | @Resource |
| | | private ChannelModbusDeviceService channelModbusDeviceService; |
| | | |
| | | @Resource |
| | | private ChannelModbusTagService channelModbusTagService; |
| | | |
| | | @Resource |
| | | private ChannelKioDeviceService channelKioDeviceService; |
| | | |
| | | @Resource |
| | | private ChannelKioTagService channelKioTagService; |
| | | |
| | | @Resource |
| | | private HttpApiService httpApiService; |
| | | |
| | | @Resource |
| | | private HttpTagService tagService; |
| | | |
| | | |
| | | @GetMapping("tree") |
| | | public CommonResult<List<TagOptionDTO>> tagTree() { |
| | | List<TagOptionDTO> result = new ArrayList<>(); |
| | | |
| | | TagOptionDTO opcuaData = new TagOptionDTO(); |
| | | opcuaData.setValue(DataSourceType.OPCUA.getCode()); |
| | | opcuaData.setLabel(DataSourceType.OPCUA.getDesc()); |
| | | List<ChannelOPCUADeviceEntity> opcuaDeviceList = channelOPCUADeviceService.list(new HashMap<>()); |
| | | List<TagOptionDTO> opcuaDeviceOp = new ArrayList<>(); |
| | | if (!CollectionUtils.isEmpty(opcuaDeviceList)) { |
| | | opcuaDeviceList.forEach(item -> { |
| | | TagOptionDTO op1 = new TagOptionDTO(); |
| | | op1.setValue(item.getId()); |
| | | op1.setLabel(item.getServerName()); |
| | | List<ChannelOPCUATagEntity> tags = channelOPCUATagService.getByDevice(item.getServerName()); |
| | | List<TagOptionDTO> op2 = new ArrayList<>(); |
| | | tags.forEach(item1 -> { |
| | | TagOptionDTO op3 = new TagOptionDTO(); |
| | | op3.setValue(item1.getTagName()); |
| | | op3.setLabel(item1.getTagName()); |
| | | op2.add(op3); |
| | | }); |
| | | op1.setChildren(op2); |
| | | opcuaDeviceOp.add(op1); |
| | | }); |
| | | } |
| | | opcuaData.setChildren(opcuaDeviceOp); |
| | | result.add(opcuaData); |
| | | |
| | | TagOptionDTO modbusData = new TagOptionDTO(); |
| | | modbusData.setValue(DataSourceType.ModBus.getCode()); |
| | | modbusData.setLabel(DataSourceType.ModBus.getDesc()); |
| | | List<ChannelModBusDeviceEntity> modbusList = channelModbusDeviceService.list(new HashMap<>()); |
| | | List<TagOptionDTO> modbusDeviceOp = new ArrayList<>(); |
| | | if (!CollectionUtils.isEmpty(modbusList)) { |
| | | modbusList.forEach(item -> { |
| | | TagOptionDTO op1 = new TagOptionDTO(); |
| | | op1.setValue(item.getId()); |
| | | op1.setLabel(item.getName()); |
| | | List<ChannelModBusTagEntity> tags = channelModbusTagService.getByDevice(item.getName()); |
| | | List<TagOptionDTO> op2 = new ArrayList<>(); |
| | | tags.forEach(item1 -> { |
| | | TagOptionDTO op3 = new TagOptionDTO(); |
| | | op3.setValue(item1.getTagName()); |
| | | op3.setLabel(item1.getTagName()); |
| | | op2.add(op3); |
| | | }); |
| | | op1.setChildren(op2); |
| | | modbusDeviceOp.add(op1); |
| | | }); |
| | | } |
| | | modbusData.setChildren(modbusDeviceOp); |
| | | result.add(modbusData); |
| | | |
| | | |
| | | TagOptionDTO kioData = new TagOptionDTO(); |
| | | kioData.setValue(DataSourceType.KIO.getCode()); |
| | | kioData.setLabel(DataSourceType.KIO.getDesc()); |
| | | List<ChannelKioDeviceDTO> kioList = channelKioDeviceService.list(new HashMap<>()); |
| | | List<TagOptionDTO> kioDeviceOp = new ArrayList<>(); |
| | | if (!CollectionUtils.isEmpty(kioList)) { |
| | | kioList.forEach(item -> { |
| | | TagOptionDTO op1 = new TagOptionDTO(); |
| | | op1.setValue(item.getId()); |
| | | op1.setLabel(item.getInstanceName()); |
| | | List<ChannelKioTagDTO> tags = channelKioTagService.getByDevice(item.getInstanceName()); |
| | | List<TagOptionDTO> op2 = new ArrayList<>(); |
| | | tags.forEach(item1 -> { |
| | | TagOptionDTO op3 = new TagOptionDTO(); |
| | | op3.setValue(item1.getTagName()); |
| | | op3.setLabel(item1.getTagName()); |
| | | op2.add(op3); |
| | | }); |
| | | op1.setChildren(op2); |
| | | kioDeviceOp.add(op1); |
| | | }); |
| | | } |
| | | kioData.setChildren(kioDeviceOp); |
| | | result.add(kioData); |
| | | |
| | | TagOptionDTO httpApiData = new TagOptionDTO(); |
| | | httpApiData.setValue(DataSourceType.HTTP.getCode()); |
| | | httpApiData.setLabel(DataSourceType.HTTP.getDesc()); |
| | | List<HttpApiEntity> httpApiList = httpApiService.list(); |
| | | List<TagOptionDTO> httpApiOp = new ArrayList<>(); |
| | | if (!CollectionUtils.isEmpty(httpApiList)) { |
| | | httpApiList.forEach(item -> { |
| | | TagOptionDTO op1 = new TagOptionDTO(); |
| | | op1.setValue(item.getId()); |
| | | op1.setLabel(item.getName()); |
| | | List<HttpTagEntity> tags = tagService.getByCode(item.getCode()); |
| | | List<TagOptionDTO> op2 = new ArrayList<>(); |
| | | tags.forEach(item1 -> { |
| | | TagOptionDTO op3 = new TagOptionDTO(); |
| | | op3.setValue(item1.getTagCode()); |
| | | op3.setLabel(item1.getTagCode()); |
| | | op2.add(op3); |
| | | }); |
| | | op1.setChildren(op2); |
| | | httpApiOp.add(op1); |
| | | }); |
| | | } |
| | | httpApiData.setChildren(httpApiOp); |
| | | result.add(httpApiData); |
| | | |
| | | return new CommonResult().setData(result); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.tag.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2023年04月23日 17:26:00 |
| | | */ |
| | | @Data |
| | | public class TagDTO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 用于显示在用户界面 |
| | | */ |
| | | private String Name; |
| | | |
| | | /** |
| | | * 用于构造获取地址空间路径path |
| | | */ |
| | | private String BrowseName; |
| | | |
| | | /** |
| | | * Id |
| | | */ |
| | | private String Id; |
| | | |
| | | /** |
| | | * 数据类型 |
| | | */ |
| | | private String Type; |
| | | |
| | | /** |
| | | * AccessRight |
| | | */ |
| | | private Integer AccessRight; |
| | | |
| | | /** |
| | | * IsFolder |
| | | */ |
| | | private Boolean IsFolder; |
| | | |
| | | /** |
| | | * 维度 |
| | | */ |
| | | private List<Object> Dimensions; |
| | | |
| | | /** |
| | | * Children |
| | | */ |
| | | private List<Object> Children; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.tag.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年05月16日 |
| | | */ |
| | | @Data |
| | | public class TagOptionDTO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | private String value; |
| | | |
| | | private String label; |
| | | |
| | | private List<TagOptionDTO> children; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.tag.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2023年04月23日 17:38:00 |
| | | */ |
| | | @Data |
| | | public class TagValueDTO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | private String Id; |
| | | |
| | | private String Quality; |
| | | |
| | | private String Timestamp; |
| | | |
| | | private String Type; |
| | | |
| | | private String Value; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.channel.tag.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2023年04月25日 14:02:00 |
| | | */ |
| | | @Data |
| | | public class TagValueQueryDTO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | private String Id; |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | * Copyright (c) 2018 人人开源 All rights reserved. |
| | | * |
| | | * https://www.renren.io |
| | | * |
| | | * 版权所有,侵权必究! |
| | | */ |
| | | |
| | | package com.iailab.module.data.common.annotation; |
| | | |
| | | import java.lang.annotation.*; |
| | | |
| | | /** |
| | | * 数据过滤注解 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | */ |
| | | @Target(ElementType.METHOD) |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | @Documented |
| | | public @interface DataFilter { |
| | | /** |
| | | * 表的别名 |
| | | */ |
| | | String tableAlias() default ""; |
| | | |
| | | /** |
| | | * 用户ID |
| | | */ |
| | | String userId() default "creator"; |
| | | |
| | | /** |
| | | * 部门ID |
| | | */ |
| | | String deptId() default "dept_id"; |
| | | |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | * Copyright (c) 2018 人人开源 All rights reserved. |
| | | * |
| | | * https://www.renren.io |
| | | * |
| | | * 版权所有,侵权必究! |
| | | */ |
| | | |
| | | package com.iailab.module.data.common.annotation; |
| | | |
| | | import java.lang.annotation.*; |
| | | |
| | | /** |
| | | * 操作日志注解 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | */ |
| | | @Target(ElementType.METHOD) |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | @Documented |
| | | public @interface LogOperation { |
| | | |
| | | String value() default ""; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.common.annotation; |
| | | |
| | | import java.lang.annotation.*; |
| | | |
| | | /** |
| | | * 系统日志注解 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | */ |
| | | @Target(ElementType.METHOD) |
| | | @Retention(RetentionPolicy.RUNTIME) |
| | | @Documented |
| | | public @interface SysLog { |
| | | |
| | | String value() default ""; |
| | | } |
对比新文件 |
| | |
| | | //package com.iailab.common.aspect; |
| | | // |
| | | //import com.alibaba.fastjson.JSONObject; |
| | | //import com.alibaba.fastjson.parser.Feature; |
| | | //import com.iailab.common.annotation.Dict; |
| | | //import com.iailab.framework.common.page.PageData; |
| | | //import com.iailab.framework.common.util.object.ConvertUtils; |
| | | //import com.iailab.common.utils.PageUtils; |
| | | //import com.iailab.common.utils.R; |
| | | //import com.iailab.common.utils.CommonResult; |
| | | //import com.iailab.entity.SysDictItem; |
| | | //import com.iailab.feign.IFeignSystemController; |
| | | //import lombok.extern.slf4j.Slf4j; |
| | | //import org.aspectj.lang.ProceedingJoinPoint; |
| | | //import org.aspectj.lang.annotation.Around; |
| | | //import org.aspectj.lang.annotation.Aspect; |
| | | //import org.aspectj.lang.annotation.Pointcut; |
| | | //import javax.annotation.Resource; |
| | | //import org.springframework.stereotype.Component; |
| | | //import org.springframework.util.CollectionUtils; |
| | | // |
| | | //import java.beans.IntrospectionException; |
| | | //import java.beans.PropertyDescriptor; |
| | | //import java.lang.reflect.Field; |
| | | //import java.lang.reflect.InvocationTargetException; |
| | | //import java.lang.reflect.Method; |
| | | //import java.util.HashMap; |
| | | //import java.util.List; |
| | | //import java.util.Map; |
| | | // |
| | | ///** |
| | | // * @author PanZhibao |
| | | // * @Description |
| | | // * @createTime 2022年05月21日 09:57:00 |
| | | // */ |
| | | //@Aspect |
| | | //@Component |
| | | //@Slf4j |
| | | //public class DictAspect { |
| | | // |
| | | // private final String PAGE_CODE = "page"; |
| | | // |
| | | // private final String DATA_CODE = "data"; |
| | | // |
| | | // @Resource |
| | | // private IFeignSystemController feignSystemController; |
| | | // |
| | | // /** |
| | | // * 定义切点Pointcut |
| | | // */ |
| | | // @Pointcut("@annotation(com.iailab.common.annotation.AutoDict)") |
| | | // public void excudeService() { |
| | | // } |
| | | // |
| | | // @Around("excudeService()") |
| | | // public Object doAround(ProceedingJoinPoint pjp) throws Throwable { |
| | | // Object result = pjp.proceed(); |
| | | // try { |
| | | // this.parseDictText(result); |
| | | // } catch (Exception ex) { |
| | | // log.info(ex.getMessage()); |
| | | // } |
| | | // return result; |
| | | // } |
| | | // |
| | | // /** |
| | | // * parseDictText |
| | | // * |
| | | // * @param result |
| | | // * @throws IntrospectionException |
| | | // * @throws InvocationTargetException |
| | | // * @throws IllegalAccessException |
| | | // */ |
| | | // private void parseDictText(Object result) throws IntrospectionException, InvocationTargetException, IllegalAccessException { |
| | | // Map<String, List<SysDictItem>> mapList = feignSystemController.queryAllDictItems(); |
| | | // Map<String,Map<String, String>> map = new HashMap<>(); |
| | | // if (!CollectionUtils.isEmpty(mapList)) { |
| | | // mapList.forEach((k , v) -> { |
| | | // Map<String, String> dictItems = new HashMap<>(); |
| | | // if (!CollectionUtils.isEmpty(v)) { |
| | | // v.forEach(item -> { |
| | | // dictItems.put(item.getItemValue(), item.getItemText()); |
| | | // }); |
| | | // } |
| | | // map.put(k, dictItems); |
| | | // }); |
| | | // } |
| | | // |
| | | // if (result instanceof R) { |
| | | // if (((R) result).get(PAGE_CODE) instanceof PageUtils) { |
| | | // PageUtils page =(PageUtils)((R) result).get(PAGE_CODE); |
| | | // for (Object record : page.getList()) { |
| | | // this.setDictText(record, map); |
| | | // } |
| | | // } else if(((R) result).get(DATA_CODE) instanceof PageUtils) { |
| | | // PageUtils page =(PageUtils)((R) result).get(DATA_CODE); |
| | | // for (Object record : page.getList()) { |
| | | // this.setDictText(record, map); |
| | | // } |
| | | // } |
| | | // } else if(result instanceof CommonResult) { |
| | | // if(((CommonResult) result).getData() != null) { |
| | | // Object data = ((CommonResult) result).getData(); |
| | | // if (data instanceof List) { |
| | | // for (Object record : (List)data) { |
| | | // this.setDictText(record, map); |
| | | // } |
| | | // } else if(data instanceof PageData) { |
| | | // Object list = ((PageData)data).getList(); |
| | | // for (Object record : (List)list) { |
| | | // this.setDictText(record, map); |
| | | // } |
| | | // } else { |
| | | // this.setDictText(data, map); |
| | | // } |
| | | // } |
| | | // } else if (result instanceof List){ |
| | | // for (Object record : (List)result) { |
| | | // this.setDictText(record, map); |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | // /** |
| | | // * setDictText |
| | | // * |
| | | // * @param record |
| | | // * @param map |
| | | // * @throws IntrospectionException |
| | | // * @throws InvocationTargetException |
| | | // * @throws IllegalAccessException |
| | | // */ |
| | | // private void setDictText(Object record, Map<String,Map<String, String>> map) throws IntrospectionException, InvocationTargetException, IllegalAccessException { |
| | | // JSONObject item = JSONObject.parseObject(JSONObject.toJSONString(record), Feature.OrderedField); |
| | | // for (Field field : ConvertUtils.getAllFields(record)) { |
| | | // if (!field.isAnnotationPresent(Dict.class)) { |
| | | // continue; |
| | | // } |
| | | // String dictCode = field.getAnnotation(Dict.class).dicCode(); |
| | | // String itemValue = field.getAnnotation(Dict.class).itemValue(); |
| | | // String value = item.getString(itemValue); |
| | | // Method method = new PropertyDescriptor(field.getName(), record.getClass()).getWriteMethod(); |
| | | // method.invoke(record, this.getDictText(dictCode, value, map)); |
| | | // } |
| | | // } |
| | | // |
| | | // /** |
| | | // * getDictText |
| | | // * |
| | | // * @param dictCode |
| | | // * @param itemValue |
| | | // * @param map |
| | | // * @return |
| | | // */ |
| | | // private String getDictText(String dictCode, String itemValue, Map<String,Map<String, String>> map) { |
| | | // String dictText = ""; |
| | | // try{ |
| | | // if (map != null || map.containsKey(dictCode)) { |
| | | // dictText = map.get(dictCode).get(itemValue); |
| | | // } |
| | | // } catch (Exception ex) { |
| | | // log.info("字典异常:" + dictCode ); |
| | | // } |
| | | // return dictText; |
| | | // } |
| | | //} |
对比新文件 |
| | |
| | | package com.iailab.module.data.common.aspect; |
| | | |
| | | import org.aspectj.lang.ProceedingJoinPoint; |
| | | import org.aspectj.lang.annotation.Around; |
| | | import org.aspectj.lang.annotation.Aspect; |
| | | import org.aspectj.lang.annotation.Pointcut; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | |
| | | /** |
| | | * 系统日志,切面处理类 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | */ |
| | | @Aspect |
| | | @Component |
| | | public class SysLogAspect { |
| | | |
| | | @Pointcut("@annotation(com.iailab.module.data.common.annotation.SysLog)") |
| | | public void logPointCut() { |
| | | |
| | | } |
| | | |
| | | @Around("logPointCut()") |
| | | public Object around(ProceedingJoinPoint point) throws Throwable { |
| | | long beginTime = System.currentTimeMillis(); |
| | | //执行方法 |
| | | Object result = point.proceed(); |
| | | //执行时长(毫秒) |
| | | long time = System.currentTimeMillis() - beginTime; |
| | | |
| | | //保存日志 |
| | | //saveSysLog(point, time); |
| | | |
| | | return result; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | ///** |
| | | // * Copyright (c) 2016-2019 人人开源 All rights reserved. |
| | | // * |
| | | // * https://www.renren.io |
| | | // * |
| | | // * 版权所有,侵权必究! |
| | | // */ |
| | | // |
| | | //package com.iailab.module.common.config; |
| | | // |
| | | //import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; |
| | | //import com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor; |
| | | //import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor; |
| | | //import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; |
| | | //import com.iailab.module.common.interceptor.DataFilterInterceptor; |
| | | //import org.springframework.context.annotation.Bean; |
| | | //import org.springframework.context.annotation.Configuration; |
| | | // |
| | | ///** |
| | | // * mybatis-plus配置 |
| | | // * |
| | | // * @author Mark sunlightcs@gmail.com |
| | | // */ |
| | | //@Configuration |
| | | //public class MybatisPlusConfig { |
| | | // |
| | | // @Bean |
| | | // public MybatisPlusInterceptor mybatisPlusInterceptor() { |
| | | // MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor(); |
| | | // // 数据权限 |
| | | // mybatisPlusInterceptor.addInnerInterceptor(new DataFilterInterceptor()); |
| | | // // 分页插件 |
| | | // mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor()); |
| | | // // 乐观锁 |
| | | // mybatisPlusInterceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor()); |
| | | // // 防止全表更新与删除 |
| | | // mybatisPlusInterceptor.addInnerInterceptor(new BlockAttackInnerInterceptor()); |
| | | // |
| | | // return mybatisPlusInterceptor; |
| | | // } |
| | | // |
| | | //} |
对比新文件 |
| | |
| | | ///** |
| | | // * Copyright (c) 2018 人人开源 All rights reserved. |
| | | // * |
| | | // * https://www.renren.io |
| | | // * |
| | | // * 版权所有,侵权必究! |
| | | // */ |
| | | // |
| | | //package com.iailab.common.config; |
| | | // |
| | | //import com.github.xiaoymin.knife4j.spring.extension.OpenApiExtensionResolver; |
| | | //import com.iailab.framework.common.constant.Constant; |
| | | //import io.swagger.annotations.ApiOperation; |
| | | //import lombok.AllArgsConstructor; |
| | | //import org.springframework.context.annotation.Bean; |
| | | //import org.springframework.context.annotation.Configuration; |
| | | //import springfox.documentation.builders.ApiInfoBuilder; |
| | | //import springfox.documentation.builders.PathSelectors; |
| | | //import springfox.documentation.builders.RequestHandlerSelectors; |
| | | //import springfox.documentation.service.ApiInfo; |
| | | //import springfox.documentation.service.ApiKey; |
| | | //import springfox.documentation.spi.DocumentationType; |
| | | //import springfox.documentation.spring.web.plugins.Docket; |
| | | //import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc; |
| | | // |
| | | //import java.util.List; |
| | | // |
| | | ///** |
| | | // * Swagger配置 |
| | | // * |
| | | // * @author Mark sunlightcs@gmail.com |
| | | // */ |
| | | //@Configuration |
| | | //@EnableSwagger2WebMvc |
| | | //@AllArgsConstructor |
| | | //public class SwaggerConfig { |
| | | // private final OpenApiExtensionResolver openApiExtensionResolver; |
| | | // |
| | | // @Bean |
| | | // public Docket createRestApi() { |
| | | // return new Docket(DocumentationType.SWAGGER_2) |
| | | // .apiInfo(apiInfo()) |
| | | // .select() |
| | | // //加了ApiOperation注解的类,生成接口文档 |
| | | // .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) |
| | | // //包下的类,生成接口文档 |
| | | // //.apis(RequestHandlerSelectors.basePackage("io.renren.modules.job.controller")) |
| | | // .paths(PathSelectors.any()) |
| | | // .build() |
| | | // .extensions(openApiExtensionResolver.buildExtensions("Renren")) |
| | | // .directModelSubstitute(java.util.Date.class, String.class) |
| | | // .securitySchemes(security()); |
| | | // } |
| | | // |
| | | // private ApiInfo apiInfo() { |
| | | // return new ApiInfoBuilder() |
| | | // .title("人人开源") |
| | | // .description("renren-admin文档") |
| | | // .termsOfServiceUrl("https://www.renren.io") |
| | | // .version("5.x") |
| | | // .build(); |
| | | // } |
| | | // |
| | | // private List<ApiKey> security() { |
| | | // return newArrayList( |
| | | // new ApiKey(Constant.TOKEN_HEADER, Constant.TOKEN_HEADER, "header") |
| | | // ); |
| | | // } |
| | | //} |
对比新文件 |
| | |
| | | package com.iailab.module.data.common.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | public class IndexQueryDTO { |
| | | |
| | | private Date startDate; |
| | | |
| | | private Date endDate; |
| | | |
| | | private String code; |
| | | |
| | | private Integer granularity; |
| | | |
| | | private List<String> codes; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.common.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | | public class IndexStatisticDTO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | public Date dateTime; |
| | | public BigDecimal data; |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.common.dto.echarts; |
| | | |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author lirm |
| | | * @Description |
| | | * @createTime 2023.05.11 |
| | | */ |
| | | @Data |
| | | @Tag(name = "图表") |
| | | public class BarLineDTO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | private String valueName;//表名称 |
| | | |
| | | private List<String> legend;//线的名称 |
| | | |
| | | private List<String> categories;//X轴数据 |
| | | |
| | | private List<SeriesItem> series;//Y轴数据集合 |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.common.dto.echarts; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author lirm |
| | | * @Description |
| | | * @createTime 2023.05.11 |
| | | */ |
| | | @Data |
| | | public class SeriesItem { |
| | | |
| | | private String name; |
| | | |
| | | private List<Object[]> data; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.common.dto.vue; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2023年05月15日 13:46:00 |
| | | */ |
| | | @Data |
| | | public class CascaderOptionDTO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | private String value; |
| | | |
| | | private String label; |
| | | |
| | | private List<CascaderOptionDTO> children; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.common.enums; |
| | | |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * @Description: 通用常量 |
| | | */ |
| | | public interface CommonConstant { |
| | | |
| | | String CJS_SYS = "system"; |
| | | |
| | | String HTTP_CLIENT_ID_XST = "xsteam"; |
| | | |
| | | String HTTP_CLIENT_ID_SD = "sd"; |
| | | |
| | | String HTTP_CLIENT_ID_OADP = "oadp"; |
| | | |
| | | String HTTP_CLIENT_ID_FXJY = "fxjy"; |
| | | |
| | | String HTTP_CLIENT_ID_ELELOW = "elelow"; |
| | | |
| | | String HTTP_RESULT_TRUE = "true"; |
| | | //常量点 |
| | | String CONSTANT = "CONSTANT"; |
| | | //计量点 |
| | | String MEASURE = "MEASURE"; |
| | | //计算点 |
| | | String CALCULATE = "CALCULATE"; |
| | | |
| | | BigDecimal BAD_VALUE = new BigDecimal("-2"); |
| | | |
| | | BigDecimal ZERO_VALUE = new BigDecimal("0"); |
| | | |
| | | |
| | | //年生产计划执行数据 |
| | | String YEAR_PEI_HTTP_TAG = "yearPeiHttpTag"; |
| | | //当前产量 |
| | | String CURRENT_PERFORMANCE_HTTP_TAG = "currentPerformanceHttpTag"; |
| | | //生产时间分布 |
| | | String PRD_TIME_DIST_HTTP_TAG = "prdTimeDistHttpTag"; |
| | | //当前销量 |
| | | String CURRENT_SALE_HTTP_TAG = "currentSaleHttpTag"; |
| | | |
| | | String HTTP_API_ZXZK_IH = "ZXZK_IH"; |
| | | |
| | | String HTTP_API_SD_RUN_STATE = "SDRunState"; |
| | | |
| | | String HTTP_API_SD_HEALTH_STATE = "SDHealthState"; |
| | | |
| | | String HTTP_API_SD_DEVICE_LIST = "SDDeviceList"; |
| | | |
| | | String HTTP_API_SD_DEVICE_TEMPERATURE = "SDDeviceTemperature"; |
| | | |
| | | String HTTP_API_ZX_DEVICE_ELECTRIC = "ZXDeviceElectric"; |
| | | |
| | | String HTTP_API_PERSON_LIST = "PersonList"; |
| | | |
| | | String HTTP_API_JOB_LIST = "JobList"; |
| | | |
| | | //年 |
| | | String YEAR = "year"; |
| | | //月 |
| | | String MONTH = "month"; |
| | | |
| | | //下划线 |
| | | String UNDERLINE = "_"; |
| | | //$符 |
| | | String DOLLAR = "$"; |
| | | |
| | | /** |
| | | * 启用 |
| | | */ |
| | | public static final int IS_ENABLE = 1; |
| | | |
| | | /** |
| | | * 删除标志 |
| | | */ |
| | | public static final Integer BPM_FLAG_1 = 1; |
| | | |
| | | /** |
| | | * 正常状态 |
| | | */ |
| | | public static final Integer STATUS_NORMAL = 0; |
| | | |
| | | /** |
| | | * 禁用状态 |
| | | */ |
| | | public static final Integer STATUS_DISABLE = -1; |
| | | |
| | | /** |
| | | * 删除标志 |
| | | */ |
| | | public static final Integer DEL_FLAG_1 = 1; |
| | | |
| | | /** |
| | | * 未删除 |
| | | */ |
| | | public static final Integer DEL_FLAG_0 = 0; |
| | | |
| | | /** |
| | | * 未提交 |
| | | */ |
| | | public static final Integer SUBMINT_STATUS_0 = 0; |
| | | |
| | | /** |
| | | * 系统日志类型: 登录 |
| | | */ |
| | | public static final int LOG_TYPE_1 = 1; |
| | | |
| | | /** |
| | | * 系统日志类型: 操作 |
| | | */ |
| | | public static final int LOG_TYPE_2 = 2; |
| | | |
| | | /** |
| | | * 操作日志类型: 查询 |
| | | */ |
| | | public static final int OPERATE_TYPE_1 = 1; |
| | | |
| | | /** |
| | | * 操作日志类型: 添加 |
| | | */ |
| | | public static final int OPERATE_TYPE_2 = 2; |
| | | |
| | | /** |
| | | * 操作日志类型: 更新 |
| | | */ |
| | | public static final int OPERATE_TYPE_3 = 3; |
| | | |
| | | /** |
| | | * 操作日志类型: 删除 |
| | | */ |
| | | public static final int OPERATE_TYPE_4 = 4; |
| | | |
| | | /** |
| | | * 操作日志类型: 倒入 |
| | | */ |
| | | public static final int OPERATE_TYPE_5 = 5; |
| | | |
| | | /** |
| | | * 操作日志类型: 导出 |
| | | */ |
| | | public static final int OPERATE_TYPE_6 = 6; |
| | | |
| | | /** |
| | | * 提交 |
| | | */ |
| | | public static final int SUBMIT_FLAG_1 = 1; |
| | | |
| | | /** |
| | | * 通过 |
| | | */ |
| | | public static final int SUBMIT_FLAG_2 = 2; |
| | | |
| | | /** |
| | | * 驳回 |
| | | */ |
| | | public static final int SUBMIT_FLAG_3 = 3; |
| | | |
| | | /** |
| | | * 提交 |
| | | */ |
| | | public static final int SUBMIT_FLAG_0 = 0; |
| | | |
| | | public static final int SUBMIT_FLAG_4 = 4; |
| | | |
| | | public static final int SUBMIT_FLAG_5 = 5; |
| | | |
| | | public static final int SUBMIT_FLAG_6 = 6; |
| | | |
| | | public static final Integer DANGER_STATUS = 1; |
| | | |
| | | public static final Integer DANGER_STATUS_2 = 2; |
| | | |
| | | |
| | | /** |
| | | * {@code 500 Server Error} (HTTP/1.0 - RFC 1945) |
| | | */ |
| | | public static final Integer SC_INTERNAL_SERVER_ERROR_500 = 500; |
| | | /** |
| | | * {@code 200 OK} (HTTP/1.0 - RFC 1945) |
| | | */ |
| | | public static final Integer SC_OK_200 = 200; |
| | | |
| | | /** |
| | | * 访问权限认证未通过 510 |
| | | */ |
| | | public static final Integer SC_JEECG_NO_AUTHZ = 510; |
| | | |
| | | /** |
| | | * 登录用户Shiro权限缓存KEY前缀 |
| | | */ |
| | | public static String PREFIX_USER_SHIRO_CACHE = "shiro:cache:org.jeecg.config.shiro.ShiroRealm.authorizationCache:"; |
| | | /** |
| | | * 登录用户Token令牌缓存KEY前缀 |
| | | */ |
| | | public static final String PREFIX_USER_TOKEN = "prefix_user_token_"; |
| | | // /** Token缓存时间:3600秒即一小时 */ |
| | | // public static final int TOKEN_EXPIRE_TIME = 3600; |
| | | |
| | | /** |
| | | * 登录二维码 |
| | | */ |
| | | public static final String LOGIN_QRCODE_PRE = "QRCODELOGIN:"; |
| | | public static final String LOGIN_QRCODE = "LQ:"; |
| | | /** |
| | | * 登录二维码token |
| | | */ |
| | | public static final String LOGIN_QRCODE_TOKEN = "LQT:"; |
| | | |
| | | |
| | | /** |
| | | * 0:一级菜单 |
| | | */ |
| | | public static final Integer MENU_TYPE_0 = 0; |
| | | /** |
| | | * 1:子菜单 |
| | | */ |
| | | public static final Integer MENU_TYPE_1 = 1; |
| | | /** |
| | | * 2:按钮权限 |
| | | */ |
| | | public static final Integer MENU_TYPE_2 = 2; |
| | | |
| | | /** |
| | | * 通告对象类型(USER:指定用户,ALL:全体用户) |
| | | */ |
| | | public static final String MSG_TYPE_UESR = "USER"; |
| | | public static final String MSG_TYPE_ALL = "ALL"; |
| | | |
| | | /** |
| | | * 发布状态(0未发布,1已发布,2已撤销) |
| | | */ |
| | | public static final String NO_SEND = "0"; |
| | | public static final String HAS_SEND = "1"; |
| | | public static final String HAS_CANCLE = "2"; |
| | | |
| | | /** |
| | | * 阅读状态(0未读,1已读) |
| | | */ |
| | | public static final String HAS_READ_FLAG = "1"; |
| | | public static final String NO_READ_FLAG = "0"; |
| | | |
| | | /** |
| | | * 优先级(L低,M中,H高) |
| | | */ |
| | | public static final String PRIORITY_L = "L"; |
| | | public static final String PRIORITY_M = "M"; |
| | | public static final String PRIORITY_H = "H"; |
| | | |
| | | /** |
| | | * 短信模板方式 0 .登录模板、1.注册模板、2.忘记密码模板 |
| | | */ |
| | | public static final String SMS_TPL_TYPE_0 = "0"; |
| | | public static final String SMS_TPL_TYPE_1 = "1"; |
| | | public static final String SMS_TPL_TYPE_2 = "2"; |
| | | |
| | | /** |
| | | * 状态(0无效1有效) |
| | | */ |
| | | public static final String STATUS_0 = "0"; |
| | | public static final String STATUS_1 = "1"; |
| | | |
| | | /** |
| | | * 状态(0无效1有效) |
| | | */ |
| | | public static final Integer INT_STATUS_0 = 0; |
| | | public static final Integer INT_STATUS_1 = 1; |
| | | |
| | | /** |
| | | * 同步工作流引擎1同步0不同步 |
| | | */ |
| | | public static final Integer ACT_SYNC_1 = 1; |
| | | public static final Integer ACT_SYNC_0 = 0; |
| | | |
| | | /** |
| | | * 消息类型1:通知公告2:系统消息 |
| | | */ |
| | | public static final String MSG_CATEGORY_1 = "1"; |
| | | public static final String MSG_CATEGORY_2 = "2"; |
| | | |
| | | /** |
| | | * 是否配置菜单的数据权限 1是0否 |
| | | */ |
| | | public static final Integer RULE_FLAG_0 = 0; |
| | | public static final Integer RULE_FLAG_1 = 1; |
| | | |
| | | /** |
| | | * 是否用户已被冻结 1正常(解冻) 2冻结 |
| | | */ |
| | | public static final Integer USER_UNFREEZE = 1; |
| | | public static final Integer USER_FREEZE = 2; |
| | | |
| | | /** |
| | | * 字典翻译文本后缀 |
| | | */ |
| | | public static final String DICT_TEXT_SUFFIX = "_dictText"; |
| | | |
| | | /** |
| | | * 表单设计器主表类型 |
| | | */ |
| | | public static final Integer DESIGN_FORM_TYPE_MAIN = 1; |
| | | |
| | | /** |
| | | * 表单设计器子表表类型 |
| | | */ |
| | | public static final Integer DESIGN_FORM_TYPE_SUB = 2; |
| | | |
| | | /** |
| | | * 表单设计器URL授权通过 |
| | | */ |
| | | public static final Integer DESIGN_FORM_URL_STATUS_PASSED = 1; |
| | | |
| | | /** |
| | | * 表单设计器URL授权未通过 |
| | | */ |
| | | public static final Integer DESIGN_FORM_URL_STATUS_NOT_PASSED = 2; |
| | | |
| | | /** |
| | | * 表单设计器新增 Flag |
| | | */ |
| | | public static final String DESIGN_FORM_URL_TYPE_ADD = "add"; |
| | | /** |
| | | * 表单设计器修改 Flag |
| | | */ |
| | | public static final String DESIGN_FORM_URL_TYPE_EDIT = "edit"; |
| | | /** |
| | | * 表单设计器详情 Flag |
| | | */ |
| | | public static final String DESIGN_FORM_URL_TYPE_DETAIL = "detail"; |
| | | /** |
| | | * 表单设计器复用数据 Flag |
| | | */ |
| | | public static final String DESIGN_FORM_URL_TYPE_REUSE = "reuse"; |
| | | /** |
| | | * 表单设计器编辑 Flag (已弃用) |
| | | */ |
| | | public static final String DESIGN_FORM_URL_TYPE_VIEW = "view"; |
| | | |
| | | /** |
| | | * online参数值设置(是:Y, 否:N) |
| | | */ |
| | | public static final String ONLINE_PARAM_VAL_IS_TURE = "Y"; |
| | | public static final String ONLINE_PARAM_VAL_IS_FALSE = "N"; |
| | | |
| | | /** |
| | | * 文件上传类型(本地:local,Minio:minio,阿里云:alioss) |
| | | */ |
| | | public static final String UPLOAD_TYPE_LOCAL = "local"; |
| | | public static final String UPLOAD_TYPE_MINIO = "minio"; |
| | | public static final String UPLOAD_TYPE_OSS = "alioss"; |
| | | |
| | | /** |
| | | * 文档上传自定义桶名称 |
| | | */ |
| | | public static final String UPLOAD_CUSTOM_BUCKET = "eoafile"; |
| | | /** |
| | | * 文档上传自定义路径 |
| | | */ |
| | | public static final String UPLOAD_CUSTOM_PATH = "eoafile"; |
| | | /** |
| | | * 文件外链接有效天数 |
| | | */ |
| | | public static final Integer UPLOAD_EFFECTIVE_DAYS = 1; |
| | | |
| | | /** |
| | | * 员工身份 (1:普通员工 2:上级) |
| | | */ |
| | | public static final Integer USER_IDENTITY_1 = 1; |
| | | public static final Integer USER_IDENTITY_2 = 2; |
| | | |
| | | /** |
| | | * sys_user 表 username 唯一键索引 |
| | | */ |
| | | public static final String SQL_INDEX_UNIQ_SYS_USER_USERNAME = "uniq_sys_user_username"; |
| | | /** |
| | | * sys_user 表 work_no 唯一键索引 |
| | | */ |
| | | public static final String SQL_INDEX_UNIQ_SYS_USER_WORK_NO = "uniq_sys_user_work_no"; |
| | | /** |
| | | * sys_user 表 phone 唯一键索引 |
| | | */ |
| | | public static final String SQL_INDEX_UNIQ_SYS_USER_PHONE = "uniq_sys_user_phone"; |
| | | /** |
| | | * 达梦数据库升提示。违反表[SYS_USER]唯一性约束 |
| | | */ |
| | | public static final String SQL_INDEX_UNIQ_SYS_USER = "唯一性约束"; |
| | | |
| | | /** |
| | | * sys_user 表 email 唯一键索引 |
| | | */ |
| | | public static final String SQL_INDEX_UNIQ_SYS_USER_EMAIL = "uniq_sys_user_email"; |
| | | /** |
| | | * sys_quartz_job 表 job_class_name 唯一键索引 |
| | | */ |
| | | public static final String SQL_INDEX_UNIQ_JOB_CLASS_NAME = "uniq_job_class_name"; |
| | | /** |
| | | * sys_position 表 code 唯一键索引 |
| | | */ |
| | | public static final String SQL_INDEX_UNIQ_CODE = "uniq_code"; |
| | | /** |
| | | * sys_role 表 code 唯一键索引 |
| | | */ |
| | | public static final String SQL_INDEX_UNIQ_SYS_ROLE_CODE = "uniq_sys_role_role_code"; |
| | | /** |
| | | * sys_depart 表 code 唯一键索引 |
| | | */ |
| | | public static final String SQL_INDEX_UNIQ_DEPART_ORG_CODE = "uniq_depart_org_code"; |
| | | /** |
| | | * sys_category 表 code 唯一键索引 |
| | | */ |
| | | public static final String SQL_INDEX_UNIQ_CATEGORY_CODE = "idx_sc_code"; |
| | | /** |
| | | * 在线聊天 是否为默认分组 |
| | | */ |
| | | public static final String IM_DEFAULT_GROUP = "1"; |
| | | /** |
| | | * 在线聊天 图片文件保存路径 |
| | | */ |
| | | public static final String IM_UPLOAD_CUSTOM_PATH = "imfile"; |
| | | /** |
| | | * 在线聊天 用户状态 |
| | | */ |
| | | public static final String IM_STATUS_ONLINE = "online"; |
| | | |
| | | /** |
| | | * 在线聊天 SOCKET消息类型 |
| | | */ |
| | | public static final String IM_SOCKET_TYPE = "chatMessage"; |
| | | |
| | | /** |
| | | * 在线聊天 是否开启默认添加好友 1是 0否 |
| | | */ |
| | | public static final String IM_DEFAULT_ADD_FRIEND = "1"; |
| | | |
| | | /** |
| | | * 在线聊天 用户好友缓存前缀 |
| | | */ |
| | | public static final String IM_PREFIX_USER_FRIEND_CACHE = "sys:cache:im:im_prefix_user_friend_"; |
| | | |
| | | /** |
| | | * 考勤补卡业务状态 (1:同意 2:不同意) |
| | | */ |
| | | public static final String SIGN_PATCH_BIZ_STATUS_1 = "1"; |
| | | public static final String SIGN_PATCH_BIZ_STATUS_2 = "2"; |
| | | |
| | | /** |
| | | * 公文文档上传自定义路径 |
| | | */ |
| | | public static final String UPLOAD_CUSTOM_PATH_OFFICIAL = "officialdoc"; |
| | | /** |
| | | * 公文文档下载自定义路径 |
| | | */ |
| | | public static final String DOWNLOAD_CUSTOM_PATH_OFFICIAL = "officaldown"; |
| | | |
| | | /** |
| | | * WPS存储值类别(1 code文号 2 text(WPS模板还是公文发文模板)) |
| | | */ |
| | | public static final String WPS_TYPE_1 = "1"; |
| | | public static final String WPS_TYPE_2 = "2"; |
| | | |
| | | |
| | | public final static String X_ACCESS_TOKEN = "X-Access-Token"; |
| | | public final static String X_SIGN = "X-Sign"; |
| | | public final static String X_TIMESTAMP = "X-TIMESTAMP"; |
| | | public final static String TOKEN_IS_INVALID_MSG = "Token失效,请重新登录!"; |
| | | |
| | | /** |
| | | * 多租户 请求头 |
| | | */ |
| | | public final static String TENANT_ID = "tenant-id"; |
| | | |
| | | /** |
| | | * 微服务读取配置文件属性 服务地址 |
| | | */ |
| | | public final static String CLOUD_SERVER_KEY = "spring.cloud.nacos.discovery.server-addr"; |
| | | |
| | | /** |
| | | * 第三方登录 验证密码/创建用户 都需要设置一个操作码 防止被恶意调用 |
| | | */ |
| | | public final static String THIRD_LOGIN_CODE = "third_login_code"; |
| | | |
| | | /** |
| | | * 第三方APP同步方向:本地 --> 第三方APP |
| | | */ |
| | | String THIRD_SYNC_TO_APP = "SYNC_TO_APP"; |
| | | /** |
| | | * 第三方APP同步方向:第三方APP --> 本地 |
| | | */ |
| | | String THIRD_SYNC_TO_LOCAL = "SYNC_TO_LOCAL"; |
| | | |
| | | /** |
| | | * 系统通告消息状态:0=未发布 |
| | | */ |
| | | String ANNOUNCEMENT_SEND_STATUS_0 = "0"; |
| | | /** |
| | | * 系统通告消息状态:1=已发布 |
| | | */ |
| | | String ANNOUNCEMENT_SEND_STATUS_1 = "1"; |
| | | /** |
| | | * 系统通告消息状态:2=已撤销 |
| | | */ |
| | | String ANNOUNCEMENT_SEND_STATUS_2 = "2"; |
| | | |
| | | /** |
| | | * ONLINE 报表权限用 从request中获取地址栏后的参数 |
| | | */ |
| | | String ONL_REP_URL_PARAM_STR = "onlRepUrlParamStr"; |
| | | |
| | | /** |
| | | * POST请求 |
| | | */ |
| | | String HTTP_POST = "POST"; |
| | | |
| | | /** |
| | | * PUT请求 |
| | | */ |
| | | String HTTP_PUT = "PUT"; |
| | | |
| | | /** |
| | | * PATCH请求 |
| | | */ |
| | | String HTTP_PATCH = "PATCH"; |
| | | |
| | | /** |
| | | * 未知的 |
| | | */ |
| | | String UNKNOWN = "unknown"; |
| | | |
| | | /** |
| | | * 字符串http |
| | | */ |
| | | String STR_HTTP = "http"; |
| | | |
| | | /** |
| | | * String 类型的空值 |
| | | */ |
| | | String STRING_NULL = "null"; |
| | | |
| | | /** |
| | | * java.util.Date 包 |
| | | */ |
| | | String JAVA_UTIL_DATE = "java.util.Date"; |
| | | |
| | | /** |
| | | * .do |
| | | */ |
| | | String SPOT_DO = ".do"; |
| | | |
| | | |
| | | /** |
| | | * 前端vue版本标识 |
| | | */ |
| | | String VERSION = "X-Version"; |
| | | |
| | | /** |
| | | * 前端vue版本 |
| | | */ |
| | | String VERSION_VUE3 = "vue3"; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.common.enums; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年06月26日 12:12:00 |
| | | */ |
| | | public class CommonDict { |
| | | |
| | | public static final Integer ONE = 1; |
| | | |
| | | public static final Integer TOW = 2; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.common.enums; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年05月12日 |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum DataSourceType { |
| | | OPCUA("OPCUA", "OPC UA"), |
| | | OPCDA("OPCDA", "OPC DA"), |
| | | ModBus("ModBus", "ModBus"), |
| | | KIO("KIO", "KIO"), |
| | | HTTP("HTTP", "HTTP"); |
| | | |
| | | private String code; |
| | | private String desc; |
| | | |
| | | public static DataSourceType getEumByCode(String code) { |
| | | if (code == null) { |
| | | return null; |
| | | } |
| | | |
| | | for (DataSourceType statusEnum : DataSourceType.values()) { |
| | | if (statusEnum.getCode().equals(code)) { |
| | | return statusEnum; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.common.enums; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2023年05月03日 19:10:00 |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum DataTypeEnum { |
| | | |
| | | INT("int"), |
| | | |
| | | FLOAT("float"), |
| | | |
| | | BOOLEAN("boolean"); |
| | | |
| | | private String code; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.common.enums; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @date 2021年09月01日 15:06 |
| | | */ |
| | | public enum DatabaseType { |
| | | DB2, MY_SQL, SQL_SERVER |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.common.enums; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2023年07月17日 17:41:00 |
| | | */ |
| | | public enum IsEnableEnum { |
| | | DISABLE(0), // 手动 |
| | | ENABLE(1); //自动 |
| | | |
| | | private Integer value; |
| | | |
| | | IsEnableEnum(Integer value) { |
| | | this.value = value; |
| | | } |
| | | |
| | | public Integer value() { |
| | | return this.value; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.common.enums; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年03月28日 17:46:00 |
| | | */ |
| | | public enum JsErrorCode { |
| | | Infinity, NaN |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.common.enums; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @date 2021年08月17日 11:28 |
| | | */ |
| | | public enum RequestMethodType { |
| | | |
| | | /** |
| | | * GET |
| | | */ |
| | | GET, |
| | | |
| | | /** |
| | | * POST |
| | | */ |
| | | POST |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.common.enums; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年06月25日 10:48:00 |
| | | */ |
| | | public class RowAction { |
| | | |
| | | public static final String ADD = "add"; |
| | | |
| | | public static final String UPDATE = "update"; |
| | | |
| | | public static final String DELETE = "delete"; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.common.enums; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2023年04月25日 15:43:00 |
| | | */ |
| | | public class TagValueTypeConstant { |
| | | |
| | | public static final String QUALITY_GOOD = "Good"; |
| | | |
| | | public static final String BOOLEAN = "Boolean"; |
| | | |
| | | public static final String INT8 = "Int8"; |
| | | |
| | | public static final String INT16 = "Int16"; |
| | | |
| | | public static final String INT32 = "Int32"; |
| | | |
| | | public static final String INT64 = "Int64"; |
| | | |
| | | public static final String UINT8 = "UInt8"; |
| | | |
| | | public static final String UINT16 = "UInt16"; |
| | | |
| | | public static final String UINT32 = "UInt32"; |
| | | |
| | | public static final String UINT64 = "UInt64"; |
| | | |
| | | public static final String FLOAT = "Float"; |
| | | |
| | | public static final String DOUBLE = "Double"; |
| | | |
| | | public static final String STRING = "String"; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.common.exception; |
| | | |
| | | /** |
| | | * 自定义异常 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | */ |
| | | public class RRException extends RuntimeException { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | private String msg; |
| | | private int code = 500; |
| | | |
| | | public RRException(String msg) { |
| | | super(msg); |
| | | this.msg = msg; |
| | | } |
| | | |
| | | public RRException(String msg, Throwable e) { |
| | | super(msg, e); |
| | | this.msg = msg; |
| | | } |
| | | |
| | | public RRException(String msg, int code) { |
| | | super(msg); |
| | | this.msg = msg; |
| | | this.code = code; |
| | | } |
| | | |
| | | public RRException(String msg, int code, Throwable e) { |
| | | super(msg, e); |
| | | this.msg = msg; |
| | | this.code = code; |
| | | } |
| | | |
| | | public String getMsg() { |
| | | return msg; |
| | | } |
| | | |
| | | public void setMsg(String msg) { |
| | | this.msg = msg; |
| | | } |
| | | |
| | | public int getCode() { |
| | | return code; |
| | | } |
| | | |
| | | public void setCode(int code) { |
| | | this.code = code; |
| | | } |
| | | |
| | | |
| | | } |
对比新文件 |
| | |
| | | //package com.iailab.common.exception; |
| | | // |
| | | //import com.iailab.common.utils.R; |
| | | //import org.apache.shiro.authz.AuthorizationException; |
| | | //import org.slf4j.Logger; |
| | | //import org.slf4j.LoggerFactory; |
| | | //import org.springframework.dao.DuplicateKeyException; |
| | | //import org.springframework.web.bind.annotation.ExceptionHandler; |
| | | //import org.springframework.web.bind.annotation.RestControllerAdvice; |
| | | //import org.springframework.web.servlet.NoHandlerFoundException; |
| | | // |
| | | ///** |
| | | // * 异常处理器 |
| | | // * |
| | | // * @author Mark sunlightcs@gmail.com |
| | | // */ |
| | | //@RestControllerAdvice |
| | | //public class RRExceptionHandler { |
| | | // private Logger logger = LoggerFactory.getLogger(getClass()); |
| | | // |
| | | // /** |
| | | // * 处理自定义异常 |
| | | // */ |
| | | // @ExceptionHandler(RRException.class) |
| | | // public R handleRRException(RRException e){ |
| | | // R r = new R(); |
| | | // r.put("code", e.getCode()); |
| | | // r.put("msg", e.getMessage()); |
| | | // |
| | | // return r; |
| | | // } |
| | | // |
| | | // @ExceptionHandler(NoHandlerFoundException.class) |
| | | // public R handlerNoFoundException(Exception e) { |
| | | // logger.error(e.getMessage(), e); |
| | | // return R.error(404, "路径不存在,请检查路径是否正确"); |
| | | // } |
| | | // |
| | | // @ExceptionHandler(DuplicateKeyException.class) |
| | | // public R handleDuplicateKeyException(DuplicateKeyException e){ |
| | | // logger.error(e.getMessage(), e); |
| | | // return R.error("数据库中已存在该记录"); |
| | | // } |
| | | // |
| | | // @ExceptionHandler(AuthorizationException.class) |
| | | // public R handleAuthorizationException(AuthorizationException e){ |
| | | // logger.error(e.getMessage(), e); |
| | | // return R.error("没有权限,请联系管理员授权"); |
| | | // } |
| | | // |
| | | // @ExceptionHandler(Exception.class) |
| | | // public R handleException(Exception e){ |
| | | // logger.error(e.getMessage(), e); |
| | | // return R.error(); |
| | | // } |
| | | //} |
对比新文件 |
| | |
| | | ///** |
| | | // * Copyright (c) 2018 人人开源 All rights reserved. |
| | | // * |
| | | // * https://www.renren.io |
| | | // * |
| | | // * 版权所有,侵权必究! |
| | | // */ |
| | | // |
| | | //package com.iailab.module.common.interceptor; |
| | | // |
| | | //import cn.hutool.core.util.StrUtil; |
| | | //import com.baomidou.mybatisplus.core.toolkit.PluginUtils; |
| | | //import com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor; |
| | | //import net.sf.jsqlparser.JSQLParserException; |
| | | //import net.sf.jsqlparser.expression.Expression; |
| | | //import net.sf.jsqlparser.expression.StringValue; |
| | | //import net.sf.jsqlparser.expression.operators.conditional.AndExpression; |
| | | //import net.sf.jsqlparser.parser.CCJSqlParserUtil; |
| | | //import net.sf.jsqlparser.statement.select.PlainSelect; |
| | | //import net.sf.jsqlparser.statement.select.Select; |
| | | //import org.apache.ibatis.executor.Executor; |
| | | //import org.apache.ibatis.mapping.BoundSql; |
| | | //import org.apache.ibatis.mapping.MappedStatement; |
| | | //import org.apache.ibatis.session.ResultHandler; |
| | | //import org.apache.ibatis.session.RowBounds; |
| | | // |
| | | //import java.util.Map; |
| | | // |
| | | ///** |
| | | // * 数据过滤 |
| | | // * |
| | | // * @author Mark sunlightcs@gmail.com |
| | | // */ |
| | | //public class DataFilterInterceptor implements InnerInterceptor { |
| | | // |
| | | // @Override |
| | | // public void beforeQuery(Executor executor, MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler, BoundSql boundSql) { |
| | | // DataScope scope = getDataScope(parameter); |
| | | // // 不进行数据过滤 |
| | | // if(scope == null || StrUtil.isBlank(scope.getSqlFilter())){ |
| | | // return; |
| | | // } |
| | | // |
| | | // // 拼接新SQL |
| | | // String buildSql = getSelect(boundSql.getSql(), scope); |
| | | // |
| | | // // 重写SQL |
| | | // PluginUtils.mpBoundSql(boundSql).sql(buildSql); |
| | | // } |
| | | // |
| | | // private DataScope getDataScope(Object parameter){ |
| | | // if (parameter == null){ |
| | | // return null; |
| | | // } |
| | | // |
| | | // // 判断参数里是否有DataScope对象 |
| | | // if (parameter instanceof Map) { |
| | | // Map<?, ?> parameterMap = (Map<?, ?>) parameter; |
| | | // for (Map.Entry entry : parameterMap.entrySet()) { |
| | | // if (entry.getValue() != null && entry.getValue() instanceof DataScope) { |
| | | // return (DataScope) entry.getValue(); |
| | | // } |
| | | // } |
| | | // } else if (parameter instanceof DataScope) { |
| | | // return (DataScope) parameter; |
| | | // } |
| | | // |
| | | // return null; |
| | | // } |
| | | // |
| | | // private String getSelect(String buildSql, DataScope scope){ |
| | | // try { |
| | | // Select select = (Select) CCJSqlParserUtil.parse(buildSql); |
| | | // PlainSelect plainSelect = (PlainSelect) select.getSelectBody(); |
| | | // |
| | | // Expression expression = plainSelect.getWhere(); |
| | | // if(expression == null){ |
| | | // plainSelect.setWhere(new StringValue(scope.getSqlFilter())); |
| | | // }else{ |
| | | // AndExpression andExpression = new AndExpression(expression, new StringValue(scope.getSqlFilter())); |
| | | // plainSelect.setWhere(andExpression); |
| | | // } |
| | | // |
| | | // return select.toString().replaceAll("'", ""); |
| | | // }catch (JSQLParserException e){ |
| | | // return buildSql; |
| | | // } |
| | | // } |
| | | //} |
对比新文件 |
| | |
| | | ///** |
| | | // * Copyright (c) 2018 人人开源 All rights reserved. |
| | | // * |
| | | // * https://www.renren.io |
| | | // * |
| | | // * 版权所有,侵权必究! |
| | | // */ |
| | | // |
| | | //package com.iailab.module.common.interceptor; |
| | | // |
| | | ///** |
| | | // * 数据范围 |
| | | // * |
| | | // * @author Mark sunlightcs@gmail.com |
| | | // * @since 1.0.0 |
| | | // */ |
| | | //public class DataScope { |
| | | // private String sqlFilter; |
| | | // |
| | | // public DataScope(String sqlFilter) { |
| | | // this.sqlFilter = sqlFilter; |
| | | // } |
| | | // |
| | | // public String getSqlFilter() { |
| | | // return sqlFilter; |
| | | // } |
| | | // |
| | | // public void setSqlFilter(String sqlFilter) { |
| | | // this.sqlFilter = sqlFilter; |
| | | // } |
| | | // |
| | | // @Override |
| | | // public String toString() { |
| | | // return this.sqlFilter; |
| | | // } |
| | | //} |
对比新文件 |
| | |
| | | package com.iailab.module.data.common.utils; |
| | | |
| | | /** |
| | | * 常量 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | */ |
| | | public class Constant { |
| | | /** 超级管理员ID */ |
| | | public static final String SUPER_ADMIN = "1"; |
| | | /** |
| | | * 当前页码 |
| | | */ |
| | | public static final String PAGE = "page"; |
| | | /** |
| | | * 每页显示记录数 |
| | | */ |
| | | public static final String LIMIT = "limit"; |
| | | /** |
| | | * 排序字段 |
| | | */ |
| | | public static final String ORDER_FIELD = "sidx"; |
| | | /** |
| | | * 排序方式 |
| | | */ |
| | | public static final String ORDER = "order"; |
| | | /** |
| | | * 升序 |
| | | */ |
| | | public static final String ASC = "asc"; |
| | | /** |
| | | * 菜单类型 |
| | | * |
| | | * @author chenshun |
| | | * @email sunlightcs@gmail.com |
| | | * @date 2016年11月15日 下午1:24:29 |
| | | */ |
| | | public enum MenuType { |
| | | /** |
| | | * 目录 |
| | | */ |
| | | CATALOG(0), |
| | | /** |
| | | * 菜单 |
| | | */ |
| | | MENU(1), |
| | | /** |
| | | * 按钮 |
| | | */ |
| | | BUTTON(2); |
| | | |
| | | private int value; |
| | | |
| | | MenuType(int value) { |
| | | this.value = value; |
| | | } |
| | | |
| | | public int getValue() { |
| | | return value; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 定时任务状态 |
| | | * |
| | | * @author chenshun |
| | | * @email sunlightcs@gmail.com |
| | | * @date 2016年12月3日 上午12:07:22 |
| | | */ |
| | | public enum ScheduleStatus { |
| | | /** |
| | | * 正常 |
| | | */ |
| | | NORMAL(0), |
| | | /** |
| | | * 暂停 |
| | | */ |
| | | PAUSE(1); |
| | | |
| | | private int value; |
| | | |
| | | ScheduleStatus(int value) { |
| | | this.value = value; |
| | | } |
| | | |
| | | public int getValue() { |
| | | return value; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 云服务商 |
| | | */ |
| | | public enum CloudService { |
| | | /** |
| | | * 七牛云 |
| | | */ |
| | | QINIU(1), |
| | | /** |
| | | * 阿里云 |
| | | */ |
| | | ALIYUN(2), |
| | | /** |
| | | * 腾讯云 |
| | | */ |
| | | QCLOUD(3); |
| | | |
| | | private int value; |
| | | |
| | | CloudService(int value) { |
| | | this.value = value; |
| | | } |
| | | |
| | | public int getValue() { |
| | | return value; |
| | | } |
| | | } |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.common.utils; |
| | | |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.lang.reflect.Field; |
| | | @Component |
| | | public class Conversion { |
| | | public static void convert(Object entity, Object dto) { |
| | | Class<?> entityClass = entity.getClass(); |
| | | Class<?> dtoClass = dto.getClass(); |
| | | Field[] entityFields = entityClass.getDeclaredFields(); |
| | | Field[] dtoFields = dtoClass.getDeclaredFields(); |
| | | try { |
| | | for (Field entityField : entityFields) { |
| | | entityField.setAccessible(true); |
| | | Object value = entityField.get(entity); |
| | | String name = entityField.getName(); |
| | | String dtoFieldName = name.substring(0, 1).toUpperCase() + name.substring(1); |
| | | for (Field dtoField : dtoFields) { |
| | | dtoField.setAccessible(true); |
| | | if (dtoField.getName().equals(dtoFieldName)) { |
| | | dtoField.set(dto, value); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | |
| | | } |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.common.utils; |
| | | |
| | | import org.apache.poi.hssf.usermodel.*; |
| | | import org.apache.poi.ss.usermodel.HorizontalAlignment; |
| | | import org.apache.poi.ss.usermodel.VerticalAlignment; |
| | | import org.apache.poi.ss.util.CellRangeAddress; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.io.OutputStream; |
| | | import java.lang.reflect.Field; |
| | | import java.util.List; |
| | | import java.util.logging.Level; |
| | | import java.util.logging.Logger; |
| | | |
| | | /** |
| | | * Excel 导出通用工具类 |
| | | * |
| | | * @author PanZhibao |
| | | * @date 2021年06月29日 9:06 |
| | | */ |
| | | public class ExcelUtil { |
| | | |
| | | /** |
| | | * 导出PointValueExcel |
| | | * |
| | | * @param sheetTitle |
| | | * @param title |
| | | * @param list |
| | | * @param response |
| | | * @return |
| | | */ |
| | | public static byte[] exportPointValue(String sheetTitle, String[] title, List<Object> list, HttpServletResponse response) { |
| | | |
| | | HSSFWorkbook wb = new HSSFWorkbook();//创建excel表 |
| | | HSSFSheet sheet = wb.createSheet(sheetTitle); |
| | | sheet.setDefaultColumnWidth(20);//设置默认行宽 |
| | | |
| | | //表头样式(加粗,水平居中,垂直居中) |
| | | HSSFCellStyle cellStyle = wb.createCellStyle(); |
| | | cellStyle.setAlignment(HorizontalAlignment.CENTER);//水平居中 |
| | | cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中 |
| | | |
| | | HSSFFont fontStyle = wb.createFont(); |
| | | |
| | | cellStyle.setFont(fontStyle); |
| | | |
| | | //标题样式(加粗,垂直居中) |
| | | HSSFCellStyle cellStyle2 = wb.createCellStyle(); |
| | | cellStyle2.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中 |
| | | cellStyle2.setFont(fontStyle); |
| | | |
| | | //字段样式(垂直居中) |
| | | HSSFCellStyle cellStyle3 = wb.createCellStyle(); |
| | | cellStyle3.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中 |
| | | |
| | | //数字样式 |
| | | HSSFCellStyle cellStyle4 = wb.createCellStyle(); |
| | | HSSFDataFormat df = wb.createDataFormat(); // 此处设置数据格式 |
| | | cellStyle4.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中 |
| | | cellStyle4.setDataFormat(df.getFormat("#,##0.000000"));//设置数值类型格式为保留两位小数 |
| | | |
| | | //创建表头 |
| | | HSSFRow row = sheet.createRow(0); |
| | | //row.setHeightInPoints(20);//行高 |
| | | |
| | | HSSFCell cell = row.createCell(0); |
| | | cell.setCellValue(sheetTitle); |
| | | cell.setCellStyle(cellStyle); |
| | | |
| | | sheet.addMergedRegion(new CellRangeAddress(0,0,0,(title.length-1))); |
| | | |
| | | //创建标题 |
| | | HSSFRow rowTitle = sheet.createRow(1); |
| | | //rowTitle.setHeightInPoints(20); |
| | | |
| | | HSSFCell hc; |
| | | for (int i = 0; i < title.length; i++) { |
| | | hc = rowTitle.createCell(i); |
| | | hc.setCellValue(title[i]); |
| | | hc.setCellStyle(cellStyle2); |
| | | } |
| | | |
| | | byte result[] = null; |
| | | |
| | | try { |
| | | //创建表格数据 |
| | | Field[] fields; |
| | | int i = 2; |
| | | for (Object obj : list) { |
| | | fields = obj.getClass().getDeclaredFields(); |
| | | |
| | | HSSFRow rowBody = sheet.createRow(i); |
| | | //rowBody.setHeightInPoints(20); |
| | | |
| | | int j = 0; |
| | | for (Field f : fields) { |
| | | |
| | | f.setAccessible(true); |
| | | |
| | | Object va = f.get(obj); |
| | | if (null == va) { |
| | | va = ""; |
| | | } |
| | | |
| | | hc = rowBody.createCell(j); |
| | | |
| | | if (j == 0) { |
| | | hc.setCellValue(Double.parseDouble(va.toString())); |
| | | hc.setCellStyle(cellStyle4); |
| | | } else { |
| | | hc.setCellValue(va.toString()); |
| | | hc.setCellStyle(cellStyle3); |
| | | } |
| | | |
| | | |
| | | j++; |
| | | } |
| | | |
| | | i++; |
| | | } |
| | | |
| | | //设置Http响应头告诉浏览器下载这个附件 |
| | | response.setHeader("Content-Disposition", "attachment;Filename=" + System.currentTimeMillis() + ".xls"); |
| | | OutputStream outputStream = response.getOutputStream(); |
| | | wb.write(outputStream); |
| | | outputStream.close(); |
| | | return wb.getBytes(); |
| | | } catch (Exception ex) { |
| | | Logger.getLogger(ExcelUtil.class.getName()).log(Level.SEVERE, null, ex); |
| | | return result; |
| | | } finally{ |
| | | try { |
| | | wb.close(); |
| | | } catch (IOException ex) { |
| | | Logger.getLogger(ExcelUtil.class.getName()).log(Level.SEVERE, null, ex); |
| | | } |
| | | } |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.common.utils; |
| | | |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | public class HttpContextUtils { |
| | | |
| | | public static HttpServletRequest getHttpServletRequest() { |
| | | return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
| | | } |
| | | |
| | | public static String getDomain(){ |
| | | HttpServletRequest request = getHttpServletRequest(); |
| | | StringBuffer url = request.getRequestURL(); |
| | | return url.delete(url.length() - request.getRequestURI().length(), url.length()).toString(); |
| | | } |
| | | |
| | | public static String getOrigin(){ |
| | | HttpServletRequest request = getHttpServletRequest(); |
| | | return request.getHeader("Origin"); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.common.utils; |
| | | |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.io.BufferedReader; |
| | | import java.io.IOException; |
| | | import java.io.InputStreamReader; |
| | | import java.io.PrintWriter; |
| | | import java.net.URL; |
| | | import java.net.URLConnection; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @date 2021年06月03日 15:31 |
| | | */ |
| | | public class HttpRequest { |
| | | /** |
| | | * 向指定URL发送GET方法的请求 |
| | | * |
| | | * @param url 发送请求的URL |
| | | * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 |
| | | * @return URL 所代表远程资源的响应结果 |
| | | */ |
| | | public static String sendGet(String url, String param) { |
| | | String result = ""; |
| | | BufferedReader in = null; |
| | | try { |
| | | String urlNameString = url + "?" + param; |
| | | URL realUrl = new URL(urlNameString); |
| | | // 打开和URL之间的连接 |
| | | URLConnection connection = realUrl.openConnection(); |
| | | // 设置通用的请求属性 |
| | | connection.setRequestProperty("accept", "*/*"); |
| | | connection.setRequestProperty("connection", "Keep-Alive"); |
| | | connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); |
| | | |
| | | // 建立实际的连接 |
| | | connection.connect(); |
| | | // 获取所有响应头字段 |
| | | Map<String, List<String>> map = connection.getHeaderFields(); |
| | | // 遍历所有的响应头字段 |
| | | for (String key : map.keySet()) { |
| | | System.out.println(key + "--->" + map.get(key)); |
| | | } |
| | | // 定义 BufferedReader输入流来读取URL的响应 |
| | | in = new BufferedReader(new InputStreamReader(connection.getInputStream())); |
| | | String line; |
| | | while ((line = in.readLine()) != null) { |
| | | result += line; |
| | | } |
| | | } catch (Exception e) { |
| | | System.out.println("发送GET请求出现异常!" + e); |
| | | e.printStackTrace(); |
| | | } |
| | | // 使用finally块来关闭输入流 |
| | | finally { |
| | | try { |
| | | if (in != null) { |
| | | in.close(); |
| | | } |
| | | } catch (Exception e2) { |
| | | e2.printStackTrace(); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | public static String sendGet(String url, Map<String, String> params, String authorization) { |
| | | String result = ""; |
| | | BufferedReader in = null; |
| | | try { |
| | | StringBuilder sb = new StringBuilder(); |
| | | sb.append(url); |
| | | if (!CollectionUtils.isEmpty(params)) { |
| | | sb.append("?"); |
| | | params.forEach((k, v) -> { |
| | | sb.append(k + "=" + v + "&"); |
| | | }); |
| | | sb.append("t=" + System.currentTimeMillis()); |
| | | } |
| | | String urlNameString = sb.toString(); |
| | | URL realUrl = new URL(urlNameString); |
| | | // 打开和URL之间的连接 |
| | | URLConnection connection = realUrl.openConnection(); |
| | | // 设置通用的请求属性 |
| | | connection.setRequestProperty("Authorization", authorization); |
| | | connection.setRequestProperty("accept", "*/*"); |
| | | connection.setRequestProperty("connection", "Keep-Alive"); |
| | | connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); |
| | | |
| | | // 建立实际的连接 |
| | | connection.connect(); |
| | | // 获取所有响应头字段 |
| | | Map<String, List<String>> map = connection.getHeaderFields(); |
| | | // 遍历所有的响应头字段 |
| | | for (String key : map.keySet()) { |
| | | System.out.println(key + "--->" + map.get(key)); |
| | | } |
| | | // 定义 BufferedReader输入流来读取URL的响应 |
| | | in = new BufferedReader(new InputStreamReader(connection.getInputStream())); |
| | | String line; |
| | | while ((line = in.readLine()) != null) { |
| | | result += line; |
| | | } |
| | | } catch (Exception e) { |
| | | System.out.println("发送GET请求出现异常!" + e); |
| | | e.printStackTrace(); |
| | | } |
| | | // 使用finally块来关闭输入流 |
| | | finally { |
| | | try { |
| | | if (in != null) { |
| | | in.close(); |
| | | } |
| | | } catch (Exception e2) { |
| | | e2.printStackTrace(); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 向指定 URL 发送POST方法的请求 |
| | | * |
| | | * @param url |
| | | * @param json |
| | | * @return |
| | | */ |
| | | public static String sendPost(String url, String json) { |
| | | PrintWriter out = null; |
| | | BufferedReader in = null; |
| | | String result = ""; |
| | | try { |
| | | URL realUrl = new URL(url); |
| | | // 打开和URL之间的连接 |
| | | URLConnection conn = realUrl.openConnection(); |
| | | // 设置通用的请求属性 |
| | | conn.setRequestProperty("accept", "*/*"); |
| | | conn.setRequestProperty("connection", "Keep-Alive"); |
| | | conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); |
| | | |
| | | // 发送POST请求必须设置如下两行 |
| | | conn.setDoOutput(true); |
| | | conn.setDoInput(true); |
| | | // 获取URLConnection对象对应的输出流 |
| | | out = new PrintWriter(conn.getOutputStream()); |
| | | // 发送请求参数 |
| | | out.print(json); |
| | | // flush输出流的缓冲 |
| | | out.flush(); |
| | | // 定义BufferedReader输入流来读取URL的响应 |
| | | in = new BufferedReader(new InputStreamReader(conn.getInputStream())); |
| | | String line; |
| | | while ((line = in.readLine()) != null) { |
| | | result += line; |
| | | } |
| | | } catch (Exception e) { |
| | | System.out.println("发送 POST 请求出现异常!" + e); |
| | | e.printStackTrace(); |
| | | } |
| | | //使用finally块来关闭输出流、输入流 |
| | | finally { |
| | | try { |
| | | if (out != null) { |
| | | out.close(); |
| | | } |
| | | if (in != null) { |
| | | in.close(); |
| | | } |
| | | } catch (IOException ex) { |
| | | ex.printStackTrace(); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 向指定 URL 发送POST方法的请求 |
| | | * |
| | | * @param url |
| | | * @param json |
| | | * @param authorization |
| | | * @return |
| | | */ |
| | | public static String sendPost(String url, String json, String authorization) { |
| | | PrintWriter out = null; |
| | | BufferedReader in = null; |
| | | String result = ""; |
| | | try { |
| | | URL realUrl = new URL(url); |
| | | // 打开和URL之间的连接 |
| | | URLConnection conn = realUrl.openConnection(); |
| | | // 设置通用的请求属性 |
| | | conn.setRequestProperty("Authorization", authorization); |
| | | conn.setRequestProperty("accept", "*/*"); |
| | | conn.setRequestProperty("connection", "Keep-Alive"); |
| | | conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); |
| | | |
| | | // 发送POST请求必须设置如下两行 |
| | | conn.setDoOutput(true); |
| | | conn.setDoInput(true); |
| | | // 获取URLConnection对象对应的输出流 |
| | | out = new PrintWriter(conn.getOutputStream()); |
| | | // 发送请求参数 |
| | | out.print(json); |
| | | // flush输出流的缓冲 |
| | | out.flush(); |
| | | // 定义BufferedReader输入流来读取URL的响应 |
| | | in = new BufferedReader(new InputStreamReader(conn.getInputStream())); |
| | | String line; |
| | | while ((line = in.readLine()) != null) { |
| | | result += line; |
| | | } |
| | | } catch (Exception e) { |
| | | System.out.println("发送 POST 请求出现异常!" + e); |
| | | e.printStackTrace(); |
| | | } |
| | | //使用finally块来关闭输出流、输入流 |
| | | finally { |
| | | try { |
| | | if (out != null) { |
| | | out.close(); |
| | | } |
| | | if (in != null) { |
| | | in.close(); |
| | | } |
| | | } catch (IOException ex) { |
| | | ex.printStackTrace(); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.common.utils; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.http.Header; |
| | | import org.apache.http.HttpEntity; |
| | | import org.apache.http.HttpResponse; |
| | | import org.apache.http.client.methods.HttpGet; |
| | | import org.apache.http.client.methods.HttpPost; |
| | | import org.apache.http.entity.StringEntity; |
| | | import org.apache.http.util.EntityUtils; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URLEncoder; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @date 2021年06月03日 16:40 |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class HttpsRequest { |
| | | |
| | | /** |
| | | * doGet |
| | | * |
| | | * @param url |
| | | * @param map |
| | | * @param charset |
| | | * @param token |
| | | * @return |
| | | */ |
| | | public String doGet(String url, Map<String, String> map, String charset, String token) { |
| | | org.apache.http.client.HttpClient httpClient = null; |
| | | HttpGet httpGet = null; |
| | | String result = null; |
| | | try { |
| | | httpClient = new SSLClient(); |
| | | StringBuilder sb = new StringBuilder(); |
| | | sb.append(url); |
| | | if (!CollectionUtils.isEmpty(map)) { |
| | | sb.append("?"); |
| | | map.forEach((k, v) -> { |
| | | try { |
| | | sb.append(k + "=" + URLEncoder.encode(v, charset) + "&"); |
| | | } catch (UnsupportedEncodingException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | }); |
| | | sb.append("t=" + System.currentTimeMillis()); |
| | | } |
| | | log.info("doGet,url=" + sb.toString()); |
| | | httpGet = new HttpGet(sb.toString()); |
| | | //设置参数 |
| | | httpGet.addHeader("Accept", "application/json"); |
| | | httpGet.addHeader("Content-Type", "application/json;charset=UTF-8"); |
| | | httpGet.addHeader("Authorization", token); |
| | | HttpResponse response = httpClient.execute(httpGet); |
| | | if (response != null) { |
| | | HttpEntity resEntity = response.getEntity(); |
| | | if (resEntity != null) { |
| | | result = EntityUtils.toString(resEntity, charset); |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * doGet |
| | | * |
| | | * @param url |
| | | * @param map |
| | | * @param charset |
| | | * @param authorization |
| | | * @return |
| | | */ |
| | | public String doGetKIO(String url, Map<String, String> map, String charset, String authorization) { |
| | | org.apache.http.client.HttpClient httpClient = null; |
| | | HttpGet httpGet = null; |
| | | String result = null; |
| | | try { |
| | | httpClient = new SSLClient(); |
| | | StringBuilder sb = new StringBuilder(); |
| | | sb.append(url); |
| | | if (!CollectionUtils.isEmpty(map)) { |
| | | sb.append("?"); |
| | | map.forEach((k, v) -> { |
| | | try { |
| | | sb.append(k + "=" + URLEncoder.encode(v, charset) + "&"); |
| | | } catch (UnsupportedEncodingException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | }); |
| | | sb.append("t=" + System.currentTimeMillis()); |
| | | } |
| | | log.info("doGet,url=" + sb.toString()); |
| | | httpGet = new HttpGet(sb.toString()); |
| | | //设置参数 |
| | | httpGet.addHeader("Accept", "application/json"); |
| | | httpGet.addHeader("Content-Type", "application/json;charset=UTF-8"); |
| | | httpGet.addHeader("Authorization", authorization); |
| | | HttpResponse response = httpClient.execute(httpGet); |
| | | if (response != null) { |
| | | HttpEntity resEntity = response.getEntity(); |
| | | if (resEntity != null) { |
| | | result = EntityUtils.toString(resEntity, charset); |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * doPost |
| | | * |
| | | * @param url |
| | | * @param map |
| | | * @param json |
| | | * @param charset |
| | | * @param token |
| | | * @return |
| | | */ |
| | | public String doPost(String url, Map<String, String> map, String json, String charset, String token) { |
| | | org.apache.http.client.HttpClient httpClient = null; |
| | | HttpPost httpPost = null; |
| | | String result = null; |
| | | try { |
| | | httpClient = new SSLClient(); |
| | | StringBuilder sb = new StringBuilder(); |
| | | sb.append(url); |
| | | if (!CollectionUtils.isEmpty(map)) { |
| | | sb.append("?"); |
| | | map.forEach((k, v) -> { |
| | | try { |
| | | sb.append(k + "=" + URLEncoder.encode(v, charset) + "&"); |
| | | } catch (UnsupportedEncodingException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | }); |
| | | sb.append("t=" + System.currentTimeMillis()); |
| | | } |
| | | httpPost = new HttpPost(sb.toString()); |
| | | //设置参数 |
| | | httpPost.addHeader("Accept", "application/json"); |
| | | httpPost.addHeader("Content-Type", "application/json;charset=UTF-8"); |
| | | httpPost.addHeader("token", token); |
| | | StringEntity stringEntity = new StringEntity(json); |
| | | stringEntity.setContentEncoding("UTF-8"); |
| | | stringEntity.setContentType("application/json"); |
| | | httpPost.setEntity(stringEntity); |
| | | HttpResponse response = httpClient.execute(httpPost); |
| | | if (response != null) { |
| | | HttpEntity resEntity = response.getEntity(); |
| | | if (resEntity != null) { |
| | | result = EntityUtils.toString(resEntity, charset); |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | // ex.printStackTrace(); |
| | | log.info("doPost失败,url=" + url); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * doPost |
| | | * |
| | | * @param url |
| | | * @param map |
| | | * @param json |
| | | * @param charset |
| | | * @param authorization |
| | | * @return |
| | | */ |
| | | public String doPostKIO(String url, Map<String, String> map, String json, String charset, String authorization) { |
| | | org.apache.http.client.HttpClient httpClient = null; |
| | | HttpPost httpPost = null; |
| | | String result = null; |
| | | try { |
| | | httpClient = new SSLClient(); |
| | | StringBuilder sb = new StringBuilder(); |
| | | sb.append(url); |
| | | if (!CollectionUtils.isEmpty(map)) { |
| | | sb.append("?"); |
| | | map.forEach((k, v) -> { |
| | | try { |
| | | sb.append(k + "=" + URLEncoder.encode(v, charset) + "&"); |
| | | } catch (UnsupportedEncodingException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | }); |
| | | sb.append("t=" + System.currentTimeMillis()); |
| | | } |
| | | httpPost = new HttpPost(sb.toString()); |
| | | //设置参数 |
| | | httpPost.addHeader("Accept", "application/json"); |
| | | httpPost.addHeader("Content-Type", "application/json;charset=UTF-8"); |
| | | httpPost.addHeader("Authorization", authorization); |
| | | StringEntity stringEntity = new StringEntity(json); |
| | | stringEntity.setContentEncoding("UTF-8"); |
| | | stringEntity.setContentType("application/json"); |
| | | httpPost.setEntity(stringEntity); |
| | | HttpResponse response = httpClient.execute(httpPost); |
| | | if (response != null) { |
| | | HttpEntity resEntity = response.getEntity(); |
| | | if (resEntity != null) { |
| | | result = EntityUtils.toString(resEntity, charset); |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * doPost |
| | | * |
| | | * @param url |
| | | * @param map |
| | | * @param json |
| | | * @param charset |
| | | * @param token |
| | | * @return |
| | | */ |
| | | public String doPostAuthorization(String url, Map<String, String> map, String json, String charset, String token) { |
| | | org.apache.http.client.HttpClient httpClient = null; |
| | | HttpPost httpPost = null; |
| | | String result = null; |
| | | try { |
| | | httpClient = new SSLClient(); |
| | | StringBuilder sb = new StringBuilder(); |
| | | sb.append(url); |
| | | if (!CollectionUtils.isEmpty(map)) { |
| | | sb.append("?"); |
| | | map.forEach((k, v) -> { |
| | | try { |
| | | sb.append(k + "=" + URLEncoder.encode(v, charset) + "&"); |
| | | } catch (UnsupportedEncodingException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | }); |
| | | sb.append("t=" + System.currentTimeMillis()); |
| | | } |
| | | httpPost = new HttpPost(sb.toString()); |
| | | //设置参数 |
| | | httpPost.addHeader("Accept", "application/json"); |
| | | httpPost.addHeader("Content-Type", "application/json;charset=UTF-8"); |
| | | httpPost.addHeader("Authorization", "Bearer{" + token + "}"); |
| | | StringEntity stringEntity = new StringEntity(json); |
| | | stringEntity.setContentEncoding("UTF-8"); |
| | | stringEntity.setContentType("application/json"); |
| | | httpPost.setEntity(stringEntity); |
| | | HttpResponse response = httpClient.execute(httpPost); |
| | | if (response != null) { |
| | | HttpEntity resEntity = response.getEntity(); |
| | | if (resEntity != null) { |
| | | result = EntityUtils.toString(resEntity, charset); |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * doPost |
| | | * |
| | | * @param url |
| | | * @param map |
| | | * @param json |
| | | * @param charset |
| | | * @return |
| | | */ |
| | | public String doPostToken(String url, Map<String, String> map, String json, String charset) { |
| | | org.apache.http.client.HttpClient httpClient = null; |
| | | HttpPost httpPost = null; |
| | | String result = null; |
| | | try { |
| | | httpClient = new SSLClient(); |
| | | StringBuilder sb = new StringBuilder(); |
| | | sb.append(url); |
| | | if (!CollectionUtils.isEmpty(map)) { |
| | | sb.append("?"); |
| | | map.forEach((k, v) -> { |
| | | try { |
| | | sb.append(k + "=" + URLEncoder.encode(v, charset) + "&"); |
| | | } catch (UnsupportedEncodingException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | }); |
| | | sb.append("t=" + System.currentTimeMillis()); |
| | | } |
| | | httpPost = new HttpPost(sb.toString()); |
| | | //设置参数 |
| | | httpPost.addHeader("Accept", "application/json"); |
| | | httpPost.addHeader("Content-Type", "application/json;charset=UTF-8"); |
| | | StringEntity stringEntity = new StringEntity(json); |
| | | stringEntity.setContentEncoding("UTF-8"); |
| | | stringEntity.setContentType("application/json"); |
| | | httpPost.setEntity(stringEntity); |
| | | HttpResponse response = httpClient.execute(httpPost); |
| | | if (response != null) { |
| | | Header[] resHeader = response.getHeaders("X-Auth-Tkn"); |
| | | if (resHeader != null) { |
| | | result = resHeader[0].getValue(); |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * doGet |
| | | * |
| | | * @param url |
| | | * @param map |
| | | * @param charset |
| | | * @param token |
| | | * @param tMap |
| | | * @return |
| | | */ |
| | | public String doGetSDData(String url, Map<String, String> map, String charset, String token, Map<String, String> tMap) { |
| | | org.apache.http.client.HttpClient httpClient = null; |
| | | HttpGet httpGet = null; |
| | | String result = null; |
| | | try { |
| | | httpClient = new SSLClient(); |
| | | StringBuilder sb = new StringBuilder(); |
| | | sb.append(url); |
| | | if (!CollectionUtils.isEmpty(map)) { |
| | | sb.append("?"); |
| | | map.forEach((k, v) -> { |
| | | try { |
| | | sb.append(k + "=" + URLEncoder.encode(v, charset) + "&"); |
| | | } catch (UnsupportedEncodingException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | }); |
| | | sb.append("t=" + System.currentTimeMillis()); |
| | | } |
| | | log.info("doGet,url=" + sb.toString()); |
| | | httpGet = new HttpGet(sb.toString()); |
| | | //设置参数 |
| | | httpGet.addHeader("Content-Type", "application/json"); |
| | | httpGet.addHeader("X-Auth-Tkn", token); |
| | | if(!Objects.isNull(tMap.get("X-Forwarded-OrgSet"))){ |
| | | httpGet.addHeader("X-Forwarded-OrgSet", tMap.get("X-Forwarded-OrgSet")); |
| | | } |
| | | if(!Objects.isNull(tMap.get("X-Forwarded-PrId"))){ |
| | | httpGet.addHeader("X-Forwarded-PrId", tMap.get("X-Forwarded-PrId")); |
| | | } |
| | | if(!Objects.isNull(tMap.get("X-Request-Id"))){ |
| | | httpGet.addHeader("X-Request-Id", tMap.get("X-Request-Id")); |
| | | } |
| | | HttpResponse response = httpClient.execute(httpGet); |
| | | if (response != null) { |
| | | HttpEntity resEntity = response.getEntity(); |
| | | if (resEntity != null) { |
| | | result = EntityUtils.toString(resEntity, charset); |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * doGet |
| | | * |
| | | * @param url |
| | | * @param map |
| | | * @param charset |
| | | * @param token |
| | | * @return |
| | | */ |
| | | public String doGetDeviceList(String url, Map<String, String> map, String charset, String token) { |
| | | org.apache.http.client.HttpClient httpClient = null; |
| | | HttpGet httpGet = null; |
| | | String result = null; |
| | | try { |
| | | httpClient = new SSLClient(); |
| | | StringBuilder sb = new StringBuilder(); |
| | | sb.append(url); |
| | | if (!CollectionUtils.isEmpty(map)) { |
| | | sb.append("?"); |
| | | map.forEach((k, v) -> { |
| | | try { |
| | | sb.append(k + "=" + URLEncoder.encode(v, charset) + "&"); |
| | | } catch (UnsupportedEncodingException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | }); |
| | | sb.append("t=" + System.currentTimeMillis()); |
| | | } |
| | | log.info("doGet,url=" + sb.toString()); |
| | | httpGet = new HttpGet(sb.toString()); |
| | | //设置参数 |
| | | httpGet.addHeader("Content-Type", "application/json"); |
| | | httpGet.addHeader("X-App-Secret", token); |
| | | HttpResponse response = httpClient.execute(httpGet); |
| | | if (response != null) { |
| | | HttpEntity resEntity = response.getEntity(); |
| | | if (resEntity != null) { |
| | | result = EntityUtils.toString(resEntity, charset); |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | } |
| | | return result; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.common.utils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.script.ScriptEngine; |
| | | import javax.script.ScriptException; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @date 2021年06月04日 16:01 |
| | | */ |
| | | @Component |
| | | public class JavaScriptHandler { |
| | | |
| | | @Resource |
| | | ScriptEngine scriptEngine; |
| | | |
| | | public String eval (String script) { |
| | | try { |
| | | return scriptEngine.eval(script).toString(); |
| | | } catch (ScriptException e) { |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.common.utils; |
| | | |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.math.BigInteger; |
| | | import java.security.MessageDigest; |
| | | import java.security.NoSuchAlgorithmException; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年06月05日 |
| | | */ |
| | | public class MD5Util { |
| | | |
| | | public static String getMD5Str(String str) { |
| | | byte[] digest = null; |
| | | try { |
| | | MessageDigest md5 = MessageDigest.getInstance("md5"); |
| | | digest = md5.digest(str.getBytes("utf-8")); |
| | | } catch (NoSuchAlgorithmException e) { |
| | | e.printStackTrace(); |
| | | } catch (UnsupportedEncodingException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | //16是表示转换为16进制数 |
| | | String md5Str = new BigInteger(1, digest).toString(16); |
| | | return md5Str; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.common.utils; |
| | | |
| | | import java.util.HashMap; |
| | | |
| | | |
| | | /** |
| | | * Map工具类 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | */ |
| | | public class MapUtils extends HashMap<String, Object> { |
| | | |
| | | @Override |
| | | public MapUtils put(String key, Object value) { |
| | | super.put(key, value); |
| | | return this; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.common.utils; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 分页工具类 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | */ |
| | | public class PageUtils implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 总记录数 |
| | | */ |
| | | private int total; |
| | | |
| | | /** |
| | | * 总记录数 |
| | | */ |
| | | private int totalCount; |
| | | /** |
| | | * 每页记录数 |
| | | */ |
| | | private int pageSize; |
| | | /** |
| | | * 总页数 |
| | | */ |
| | | private int totalPage; |
| | | /** |
| | | * 当前页数 |
| | | */ |
| | | private int currPage; |
| | | /** |
| | | * 列表数据 |
| | | */ |
| | | private List<?> list; |
| | | |
| | | /** |
| | | * 分页 |
| | | * @param list 列表数据 |
| | | * @param totalCount 总记录数 |
| | | * @param pageSize 每页记录数 |
| | | * @param currPage 当前页数 |
| | | */ |
| | | public PageUtils(List<?> list, int totalCount, int pageSize, int currPage) { |
| | | this.list = list; |
| | | this.total = totalCount; |
| | | this.totalCount = totalCount; |
| | | this.pageSize = pageSize; |
| | | this.currPage = currPage; |
| | | this.totalPage = (int)Math.ceil((double)totalCount/pageSize); |
| | | } |
| | | |
| | | /** |
| | | * 分页 |
| | | */ |
| | | public PageUtils(IPage<?> page) { |
| | | this.list = page.getRecords(); |
| | | this.total = (int)page.getTotal(); |
| | | this.totalCount = (int)page.getTotal(); |
| | | this.pageSize = (int)page.getSize(); |
| | | this.currPage = (int)page.getCurrent(); |
| | | this.totalPage = (int)page.getPages(); |
| | | } |
| | | |
| | | public int getTotal() { |
| | | return total; |
| | | } |
| | | |
| | | public void setTotal(int total) { |
| | | this.total = total; |
| | | } |
| | | public int getTotalCount() { |
| | | return totalCount; |
| | | } |
| | | |
| | | public void setTotalCount(int totalCount) { |
| | | this.totalCount = totalCount; |
| | | } |
| | | |
| | | public int getPageSize() { |
| | | return pageSize; |
| | | } |
| | | |
| | | public void setPageSize(int pageSize) { |
| | | this.pageSize = pageSize; |
| | | } |
| | | |
| | | public int getTotalPage() { |
| | | return totalPage; |
| | | } |
| | | |
| | | public void setTotalPage(int totalPage) { |
| | | this.totalPage = totalPage; |
| | | } |
| | | |
| | | public int getCurrPage() { |
| | | return currPage; |
| | | } |
| | | |
| | | public void setCurrPage(int currPage) { |
| | | this.currPage = currPage; |
| | | } |
| | | |
| | | public List<?> getList() { |
| | | return list; |
| | | } |
| | | |
| | | public void setList(List<?> list) { |
| | | this.list = list; |
| | | } |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.common.utils; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.metadata.OrderItem; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.iailab.module.data.common.xss.SQLFilter; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 查询参数 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | */ |
| | | public class Query<T> { |
| | | |
| | | public IPage<T> getPage(Map<String, Object> params) { |
| | | return this.getPage(params, null, false); |
| | | } |
| | | |
| | | public IPage<T> getPage(Map<String, Object> params, String defaultOrderField, boolean isAsc) { |
| | | //分页参数 |
| | | long curPage = 1; |
| | | long limit = 10; |
| | | |
| | | if(params.get(Constant.PAGE) != null){ |
| | | curPage = Long.parseLong((String)params.get(Constant.PAGE)); |
| | | } |
| | | if(params.get(Constant.LIMIT) != null){ |
| | | limit = Long.parseLong((String)params.get(Constant.LIMIT)); |
| | | } |
| | | |
| | | //分页对象 |
| | | Page<T> page = new Page<>(curPage, limit); |
| | | |
| | | //分页参数 |
| | | params.put(Constant.PAGE, page); |
| | | |
| | | //排序字段 |
| | | //防止SQL注入(因为sidx、order是通过拼接SQL实现排序的,会有SQL注入风险) |
| | | String orderField = SQLFilter.sqlInject((String)params.get(Constant.ORDER_FIELD)); |
| | | String order = (String)params.get(Constant.ORDER); |
| | | |
| | | |
| | | //前端字段排序 |
| | | if(StringUtils.isNotEmpty(orderField) && StringUtils.isNotEmpty(order)){ |
| | | if(Constant.ASC.equalsIgnoreCase(order)) { |
| | | return page.addOrder(OrderItem.asc(orderField)); |
| | | }else { |
| | | return page.addOrder(OrderItem.desc(orderField)); |
| | | } |
| | | } |
| | | |
| | | //没有排序字段,则不排序 |
| | | if(StringUtils.isBlank(defaultOrderField)){ |
| | | return page; |
| | | } |
| | | |
| | | //默认排序 |
| | | if(isAsc) { |
| | | page.addOrder(OrderItem.asc(defaultOrderField)); |
| | | }else { |
| | | page.addOrder(OrderItem.desc(defaultOrderField)); |
| | | } |
| | | |
| | | return page; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | * Copyright (c) 2016-2019 人人开源 All rights reserved. |
| | | * |
| | | * https://www.renren.io |
| | | * |
| | | * 版权所有,侵权必究! |
| | | */ |
| | | |
| | | package com.iailab.module.data.common.utils; |
| | | |
| | | import org.apache.http.HttpStatus; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 返回数据 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | */ |
| | | public class R extends HashMap<String, Object> { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | public R() { |
| | | put("code", 0); |
| | | put("msg", "success"); |
| | | } |
| | | |
| | | public static R error() { |
| | | return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "未知异常,请联系管理员"); |
| | | } |
| | | |
| | | public static R error(String msg) { |
| | | return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, msg); |
| | | } |
| | | |
| | | public static R error(int code, String msg) { |
| | | R r = new R(); |
| | | r.put("code", code); |
| | | r.put("msg", msg); |
| | | return r; |
| | | } |
| | | |
| | | public static R ok(String msg) { |
| | | R r = new R(); |
| | | r.put("msg", msg); |
| | | return r; |
| | | } |
| | | |
| | | public static R ok(Map<String, Object> map) { |
| | | R r = new R(); |
| | | r.putAll(map); |
| | | return r; |
| | | } |
| | | |
| | | public static R ok() { |
| | | return new R(); |
| | | } |
| | | |
| | | public R put(String key, Object value) { |
| | | super.put(key, value); |
| | | return this; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.common.utils; |
| | | |
| | | |
| | | import org.apache.http.conn.ClientConnectionManager; |
| | | import org.apache.http.conn.scheme.Scheme; |
| | | import org.apache.http.conn.scheme.SchemeRegistry; |
| | | import org.apache.http.conn.ssl.SSLSocketFactory; |
| | | import org.apache.http.impl.client.DefaultHttpClient; |
| | | |
| | | import javax.net.ssl.SSLContext; |
| | | import javax.net.ssl.TrustManager; |
| | | import javax.net.ssl.X509TrustManager; |
| | | import java.security.cert.CertificateException; |
| | | import java.security.cert.X509Certificate; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @date 2021年06月03日 15:35 |
| | | */ |
| | | public class SSLClient extends DefaultHttpClient { |
| | | public SSLClient() throws Exception { |
| | | super(); |
| | | //传输协议需要根据自己的判断 |
| | | SSLContext ctx = SSLContext.getInstance("TLS"); |
| | | X509TrustManager tm = new X509TrustManager() { |
| | | @Override |
| | | public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { |
| | | } |
| | | |
| | | @Override |
| | | public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { |
| | | } |
| | | |
| | | @Override |
| | | public X509Certificate[] getAcceptedIssuers() { |
| | | return null; |
| | | } |
| | | }; |
| | | ctx.init(null, new TrustManager[]{tm}, null); |
| | | SSLSocketFactory ssf = new SSLSocketFactory(ctx, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); |
| | | ClientConnectionManager ccm = this.getConnectionManager(); |
| | | SchemeRegistry sr = ccm.getSchemeRegistry(); |
| | | sr.register(new Scheme("https", 443, ssf)); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.common.utils; |
| | | |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | import javax.script.ScriptEngine; |
| | | import javax.script.ScriptEngineManager; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @date 2021年06月09日 16:38 |
| | | */ |
| | | @Configuration |
| | | public class ScriptEngineConfiguration { |
| | | |
| | | @Bean("scriptEngine") |
| | | public ScriptEngine scriptEngine() { |
| | | return new ScriptEngineManager().getEngineByName("javascript"); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.common.utils; |
| | | |
| | | import java.text.MessageFormat; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年05月12日 |
| | | */ |
| | | public class TagUtils { |
| | | |
| | | public static String genTagId(String sourceType, String sourceName, String tagNo) { |
| | | return MessageFormat.format("source={0};id={1}.{2}", sourceType, sourceName, tagNo); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.common.xss; |
| | | |
| | | import java.util.*; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.concurrent.ConcurrentMap; |
| | | import java.util.logging.Logger; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | |
| | | /** |
| | | * |
| | | * HTML filtering utility for protecting against XSS (Cross Site Scripting). |
| | | * |
| | | * This code is licensed LGPLv3 |
| | | * |
| | | * This code is a Java port of the original work in PHP by Cal Hendersen. |
| | | * http://code.iamcal.com/php/lib_filter/ |
| | | * |
| | | * The trickiest part of the translation was handling the differences in regex handling |
| | | * between PHP and Java. These resources were helpful in the process: |
| | | * |
| | | * http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html |
| | | * http://us2.php.net/manual/en/reference.pcre.pattern.modifiers.php |
| | | * http://www.regular-expressions.info/modifiers.html |
| | | * |
| | | * A note on naming conventions: instance variables are prefixed with a "v"; global |
| | | * constants are in all caps. |
| | | * |
| | | * Sample use: |
| | | * String input = ... |
| | | * String clean = new HTMLFilter().filter( input ); |
| | | * |
| | | * The class is not thread safe. Create a new instance if in doubt. |
| | | * |
| | | * If you find bugs or have suggestions on improvement (especially regarding |
| | | * performance), please contact us. The latest version of this |
| | | * source, and our contact details, can be found at http://xss-html-filter.sf.net |
| | | * |
| | | * @author Joseph O'Connell |
| | | * @author Cal Hendersen |
| | | * @author Michael Semb Wever |
| | | */ |
| | | public final class HTMLFilter { |
| | | |
| | | /** regex flag union representing /si modifiers in php **/ |
| | | private static final int REGEX_FLAGS_SI = Pattern.CASE_INSENSITIVE | Pattern.DOTALL; |
| | | private static final Pattern P_COMMENTS = Pattern.compile("<!--(.*?)-->", Pattern.DOTALL); |
| | | private static final Pattern P_COMMENT = Pattern.compile("^!--(.*)--$", REGEX_FLAGS_SI); |
| | | private static final Pattern P_TAGS = Pattern.compile("<(.*?)>", Pattern.DOTALL); |
| | | private static final Pattern P_END_TAG = Pattern.compile("^/([a-z0-9]+)", REGEX_FLAGS_SI); |
| | | private static final Pattern P_START_TAG = Pattern.compile("^([a-z0-9]+)(.*?)(/?)$", REGEX_FLAGS_SI); |
| | | private static final Pattern P_QUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)=([\"'])(.*?)\\2", REGEX_FLAGS_SI); |
| | | private static final Pattern P_UNQUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)(=)([^\"\\s']+)", REGEX_FLAGS_SI); |
| | | private static final Pattern P_PROTOCOL = Pattern.compile("^([^:]+):", REGEX_FLAGS_SI); |
| | | private static final Pattern P_ENTITY = Pattern.compile("&#(\\d+);?"); |
| | | private static final Pattern P_ENTITY_UNICODE = Pattern.compile("&#x([0-9a-f]+);?"); |
| | | private static final Pattern P_ENCODE = Pattern.compile("%([0-9a-f]{2});?"); |
| | | private static final Pattern P_VALID_ENTITIES = Pattern.compile("&([^&;]*)(?=(;|&|$))"); |
| | | private static final Pattern P_VALID_QUOTES = Pattern.compile("(>|^)([^<]+?)(<|$)", Pattern.DOTALL); |
| | | private static final Pattern P_END_ARROW = Pattern.compile("^>"); |
| | | private static final Pattern P_BODY_TO_END = Pattern.compile("<([^>]*?)(?=<|$)"); |
| | | private static final Pattern P_XML_CONTENT = Pattern.compile("(^|>)([^<]*?)(?=>)"); |
| | | private static final Pattern P_STRAY_LEFT_ARROW = Pattern.compile("<([^>]*?)(?=<|$)"); |
| | | private static final Pattern P_STRAY_RIGHT_ARROW = Pattern.compile("(^|>)([^<]*?)(?=>)"); |
| | | private static final Pattern P_AMP = Pattern.compile("&"); |
| | | private static final Pattern P_QUOTE = Pattern.compile("<"); |
| | | private static final Pattern P_LEFT_ARROW = Pattern.compile("<"); |
| | | private static final Pattern P_RIGHT_ARROW = Pattern.compile(">"); |
| | | private static final Pattern P_BOTH_ARROWS = Pattern.compile("<>"); |
| | | |
| | | // @xxx could grow large... maybe use sesat's ReferenceMap |
| | | private static final ConcurrentMap<String,Pattern> P_REMOVE_PAIR_BLANKS = new ConcurrentHashMap<String, Pattern>(); |
| | | private static final ConcurrentMap<String,Pattern> P_REMOVE_SELF_BLANKS = new ConcurrentHashMap<String, Pattern>(); |
| | | |
| | | /** set of allowed html elements, along with allowed attributes for each element **/ |
| | | private final Map<String, List<String>> vAllowed; |
| | | /** counts of open tags for each (allowable) html element **/ |
| | | private final Map<String, Integer> vTagCounts = new HashMap<String, Integer>(); |
| | | |
| | | /** html elements which must always be self-closing (e.g. "<img />") **/ |
| | | private final String[] vSelfClosingTags; |
| | | /** html elements which must always have separate opening and closing tags (e.g. "<b></b>") **/ |
| | | private final String[] vNeedClosingTags; |
| | | /** set of disallowed html elements **/ |
| | | private final String[] vDisallowed; |
| | | /** attributes which should be checked for valid protocols **/ |
| | | private final String[] vProtocolAtts; |
| | | /** allowed protocols **/ |
| | | private final String[] vAllowedProtocols; |
| | | /** tags which should be removed if they contain no content (e.g. "<b></b>" or "<b />") **/ |
| | | private final String[] vRemoveBlanks; |
| | | /** entities allowed within html markup **/ |
| | | private final String[] vAllowedEntities; |
| | | /** flag determining whether comments are allowed in input String. */ |
| | | private final boolean stripComment; |
| | | private final boolean encodeQuotes; |
| | | private boolean vDebug = false; |
| | | /** |
| | | * flag determining whether to try to make tags when presented with "unbalanced" |
| | | * angle brackets (e.g. "<b text </b>" becomes "<b> text </b>"). If set to false, |
| | | * unbalanced angle brackets will be html escaped. |
| | | */ |
| | | private final boolean alwaysMakeTags; |
| | | |
| | | /** Default constructor. |
| | | * |
| | | */ |
| | | public HTMLFilter() { |
| | | vAllowed = new HashMap<>(); |
| | | |
| | | final ArrayList<String> a_atts = new ArrayList<String>(); |
| | | a_atts.add("href"); |
| | | a_atts.add("target"); |
| | | vAllowed.put("a", a_atts); |
| | | |
| | | final ArrayList<String> img_atts = new ArrayList<String>(); |
| | | img_atts.add("src"); |
| | | img_atts.add("width"); |
| | | img_atts.add("height"); |
| | | img_atts.add("alt"); |
| | | vAllowed.put("img", img_atts); |
| | | |
| | | final ArrayList<String> no_atts = new ArrayList<String>(); |
| | | vAllowed.put("b", no_atts); |
| | | vAllowed.put("strong", no_atts); |
| | | vAllowed.put("i", no_atts); |
| | | vAllowed.put("em", no_atts); |
| | | |
| | | vSelfClosingTags = new String[]{"img"}; |
| | | vNeedClosingTags = new String[]{"a", "b", "strong", "i", "em"}; |
| | | vDisallowed = new String[]{}; |
| | | vAllowedProtocols = new String[]{"http", "mailto", "https"}; // no ftp. |
| | | vProtocolAtts = new String[]{"src", "href"}; |
| | | vRemoveBlanks = new String[]{"a", "b", "strong", "i", "em"}; |
| | | vAllowedEntities = new String[]{"amp", "gt", "lt", "quot"}; |
| | | stripComment = true; |
| | | encodeQuotes = true; |
| | | alwaysMakeTags = true; |
| | | } |
| | | |
| | | /** Set debug flag to true. Otherwise use default settings. See the default constructor. |
| | | * |
| | | * @param debug turn debug on with a true argument |
| | | */ |
| | | public HTMLFilter(final boolean debug) { |
| | | this(); |
| | | vDebug = debug; |
| | | |
| | | } |
| | | |
| | | /** Map-parameter configurable constructor. |
| | | * |
| | | * @param conf map containing configuration. keys match field names. |
| | | */ |
| | | public HTMLFilter(final Map<String,Object> conf) { |
| | | |
| | | assert conf.containsKey("vAllowed") : "configuration requires vAllowed"; |
| | | assert conf.containsKey("vSelfClosingTags") : "configuration requires vSelfClosingTags"; |
| | | assert conf.containsKey("vNeedClosingTags") : "configuration requires vNeedClosingTags"; |
| | | assert conf.containsKey("vDisallowed") : "configuration requires vDisallowed"; |
| | | assert conf.containsKey("vAllowedProtocols") : "configuration requires vAllowedProtocols"; |
| | | assert conf.containsKey("vProtocolAtts") : "configuration requires vProtocolAtts"; |
| | | assert conf.containsKey("vRemoveBlanks") : "configuration requires vRemoveBlanks"; |
| | | assert conf.containsKey("vAllowedEntities") : "configuration requires vAllowedEntities"; |
| | | |
| | | vAllowed = Collections.unmodifiableMap((HashMap<String, List<String>>) conf.get("vAllowed")); |
| | | vSelfClosingTags = (String[]) conf.get("vSelfClosingTags"); |
| | | vNeedClosingTags = (String[]) conf.get("vNeedClosingTags"); |
| | | vDisallowed = (String[]) conf.get("vDisallowed"); |
| | | vAllowedProtocols = (String[]) conf.get("vAllowedProtocols"); |
| | | vProtocolAtts = (String[]) conf.get("vProtocolAtts"); |
| | | vRemoveBlanks = (String[]) conf.get("vRemoveBlanks"); |
| | | vAllowedEntities = (String[]) conf.get("vAllowedEntities"); |
| | | stripComment = conf.containsKey("stripComment") ? (Boolean) conf.get("stripComment") : true; |
| | | encodeQuotes = conf.containsKey("encodeQuotes") ? (Boolean) conf.get("encodeQuotes") : true; |
| | | alwaysMakeTags = conf.containsKey("alwaysMakeTags") ? (Boolean) conf.get("alwaysMakeTags") : true; |
| | | } |
| | | |
| | | private void reset() { |
| | | vTagCounts.clear(); |
| | | } |
| | | |
| | | private void debug(final String msg) { |
| | | if (vDebug) { |
| | | Logger.getAnonymousLogger().info(msg); |
| | | } |
| | | } |
| | | |
| | | //--------------------------------------------------------------- |
| | | // my versions of some PHP library functions |
| | | public static String chr(final int decimal) { |
| | | return String.valueOf((char) decimal); |
| | | } |
| | | |
| | | public static String htmlSpecialChars(final String s) { |
| | | String result = s; |
| | | result = regexReplace(P_AMP, "&", result); |
| | | result = regexReplace(P_QUOTE, """, result); |
| | | result = regexReplace(P_LEFT_ARROW, "<", result); |
| | | result = regexReplace(P_RIGHT_ARROW, ">", result); |
| | | return result; |
| | | } |
| | | |
| | | //--------------------------------------------------------------- |
| | | /** |
| | | * given a user submitted input String, filter out any invalid or restricted |
| | | * html. |
| | | * |
| | | * @param input text (i.e. submitted by a user) than may contain html |
| | | * @return "clean" version of input, with only valid, whitelisted html elements allowed |
| | | */ |
| | | public String filter(final String input) { |
| | | reset(); |
| | | String s = input; |
| | | |
| | | debug("************************************************"); |
| | | debug(" INPUT: " + input); |
| | | |
| | | s = escapeComments(s); |
| | | debug(" escapeComments: " + s); |
| | | |
| | | s = balanceHTML(s); |
| | | debug(" balanceHTML: " + s); |
| | | |
| | | s = checkTags(s); |
| | | debug(" checkTags: " + s); |
| | | |
| | | s = processRemoveBlanks(s); |
| | | debug("processRemoveBlanks: " + s); |
| | | |
| | | s = validateEntities(s); |
| | | debug(" validateEntites: " + s); |
| | | |
| | | debug("************************************************\n\n"); |
| | | return s; |
| | | } |
| | | |
| | | public boolean isAlwaysMakeTags(){ |
| | | return alwaysMakeTags; |
| | | } |
| | | |
| | | public boolean isStripComments(){ |
| | | return stripComment; |
| | | } |
| | | |
| | | private String escapeComments(final String s) { |
| | | final Matcher m = P_COMMENTS.matcher(s); |
| | | final StringBuffer buf = new StringBuffer(); |
| | | if (m.find()) { |
| | | final String match = m.group(1); //(.*?) |
| | | m.appendReplacement(buf, Matcher.quoteReplacement("<!--" + htmlSpecialChars(match) + "-->")); |
| | | } |
| | | m.appendTail(buf); |
| | | |
| | | return buf.toString(); |
| | | } |
| | | |
| | | private String balanceHTML(String s) { |
| | | if (alwaysMakeTags) { |
| | | // |
| | | // try and form html |
| | | // |
| | | s = regexReplace(P_END_ARROW, "", s); |
| | | s = regexReplace(P_BODY_TO_END, "<$1>", s); |
| | | s = regexReplace(P_XML_CONTENT, "$1<$2", s); |
| | | |
| | | } else { |
| | | // |
| | | // escape stray brackets |
| | | // |
| | | s = regexReplace(P_STRAY_LEFT_ARROW, "<$1", s); |
| | | s = regexReplace(P_STRAY_RIGHT_ARROW, "$1$2><", s); |
| | | |
| | | // |
| | | // the last regexp causes '<>' entities to appear |
| | | // (we need to do a lookahead assertion so that the last bracket can |
| | | // be used in the next pass of the regexp) |
| | | // |
| | | s = regexReplace(P_BOTH_ARROWS, "", s); |
| | | } |
| | | |
| | | return s; |
| | | } |
| | | |
| | | private String checkTags(String s) { |
| | | Matcher m = P_TAGS.matcher(s); |
| | | |
| | | final StringBuffer buf = new StringBuffer(); |
| | | while (m.find()) { |
| | | String replaceStr = m.group(1); |
| | | replaceStr = processTag(replaceStr); |
| | | m.appendReplacement(buf, Matcher.quoteReplacement(replaceStr)); |
| | | } |
| | | m.appendTail(buf); |
| | | |
| | | s = buf.toString(); |
| | | |
| | | // these get tallied in processTag |
| | | // (remember to reset before subsequent calls to filter method) |
| | | for (String key : vTagCounts.keySet()) { |
| | | for (int ii = 0; ii < vTagCounts.get(key); ii++) { |
| | | s += "</" + key + ">"; |
| | | } |
| | | } |
| | | |
| | | return s; |
| | | } |
| | | |
| | | private String processRemoveBlanks(final String s) { |
| | | String result = s; |
| | | for (String tag : vRemoveBlanks) { |
| | | if(!P_REMOVE_PAIR_BLANKS.containsKey(tag)){ |
| | | P_REMOVE_PAIR_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?></" + tag + ">")); |
| | | } |
| | | result = regexReplace(P_REMOVE_PAIR_BLANKS.get(tag), "", result); |
| | | if(!P_REMOVE_SELF_BLANKS.containsKey(tag)){ |
| | | P_REMOVE_SELF_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?/>")); |
| | | } |
| | | result = regexReplace(P_REMOVE_SELF_BLANKS.get(tag), "", result); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | private static String regexReplace(final Pattern regex_pattern, final String replacement, final String s) { |
| | | Matcher m = regex_pattern.matcher(s); |
| | | return m.replaceAll(replacement); |
| | | } |
| | | |
| | | private String processTag(final String s) { |
| | | // ending tags |
| | | Matcher m = P_END_TAG.matcher(s); |
| | | if (m.find()) { |
| | | final String name = m.group(1).toLowerCase(); |
| | | if (allowed(name)) { |
| | | if (!inArray(name, vSelfClosingTags)) { |
| | | if (vTagCounts.containsKey(name)) { |
| | | vTagCounts.put(name, vTagCounts.get(name) - 1); |
| | | return "</" + name + ">"; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // starting tags |
| | | m = P_START_TAG.matcher(s); |
| | | if (m.find()) { |
| | | final String name = m.group(1).toLowerCase(); |
| | | final String body = m.group(2); |
| | | String ending = m.group(3); |
| | | |
| | | //debug( "in a starting tag, name='" + name + "'; body='" + body + "'; ending='" + ending + "'" ); |
| | | if (allowed(name)) { |
| | | String params = ""; |
| | | |
| | | final Matcher m2 = P_QUOTED_ATTRIBUTES.matcher(body); |
| | | final Matcher m3 = P_UNQUOTED_ATTRIBUTES.matcher(body); |
| | | final List<String> paramNames = new ArrayList<String>(); |
| | | final List<String> paramValues = new ArrayList<String>(); |
| | | while (m2.find()) { |
| | | paramNames.add(m2.group(1)); //([a-z0-9]+) |
| | | paramValues.add(m2.group(3)); //(.*?) |
| | | } |
| | | while (m3.find()) { |
| | | paramNames.add(m3.group(1)); //([a-z0-9]+) |
| | | paramValues.add(m3.group(3)); //([^\"\\s']+) |
| | | } |
| | | |
| | | String paramName, paramValue; |
| | | for (int ii = 0; ii < paramNames.size(); ii++) { |
| | | paramName = paramNames.get(ii).toLowerCase(); |
| | | paramValue = paramValues.get(ii); |
| | | |
| | | // debug( "paramName='" + paramName + "'" ); |
| | | // debug( "paramValue='" + paramValue + "'" ); |
| | | // debug( "allowed? " + vAllowed.get( name ).contains( paramName ) ); |
| | | |
| | | if (allowedAttribute(name, paramName)) { |
| | | if (inArray(paramName, vProtocolAtts)) { |
| | | paramValue = processParamProtocol(paramValue); |
| | | } |
| | | params += " " + paramName + "=\"" + paramValue + "\""; |
| | | } |
| | | } |
| | | |
| | | if (inArray(name, vSelfClosingTags)) { |
| | | ending = " /"; |
| | | } |
| | | |
| | | if (inArray(name, vNeedClosingTags)) { |
| | | ending = ""; |
| | | } |
| | | |
| | | if (ending == null || ending.length() < 1) { |
| | | if (vTagCounts.containsKey(name)) { |
| | | vTagCounts.put(name, vTagCounts.get(name) + 1); |
| | | } else { |
| | | vTagCounts.put(name, 1); |
| | | } |
| | | } else { |
| | | ending = " /"; |
| | | } |
| | | return "<" + name + params + ending + ">"; |
| | | } else { |
| | | return ""; |
| | | } |
| | | } |
| | | |
| | | // comments |
| | | m = P_COMMENT.matcher(s); |
| | | if (!stripComment && m.find()) { |
| | | return "<" + m.group() + ">"; |
| | | } |
| | | |
| | | return ""; |
| | | } |
| | | |
| | | private String processParamProtocol(String s) { |
| | | s = decodeEntities(s); |
| | | final Matcher m = P_PROTOCOL.matcher(s); |
| | | if (m.find()) { |
| | | final String protocol = m.group(1); |
| | | if (!inArray(protocol, vAllowedProtocols)) { |
| | | // bad protocol, turn into local anchor link instead |
| | | s = "#" + s.substring(protocol.length() + 1, s.length()); |
| | | if (s.startsWith("#//")) { |
| | | s = "#" + s.substring(3, s.length()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return s; |
| | | } |
| | | |
| | | private String decodeEntities(String s) { |
| | | StringBuffer buf = new StringBuffer(); |
| | | |
| | | Matcher m = P_ENTITY.matcher(s); |
| | | while (m.find()) { |
| | | final String match = m.group(1); |
| | | final int decimal = Integer.decode(match).intValue(); |
| | | m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); |
| | | } |
| | | m.appendTail(buf); |
| | | s = buf.toString(); |
| | | |
| | | buf = new StringBuffer(); |
| | | m = P_ENTITY_UNICODE.matcher(s); |
| | | while (m.find()) { |
| | | final String match = m.group(1); |
| | | final int decimal = Integer.valueOf(match, 16).intValue(); |
| | | m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); |
| | | } |
| | | m.appendTail(buf); |
| | | s = buf.toString(); |
| | | |
| | | buf = new StringBuffer(); |
| | | m = P_ENCODE.matcher(s); |
| | | while (m.find()) { |
| | | final String match = m.group(1); |
| | | final int decimal = Integer.valueOf(match, 16).intValue(); |
| | | m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); |
| | | } |
| | | m.appendTail(buf); |
| | | s = buf.toString(); |
| | | |
| | | s = validateEntities(s); |
| | | return s; |
| | | } |
| | | |
| | | private String validateEntities(final String s) { |
| | | StringBuffer buf = new StringBuffer(); |
| | | |
| | | // validate entities throughout the string |
| | | Matcher m = P_VALID_ENTITIES.matcher(s); |
| | | while (m.find()) { |
| | | final String one = m.group(1); //([^&;]*) |
| | | final String two = m.group(2); //(?=(;|&|$)) |
| | | m.appendReplacement(buf, Matcher.quoteReplacement(checkEntity(one, two))); |
| | | } |
| | | m.appendTail(buf); |
| | | |
| | | return encodeQuotes(buf.toString()); |
| | | } |
| | | |
| | | private String encodeQuotes(final String s){ |
| | | if(encodeQuotes){ |
| | | StringBuffer buf = new StringBuffer(); |
| | | Matcher m = P_VALID_QUOTES.matcher(s); |
| | | while (m.find()) { |
| | | final String one = m.group(1); //(>|^) |
| | | final String two = m.group(2); //([^<]+?) |
| | | final String three = m.group(3); //(<|$) |
| | | m.appendReplacement(buf, Matcher.quoteReplacement(one + regexReplace(P_QUOTE, """, two) + three)); |
| | | } |
| | | m.appendTail(buf); |
| | | return buf.toString(); |
| | | }else{ |
| | | return s; |
| | | } |
| | | } |
| | | |
| | | private String checkEntity(final String preamble, final String term) { |
| | | |
| | | return ";".equals(term) && isValidEntity(preamble) |
| | | ? '&' + preamble |
| | | : "&" + preamble; |
| | | } |
| | | |
| | | private boolean isValidEntity(final String entity) { |
| | | return inArray(entity, vAllowedEntities); |
| | | } |
| | | |
| | | private static boolean inArray(final String s, final String[] array) { |
| | | for (String item : array) { |
| | | if (item != null && item.equals(s)) { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | private boolean allowed(final String name) { |
| | | return (vAllowed.isEmpty() || vAllowed.containsKey(name)) && !inArray(name, vDisallowed); |
| | | } |
| | | |
| | | private boolean allowedAttribute(final String name, final String paramName) { |
| | | return allowed(name) && (vAllowed.isEmpty() || vAllowed.get(name).contains(paramName)); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.common.xss; |
| | | |
| | | import com.iailab.module.data.common.exception.RRException; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | |
| | | /** |
| | | * SQL过滤 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | */ |
| | | public class SQLFilter { |
| | | |
| | | /** |
| | | * SQL注入过滤 |
| | | * @param str 待验证的字符串 |
| | | */ |
| | | public static String sqlInject(String str){ |
| | | if(StringUtils.isBlank(str)){ |
| | | return null; |
| | | } |
| | | //去掉'|"|;|\字符 |
| | | str = StringUtils.replace(str, "'", ""); |
| | | str = StringUtils.replace(str, "\"", ""); |
| | | str = StringUtils.replace(str, ";", ""); |
| | | str = StringUtils.replace(str, "\\", ""); |
| | | |
| | | //转换成小写 |
| | | str = str.toLowerCase(); |
| | | |
| | | //非法字符 |
| | | String[] keywords = {"master", "truncate", "insert", "select", "delete", "update", "declare", "alter", "drop"}; |
| | | |
| | | //判断是否包含非法字符 |
| | | for(String keyword : keywords){ |
| | | if(str.indexOf(keyword) != -1){ |
| | | throw new RRException("包含非法字符"); |
| | | } |
| | | } |
| | | |
| | | return str; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.common.xss; |
| | | |
| | | import javax.servlet.*; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.IOException; |
| | | |
| | | /** |
| | | * XSS过滤 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | */ |
| | | public class XssFilter implements Filter { |
| | | |
| | | @Override |
| | | public void init(FilterConfig config) throws ServletException { |
| | | } |
| | | |
| | | public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) |
| | | throws IOException, ServletException { |
| | | XssHttpServletRequestWrapper xssRequest = new XssHttpServletRequestWrapper( |
| | | (HttpServletRequest) request); |
| | | chain.doFilter(xssRequest, response); |
| | | } |
| | | |
| | | @Override |
| | | public void destroy() { |
| | | } |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.common.xss; |
| | | |
| | | import org.apache.commons.io.IOUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.MediaType; |
| | | |
| | | import javax.servlet.ReadListener; |
| | | import javax.servlet.ServletInputStream; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletRequestWrapper; |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.IOException; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * XSS过滤处理 |
| | | * |
| | | * @author Mark sunlightcs@gmail.com |
| | | */ |
| | | public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper { |
| | | //没被包装过的HttpServletRequest(特殊场景,需要自己过滤) |
| | | HttpServletRequest orgRequest; |
| | | //html过滤 |
| | | private final static HTMLFilter htmlFilter = new HTMLFilter(); |
| | | |
| | | public XssHttpServletRequestWrapper(HttpServletRequest request) { |
| | | super(request); |
| | | orgRequest = request; |
| | | } |
| | | |
| | | @Override |
| | | public ServletInputStream getInputStream() throws IOException { |
| | | //非json类型,直接返回 |
| | | if(!MediaType.APPLICATION_JSON_VALUE.equalsIgnoreCase(super.getHeader(HttpHeaders.CONTENT_TYPE))){ |
| | | return super.getInputStream(); |
| | | } |
| | | |
| | | //为空,直接返回 |
| | | String json = IOUtils.toString(super.getInputStream(), "utf-8"); |
| | | if (StringUtils.isBlank(json)) { |
| | | return super.getInputStream(); |
| | | } |
| | | |
| | | //xss过滤 |
| | | json = xssEncode(json); |
| | | final ByteArrayInputStream bis = new ByteArrayInputStream(json.getBytes("utf-8")); |
| | | return new ServletInputStream() { |
| | | @Override |
| | | public boolean isFinished() { |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public boolean isReady() { |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public void setReadListener(ReadListener readListener) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public int read() throws IOException { |
| | | return bis.read(); |
| | | } |
| | | }; |
| | | } |
| | | |
| | | @Override |
| | | public String getParameter(String name) { |
| | | String value = super.getParameter(xssEncode(name)); |
| | | if (StringUtils.isNotBlank(value)) { |
| | | value = xssEncode(value); |
| | | } |
| | | return value; |
| | | } |
| | | |
| | | @Override |
| | | public String[] getParameterValues(String name) { |
| | | String[] parameters = super.getParameterValues(name); |
| | | if (parameters == null || parameters.length == 0) { |
| | | return null; |
| | | } |
| | | |
| | | for (int i = 0; i < parameters.length; i++) { |
| | | parameters[i] = xssEncode(parameters[i]); |
| | | } |
| | | return parameters; |
| | | } |
| | | |
| | | @Override |
| | | public Map<String,String[]> getParameterMap() { |
| | | Map<String,String[]> map = new LinkedHashMap<>(); |
| | | Map<String,String[]> parameters = super.getParameterMap(); |
| | | for (String key : parameters.keySet()) { |
| | | String[] values = parameters.get(key); |
| | | for (int i = 0; i < values.length; i++) { |
| | | values[i] = xssEncode(values[i]); |
| | | } |
| | | map.put(key, values); |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | @Override |
| | | public String getHeader(String name) { |
| | | String value = super.getHeader(xssEncode(name)); |
| | | if (StringUtils.isNotBlank(value)) { |
| | | value = xssEncode(value); |
| | | } |
| | | return value; |
| | | } |
| | | |
| | | private String xssEncode(String input) { |
| | | return htmlFilter.filter(input); |
| | | } |
| | | |
| | | /** |
| | | * 获取最原始的request |
| | | */ |
| | | public HttpServletRequest getOrgRequest() { |
| | | return orgRequest; |
| | | } |
| | | |
| | | /** |
| | | * 获取最原始的request |
| | | */ |
| | | public static HttpServletRequest getOrgRequest(HttpServletRequest request) { |
| | | if (request instanceof XssHttpServletRequestWrapper) { |
| | | return ((XssHttpServletRequestWrapper) request).getOrgRequest(); |
| | | } |
| | | |
| | | return request; |
| | | } |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.feign; |
| | | |
| | | import com.alibaba.cloud.commons.lang.StringUtils; |
| | | import com.iailab.module.data.api.IFeignDataApi; |
| | | import com.iailab.framework.common.util.date.DateUtils; |
| | | import com.iailab.framework.common.util.object.BeanUtils; |
| | | import com.iailab.module.data.common.enums.DataTypeEnum; |
| | | import com.iailab.module.data.dto.*; |
| | | import com.iailab.module.data.http.entity.HttpApiEntity; |
| | | import com.iailab.module.data.influxdb.pojo.InfluxPointValuePOJO; |
| | | import com.iailab.module.data.point.collection.PointCollector; |
| | | import com.iailab.module.data.point.dto.DaPointDTO; |
| | | import com.iailab.module.data.point.dto.DaPointWriteValueDTO; |
| | | import com.iailab.module.data.point.service.DaPointService; |
| | | import com.iailab.module.data.http.service.HttpApiService; |
| | | import com.iailab.module.data.ind.collection.IndItemCollector; |
| | | import com.iailab.module.data.ind.dto.IndItemValueDTO; |
| | | import com.iailab.module.data.influxdb.service.InfluxDBService; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2023年06月28日 08:53:00 |
| | | */ |
| | | @RestController |
| | | public class FeignDataImpl implements IFeignDataApi { |
| | | @Resource |
| | | private InfluxDBService influxDBService; |
| | | |
| | | @Resource |
| | | DaPointService daPointService; |
| | | |
| | | @Resource |
| | | private HttpApiService httpApiService; |
| | | |
| | | @Resource |
| | | private IndItemCollector indItemCollector; |
| | | |
| | | @Resource |
| | | private PointCollector pointCollector; |
| | | |
| | | @Override |
| | | public List<ApiDataDTO> queryPointValues(FeignQueryPointDTO dto) { |
| | | DaPointDTO daPointDTO = daPointService.getByNo(dto.getPointCode()); |
| | | InfluxPointValuePOJO pojo = new InfluxPointValuePOJO(); |
| | | pojo.setPoint(dto.getPointCode()); |
| | | pojo.setType(daPointDTO.getDataType()); |
| | | Date startTime = dto.getStartTime(); |
| | | Date endTime = dto.getEndTime(); |
| | | List<Map<String, Object>> list = influxDBService.queryPointValues(pojo, startTime, endTime); |
| | | List<ApiDataDTO> dataEntityList = new ArrayList<>(); |
| | | for (int i = 0; list.size() - i >= 1; i++) { |
| | | ApiDataDTO dataEntity = new ApiDataDTO(); |
| | | dataEntity.setDataValue(Double.parseDouble(list.get(i).get("value").toString())); |
| | | dataEntity.setTimeStamp((Date)(list.get(i).get("time"))); |
| | | dataEntityList.add(dataEntity); |
| | | } |
| | | return dataEntityList; |
| | | } |
| | | |
| | | @Override |
| | | public List<ApiDataDTO> querySimTagValues(FeignQueryPointDTO dto) { |
| | | |
| | | InfluxPointValuePOJO pojo = new InfluxPointValuePOJO(); |
| | | pojo.setPoint(dto.getPointCode()); |
| | | pojo.setType(DataTypeEnum.FLOAT.getCode()); |
| | | Date startTime = dto.getStartTime(); |
| | | Date endTime = dto.getEndTime(); |
| | | List<Map<String, Object>> list = influxDBService.queryPointValues(pojo, startTime, endTime); |
| | | List<ApiDataDTO> dataEntityList = new ArrayList<>(); |
| | | for (int i = 0; list.size() - i >= 1; i++) { |
| | | ApiDataDTO dataEntity = new ApiDataDTO(); |
| | | dataEntity.setDataValue(Double.parseDouble(list.get(i).get("value").toString())); |
| | | dataEntity.setTimeStamp((Date)(list.get(i).get("time"))); |
| | | dataEntityList.add(dataEntity); |
| | | } |
| | | return dataEntityList; |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> getCurrentValue(List<String> pointNos) { |
| | | return pointCollector.getCurrentValue(pointNos); |
| | | } |
| | | |
| | | @Override |
| | | public ApiDataPointDTO getPoint(String pointNo) { |
| | | DaPointDTO daPointDTO = daPointService.getByNo(pointNo); |
| | | return BeanUtils.toBean(daPointDTO, ApiDataPointDTO.class); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public FeignHttpApiDTO getHttpApi(String code) { |
| | | HttpApiEntity entity = httpApiService.getByCode(code); |
| | | return BeanUtils.toBean(entity, FeignHttpApiDTO.class); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public List<ApiDataDTO> queryIndItemValues(FeignQueryPointDTO dto) { |
| | | List<ApiDataDTO> result = new ArrayList<>(); |
| | | List<String> itemNos = new ArrayList<>(); |
| | | itemNos.add(dto.getPointCode()); |
| | | Map<String, List<IndItemValueDTO>> data = indItemCollector.getValueList(itemNos); |
| | | List<IndItemValueDTO> list = data.get(dto.getPointCode()); |
| | | if (CollectionUtils.isEmpty(list)) { |
| | | return result; |
| | | } |
| | | list.forEach(item -> { |
| | | BigDecimal dv = null; |
| | | ApiDataDTO entity = new ApiDataDTO(); |
| | | entity.setDataTime(item.getDataTime()); |
| | | entity.setDataValue(item.getDataValue() == null ? 0 : item.getDataValue().doubleValue()); |
| | | result.add(entity); |
| | | }); |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public List<ApiIndValueDTO> getIndItemValues(FeignQueryPointDTO dto) { |
| | | List<ApiIndValueDTO> result = new ArrayList<>(); |
| | | List<String> itemNos = new ArrayList<>(); |
| | | itemNos.add(dto.getPointCode()); |
| | | Map<String, List<IndItemValueDTO>> data = indItemCollector.getValueList(itemNos); |
| | | List<IndItemValueDTO> list = data.get(dto.getPointCode()); |
| | | if (CollectionUtils.isEmpty(list)) { |
| | | return result; |
| | | } |
| | | list.forEach(item -> { |
| | | BigDecimal dv = null; |
| | | ApiIndValueDTO entity = new ApiIndValueDTO(); |
| | | entity.setDataTime(item.getDataTime()); |
| | | entity.setDataValue(item.getDataValue()); |
| | | result.add(entity); |
| | | }); |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public List<ApiIndValueDTO> queryIndItemValuesRange(FeignQueryPointDTO dto) { |
| | | List<ApiIndValueDTO> result = new ArrayList<>(); |
| | | List<String> itemNos = new ArrayList<>(); |
| | | itemNos.add(dto.getPointCode()); |
| | | Map<String, List<IndItemValueDTO>> data = new HashMap<>(); |
| | | if (StringUtils.isBlank(dto.getStartDate()) && StringUtils.isBlank(dto.getEndDate())) { |
| | | data = indItemCollector.getValueList(itemNos); |
| | | } else { |
| | | if (dto.getStartDate() == null) { |
| | | dto.setStartDate(DateUtils.format(new Date())); |
| | | } |
| | | if (dto.getEndDate() == null) { |
| | | dto.setEndDate(DateUtils.format(new Date())); |
| | | } |
| | | data = indItemCollector.getValueListRange(itemNos, dto.getStartDate(), dto.getEndDate()); |
| | | } |
| | | List<IndItemValueDTO> list = data.get(dto.getPointCode()); |
| | | if (CollectionUtils.isEmpty(list)) { |
| | | return result; |
| | | } |
| | | list.forEach(item -> { |
| | | BigDecimal dv = null; |
| | | ApiIndValueDTO entity = new ApiIndValueDTO(); |
| | | entity.setDataTime(item.getDataTime()); |
| | | entity.setDataValue(item.getDataValue()); |
| | | result.add(entity); |
| | | }); |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public FeignResultDTO setPointValue(FeignWritePointValueDTO writePointValue) { |
| | | FeignResultDTO result = new FeignResultDTO(); |
| | | try { |
| | | DaPointWriteValueDTO wr = new DaPointWriteValueDTO(); |
| | | wr.setPointNo(writePointValue.getPointCode()); |
| | | wr.setPointValue(writePointValue.getPointValue()); |
| | | pointCollector.setValue(wr); |
| | | result.setCode(0); |
| | | result.setMsg(""); |
| | | } catch (Exception ex) { |
| | | result.setCode(-1); |
| | | result.setMsg(ex.getMessage()); |
| | | } |
| | | return result; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | //package com.iailab.module.data.framework.filter; |
| | | // |
| | | //import org.apache.logging.log4j.LogManager; |
| | | //import org.apache.logging.log4j.Logger; |
| | | //import org.springframework.stereotype.Component; |
| | | // |
| | | //import javax.servlet.*; |
| | | //import javax.servlet.http.HttpServletRequest; |
| | | //import java.io.IOException; |
| | | // |
| | | //public class MyFilter implements Filter { |
| | | // |
| | | // private static final Logger LOGGER = LogManager.getLogger(LogManager.ROOT_LOGGER_NAME); |
| | | // |
| | | // @Override |
| | | // public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { |
| | | // LOGGER.info("过滤器filter3开始 doFilter"); |
| | | // ServletRequest requestWrapper = null; |
| | | // if(request instanceof HttpServletRequest) { |
| | | // requestWrapper = new MyHttpServletRequestWrapper((HttpServletRequest) request); |
| | | // } |
| | | // //获取请求中的流如何,将取出来的字符串,再次转换成流,然后把它放入到新request对象中。 |
| | | // // 在chain.doFiler方法中传递新的request对象 |
| | | // if(requestWrapper == null) { |
| | | // |
| | | // chain.doFilter(request, response); |
| | | // } else { |
| | | // chain.doFilter(requestWrapper, response); |
| | | // } |
| | | // } |
| | | //} |
对比新文件 |
| | |
| | | package com.iailab.module.data.framework.filter; |
| | | |
| | | import groovy.util.logging.Slf4j; |
| | | import lombok.Getter; |
| | | |
| | | import javax.servlet.ReadListener; |
| | | import javax.servlet.ServletInputStream; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletRequestWrapper; |
| | | import java.io.BufferedReader; |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.IOException; |
| | | import java.io.InputStreamReader; |
| | | |
| | | @Slf4j |
| | | @Getter |
| | | public class MyHttpServletRequestWrapper extends HttpServletRequestWrapper { |
| | | /** 复制请求body */ |
| | | private final String body; |
| | | |
| | | public MyHttpServletRequestWrapper (HttpServletRequest request) { |
| | | super(request); |
| | | try { |
| | | //设置编码格式, 防止中文乱码 |
| | | request.setCharacterEncoding("UTF-8"); |
| | | //将请求中的流取出来放到body里,后面都只操作body就行 |
| | | this.body = RequestReadUtils.read(request); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException("MyHttpServletRequestWrapper 拦截器异常"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public ServletInputStream getInputStream() { |
| | | //返回body的流信息即可 |
| | | try(final ByteArrayInputStream bais = new ByteArrayInputStream(body.getBytes())){ |
| | | return getServletInputStream(bais); |
| | | }catch(IOException e){ |
| | | throw new RuntimeException("MyHttpServletRequestWrapper 获取input流异常"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public BufferedReader getReader(){ |
| | | return new BufferedReader(new InputStreamReader(this.getInputStream())); |
| | | } |
| | | |
| | | /** |
| | | * 重写getInputStream流 |
| | | * @param bais |
| | | * @return |
| | | */ |
| | | private static ServletInputStream getServletInputStream(ByteArrayInputStream bais) { |
| | | return new ServletInputStream() { |
| | | @Override |
| | | public boolean isFinished() { |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public boolean isReady() { |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public void setReadListener(ReadListener readListener) { |
| | | } |
| | | @Override |
| | | public int read() { |
| | | return bais.read(); |
| | | } |
| | | }; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.framework.filter; |
| | | |
| | | import groovy.util.logging.Slf4j; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.BufferedReader; |
| | | |
| | | @Slf4j |
| | | public class RequestReadUtils { |
| | | /** |
| | | * 读取请求流 |
| | | * @param request |
| | | * @return |
| | | */ |
| | | public static String read(HttpServletRequest request){ |
| | | try(BufferedReader reader = request.getReader()){ |
| | | StringBuilder sb = new StringBuilder(); |
| | | String line; |
| | | while ((line = reader.readLine()) != null) { |
| | | sb.append(line); |
| | | } |
| | | return sb.toString(); |
| | | }catch (Exception e){ |
| | | throw new RuntimeException("MyHttpServletRequestWrapper.RequestReadUtils.read 获取请求流异常"); |
| | | } |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.framework.filter; |
| | | |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.core.annotation.Order; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.servlet.*; |
| | | import javax.servlet.annotation.WebFilter; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.IOException; |
| | | import java.util.Objects; |
| | | import java.util.Optional; |
| | | |
| | | @Component |
| | | @WebFilter(filterName = "RewriteRequestFilter", urlPatterns = "/*") |
| | | @Order(1) |
| | | public class RewriteRequestFilter implements Filter { |
| | | |
| | | @Override |
| | | public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { |
| | | //文件上传类型 不需要处理,否则会报java.nio.charset.MalformedInputException: Input length = 1异常 |
| | | if (Objects.isNull(request) || Optional.ofNullable(request.getContentType()).orElse(StringUtils.EMPTY).startsWith("multipart/")) { |
| | | chain.doFilter(request, response); |
| | | return; |
| | | } |
| | | //自定义wrapper 处理流,必须在过滤器中处理,然后通过FilterChain传下去, 否则重写后的getInputStream()方法不会被调用 |
| | | MyHttpServletRequestWrapper requestWrapper = new MyHttpServletRequestWrapper((HttpServletRequest)request); |
| | | chain.doFilter(requestWrapper,response); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.framework.interceptor; |
| | | |
| | | import lombok.Getter; |
| | | import lombok.Setter; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | | @Slf4j |
| | | @Getter |
| | | @Setter |
| | | public class CommonData { |
| | | private static ThreadLocal<Map<String, Object>> threadLocal = new ThreadLocal<>(); |
| | | |
| | | /** |
| | | * 添加数据 |
| | | * @param key |
| | | * @param value |
| | | */ |
| | | public static void set(String key, Object value) { |
| | | if (threadLocal.get() == null) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | threadLocal.set(map); |
| | | } |
| | | threadLocal.get().put(key, value); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 清除数据 |
| | | */ |
| | | public static void clearAll() { |
| | | threadLocal.set(null); |
| | | } |
| | | |
| | | |
| | | public static Map<String, Object> getSignParam() { |
| | | Object o = threadLocal.get().get("param"); |
| | | if (Objects.isNull(o)) { |
| | | log.info("CommonData.getSignParam is null"); |
| | | return null; |
| | | } |
| | | return (Map<String, Object>) o; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | //package com.iailab.module.data.framework.interceptor; |
| | | // |
| | | //import com.iailab.module.data.framework.filter.MyFilter; |
| | | //import org.springframework.boot.web.servlet.FilterRegistrationBean; |
| | | //import org.springframework.context.annotation.Bean; |
| | | //import org.springframework.context.annotation.Configuration; |
| | | //import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
| | | // |
| | | //@Configuration |
| | | //public class WebMvcConfig implements WebMvcConfigurer { |
| | | // |
| | | // @Bean |
| | | // public FilterRegistrationBean httpServletRequestReplacedFilter() { |
| | | // FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(); |
| | | // filterRegistrationBean.setFilter(new MyFilter()); |
| | | // filterRegistrationBean.addUrlPatterns("/*"); |
| | | // filterRegistrationBean.setName("myFilter"); |
| | | // filterRegistrationBean.setOrder(1); |
| | | // return filterRegistrationBean; |
| | | // } |
| | | // |
| | | //} |
对比新文件 |
| | |
| | | /** |
| | | * 属于 infra 模块的 framework 封装 |
| | | * |
| | | * @author iailab |
| | | */ |
| | | package com.iailab.module.data.framework; |
对比新文件 |
| | |
| | | package com.iailab.module.data.framework.rpc.config; |
| | | |
| | | import com.iailab.api.IFeignModelApi; |
| | | import com.iailab.api.IFeignProddispApi; |
| | | import com.iailab.module.infra.api.config.ConfigApi; |
| | | import com.iailab.module.system.api.permission.RoleApi; |
| | | import com.iailab.module.system.api.user.AdminUserApi; |
| | | import org.springframework.cloud.openfeign.EnableFeignClients; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | @Configuration(proxyBeanMethods = false) |
| | | @EnableFeignClients(clients = {IFeignModelApi.class, AdminUserApi.class, RoleApi.class, IFeignProddispApi.class, ConfigApi.class}) |
| | | public class RpcConfiguration { |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | * 占位 |
| | | */ |
| | | package com.iailab.module.data.framework.rpc; |
对比新文件 |
| | |
| | | package com.iailab.module.data.framework.security.config; |
| | | |
| | | import com.iailab.framework.security.config.AuthorizeRequestsCustomizer; |
| | | import com.iailab.module.data.enums.ApiConstants; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.security.config.annotation.web.builders.HttpSecurity; |
| | | import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; |
| | | |
| | | /** |
| | | * data 模块的 Security 配置 |
| | | */ |
| | | @Configuration(proxyBeanMethods = false, value = "dataSecurityConfiguration") |
| | | public class SecurityConfiguration { |
| | | |
| | | @Value("${spring.boot.admin.context-path:''}") |
| | | private String adminSeverContextPath; |
| | | |
| | | @Bean("infraAuthorizeRequestsCustomizer") |
| | | public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() { |
| | | return new AuthorizeRequestsCustomizer() { |
| | | |
| | | @Override |
| | | public void customize(ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry registry) { |
| | | // Swagger 接口文档 |
| | | registry.antMatchers("/v3/api-docs/**").permitAll() // 元数据 |
| | | .antMatchers("/swagger-ui.html").permitAll(); // Swagger UI |
| | | // Spring Boot Actuator 的安全配置 |
| | | registry.antMatchers("/actuator").anonymous() |
| | | .antMatchers("/actuator/**").anonymous(); |
| | | // Druid 监控 |
| | | registry.antMatchers("/druid/**").anonymous(); |
| | | // Spring Boot Admin Server 的安全配置 |
| | | registry.antMatchers(adminSeverContextPath).anonymous() |
| | | .antMatchers(adminSeverContextPath + "/**").anonymous(); |
| | | // 文件读取 |
| | | registry.antMatchers(buildAdminApi("/data/point/**")).permitAll(); |
| | | |
| | | // TODO iailab:这个每个项目都需要重复配置,得捉摸有没通用的方案 |
| | | // RPC 服务的安全配置 |
| | | registry.antMatchers(ApiConstants.PREFIX + "/**").permitAll(); |
| | | } |
| | | |
| | | }; |
| | | } |
| | | |
| | | } |
对比新文件 |
| | |
| | | /** |
| | | * 占位 |
| | | */ |
| | | package com.iailab.module.data.framework.security.core; |
对比新文件 |
| | |
| | | package com.iailab.module.data.gateway.controller; |
| | | |
| | | import com.iailab.module.data.common.utils.PageUtils; |
| | | import com.iailab.module.data.common.utils.R; |
| | | import com.iailab.module.data.gateway.service.ApiAuthorizedService; |
| | | import com.iailab.module.data.gateway.entity.ApiAppEntity; |
| | | import com.iailab.module.data.gateway.service.ApiAppService; |
| | | import org.apache.commons.lang3.RandomStringUtils; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年07月15日 14:13:00 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/api-gateway/app") |
| | | public class ApiAppController { |
| | | @Resource |
| | | private ApiAppService apiAppService; |
| | | |
| | | @Resource |
| | | private ApiAuthorizedService apiAuthorizedService; |
| | | |
| | | /** |
| | | * 合作方APP列表 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @GetMapping("/list") |
| | | public R list(@RequestParam Map<String, Object> params) { |
| | | PageUtils page = apiAppService.queryPage(params); |
| | | return R.ok().put("page", page); |
| | | } |
| | | |
| | | /** |
| | | * 新增合作方APP |
| | | * |
| | | * @param apiAppEntity |
| | | * @return |
| | | */ |
| | | @PostMapping("/add") |
| | | public R add(@RequestBody ApiAppEntity apiAppEntity) { |
| | | int count = apiAppService.cheack(apiAppEntity); |
| | | if (count > 0) { |
| | | return R.error("名称或数据值重复"); |
| | | } |
| | | apiAppEntity.setCreateTime(new Date()); |
| | | apiAppService.add(apiAppEntity); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 更新合作方APP |
| | | * |
| | | * @param apiAppEntity |
| | | * @return |
| | | */ |
| | | @PostMapping("/update") |
| | | public R update(@RequestBody ApiAppEntity apiAppEntity) { |
| | | int count = apiAppService.cheack(apiAppEntity); |
| | | if (count > 0) { |
| | | return R.error("名称或数据值重复"); |
| | | } |
| | | apiAppEntity.setCreateTime(new Date()); |
| | | apiAppService.update(apiAppEntity); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 重置Secret |
| | | * |
| | | * @param apiAppEntity |
| | | * @return |
| | | */ |
| | | @PostMapping("/restAppSecret") |
| | | public R restAppSecret(@RequestBody ApiAppEntity apiAppEntity) { |
| | | ApiAppEntity apiAppEntityUpdate = new ApiAppEntity(); |
| | | apiAppEntityUpdate.setId(apiAppEntity.getId()); |
| | | apiAppEntityUpdate.setAppSecret(RandomStringUtils.randomAlphanumeric(8)); |
| | | apiAppService.update(apiAppEntity); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 删除合作方APP |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @PostMapping("/delete") |
| | | public R delete(@RequestBody Map<String, Object> params) { |
| | | String id = (String)params.get("id"); |
| | | apiAppService.deleteById(id); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 合作方APP详情 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @RequestMapping("/info/{id}") |
| | | public R info(@PathVariable("id") String id){ |
| | | ApiAppEntity apiAppEntity = apiAppService.getInfoById(id); |
| | | Map<String, Object> queryParams = new HashMap<>(); |
| | | queryParams.put("appId", id); |
| | | apiAppEntity.setApiAuthorizedList(apiAuthorizedService.queryList(queryParams)); |
| | | return R.ok().put("data", apiAppEntity); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.gateway.controller; |
| | | |
| | | import com.iailab.module.data.common.utils.PageUtils; |
| | | import com.iailab.module.data.common.utils.R; |
| | | import com.iailab.module.data.gateway.service.ApiAuthorizedService; |
| | | import com.iailab.module.data.gateway.entity.ApiAuthorizedEntity; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年07月15日 14:16:00 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/api-gateway/authorized") |
| | | public class ApiAuthorizedController { |
| | | @Resource |
| | | private ApiAuthorizedService apiAuthorizedService; |
| | | |
| | | /** |
| | | * 已授权API列表 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @GetMapping("/list") |
| | | public R list(@RequestParam Map<String, Object> params) { |
| | | PageUtils page = apiAuthorizedService.queryPage(params); |
| | | return R.ok().put("page", page); |
| | | } |
| | | |
| | | /** |
| | | * 已授权API更新 |
| | | * |
| | | * @param apiAuthorizedEntity |
| | | * @return |
| | | */ |
| | | @PostMapping("/update") |
| | | public R update(@RequestBody ApiAuthorizedEntity apiAuthorizedEntity) { |
| | | apiAuthorizedService.update(apiAuthorizedEntity); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * API授权 |
| | | * |
| | | * @param appId |
| | | * @param apiIdList |
| | | * @return |
| | | */ |
| | | @PostMapping("/grant-api/{appId}") |
| | | public R grantApi(@PathVariable("appId") String appId, @RequestBody List<String> apiIdList) { |
| | | apiAuthorizedService.grantApi(appId, apiIdList); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 删除已授权API |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @PostMapping("/delete") |
| | | public R delete(@RequestBody Map<String, Object> params) { |
| | | String id = (String)params.get("id"); |
| | | apiAuthorizedService.deleteById(id); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 已授权API详情 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @RequestMapping("/info/{id}") |
| | | public R info(@PathVariable("id") String id){ |
| | | ApiAuthorizedEntity sysDictItemEntity = apiAuthorizedService.getInfoById(id); |
| | | |
| | | return R.ok().put("dictItem", sysDictItemEntity); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.gateway.controller; |
| | | |
| | | import com.iailab.module.data.common.utils.PageUtils; |
| | | import com.iailab.module.data.common.utils.R; |
| | | import com.iailab.module.data.gateway.entity.ApiGroupEntity; |
| | | import com.iailab.module.data.gateway.service.ApiGroupService; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.Date; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年07月15日 14:16:00 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/api-gateway/group") |
| | | public class ApiGroupController { |
| | | @Resource |
| | | private ApiGroupService apiGroupService; |
| | | |
| | | /** |
| | | * API分组列表 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @GetMapping("/list") |
| | | public R list(@RequestParam Map<String, Object> params) { |
| | | PageUtils page = apiGroupService.queryPage(params); |
| | | return R.ok().put("page", page); |
| | | } |
| | | |
| | | /** |
| | | * 新增API分组 |
| | | * |
| | | * @param apiAppEntity |
| | | * @return |
| | | */ |
| | | @PostMapping("/add") |
| | | public R add(@RequestBody ApiGroupEntity apiAppEntity) { |
| | | int count = apiGroupService.cheack(apiAppEntity); |
| | | if (count > 0) { |
| | | return R.error("名称或数据值重复"); |
| | | } |
| | | apiAppEntity.setCreateTime(new Date()); |
| | | apiGroupService.add(apiAppEntity); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 更新API分组 |
| | | * |
| | | * @param apiAppEntity |
| | | * @return |
| | | */ |
| | | @PostMapping("/update") |
| | | public R update(@RequestBody ApiGroupEntity apiAppEntity) { |
| | | int count = apiGroupService.cheack(apiAppEntity); |
| | | if (count > 0) { |
| | | return R.error("名称或数据值重复"); |
| | | } |
| | | apiGroupService.update(apiAppEntity); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 删除API分组 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @PostMapping("/delete") |
| | | public R delete(@RequestBody Map<String, Object> params) { |
| | | String id = (String)params.get("id"); |
| | | apiGroupService.deleteById(id); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * API分组详情 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @RequestMapping("/info/{id}") |
| | | public R info(@PathVariable("id") String id){ |
| | | ApiGroupEntity sysDictItemEntity = apiGroupService.getInfoById(id); |
| | | |
| | | return R.ok().put("data", sysDictItemEntity); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.gateway.controller; |
| | | |
| | | import com.iailab.module.data.common.utils.PageUtils; |
| | | import com.iailab.module.data.common.utils.R; |
| | | import com.iailab.module.data.gateway.service.ApiInfoService; |
| | | import com.iailab.module.data.gateway.entity.ApiInfoEntity; |
| | | import com.iailab.module.data.gateway.service.ApiGroupService; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.Date; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年07月15日 14:17:00 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/api-gateway/info") |
| | | public class ApiInfoController { |
| | | @Resource |
| | | private ApiInfoService apiInfoService; |
| | | |
| | | @Resource |
| | | private ApiGroupService apiGroupService; |
| | | |
| | | /** |
| | | * API信息列表 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @GetMapping("/list") |
| | | public R list(@RequestParam Map<String, Object> params) { |
| | | PageUtils page = apiInfoService.queryPage(params); |
| | | return R.ok().put("page", page); |
| | | } |
| | | |
| | | /** |
| | | * 新增API信息 |
| | | * |
| | | * @param apiAppEntity |
| | | * @return |
| | | */ |
| | | @PostMapping("/add") |
| | | public R add(@RequestBody ApiInfoEntity apiAppEntity) { |
| | | int count = apiInfoService.cheack(apiAppEntity); |
| | | if (count > 0) { |
| | | return R.error("名称或数据值重复"); |
| | | } |
| | | apiAppEntity.setCreateTime(new Date()); |
| | | apiInfoService.add(apiAppEntity); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 更新API信息 |
| | | * |
| | | * @param apiAppEntity |
| | | * @return |
| | | */ |
| | | @PostMapping("/update") |
| | | public R update(@RequestBody ApiInfoEntity apiAppEntity) { |
| | | int count = apiInfoService.cheack(apiAppEntity); |
| | | if (count > 0) { |
| | | return R.error("名称或数据值重复"); |
| | | } |
| | | apiInfoService.update(apiAppEntity); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 删除API信息 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @PostMapping("/delete") |
| | | public R delete(@RequestBody Map<String, Object> params) { |
| | | String id = (String)params.get("id"); |
| | | apiInfoService.deleteById(id); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * API信息详情 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @RequestMapping("/info/{id}") |
| | | public R info(@PathVariable("id") String id){ |
| | | ApiInfoEntity sysDictItemEntity = apiInfoService.getInfoById(id); |
| | | |
| | | return R.ok().put("data", sysDictItemEntity); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.gateway.controller; |
| | | |
| | | import com.iailab.module.data.common.utils.PageUtils; |
| | | import com.iailab.module.data.common.utils.R; |
| | | import com.iailab.module.data.gateway.service.ApiServerService; |
| | | import com.iailab.module.data.gateway.entity.ApiServerEntity; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.Date; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年07月15日 14:17:00 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/api-gateway/server") |
| | | public class ApiServerController { |
| | | @Resource |
| | | private ApiServerService apiServerService; |
| | | |
| | | /** |
| | | * API提供方列表 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @GetMapping("/list") |
| | | public R list(@RequestParam Map<String, Object> params) { |
| | | PageUtils page = apiServerService.queryPage(params); |
| | | return R.ok().put("page", page); |
| | | } |
| | | |
| | | /** |
| | | * 新增API提供方 |
| | | * |
| | | * @param apiAppEntity |
| | | * @return |
| | | */ |
| | | @PostMapping("/add") |
| | | public R add(@RequestBody ApiServerEntity apiAppEntity) { |
| | | int count = apiServerService.cheack(apiAppEntity); |
| | | if (count > 0) { |
| | | return R.error("名称或数据值重复"); |
| | | } |
| | | apiAppEntity.setCreateTime(new Date()); |
| | | apiServerService.add(apiAppEntity); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 更新API提供方 |
| | | * |
| | | * @param apiAppEntity |
| | | * @return |
| | | */ |
| | | @PostMapping("/update") |
| | | public R update(@RequestBody ApiServerEntity apiAppEntity) { |
| | | int count = apiServerService.cheack(apiAppEntity); |
| | | if (count > 0) { |
| | | return R.error("名称或数据值重复"); |
| | | } |
| | | apiServerService.update(apiAppEntity); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 删除API提供方 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @PostMapping("/delete") |
| | | public R delete(@RequestBody Map<String, Object> params) { |
| | | String id = (String)params.get("id"); |
| | | apiServerService.deleteById(id); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * API提供方详情 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @RequestMapping("/info/{id}") |
| | | public R info(@PathVariable("id") String id){ |
| | | ApiServerEntity sysDictItemEntity = apiServerService.getInfoById(id); |
| | | |
| | | return R.ok().put("data", sysDictItemEntity); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.gateway.dao; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.iailab.module.data.gateway.entity.ApiAppEntity; |
| | | import com.iailab.module.data.gateway.entity.ApiAppEntity; |
| | | import com.iailab.module.data.gateway.entity.ApiAppEntity; |
| | | import com.iailab.module.data.gateway.entity.ApiAppEntity; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年07月15日 13:53:00 |
| | | */ |
| | | @Mapper |
| | | public interface ApiAppDao extends BaseMapper<ApiAppEntity> { |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.gateway.dao; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.iailab.module.data.gateway.entity.ApiAuthorizedEntity; |
| | | import com.iailab.module.data.gateway.entity.ApiAuthorizedEntity; |
| | | import com.iailab.module.data.gateway.entity.ApiAuthorizedEntity; |
| | | import com.iailab.module.data.gateway.vo.SysGatewayApi; |
| | | import com.iailab.module.data.gateway.entity.ApiAuthorizedEntity; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年07月15日 13:55:00 |
| | | */ |
| | | @Mapper |
| | | public interface ApiAuthorizedDao extends BaseMapper<ApiAuthorizedEntity> { |
| | | |
| | | IPage<ApiAuthorizedEntity> queryList(IPage<ApiAuthorizedEntity> page, @Param("params") Map<String, Object> params); |
| | | |
| | | List<SysGatewayApi> queryListGatewayApi(Map<String, Object> params); |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.gateway.dao; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.iailab.module.data.gateway.entity.ApiGroupEntity; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年07月15日 13:56:00 |
| | | */ |
| | | @Mapper |
| | | public interface ApiGroupDao extends BaseMapper<ApiGroupEntity> { |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.gateway.dao; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.iailab.module.data.gateway.entity.ApiInfoEntity; |
| | | import com.iailab.module.data.gateway.entity.ApiInfoEntity; |
| | | import com.iailab.module.data.gateway.entity.ApiInfoEntity; |
| | | import com.iailab.module.data.gateway.entity.ApiInfoEntity; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年07月15日 13:57:00 |
| | | */ |
| | | @Mapper |
| | | public interface ApiInfoDao extends BaseMapper<ApiInfoEntity> { |
| | | |
| | | IPage<ApiInfoEntity> queryList(IPage<ApiInfoEntity> page, @Param("params") Map<String, Object> params); |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.gateway.dao; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.iailab.module.data.gateway.entity.ApiServerEntity; |
| | | import com.iailab.module.data.gateway.entity.ApiServerEntity; |
| | | import com.iailab.module.data.gateway.entity.ApiServerEntity; |
| | | import com.iailab.module.data.gateway.entity.ApiServerEntity; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年07月15日 13:58:00 |
| | | */ |
| | | @Mapper |
| | | public interface ApiServerDao extends BaseMapper<ApiServerEntity> { |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.gateway.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.iailab.framework.excel.core.annotations.DictFormat; |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | @TableName("t_api_app") |
| | | public class ApiAppEntity { |
| | | |
| | | @TableId(type = IdType.ASSIGN_ID) |
| | | private String id; |
| | | |
| | | private String appName; |
| | | |
| | | private String appKey; |
| | | |
| | | private String appSecret; |
| | | |
| | | private String appDesc; |
| | | |
| | | private Integer status; |
| | | |
| | | @DictFormat("enable") |
| | | @TableField(exist = false) |
| | | private String statusName; |
| | | |
| | | private java.util.Date createTime; |
| | | |
| | | @TableField(exist = false) |
| | | private List<ApiAuthorizedEntity> apiAuthorizedList; |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.gateway.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | @TableName("t_api_authorized") |
| | | public class ApiAuthorizedEntity { |
| | | |
| | | @TableId(type = IdType.ASSIGN_ID) |
| | | private String id; |
| | | |
| | | private String appId; |
| | | |
| | | private String appKey; |
| | | |
| | | private String apiId; |
| | | |
| | | @TableField(exist = false) |
| | | private String serverName; |
| | | |
| | | @TableField(exist = false) |
| | | private String apiName; |
| | | |
| | | @TableField(exist = false) |
| | | private String apiAddress; |
| | | |
| | | private Integer limitMin; |
| | | |
| | | private Integer limitHour; |
| | | |
| | | private Integer limitDay; |
| | | |
| | | private java.util.Date createTime; |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.gateway.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import lombok.Data; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | |
| | | @Data |
| | | @TableName("t_api_group") |
| | | public class ApiGroupEntity { |
| | | |
| | | @TableId(type = IdType.ASSIGN_ID) |
| | | private String id; |
| | | |
| | | private String groupName; |
| | | |
| | | private String groupDesc; |
| | | |
| | | private Integer status; |
| | | |
| | | private java.util.Date createTime; |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.gateway.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | @TableName("t_api_info") |
| | | public class ApiInfoEntity { |
| | | |
| | | @TableId(type = IdType.ASSIGN_ID) |
| | | private String id; |
| | | |
| | | private String apiName; |
| | | |
| | | private String apiGroupId; |
| | | |
| | | @TableField(exist = false) |
| | | private String groupName; |
| | | |
| | | private String apiServerId; |
| | | |
| | | @TableField(exist = false) |
| | | private String serverName; |
| | | |
| | | private String apiDesc; |
| | | |
| | | private String apiAddress; |
| | | |
| | | private Integer status; |
| | | |
| | | private java.util.Date createTime; |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.gateway.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.iailab.framework.excel.core.annotations.DictFormat; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | @TableName("t_api_server") |
| | | public class ApiServerEntity { |
| | | @TableId(type = IdType.ASSIGN_ID) |
| | | private String id; |
| | | |
| | | private String serverName; |
| | | |
| | | private String serverDesc; |
| | | |
| | | private String serverAddress; |
| | | |
| | | private Integer limitMin; |
| | | |
| | | private Integer status; |
| | | |
| | | @DictFormat("enable") |
| | | @TableField(exist = false) |
| | | private String statusName; |
| | | |
| | | private java.util.Date createTime; |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.gateway.form; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年07月19日 17:18:00 |
| | | */ |
| | | @Data |
| | | public class AppLoginForm { |
| | | private String appKey; |
| | | private String appSecret; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.gateway.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.iailab.module.data.common.utils.PageUtils; |
| | | import com.iailab.module.data.gateway.entity.ApiAppEntity; |
| | | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年07月15日 14:00:00 |
| | | */ |
| | | public interface ApiAppService extends IService<ApiAppEntity> { |
| | | |
| | | PageUtils queryPage(Map<String, Object> params); |
| | | |
| | | void add(ApiAppEntity apiAppEntity); |
| | | |
| | | void update(ApiAppEntity apiAppEntity); |
| | | |
| | | void deleteById(String id); |
| | | |
| | | ApiAppEntity getInfoById(String id); |
| | | |
| | | ApiAppEntity getInfoByAppKey(String appKey); |
| | | |
| | | int cheack(ApiAppEntity apiAppEntity); |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.gateway.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.iailab.module.data.common.utils.PageUtils; |
| | | import com.iailab.module.data.gateway.entity.ApiAuthorizedEntity; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年07月15日 14:00:00 |
| | | */ |
| | | public interface ApiAuthorizedService extends IService<ApiAuthorizedEntity> { |
| | | |
| | | PageUtils queryPage(Map<String, Object> params); |
| | | |
| | | List<ApiAuthorizedEntity> queryList(Map<String, Object> params); |
| | | |
| | | void add(ApiAuthorizedEntity dictItemEntity); |
| | | |
| | | void update(ApiAuthorizedEntity dictItemEntity); |
| | | |
| | | void deleteById(String id); |
| | | |
| | | ApiAuthorizedEntity getInfoById(String id); |
| | | |
| | | void grantApi(String appId, List<String> apiIdList); |
| | | |
| | | void addApiRedis(); |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.gateway.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.iailab.module.data.common.utils.PageUtils; |
| | | import com.iailab.module.data.gateway.entity.ApiGroupEntity; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年07月15日 14:00:00 |
| | | */ |
| | | public interface ApiGroupService extends IService<ApiGroupEntity> { |
| | | PageUtils queryPage(Map<String, Object> params); |
| | | |
| | | List<ApiGroupEntity> queryList(); |
| | | |
| | | void add(ApiGroupEntity apiGroupEntity); |
| | | |
| | | void update(ApiGroupEntity apiGroupEntity); |
| | | |
| | | void deleteById(String id); |
| | | |
| | | ApiGroupEntity getInfoById(String id); |
| | | |
| | | int cheack(ApiGroupEntity apiGroupEntity); |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.gateway.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.iailab.module.data.common.utils.PageUtils; |
| | | import com.iailab.module.data.gateway.entity.ApiInfoEntity; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年07月15日 14:01:00 |
| | | */ |
| | | public interface ApiInfoService extends IService<ApiInfoEntity> { |
| | | |
| | | PageUtils queryPage(Map<String, Object> params); |
| | | |
| | | List<ApiInfoEntity> queryList(Map<String, Object> params); |
| | | |
| | | void add(ApiInfoEntity apiInfoEntity); |
| | | |
| | | void update(ApiInfoEntity apiInfoEntity); |
| | | |
| | | void deleteById(String id); |
| | | |
| | | ApiInfoEntity getInfoById(String id); |
| | | |
| | | int cheack(ApiInfoEntity apiInfoEntity); |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.gateway.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.iailab.module.data.common.utils.PageUtils; |
| | | import com.iailab.module.data.gateway.entity.ApiServerEntity; |
| | | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年07月15日 14:01:00 |
| | | */ |
| | | public interface ApiServerService extends IService<ApiServerEntity> { |
| | | PageUtils queryPage(Map<String, Object> params); |
| | | |
| | | void add(ApiServerEntity apiServerEntity); |
| | | |
| | | void update(ApiServerEntity apiServerEntity); |
| | | |
| | | void deleteById(String id); |
| | | |
| | | ApiServerEntity getInfoById(String id); |
| | | |
| | | int cheack(ApiServerEntity apiServerEntity); |
| | | |
| | | void addRouteRedis(); |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.gateway.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.iailab.framework.common.constant.Constant; |
| | | import com.iailab.module.data.common.utils.PageUtils; |
| | | import com.iailab.module.data.common.utils.Query; |
| | | import com.iailab.module.data.gateway.dao.ApiAppDao; |
| | | import com.iailab.module.data.gateway.entity.ApiAppEntity; |
| | | import com.iailab.module.data.gateway.service.ApiAppService; |
| | | import org.apache.commons.lang3.RandomStringUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Map; |
| | | import java.util.UUID; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年07月15日 14:02:00 |
| | | */ |
| | | @Service("apiAppService") |
| | | public class ApiAppServiceImpl extends ServiceImpl<ApiAppDao, ApiAppEntity> implements ApiAppService { |
| | | |
| | | @Override |
| | | public PageUtils queryPage(Map<String, Object> params) { |
| | | String appName = (String)params.get("appName"); |
| | | String appKey = (String)params.get("appKey"); |
| | | IPage<ApiAppEntity> page = this.page( |
| | | new Query<ApiAppEntity>().getPage(params), |
| | | new QueryWrapper<ApiAppEntity>() |
| | | .like(StringUtils.isNotBlank(appName),"app_name", appName) |
| | | .like(StringUtils.isNotBlank(appKey),"app_key", appKey) |
| | | .orderByDesc("create_time") |
| | | ); |
| | | return new PageUtils(page); |
| | | } |
| | | |
| | | @Override |
| | | public void add(ApiAppEntity entity) { |
| | | entity.setId(UUID.randomUUID().toString().replace("-", "")); |
| | | //apiAppEntity.setAppKey(UUID.randomUUID().toString().replace("-", "").substring(0, 16)); |
| | | entity.setAppSecret(StringUtils.isNotBlank(entity.getAppSecret()) ? entity.getAppSecret() : RandomStringUtils.randomAlphanumeric(8)); |
| | | entity.setStatus(Constant.EnableStatus.NORMAL.getValue()); |
| | | this.save(entity); |
| | | } |
| | | |
| | | @Override |
| | | public void update(ApiAppEntity apiAppEntity) { |
| | | this.updateById(apiAppEntity); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteById(String id) { |
| | | this.getBaseMapper().delete(new QueryWrapper<ApiAppEntity>().eq("id", id)); |
| | | } |
| | | |
| | | @Override |
| | | public ApiAppEntity getInfoById(String id) { |
| | | return this.getById(id); |
| | | } |
| | | |
| | | @Override |
| | | public ApiAppEntity getInfoByAppKey(String appKey) { |
| | | return this.getOne(new QueryWrapper<ApiAppEntity>().eq("app_key", appKey)); |
| | | } |
| | | |
| | | @Override |
| | | public int cheack(ApiAppEntity apiAppEntity) { |
| | | String id = apiAppEntity.getId(); |
| | | String appName = apiAppEntity.getAppName(); |
| | | String appKey = apiAppEntity.getAppKey(); |
| | | QueryWrapper<ApiAppEntity> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.ne(StringUtils.isNotBlank(id), "id", id); |
| | | queryWrapper.and(wrapper -> wrapper.eq("app_name", appName).or(). |
| | | eq(StringUtils.isNotBlank(appKey),"app_key", appKey)); |
| | | return (int)this.count(queryWrapper); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.gateway.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.iailab.module.data.common.utils.PageUtils; |
| | | import com.iailab.module.data.common.utils.Query; |
| | | import com.iailab.framework.common.constant.CacheConstant; |
| | | import com.iailab.module.data.gateway.dao.ApiAppDao; |
| | | import com.iailab.module.data.gateway.dao.ApiAuthorizedDao; |
| | | import com.iailab.module.data.gateway.dao.ApiInfoDao; |
| | | import com.iailab.module.data.gateway.entity.ApiAppEntity; |
| | | import com.iailab.module.data.gateway.entity.ApiAuthorizedEntity; |
| | | import com.iailab.module.data.gateway.entity.ApiInfoEntity; |
| | | import com.iailab.module.data.gateway.service.ApiAuthorizedService; |
| | | import com.iailab.module.data.gateway.vo.SysGatewayApi; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.data.redis.core.StringRedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年07月15日 14:02:00 |
| | | */ |
| | | @Service("apiAuthorizedService") |
| | | public class ApiAuthorizedServiceImpl extends ServiceImpl<ApiAuthorizedDao, ApiAuthorizedEntity> implements ApiAuthorizedService { |
| | | |
| | | @Resource |
| | | private ApiAppDao apiAppDao; |
| | | |
| | | @Resource |
| | | private ApiInfoDao apiInfoDao; |
| | | |
| | | @Resource |
| | | private StringRedisTemplate stringRedisTemplate; |
| | | |
| | | @Override |
| | | public PageUtils queryPage(Map<String, Object> params) { |
| | | String appId = (String)params.get("appId"); |
| | | Map<String, Object> queryParams = new HashMap<>(1); |
| | | queryParams.put("appId", appId); |
| | | IPage<ApiAuthorizedEntity> page = getBaseMapper().queryList( |
| | | new Query<ApiAuthorizedEntity>().getPage(params), |
| | | queryParams |
| | | ); |
| | | return new PageUtils(page); |
| | | } |
| | | |
| | | @Override |
| | | public List<ApiAuthorizedEntity> queryList(Map<String, Object> params) { |
| | | String appId = (String)params.get("appId"); |
| | | return getBaseMapper().selectList(new QueryWrapper<ApiAuthorizedEntity>() |
| | | .eq(StringUtils.isNotBlank(appId), "app_id", appId) |
| | | .orderByDesc("create_time")); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void grantApi(String appId, List<String> apiIdList) { |
| | | ApiAppEntity apiAppEntity = apiAppDao.selectById(appId); |
| | | if (apiAppEntity == null) { |
| | | return; |
| | | } |
| | | String appKey = apiAppEntity.getAppKey(); |
| | | getBaseMapper().delete(new QueryWrapper<ApiAuthorizedEntity>().eq("app_id", appId)); |
| | | if (!CollectionUtils.isEmpty(apiIdList)) { |
| | | apiIdList = apiIdList.stream().distinct().collect(Collectors.toList()); |
| | | apiIdList.forEach(item -> { |
| | | ApiInfoEntity apiInfoEntity = apiInfoDao.selectById(item); |
| | | if (apiInfoEntity != null) { |
| | | ApiAuthorizedEntity apiAuthorizedEntity = new ApiAuthorizedEntity(); |
| | | apiAuthorizedEntity.setId(UUID.randomUUID().toString().replace("-", "")); |
| | | apiAuthorizedEntity.setAppId(appId); |
| | | apiAuthorizedEntity.setAppKey(appKey); |
| | | apiAuthorizedEntity.setApiId(apiInfoEntity.getId()); |
| | | apiAuthorizedEntity.setCreateTime(new Date()); |
| | | this.save(apiAuthorizedEntity); |
| | | } |
| | | }); |
| | | } |
| | | addApiRedis(); |
| | | } |
| | | |
| | | @Override |
| | | public void add(ApiAuthorizedEntity apiAuthorizedEntity) { |
| | | this.save(apiAuthorizedEntity); |
| | | addApiRedis(); |
| | | } |
| | | |
| | | @Override |
| | | public void update(ApiAuthorizedEntity apiAuthorizedEntity) { |
| | | this.updateById(apiAuthorizedEntity); |
| | | addApiRedis(); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteById(String id) { |
| | | this.getBaseMapper().delete(new QueryWrapper<ApiAuthorizedEntity>().eq("id", id)); |
| | | addApiRedis(); |
| | | } |
| | | |
| | | @Override |
| | | public ApiAuthorizedEntity getInfoById(String id) { |
| | | return this.getById(id); |
| | | } |
| | | |
| | | @Override |
| | | public void addApiRedis() { |
| | | Map<String, String> apis = new HashMap<>(); |
| | | Map<String, Object> params = new HashMap<>(1); |
| | | params.put("serverStatus", 1); |
| | | List<SysGatewayApi> gatewayApiList = getBaseMapper().queryListGatewayApi(params); |
| | | if (!CollectionUtils.isEmpty(gatewayApiList)) { |
| | | gatewayApiList.forEach(item -> { |
| | | String url = "/" + item.getServerName() + item.getApiAddress(); |
| | | apis.put(item.getAppKey() + "_" + url, item.getApiStatus().toString()); |
| | | }); |
| | | } |
| | | stringRedisTemplate.opsForValue().set(CacheConstant.GATEWAY_APIS, JSON.toJSONString(apis)); |
| | | } |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.gateway.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.iailab.module.data.common.utils.PageUtils; |
| | | import com.iailab.module.data.common.utils.Query; |
| | | import com.iailab.module.data.gateway.dao.ApiGroupDao; |
| | | import com.iailab.module.data.gateway.entity.ApiGroupEntity; |
| | | import com.iailab.module.data.gateway.service.ApiGroupService; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.UUID; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年07月15日 14:02:00 |
| | | */ |
| | | @Service("apiGroupService") |
| | | public class ApiGroupServiceImpl extends ServiceImpl<ApiGroupDao, ApiGroupEntity> implements ApiGroupService { |
| | | |
| | | @Override |
| | | public PageUtils queryPage(Map<String, Object> params) { |
| | | String groupName = (String)params.get("groupName"); |
| | | |
| | | IPage<ApiGroupEntity> page = this.page( |
| | | new Query<ApiGroupEntity>().getPage(params), |
| | | new QueryWrapper<ApiGroupEntity>() |
| | | .like(StringUtils.isNotBlank(groupName),"group_name", groupName) |
| | | .orderByDesc("create_time") |
| | | ); |
| | | return new PageUtils(page); |
| | | } |
| | | |
| | | @Override |
| | | public List<ApiGroupEntity> queryList() { |
| | | return getBaseMapper().selectList(new QueryWrapper<ApiGroupEntity>().orderByDesc("create_time")); |
| | | } |
| | | |
| | | @Override |
| | | public void add(ApiGroupEntity apiGroupEntity) { |
| | | apiGroupEntity.setId(UUID.randomUUID().toString().replace("-", "")); |
| | | apiGroupEntity.setCreateTime(new Date()); |
| | | this.save(apiGroupEntity); |
| | | } |
| | | |
| | | @Override |
| | | public void update(ApiGroupEntity apiGroupEntity) { |
| | | this.updateById(apiGroupEntity); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteById(String id) { |
| | | this.getBaseMapper().delete(new QueryWrapper<ApiGroupEntity>().eq("id", id)); |
| | | } |
| | | |
| | | @Override |
| | | public ApiGroupEntity getInfoById(String id) { |
| | | return this.getById(id); |
| | | } |
| | | |
| | | @Override |
| | | public int cheack(ApiGroupEntity apiGroupEntity) { |
| | | String id = apiGroupEntity.getId(); |
| | | String groupName = apiGroupEntity.getGroupName(); |
| | | |
| | | QueryWrapper<ApiGroupEntity> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.ne(StringUtils.isNotBlank(id), "id", id); |
| | | queryWrapper.and(wrapper -> wrapper.eq("group_name", groupName)); |
| | | return (int)this.count(queryWrapper); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.gateway.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.iailab.module.data.common.utils.PageUtils; |
| | | import com.iailab.module.data.common.utils.Query; |
| | | import com.iailab.module.data.gateway.service.ApiInfoService; |
| | | import com.iailab.module.data.gateway.dao.ApiInfoDao; |
| | | import com.iailab.module.data.gateway.entity.ApiInfoEntity; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年07月15日 14:03:00 |
| | | */ |
| | | @Service("apiInfoService") |
| | | public class ApiInfoServiceImpl extends ServiceImpl<ApiInfoDao, ApiInfoEntity> implements ApiInfoService { |
| | | |
| | | @Override |
| | | public PageUtils queryPage(Map<String, Object> params) { |
| | | String apiName = (String)params.get("apiName"); |
| | | String apiGroupId = (String)params.get("apiGroupId"); |
| | | String apiServerId = (String)params.get("apiServerId"); |
| | | |
| | | Map<String, Object> queryParams = new HashMap<>(3); |
| | | queryParams.put("apiName", apiName); |
| | | queryParams.put("apiGroupId", apiGroupId); |
| | | queryParams.put("apiServerId", apiServerId); |
| | | IPage<ApiInfoEntity> page = getBaseMapper().queryList( |
| | | new Query<ApiInfoEntity>().getPage(queryParams), |
| | | params |
| | | ); |
| | | return new PageUtils(page); |
| | | } |
| | | |
| | | @Override |
| | | public List<ApiInfoEntity> queryList(Map<String, Object> params) { |
| | | String apiGroupId = (String)params.get("apiGroupId"); |
| | | String apiServerId = (String)params.get("apiServerId"); |
| | | return getBaseMapper().selectList(new QueryWrapper<ApiInfoEntity>() |
| | | .eq(StringUtils.isNotBlank(apiGroupId), "api_group_id", apiGroupId) |
| | | .eq(StringUtils.isNotBlank(apiServerId), "api_server_id", apiServerId) |
| | | .orderByDesc("create_time")); |
| | | } |
| | | |
| | | @Override |
| | | public void add(ApiInfoEntity apiInfoEntity) { |
| | | this.save(apiInfoEntity); |
| | | } |
| | | |
| | | @Override |
| | | public void update(ApiInfoEntity apiInfoEntity) { |
| | | this.updateById(apiInfoEntity); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteById(String id) { |
| | | this.getBaseMapper().delete(new QueryWrapper<ApiInfoEntity>().eq("id", id)); |
| | | } |
| | | |
| | | @Override |
| | | public ApiInfoEntity getInfoById(String id) { |
| | | return this.getById(id); |
| | | } |
| | | |
| | | @Override |
| | | public int cheack(ApiInfoEntity apiInfoEntity) { |
| | | String id = apiInfoEntity.getId(); |
| | | String apiName = apiInfoEntity.getApiName(); |
| | | |
| | | QueryWrapper<ApiInfoEntity> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.ne(StringUtils.isNotBlank(id), "id", id); |
| | | queryWrapper.and(wrapper -> wrapper.eq("api_name", apiName)); |
| | | return (int)this.count(queryWrapper); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.gateway.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.iailab.module.data.common.utils.PageUtils; |
| | | import com.iailab.module.data.common.utils.Query; |
| | | import com.iailab.framework.common.constant.CacheConstant; |
| | | import com.iailab.framework.common.constant.GlobalConstants; |
| | | import com.iailab.module.data.gateway.dao.ApiServerDao; |
| | | import com.iailab.module.data.gateway.entity.ApiServerEntity; |
| | | import com.iailab.module.data.gateway.service.ApiServerService; |
| | | import com.iailab.module.data.gateway.vo.SysGatewayRoute; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.UUID; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年07月15日 14:03:00 |
| | | */ |
| | | @Service("apiServerService") |
| | | public class ApiServerServiceImpl extends ServiceImpl<ApiServerDao, ApiServerEntity> implements ApiServerService { |
| | | |
| | | @Resource |
| | | private RedisTemplate<String, Object> redisTemplate; |
| | | |
| | | private final int MINS = 60; |
| | | |
| | | private String filterJson = "[{\"args\":[{\"key\":\"parts\",\"value\":\"1\"}],\"name\":\"StripPrefix\"},{\"args\":[{\"key\":\"key-resolver\",\"value\":\"#{@authorizedApiKeyResolver}\"},{\"key\":\"redis-rate-limiter.replenishRate\",\"value\":1},{\"key\":\"redis-rate-limiter.burstCapacity\",\"value\":60},{\"key\":\"redis-rate-limiter.requestedTokens\",\"value\":requestedTokensValue}],\"name\":\"RequestRateLimiter\"}]"; |
| | | |
| | | @Override |
| | | public PageUtils queryPage(Map<String, Object> params) { |
| | | String serverName = (String)params.get("serverName"); |
| | | |
| | | IPage<ApiServerEntity> page = this.page( |
| | | new Query<ApiServerEntity>().getPage(params), |
| | | new QueryWrapper<ApiServerEntity>() |
| | | .like(StringUtils.isNotBlank(serverName),"server_name", serverName) |
| | | .orderByDesc("create_time") |
| | | ); |
| | | return new PageUtils(page); |
| | | } |
| | | |
| | | @Override |
| | | public void add(ApiServerEntity apiServerEntity) { |
| | | apiServerEntity.setId(UUID.randomUUID().toString().replace("-", "")); |
| | | this.save(apiServerEntity); |
| | | // this.addRouteRedis(); |
| | | } |
| | | |
| | | @Override |
| | | public void update(ApiServerEntity apiServerEntity) { |
| | | this.updateById(apiServerEntity); |
| | | // this.addRouteRedis(); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteById(String id) { |
| | | this.getBaseMapper().delete(new QueryWrapper<ApiServerEntity>().eq("id", id)); |
| | | } |
| | | |
| | | @Override |
| | | public ApiServerEntity getInfoById(String id) { |
| | | return this.getById(id); |
| | | } |
| | | |
| | | @Override |
| | | public int cheack(ApiServerEntity apiServerEntity) { |
| | | String id = apiServerEntity.getId(); |
| | | String serverName = apiServerEntity.getServerName(); |
| | | |
| | | QueryWrapper<ApiServerEntity> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.ne(StringUtils.isNotBlank(id), "id", id); |
| | | queryWrapper.and(wrapper -> wrapper.eq("server_name", serverName)); |
| | | return (int)this.count(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public void addRouteRedis() { |
| | | List<SysGatewayRoute> ls = new ArrayList<>(); |
| | | List<ApiServerEntity> list = getBaseMapper().selectList(new QueryWrapper<>()); |
| | | if (!CollectionUtils.isEmpty(list)) { |
| | | ls = list.stream().map(item -> { |
| | | SysGatewayRoute sysGatewayRoute = new SysGatewayRoute(); |
| | | sysGatewayRoute.setId(item.getId()); |
| | | sysGatewayRoute.setRouterId(item.getServerName()); |
| | | sysGatewayRoute.setName(item.getServerName()); |
| | | sysGatewayRoute.setUri(item.getServerAddress()); |
| | | sysGatewayRoute.setPredicates("[{\"args\":[\"/" + item.getServerName() +"/**\"],\"name\":\"Path\"}]"); |
| | | sysGatewayRoute.setFilters("[{\"args\":[{\"key\":\"parts\",\"value\":\"1\"}],\"name\":\"StripPrefix\"}]"); |
| | | if (item.getLimitMin() != null && item.getLimitMin().compareTo(MINS) <= 0) { |
| | | String requestedTokensValue = (new BigDecimal(MINS)).divide(new BigDecimal(item.getLimitMin()), 0, BigDecimal.ROUND_FLOOR).toString(); |
| | | sysGatewayRoute.setFilters(filterJson.replace("requestedTokensValue", requestedTokensValue)); |
| | | } |
| | | sysGatewayRoute.setStatus(item.getStatus()); |
| | | return sysGatewayRoute; |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | redisTemplate.opsForValue().set(CacheConstant.GATEWAY_ROUTES, JSON.toJSONString(ls)); |
| | | //刷新网关 |
| | | redisTemplate.convertAndSend(GlobalConstants.REDIS_TOPIC_NAME, GlobalConstants.LODER_ROUDER_HANDLER); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.gateway.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年07月20日 10:34:00 |
| | | */ |
| | | @Data |
| | | public class SysGatewayApi implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | private String appKey; |
| | | |
| | | private Integer apiStatus; |
| | | |
| | | private String apiAddress; |
| | | |
| | | private String serverName; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.gateway.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年07月19日 22:32:00 |
| | | */ |
| | | @Data |
| | | public class SysGatewayRoute implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /**主键*/ |
| | | private String id; |
| | | |
| | | /**routerKEy*/ |
| | | private String routerId; |
| | | |
| | | /**服务名*/ |
| | | private String name; |
| | | |
| | | /**服务地址*/ |
| | | private String uri; |
| | | |
| | | /** |
| | | * 断言配置 |
| | | */ |
| | | private String predicates; |
| | | |
| | | /** |
| | | * 过滤配置 |
| | | */ |
| | | private String filters; |
| | | |
| | | /**是否忽略前缀0-否 1-是*/ |
| | | private Integer stripPrefix; |
| | | |
| | | /**是否重试0-否 1-是*/ |
| | | private Integer retryable; |
| | | |
| | | /**是否为保留数据:0-否 1-是*/ |
| | | private Integer persistable; |
| | | |
| | | /**是否在接口文档中展示:0-否 1-是*/ |
| | | private Integer showApi; |
| | | |
| | | /**状态 1有效 0无效*/ |
| | | private Integer status; |
| | | |
| | | /**创建日期*/ |
| | | private Date createTime; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.http.collector; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.iailab.module.data.common.utils.HttpsRequest; |
| | | import com.iailab.api.IFeignModelApi; |
| | | import com.iailab.module.data.http.entity.HttpApiEntity; |
| | | import com.iailab.module.data.http.service.HttpTokenService; |
| | | import com.iailab.module.data.http.service.HttpApiService; |
| | | import com.iailab.module.data.http.service.HttpTagService; |
| | | import com.iailab.module.data.influxdb.service.InfluxDBService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 山大设备数据采集 |
| | | * |
| | | * @author lirm |
| | | * @Description |
| | | * @createTime 2024年05月21日 |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class HttpCollectorForSD { |
| | | |
| | | @Resource |
| | | private HttpApiService httpApiService; |
| | | |
| | | @Resource |
| | | private HttpTagService httpTagService; |
| | | |
| | | @Resource |
| | | HttpTokenService httpTokenService; |
| | | @Resource |
| | | HttpsRequest httpsRequest; |
| | | |
| | | @Resource |
| | | private IFeignModelApi feignModelApi; |
| | | |
| | | @Resource |
| | | private InfluxDBService influxDBService; |
| | | |
| | | public void getRunStateValue(Map<String, String> tMap) { |
| | | Map<String, Integer> monitorCountMap = new HashMap<>(); |
| | | HttpApiEntity httpApi = httpApiService.getByCode(tMap.get("code")); |
| | | String token = httpTokenService.queryToken(tMap.get("client_id")); |
| | | Map<String, String> queryParams = new HashMap<>(); |
| | | queryParams.put("cu_ids", tMap.get("cu_ids")); |
| | | queryParams.put("t", tMap.get("t")); |
| | | String responseStr = httpsRequest.doGetSDData(httpApi.getUrl(), queryParams, "utf-8", token, tMap); |
| | | JSONObject responseObj = JSON.parseObject(responseStr); |
| | | if ("0".equals(responseObj.get("code").toString())) { |
| | | JSONObject dataObject = (JSONObject) responseObj.get("data"); |
| | | |
| | | JSONArray hasSensorArray = dataObject.getJSONArray("has_sensor"); |
| | | if (!CollectionUtils.isEmpty(hasSensorArray)) { |
| | | for (int i = 0; i < hasSensorArray.size(); i++) { |
| | | JSONObject item = hasSensorArray.getJSONObject(i); |
| | | String value = item.get("de_has_sensor").toString(); |
| | | if ("yes".equals(value)) { |
| | | monitorCountMap.put("total_count", Integer.parseInt(item.get("count").toString()));//在线监控设备数量 |
| | | } |
| | | } |
| | | } |
| | | JSONArray stateArray = dataObject.getJSONArray("state"); |
| | | if (!CollectionUtils.isEmpty(stateArray)) { |
| | | monitorCountMap.put("offline_count", 0); |
| | | monitorCountMap.put("halt_count", 0); |
| | | monitorCountMap.put("run_count", 0); |
| | | for (int i = 0; i < stateArray.size(); i++) { |
| | | JSONObject item = stateArray.getJSONObject(i); |
| | | String value = item.get("device_state").toString(); |
| | | if ("0".equals(value)) { |
| | | monitorCountMap.put("offline_count", Integer.parseInt(item.get("count").toString()));//离线设备数量 |
| | | } else if ("1".equals(value)) { |
| | | monitorCountMap.put("halt_count", Integer.parseInt(item.get("count").toString()));//停机设备数量 |
| | | } else if ("2".equals(value)) { |
| | | monitorCountMap.put("run_count", Integer.parseInt(item.get("count").toString()));//运行设备数量 |
| | | } |
| | | } |
| | | } |
| | | if (!monitorCountMap.isEmpty()) { |
| | | feignModelApi.insertRunState(monitorCountMap); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void getHealthStateValue(Map<String, String> tMap) { |
| | | Map<String, Object> monitorCountMap = new HashMap<>(); |
| | | HttpApiEntity httpApi = httpApiService.getByCode(tMap.get("code")); |
| | | String token = httpTokenService.queryToken(tMap.get("client_id")); |
| | | Map<String, String> queryParams = new HashMap<>(); |
| | | queryParams.put("cu_ids", tMap.get("cu_ids")); |
| | | queryParams.put("t", tMap.get("t")); |
| | | String responseStr = httpsRequest.doGetSDData(httpApi.getUrl(), queryParams, "utf-8", token, tMap); |
| | | JSONObject responseObj = JSON.parseObject(responseStr); |
| | | if ("0".equals(responseObj.get("code").toString())) { |
| | | JSONArray hasSensorArray = responseObj.getJSONArray("data"); |
| | | if (!CollectionUtils.isEmpty(hasSensorArray)) { |
| | | for (int i = 0; i < hasSensorArray.size(); i++) { |
| | | JSONObject item = hasSensorArray.getJSONObject(i); |
| | | String value = item.get("fault_level").toString(); |
| | | if ("0".equals(value)) { |
| | | monitorCountMap.put("normal", item.get("count"));//正常 |
| | | } else if ("1".equals(value)) { |
| | | monitorCountMap.put("common", item.get("count"));//一般 |
| | | } else if ("2".equals(value)) { |
| | | monitorCountMap.put("heavy", item.get("count"));//较重 |
| | | } else if ("3".equals(value)) { |
| | | monitorCountMap.put("serious", item.get("count"));//严重 |
| | | } else if ("4".equals(value)) { |
| | | monitorCountMap.put("espSerious", item.get("count"));//特别严重 |
| | | } |
| | | } |
| | | } |
| | | if (!monitorCountMap.isEmpty()) { |
| | | feignModelApi.insertHealthState(monitorCountMap); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void getDeviceList(Map<String, String> tMap) { |
| | | HttpApiEntity httpApi = httpApiService.getByCode(tMap.get("code")); |
| | | tMap.put("url", httpApi.getUrl()); |
| | | |
| | | feignModelApi.insertDeviceList(tMap); |
| | | } |
| | | |
| | | public void getTemperatureValue(Map<String, String> tMap, Date date) { |
| | | Map<String, Object> monitorCountMap = new HashMap<>(); |
| | | HttpApiEntity httpApi = httpApiService.getByCode(tMap.get("code")); |
| | | String token = httpTokenService.queryToken(tMap.get("client_id")); |
| | | List<String> deviceIdList = feignModelApi.getDeviceIdList(); |
| | | if (!CollectionUtils.isEmpty(deviceIdList)) { |
| | | for (String deviceId : deviceIdList) { |
| | | List<String> tagNoList = httpTagService.getByTagType(deviceId); |
| | | if (CollectionUtils.isEmpty(tagNoList)) { |
| | | continue; |
| | | } |
| | | StringBuffer sb = new StringBuffer(); |
| | | sb.append(httpApi.getUrl()); |
| | | sb.append("/"); |
| | | sb.append(deviceId); |
| | | Map<String, String> queryParams = new HashMap<>(); |
| | | String responseStr = httpsRequest.doGetSDData(sb.toString(), queryParams, "utf-8", token, tMap); |
| | | JSONObject responseObj = JSON.parseObject(responseStr); |
| | | if ("200".equals(responseObj.get("status").toString())) { |
| | | JSONObject dataObject = (JSONObject) responseObj.get("data"); |
| | | JSONArray jsonArray = dataObject.getJSONArray("realtime-params"); |
| | | if (!CollectionUtils.isEmpty(jsonArray)) { |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | JSONObject item = jsonArray.getJSONObject(i); |
| | | String order = item.get("cp_order").toString(); |
| | | String name = item.get("param_name").toString(); |
| | | if ("1".equals(order) && "温度".equals(name)) { |
| | | for (String tagCode : tagNoList) { |
| | | String value = item.get("last_value").toString(); |
| | | // Date date = DateUtils.parse(item.get("last_time").toString(),"yyyy-MM-dd HH:mm:ss"); |
| | | if (tagCode.contains("Temperature")) { |
| | | influxDBService.syncWriteFloatValue(tagCode, value, date.getTime()); |
| | | } |
| | | } |
| | | } |
| | | if ("1".equals(order) && "1倍频振幅".equals(name)) { |
| | | for (String tagCode : tagNoList) { |
| | | String value = item.get("last_value").toString(); |
| | | // Date date = DateUtils.parse(item.get("last_time").toString(),"yyyy-MM-dd HH:mm:ss"); |
| | | if (tagCode.contains("Flutter")) { |
| | | influxDBService.syncWriteFloatValue(tagCode, value, date.getTime()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.http.collector; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.iailab.module.data.common.utils.HttpsRequest; |
| | | import com.iailab.module.data.http.entity.HttpApiEntity; |
| | | import com.iailab.module.data.http.service.HttpApiService; |
| | | import com.iailab.module.system.api.permission.RoleApi; |
| | | import com.iailab.module.system.api.permission.dto.RoleDTO; |
| | | import com.iailab.module.system.api.user.AdminUserApi; |
| | | import com.iailab.module.system.api.user.dto.AdminUserRespDTO; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 山大设备数据采集 |
| | | * |
| | | * @author lirm |
| | | * @Description |
| | | * @createTime 2024年05月21日 |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class HttpCollectorForUser { |
| | | |
| | | @Resource |
| | | private HttpApiService httpApiService; |
| | | |
| | | @Resource |
| | | HttpsRequest httpsRequest; |
| | | |
| | | @Resource |
| | | private AdminUserApi adminUserApi; |
| | | |
| | | @Resource |
| | | private RoleApi roleApi; |
| | | |
| | | public void saveJobInfo(Map<String, String> tMap) { |
| | | HttpApiEntity httpApi = httpApiService.getByCode(tMap.get("code")); |
| | | String responseStr = httpsRequest.doGet(httpApi.getUrl(), null, "utf-8", ""); |
| | | log.info("JobInfo responseStr:" + responseStr); |
| | | JSONObject responseObj = JSON.parseObject(responseStr); |
| | | if ("true".equals(responseObj.get("sta").toString())) { |
| | | JSONArray jsonArray = responseObj.getJSONArray("res"); |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | JSONObject jsonObject = jsonArray.getJSONObject(i); |
| | | RoleDTO role = new RoleDTO(); |
| | | role.setName(jsonObject.getString("name")); |
| | | role.setUpdateDate(new Date()); |
| | | log.info("同步保存的角色名称为:" + role.getName()); |
| | | roleApi.saveRoleInfo(role); |
| | | } |
| | | } |
| | | |
| | | } |
| | | public void saveUserInfo(Map<String, String> tMap) { |
| | | HttpApiEntity httpApi = httpApiService.getByCode(tMap.get("code")); |
| | | String responseStr = httpsRequest.doGet(httpApi.getUrl(), null, "utf-8", ""); |
| | | log.info("responseStr:" + responseStr); |
| | | JSONObject responseObj = JSON.parseObject(responseStr); |
| | | if ("true".equals(responseObj.get("sta").toString())) { |
| | | JSONArray jsonArray = responseObj.getJSONArray("res"); |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | JSONObject jsonObject = jsonArray.getJSONObject(i); |
| | | AdminUserRespDTO sysUser = new AdminUserRespDTO(); |
| | | sysUser.setUsername(jsonObject.getString("no")); |
| | | sysUser.setNickname(jsonObject.getString("name")); |
| | | sysUser.setMobile(jsonObject.getString("phone")); |
| | | sysUser.setStatus(1); |
| | | //添加用户角色 |
| | | RoleDTO role = roleApi.getRoleByName(jsonObject.getString("job")); |
| | | Set<Long> roleIdList = new HashSet<>(); |
| | | roleIdList.add(role.getId()); |
| | | //为用户添加默认角色 |
| | | roleIdList.add(2L); |
| | | sysUser.setRoleIdList(roleIdList); |
| | | adminUserApi.saveOrUpdateUserInfo(sysUser); |
| | | } |
| | | } |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.http.collector; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.iailab.module.data.common.enums.CommonConstant; |
| | | import com.iailab.module.data.common.enums.DataSourceType; |
| | | import com.iailab.module.data.common.utils.HttpsRequest; |
| | | import com.iailab.module.data.common.utils.TagUtils; |
| | | import com.iailab.module.data.http.entity.HttpApiEntity; |
| | | import com.iailab.module.data.http.service.HttpApiService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 中选时序数据采集 |
| | | * http://192.168.55.122/api/Data/CurrentData?domain=NttRslinxLogic&tagstr=[ZX1]D_113.State.KM,[ZX1]D_114.State.KM |
| | | * domain:限定数据域,可空,为空时不限定数据域。 |
| | | * tagstr:限定标签集合,可空,为空时不限定标签。格式为英文逗号分隔的一个或多个标签名,如tag1,tag2,由于标签中可能包含特殊字符,get参数需要对此参数进行encode处理。 |
| | | * { |
| | | * "sta": true, |
| | | * "msg": null, |
| | | * "res": [ |
| | | * { |
| | | * "Tag": "[ZX1]D_110.State.KM",//标签 |
| | | * "Value": 0//当前值 |
| | | * }, |
| | | * |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年05月16日 |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class HttpCollectorForZxzk { |
| | | |
| | | private Map<String, HttpApiEntity> apiMap = new HashMap<>(); |
| | | |
| | | @Resource |
| | | private HttpApiService httpApiService; |
| | | |
| | | @Resource |
| | | HttpsRequest httpsRequest; |
| | | |
| | | private final String STA_TRUE = "true"; |
| | | |
| | | private final int GROUP_MAX_COUNT = 50; |
| | | |
| | | private HttpApiEntity getHttpApi(String id) { |
| | | if (apiMap.containsKey(id)) { |
| | | return apiMap.get(id); |
| | | } |
| | | HttpApiEntity httpApi = httpApiService.get(id); |
| | | apiMap.put(id, httpApi); |
| | | return httpApi; |
| | | } |
| | | |
| | | public BigDecimal getTagValue(String sourceId, String tagNo) { |
| | | BigDecimal value = CommonConstant.BAD_VALUE; |
| | | HttpApiEntity httpApi = this.getHttpApi(sourceId); |
| | | Map<String, String> queryParams = new HashMap<>(); |
| | | queryParams.put("tagstr", tagNo); |
| | | String responseStr = httpsRequest.doGet(httpApi.getUrl(), queryParams, "utf-8", ""); |
| | | JSONObject responseObj = JSON.parseObject(responseStr); |
| | | if (STA_TRUE.equals(responseObj.get("sta").toString())) { |
| | | JSONArray tagValueList = responseObj.getJSONArray("res"); |
| | | if (!CollectionUtils.isEmpty(tagValueList)) { |
| | | for (int i = 0; i < tagValueList.size(); i++) { |
| | | JSONObject item = tagValueList.getJSONObject(i); |
| | | value = new BigDecimal(item.get("Value").toString()); |
| | | } |
| | | } |
| | | } |
| | | return value; |
| | | } |
| | | |
| | | |
| | | public Map<String, Object> getTagValues(List<String[]> params) { |
| | | if (CollectionUtils.isEmpty(params)) { |
| | | return new HashMap<>(); |
| | | } |
| | | |
| | | Map<Integer, List<String[]>> measurePointsCountGroup = new HashMap<>(); |
| | | int pointListSize = params.size(); |
| | | int groupCount = pointListSize / GROUP_MAX_COUNT + ((pointListSize % GROUP_MAX_COUNT) > 0 ? 1 : 0); |
| | | log.info("groupCount=" + groupCount); |
| | | for (int i = 0; i < groupCount; i++) { |
| | | int end = (i + 1) * GROUP_MAX_COUNT; |
| | | if (end > pointListSize) { |
| | | end = pointListSize; |
| | | } |
| | | measurePointsCountGroup.put(i, params.subList(i * GROUP_MAX_COUNT, end)); |
| | | } |
| | | Map<String, Object> result = new HashMap<>(params.size()); |
| | | for(Map.Entry<Integer, List<String[]>> measurePointsItem : measurePointsCountGroup.entrySet()) { |
| | | try { |
| | | getByHtp(result, measurePointsItem.getValue()); |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | private void getByHtp(Map<String, Object> result, List<String[]> params) { |
| | | HttpApiEntity httpApi = this.getHttpApi(params.get(0)[0]); |
| | | Map<String, String> queryParams = new HashMap<>(); |
| | | StringBuilder tagSb = new StringBuilder(); |
| | | for (int i = 0; i < params.size(); i ++) { |
| | | tagSb.append(params.get(i)[1]); |
| | | if (i < params.size() - 1) { |
| | | tagSb.append(","); |
| | | } |
| | | } |
| | | queryParams.put("tagstr", tagSb.toString()); |
| | | String responseStr = httpsRequest.doGet(httpApi.getUrl(), queryParams, "utf-8", ""); |
| | | JSONObject responseObj = JSON.parseObject(responseStr); |
| | | if (STA_TRUE.equals(responseObj.get("sta").toString())) { |
| | | JSONArray tagValueList = responseObj.getJSONArray("res"); |
| | | if (!CollectionUtils.isEmpty(tagValueList)) { |
| | | for (int i = 0; i < tagValueList.size(); i++) { |
| | | JSONObject item = tagValueList.getJSONObject(i); |
| | | result.put(TagUtils.genTagId(DataSourceType.HTTP.getCode(), httpApi.getCode(), item.get("Tag").toString()), item.get("Value")); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.http.controller.admin; |
| | | |
| | | import com.iailab.framework.common.page.PageData; |
| | | import com.iailab.module.data.common.utils.R; |
| | | import com.iailab.framework.common.pojo.CommonResult; |
| | | import com.iailab.module.data.http.entity.HttpApiEntity; |
| | | import com.iailab.module.data.http.service.HttpApiService; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.UUID; |
| | | |
| | | import static com.iailab.framework.common.pojo.CommonResult.success; |
| | | |
| | | @RestController |
| | | @RequestMapping("/data/http/api") |
| | | public class HttpApiController { |
| | | |
| | | @Resource |
| | | private HttpApiService httpApiService; |
| | | |
| | | @GetMapping("page") |
| | | public CommonResult<PageData<HttpApiEntity>> page(@RequestParam Map<String, Object> params) { |
| | | PageData<HttpApiEntity> page = httpApiService.page(params); |
| | | return success(page); |
| | | } |
| | | |
| | | @GetMapping("list") |
| | | public CommonResult<List<HttpApiEntity>> list() { |
| | | List<HttpApiEntity> list = httpApiService.list(); |
| | | return new CommonResult<List<HttpApiEntity>>().setData(list); |
| | | } |
| | | |
| | | /** |
| | | * 根据id查询详情 |
| | | * |
| | | * @param id |
| | | */ |
| | | @GetMapping("/info/{id}") |
| | | public R info(@PathVariable("id") String id){ |
| | | HttpApiEntity info= httpApiService.selectById(id); |
| | | return R.ok().put("data", info); |
| | | } |
| | | /** |
| | | * 添加API |
| | | * |
| | | * @param httpApiEntity |
| | | */ |
| | | @PostMapping("/add") |
| | | public R add(@RequestBody HttpApiEntity httpApiEntity){ |
| | | String id = UUID.randomUUID().toString(); |
| | | httpApiEntity.setId(id); |
| | | httpApiService.insert(httpApiEntity); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 修改API |
| | | * |
| | | * @param httpApiEntity |
| | | */ |
| | | @PostMapping("/update") |
| | | public R update(@RequestBody HttpApiEntity httpApiEntity) { |
| | | httpApiService.updateById(httpApiEntity); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 删除API |
| | | * |
| | | * @param params |
| | | * |
| | | */ |
| | | @PostMapping("/delete") |
| | | public R delete(@RequestBody Map<String, Object> params) { |
| | | String id = (String)params.get("id"); |
| | | httpApiService.deleteById(id); |
| | | return R.ok(); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.http.controller.admin; |
| | | |
| | | import com.iailab.module.data.common.utils.PageUtils; |
| | | import com.iailab.module.data.common.utils.R; |
| | | import com.iailab.framework.common.pojo.CommonResult; |
| | | import com.iailab.module.data.http.dto.HttpTagDTO; |
| | | import com.iailab.module.data.http.entity.HttpTagEntity; |
| | | import com.iailab.module.data.http.service.HttpTagService; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.UUID; |
| | | |
| | | /** |
| | | * @author Houzhongjian |
| | | * @Description |
| | | * @createTime 2024年04月10日 17:37:00 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/data/http/tag") |
| | | public class HttpTagController { |
| | | |
| | | @Resource |
| | | private HttpTagService tagService; |
| | | |
| | | /** |
| | | * 分页 |
| | | * |
| | | * @param params |
| | | */ |
| | | @GetMapping("/page") |
| | | public R tagPageList(@RequestParam Map<String, Object> params) { |
| | | PageUtils page = tagService.queryPage(params); |
| | | |
| | | return R.ok().put("page", page); |
| | | } |
| | | |
| | | /** |
| | | * 查询tagList |
| | | * |
| | | */ |
| | | @GetMapping("/list") |
| | | public R tagList(@RequestParam Map<String, Object> params){ |
| | | List<HttpTagEntity> data = tagService.selectList(params); |
| | | |
| | | return R.ok().put("data", data); |
| | | } |
| | | |
| | | /** |
| | | * 详情 |
| | | * |
| | | * @param id |
| | | */ |
| | | @GetMapping("/info/{id}") |
| | | public R tagInfo(@PathVariable("id") String id) { |
| | | HttpTagEntity info = tagService.selectById(id); |
| | | return R.ok().put("data", info); |
| | | } |
| | | |
| | | /** |
| | | * 添加 |
| | | * |
| | | * @param entity |
| | | */ |
| | | @PostMapping("/add") |
| | | public R tagAdd(@RequestBody HttpTagEntity entity) { |
| | | entity.setId(UUID.randomUUID().toString()); |
| | | tagService.insert(entity); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 修改 |
| | | * |
| | | * @param entity |
| | | */ |
| | | @PostMapping("/update") |
| | | public R tagUpdate(@RequestBody HttpTagEntity entity) { |
| | | tagService.updateById(entity); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 删除 |
| | | * |
| | | * @param params |
| | | */ |
| | | @PostMapping("/delete") |
| | | public R tagDelete(@RequestBody Map<String, Object> params) { |
| | | String id = (String) params.get("id"); |
| | | tagService.deleteById(id); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | @GetMapping("tagNo") |
| | | public CommonResult<List<HttpTagDTO>> list(@RequestParam Map<String, Object> params){ |
| | | List<HttpTagDTO> list = tagService.list(params); |
| | | return new CommonResult<List<HttpTagDTO>>().setData(list); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.http.controller.admin; |
| | | |
| | | import com.iailab.framework.common.page.PageData; |
| | | import com.iailab.module.data.common.utils.R; |
| | | import com.iailab.framework.common.pojo.CommonResult; |
| | | import com.iailab.module.data.http.entity.HttpTokenEntity; |
| | | import com.iailab.module.data.http.service.HttpTokenService; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.Map; |
| | | import java.util.UUID; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2023年12月22日 10:52:00 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/data/http/token") |
| | | public class HttpTokenController { |
| | | |
| | | @Resource |
| | | private HttpTokenService httpTokenService; |
| | | |
| | | /** |
| | | * 分页 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @GetMapping("page") |
| | | public CommonResult<PageData<HttpTokenEntity>> page(@RequestParam Map<String, Object> params) { |
| | | PageData<HttpTokenEntity> page = httpTokenService.page(params); |
| | | |
| | | return new CommonResult<PageData<HttpTokenEntity>>().setData(page); |
| | | } |
| | | |
| | | /** |
| | | * 详情 |
| | | * |
| | | * @param id |
| | | */ |
| | | @GetMapping("/info/{id}") |
| | | public R info(@PathVariable("id") String id) { |
| | | HttpTokenEntity info = httpTokenService.selectById(id); |
| | | return R.ok().put("data", info); |
| | | } |
| | | |
| | | /** |
| | | * 详情 |
| | | * |
| | | * @param apiId |
| | | */ |
| | | @GetMapping("/api-id/{apiId}") |
| | | public R apiId(@PathVariable("apiId") String apiId) { |
| | | HttpTokenEntity info = httpTokenService.getByApiId(apiId); |
| | | return R.ok().put("data", info); |
| | | } |
| | | |
| | | /** |
| | | * 添加 |
| | | * |
| | | * @param httpApiEntity |
| | | */ |
| | | @PostMapping("/add") |
| | | public R add(@RequestBody HttpTokenEntity httpApiEntity) { |
| | | String id = UUID.randomUUID().toString(); |
| | | httpApiEntity.setId(id); |
| | | httpTokenService.insert(httpApiEntity); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 修改 |
| | | * |
| | | * @param httpApiEntity |
| | | */ |
| | | @PostMapping("/update") |
| | | public R update(@RequestBody HttpTokenEntity httpApiEntity) { |
| | | httpTokenService.updateById(httpApiEntity); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 删除 |
| | | * |
| | | * @param params |
| | | */ |
| | | @PostMapping("/delete") |
| | | public R delete(@RequestBody Map<String, Object> params) { |
| | | String id = (String) params.get("id"); |
| | | httpTokenService.deleteById(id); |
| | | return R.ok(); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.http.controller; |
对比新文件 |
| | |
| | | package com.iailab.module.data.http.dao; |
| | | |
| | | import com.iailab.framework.common.dao.BaseDao; |
| | | import com.iailab.module.data.http.entity.EleLowTagEntity; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2023年12月19日 08:35:00 |
| | | */ |
| | | @Mapper |
| | | public interface EleLowTagDao extends BaseDao<EleLowTagEntity> { |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.http.dao; |
| | | |
| | | import com.iailab.framework.common.dao.BaseDao; |
| | | import com.iailab.module.data.http.entity.FxjyTagEntity; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @author DongYukun |
| | | * @Description |
| | | * @createTime 2024年01月17日 13:13:00 |
| | | */ |
| | | @Mapper |
| | | public interface FxjyTagDao extends BaseDao<FxjyTagEntity> { |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.http.dao; |
| | | |
| | | import com.iailab.framework.common.dao.BaseDao; |
| | | import com.iailab.module.data.http.entity.HttpApiEntity; |
| | | import com.iailab.module.data.http.entity.HttpApiEntity; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | @Mapper |
| | | public interface HttpApiDao extends BaseDao<HttpApiEntity> { |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.http.dao; |
| | | |
| | | import com.iailab.framework.common.dao.BaseDao; |
| | | import com.iailab.module.data.http.dto.HttpTagDTO; |
| | | import com.iailab.module.data.http.entity.HttpTagEntity; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author Houzhongjian |
| | | * @Description |
| | | * @createTime 2024年04月10日 17:35:00 |
| | | */ |
| | | @Mapper |
| | | public interface HttpTagDao extends BaseDao<HttpTagEntity> { |
| | | List<HttpTagDTO> getList(Map<String, Object> params); |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.http.dao; |
| | | |
| | | import com.iailab.framework.common.dao.BaseDao; |
| | | import com.iailab.module.data.http.entity.HttpTokenEntity; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | @Mapper |
| | | public interface HttpTokenDao extends BaseDao<HttpTokenEntity> { |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.http.dao; |
| | | |
| | | import com.iailab.framework.common.dao.BaseDao; |
| | | import com.iailab.module.data.http.entity.XSTTagEntity; |
| | | import com.iailab.module.data.http.entity.XSTTagEntity; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | @Mapper |
| | | public interface XSTTagDao extends BaseDao<XSTTagEntity> { |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.http.dto; |
| | | |
| | | import lombok.Data; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * @author lirm |
| | | * @Description |
| | | * @createTime 2024年06月03日 |
| | | */ |
| | | @Component |
| | | @Data |
| | | public class HttpTagDTO { |
| | | private String tagType; |
| | | private String tagCode; |
| | | private String tagName; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.http.dto; |
| | | |
| | | import lombok.Data; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | @Data |
| | | public class TagAffectDetailsJsonDto implements Serializable { |
| | | private String sta; |
| | | private String msg; |
| | | private DATA res; |
| | | |
| | | @Component |
| | | @Data |
| | | public static class DATA{ |
| | | |
| | | private List<AFFECTDETAILS> affectDetails; |
| | | |
| | | @Data |
| | | public static class AFFECTDETAILS { |
| | | //区域 |
| | | String area; |
| | | //时间 |
| | | String date; |
| | | //开始时间 |
| | | String starttime; |
| | | //结束时间 |
| | | String endtime; |
| | | //影响时间(时分秒格式) |
| | | String affecttime; |
| | | //停机原因 |
| | | String info; |
| | | } |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.http.dto; |
| | | |
| | | import lombok.Data; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * @author Houzhongjian |
| | | * @Description |
| | | * @createTime 2024年04月10日 17:35:00 |
| | | */ |
| | | @Component |
| | | @Data |
| | | public class TagCommonCurrentDto { |
| | | private String tagType; |
| | | private String tagCode; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.http.dto; |
| | | |
| | | import lombok.Data; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | @Component |
| | | @Data |
| | | public class TagCurrentPerformanceJsonDto implements Serializable { |
| | | private String sta; |
| | | private String msg; |
| | | private DATA res; |
| | | |
| | | @Data |
| | | public static class DATA{ |
| | | TODAY today; |
| | | YESTERDAY yesterday; |
| | | CURRENTMONTH currentMonth; |
| | | CURRENTYEAR currentYear; |
| | | @Data |
| | | public static class TODAY{ |
| | | //筛选产量 |
| | | String xxPerformance; |
| | | //栈桥运输量 |
| | | String zqPerformance; |
| | | } |
| | | @Data |
| | | public static class YESTERDAY{ |
| | | //筛选产量 |
| | | String xxPerformance; |
| | | //栈桥运输量 |
| | | String zqPerformance; |
| | | } |
| | | @Data |
| | | public static class CURRENTMONTH{ |
| | | //筛选产量 |
| | | String xxPerformance; |
| | | //栈桥运输量 |
| | | String zqPerformance; |
| | | } |
| | | @Data |
| | | public static class CURRENTYEAR{ |
| | | //筛选产量 |
| | | String xxPerformance; |
| | | //栈桥运输量 |
| | | String zqPerformance; |
| | | } |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.http.dto; |
| | | |
| | | import lombok.Data; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | @Component |
| | | @Data |
| | | public class TagCurrentSaleJsonDto implements Serializable { |
| | | private String sta; |
| | | private String msg; |
| | | private DATA res; |
| | | |
| | | @Component |
| | | @Data |
| | | public static class DATA{ |
| | | private TODAY today; |
| | | private YESTERDAY yesterday; |
| | | private CURRENTMONTH currentmonth; |
| | | private CURRENTYEAR currentyear; |
| | | |
| | | @Data |
| | | public static class TODAY { |
| | | //地销混煤 |
| | | String groundsales; |
| | | //洗中块 |
| | | String medblock; |
| | | //洗小块 |
| | | String nubmeasure; |
| | | //矸石 |
| | | String gangue; |
| | | //小块转载 |
| | | String reshipped; |
| | | //火车外运吨数 |
| | | String trainTon; |
| | | //火车外运列数 |
| | | String trainCount; |
| | | } |
| | | @Data |
| | | public static class YESTERDAY { |
| | | //地销混煤 |
| | | String groundsales; |
| | | //洗中块 |
| | | String medblock; |
| | | //洗小块 |
| | | String nubmeasure; |
| | | //矸石 |
| | | String gangue; |
| | | //小块转载 |
| | | String reshipped; |
| | | //火车外运吨数 |
| | | String trainTon; |
| | | //火车外运列数 |
| | | String trainCount; |
| | | } |
| | | @Data |
| | | public static class CURRENTMONTH { |
| | | //地销混煤 |
| | | String groundsales; |
| | | //洗中块 |
| | | String medblock; |
| | | //洗小块 |
| | | String nubmeasure; |
| | | //矸石 |
| | | String gangue; |
| | | //小块转载 |
| | | String reshipped; |
| | | //火车外运吨数 |
| | | String trainTon; |
| | | //火车外运列数 |
| | | String trainCount; |
| | | } |
| | | @Data |
| | | public static class CURRENTYEAR { |
| | | //地销混煤 |
| | | String groundsales; |
| | | //洗中块 |
| | | String medblock; |
| | | //洗小块 |
| | | String nubmeasure; |
| | | //矸石 |
| | | String gangue; |
| | | //小块转载 |
| | | String reshipped; |
| | | //火车外运吨数 |
| | | String trainTon; |
| | | //火车外运列数 |
| | | String trainCount; |
| | | } |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.http.dto; |
| | | |
| | | import lombok.Data; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | @Data |
| | | public class TagJsonDto implements Serializable { |
| | | |
| | | private List<RESULT> result; |
| | | private String targetUrl; |
| | | private String success; |
| | | private String error; |
| | | private String unAuthorizedRequest; |
| | | private String __abp; |
| | | |
| | | @Data |
| | | public static class RESULT{ |
| | | private String pointId; |
| | | private String pointCode; |
| | | private String pointName; |
| | | private String equipmentId; |
| | | private String equipmentName; |
| | | private String unit; |
| | | private String unitCode; |
| | | private String sampleTime; |
| | | private String measureValue; |
| | | private String pntDirect; |
| | | private String sensorAxis; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.http.dto; |
| | | |
| | | import lombok.Data; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | @Component |
| | | @Data |
| | | public class TagPrdTimeDistJsonDto implements Serializable { |
| | | private String sta; |
| | | private String msg; |
| | | private DATA res; |
| | | |
| | | @Component |
| | | @Data |
| | | public static class DATA{ |
| | | private XX xx; |
| | | private ZQ zq; |
| | | |
| | | @Data |
| | | public static class XX { |
| | | //runMinutes:生产时间(分钟) |
| | | String runMinutes; |
| | | //overhaulMinutes:检修时间(分钟) |
| | | String overhaulMinutes; |
| | | //affectMinutes:影响时间(分钟) |
| | | String affectMinutes; |
| | | } |
| | | @Data |
| | | public static class ZQ { |
| | | //runMinutes:生产时间(分钟) |
| | | String runMinutes; |
| | | //overhaulMinutes:检修时间(分钟) |
| | | String overhaulMinutes; |
| | | //affectMinutes:影响时间(分钟) |
| | | String affectMinutes; |
| | | } |
| | | |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.http.dto; |
| | | |
| | | import lombok.Data; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | | @Data |
| | | public class TagYearPeiJsonDto implements Serializable { |
| | | private String sta; |
| | | private String msg; |
| | | private DATA res; |
| | | @Data |
| | | public static class DATA{ |
| | | YEAR yearData; |
| | | List<MONTH> monthData; |
| | | @Data |
| | | public static class YEAR { |
| | | //洗选计划量 |
| | | String xxPlan; |
| | | //洗选产量 |
| | | String xxPerformance; |
| | | //栈桥计划量 |
| | | String zqPlan; |
| | | //栈桥产量 |
| | | String zqPerformance; |
| | | } |
| | | @Data |
| | | public static class MONTH { |
| | | //月份 |
| | | String month; |
| | | //洗选计划量 |
| | | String xxPlan; |
| | | //洗选产量 |
| | | String xxPerformance; |
| | | //栈桥计划量 |
| | | String zqPlan; |
| | | //栈桥产量 |
| | | String zqPerformance; |
| | | } |
| | | } |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.http.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Map; |
| | | |
| | | @Data |
| | | public class TokenJsonDto implements Serializable { |
| | | |
| | | private Map<String,String> result; |
| | | private String targetUrl; |
| | | private String success; |
| | | private String error; |
| | | private String unAuthorizedRequest; |
| | | private String __abp; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.http.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2023年12月18日 16:53:00 |
| | | */ |
| | | @Data |
| | | @TableName("t_ele_low_tag") |
| | | public class EleLowTagEntity implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * ID |
| | | */ |
| | | @Schema(description = "ID") |
| | | @TableId(value = "id", type = IdType.INPUT) |
| | | private String id; |
| | | |
| | | /** |
| | | * 位置 |
| | | */ |
| | | private String location; |
| | | |
| | | /** |
| | | * 所在柜号 |
| | | */ |
| | | private String boxNum; |
| | | |
| | | /** |
| | | * 开关位置 |
| | | */ |
| | | private String switchLocation; |
| | | |
| | | /** |
| | | * 测点名称 |
| | | */ |
| | | private String tagName; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * 更新时间 |
| | | */ |
| | | private Date updateTime; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.http.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @author DongYukun |
| | | * @Description |
| | | * @createTime 2024年01月17日 13:19:00 |
| | | */ |
| | | @Data |
| | | @TableName("t_fxjy_tag") |
| | | public class FxjyTagEntity implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @Schema(description = "主键") |
| | | @TableId(value = "id", type = IdType.INPUT) |
| | | private String id; |
| | | |
| | | /** |
| | | * 测点类型 |
| | | */ |
| | | private String tagType; |
| | | |
| | | /** |
| | | * 测点编码 |
| | | */ |
| | | private String tagCode; |
| | | |
| | | /** |
| | | * 测点名称 |
| | | */ |
| | | private String tagName; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * 更新时间 |
| | | */ |
| | | private Date updateTime; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.http.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | | @TableName("T_HTTP_API") |
| | | public class HttpApiEntity implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @Schema(description = "主键") |
| | | @TableId(value = "id", type = IdType.INPUT) |
| | | private String id; |
| | | private String name; |
| | | private String code; |
| | | private String url; |
| | | private String method; |
| | | private String collectType; |
| | | private String param; |
| | | private String descp; |
| | | private Integer status; |
| | | private Date createTime; |
| | | private Date updateTime; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.http.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @author Houzhongjian |
| | | * @Description |
| | | * @createTime 2024年04月10日 17:35:00 |
| | | */ |
| | | @Data |
| | | @TableName("t_http_tag") |
| | | public class HttpTagEntity implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @Schema(description = "主键") |
| | | @TableId(value = "id", type = IdType.INPUT) |
| | | private String id; |
| | | |
| | | /** |
| | | * HTTP api code |
| | | */ |
| | | private String httpApiCode; |
| | | |
| | | /** |
| | | * 测点类型 |
| | | */ |
| | | private String tagType; |
| | | |
| | | /** |
| | | * 测点编码 |
| | | */ |
| | | private String tagCode; |
| | | |
| | | /** |
| | | * 测点名称 |
| | | */ |
| | | private String tagName; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * 更新时间 |
| | | */ |
| | | private Date updateTime; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.http.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | | @TableName("T_HTTP_TOKEN") |
| | | public class HttpTokenEntity implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @Schema(description = "主键") |
| | | @TableId(value = "id", type = IdType.INPUT) |
| | | private String id; |
| | | private String apiId; |
| | | private String loginUrl; |
| | | private String clientId; |
| | | private String clientSecret; |
| | | private String username; |
| | | private String password; |
| | | private String token; |
| | | private String prvsetName; |
| | | private String projectName; |
| | | private String platform; |
| | | private Date expireTime; |
| | | private Date updateTime; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.http.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | | @TableName("T_XST_TAG") |
| | | public class XSTTagEntity implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @Schema(description = "主键") |
| | | @TableId(value = "id", type = IdType.INPUT) |
| | | private String id; |
| | | |
| | | /** |
| | | * 设备编码 |
| | | */ |
| | | private String deviceCode; |
| | | |
| | | /** |
| | | * 设备名称 |
| | | */ |
| | | private String deviceName; |
| | | |
| | | /** |
| | | * 测点名称 |
| | | */ |
| | | private String pointName; |
| | | |
| | | /** |
| | | * 测点编码 |
| | | */ |
| | | private String pointCode; |
| | | |
| | | /** |
| | | * 单位 |
| | | */ |
| | | private String unit; |
| | | |
| | | /** |
| | | * 传感器标识符 |
| | | */ |
| | | private String identifier; |
| | | |
| | | /** |
| | | * Tag编号 |
| | | */ |
| | | private String tagno; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * 更新时间 |
| | | */ |
| | | private Date updateTime; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.http.service; |
| | | |
| | | import com.iailab.framework.common.page.PageData; |
| | | import com.iailab.framework.common.service.BaseService; |
| | | import com.iailab.module.data.http.entity.HttpApiEntity; |
| | | import com.iailab.module.data.http.entity.HttpApiEntity; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | public interface HttpApiService extends BaseService<HttpApiEntity> { |
| | | HttpApiEntity selectXstHttpTagApi(); |
| | | |
| | | HttpApiEntity get(String id); |
| | | |
| | | HttpApiEntity getByCode(String code); |
| | | |
| | | PageData<HttpApiEntity> page(Map<String, Object> params); |
| | | |
| | | List<HttpApiEntity> list(); |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.http.service; |
| | | |
| | | |
| | | import com.iailab.module.data.common.utils.PageUtils; |
| | | import com.iailab.framework.common.service.BaseService; |
| | | import com.iailab.module.data.http.dto.HttpTagDTO; |
| | | import com.iailab.module.data.http.dto.TagCommonCurrentDto; |
| | | import com.iailab.module.data.http.entity.HttpTagEntity; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author Houzhongjian |
| | | * @Description |
| | | * @createTime 2024年04月10日 17:35:00 |
| | | */ |
| | | public interface HttpTagService extends BaseService<HttpTagEntity> { |
| | | |
| | | PageUtils queryPage(Map<String, Object> params); |
| | | |
| | | List<HttpTagEntity> selectList(Map<String, Object> params); |
| | | |
| | | Map<String, BigDecimal> getTagsValues(String httpApiCode, List<TagCommonCurrentDto> tags); |
| | | |
| | | List<HttpTagEntity> getByCode(String code); |
| | | |
| | | List<String> getByTagType(String deviceId); |
| | | |
| | | List<HttpTagDTO> list(Map<String, Object> params); |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.http.service; |
| | | |
| | | |
| | | import com.iailab.framework.common.page.PageData; |
| | | import com.iailab.framework.common.service.BaseService; |
| | | import com.iailab.module.data.http.entity.HttpTokenEntity; |
| | | import com.iailab.module.data.http.entity.HttpTokenEntity; |
| | | |
| | | import java.util.Map; |
| | | |
| | | public interface HttpTokenService extends BaseService<HttpTokenEntity> { |
| | | |
| | | PageData<HttpTokenEntity> page(Map<String, Object> params); |
| | | |
| | | HttpTokenEntity getByApiId(String apiId); |
| | | |
| | | void updateToken (String clientId); |
| | | |
| | | String queryToken (String clientId); |
| | | |
| | | } |
对比新文件 |
| | |
| | | //package com.iailab.module.http.service.impl; |
| | | // |
| | | //import com.alibaba.fastjson.JSONObject; |
| | | //import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | //import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | //import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | //import com.iailab.framework.common.service.impl.BaseServiceImpl; |
| | | //import com.iailab.common.utils.HttpsRequest; |
| | | //import com.iailab.common.utils.PageUtils; |
| | | //import com.iailab.common.utils.Query; |
| | | //import com.iailab.module.http.dao.FxjyTagDao; |
| | | //import com.iailab.module.http.entity.FxjyTagEntity; |
| | | //import com.iailab.module.http.service.HttpApiService; |
| | | //import lombok.extern.slf4j.Slf4j; |
| | | //import javax.annotation.Resource; |
| | | //import org.springframework.stereotype.Service; |
| | | // |
| | | //import java.lang.reflect.Field; |
| | | //import java.math.BigDecimal; |
| | | //import java.util.HashMap; |
| | | //import java.util.List; |
| | | //import java.util.Map; |
| | | // |
| | | //@Slf4j |
| | | //@Service |
| | | //public class FxjyTagServiceImpl extends BaseServiceImpl<FxjyTagDao, FxjyTagEntity> implements FxjyTagService { |
| | | // |
| | | // @Resource |
| | | // private HttpsRequest httpsRequest; |
| | | // |
| | | // @Resource |
| | | // private HttpApiService httpApiService; |
| | | // |
| | | // private final String API_CODE = "fxjyHttpTag"; |
| | | // |
| | | // /** |
| | | // * 分页查询tag |
| | | // * |
| | | // * @param params |
| | | // */ |
| | | // @Override |
| | | // public PageUtils queryPage(Map<String, Object> params) { |
| | | // String tagType = (String) params.get("tagType"); |
| | | // String tagCode = (String) params.get("tagCode"); |
| | | // String tagName = (String) params.get("tagName"); |
| | | // |
| | | // IPage<FxjyTagEntity> page = baseDao.selectPage( |
| | | // new Query<FxjyTagEntity>().getPage(params), |
| | | // new QueryWrapper<FxjyTagEntity>() |
| | | // .like(StringUtils.isNotBlank(tagType), "tag_type", tagType) |
| | | // .like(StringUtils.isNotBlank(tagCode), "tag_code", tagCode) |
| | | // .like(StringUtils.isNotBlank(tagName), "tag_name", tagName) |
| | | // .orderByDesc("create_time") |
| | | // ); |
| | | // return new PageUtils(page); |
| | | // } |
| | | // |
| | | // @Override |
| | | // public Map<String, BigDecimal> getTagsValues(List<FxjyCurrentDto> tags){ |
| | | // Map<String, BigDecimal> result = new HashMap<>(tags.size()); |
| | | // Map<String, String> params = new HashMap<>(2); |
| | | // String url = httpApiService.getByCode(API_CODE).getUrl(); |
| | | //// String responseStr = httpsRequest.doGet(url, params,"utf-8", ""); |
| | | // String responseStr = "{\n" + |
| | | // "\"flag\":true,\n" + |
| | | // "\"data\":{\n" + |
| | | // "\"ST\":\"2024-01-1616:42:36\",\n" + |
| | | // "\"JYJ1\":{\n" + |
| | | // "\"CURRENT_SPEED\":199.17,\n" + |
| | | // "\"DL\":4.5,\n" + |
| | | // "\"CW\":false,\n" + |
| | | // "\"EN\":true,\n" + |
| | | // "\"FAULT\":false,\n" + |
| | | // "\"GL\":false,\n" + |
| | | // "\"GY\":false,\n" + |
| | | // "\"QY\":false,\n" + |
| | | // "\"RUNING\":true,\n" + |
| | | // "\"SPEED_SET\":200.0\n" + |
| | | // "},\n" + |
| | | // "\"JYJ2\":{\n" + |
| | | // "\"CURRENT_SPEED\":0.0,\n" + |
| | | // "\"DL\":1.8,\n" + |
| | | // "\"CW\":false,\n" + |
| | | // "\"EN\":true,\n" + |
| | | // "\"FAULT\":false,\n" + |
| | | // "\"GL\":false,\n" + |
| | | // "\"GY\":false,\n" + |
| | | // "\"QY\":false,\n" + |
| | | // "\"RUNING\":false,\n" + |
| | | // "\"SPEED_SET\":50.0\n" + |
| | | // "},\n" + |
| | | // "\"JYJ3\":{\n" + |
| | | // "\"CURRENT_SPEED\":199.17,\n" + |
| | | // "\"DL\":4.5,\n" + |
| | | // "\"CW\":false,\n" + |
| | | // "\"EN\":true,\n" + |
| | | // "\"FAULT\":false,\n" + |
| | | // "\"GL\":false,\n" + |
| | | // "\"GY\":false,\n" + |
| | | // "\"QY\":false,\n" + |
| | | // "\"RUNING\":true,\n" + |
| | | // "\"SPEED_SET\":200.0\n" + |
| | | // "},\n" + |
| | | // "\"JYJ4\":{\n" + |
| | | // "\"CURRENT_SPEED\":0.0,\n" + |
| | | // "\"DL\":1.8,\n" + |
| | | // "\"CW\":false,\n" + |
| | | // "\"EN\":true,\n" + |
| | | // "\"FAULT\":false,\n" + |
| | | // "\"GL\":false,\n" + |
| | | // "\"GY\":false,\n" + |
| | | // "\"QY\":false,\n" + |
| | | // "\"RUNING\":false,\n" + |
| | | // "\"SPEED_SET\":50.0\n" + |
| | | // "},\n" + |
| | | // "\"FXJY\":{\n" + |
| | | // "\"YW401\":5.49,\n" + |
| | | // "\"YW407\":66.83,\n" + |
| | | // "\"YW408\":19.92,\n" + |
| | | // "\"PumpRun_402A\":true,\n" + |
| | | // "\"PumpRun_402B\":true,\n" + |
| | | // "\"YCLQ_Run_403A\":true,\n" + |
| | | // "\"YCLQ_Run_403B\":true,\n" + |
| | | // "\"Valve1_GDW\":false,\n" + |
| | | // "\"Valve1_KDW\":true,\n" + |
| | | // "\"Valve1_ZZK\":false,\n" + |
| | | // "\"Valve1_ZZG\":false,\n" + |
| | | // "\"Valve2_GDW\":true,\n" + |
| | | // "\"Valve2_KDW\":false,\n" + |
| | | // "\"Valve2_ZZK\":false,\n" + |
| | | // "\"Valve2_ZZG\":false,\n" + |
| | | // "\"Valve3_GDW\":false,\n" + |
| | | // "\"Valve3_KDW\":true,\n" + |
| | | // "\"Valve3_ZZK\":false,\n" + |
| | | // "\"Valve3_ZZG\":false,\n" + |
| | | // "\"Valve4_GDW\":true,\n" + |
| | | // "\"Valve4_KDW\":false,\n" + |
| | | // " \"Valve4_ZZK\": false,\n" + |
| | | // "\"Valve4_ZZG\": false,\n" + |
| | | // "\"ZLLLJ1_403A\": 19.35,\n" + |
| | | // "\"ZLLLJ2_403A\": 2.73,\n" + |
| | | // "\"ZLLLJ1_403B\": 15.99,\n" + |
| | | // "\"ZLLLJ2_403B\": 5.19,\n" + |
| | | // "\"FXRL_LLJ_403A1\": 983.75,\n" + |
| | | // "\"FXRL_LLJ_403A2\": 583.91,\n" + |
| | | // "\"FXPMHDJC1\": 5.11,\n" + |
| | | // "\"FXPMHDJC2\": 1.95,\n" + |
| | | // "\"LD3_LD1\": 0.0,\n" + |
| | | // "\"LD3_LD2\": 0.0,\n" + |
| | | // "\"LD3_ND\": 0.0\n" + |
| | | // "},\n" + |
| | | // "\"YLXT\": {\n" + |
| | | // "\"YW405A\": 21.98,\n" + |
| | | // "\"YW405B\": 17.04,\n" + |
| | | // "\"YW601\": 33.79,\n" + |
| | | // "\"VF861_Run\": true,\n" + |
| | | // "\"VF862_Run\": true,\n" + |
| | | // "\"VF863_Run\": true,\n" + |
| | | // "\"KM414A_Run\": false,\n" + |
| | | // "\"KM414B_Run\": false,\n" + |
| | | // "\"KM418A_Run\": false,\n" + |
| | | // "\"KM418B_Run\": false,\n" + |
| | | // "\"KM602A_Run\": false,\n" + |
| | | // "\"KM602B_Run\": false,\n" + |
| | | // "\"KM602C_Run\": true,\n" + |
| | | // "\"KM416A_Run\": false,\n" + |
| | | // "\"KM416B_Run\": false,\n" + |
| | | // "\"KM420A_Run\": false,\n" + |
| | | // "\"KM420B_Run\": false,\n" + |
| | | // "\"KM606A_Run\": false,\n" + |
| | | // "\"KM606B_Run\": false,\n" + |
| | | // "\"KM606C_Run\": false\n" + |
| | | // "},\n" + |
| | | // "\"LJL\": {\n" + |
| | | // "\"Timestamp\": \"2024-01-16\",\n" + |
| | | // "\"JYJ1\": 120.53,\n" + |
| | | // "\"JYJ2\": 0.0,\n" + |
| | | // "\"JYJ3\": 117.66,\n" + |
| | | // "\"JYJ4\": 0.0\n" + |
| | | // "},\n" + |
| | | // "\"YCZ\": {\n" + |
| | | // "\"JYJ1\": 249.6,\n" + |
| | | // "\"JYJ2\": 0.0,\n" + |
| | | // "\"JYJ3\": 248.23,\n" + |
| | | // "\"JYJ4\": 0.0\n" + |
| | | // "},\n" + |
| | | // "\"YLCS\": {\n" + |
| | | // "\"YL415A_GLCSXS\": 7,\n" + |
| | | // "\"YL415B_GLCSXS\": 8,\n" + |
| | | // "\"YL419A_GLCSXS\": 7,\n" + |
| | | // "\"YL419B_GLCSXS\": 8,\n" + |
| | | // "\"YL603A_GLCSXS\": 1,\n" + |
| | | // "\"YL603B_GLCSXS\": 0,\n" + |
| | | // "\"YL603C_GLCSXS\": 3\n" + |
| | | // "},\n" + |
| | | // "\"TEMP\": {\n" + |
| | | // "\"FXRLNDJ403A\": 67.12\n" + |
| | | // "}\n" + |
| | | // "},\n" + |
| | | // "\"msg\": \"查询成功\"\n" + |
| | | // "}"; |
| | | // if (StringUtils.isNotBlank(responseStr)) { |
| | | // FxjyJsonDto fxjyJsonDto = parseDto(responseStr); |
| | | // fxjyJsonDto.getData().getLJL().getJYJ1(); |
| | | // tags.stream().forEach( |
| | | // item->{ |
| | | // Class<?> fxjyClass= fxjyJsonDto.getData().getClass(); |
| | | // try { |
| | | // Class<?> fxjyTypeClass = fxjyClass.getDeclaredField(item.getTagType()).getClass(); |
| | | // Field field = fxjyTypeClass.getDeclaredField(item.getTagCode()); |
| | | // field.setAccessible(true); |
| | | // BigDecimal value = new BigDecimal((String)field.get(fxjyJsonDto.getData())); |
| | | // result.put(item.getTagType()+"_"+item.getTagCode(), value); |
| | | // }catch (NoSuchFieldException e){ |
| | | // log.info("没有找到tag"+item.getTagType()+";"+item.getTagCode()); |
| | | // }catch(IllegalAccessException e){ |
| | | // log.info("没有反射权限"); |
| | | // } |
| | | // } |
| | | // ); |
| | | // } |
| | | // return result; |
| | | // } |
| | | // |
| | | // @Override |
| | | // public List<FxjyTagEntity> selectList() { |
| | | // return baseDao.selectList(new QueryWrapper<FxjyTagEntity>().orderByDesc("create_time")); |
| | | // } |
| | | // |
| | | // private FxjyJsonDto parseDto(String responseStr) { |
| | | // FxjyJsonDto result = new FxjyJsonDto(); |
| | | // if (!org.apache.commons.lang.StringUtils.isEmpty(responseStr)) { |
| | | // JSONObject items = JSONObject.parseObject(responseStr); |
| | | // result = items.toJavaObject(FxjyJsonDto.class); |
| | | // } |
| | | // return result; |
| | | // } |
| | | //} |
对比新文件 |
| | |
| | | package com.iailab.module.data.http.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.iailab.framework.common.page.PageData; |
| | | import com.iailab.framework.common.service.impl.BaseServiceImpl; |
| | | import com.iailab.module.data.http.entity.HttpApiEntity; |
| | | import com.iailab.module.data.http.entity.HttpApiEntity; |
| | | import com.iailab.module.data.http.dao.HttpApiDao; |
| | | import com.iailab.module.data.http.service.HttpApiService; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Service |
| | | public class HttpApiServiceImpl extends BaseServiceImpl<HttpApiDao, HttpApiEntity> implements HttpApiService { |
| | | @Override |
| | | public HttpApiEntity selectXstHttpTagApi() { |
| | | return baseDao.selectOne(new QueryWrapper<HttpApiEntity>().eq("code","xstHttpTag")); |
| | | } |
| | | |
| | | @Override |
| | | public HttpApiEntity get(String id) { |
| | | return baseDao.selectById(id); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public HttpApiEntity getByCode(String code) { |
| | | return baseDao.selectOne(new QueryWrapper<HttpApiEntity>().eq("code", code)); |
| | | } |
| | | |
| | | @Override |
| | | public PageData<HttpApiEntity> page(Map<String, Object> params) { |
| | | IPage<HttpApiEntity> page = baseDao.selectPage( |
| | | getPage(params, "create_time", false), |
| | | getWrapper(params) |
| | | ); |
| | | |
| | | return getPageData(page, HttpApiEntity.class); |
| | | } |
| | | |
| | | @Override |
| | | public List<HttpApiEntity> list() { |
| | | List<HttpApiEntity> page = baseDao.selectList(new QueryWrapper<>()); |
| | | return page; |
| | | } |
| | | |
| | | private QueryWrapper<HttpApiEntity> getWrapper(Map<String, Object> params){ |
| | | String name = (String)params.get("name"); |
| | | QueryWrapper<HttpApiEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq(StringUtils.isNotBlank(name), "name", name); |
| | | return wrapper; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.http.service.impl; |
| | | |
| | | import com.iailab.module.data.http.dto.TagCommonCurrentDto; |
| | | import com.iailab.module.data.http.service.HttpTagService; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Component |
| | | public class HttpTagCollector { |
| | | |
| | | @Resource |
| | | private HttpTagService httpTagService; |
| | | |
| | | |
| | | public Map<String, Object> collect(String httpApiCode, List<String> tagIds) { |
| | | Map<String, Object> result = new HashMap<>(); |
| | | if (CollectionUtils.isEmpty(tagIds)) { |
| | | return null; |
| | | } |
| | | List<TagCommonCurrentDto> tags = new ArrayList<>(); |
| | | for (String tagId : tagIds) { |
| | | String[] parts = tagId.split("_"); |
| | | TagCommonCurrentDto dto=new TagCommonCurrentDto(); |
| | | dto.setTagType(parts[0]); |
| | | dto.setTagCode(tagId); |
| | | tags.add(dto); |
| | | } |
| | | Map<String, BigDecimal> tagsValues = httpTagService.getTagsValues(httpApiCode, tags); |
| | | if (!CollectionUtils.isEmpty(tagsValues)) { |
| | | tagsValues.forEach((k, v) -> { |
| | | result.put(k, v); |
| | | }); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.http.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.iailab.module.data.common.enums.CommonConstant; |
| | | import com.iailab.framework.common.service.impl.BaseServiceImpl; |
| | | import com.iailab.module.data.common.utils.HttpsRequest; |
| | | import com.iailab.module.data.common.utils.PageUtils; |
| | | import com.iailab.module.data.common.utils.Query; |
| | | import com.iailab.module.data.http.dao.HttpTagDao; |
| | | import com.iailab.module.data.http.dto.*; |
| | | import com.iailab.module.data.http.entity.HttpApiEntity; |
| | | import com.iailab.module.data.http.entity.HttpTagEntity; |
| | | import com.iailab.module.data.http.service.HttpApiService; |
| | | import com.iailab.module.data.http.service.HttpTagService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.lang.reflect.Field; |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @author Houzhongjian |
| | | * @Description |
| | | * @createTime 2024年04月10日 17:35:00 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class HttpTagServiceImpl extends BaseServiceImpl<HttpTagDao, HttpTagEntity> implements HttpTagService { |
| | | |
| | | @Resource |
| | | private HttpsRequest httpsRequest; |
| | | |
| | | @Resource |
| | | private HttpApiService httpApiService; |
| | | |
| | | |
| | | /** |
| | | * 分页查询tag |
| | | * |
| | | * @param params |
| | | */ |
| | | @Override |
| | | public PageUtils queryPage(Map<String, Object> params) { |
| | | String httpApiCode = (String) params.get("httpApiCode"); |
| | | String tagType = (String) params.get("tagType"); |
| | | String tagCode = (String) params.get("tagCode"); |
| | | String tagName = (String) params.get("tagName"); |
| | | |
| | | IPage<HttpTagEntity> page = baseDao.selectPage( |
| | | new Query<HttpTagEntity>().getPage(params), |
| | | new QueryWrapper<HttpTagEntity>() |
| | | .like(StringUtils.isNotBlank(httpApiCode), "http_api_code", httpApiCode) |
| | | .like(StringUtils.isNotBlank(tagType), "tag_type", tagType) |
| | | .like(StringUtils.isNotBlank(tagCode), "tag_code", tagCode) |
| | | .like(StringUtils.isNotBlank(tagName), "tag_name", tagName) |
| | | .orderByDesc("create_time") |
| | | ); |
| | | return new PageUtils(page); |
| | | } |
| | | |
| | | @Override |
| | | public List<HttpTagEntity> selectList(Map<String, Object> params) { |
| | | String httpId = (String) params.get("httpId"); |
| | | HttpApiEntity httpApiEntity = httpApiService.selectById(httpId); |
| | | return baseDao.selectList(new QueryWrapper<HttpTagEntity>() |
| | | .eq("http_api_code", httpApiEntity.getCode()) |
| | | .orderByDesc("create_time")); |
| | | } |
| | | |
| | | @Override |
| | | public List<HttpTagEntity> getByCode(String code) { |
| | | return baseDao.selectList(new QueryWrapper<HttpTagEntity>() |
| | | .eq("http_api_code", code) |
| | | .orderByDesc("create_time")); |
| | | } |
| | | |
| | | @Override |
| | | public List<String> getByTagType(String deviceId) { |
| | | QueryWrapper<HttpTagEntity> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("tag_type", deviceId); |
| | | List<HttpTagEntity> entityList = baseDao.selectList(queryWrapper); |
| | | List<String> list = new ArrayList<>(); |
| | | if(ObjectUtils.isNotEmpty(entityList)) { |
| | | entityList.stream().forEach(entity -> { |
| | | String tagCode = entity.getTagCode(); |
| | | list.add(tagCode); |
| | | }); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public List<HttpTagDTO> list(Map<String, Object> params) { |
| | | List<HttpTagDTO> list = baseDao.getList(params); |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, BigDecimal> getTagsValues(String httpApiCode, List<TagCommonCurrentDto> tags) { |
| | | Map<String, BigDecimal> stringBigDecimalMap = new HashMap<>(); |
| | | if (CommonConstant.YEAR_PEI_HTTP_TAG.equals(httpApiCode)) { |
| | | stringBigDecimalMap = yearPeiTagsValues(tags); |
| | | } else if(CommonConstant.CURRENT_PERFORMANCE_HTTP_TAG.equals(httpApiCode)) { |
| | | stringBigDecimalMap = currentPerformanceTagsValues(tags); |
| | | } else if(CommonConstant.CURRENT_SALE_HTTP_TAG.equals(httpApiCode)) { |
| | | stringBigDecimalMap = currentSaleTagsValues(tags); |
| | | } else if(CommonConstant.PRD_TIME_DIST_HTTP_TAG.equals(httpApiCode)) { |
| | | stringBigDecimalMap = prdTimeDistTagsValues(tags); |
| | | } |
| | | return stringBigDecimalMap; |
| | | } |
| | | |
| | | private Map<String, BigDecimal> yearPeiTagsValues(List<TagCommonCurrentDto> tags) { |
| | | Map<String, BigDecimal> result = new HashMap<>(tags.size()); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | int currentMonth = calendar.get(Calendar.MONTH) + 1; |
| | | // String url = httpApiService.getByCode(API_CODE).getUrl(); |
| | | // String responseStr = httpsRequest.doGet(url, params,"utf-8", ""); |
| | | String url = "http://192.168.55.121/Sunny/Action/BdApi/Invoke?code=Prd.YearPEI"; |
| | | String responseStr = "{\"sta\":true,\"msg\":null,\"res\":{\"yearData\":{\"year\":2024,\"xxPlan\":21850000.00,\"xxPerformance\":6794492.00,\"zqPlan\":12500000.00,\"zqPerformance\":3149110.41},\"monthData\":[{\"month\":1,\"xxPlan\":1400000.00,\"xxPerformance\":2022725.00,\"zqPlan\":800000.00,\"zqPerformance\":955066.76},{\"month\":2,\"xxPlan\":1400000.00,\"xxPerformance\":1829671.00,\"zqPlan\":800000.00,\"zqPerformance\":809494.02},{\"month\":3,\"xxPlan\":1700000.00,\"xxPerformance\":2225923.00,\"zqPlan\":1000000.00,\"zqPerformance\":971406.22},{\"month\":4,\"xxPlan\":1620000.00,\"xxPerformance\":716173.00,\"zqPlan\":1000000.00,\"zqPerformance\":345324.75},{\"month\":5,\"xxPlan\":0.0,\"xxPerformance\":0.00,\"zqPlan\":0.0,\"zqPerformance\":0.0},{\"month\":6,\"xxPlan\":0.0,\"xxPerformance\":0.0,\"zqPlan\":0.0,\"zqPerformance\":0.0},{\"month\":7,\"xxPlan\":0.0,\"xxPerformance\":0.0,\"zqPlan\":0.0,\"zqPerformance\":0.0},{\"month\":8,\"xxPlan\":0.0,\"xxPerformance\":0.0,\"zqPlan\":0.0,\"zqPerformance\":0.0},{\"month\":9,\"xxPlan\":0.0,\"xxPerformance\":0.0,\"zqPlan\":0.0,\"zqPerformance\":0.0},{\"month\":10,\"xxPlan\":0.0,\"xxPerformance\":0.0,\"zqPlan\":0.0,\"zqPerformance\":0.0},{\"month\":11,\"xxPlan\":0.0,\"xxPerformance\":0.0,\"zqPlan\":0.0,\"zqPerformance\":0.0},{\"month\":12,\"xxPlan\":0.0,\"xxPerformance\":0.0,\"zqPlan\":0.0,\"zqPerformance\":0.0}]}}"; |
| | | if (StringUtils.isNotBlank(responseStr)) { |
| | | TagYearPeiJsonDto yearPeiJsonDto = parseYearPeiDto(responseStr); |
| | | tags.stream().forEach( |
| | | item -> { |
| | | String tagType = item.getTagType(); |
| | | String tagCode = item.getTagCode().split(CommonConstant.UNDERLINE)[1]; |
| | | TagYearPeiJsonDto.DATA res = yearPeiJsonDto.getRes(); |
| | | TagYearPeiJsonDto.DATA.YEAR yearData = res.getYearData(); |
| | | List<TagYearPeiJsonDto.DATA.MONTH> monthDataList = res.getMonthData(); |
| | | TagYearPeiJsonDto.DATA.MONTH month = monthDataList.get(currentMonth - 1); |
| | | Class<?> yearPeiClass = res.getClass(); |
| | | String name = yearPeiClass.getName(); |
| | | try { |
| | | BigDecimal value; |
| | | Class<?> yearPeiTypeClass1 = Class.forName(name + CommonConstant.DOLLAR + tagType.toUpperCase()); |
| | | Field field = yearPeiTypeClass1.getDeclaredField(tagCode); |
| | | field.setAccessible(true); |
| | | if(CommonConstant.YEAR.equals(tagType)){ |
| | | value = new BigDecimal((String) field.get(yearData)); |
| | | result.put(item.getTagCode(), value); |
| | | } else if(CommonConstant.MONTH.equals(tagType)){ |
| | | value = new BigDecimal((String) field.get(month)); |
| | | result.put(item.getTagCode(), value); |
| | | } |
| | | } catch (NoSuchFieldException e) { |
| | | log.info("没有找到tag" + item.getTagType() + ";" + item.getTagCode()); |
| | | } catch (IllegalAccessException e) { |
| | | log.info("没有反射权限"); |
| | | } catch (ClassNotFoundException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | ); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | private Map<String, BigDecimal> currentPerformanceTagsValues(List<TagCommonCurrentDto> tags) { |
| | | Map<String, BigDecimal> result = new HashMap<>(tags.size()); |
| | | Map<String, String> params = new HashMap<>(2); |
| | | // String url = httpApiService.getByCode(API_CODE).getUrl(); |
| | | // String responseStr = httpsRequest.doGet(url, params,"utf-8", ""); |
| | | String responseStr = "{\"sta\":true,\"msg\":null,\"res\":{\"today\":{\"xxPerformance\":30866.00,\"zqPerformance\":0.0},\"yesterday\":{\"xxPerformance\":65748.00,\"zqPerformance\":36263.20},\"currentMonth\":{\"xxPerformance\":716173.00,\"zqPerformance\":345324.75},\"currentYear\":{\"xxPerformance\":6794492.00,\"zqPerformance\":3149110.41}}}"; |
| | | if (StringUtils.isNotBlank(responseStr)) { |
| | | TagCurrentPerformanceJsonDto currentPerformanceJsonDto = parseCurrentPerformanceDto(responseStr); |
| | | tags.stream().forEach( |
| | | item -> { |
| | | String tagType = item.getTagType(); |
| | | String tagCode = item.getTagCode().split(CommonConstant.UNDERLINE)[1]; |
| | | Class<?> currentPerformanceClass = currentPerformanceJsonDto.getRes().getClass(); |
| | | String name = currentPerformanceClass.getName(); |
| | | try { |
| | | Field declaredField = currentPerformanceClass.getDeclaredField(tagType); |
| | | Class<?> typeClass = Class.forName(name + CommonConstant.DOLLAR + tagType.toUpperCase()); |
| | | Field field = typeClass.getDeclaredField(tagCode); |
| | | field.setAccessible(true); |
| | | declaredField.setAccessible(true); |
| | | BigDecimal value = new BigDecimal((String) field.get(declaredField.get(currentPerformanceJsonDto.getRes()))); |
| | | result.put(item.getTagCode(), value); |
| | | } catch (NoSuchFieldException e) { |
| | | log.info("没有找到tag" + item.getTagType() + ";" + item.getTagCode()); |
| | | } catch (IllegalAccessException e) { |
| | | log.info("没有反射权限"); |
| | | } catch (ClassNotFoundException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | ); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | private Map<String, BigDecimal> currentSaleTagsValues(List<TagCommonCurrentDto> tags) { |
| | | Map<String, BigDecimal> result = new HashMap<>(tags.size()); |
| | | Map<String, String> params = new HashMap<>(2); |
| | | // String url = httpApiService.getByCode(API_CODE).getUrl(); |
| | | // String responseStr = httpsRequest.doGet(url, params,"utf-8", ""); |
| | | String responseStr = "{\"sta\":true,\"msg\":null,\"res\":{\"today\":{\"groundsales\":0.0,\"medblock\":0.0,\"nubmeasure\":0.0,\"gangue\":0.0,\"reshipped\":0.0,\"trainTon\":0.0,\"trainCount\":0},\"yesterday\":{\"groundsales\":15696.00,\"medblock\":14757.00,\"nubmeasure\":0.00,\"gangue\":4384.00,\"reshipped\":2447.00,\"trainTon\":36263.20,\"trainCount\":10},\"currentMonth\":{\"groundsales\":0.0,\"medblock\":0.0,\"nubmeasure\":0.0,\"gangue\":0.0,\"reshipped\":0.0,\"trainTon\":0.0,\"trainCount\":0},\"currentYear\":{\"groundsales\":521638.00,\"medblock\":266372.00,\"nubmeasure\":0.00,\"gangue\":143475.00,\"reshipped\":139695.00,\"trainTon\":0.0,\"trainCount\":0}}}"; |
| | | if (StringUtils.isNotBlank(responseStr)) { |
| | | TagCurrentSaleJsonDto currentPerformanceJsonDto = parseCurrentSaleDto(responseStr); |
| | | tags.stream().forEach( |
| | | item -> { |
| | | String tagType = item.getTagType(); |
| | | String tagCode = item.getTagCode().split(CommonConstant.UNDERLINE)[1]; |
| | | Class<?> currentSaleClass = currentPerformanceJsonDto.getRes().getClass(); |
| | | String name = currentSaleClass.getName(); |
| | | try { |
| | | Field declaredField = currentSaleClass.getDeclaredField(tagType); |
| | | Class<?> typeClass = Class.forName(name + CommonConstant.DOLLAR + tagType.toUpperCase()); |
| | | Field field = typeClass.getDeclaredField(tagCode); |
| | | field.setAccessible(true); |
| | | declaredField.setAccessible(true); |
| | | BigDecimal value = new BigDecimal((String) field.get(declaredField.get(currentPerformanceJsonDto.getRes()))); |
| | | result.put(item.getTagCode(), value); |
| | | } catch (NoSuchFieldException e) { |
| | | log.info("没有找到tag" + item.getTagType() + ";" + item.getTagCode()); |
| | | } catch (IllegalAccessException e) { |
| | | log.info("没有反射权限"); |
| | | } catch (ClassNotFoundException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | ); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | private Map<String, BigDecimal> prdTimeDistTagsValues(List<TagCommonCurrentDto> tags) { |
| | | Map<String, BigDecimal> result = new HashMap<>(tags.size()); |
| | | Map<String, String> params = new HashMap<>(2); |
| | | // String url = httpApiService.getByCode(API_CODE).getUrl(); |
| | | // String responseStr = httpsRequest.doGet(url, params,"utf-8", ""); |
| | | String responseStr = "{\"sta\":true,\"msg\":null,\"res\":{\"xx\":{\"runMinutes\":1120.0,\"overhaulMinutes\":305.0,\"affectMinutes\":15.0},\"zq\":{\"runMinutes\":645.0,\"overhaulMinutes\":223.0,\"affectMinutes\":572.0}}}"; |
| | | if (StringUtils.isNotBlank(responseStr)) { |
| | | TagPrdTimeDistJsonDto prdTimeDistJsonDto = parsePrdTimeDistDto(responseStr); |
| | | tags.stream().forEach( |
| | | item -> { |
| | | String tagType = item.getTagType(); |
| | | String tagCode = item.getTagCode().split(CommonConstant.UNDERLINE)[1]; |
| | | Class<?> prdTimeDistClass = prdTimeDistJsonDto.getRes().getClass(); |
| | | String name = prdTimeDistClass.getName(); |
| | | try { |
| | | Field declaredField = prdTimeDistClass.getDeclaredField(tagType); |
| | | Class<?> typeClass = Class.forName(name + CommonConstant.DOLLAR + tagType.toUpperCase()); |
| | | Field field = typeClass.getDeclaredField(tagCode); |
| | | field.setAccessible(true); |
| | | declaredField.setAccessible(true); |
| | | BigDecimal value = new BigDecimal((String) field.get(declaredField.get(prdTimeDistJsonDto.getRes()))); |
| | | result.put(item.getTagCode(), value); |
| | | } catch (NoSuchFieldException e) { |
| | | log.info("没有找到tag" + item.getTagType() + ";" + item.getTagCode()); |
| | | } catch (IllegalAccessException e) { |
| | | log.info("没有反射权限"); |
| | | } catch (ClassNotFoundException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | ); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | private TagYearPeiJsonDto parseYearPeiDto(String responseStr) { |
| | | TagYearPeiJsonDto result = new TagYearPeiJsonDto(); |
| | | if (!StringUtils.isEmpty(responseStr)) { |
| | | JSONObject items = JSONObject.parseObject(responseStr); |
| | | result = items.toJavaObject(TagYearPeiJsonDto.class); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | private TagCurrentPerformanceJsonDto parseCurrentPerformanceDto(String responseStr) { |
| | | TagCurrentPerformanceJsonDto result = new TagCurrentPerformanceJsonDto(); |
| | | if (!StringUtils.isEmpty(responseStr)) { |
| | | JSONObject items = JSONObject.parseObject(responseStr); |
| | | result = items.toJavaObject(TagCurrentPerformanceJsonDto.class); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | private TagCurrentSaleJsonDto parseCurrentSaleDto(String responseStr) { |
| | | TagCurrentSaleJsonDto result = new TagCurrentSaleJsonDto(); |
| | | if (!StringUtils.isEmpty(responseStr)) { |
| | | JSONObject items = JSONObject.parseObject(responseStr); |
| | | result = items.toJavaObject(TagCurrentSaleJsonDto.class); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | private TagPrdTimeDistJsonDto parsePrdTimeDistDto(String responseStr) { |
| | | TagPrdTimeDistJsonDto result = new TagPrdTimeDistJsonDto(); |
| | | if (!StringUtils.isEmpty(responseStr)) { |
| | | JSONObject items = JSONObject.parseObject(responseStr); |
| | | result = items.toJavaObject(TagPrdTimeDistJsonDto.class); |
| | | } |
| | | return result; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.http.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.iailab.module.data.common.utils.HttpsRequest; |
| | | import com.iailab.framework.common.page.PageData; |
| | | import com.iailab.framework.common.service.impl.BaseServiceImpl; |
| | | import com.iailab.module.data.http.dao.HttpTokenDao; |
| | | import com.iailab.module.data.http.entity.HttpTokenEntity; |
| | | import com.iailab.module.data.http.service.HttpTokenService; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | @Service |
| | | public class HttpTokenServiceImpl extends BaseServiceImpl<HttpTokenDao, HttpTokenEntity> implements HttpTokenService { |
| | | |
| | | @Resource |
| | | private HttpsRequest httpsRequest; |
| | | |
| | | @Override |
| | | public PageData<HttpTokenEntity> page(Map<String, Object> params) { |
| | | IPage<HttpTokenEntity> page = baseDao.selectPage( |
| | | getPage(params, "client_id", false), |
| | | getWrapper(params) |
| | | ); |
| | | return getPageData(page, HttpTokenEntity.class); |
| | | } |
| | | |
| | | private QueryWrapper<HttpTokenEntity> getWrapper(Map<String, Object> params){ |
| | | String clientId = (String)params.get("clientId"); |
| | | QueryWrapper<HttpTokenEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq(StringUtils.isNotBlank(clientId), "client_id", clientId); |
| | | return wrapper; |
| | | } |
| | | |
| | | @Override |
| | | public HttpTokenEntity getByApiId(String apiId) { |
| | | QueryWrapper<HttpTokenEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq(StringUtils.isNotBlank(apiId), "api_id", apiId); |
| | | return baseDao.selectOne(wrapper); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void updateToken(String clientId) { |
| | | Map<String, String> params = new HashMap<>(1); |
| | | params.put("timeout", "30000"); |
| | | HttpTokenEntity entity = baseDao.selectOne(new QueryWrapper<HttpTokenEntity>().eq("client_id", clientId)); |
| | | Map<String, String> dataJson = new HashMap<>(2); |
| | | String url = entity.getLoginUrl(); |
| | | String userName = entity.getUsername(); |
| | | String password = entity.getPassword(); |
| | | String prvsetName = entity.getPrvsetName(); |
| | | String projectName = entity.getProjectName(); |
| | | String platform = entity.getPlatform(); |
| | | dataJson.put("username", userName); |
| | | dataJson.put("password", password); |
| | | dataJson.put("prvset_name", prvsetName); |
| | | dataJson.put("project_name", projectName); |
| | | dataJson.put("platform", platform); |
| | | //查询token的请求 |
| | | String responseStr = httpsRequest.doPostToken(url, params, JSONObject.toJSONString(dataJson), "utf-8"); |
| | | //插入token和更新时间 |
| | | entity.setToken(responseStr); |
| | | entity.setUpdateTime(new Date()); |
| | | baseDao.update(entity, new QueryWrapper<HttpTokenEntity>().eq("client_id", clientId)); |
| | | } |
| | | |
| | | @Override |
| | | public String queryToken(String clientId) { |
| | | return baseDao.selectOne(new QueryWrapper<HttpTokenEntity>().eq("client_id", clientId)).getToken(); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.ind.collection; |
| | | |
| | | import com.iailab.module.data.ind.collection.handler.AtomItemHandle; |
| | | import com.iailab.module.data.ind.service.IndItemService; |
| | | import com.iailab.module.data.ind.collection.handler.AtomItemHandle; |
| | | import com.iailab.module.data.ind.service.IndItemService; |
| | | import com.iailab.module.data.ind.collection.handler.AtomItemHandle; |
| | | import com.iailab.module.data.ind.collection.handler.CalItemHandle; |
| | | import com.iailab.module.data.ind.dto.IndItemDTO; |
| | | import com.iailab.module.data.ind.dto.IndItemValueDTO; |
| | | import com.iailab.module.data.ind.service.IndItemService; |
| | | import com.iailab.module.data.ind.collection.handler.AtomItemHandle; |
| | | import com.iailab.module.data.ind.service.IndItemService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年05月25日 |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class IndItemCollector { |
| | | |
| | | @Resource |
| | | private IndItemService indItemService; |
| | | |
| | | @Resource |
| | | private AtomItemHandle atomItemHandle; |
| | | |
| | | @Resource |
| | | private CalItemHandle calItemHandle; |
| | | |
| | | |
| | | public Map<String, List<IndItemValueDTO>> getValueList(List<String> itemNos) { |
| | | Map<String, List<IndItemValueDTO>> result = new HashMap<>(); |
| | | if (CollectionUtils.isEmpty(itemNos)) { |
| | | return result; |
| | | } |
| | | try { |
| | | List<IndItemDTO> atomList = indItemService.getItemAtom(itemNos); |
| | | atomList.forEach(item -> { |
| | | result.put(item.getItemNo(), atomItemHandle.getItemSourceValue(item.getItemNo())); |
| | | }); |
| | | |
| | | List<IndItemDTO> calList = indItemService.getItemCal(itemNos); |
| | | calList.forEach(item -> { |
| | | result.put(item.getItemNo(), calItemHandle.getItemCalValue(item.getItemNo())); |
| | | }); |
| | | |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | public Map<String, List<IndItemValueDTO>> getValueListRange(List<String> itemNos, String start, String end) { |
| | | Map<String, List<IndItemValueDTO>> result = new HashMap<>(); |
| | | if (CollectionUtils.isEmpty(itemNos)) { |
| | | return result; |
| | | } |
| | | try { |
| | | List<IndItemDTO> atomList = indItemService.getItemAtom(itemNos); |
| | | atomList.forEach(item -> { |
| | | result.put(item.getItemNo(), atomItemHandle.getItemSourceValue(item.getItemNo(), start, end)); |
| | | }); |
| | | |
| | | List<IndItemDTO> calList = indItemService.getItemCal(itemNos); |
| | | calList.forEach(item -> { |
| | | result.put(item.getItemNo(), calItemHandle.getItemCalValue(item.getItemNo(), start, end)); |
| | | }); |
| | | |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | } |
| | | return result; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.ind.collection.handler; |
| | | |
| | | import com.iailab.module.data.ind.service.IndItemService; |
| | | import com.iailab.module.data.ind.service.IndItemService; |
| | | import com.iailab.module.data.ind.collection.utils.IndSqlUtils; |
| | | import com.iailab.module.data.ind.dao.IndItemValueDao; |
| | | import com.iailab.module.data.ind.dto.IndItemDTO; |
| | | import com.iailab.module.data.ind.dto.IndItemValueDTO; |
| | | import com.iailab.module.data.ind.service.IndItemService; |
| | | import com.iailab.module.data.ind.service.IndItemService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年05月25日 |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class AtomItemHandle { |
| | | |
| | | @Resource |
| | | private IndItemService indItemService; |
| | | |
| | | @Resource |
| | | private IndItemValueDao indItemValueDao; |
| | | |
| | | |
| | | public List<IndItemValueDTO> getItemSourceValue(String itemNo) { |
| | | List<IndItemValueDTO> result = new ArrayList<>(); |
| | | IndItemDTO indItemDTO = indItemService.getItemAtom(itemNo); |
| | | if (indItemDTO == null) { |
| | | return result; |
| | | } |
| | | try { |
| | | StringBuilder sqlSelect = new StringBuilder(); |
| | | sqlSelect.append(" data_value, data_time "); |
| | | indItemDTO.setSqlSelect(sqlSelect.toString()); |
| | | indItemDTO.setSqlWhere(IndSqlUtils.getSqlWhere(indItemDTO.getTimeRange(), indItemDTO.getTimeGranularity())); |
| | | result = indItemValueDao.getSourceValue(indItemDTO); |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | } |
| | | |
| | | result.forEach(item -> { |
| | | if (indItemDTO.getCoefficient() != null) { |
| | | item.setDataValue(item.getDataValue().multiply(indItemDTO.getCoefficient())); |
| | | } |
| | | if (indItemDTO.getPrecision() != null) { |
| | | item.setDataValue(item.getDataValue().setScale(indItemDTO.getPrecision(), BigDecimal.ROUND_HALF_UP)); |
| | | } |
| | | item.setItemNo(itemNo); |
| | | }); |
| | | return result; |
| | | } |
| | | |
| | | public List<IndItemValueDTO> getItemSourceValue(String itemNo, String start, String end) { |
| | | List<IndItemValueDTO> result = new ArrayList<>(); |
| | | IndItemDTO indItemDTO = indItemService.getItemAtom(itemNo); |
| | | if (indItemDTO == null) { |
| | | return result; |
| | | } |
| | | try { |
| | | StringBuilder sqlSelect = new StringBuilder(); |
| | | sqlSelect.append(" data_value, data_time "); |
| | | indItemDTO.setSqlSelect(sqlSelect.toString()); |
| | | indItemDTO.setSqlWhere(IndSqlUtils.getSqlWhereByRange(start, end)); |
| | | result = indItemValueDao.getSourceValue(indItemDTO); |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | } |
| | | |
| | | result.forEach(item -> { |
| | | if (indItemDTO.getCoefficient() != null) { |
| | | item.setDataValue(item.getDataValue().multiply(indItemDTO.getCoefficient())); |
| | | } |
| | | if (indItemDTO.getPrecision() != null) { |
| | | item.setDataValue(item.getDataValue().setScale(indItemDTO.getPrecision(), BigDecimal.ROUND_HALF_UP)); |
| | | } |
| | | item.setItemNo(itemNo); |
| | | }); |
| | | return result; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.ind.collection.handler; |
| | | |
| | | import com.iailab.module.data.common.enums.CommonConstant; |
| | | import com.iailab.module.data.common.enums.JsErrorCode; |
| | | import com.iailab.module.data.common.utils.JavaScriptHandler; |
| | | import com.iailab.module.data.ind.service.IndItemService; |
| | | import com.iailab.module.data.ind.dto.IndItemDTO; |
| | | import com.iailab.module.data.ind.dto.IndItemValueDTO; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年05月25日 |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class CalItemHandle { |
| | | |
| | | @Resource |
| | | private JavaScriptHandler javaScriptHandler; |
| | | |
| | | public static final String regex = "[+\\-\\*\\/\\(\\)\\&\\|\\>\\<]"; |
| | | |
| | | @Resource |
| | | private IndItemService indItemService; |
| | | |
| | | @Resource |
| | | private AtomItemHandle atomItemHandle; |
| | | |
| | | |
| | | public List<IndItemValueDTO> getItemCalValue(String itemNo) { |
| | | List<IndItemValueDTO> result = new ArrayList<>(); |
| | | IndItemDTO indItemDTO = indItemService.getItemCal(itemNo); |
| | | if (indItemDTO == null) { |
| | | return result; |
| | | } |
| | | String expression = indItemDTO.getExpression(); |
| | | if (StringUtils.isBlank(expression)) { |
| | | return result; |
| | | } |
| | | String[] arr = expression.split(regex); |
| | | int dataLength = 0; |
| | | List<List<IndItemValueDTO>> valueMix = new ArrayList<>(); |
| | | |
| | | for (int i = 0; i < arr.length; i++) { |
| | | String s = arr[i]; |
| | | if (StringUtils.isBlank(s)) { |
| | | continue; |
| | | } |
| | | valueMix.add(atomItemHandle.getItemSourceValue(s)); |
| | | } |
| | | dataLength = valueMix.get(0).size(); |
| | | |
| | | for (int i = 0; i < dataLength; i++) { |
| | | Map<String, IndItemValueDTO> dataMap = new HashMap<>(); |
| | | for (int j = 0; j < valueMix.size(); j++) { |
| | | IndItemValueDTO valueDTO = valueMix.get(j).get(i); |
| | | dataMap.put(valueDTO.getItemNo(), valueDTO); |
| | | } |
| | | IndItemValueDTO itemValue = this.singleCompute(indItemDTO, dataMap); |
| | | result.add(itemValue); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | public List<IndItemValueDTO> getItemCalValue(String itemNo, String start, String end) { |
| | | List<IndItemValueDTO> result = new ArrayList<>(); |
| | | IndItemDTO indItemDTO = indItemService.getItemCal(itemNo); |
| | | if (indItemDTO == null) { |
| | | return result; |
| | | } |
| | | String expression = indItemDTO.getExpression(); |
| | | if (StringUtils.isBlank(expression)) { |
| | | return result; |
| | | } |
| | | String[] arr = expression.split(regex); |
| | | int dataLength = 0; |
| | | List<List<IndItemValueDTO>> valueMix = new ArrayList<>(); |
| | | |
| | | for (int i = 0; i < arr.length; i++) { |
| | | String s = arr[i]; |
| | | if (StringUtils.isBlank(s)) { |
| | | continue; |
| | | } |
| | | valueMix.add(atomItemHandle.getItemSourceValue(s, start, end)); |
| | | } |
| | | dataLength = valueMix.get(0).size(); |
| | | |
| | | for (int i = 0; i < dataLength; i++) { |
| | | Map<String, IndItemValueDTO> dataMap = new HashMap<>(); |
| | | for (int j = 0; j < valueMix.size(); j++) { |
| | | IndItemValueDTO valueDTO = valueMix.get(j).get(i); |
| | | dataMap.put(valueDTO.getItemNo(), valueDTO); |
| | | } |
| | | IndItemValueDTO itemValue = this.singleCompute(indItemDTO, dataMap); |
| | | result.add(itemValue); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | private IndItemValueDTO singleCompute(IndItemDTO dto, Map<String, IndItemValueDTO> dataMap) { |
| | | IndItemValueDTO resultDto = new IndItemValueDTO(); |
| | | String dataTime = ""; |
| | | BigDecimal dataValue = CommonConstant.ZERO_VALUE; |
| | | String expression = dto.getExpression(); |
| | | String[] arr = expression.split(regex); |
| | | |
| | | for (int i = 0; i < arr.length; i++) { |
| | | String s = arr[i]; |
| | | if (StringUtils.isNotBlank(s) && dataMap.containsKey(s)) { |
| | | dataTime = dataMap.get(s).getDataTime(); |
| | | if (dataMap.get(s) == null || dataMap.get(s).getDataValue() == null) { |
| | | resultDto.setDataTime(dataTime); |
| | | return resultDto; |
| | | } |
| | | expression = expression.replace(s, dataMap.get(s).getDataValue().toString()); |
| | | } |
| | | } |
| | | expression = expression.replace("&", "&&"); |
| | | expression = expression.replace("|", "||"); |
| | | expression = expression.replace("False", "false"); |
| | | expression = expression.replace("True", "true"); |
| | | log.info("ItemNo=" + dto.getItemNo() + ";expression=" + expression); |
| | | String result = javaScriptHandler.eval(expression); |
| | | log.info("result=" + result); |
| | | if (result == null) { |
| | | return null; |
| | | } else if (result.contains(JsErrorCode.Infinity.name()) || |
| | | result.contains(JsErrorCode.NaN.name())) { |
| | | log.info("计算异常,使用默认值"); |
| | | } else { |
| | | dataValue = new BigDecimal(result); |
| | | } |
| | | resultDto.setDataTime(dataTime); |
| | | |
| | | if (dto.getCoefficient() != null) { |
| | | dataValue = dataValue.multiply(dto.getCoefficient()); |
| | | } |
| | | if (dto.getPrecision() != null) { |
| | | dataValue = dataValue.setScale(dto.getPrecision(), BigDecimal.ROUND_HALF_UP); |
| | | } |
| | | resultDto.setDataValue(dataValue); |
| | | return resultDto; |
| | | } |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.ind.collection.utils; |
| | | |
| | | import com.iailab.framework.common.util.date.DateUtils; |
| | | import com.iailab.module.data.ind.common.IndTimeRangeConst; |
| | | |
| | | import java.util.Calendar; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年05月25日 |
| | | */ |
| | | public class IndSqlUtils { |
| | | |
| | | public final static String PATTERN_YEAR = "yyyy"; |
| | | |
| | | public final static String PATTERN_MON = "yyyy-MM"; |
| | | |
| | | public final static String PATTERN_DATE = "yyyy-MM-dd"; |
| | | |
| | | |
| | | public static String getSqlWhere(String timeRange, String timeGranularity) { |
| | | StringBuilder sqlWhere = new StringBuilder(); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.set(Calendar.MILLISECOND, 0); |
| | | switch (timeRange) { |
| | | case IndTimeRangeConst.LAST_YEAR: |
| | | calendar.add(Calendar.YEAR, -1); |
| | | sqlWhere.append("ind_t.data_time = '"); |
| | | sqlWhere.append(DateUtils.format(calendar.getTime(), PATTERN_YEAR)); |
| | | sqlWhere.append("'"); |
| | | break; |
| | | case IndTimeRangeConst.THIS_YEAR: |
| | | sqlWhere.append("ind_t.data_time = '"); |
| | | sqlWhere.append(DateUtils.format(calendar.getTime(), PATTERN_YEAR)); |
| | | sqlWhere.append("'"); |
| | | break; |
| | | case IndTimeRangeConst.THIS_YEAR_MONTH: |
| | | sqlWhere.append("ind_t.data_time >= '"); |
| | | sqlWhere.append(DateUtils.format(calendar.getTime(), PATTERN_YEAR) + "-01' "); |
| | | sqlWhere.append("and ind_t.data_time <= '"); |
| | | sqlWhere.append(DateUtils.format(calendar.getTime(), PATTERN_YEAR) + "-12' "); |
| | | break; |
| | | case IndTimeRangeConst.THIS_MONTH: |
| | | sqlWhere.append("ind_t.data_time = '"); |
| | | sqlWhere.append(DateUtils.format(calendar.getTime(), PATTERN_MON)); |
| | | sqlWhere.append("'"); |
| | | break; |
| | | case IndTimeRangeConst.YESTERDAY: |
| | | calendar.add(Calendar.DAY_OF_YEAR, -1); |
| | | sqlWhere.append("ind_t.data_time = '"); |
| | | sqlWhere.append(DateUtils.format(calendar.getTime(), PATTERN_DATE)); |
| | | sqlWhere.append("'"); |
| | | break; |
| | | case IndTimeRangeConst.TODAY: |
| | | sqlWhere.append("ind_t.data_time = '"); |
| | | sqlWhere.append(DateUtils.format(calendar.getTime(), PATTERN_DATE)); |
| | | sqlWhere.append("'"); |
| | | break; |
| | | case IndTimeRangeConst.LAST_DAY_7: |
| | | calendar.add(Calendar.DAY_OF_YEAR, -7); |
| | | sqlWhere.append("ind_t.data_time >= '"); |
| | | sqlWhere.append(DateUtils.format(calendar.getTime(), PATTERN_DATE)); |
| | | sqlWhere.append("'"); |
| | | break; |
| | | case IndTimeRangeConst.LAST_DAY_30: |
| | | calendar.add(Calendar.DAY_OF_YEAR, -30); |
| | | sqlWhere.append("ind_t.data_time >= '"); |
| | | sqlWhere.append(DateUtils.format(calendar.getTime(), PATTERN_DATE)); |
| | | sqlWhere.append("'"); |
| | | break; |
| | | default: |
| | | break; |
| | | |
| | | } |
| | | return sqlWhere.toString(); |
| | | } |
| | | |
| | | public static String getSqlWhereByRange(String start, String end) { |
| | | StringBuilder sqlWhere = new StringBuilder(); |
| | | sqlWhere.append("ind_t.data_time >= '"); |
| | | sqlWhere.append(start); |
| | | sqlWhere.append("' "); |
| | | sqlWhere.append("and ind_t.data_time <= '"); |
| | | sqlWhere.append(end); |
| | | sqlWhere.append("' "); |
| | | return sqlWhere.toString(); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.ind.common; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年05月25日 |
| | | */ |
| | | public enum IndItemTypeEnum { |
| | | |
| | | ATOM_ITEM("ATOM", "ATOM"), |
| | | CAL_ITEM("CAL", "CAL"); |
| | | |
| | | private String code; |
| | | |
| | | private String name; |
| | | |
| | | IndItemTypeEnum(String code, String name){ |
| | | this.code = code; |
| | | this.name = name; |
| | | } |
| | | |
| | | public String getCode() { |
| | | return code; |
| | | } |
| | | |
| | | public void setCode(String code) { |
| | | this.code = code; |
| | | } |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.ind.common; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年05月27日 |
| | | */ |
| | | public interface IndTimeRangeConst { |
| | | |
| | | String LAST_YEAR = "LAST_YEAR"; |
| | | |
| | | String THIS_YEAR = "THIS_YEAR"; |
| | | |
| | | String THIS_YEAR_MONTH = "THIS_YEAR_MONTH"; |
| | | |
| | | String LAST_MONTH_12 = "LAST_MONTH_12"; |
| | | |
| | | String THIS_MONTH = "THIS_MONTH"; |
| | | |
| | | String YESTERDAY = "YESTERDAY"; |
| | | |
| | | String TODAY = "TODAY"; |
| | | |
| | | String LAST_DAY_7 = "LAST_DAY_7"; |
| | | |
| | | String LAST_DAY_30 = "LAST_DAY_30"; |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.ind.common; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年05月25日 |
| | | */ |
| | | public enum IndTimeRangeEnum { |
| | | |
| | | LAST_YEAR("LAST_YEAR", "LAST_YEAR"), |
| | | THIS_YEAR("THIS_YEAR", "THIS_YEAR"), |
| | | LAST_MONTH_12("LAST_MONTH_12", "LAST_MONTH_12"), |
| | | YESTERDAY("YESTERDAY", "YESTERDAY"), |
| | | TODAY("TODAY", "TODAY"), |
| | | LAST_DAY_7("LAST_DAY_7", "LAST_DAY_7"), |
| | | LAST_DAY_30("LAST_DAY_30", "LAST_DAY_30"); |
| | | |
| | | private String code; |
| | | |
| | | private String name; |
| | | |
| | | IndTimeRangeEnum(String code, String name){ |
| | | this.code = code; |
| | | this.name = name; |
| | | } |
| | | |
| | | public String getCode() { |
| | | return code; |
| | | } |
| | | |
| | | public void setCode(String code) { |
| | | this.code = code; |
| | | } |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.ind.common; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年05月25日 |
| | | */ |
| | | public enum IndtimeGranularityEnum { |
| | | |
| | | DAY("DAY", "DAY"), |
| | | MONTH("MONTH", "MONTH"); |
| | | |
| | | private String code; |
| | | |
| | | private String name; |
| | | |
| | | IndtimeGranularityEnum(String code, String name){ |
| | | this.code = code; |
| | | this.name = name; |
| | | } |
| | | |
| | | public String getCode() { |
| | | return code; |
| | | } |
| | | |
| | | public void setCode(String code) { |
| | | this.code = code; |
| | | } |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.ind.controller.admin; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年05月25日 |
| | | */ |
| | | public class IndItemAtomController { |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.ind.controller.admin; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年05月25日 |
| | | */ |
| | | public class IndItemCalController { |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.ind.controller.admin; |
| | | |
| | | import com.iailab.framework.common.annotation.AutoDict; |
| | | import com.iailab.framework.common.constant.Constant; |
| | | import com.iailab.framework.common.page.PageData; |
| | | import com.iailab.framework.common.pojo.CommonResult; |
| | | import com.iailab.framework.common.util.validation.ValidationUtils; |
| | | import com.iailab.framework.common.validation.group.AddGroup; |
| | | import com.iailab.framework.common.validation.group.DefaultGroup; |
| | | import com.iailab.module.data.ind.service.IndItemService; |
| | | import com.iailab.module.data.ind.dto.IndItemDTO; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.Parameters; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年05月25日 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/ind/item") |
| | | public class IndItemController { |
| | | |
| | | @Resource |
| | | private IndItemService indItemService; |
| | | |
| | | @GetMapping("page") |
| | | @Operation(summary = "分页") |
| | | @Parameters({ |
| | | @Parameter(name = Constant.PAGE, description = "当前页码,从1开始", required = true), |
| | | @Parameter(name = Constant.LIMIT, description = "每页显示记录数", required = true), |
| | | @Parameter(name = Constant.ORDER_FIELD, description = "排序字段"), |
| | | @Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)") |
| | | }) |
| | | @AutoDict |
| | | public CommonResult<PageData<IndItemDTO>> page(@RequestParam Map<String, Object> params) { |
| | | PageData<IndItemDTO> page = indItemService.page(params); |
| | | |
| | | return new CommonResult<PageData<IndItemDTO>>().setData(page); |
| | | } |
| | | |
| | | @GetMapping("list") |
| | | @AutoDict |
| | | public CommonResult<List<IndItemDTO>> list(@RequestParam Map<String, Object> params) { |
| | | List<IndItemDTO> list = indItemService.getList(params); |
| | | return new CommonResult<List<IndItemDTO>>().setData(list); |
| | | } |
| | | |
| | | @GetMapping("{id}") |
| | | @Operation(summary = "信息") |
| | | public CommonResult<IndItemDTO> get(@PathVariable("id") String id) { |
| | | IndItemDTO data = indItemService.get(id); |
| | | |
| | | return new CommonResult<IndItemDTO>().setData(data); |
| | | } |
| | | |
| | | @PostMapping |
| | | @Operation(summary = "保存") |
| | | @PreAuthorize("@ss.hasPermission('ind:item:save')") |
| | | public CommonResult save(@RequestBody IndItemDTO dto){ |
| | | //效验数据 |
| | | ValidationUtils.validate(dto, AddGroup.class, DefaultGroup.class); |
| | | IndItemDTO data = indItemService.getItemByItemNo(dto.getItemNo()); |
| | | if(data != null){ |
| | | return new CommonResult().setMsg("指标编码已经存在,请重新定义指标编码!"); |
| | | } |
| | | indItemService.save(dto); |
| | | return new CommonResult(); |
| | | } |
| | | |
| | | @PutMapping |
| | | @Operation(summary = "修改") |
| | | @PreAuthorize("@ss.hasPermission('ind:item:update')") |
| | | public CommonResult update(@RequestBody IndItemDTO dto){ |
| | | //效验数据 |
| | | ValidationUtils.validate(dto, AddGroup.class, DefaultGroup.class); |
| | | indItemService.update(dto); |
| | | return new CommonResult(); |
| | | } |
| | | |
| | | @DeleteMapping |
| | | @Operation(summary = "删除") |
| | | @PreAuthorize("@ss.hasPermission('ind:item:delete')") |
| | | public CommonResult delete(@RequestBody String[] ids){ |
| | | indItemService.delete(ids); |
| | | return new CommonResult(); |
| | | } |
| | | |
| | | @PutMapping("/enable") |
| | | @Operation(summary = "启用") |
| | | @Transactional |
| | | public CommonResult enable(@RequestBody String[] ids) { |
| | | indItemService.enableByIds(ids); |
| | | return new CommonResult(); |
| | | } |
| | | |
| | | @PutMapping("/disable") |
| | | @Operation(summary = "禁用") |
| | | @Transactional |
| | | public CommonResult disable(@RequestBody String[] ids) { |
| | | indItemService.disableByIds(ids); |
| | | return new CommonResult(); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.ind.controller; |
对比新文件 |
| | |
| | | package com.iailab.module.data.ind.dao; |
| | | |
| | | import com.iailab.framework.common.dao.BaseDao; |
| | | import com.iailab.module.data.ind.entity.IndItemAtomEntity; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年05月25日 |
| | | */ |
| | | @Mapper |
| | | public interface IndItemAtomDao extends BaseDao<IndItemAtomEntity> { |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.ind.dao; |
| | | |
| | | import com.iailab.framework.common.dao.BaseDao; |
| | | import com.iailab.module.data.ind.entity.IndItemCalEntity; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年05月25日 |
| | | */ |
| | | @Mapper |
| | | public interface IndItemCalDao extends BaseDao<IndItemCalEntity> { |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.ind.dao; |
| | | |
| | | import com.iailab.framework.common.dao.BaseDao; |
| | | import com.iailab.module.data.ind.entity.IndItemEntity; |
| | | import com.iailab.module.data.ind.entity.IndItemEntity; |
| | | import com.iailab.module.data.ind.dto.IndItemDTO; |
| | | import com.iailab.module.data.ind.entity.IndItemEntity; |
| | | import com.iailab.module.data.ind.entity.IndItemEntity; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年05月25日 |
| | | */ |
| | | @Mapper |
| | | public interface IndItemDao extends BaseDao<IndItemEntity> { |
| | | |
| | | List<IndItemDTO> getItemAtom(Map<String, Object> params); |
| | | |
| | | List<IndItemDTO> getItemCal(Map<String, Object> params); |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.ind.dao; |
| | | |
| | | import com.iailab.framework.common.dao.BaseDao; |
| | | import com.iailab.module.data.ind.entity.IndItemValueEntity; |
| | | import com.iailab.module.data.ind.entity.IndItemValueEntity; |
| | | import com.iailab.module.data.ind.dto.IndItemDTO; |
| | | import com.iailab.module.data.ind.dto.IndItemValueDTO; |
| | | import com.iailab.module.data.ind.entity.IndItemValueEntity; |
| | | import com.iailab.module.data.ind.entity.IndItemValueEntity; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年05月25日 |
| | | */ |
| | | @Mapper |
| | | public interface IndItemValueDao extends BaseDao<IndItemValueEntity> { |
| | | |
| | | List<IndItemValueDTO> getSourceValue(IndItemDTO queryDto); |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.ind.dto; |
| | | |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年05月25日 |
| | | */ |
| | | @Data |
| | | @Tag(name = "原子指标") |
| | | public class IndItemAtomDTO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | private String id; |
| | | |
| | | private String itemId; |
| | | |
| | | private String dataSource; |
| | | |
| | | private String querySql; |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.ind.dto; |
| | | |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年05月25日 |
| | | */ |
| | | @Data |
| | | @Tag(name = "计算指标") |
| | | public class IndItemCalDTO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | private String id; |
| | | |
| | | private String itemId; |
| | | |
| | | private String expression; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.ind.dto; |
| | | |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年05月25日 |
| | | */ |
| | | @Data |
| | | @Tag(name = "指标项") |
| | | public class IndItemDTO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | private String id; |
| | | |
| | | private String itemNo; |
| | | |
| | | private String itemName; |
| | | |
| | | private String itemType; |
| | | |
| | | private BigDecimal coefficient; |
| | | |
| | | private Integer precision; |
| | | |
| | | private String businessType; |
| | | |
| | | private String timeRange; |
| | | |
| | | private String timeGranularity; |
| | | |
| | | private String remark; |
| | | |
| | | private Integer isEnable; |
| | | |
| | | private String creator; |
| | | |
| | | private Date createTime; |
| | | |
| | | private String updater; |
| | | |
| | | private Date updateTime; |
| | | |
| | | private String dataSource; |
| | | |
| | | private String querySql; |
| | | |
| | | private String expression; |
| | | |
| | | private String sqlSelect; |
| | | |
| | | private String sqlWhere; |
| | | |
| | | private IndItemAtomDTO indItemAtom; |
| | | |
| | | private IndItemCalDTO indItemCal; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.ind.dto; |
| | | |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年05月25日 |
| | | */ |
| | | @Data |
| | | @Tag(name = "指标值") |
| | | public class IndItemValueDTO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | |
| | | @Schema(description = "指标编码") |
| | | private String itemNo; |
| | | |
| | | @Schema(description = "数据时间") |
| | | private String dataTime; |
| | | |
| | | @Schema(description = "数据值") |
| | | private BigDecimal dataValue; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.ind.entity; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | @Data |
| | | @TableName("t_ind_item_atom") |
| | | public class IndItemAtomEntity implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @TableId(type = IdType.ASSIGN_UUID) |
| | | private String id; |
| | | |
| | | private String itemId; |
| | | |
| | | private String dataSource; |
| | | |
| | | private String querySql; |
| | | |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.ind.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | @Data |
| | | @TableName("t_ind_item_cal") |
| | | public class IndItemCalEntity implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @TableId(type = IdType.ASSIGN_UUID) |
| | | private String id; |
| | | |
| | | private String itemId; |
| | | |
| | | private String expression; |
| | | |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.ind.entity; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | | @TableName("t_ind_item") |
| | | public class IndItemEntity implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * ID |
| | | */ |
| | | @TableId(type = IdType.ASSIGN_UUID) |
| | | private String id; |
| | | |
| | | /** |
| | | * 指标编码 |
| | | */ |
| | | private String itemNo; |
| | | |
| | | /** |
| | | * 指标名称 |
| | | */ |
| | | private String itemName; |
| | | |
| | | /** |
| | | * 指标类型 |
| | | */ |
| | | private String itemType; |
| | | |
| | | /** |
| | | * 系数 |
| | | */ |
| | | private BigDecimal coefficient; |
| | | |
| | | /** |
| | | * 指标精度 |
| | | */ |
| | | @TableField("`precision`") |
| | | private Integer precision; |
| | | |
| | | /** |
| | | * 业务类型 |
| | | */ |
| | | private String businessType; |
| | | |
| | | /** |
| | | * 时间范围 |
| | | */ |
| | | private String timeRange; |
| | | |
| | | /** |
| | | * 时间粒度 |
| | | */ |
| | | private String timeGranularity; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | private String remark; |
| | | |
| | | /** |
| | | * 是否启用 |
| | | */ |
| | | private Integer isEnable; |
| | | |
| | | /** |
| | | * 创建人 |
| | | */ |
| | | private String creator; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * 修改人 |
| | | */ |
| | | private String updater; |
| | | |
| | | /** |
| | | * 修改人 |
| | | */ |
| | | private Date updateTime; |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.ind.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年05月25日 |
| | | */ |
| | | @Data |
| | | @TableName("t_ind_item_value") |
| | | public class IndItemValueEntity implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @TableId(type = IdType.ASSIGN_UUID) |
| | | private String id; |
| | | |
| | | private String itemNo; |
| | | |
| | | private BigDecimal dataValue; |
| | | |
| | | private String dataTime; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.ind.service; |
| | | |
| | | import com.iailab.framework.common.page.PageData; |
| | | import com.iailab.framework.common.service.BaseService; |
| | | import com.iailab.module.data.ind.dto.IndItemAtomDTO; |
| | | import com.iailab.module.data.ind.entity.IndItemAtomEntity; |
| | | import com.iailab.module.data.ind.dto.IndItemAtomDTO; |
| | | import com.iailab.module.data.ind.entity.IndItemAtomEntity; |
| | | import com.iailab.module.data.ind.dto.IndItemAtomDTO; |
| | | import com.iailab.module.data.ind.entity.IndItemAtomEntity; |
| | | import com.iailab.module.data.ind.dto.IndItemAtomDTO; |
| | | import com.iailab.module.data.ind.entity.IndItemAtomEntity; |
| | | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年05月25日 |
| | | */ |
| | | public interface IndItemAtomService extends BaseService<IndItemAtomEntity> { |
| | | |
| | | PageData<IndItemAtomDTO> page(Map<String, Object> params); |
| | | |
| | | IndItemAtomDTO get(String id); |
| | | |
| | | IndItemAtomDTO getItemId(String itemId); |
| | | |
| | | void save(IndItemAtomDTO dto); |
| | | |
| | | void update(IndItemAtomDTO dto); |
| | | |
| | | void delete(String[] ids); |
| | | |
| | | void deleteByItemId(String[] ids); |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.ind.service; |
| | | |
| | | import com.iailab.framework.common.page.PageData; |
| | | import com.iailab.framework.common.service.BaseService; |
| | | import com.iailab.module.data.ind.dto.IndItemCalDTO; |
| | | import com.iailab.module.data.ind.entity.IndItemCalEntity; |
| | | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年05月25日 |
| | | */ |
| | | public interface IndItemCalService extends BaseService<IndItemCalEntity> { |
| | | |
| | | PageData<IndItemCalDTO> page(Map<String, Object> params); |
| | | |
| | | IndItemCalDTO get(String id); |
| | | |
| | | IndItemCalDTO getItemId(String itemId); |
| | | |
| | | void save(IndItemCalDTO dto); |
| | | |
| | | void update(IndItemCalDTO dto); |
| | | |
| | | void delete(String[] ids); |
| | | |
| | | void deleteByItemId(String[] ids); |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.ind.service; |
| | | |
| | | import com.iailab.framework.common.page.PageData; |
| | | import com.iailab.framework.common.service.BaseService; |
| | | import com.iailab.module.data.ind.dto.IndItemDTO; |
| | | import com.iailab.module.data.ind.entity.IndItemEntity; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年05月25日 |
| | | */ |
| | | public interface IndItemService extends BaseService<IndItemEntity> { |
| | | |
| | | PageData<IndItemDTO> page(Map<String, Object> params); |
| | | |
| | | IndItemDTO get(String id); |
| | | |
| | | void save(IndItemDTO dto); |
| | | |
| | | void update(IndItemDTO dto); |
| | | |
| | | void delete(String[] ids); |
| | | |
| | | List<IndItemDTO> getItemAtom(List<String> itemNos); |
| | | |
| | | IndItemDTO getItemAtom(String itemNo); |
| | | |
| | | List<IndItemDTO> getItemCal(List<String> itemNos); |
| | | |
| | | IndItemDTO getItemCal(String itemNo); |
| | | |
| | | List<IndItemDTO> getList(Map<String, Object> params); |
| | | |
| | | void enableByIds(String[] ids); |
| | | |
| | | void disableByIds(String[] ids); |
| | | |
| | | IndItemDTO getItemByItemNo(String itemNo); |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.ind.service; |
| | | |
| | | import com.iailab.framework.common.page.PageData; |
| | | import com.iailab.framework.common.service.BaseService; |
| | | import com.iailab.module.data.ind.dto.IndItemValueDTO; |
| | | import com.iailab.module.data.ind.entity.IndItemValueEntity; |
| | | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年05月25日 |
| | | */ |
| | | public interface IndItemValueService extends BaseService<IndItemValueEntity> { |
| | | |
| | | PageData<IndItemValueDTO> page(Map<String, Object> params); |
| | | |
| | | IndItemValueDTO get(String id); |
| | | |
| | | void save(IndItemValueDTO dto); |
| | | |
| | | void update(IndItemValueDTO dto); |
| | | |
| | | void delete(String[] ids); |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.ind.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.iailab.framework.common.constant.Constant; |
| | | import com.iailab.framework.common.page.PageData; |
| | | import com.iailab.framework.common.service.impl.BaseServiceImpl; |
| | | import com.iailab.framework.common.util.object.ConvertUtils; |
| | | import com.iailab.module.data.ind.dao.IndItemAtomDao; |
| | | import com.iailab.module.data.ind.dto.IndItemAtomDTO; |
| | | import com.iailab.module.data.ind.dao.IndItemAtomDao; |
| | | import com.iailab.module.data.ind.dto.IndItemAtomDTO; |
| | | import com.iailab.module.data.ind.dao.IndItemAtomDao; |
| | | import com.iailab.module.data.ind.dto.IndItemAtomDTO; |
| | | import com.iailab.module.data.ind.entity.IndItemAtomEntity; |
| | | import com.iailab.module.data.ind.service.IndItemAtomService; |
| | | import com.iailab.module.data.ind.dao.IndItemAtomDao; |
| | | import com.iailab.module.data.ind.dto.IndItemAtomDTO; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年05月25日 |
| | | */ |
| | | @Service |
| | | public class IndItemAtomServiceImpl extends BaseServiceImpl<IndItemAtomDao, IndItemAtomEntity> implements IndItemAtomService { |
| | | |
| | | @Override |
| | | public PageData<IndItemAtomDTO> page(Map<String, Object> params) { |
| | | IPage<IndItemAtomEntity> page = baseDao.selectPage( |
| | | getPage(params, Constant.CREATE_DATE, false), |
| | | getWrapper(params) |
| | | ); |
| | | return getPageData(page, IndItemAtomDTO.class); |
| | | } |
| | | |
| | | private QueryWrapper<IndItemAtomEntity> getWrapper(Map<String, Object> params){ |
| | | String itemId = (String)params.get("itemId"); |
| | | |
| | | QueryWrapper<IndItemAtomEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.like(StringUtils.isNotBlank(itemId), "item_id", itemId); |
| | | |
| | | return wrapper; |
| | | } |
| | | |
| | | @Override |
| | | public IndItemAtomDTO get(String id) { |
| | | IndItemAtomEntity entity = baseDao.selectById(id); |
| | | |
| | | return ConvertUtils.sourceToTarget(entity, IndItemAtomDTO.class); |
| | | } |
| | | |
| | | @Override |
| | | public IndItemAtomDTO getItemId(String itemId) { |
| | | QueryWrapper<IndItemAtomEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.like(StringUtils.isNotBlank(itemId), "item_id", itemId); |
| | | IndItemAtomEntity entity = baseDao.selectOne(wrapper); |
| | | |
| | | return ConvertUtils.sourceToTarget(entity, IndItemAtomDTO.class); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void save(IndItemAtomDTO dto) { |
| | | IndItemAtomEntity entity = ConvertUtils.sourceToTarget(dto, IndItemAtomEntity.class); |
| | | |
| | | insert(entity); |
| | | } |
| | | |
| | | @Override |
| | | public void update(IndItemAtomDTO dto) { |
| | | IndItemAtomEntity entity = ConvertUtils.sourceToTarget(dto, IndItemAtomEntity.class); |
| | | |
| | | updateById(entity); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void delete(String[] ids) { |
| | | baseDao.deleteBatchIds(Arrays.asList(ids)); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void deleteByItemId(String[] ids) { |
| | | QueryWrapper<IndItemAtomEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.in("item_id", ids); |
| | | baseDao.delete(wrapper); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.ind.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.iailab.framework.common.constant.Constant; |
| | | import com.iailab.framework.common.page.PageData; |
| | | import com.iailab.framework.common.service.impl.BaseServiceImpl; |
| | | import com.iailab.framework.common.util.object.ConvertUtils; |
| | | import com.iailab.module.data.ind.dao.IndItemCalDao; |
| | | import com.iailab.module.data.ind.entity.IndItemCalEntity; |
| | | import com.iailab.module.data.ind.service.IndItemCalService; |
| | | import com.iailab.module.data.ind.dao.IndItemCalDao; |
| | | import com.iailab.module.data.ind.entity.IndItemCalEntity; |
| | | import com.iailab.module.data.ind.service.IndItemCalService; |
| | | import com.iailab.module.data.ind.dao.IndItemCalDao; |
| | | import com.iailab.module.data.ind.dto.IndItemCalDTO; |
| | | import com.iailab.module.data.ind.entity.IndItemCalEntity; |
| | | import com.iailab.module.data.ind.service.IndItemCalService; |
| | | import com.iailab.module.data.ind.dao.IndItemCalDao; |
| | | import com.iailab.module.data.ind.entity.IndItemCalEntity; |
| | | import com.iailab.module.data.ind.service.IndItemCalService; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年05月25日 |
| | | */ |
| | | @Service |
| | | public class IndItemCalServiceImpl extends BaseServiceImpl<IndItemCalDao, IndItemCalEntity> implements IndItemCalService { |
| | | |
| | | @Override |
| | | public PageData<IndItemCalDTO> page(Map<String, Object> params) { |
| | | IPage<IndItemCalEntity> page = baseDao.selectPage( |
| | | getPage(params, Constant.CREATE_DATE, false), |
| | | getWrapper(params) |
| | | ); |
| | | return getPageData(page, IndItemCalDTO.class); |
| | | } |
| | | |
| | | private QueryWrapper<IndItemCalEntity> getWrapper(Map<String, Object> params){ |
| | | String itemId = (String)params.get("itemId"); |
| | | |
| | | QueryWrapper<IndItemCalEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.like(StringUtils.isNotBlank(itemId), "item_id", itemId); |
| | | |
| | | return wrapper; |
| | | } |
| | | |
| | | @Override |
| | | public IndItemCalDTO get(String id) { |
| | | IndItemCalEntity entity = baseDao.selectById(id); |
| | | |
| | | return ConvertUtils.sourceToTarget(entity, IndItemCalDTO.class); |
| | | } |
| | | |
| | | @Override |
| | | public IndItemCalDTO getItemId(String itemId) { |
| | | QueryWrapper<IndItemCalEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.like(StringUtils.isNotBlank(itemId), "item_id", itemId); |
| | | IndItemCalEntity entity = baseDao.selectOne(wrapper); |
| | | |
| | | return ConvertUtils.sourceToTarget(entity, IndItemCalDTO.class); |
| | | } |
| | | |
| | | @Override |
| | | public void save(IndItemCalDTO dto) { |
| | | IndItemCalEntity entity = ConvertUtils.sourceToTarget(dto, IndItemCalEntity.class); |
| | | |
| | | insert(entity); |
| | | } |
| | | |
| | | @Override |
| | | public void update(IndItemCalDTO dto) { |
| | | IndItemCalEntity entity = ConvertUtils.sourceToTarget(dto, IndItemCalEntity.class); |
| | | |
| | | updateById(entity); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void delete(String[] ids) { |
| | | baseDao.deleteBatchIds(Arrays.asList(ids)); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void deleteByItemId(String[] ids) { |
| | | QueryWrapper<IndItemCalEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.in("item_id", ids); |
| | | baseDao.delete(wrapper); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.ind.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.iailab.framework.common.constant.Constant; |
| | | import com.iailab.module.data.common.enums.CommonConstant; |
| | | import com.iailab.module.data.common.enums.IsEnableEnum; |
| | | import com.iailab.framework.common.page.PageData; |
| | | import com.iailab.framework.common.service.impl.BaseServiceImpl; |
| | | import com.iailab.framework.common.util.object.ConvertUtils; |
| | | import com.iailab.module.data.ind.dto.IndItemAtomDTO; |
| | | import com.iailab.module.data.ind.service.IndItemCalService; |
| | | import com.iailab.module.data.ind.service.IndItemService; |
| | | import com.iailab.module.data.ind.common.IndItemTypeEnum; |
| | | import com.iailab.module.data.ind.dao.IndItemDao; |
| | | import com.iailab.module.data.ind.dto.IndItemCalDTO; |
| | | import com.iailab.module.data.ind.dto.IndItemDTO; |
| | | import com.iailab.module.data.ind.entity.IndItemEntity; |
| | | import com.iailab.module.data.ind.service.IndItemAtomService; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年05月25日 |
| | | */ |
| | | @Service |
| | | public class IndItemServiceImpl extends BaseServiceImpl<IndItemDao, IndItemEntity> implements IndItemService { |
| | | |
| | | @Resource |
| | | private IndItemAtomService indItemAtomService; |
| | | |
| | | @Resource |
| | | private IndItemCalService indItemCalService; |
| | | |
| | | @Override |
| | | public PageData<IndItemDTO> page(Map<String, Object> params) { |
| | | IPage<IndItemEntity> page = baseDao.selectPage( |
| | | getPage(params, Constant.CREATE_TIME, false), |
| | | getWrapper(params) |
| | | ); |
| | | return getPageData(page, IndItemDTO.class); |
| | | } |
| | | |
| | | @Override |
| | | public List<IndItemDTO> getList(Map<String, Object> params) { |
| | | List<IndItemEntity> list = baseDao.selectList(getWrapper(params)); |
| | | return ConvertUtils.sourceToTarget(list, IndItemDTO.class); |
| | | } |
| | | |
| | | @Override |
| | | public void enableByIds(String[] ids) { |
| | | if (CollectionUtils.isEmpty(Arrays.asList(ids))) { |
| | | return; |
| | | } |
| | | Arrays.asList(ids).forEach(item -> { |
| | | IndItemEntity entity = new IndItemEntity(); |
| | | entity.setId(item); |
| | | entity.setIsEnable(IsEnableEnum.ENABLE.value()); |
| | | baseDao.updateById(entity); |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public void disableByIds(String[] ids) { |
| | | if (CollectionUtils.isEmpty(Arrays.asList(ids))) { |
| | | return; |
| | | } |
| | | Arrays.asList(ids).forEach(item -> { |
| | | IndItemEntity entity = new IndItemEntity(); |
| | | entity.setId(item); |
| | | entity.setIsEnable(IsEnableEnum.DISABLE.value()); |
| | | baseDao.updateById(entity); |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public IndItemDTO getItemByItemNo(String itemNo) { |
| | | QueryWrapper<IndItemEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("item_no", itemNo); |
| | | return ConvertUtils.sourceToTarget(baseDao.selectOne(wrapper),IndItemDTO.class); |
| | | } |
| | | |
| | | private QueryWrapper<IndItemEntity> getWrapper(Map<String, Object> params){ |
| | | String itemNo = (String)params.get("itemNo"); |
| | | |
| | | QueryWrapper<IndItemEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.like(StringUtils.isNotBlank(itemNo), "item_no", itemNo); |
| | | |
| | | return wrapper; |
| | | } |
| | | |
| | | @Override |
| | | public IndItemDTO get(String id) { |
| | | IndItemEntity entity = baseDao.selectById(id); |
| | | if (entity == null) { |
| | | return null; |
| | | } |
| | | IndItemDTO result = ConvertUtils.sourceToTarget(entity, IndItemDTO.class); |
| | | if (IndItemTypeEnum.ATOM_ITEM.getCode().equals(result.getItemType())) { |
| | | IndItemAtomDTO dto = indItemAtomService.getItemId(id); |
| | | result.setIndItemAtom(dto); |
| | | } else if (IndItemTypeEnum.CAL_ITEM.getCode().equals(result.getItemType())) { |
| | | IndItemCalDTO dto = indItemCalService.getItemId(id); |
| | | result.setIndItemCal(dto); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public void save(IndItemDTO dto) { |
| | | IndItemEntity entity = ConvertUtils.sourceToTarget(dto, IndItemEntity.class); |
| | | entity.setId(UUID.randomUUID().toString()); |
| | | if (IndItemTypeEnum.ATOM_ITEM.getName().equals(entity.getItemType())) { |
| | | IndItemAtomDTO indItemAtomDTO = new IndItemAtomDTO(); |
| | | indItemAtomDTO.setId(UUID.randomUUID().toString()); |
| | | indItemAtomDTO.setItemId(entity.getId()); |
| | | indItemAtomDTO.setDataSource(dto.getDataSource()); |
| | | indItemAtomDTO.setQuerySql(dto.getQuerySql()); |
| | | indItemAtomService.save(indItemAtomDTO); |
| | | }else if (IndItemTypeEnum.CAL_ITEM.getName().equals(entity.getItemType())){ |
| | | IndItemCalDTO indItemCalDTO = new IndItemCalDTO(); |
| | | indItemCalDTO.setId(UUID.randomUUID().toString()); |
| | | indItemCalDTO.setItemId(entity.getId()); |
| | | indItemCalDTO.setExpression(dto.getExpression()); |
| | | indItemCalService.save(indItemCalDTO); |
| | | } |
| | | entity.setIsEnable(CommonConstant.IS_ENABLE); |
| | | entity.setCreateTime(new Date()); |
| | | insert(entity); |
| | | } |
| | | |
| | | @Override |
| | | public void update(IndItemDTO dto) { |
| | | IndItemEntity entity = ConvertUtils.sourceToTarget(dto, IndItemEntity.class); |
| | | entity.setUpdateTime(new Date()); |
| | | updateById(entity); |
| | | System.out.println(IndItemTypeEnum.ATOM_ITEM.getName()+IndItemTypeEnum.CAL_ITEM.getName()); |
| | | if (IndItemTypeEnum.ATOM_ITEM.getName().equals(entity.getItemType())) { |
| | | dto.getIndItemAtom().setDataSource(dto.getDataSource()); |
| | | dto.getIndItemAtom().setQuerySql(dto.getQuerySql()); |
| | | indItemAtomService.update(dto.getIndItemAtom()); |
| | | }else if (IndItemTypeEnum.CAL_ITEM.getName().equals(entity.getItemType())){ |
| | | dto.getIndItemCal().setExpression(dto.getExpression()); |
| | | indItemCalService.update(dto.getIndItemCal()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void delete(String[] ids) { |
| | | baseDao.deleteBatchIds(Arrays.asList(ids)); |
| | | indItemAtomService.deleteByItemId(ids); |
| | | indItemCalService.deleteByItemId(ids); |
| | | } |
| | | |
| | | @Override |
| | | public List<IndItemDTO> getItemAtom(List<String> itemNos) { |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("itemType", IndItemTypeEnum.ATOM_ITEM.getCode()); |
| | | params.put("isEnable", CommonConstant.IS_ENABLE); |
| | | params.put("itemNos", itemNos); |
| | | return baseDao.getItemAtom(params); |
| | | } |
| | | |
| | | @Override |
| | | public IndItemDTO getItemAtom(String itemNo) { |
| | | IndItemDTO result = null; |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("itemType", IndItemTypeEnum.ATOM_ITEM.getCode()); |
| | | params.put("isEnable", CommonConstant.IS_ENABLE); |
| | | params.put("itemNo", itemNo); |
| | | List<IndItemDTO> list = baseDao.getItemAtom(params); |
| | | if (!CollectionUtils.isEmpty(list)) { |
| | | result = list.get(0); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public List<IndItemDTO> getItemCal(List<String> itemNos) { |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("itemType", IndItemTypeEnum.CAL_ITEM.getCode()); |
| | | params.put("isEnable", CommonConstant.IS_ENABLE); |
| | | params.put("itemNos", itemNos); |
| | | return baseDao.getItemCal(params); |
| | | } |
| | | |
| | | @Override |
| | | public IndItemDTO getItemCal(String itemNo) { |
| | | IndItemDTO result = null; |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("itemType", IndItemTypeEnum.CAL_ITEM.getCode()); |
| | | params.put("isEnable", CommonConstant.IS_ENABLE); |
| | | params.put("itemNo", itemNo); |
| | | List<IndItemDTO> list = baseDao.getItemCal(params); |
| | | if (!CollectionUtils.isEmpty(list)) { |
| | | result = list.get(0); |
| | | } |
| | | return result; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.ind.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.iailab.framework.common.constant.Constant; |
| | | import com.iailab.framework.common.page.PageData; |
| | | import com.iailab.framework.common.service.impl.BaseServiceImpl; |
| | | import com.iailab.framework.common.util.object.ConvertUtils; |
| | | import com.iailab.module.data.ind.dao.IndItemValueDao; |
| | | import com.iailab.module.data.ind.entity.IndItemValueEntity; |
| | | import com.iailab.module.data.ind.service.IndItemValueService; |
| | | import com.iailab.module.data.ind.dao.IndItemValueDao; |
| | | import com.iailab.module.data.ind.entity.IndItemValueEntity; |
| | | import com.iailab.module.data.ind.service.IndItemValueService; |
| | | import com.iailab.module.data.ind.dao.IndItemValueDao; |
| | | import com.iailab.module.data.ind.dto.IndItemValueDTO; |
| | | import com.iailab.module.data.ind.entity.IndItemValueEntity; |
| | | import com.iailab.module.data.ind.service.IndItemValueService; |
| | | import com.iailab.module.data.ind.dao.IndItemValueDao; |
| | | import com.iailab.module.data.ind.entity.IndItemValueEntity; |
| | | import com.iailab.module.data.ind.service.IndItemValueService; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年05月25日 |
| | | */ |
| | | @Service |
| | | public class IndItemValueServiceImpl extends BaseServiceImpl<IndItemValueDao, IndItemValueEntity> implements IndItemValueService { |
| | | |
| | | @Override |
| | | public PageData<IndItemValueDTO> page(Map<String, Object> params) { |
| | | IPage<IndItemValueEntity> page = baseDao.selectPage( |
| | | getPage(params, Constant.CREATE_DATE, false), |
| | | getWrapper(params) |
| | | ); |
| | | return getPageData(page, IndItemValueDTO.class); |
| | | } |
| | | |
| | | private QueryWrapper<IndItemValueEntity> getWrapper(Map<String, Object> params) { |
| | | String itemNo = (String) params.get("itemNo"); |
| | | |
| | | QueryWrapper<IndItemValueEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.like(StringUtils.isNotBlank(itemNo), "item_no", itemNo); |
| | | |
| | | return wrapper; |
| | | } |
| | | |
| | | @Override |
| | | public IndItemValueDTO get(String id) { |
| | | IndItemValueEntity entity = baseDao.selectById(id); |
| | | |
| | | return ConvertUtils.sourceToTarget(entity, IndItemValueDTO.class); |
| | | } |
| | | |
| | | @Override |
| | | public void save(IndItemValueDTO dto) { |
| | | IndItemValueEntity entity = ConvertUtils.sourceToTarget(dto, IndItemValueEntity.class); |
| | | |
| | | insert(entity); |
| | | } |
| | | |
| | | @Override |
| | | public void update(IndItemValueDTO dto) { |
| | | IndItemValueEntity entity = ConvertUtils.sourceToTarget(dto, IndItemValueEntity.class); |
| | | |
| | | updateById(entity); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void delete(String[] ids) { |
| | | baseDao.deleteBatchIds(Arrays.asList(ids)); |
| | | |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.indexdata.common; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年09月11日 09:52:00 |
| | | */ |
| | | public enum ClockSuffix { |
| | | BB,YB,RI |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.indexdata.common; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年09月10日 23:29:00 |
| | | */ |
| | | public enum IndexDataBc { |
| | | BC_B_ST,BC_Y_ST,BC_TIME |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.indexdata.common; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年09月12日 08:57:00 |
| | | */ |
| | | public interface IndexDataConstant { |
| | | |
| | | /** |
| | | * 数据项类别 原煤 |
| | | */ |
| | | String DATA_ITEM_TYPE_YM = "1"; |
| | | |
| | | /** |
| | | * 数据项类别 洗选 |
| | | */ |
| | | String DATA_ITEM_TYPE_XX = "2"; |
| | | |
| | | /** |
| | | * 数据项类别 装车 |
| | | */ |
| | | String DATA_ITEM_TYPE_ZC = "3"; |
| | | |
| | | /** |
| | | * 数据项类别 装车 |
| | | */ |
| | | String DATA_ITEM_TYPE_ZJ = "4"; |
| | | |
| | | /** |
| | | * 运行时长全部 |
| | | */ |
| | | String RUN_TIME = "run-time"; |
| | | |
| | | /** |
| | | * 运行时长正常 |
| | | */ |
| | | String RUN_TIME_ZC = "run-time-zc"; |
| | | |
| | | /** |
| | | * 运行时长空载 |
| | | */ |
| | | String RUN_TIME_KZ = "run-time-kz"; |
| | | |
| | | /** |
| | | * 消耗指标 |
| | | */ |
| | | String CONSUME_TARGET = "consume-target"; |
| | | |
| | | /** |
| | | * 电耗 |
| | | */ |
| | | String POWER_CONSUME = "power-consume"; |
| | | |
| | | /** |
| | | * 调入量 |
| | | */ |
| | | String WASH_TRANSFER_IN = "wash-transfer-in"; |
| | | |
| | | /** |
| | | * 入洗量 |
| | | */ |
| | | String WASH_TO_WASH = "wash-to-wash"; |
| | | |
| | | /** |
| | | * 生产量 |
| | | */ |
| | | String WASH_PROD_VOLUME = "wash-prod-volume"; |
| | | |
| | | /** |
| | | * 仓位 |
| | | */ |
| | | String WAREHOUSE_POSITION = "warehouse-position"; |
| | | |
| | | /** |
| | | * 小时量 |
| | | */ |
| | | String HOUR_VOLUME = "hour-volume"; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.indexdata.common; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.iailab.dto.*; |
| | | import com.iailab.module.data.common.enums.CommonConstant; |
| | | import com.iailab.api.IFeignProddispApi; |
| | | import com.iailab.framework.common.util.date.DateUtils; |
| | | import com.iailab.module.data.point.dto.DaPointDTO; |
| | | import com.iailab.module.data.point.service.DaPointService; |
| | | import com.iailab.module.data.indexdata.entity.IndexDataItemEntity; |
| | | import com.iailab.module.data.indexdata.entity.IndexDataValueEntity; |
| | | import com.iailab.module.data.indexdata.service.IndexDataItemService; |
| | | import com.iailab.module.data.indexdata.service.IndexDataValueService; |
| | | import com.iailab.module.data.influxdb.pojo.InfluxPointValuePOJO; |
| | | import com.iailab.module.data.influxdb.service.InfluxDBService; |
| | | import com.iailab.module.infra.api.config.ConfigApi; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.joda.time.LocalDate; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年09月11日 14:11:00 |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class IndexDataUtils { |
| | | |
| | | private BigDecimal hourMins = new BigDecimal("60"); |
| | | |
| | | private String DATA_TYPE_BOOLEAN = "boolean"; |
| | | |
| | | private final int granularity = 5; |
| | | |
| | | @Resource |
| | | private InfluxDBService influxDBService; |
| | | |
| | | @Resource |
| | | private IndexDataValueService indexDataValueService; |
| | | |
| | | @Resource |
| | | private IFeignProddispApi feignProddispApi; |
| | | |
| | | @Resource |
| | | private ConfigApi configApi; |
| | | |
| | | @Resource |
| | | private DaPointService daPointService; |
| | | |
| | | @Resource |
| | | private IndexDataItemService indexDataItemService; |
| | | |
| | | public void doCal(Date startTime, Date endTime, String CLOCK_CODE, String DICT_DC) throws Exception { |
| | | log.info("startTime=" + DateUtils.format(startTime, DateUtils.FORMAT_YEAR_MONTH_DAY)); |
| | | log.info("endTime=" + DateUtils.format(endTime, DateUtils.FORMAT_YEAR_MONTH_DAY)); |
| | | // 获取数据项 |
| | | List<IndexDataItemEntity> indexDataItemList = indexDataItemService.getListByClockConfig(CLOCK_CODE); |
| | | if (CollectionUtils.isEmpty(indexDataItemList)) { |
| | | log.warn("indexDataItemEntityList为空, clockCode=" + CLOCK_CODE); |
| | | throw new Exception("indexDataItemEntityList为空, clockCode=" + CLOCK_CODE); |
| | | } |
| | | indexDataItemList.forEach(dataItem -> { |
| | | switch (dataItem.getItemType()) { |
| | | case IndexDataConstant.RUN_TIME: |
| | | // 运行时长 |
| | | this.createRunTime(CLOCK_CODE, dataItem, "all" ,startTime, endTime); |
| | | break; |
| | | case IndexDataConstant.RUN_TIME_ZC: |
| | | // 运行时长正常 |
| | | this.createRunTime(CLOCK_CODE, dataItem, "zc",startTime, endTime); |
| | | break; |
| | | case IndexDataConstant.RUN_TIME_KZ: |
| | | // 运行时长空载 |
| | | this.createRunTime(CLOCK_CODE, dataItem, "kz",startTime, endTime); |
| | | break; |
| | | case IndexDataConstant.POWER_CONSUME: |
| | | // 电耗 |
| | | this.createPowerConsume(CLOCK_CODE, dataItem, startTime, endTime); |
| | | break; |
| | | case IndexDataConstant.WASH_TRANSFER_IN: |
| | | // 调入量 |
| | | this.createWashTransferIn(CLOCK_CODE, dataItem, startTime, endTime); |
| | | break; |
| | | case IndexDataConstant.WASH_TO_WASH: |
| | | // 入洗量 |
| | | this.createWashToWash(CLOCK_CODE, dataItem, startTime, endTime); |
| | | break; |
| | | case IndexDataConstant.WASH_PROD_VOLUME: |
| | | // 生产量 |
| | | this.createWashProdVolume(CLOCK_CODE, dataItem, startTime, endTime); |
| | | break; |
| | | case IndexDataConstant.WAREHOUSE_POSITION: |
| | | // 仓位 |
| | | this.createWarehousePosition(CLOCK_CODE, dataItem, startTime, endTime); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | }); |
| | | |
| | | // 统计库存 |
| | | this.createWarehouseStock(DateUtils.format(startTime), DICT_DC); |
| | | |
| | | // 统计总电量 |
| | | FeignConsumeTargetDTO dto = new FeignConsumeTargetDTO(); |
| | | Map param = new HashMap(); |
| | | param.put("rq",new LocalDate()); |
| | | param.put("bc",DICT_DC); |
| | | BigDecimal hdl = feignProddispApi.sumData(param); |
| | | dto.setRq(DateUtils.format(startTime)); |
| | | dto.setBc(DICT_DC); |
| | | dto.setXhzb("hdl"); |
| | | dto.setDw("kw.h"); |
| | | dto.setNbdrl(hdl); |
| | | dto.setNbtzl(new BigDecimal(0)); |
| | | dto.setWbdrl(new BigDecimal(0)); |
| | | dto.setWbtzl(new BigDecimal(0)); |
| | | dto.setCjr(CommonConstant.CJS_SYS); |
| | | dto.setCjsj(new Date()); |
| | | dto.setXgsj(new Date()); |
| | | feignProddispApi.createConsumeTarget(dto); |
| | | |
| | | } |
| | | |
| | | public void doHourVolume(Date startTime, Date endTime, String CLOCK_CODE, String DICT_DC) throws Exception { |
| | | log.info("startTime=" + DateUtils.format(startTime, DateUtils.FORMAT_YEAR_MONTH_DAY)); |
| | | log.info("endTime=" + DateUtils.format(endTime, DateUtils.FORMAT_YEAR_MONTH_DAY)); |
| | | // 获取数据项 |
| | | List<IndexDataItemEntity> indexDataItemList = indexDataItemService.getListByClockConfig(CLOCK_CODE); |
| | | if (CollectionUtils.isEmpty(indexDataItemList)) { |
| | | log.warn("indexDataItemEntityList为空, clockCode=" + CLOCK_CODE); |
| | | throw new Exception("indexDataItemEntityList为空, clockCode=" + CLOCK_CODE); |
| | | } |
| | | indexDataItemList.forEach(dataItem -> {this.createHourVolume(CLOCK_CODE, dataItem, startTime, endTime);}); |
| | | |
| | | } |
| | | public void createRunTime(String clockCode, IndexDataItemEntity dataItem, String runTimeType,Date startTime, Date endTime) { |
| | | try{ |
| | | log.info("计算运行时长开始,itemCode=" + dataItem.getPointCode()); |
| | | InfluxPointValuePOJO pojo = new InfluxPointValuePOJO(); |
| | | pojo.setPoint(dataItem.getPointCode()); |
| | | pojo.setType(DATA_TYPE_BOOLEAN); |
| | | List<Map<String, Object>> pointData = influxDBService.queryPointValues(pojo, startTime, endTime); |
| | | if (CollectionUtils.isEmpty(pointData)) { |
| | | log.warn("历史值为空,PointCode=" + dataItem.getPointCode()); |
| | | return; |
| | | } |
| | | int mins = this.getRunMins(pointData); |
| | | int times = this.getStartUpTimes(pointData); |
| | | |
| | | Map<String, BigDecimal> valueMap = new HashMap<>(2); |
| | | valueMap.put("sumValue", new BigDecimal(mins)); |
| | | valueMap.put("startUpTimes", new BigDecimal(times)); |
| | | IndexDataValueEntity indexDataValue = this.buildIndexDataValueEntity(dataItem, clockCode, valueMap); |
| | | indexDataValueService.add(indexDataValue); |
| | | |
| | | FeignRunTimeDTO dto = new FeignRunTimeDTO(); |
| | | dto.setRq(DateUtils.format(startTime)); |
| | | dto.setBc(dataItem.getBc()); |
| | | dto.setScxm(dataItem.getXtCode()); |
| | | dto.setRunTimeType(runTimeType); |
| | | dto.setXss(Long.valueOf((mins / 60))); |
| | | dto.setFzs(Long.valueOf((mins % 60))); |
| | | dto.setZsc(Long.valueOf(mins)); |
| | | dto.setCjr(CommonConstant.CJS_SYS); |
| | | dto.setCjsj(new Date()); |
| | | dto.setXgsj(new Date()); |
| | | feignProddispApi.createRunTime(dto); |
| | | log.info("计算运行时长结束,itemCode=" + dataItem.getPointCode()); |
| | | } catch (Exception ex) { |
| | | log.info("计算运行时长异常,itemCode=" + dataItem.getPointCode()); |
| | | ex.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | public void createConsumeTarget(String clockCode, IndexDataItemEntity dataItem, Date startTime, Date endTime) { |
| | | try{ |
| | | log.info("计算消耗指标开始,itemCode=" + dataItem.getPointCode()); |
| | | |
| | | // 插入指标数据表 |
| | | Map<String, BigDecimal> valueMap = new HashMap<>(2); |
| | | valueMap.put("sumValue", new BigDecimal(0)); |
| | | IndexDataValueEntity indexDataValue = this.buildIndexDataValueEntity(dataItem, clockCode, valueMap); |
| | | indexDataValueService.add(indexDataValue); |
| | | |
| | | FeignConsumeTargetDTO dto = new FeignConsumeTargetDTO(); |
| | | dto.setRq(DateUtils.format(startTime)); |
| | | dto.setBc(dataItem.getBc()); |
| | | dto.setXhzb(dataItem.getExt1()); |
| | | dto.setDw(dataItem.getUnit()); |
| | | dto.setNbdrl(new BigDecimal(0)); |
| | | dto.setNbtzl(new BigDecimal(0)); |
| | | dto.setWbdrl(new BigDecimal(0)); |
| | | dto.setWbtzl(new BigDecimal(0)); |
| | | dto.setCjr(CommonConstant.CJS_SYS); |
| | | dto.setCjsj(new Date()); |
| | | dto.setXgsj(new Date()); |
| | | feignProddispApi.createConsumeTarget(dto); |
| | | log.info("计算消耗指标结束,itemCode=" + dataItem.getPointCode()); |
| | | } catch (Exception ex) { |
| | | log.info("计算消耗指标异常,itemCode=" + dataItem.getPointCode()); |
| | | ex.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | public void createPowerConsume(String clockCode, IndexDataItemEntity dataItem, Date startTime, Date endTime) { |
| | | try{ |
| | | DaPointDTO daPoint = daPointService.getByNo(dataItem.getPointCode()); |
| | | |
| | | if (daPoint == null) { |
| | | log.info("daPoint is null"); |
| | | return; |
| | | } |
| | | InfluxPointValuePOJO pojo = new InfluxPointValuePOJO(); |
| | | pojo.setPoint(daPoint.getPointNo()); |
| | | pojo.setType(daPoint.getPointType()); |
| | | // 取10min内最大值 |
| | | Object startPointValue = influxDBService.queryPointMaxValue(pojo, new Date(startTime.getTime() - 1000 * 60 * 10)); |
| | | Object endPointValue = influxDBService.queryPointMaxValue(pojo, new Date(endTime.getTime() - 1000 * 60 * 10)); |
| | | BigDecimal startValue = startPointValue == null ? BigDecimal.ZERO : new BigDecimal(startPointValue.toString()); |
| | | BigDecimal endValue = endPointValue == null ? BigDecimal.ZERO : new BigDecimal(endPointValue.toString()); |
| | | BigDecimal value = new BigDecimal(0); |
| | | if(endValue.compareTo(startValue) == 1){ |
| | | value = endValue.subtract(startValue); |
| | | } |
| | | // 插入指标数据表 |
| | | Map<String, BigDecimal> valueMap = new HashMap<>(1); |
| | | valueMap.put("sumValue", value); |
| | | IndexDataValueEntity indexDataValue = this.buildIndexDataValueEntity(dataItem, clockCode, valueMap); |
| | | indexDataValueService.add(indexDataValue); |
| | | |
| | | String xt = configApi.queryConfigByCode(dataItem.getExt1()); |
| | | // 插入统计表 |
| | | FeignPowerConsumeDTO dto = new FeignPowerConsumeDTO(); |
| | | dto.setRq(DateUtils.format(startTime)); |
| | | dto.setBc(dataItem.getBc()); |
| | | dto.setXt(xt); |
| | | dto.setNbdrl(value); |
| | | dto.setNbtzl(new BigDecimal(0)); |
| | | dto.setWbdrl(value); |
| | | dto.setWbtzl(new BigDecimal(0)); |
| | | dto.setCjr(CommonConstant.CJS_SYS); |
| | | dto.setCjsj(new Date()); |
| | | dto.setXgsj(new Date()); |
| | | feignProddispApi.createPowerConsume(dto); |
| | | log.info("计算电耗结束,itemCode=" + dataItem.getPointCode()); |
| | | } catch (Exception ex) { |
| | | log.info("计算电耗异常,itemCode=" + dataItem.getPointCode()); |
| | | ex.printStackTrace(); |
| | | } |
| | | } |
| | | public void createHourVolume(String clockCode, IndexDataItemEntity dataItem, Date startTime, Date endTime) { |
| | | try{ |
| | | /** |
| | | * 861 精煤 |
| | | * 862 混煤 |
| | | * 903 矸石 |
| | | * 603ABC 煤泥板数 |
| | | */ |
| | | log.info("计算小时量开始,itemCode=" + dataItem.getPointCode()); |
| | | List<String> pointNos = new ArrayList<>(); |
| | | pointNos.add(dataItem.getPointCode()); |
| | | if(StringUtils.isNotBlank(dataItem.getExt1())) { |
| | | pointNos.add(dataItem.getExt1()); |
| | | } |
| | | if(StringUtils.isNotBlank(dataItem.getExt2())) { |
| | | pointNos.add(dataItem.getExt2()); |
| | | } |
| | | if(StringUtils.isNotBlank(dataItem.getExt3())) { |
| | | pointNos.add(dataItem.getExt3()); |
| | | } |
| | | if(StringUtils.isNotBlank(dataItem.getExt4())) { |
| | | pointNos.add(dataItem.getExt4()); |
| | | } |
| | | if(StringUtils.isNotBlank(dataItem.getExt5())) { |
| | | pointNos.add(dataItem.getExt5()); |
| | | } |
| | | List<DaPointDTO> pointList = daPointService.getByNos(pointNos); |
| | | if (CollectionUtils.isEmpty(pointList)) { |
| | | log.warn("pointNos查询为空!"); |
| | | return; |
| | | } |
| | | List<InfluxPointValuePOJO> influxParams = pointList.stream().map(item -> { |
| | | InfluxPointValuePOJO pojo = new InfluxPointValuePOJO(); |
| | | pojo.setPoint(item.getPointNo()); |
| | | pojo.setType(item.getDataType()); |
| | | return pojo; |
| | | }).collect(Collectors.toList()); |
| | | Map<String, Object> data = influxDBService.queryPointsSpread(influxParams, startTime, endTime); |
| | | log.info("查询完成!"); |
| | | |
| | | log.info("插入统计表"); |
| | | FeignHourVolumeDTO dto = new FeignHourVolumeDTO(); |
| | | dto.setRq(DateUtils.format(startTime)); |
| | | dto.setBc(this.getBcByTime(endTime)); |
| | | dto.setSj(endTime); |
| | | if (StringUtils.isNotBlank(dataItem.getPointCode()) && data.get(dataItem.getPointCode()) != null) { |
| | | dto.setRxl(new BigDecimal(data.get(dataItem.getPointCode()).toString())); |
| | | log.info(" 插入指标数据表"); |
| | | Map<String, BigDecimal> valueMap = new HashMap<>(1); |
| | | valueMap.put("sumValue", new BigDecimal(data.get(dataItem.getPointCode()).toString())); |
| | | IndexDataValueEntity indexDataValue = this.buildIndexDataValueEntity(dataItem, clockCode, valueMap); |
| | | indexDataValueService.add(indexDataValue); |
| | | } |
| | | if (StringUtils.isNotBlank(dataItem.getExt1()) && data.get(dataItem.getExt1()) != null) { |
| | | dto.setJml(new BigDecimal(data.get(dataItem.getExt1()).toString())); |
| | | } |
| | | if (StringUtils.isNotBlank(dataItem.getExt2()) && data.get(dataItem.getExt2()) != null) { |
| | | dto.setHml(new BigDecimal(data.get(dataItem.getExt2()).toString())); |
| | | } |
| | | if (StringUtils.isNotBlank(dataItem.getExt3()) && data.get(dataItem.getExt3()) != null) { |
| | | dto.setGsl(new BigDecimal(data.get(dataItem.getExt3()).toString())); |
| | | } |
| | | if (StringUtils.isNotBlank(dataItem.getExt4()) && data.get(dataItem.getExt4()) != null) { |
| | | dto.setFjbs(new BigDecimal(data.get(dataItem.getExt4()).toString())); |
| | | } |
| | | if (StringUtils.isNotBlank(dataItem.getExt5()) && data.get(dataItem.getExt5()) != null) { |
| | | dto.setMnbs(new BigDecimal(data.get(dataItem.getExt5()).toString())); |
| | | } |
| | | dto.setCjr(CommonConstant.CJS_SYS); |
| | | dto.setCjsj(new Date()); |
| | | dto.setXgsj(new Date()); |
| | | feignProddispApi.createHourVolume(dto); |
| | | log.info("计算小时量结束,itemCode=" + dataItem.getPointCode()); |
| | | } catch (Exception ex) { |
| | | log.info("计算小时量异常,itemCode=" + dataItem.getPointCode()); |
| | | ex.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | private String getBcByTime(Date dateTime) { |
| | | String bc = "bb"; |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(dateTime); |
| | | if (calendar.get(Calendar.HOUR_OF_DAY) >= 21 || calendar.get(Calendar.HOUR_OF_DAY) <= 8) { |
| | | bc = "yb"; |
| | | } |
| | | return bc; |
| | | } |
| | | |
| | | public void createWashTransferIn(String clockCode, IndexDataItemEntity dataItem, Date startTime, Date endTime) { |
| | | try{ |
| | | log.info("计算调入量开始,itemCode=" + dataItem.getPointCode()); |
| | | // 查询测点里的累计产量 |
| | | DaPointDTO daPoint = daPointService.getByNo(dataItem.getPointCode()); |
| | | |
| | | if (daPoint == null) { |
| | | log.info("daPoint is null"); |
| | | return; |
| | | } |
| | | InfluxPointValuePOJO pojo = new InfluxPointValuePOJO(); |
| | | pojo.setPoint(daPoint.getPointNo()); |
| | | pojo.setType(daPoint.getDataType()); |
| | | // 取10min内最大值 |
| | | Object pointValue = influxDBService.queryPointMaxValue(pojo, new Date(endTime.getTime() - 1000 * 60 * 10)); |
| | | BigDecimal sumValue = pointValue == null ? BigDecimal.ZERO : new BigDecimal(pointValue.toString()); |
| | | |
| | | // 插入指标数据表 |
| | | Map<String, BigDecimal> valueMap = new HashMap<>(1); |
| | | valueMap.put("sumValue", sumValue); |
| | | IndexDataValueEntity indexDataValue = this.buildIndexDataValueEntity(dataItem, clockCode, valueMap); |
| | | indexDataValueService.add(indexDataValue); |
| | | |
| | | String mz = configApi.queryConfigByCode(dataItem.getExt1()); |
| | | // 插入统计表 |
| | | FeignWashTransferInDTO dto = new FeignWashTransferInDTO(); |
| | | dto.setRq(DateUtils.format(startTime)); |
| | | dto.setBc(dataItem.getBc()); |
| | | dto.setDrly(mz); |
| | | dto.setNbdrl(sumValue); |
| | | dto.setNbtzl(new BigDecimal(0)); |
| | | dto.setWbdrl(sumValue); |
| | | dto.setWbtzl(new BigDecimal(0)); |
| | | dto.setCjr(CommonConstant.CJS_SYS); |
| | | dto.setCjsj(new Date()); |
| | | dto.setXgsj(new Date()); |
| | | feignProddispApi.createWashTransferIn(dto); |
| | | log.info("计算调入量结束,itemCode=" + dataItem.getPointCode()); |
| | | } catch (Exception ex) { |
| | | log.info("计算调入量异常,itemCode=" + dataItem.getPointCode()); |
| | | ex.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | public void createWashToWash(String clockCode, IndexDataItemEntity dataItem, Date startTime, Date endTime) { |
| | | try{ |
| | | log.info("计算入洗量开始,itemCode=" + dataItem.getPointCode()); |
| | | // 查询测点里的累计产量 |
| | | DaPointDTO daPoint = daPointService.getByNo(dataItem.getPointCode()); |
| | | if (daPoint == null) { |
| | | log.info("daPoint is null"); |
| | | return; |
| | | } |
| | | InfluxPointValuePOJO pojo = new InfluxPointValuePOJO(); |
| | | pojo.setPoint(daPoint.getPointNo()); |
| | | pojo.setType(daPoint.getDataType()); |
| | | // 取10min内最大值 |
| | | Object pointValue = influxDBService.queryPointMaxValue(pojo, new Date(endTime.getTime() - 1000 * 60 * 10)); |
| | | BigDecimal sumValue = pointValue == null ? BigDecimal.ZERO : new BigDecimal(pointValue.toString()); |
| | | log.info("插入指标数据表"); |
| | | Map<String, BigDecimal> valueMap = new HashMap<>(1); |
| | | log.info("sumValue"+sumValue); |
| | | valueMap.put("sumValue", sumValue); |
| | | IndexDataValueEntity indexDataValue = this.buildIndexDataValueEntity(dataItem, clockCode, valueMap); |
| | | indexDataValueService.add(indexDataValue); |
| | | List<FeignMcMzDTO> mzList = feignProddispApi.selectMcMzByMc(dataItem.getExt1()); |
| | | log.info("dataItem.getExt1()"+dataItem.getExt1()); |
| | | |
| | | //获取总入洗量 |
| | | pojo.setPoint(dataItem.getExt2()); |
| | | pojo.setType("float"); |
| | | Object rxlPointValue = influxDBService.queryPointMaxValue(pojo, new Date(endTime.getTime() - 1000 * 60 * 10)); |
| | | BigDecimal sumRXL = rxlPointValue == null ? BigDecimal.ZERO : new BigDecimal(rxlPointValue.toString()); |
| | | |
| | | mzList.stream().forEach( |
| | | mz->{ |
| | | log.info("插入统计表,mc:"+mz.getMc()+";mz:"+mz.getMz()); |
| | | FeignWashToWashDTO dto = new FeignWashToWashDTO(); |
| | | dto.setRq(DateUtils.format(startTime)); |
| | | dto.setBc(dataItem.getBc()); |
| | | dto.setXxjm(mz.getMz()); |
| | | dto.setNbdrl(sumValue.multiply(BigDecimal.valueOf(mz.getProportion())).divide(BigDecimal.valueOf(mz.getDen())) ); |
| | | dto.setRxbl(dto.getNbdrl().divide(sumRXL, 2, RoundingMode.HALF_UP)); |
| | | dto.setRxly(dataItem.getExt1()); |
| | | dto.setNbtzl(new BigDecimal(0)); |
| | | dto.setWbdrl(dto.getNbdrl()); |
| | | dto.setWbtzl(new BigDecimal(0)); |
| | | dto.setCjr(CommonConstant.CJS_SYS); |
| | | dto.setCjsj(new Date()); |
| | | dto.setXgsj(new Date()); |
| | | feignProddispApi.createWashToWash(dto); |
| | | } |
| | | ); |
| | | |
| | | |
| | | log.info("计算入洗量结束,itemCode=" + dataItem.getPointCode()); |
| | | } catch (Exception ex) { |
| | | log.info("计算入洗量异常,itemCode=" + dataItem.getPointCode()); |
| | | ex.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | public void createWashProdVolume(String clockCode, IndexDataItemEntity dataItem, Date startTime, Date endTime) { |
| | | try{ |
| | | log.info("计算生产量开始,itemCode=" + dataItem.getPointCode()); |
| | | // 查询测点里的累计产量 |
| | | DaPointDTO daPoint = daPointService.getByNo(dataItem.getPointCode()); |
| | | if (daPoint == null) { |
| | | log.info("daPoint is null"); |
| | | return; |
| | | } |
| | | InfluxPointValuePOJO pojo = new InfluxPointValuePOJO(); |
| | | pojo.setPoint(daPoint.getPointNo()); |
| | | pojo.setType(daPoint.getDataType()); |
| | | // 取10min内最大值 |
| | | Object pointValue = influxDBService.queryPointMaxValue(pojo, new Date(endTime.getTime() - 1000 * 60 * 10)); |
| | | BigDecimal sumValue = pointValue == null ? BigDecimal.ZERO : new BigDecimal(pointValue.toString()); |
| | | |
| | | log.info("插入指标数据表"); |
| | | Map<String, BigDecimal> valueMap = new HashMap<>(1); |
| | | valueMap.put("sumValue", sumValue); |
| | | IndexDataValueEntity indexDataValue = this.buildIndexDataValueEntity(dataItem, clockCode, valueMap); |
| | | indexDataValueService.add(indexDataValue); |
| | | |
| | | log.info("插入统计表"); |
| | | FeignWashProdVolumeDTO dto = new FeignWashProdVolumeDTO(); |
| | | dto.setRq(DateUtils.format(startTime)); |
| | | dto.setBc(dataItem.getBc()); |
| | | dto.setClmz(dataItem.getExt1()); |
| | | dto.setNbdrl(sumValue); |
| | | dto.setNbtzl(new BigDecimal(0)); |
| | | dto.setWbdrl(sumValue); |
| | | dto.setWbtzl(new BigDecimal(0)); |
| | | dto.setCjr(CommonConstant.CJS_SYS); |
| | | dto.setCjsj(new Date()); |
| | | dto.setXgsj(new Date()); |
| | | feignProddispApi.createWashProdVolume(dto); |
| | | log.info("计算生产量结束,itemCode=" + dataItem.getPointCode()); |
| | | } catch (Exception ex) { |
| | | log.info("计算生产量异常,itemCode=" + dataItem.getPointCode()); |
| | | ex.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | public void createWarehousePosition(String clockCode, IndexDataItemEntity dataItem, Date startTime, Date endTime) { |
| | | try{ |
| | | log.info("计算仓位开始,itemCode=" + dataItem.getPointCode()); |
| | | DaPointDTO daPoint = daPointService.getByNo(dataItem.getPointCode()); |
| | | if (daPoint == null) { |
| | | log.info("daPoint is null"); |
| | | return; |
| | | } |
| | | InfluxPointValuePOJO pojo = new InfluxPointValuePOJO(); |
| | | pojo.setPoint(daPoint.getPointNo()); |
| | | pojo.setType(daPoint.getDataType()); |
| | | List<Map<String, Object>> pointValues = influxDBService.queryPointValues(pojo, new Date(endTime.getTime() - 1000 * 30), endTime); |
| | | String point = JSON.toJSONString(pointValues); |
| | | log.info("pointValues :"+point); |
| | | if (CollectionUtils.isEmpty(pointValues)) { |
| | | log.info("pointValues is null"); |
| | | return; |
| | | } |
| | | |
| | | Map<String, Object> pointValue = pointValues.get(pointValues.size() - 1); |
| | | JSONObject json = new JSONObject(pointValue); |
| | | log.info("插入指标数据表:"+json); |
| | | Map<String, BigDecimal> valueMap = new HashMap<>(1); |
| | | BigDecimal sumValue = new BigDecimal(pointValue.get("value").toString()); |
| | | valueMap.put("sumValue",sumValue); |
| | | IndexDataValueEntity indexDataValue = this.buildIndexDataValueEntity(dataItem, clockCode, valueMap); |
| | | indexDataValueService.add(indexDataValue); |
| | | log.info("mc:"+dataItem.getExt1()); |
| | | FeignWarehouseItemDTO warehouseItem = feignProddispApi.selectWarehouseItemByMc(dataItem.getExt1()); |
| | | log.info("插入仓位统计表开始"); |
| | | FeignWarehousePositionDTO dto = new FeignWarehousePositionDTO(); |
| | | dto.setRq(DateUtils.format(startTime)); |
| | | dto.setBc(dataItem.getBc()); |
| | | dto.setMc(dataItem.getExt1()); |
| | | dto.setMclx(dataItem.getExt2()); |
| | | log.info(Integer.toString(warehouseItem.getCapacity())); |
| | | dto.setCrl(Integer.toString(warehouseItem.getCapacity())); |
| | | BigDecimal dqcc = sumValue.multiply(new BigDecimal(dto.getCrl())).divide(new BigDecimal(100), 1, BigDecimal.ROUND_HALF_UP); |
| | | dto.setNbgl(dqcc); |
| | | dto.setWbgl(dqcc); |
| | | dto.setCjr(CommonConstant.CJS_SYS); |
| | | dto.setCjsj(new Date()); |
| | | dto.setXgsj(new Date()); |
| | | feignProddispApi.createWarehousePosition(dto); |
| | | log.info("计算仓位结束,itemCode=" + dataItem.getPointCode()); |
| | | } catch (Exception ex) { |
| | | log.info("计算仓位异常,itemCode=" + dataItem.getPointCode()); |
| | | ex.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | public void createWarehouseStock(String rq, String bc) { |
| | | try{ |
| | | log.info("计算库存开始,rq=" + rq); |
| | | |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("rq", rq); |
| | | params.put("bc", bc); |
| | | List<FeignWarehousePositionDTO> list = feignProddispApi.selectWarehouseGroupByCp(params); |
| | | list.forEach(item -> { |
| | | log.info("遍历" + item.getMc()+"煤仓煤种"); |
| | | List<FeignMcMzDTO> mzList = feignProddispApi.selectMcMzByMc(item.getMc()); |
| | | mzList.stream().forEach( |
| | | mz->{ |
| | | log.info("插入" + mz.getMz()+"库存"); |
| | | FeignWarehouseStockDTO dto = new FeignWarehouseStockDTO(); |
| | | dto.setRq(rq); |
| | | dto.setBc(bc); |
| | | dto.setLsh(new SimpleDateFormat("yyyyMMddhhmmssSSS").format(new Date())); |
| | | dto.setBs(item.getMclx()); |
| | | dto.setKcmz(mz.getMz()); |
| | | dto.setNbzrkc(new BigDecimal(0)); |
| | | dto.setNbjrrk(new BigDecimal(0)); |
| | | log.info(mz.getProportion().toString()); |
| | | log.info(mz.getDen().toString()); |
| | | BigDecimal math = item.getNbgl().multiply(BigDecimal.valueOf(mz.getProportion()).divide(BigDecimal.valueOf(mz.getDen()))); |
| | | BigDecimal nbjrkc = math.setScale(2, RoundingMode.HALF_UP); |
| | | dto.setNbjrkc(nbjrkc); |
| | | dto.setNbtzl(new BigDecimal(0)); |
| | | dto.setWbzrkc(new BigDecimal(0)); |
| | | dto.setWbjrrk(new BigDecimal(0)); |
| | | dto.setWbjrkc(dto.getNbjrkc()); |
| | | dto.setWbtzl(new BigDecimal(0)); |
| | | dto.setCjr(CommonConstant.CJS_SYS); |
| | | dto.setCjsj(new Date()); |
| | | dto.setXgsj(new Date()); |
| | | feignProddispApi.createWarehouseStock(dto); |
| | | } |
| | | ); |
| | | }); |
| | | log.info("计算库存结束,rq=" + rq); |
| | | } catch (Exception ex) { |
| | | log.info("计算库存异常,rq=" + rq); |
| | | ex.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | public int getRunMins(List<Map<String, Object>> pointData) { |
| | | int seconds = 0; |
| | | for (Map<String, Object> item: |
| | | pointData) { |
| | | if (Boolean.parseBoolean(item.get("value").toString())) { |
| | | seconds = seconds + granularity; |
| | | } |
| | | } |
| | | return (seconds / 60); |
| | | } |
| | | |
| | | /** |
| | | * getAvgOutput |
| | | * |
| | | * @param indexDataItemEntity |
| | | * @param output |
| | | * @param hours |
| | | * @return |
| | | */ |
| | | public BigDecimal getAvgOutput(IndexDataItemEntity indexDataItemEntity, BigDecimal output, BigDecimal hours) { |
| | | BigDecimal result = BigDecimal.ZERO; |
| | | if (hours.compareTo(BigDecimal.ZERO) > 0) { |
| | | result = output.divide(hours, 0, BigDecimal.ROUND_HALF_UP); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * buildIndexDataValueEntity |
| | | * |
| | | * @param indexDataItemEntity |
| | | * @param clock |
| | | * @param valueMap |
| | | * @return |
| | | */ |
| | | public IndexDataValueEntity buildIndexDataValueEntity(IndexDataItemEntity indexDataItemEntity, String clock, |
| | | Map<String, BigDecimal> valueMap) { |
| | | IndexDataValueEntity entity = new IndexDataValueEntity(); |
| | | entity.setId(UUID.randomUUID().toString().replace("-","")); |
| | | entity.setConfigId(indexDataItemEntity.getId()); |
| | | entity.setUnit2(indexDataItemEntity.getUnit2()); |
| | | entity.setSsdw(indexDataItemEntity.getSsdw()); |
| | | entity.setItemCode(indexDataItemEntity.getItemCode()); |
| | | entity.setItemName(indexDataItemEntity.getItemName()); |
| | | entity.setUnit(indexDataItemEntity.getUnit()); |
| | | entity.setClock(clock); |
| | | entity.setSumValue(valueMap.get("sumValue")); |
| | | entity.setAvgValue(valueMap.get("avgValue")); |
| | | entity.setReportValue(valueMap.get("reportValue")); |
| | | entity.setReportHourValue(valueMap.get("reportHourValue")); |
| | | entity.setCollectValue(valueMap.get("collectValue")); |
| | | entity.setCollectHourValue(valueMap.get("collectHourValue")); |
| | | entity.setStartUpTimes(valueMap.get("startUpTimes")); |
| | | entity.setCreateTime(new Date()); |
| | | return entity; |
| | | } |
| | | |
| | | /** |
| | | * getAvgValue |
| | | * |
| | | * @param dataMap |
| | | * @return |
| | | */ |
| | | public BigDecimal getAvgValue (LinkedHashMap<String, BigDecimal> dataMap) { |
| | | BigDecimal avgValue = BigDecimal.ZERO; |
| | | double sumValue = 0d; |
| | | if (!CollectionUtils.isEmpty(dataMap)) { |
| | | int size = dataMap.size(); |
| | | for (Map.Entry<String, BigDecimal> item : dataMap.entrySet()) { |
| | | if (item.getValue() != null && item.getValue().compareTo(BigDecimal.ZERO) > 0) { |
| | | sumValue = sumValue + item.getValue().doubleValue(); |
| | | } |
| | | } |
| | | avgValue = new BigDecimal(sumValue).divide(new BigDecimal(size), 2, BigDecimal.ROUND_HALF_UP); |
| | | } |
| | | return avgValue; |
| | | } |
| | | |
| | | /** |
| | | * getRunHours |
| | | * |
| | | * @param dataMap |
| | | * @return |
| | | */ |
| | | public BigDecimal getRunHours (LinkedHashMap<String, BigDecimal> dataMap) { |
| | | BigDecimal result = BigDecimal.ZERO; |
| | | if (!CollectionUtils.isEmpty(dataMap)) { |
| | | int mins = 0; |
| | | for (Map.Entry<String, BigDecimal> item : dataMap.entrySet()) { |
| | | if (item.getValue() != null && item.getValue().compareTo(BigDecimal.ZERO) > 0) { |
| | | mins++; |
| | | } |
| | | } |
| | | result = new BigDecimal(mins).divide(hourMins, 2, BigDecimal.ROUND_HALF_UP); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * getStartUpTimes |
| | | * |
| | | * @param pointData |
| | | * @return |
| | | */ |
| | | public int getStartUpTimes (List<Map<String, Object>> pointData) { |
| | | int times = 0; |
| | | Boolean lastValue = Boolean.FALSE; |
| | | for (Map<String, Object> item: |
| | | pointData) { |
| | | Boolean itemValue = Boolean.parseBoolean(item.get("value").toString()); |
| | | if (itemValue.compareTo(lastValue) != 0) { |
| | | times++; |
| | | } |
| | | lastValue = itemValue; |
| | | } |
| | | return times; |
| | | } |
| | | |
| | | /** |
| | | * 完善数据 |
| | | * |
| | | * @param length |
| | | * @param sourceDataMap |
| | | * @param startTime |
| | | * @param endTime |
| | | * @return |
| | | */ |
| | | public LinkedHashMap<String, BigDecimal> completionData(int length, LinkedHashMap<String, BigDecimal> sourceDataMap, Date startTime, Date endTime) { |
| | | if (CollectionUtils.isEmpty(sourceDataMap) || length <= sourceDataMap.size()) { |
| | | return sourceDataMap; |
| | | } |
| | | log.info("补全数据, length =" + length + "; size = " + sourceDataMap.size() + "; startTime = " + startTime.getTime() + "; endTime = " + endTime.getTime()); |
| | | |
| | | //找出缺少项 |
| | | long oneMin = 1000 * 60; |
| | | long start = startTime.getTime(); |
| | | long end = endTime.getTime(); |
| | | long mins = ((end - start) / oneMin); |
| | | LinkedHashMap<String, BigDecimal> dataMap = new LinkedHashMap<>(); |
| | | for (int i = 0; i < mins; i ++) { |
| | | String key = DateUtils.format(new Date(start + oneMin * i), ""); |
| | | dataMap.put(key, sourceDataMap.get(key)); |
| | | } |
| | | |
| | | //补充缺少项 |
| | | int k = 0; |
| | | Map.Entry<String, BigDecimal> lastItem = null; |
| | | for (Map.Entry<String, BigDecimal> item : dataMap.entrySet()) { |
| | | if (k == 0 && item.getValue() == null) { |
| | | item.setValue(getFirstValue(dataMap)); |
| | | } else if (item.getValue() == null) { |
| | | item.setValue(lastItem.getValue()); |
| | | } |
| | | k ++; |
| | | lastItem = item; |
| | | } |
| | | log.info("补全完成"); |
| | | return dataMap; |
| | | } |
| | | |
| | | /** |
| | | * getFirstValue |
| | | * |
| | | * @param dataMap |
| | | * @return |
| | | */ |
| | | private BigDecimal getFirstValue(LinkedHashMap<String, BigDecimal> dataMap) { |
| | | for (Map.Entry<String, BigDecimal> item : dataMap.entrySet()) { |
| | | if (item.getValue() != null) { |
| | | return item.getValue(); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.indexdata.controller.admin; |
| | | |
| | | import com.iailab.module.data.common.utils.PageUtils; |
| | | import com.iailab.module.data.common.utils.R; |
| | | import com.iailab.framework.security.core.util.SecurityFrameworkUtils; |
| | | import com.iailab.module.data.indexdata.entity.IndexDataClockEntity; |
| | | import com.iailab.module.data.indexdata.service.IndexDataClockService; |
| | | import javax.annotation.Resource; |
| | | |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年09月08日 21:52:00 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/data/index-data/clock") |
| | | @Tag(name = "数据采集-index-data-clock") |
| | | public class IndexDataClockController { |
| | | |
| | | @Resource |
| | | private IndexDataClockService indexDataClockService; |
| | | |
| | | /** |
| | | * 所有时钟配置列表 |
| | | */ |
| | | @GetMapping("/list") |
| | | @Operation(summary = "查询列表") |
| | | public R list(@RequestParam Map<String, Object> params){ |
| | | PageUtils page = indexDataClockService.queryPage(params); |
| | | return R.ok().put("page", page); |
| | | } |
| | | |
| | | /** |
| | | * 采集点列表(全部) |
| | | */ |
| | | @GetMapping("/list/all") |
| | | public R queryAll(@RequestParam Map<String, Object> params){ |
| | | List<IndexDataClockEntity> data = indexDataClockService.queryList(params); |
| | | return R.ok().put("data", data); |
| | | } |
| | | |
| | | /** |
| | | * 新增时钟配置 |
| | | * |
| | | * @param indexDataClockEntity |
| | | * @return |
| | | */ |
| | | @PostMapping("/add") |
| | | public R add(@RequestBody IndexDataClockEntity indexDataClockEntity) { |
| | | int count = indexDataClockService.cheack(indexDataClockEntity); |
| | | if (count > 0) { |
| | | return R.error("名称或编号重复"); |
| | | } |
| | | indexDataClockEntity.setCreateBy(SecurityFrameworkUtils.getLoginUserId().toString()); |
| | | indexDataClockEntity.setCreateTime(new Date()); |
| | | indexDataClockService.add(indexDataClockEntity); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 更新时钟配置 |
| | | * |
| | | * @param indexDataClockEntity |
| | | * @return |
| | | */ |
| | | @PostMapping("/update") |
| | | public R update(@RequestBody IndexDataClockEntity indexDataClockEntity) { |
| | | int count = indexDataClockService.cheack(indexDataClockEntity); |
| | | if (count > 0) { |
| | | return R.error("名称或编号重复"); |
| | | } |
| | | indexDataClockEntity.setUpdateBy(SecurityFrameworkUtils.getLoginUserId().toString()); |
| | | indexDataClockService.update(indexDataClockEntity); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 删除时钟配置 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @PostMapping("/delete") |
| | | public R delete(@RequestParam Map<String, Object> params) { |
| | | String id = (String)params.get("id"); |
| | | indexDataClockService.deleteById(id); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 时钟配置详情 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @RequestMapping("/info/{id}") |
| | | public R info(@PathVariable("id") String id){ |
| | | IndexDataClockEntity indexDataClockEntity = indexDataClockService.getInfoById(id); |
| | | return R.ok().put("data", indexDataClockEntity); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.indexdata.controller.admin; |
| | | |
| | | import com.iailab.module.data.common.utils.PageUtils; |
| | | import com.iailab.module.data.common.utils.R; |
| | | import com.iailab.framework.security.core.util.SecurityFrameworkUtils; |
| | | import com.iailab.module.data.indexdata.service.IndexDataItemService; |
| | | import com.iailab.module.data.indexdata.entity.IndexDataItemEntity; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.Date; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年09月08日 21:53:00 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/data/index-data/item") |
| | | public class IndexDataItemController { |
| | | @Resource |
| | | private IndexDataItemService indexDataItemService; |
| | | |
| | | /** |
| | | * 所有数据项目列表 |
| | | */ |
| | | @GetMapping("/list") |
| | | public R list(@RequestParam Map<String, Object> params){ |
| | | PageUtils page = indexDataItemService.queryPage(params); |
| | | return R.ok().put("page", page); |
| | | } |
| | | |
| | | /** |
| | | * 新增数据项目 |
| | | * |
| | | * @param enity |
| | | * @return |
| | | */ |
| | | @PostMapping("/add") |
| | | public R add(@RequestBody IndexDataItemEntity enity) { |
| | | enity.setId(null); |
| | | int count = indexDataItemService.cheack(enity); |
| | | if (count > 0) { |
| | | return R.error("名称或编号重复"); |
| | | } |
| | | enity.setCreateBy(SecurityFrameworkUtils.getLoginUserId().toString()); |
| | | enity.setCreateTime(new Date()); |
| | | indexDataItemService.add(enity); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 更新数据项目 |
| | | * |
| | | * @param enity |
| | | * @return |
| | | */ |
| | | @PostMapping("/update") |
| | | public R update(@RequestBody IndexDataItemEntity enity) { |
| | | int count = indexDataItemService.cheack(enity); |
| | | if (count > 0) { |
| | | return R.error("名称或编号重复"); |
| | | } |
| | | enity.setUpdateBy(SecurityFrameworkUtils.getLoginUserId().toString()); |
| | | indexDataItemService.update(enity); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 删除数据项目 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @PostMapping("/delete") |
| | | public R delete(@RequestBody String[] ids) { |
| | | indexDataItemService.deleteBatch(ids); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 数据项目详情 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @RequestMapping("/info/{id}") |
| | | public R info(@PathVariable("id") String id){ |
| | | IndexDataItemEntity enity = indexDataItemService.getInfoById(id); |
| | | return R.ok().put("data", enity); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.indexdata.controller.admin; |
| | | |
| | | import com.iailab.module.data.common.utils.PageUtils; |
| | | import com.iailab.module.data.common.utils.R; |
| | | import com.iailab.module.data.indexdata.service.IndexDataValueService; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年09月08日 21:53:00 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/data/index-data/value") |
| | | public class IndexDataValueController { |
| | | |
| | | @Resource |
| | | private IndexDataValueService indexDataValueService; |
| | | |
| | | /** |
| | | * 所有数据值列表 |
| | | */ |
| | | @GetMapping("/list") |
| | | public R list(@RequestParam Map<String, Object> params){ |
| | | PageUtils page = indexDataValueService.queryPage(params); |
| | | return R.ok().put("page", page); |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.indexdata.controller; |
对比新文件 |
| | |
| | | package com.iailab.module.data.indexdata.dao; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.iailab.module.data.indexdata.entity.IndexDataClockEntity; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年09月08日 21:36:00 |
| | | */ |
| | | @Mapper |
| | | public interface IndexDataClockDao extends BaseMapper<IndexDataClockEntity> { |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.indexdata.dao; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.iailab.module.data.indexdata.entity.IndexDataItemEntity; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年09月08日 21:45:00 |
| | | */ |
| | | @Mapper |
| | | public interface IndexDataItemDao extends BaseMapper<IndexDataItemEntity> { |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.indexdata.dao; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.iailab.module.data.indexdata.entity.IndexDataValueEntity; |
| | | import com.iailab.module.data.indexdata.entity.IndexDataValueEntity; |
| | | import com.iailab.module.data.indexdata.entity.IndexDataValueEntity; |
| | | import com.iailab.module.data.indexdata.entity.IndexDataValueEntity; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年09月08日 21:45:00 |
| | | */ |
| | | @Mapper |
| | | public interface IndexDataValueDao extends BaseMapper<IndexDataValueEntity> { |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.indexdata.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.iailab.framework.excel.core.annotations.DictFormat; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年09月08日 18:26:00 |
| | | */ |
| | | @Data |
| | | @TableName("t_index_data_clock") |
| | | public class IndexDataClockEntity { |
| | | |
| | | /** |
| | | * ID |
| | | */ |
| | | @TableId(type = IdType.ASSIGN_ID) |
| | | private String id; |
| | | |
| | | /** |
| | | * 时钟代码 |
| | | */ |
| | | private String clockCode; |
| | | |
| | | /** |
| | | * 时钟名称 |
| | | */ |
| | | private String clockName; |
| | | |
| | | /** |
| | | * 类别 |
| | | */ |
| | | private String clockType; |
| | | |
| | | /** |
| | | * 类别 |
| | | */ |
| | | @DictFormat("clock-type") |
| | | @TableField(exist = false) |
| | | private String clockTypeName; |
| | | |
| | | /** |
| | | * 描述 |
| | | */ |
| | | private String description; |
| | | |
| | | /** |
| | | * 状态 |
| | | */ |
| | | private Integer status; |
| | | |
| | | /** |
| | | * 状态 |
| | | */ |
| | | @DictFormat("enable") |
| | | @TableField(exist = false) |
| | | private String statusName; |
| | | |
| | | /** |
| | | * 创建人 |
| | | */ |
| | | private String createBy; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * 更新人 |
| | | */ |
| | | private String updateBy; |
| | | |
| | | /** |
| | | * 更新时间 |
| | | */ |
| | | private Date updateTime; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.indexdata.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.iailab.framework.excel.core.annotations.DictFormat; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年09月08日 18:28:00 |
| | | */ |
| | | @Data |
| | | @TableName("t_index_data_item") |
| | | public class IndexDataItemEntity { |
| | | |
| | | /** |
| | | * ID |
| | | */ |
| | | @TableId(type = IdType.ASSIGN_ID) |
| | | private String id; |
| | | |
| | | /** |
| | | * 所属公司 |
| | | */ |
| | | private String unit2; |
| | | |
| | | /** |
| | | * 所属公司 |
| | | */ |
| | | //@Dict(dicCode = "unit2", itemValue = "unit2") |
| | | @TableField(exist = false) |
| | | private String unit2Name; |
| | | |
| | | /** |
| | | * 所属单位 |
| | | */ |
| | | private String ssdw; |
| | | |
| | | /** |
| | | * 所属单位 |
| | | */ |
| | | //@Dict(dicCode = "ssdw", itemValue = "ssdw") |
| | | @TableField(exist = false) |
| | | private String ssdwName; |
| | | |
| | | /** |
| | | * 项目代码 |
| | | */ |
| | | private String itemCode; |
| | | |
| | | /** |
| | | * 项目名称 |
| | | */ |
| | | private String itemName; |
| | | |
| | | /** |
| | | * 点编码 |
| | | */ |
| | | private String pointCode; |
| | | |
| | | /** |
| | | * 点名称 |
| | | */ |
| | | private String pointName; |
| | | |
| | | /** |
| | | * 类别 |
| | | */ |
| | | private String itemType; |
| | | |
| | | /** |
| | | * 类别 |
| | | */ |
| | | @DictFormat("data-item-type") |
| | | @TableField(exist = false) |
| | | private String itemTypeName; |
| | | |
| | | /** |
| | | * 默认值 |
| | | */ |
| | | private BigDecimal defaultValue; |
| | | |
| | | /** |
| | | * 描述 |
| | | */ |
| | | private String description; |
| | | |
| | | /** |
| | | * 单位 |
| | | */ |
| | | private String unit; |
| | | |
| | | /** |
| | | * 配置时间 |
| | | */ |
| | | private String clockConfig; |
| | | |
| | | /** |
| | | * 班次 |
| | | */ |
| | | private String bc; |
| | | |
| | | /** |
| | | * 班次 |
| | | */ |
| | | @DictFormat("bc") |
| | | @TableField(exist = false) |
| | | private String bcName; |
| | | |
| | | /** |
| | | * 系统 |
| | | */ |
| | | private String xtCode; |
| | | |
| | | /** |
| | | * 系统 |
| | | */ |
| | | @DictFormat("scxt") |
| | | @TableField(exist = false) |
| | | private String xtName; |
| | | |
| | | /** |
| | | * 拓展字段1 |
| | | */ |
| | | private String ext1; |
| | | |
| | | /** |
| | | * 拓展字段2 |
| | | */ |
| | | private String ext2; |
| | | |
| | | /** |
| | | * 拓展字段3 |
| | | */ |
| | | private String ext3; |
| | | |
| | | /** |
| | | * 拓展字段4 |
| | | */ |
| | | private String ext4; |
| | | |
| | | /** |
| | | * 拓展字段5 |
| | | */ |
| | | private String ext5; |
| | | |
| | | /** |
| | | * 状态 |
| | | */ |
| | | private Integer status; |
| | | |
| | | /** |
| | | * 状态 |
| | | */ |
| | | @DictFormat("enable") |
| | | @TableField(exist = false) |
| | | private String statusName; |
| | | |
| | | /** |
| | | * 创建人 |
| | | */ |
| | | private String createBy; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * 更新人 |
| | | */ |
| | | private String updateBy; |
| | | |
| | | /** |
| | | * 更新时间 |
| | | */ |
| | | private Date updateTime; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.data.indexdata.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.iailab.framework.excel.core.annotations.DictFormat; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2022年09月08日 18:30:00 |
| | | */ |
| | | @Data |
| | | @TableName("t_index_data_value") |
| | | public class IndexDataValueEntity { |
| | | |
| | | /** |
| | | * ID |
| | | */ |
| | | @TableId(type = IdType.ASSIGN_ID) |
| | | private String id; |
| | | |
| | | /** |
| | | * 配置ID |
| | | */ |
| | | private String configId; |
| | | |
| | | /** |
| | | * 所属公司 |
| | | */ |
| | | private String unit2; |
| | | |
| | | /** |
| | | * 所属公司 |
| | | */ |
| | | @DictFormat("unit2") |
| | | @TableField(exist = false) |
| | | private String unit2Name; |
| | | |
| | | /** |
| | | * 所属单位 |
| | | */ |
| | | private String ssdw; |
| | | |
| | | /** |
| | | * 所属单位 |
| | | */ |
| | | @DictFormat("ssdw") |
| | | @TableField(exist = false) |
| | | private String ssdwName; |
| | | |
| | | /** |
| | | * 项目代码 |
| | | */ |
| | | private String itemCode; |
| | | |
| | | /** |
| | | * 项目名称 |
| | | */ |
| | | private String itemName; |
| | | |
| | | /** |
| | | * 单位 |
| | | */ |
| | | private String unit; |
| | | |
| | | /** |
| | | * 时间 |
| | | */ |
| | | private String clock; |
| | | |
| | | /** |
| | | * 累计值 |
| | | */ |
| | | private BigDecimal sumValue; |
| | | |
| | | /** |
| | | * 平均值 |
| | | */ |
| | | private BigDecimal avgValue; |
| | | |
| | | /** |
| | | * 上报值 |
| | | */ |
| | | private BigDecimal reportValue; |
| | | |
| | | /** |
| | | * 上报小时值 |
| | | */ |
| | | private BigDecimal reportHourValue; |
| | | |
| | | /** |
| | | * 采集值 |
| | | */ |
| | | private BigDecimal collectValue; |
| | | |
| | | /** |
| | | * 采集小时值 |
| | | */ |
| | | private BigDecimal collectHourValue; |
| | | |
| | | /** |
| | | * 启动次数 |
| | | */ |
| | | private BigDecimal startUpTimes; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * 更新时间 |
| | | */ |
| | | private Date updateTime; |
| | | } |
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/service/IndexDataClockService.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/service/IndexDataItemService.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/service/IndexDataValueService.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/service/impl/IndexDataClockServiceImpl.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/service/impl/IndexDataItemServiceImpl.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/indexdata/service/impl/IndexDataValueServiceImpl.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/common/config/InfluxDBInstance.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/common/enums/DataMeasurement.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/common/utils/PointValueUtils.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/common/utils/TagValueUtils.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxPointValueBoolPOJO.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxPointValueDigPOJO.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxPointValuePOJO.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxPointValueSimPOJO.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxPointValueStrPOJO.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxTagValueBoolPOJO.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxTagValueFloatPOJO.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxTagValueIntPOJO.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxTagValuePOJO.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/pojo/InfluxTagValueStrPOJO.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/service/InfluxDBService.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/service/impl/InfluxDBServiceImpl.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/config/ScheduleConfig.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/controller/admin/ScheduleJobController.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/controller/admin/ScheduleJobLogController.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/controller/package-info.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/dao/ScheduleJobDao.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/dao/ScheduleJobLogDao.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/dto/ScheduleJobDTO.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/dto/ScheduleJobLogDTO.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/entity/ScheduleJobEntity.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/entity/ScheduleJobLogEntity.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/init/JobCommandLineRunner.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/service/ScheduleJobLogService.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/service/ScheduleJobService.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/service/impl/ScheduleJobLogServiceImpl.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/service/impl/ScheduleJobServiceImpl.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/HttpCollectDeviceTask.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/HttpCollectHealthStateTask.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/HttpCollectRunStateTask.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/HttpCollectTemperatureTask.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/HttpCollectUserTask.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/HttpTokenTask.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/ITask.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/PointCollectTaskNet10.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/PointCollectTaskNet30.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/PointCollectTaskNet60.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/PointCollectTaskNetKIO10.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/PointCollectTaskNetKIO60.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/TestTask.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/utils/ScheduleJob.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/utils/ScheduleUtils.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/PointCollector.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/CalculateHandle.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/ConstantHandle.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/MeasureHandle.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/utils/GenInfluxPointValueUtils.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/IncreaseCodeEnum.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/ItemTypeEnum.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/PointDataTypeEnum.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/PointDataTypeUtils.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/PointTypeEnum.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/common/StoreTypeEnum.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/controller/admin/DaPointController.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dao/DaMathPointDao.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dao/DaMeasurePointDao.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dao/DaPointDao.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dao/DaPointValueDao.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dao/DaSequenceNumDao.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dto/DaMathPointDTO.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dto/DaMeasurePointDTO.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dto/DaPointDTO.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dto/DaPointMeasureDTO.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dto/DaPointValueDTO.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/dto/DaPointWriteValueDTO.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/entity/DaMathPointEntity.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/entity/DaMeasurePointEntity.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/entity/DaPointEntity.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/entity/DaPointValueEntity.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/entity/DaSequenceNumEntity.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaMathPointService.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaMeasurePointService.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaPointService.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaPointValueService.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/DaSequenceNumService.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaMathPointServiceImpl.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaMeasurePointServiceImpl.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointServiceImpl.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointValueServiceImpl.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaSequenceNumServiceImpl.java
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/package-info.java
iailab-module-data/iailab-module-data-biz/src/main/resources/application-dev.yml
iailab-module-data/iailab-module-data-biz/src/main/resources/application-local.yml
iailab-module-data/iailab-module-data-biz/src/main/resources/application-prod.yml
iailab-module-data/iailab-module-data-biz/src/main/resources/application-test.yml
iailab-module-data/iailab-module-data-biz/src/main/resources/application-uat.yml
iailab-module-data/iailab-module-data-biz/src/main/resources/application.yml
iailab-module-data/iailab-module-data-biz/src/main/resources/banner.txt
iailab-module-data/iailab-module-data-biz/src/main/resources/logback-spring.xml
iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/da/DaPointDao.xml
iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/gateway/ApiAuthorizedDao.xml
iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/gateway/ApiInfoDao.xml
iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/http/HttpTagDao.xml
iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/ind/IndItemDao.xml
iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/ind/IndItemValueDao.xml
iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/job/ScheduleJobDao.xml
iailab-module-data/iailab-module-data-biz/src/main/resources/mapper/job/ScheduleJobLogDao.xml
iailab-module-data/iailab-module-data-biz/src/main/resources/导入模板/ModBus.xlsx
iailab-module-data/iailab-module-data-biz/src/main/resources/导入模板/OpcUa.xlsx
iailab-module-data/iailab-module-data-biz/src/test/java/com/iailab/InfluxDBTest.java
iailab-module-data/iailab-module-data-biz/src/test/java/com/iailab/OadpTagCollectorTest.java
iailab-module-infra/iailab-module-infra-api/src/main/java/com/iailab/module/infra/api/config/ConfigApi.java
iailab-module-infra/iailab-module-infra-biz/src/main/java/com/iailab/module/infra/api/config/ConfigApiImpl.java
iailab-module-model/iailab-module-model-api/pom.xml
iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/api/IFeignModelApi.java
iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/api/IFeignProddispApi.java
iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignConsumeTargetDTO.java
iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignHourVolumeDTO.java
iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignMcMzDTO.java
iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignPowerConsumeDTO.java
iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignRunTimeDTO.java
iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignWarehouseItemDTO.java
iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignWarehousePositionDTO.java
iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignWarehouseStockDTO.java
iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignWashProdVolumeDTO.java
iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignWashToWashDTO.java
iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/dto/FeignWashTransferInDTO.java
iailab-module-model/iailab-module-model-biz/pom.xml
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/ModelServiceApplication.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/annotation/DataFilter.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/annotation/LogOperation.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/aspect/DictAspect.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/config/MybatisPlusConfig.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/constant/BusinessConstant.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/dto/IndexQueryDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/dto/IndexStatisticDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/dto/echarts/BarLineDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/dto/echarts/SeriesItem.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/dto/vue/CascaderOptionDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/CdbmEnum.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/CommonConstant.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/DataAshType.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/DataTypeEnum.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/HttpMethodEnum.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/IsEnableEnum.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/ModelTypeEnum.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/PostalStatus.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/SourceTypeEnum.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/SuperAdminEnum.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/enums/WatchDogStsEnum.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/exception/RRException.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/interceptor/DataFilterInterceptor.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/interceptor/DataScope.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/CommonUtils.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/Constant.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/DateUtils.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/ExcelUtil.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/ExcelUtils.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/HttpRequest.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/HttpsRequest.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/MatlabUtil.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/PythonUtil.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/SSLClient.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/common/utils/UnzipUtils.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/controller/AnyController.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/controller/AnyProcCardController.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/controller/AnyProcReportController.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dao/AnyProcCardDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dao/AnyProcParamDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dao/AnyProcReportDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dao/AnyProcReportDetDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dao/AnySugLibDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dto/AnyAllEvaluationDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dto/AnyProcCardDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dto/AnyProcParamDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dto/AnyProcReportDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dto/AnyProcReportDetDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dto/AnyStoreReliabilityDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dto/AnySugLibDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/dto/AnyTrendResultDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/entity/AnyProcCardEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/entity/AnyProcParamEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/entity/AnyProcReportDetEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/entity/AnyProcReportEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/entity/AnySugLibEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/AnyProcCardService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/AnyProcParamService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/AnyProcReportDetService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/AnyProcReportService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/AnySugLibService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/impl/AnyProcCardServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/impl/AnyProcParamServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/impl/AnyProcReportDetServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/impl/AnyProcReportServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/any/service/impl/AnySugLibServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/cons/dao/ConsDayDataDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/cons/dto/ConsDayDataDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/cons/entity/ConsDayDataEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/cons/service/ConsDayDataService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/cons/service/impl/ConsDayDataServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/commons/HealthIndexTypeEnum.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/commons/HealthLevelEnum.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceAbnormalHistoryController.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceAccountController.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceAccountHistoryController.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceFaultController.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceHealthAlarmController.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceHealthEvaluateController.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceHealthReportController.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceHealthStateController.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceInfoController.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceRunStateController.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/controller/DeviceStatNewnessController.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceAbnormalHistoryDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceAccountDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceAccountHistoryDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceEvaluateIndexDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceFaultDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceHealthAlarmDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceHealthAlarmDetailDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceHealthEvaluateDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceHealthReportDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceHealthReportDataDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceHealthStateDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceIndexDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceInfoDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceMainDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceRunStateDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceStatCountDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceStatNewnessDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dao/DeviceStatUsageDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceAbnormalHistoryDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceAccountDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceAccountHistoryDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceCurrentRateDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceEvaluateIndexDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceFaultDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceHealthAlarmDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceHealthAlarmDetailDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceHealthEvaluateDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceHealthReportDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceHealthReportDataDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceHealthStateDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceIndexDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceInfoDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceListJsonDto.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceMainDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceRunStateDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceStatCountDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/dto/DeviceStatNewnessDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceAbnormalHistoryEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceAccountEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceAccountHistoryEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceEvaluateIndexEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceFaultEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceFaultHistoryEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceHealthAlarmDetailEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceHealthAlarmEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceHealthEvaluateEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceHealthReportDataEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceHealthReportEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceHealthStateEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceIndexEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceInfoEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceMainEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceRunStateEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceStatCountEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceStatNewnessEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/entity/DeviceStatUsageEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/excel/DeviceAbnormalHistoryExcel.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/excel/DeviceAccountExcel.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/excel/DeviceAccountHistoryExcel.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/excel/DeviceFaultExcel.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/excel/DeviceHealthStateExcel.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/excel/DeviceInfoExcel.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/excel/DeviceRunStateExcel.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceAbnormalHistoryService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceAccountHistoryService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceAccountService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceEvaluateIndexService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceFaultService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceHealthAlarmDetailService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceHealthAlarmService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceHealthEvaluateService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceHealthReportDataService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceHealthReportService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceHealthStateService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceIndexService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceInfoService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceMainService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceRunStateService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceStatCountService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceStatNewnessService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/DeviceStatUsageService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceAbnormalHistoryServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceAccountHistoryServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceAccountServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceEvaluateIndexServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceFaultServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceHealthAlarmDetailServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceHealthAlarmServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceHealthEvaluateServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceHealthReportDataServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceHealthReportServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceHealthStateServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceIndexServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceInfoServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceMainServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceRunStateServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceStatCountServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceStatNewnessServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/device/service/impl/DeviceStatUsageServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/event/dao/EventInfoDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/event/dto/EventInfoDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/event/entity/EventInfoEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/event/service/EventInfoService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/event/service/impl/EventInfoServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/event/ws/EventWebSocketClient.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/event/ws/EventWsBean.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/event/ws/ReconnectThreadEnum.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/feign/FeignModelImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/framework/package-info.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/framework/rpc/config/RpcConfiguration.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/framework/rpc/package-info.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/framework/security/config/SecurityConfiguration.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/framework/security/core/package-info.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/config/ScheduleConfig.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/controller/ScheduleJobController.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/controller/ScheduleJobLogController.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/dao/ScheduleJobDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/dao/ScheduleJobLogDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/dto/ScheduleJobDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/dto/ScheduleJobLogDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/entity/ScheduleJobEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/entity/ScheduleJobLogEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/init/JobCommandLineRunner.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/service/ScheduleJobLogService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/service/ScheduleJobService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/service/impl/ScheduleJobLogServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/service/impl/ScheduleJobServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/AnyProc1Task.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/AnyProc2Task.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/AnyProc3Task.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/AnyProc4Task.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/AnyProc5Task.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/AnyProc6Task.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/AnyProc7Task.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/DeviceHealthTask.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/FakeDataTask.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ITask.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/MigrationTableDataTask.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelAllEvaluationTask.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelBlowerTask.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelControlReliabilityTask.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelQCThickenerTask.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelSeparationTask.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelShallowTask.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelStorageReliabilityTask.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelWarehouseTask.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelXLFilterTask.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/ModelXLThickenerTask.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncConsDayDataTask.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncDeviceInfoTask.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncDeviceStatUsageTask.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncPrdCurrentSaleTask.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncPrdDayDutyTask.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncPrdDayProdTask.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncPrdPerformanceTask.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncPrdPlanTask.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncPrdStorageDayTask.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncPrdTimeDayTask.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/SyncQualityTrendDayTask.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchControllerOn1Task.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchControllerOn2Task.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchControllerOn3Task.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchControllerOn4Task.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchControllerOn5Task.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchControllerOn6Task.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchControllerOn7Task.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchDogZX1Task.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/task/WatchDogZX2Task.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/utils/ScheduleJob.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/job/utils/ScheduleUtils.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/controller/KnowledgeDetController.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/controller/KnowledgePathController.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/dao/KnowledgeDetDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/dao/KnowledgePathDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/dto/KnowledgeDetDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/dto/KnowledgePathDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/entity/KnowledgeDetEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/entity/KnowledgePathEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/service/KnowledgeDetService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/service/KnowledgePathService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/service/impl/KnowledgeDetServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/knowledge/service/impl/KnowledgePathServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/controller/admin/StModelController.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/controller/admin/StModelDocController.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/controller/admin/StModelRequestLogController.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/controller/admin/StModelRunlogController.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/controller/package-info.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dao/StModelDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dao/StModelDocDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dao/StModelOutDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dao/StModelParamDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dao/StModelRequestLogDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dao/StModelResultDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dao/StModelRunlogDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dao/StModelSettingDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/RelationLineDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/RelationNodeDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/StModelDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/StModelDocDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/StModelOutDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/StModelParamDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/StModelRequestLogDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/StModelResultDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/StModelRunlogDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/dto/StModelSettingDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/entity/StModelDocEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/entity/StModelEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/entity/StModelOutEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/entity/StModelParamEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/entity/StModelRequestLogEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/entity/StModelRunlogEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/entity/StModelSettingEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/excel/StModelRunlogExcel.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/StModelDocService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/StModelOutService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/StModelParamService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/StModelRequestLogService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/StModelResultService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/StModelRunlogService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/StModelService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/StModelSettingService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/impl/StModelDocServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/impl/StModelOutServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/impl/StModelParamServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/impl/StModelRequestLogServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/impl/StModelResultServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/impl/StModelRunlogServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/impl/StModelServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/mcs/service/impl/StModelSettingServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/IAILModel.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/ApiModelController.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/command/MLCommand.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/command/PyCommand.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/dto/RunSetDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/entity/ModelEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/enums/ModelResultEnum.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/handler/ModelHandler.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/constructor/SampleConstructor.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/constructor/SampleDataConstructor.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/constructor/SampleInfoConstructor.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/dto/ColumnItem.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/dto/ColumnItemPort.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/dto/DataValue.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/dto/SampleData.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/dto/SampleInfo.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/sample/entity/DataEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/utils/DcsUtils.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/oss/controller/OssFileController.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/oss/dao/OssFileDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/oss/dto/OssFileDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/oss/entity/OssFileEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/oss/service/OssFileService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/oss/service/impl/OssFileServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/package-info.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/controller/PageParamController.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/dao/PageParamDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/dto/PageParamDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/dto/PageParamResultValueDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/dto/PointDataValueDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/dto/ResultPointAndTrendDataDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/entity/PageParamEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/service/PageParmService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/param/service/impl/PageParamServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/controller/IndexEvaluateSystemController.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/controller/PageCharsController.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/controller/StoreDependableAnalysisController.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/IndexEvaluateSystemDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/PrdCurrentPerformanceDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/PrdCurrentSaleDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/PrdDayDutyDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/PrdDayProdDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/PrdPlanMonDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/PrdPlanYearDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/PrdTimeDayDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dao/StorageDayDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/IndexEvaluateSystemDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/PageCharsDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/PrdCurrentPerformanceDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/PrdCurrentSaleDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/PrdDayDutyDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/PrdDayProdDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/PrdPlanMonDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/PrdPlanYearDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/dto/StorageDayDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/IndexEvaluateSystemEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/PrdCurrentPerformanceEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/PrdCurrentSaleEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/PrdDayDutyEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/PrdDayProdEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/PrdPlanMonEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/PrdPlanYearEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/PrdTimeDayEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/entity/StorageDayEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/IndexEvaluateSystemService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/PageCharsService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/PrdCurrentPerformanceService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/PrdCurrentSaleService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/PrdDayDutyService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/PrdDayProdService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/PrdPlanMonService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/PrdPlanYearService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/PrdTimeDayService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/StorageDayService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/IndexEvaluateSystemServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/PageCharsServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/PrdCurrentPerformanceServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/PrdCurrentSaleServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/PrdDayDutyServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/PrdDayProdServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/PrdPlanMonServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/PrdPlanYearServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/PrdTimeDayServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/prod/service/impl/StorageDayServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/quality/dao/QualityQualityTrendDayDao.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/quality/dto/QualityQualityTrendDayDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/quality/entity/QualityQualityTrendDayEntity.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/quality/service/QualityQualityTrendDayService.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/quality/service/impl/QualityQualityTrendDayServiceImpl.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/watch/WatchConstant.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/watch/WatchDog.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/websocket/api/dto/ApiMsgDTO.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/websocket/config/ServerEncoder.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/websocket/config/WebSocketConfig.java
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/websocket/server/WebSocketServer.java
iailab-module-model/iailab-module-model-biz/src/main/resources/application-dev.yml
iailab-module-model/iailab-module-model-biz/src/main/resources/application-local.yml
iailab-module-model/iailab-module-model-biz/src/main/resources/application-prod.yml
iailab-module-model/iailab-module-model-biz/src/main/resources/application-test.yml
iailab-module-model/iailab-module-model-biz/src/main/resources/application-uat.yml
iailab-module-model/iailab-module-model-biz/src/main/resources/application.yml
iailab-module-model/iailab-module-model-biz/src/main/resources/banner.txt
iailab-module-model/iailab-module-model-biz/src/main/resources/logback-spring.xml
iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceAbnormalHistoryDao.xml
iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceAccountDao.xml
iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceAccountHistoryDao.xml
iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceFaultDao.xml
iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceHealthAlarmDao.xml
iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceHealthStateDao.xml
iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceInfoDao.xml
iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceRunStateDao.xml
iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceStatCountDao.xml
iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceStatNewnessDao.xml
iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/device/DeviceStatUsageDao.xml
iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/job/ScheduleJobDao.xml
iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/job/ScheduleJobLogDao.xml
iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/knowledge/KnowledgePathDao.xml
iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/StModelDao.xml
iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/StModelOutDao.xml
iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/StModelParamDao.xml
iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/StModelResultDao.xml
iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/StModelRunlogDao.xml
iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/StModelSettingDao.xml
iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/report/AnyProcReportDao.xml
iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/report/AnyProcReportDetDao.xml
iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/report/DeviceHealthReportDao.xml
iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/report/DeviceHealthReportDataDao.xml
iailab-module-model/iailab-module-model-biz/src/test/java/com/iailab/InfluxDBTest.java
iailab-module-model/iailab-module-model-biz/src/test/java/com/iailab/OadpTagCollectorTest.java
iailab-module-model/pom.xml
iailab-module-system/iailab-module-system-api/src/main/java/com/iailab/module/system/api/params/ParamsApi.java
iailab-module-system/iailab-module-system-api/src/main/java/com/iailab/module/system/api/permission/dto/RoleDTO.java
iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/service/params/ParamsService.java
iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/service/params/ParamsServiceImpl.java |