560 lines
18 KiB
Dart
560 lines
18 KiB
Dart
import 'dart:io';
|
||
|
||
import 'package:dio/dio.dart';
|
||
import 'package:qhd_prevention/tools/tools.dart';
|
||
|
||
import 'HttpManager.dart';
|
||
|
||
class ApiService {
|
||
// static const String basePath = "http://192.168.0.25:28199/";
|
||
// static const String basePath = "http://192.168.20.240:8500/integrated_whb";
|
||
// static const String baseFacePath = "http://192.168.0.25:38199/";
|
||
// 人脸识别服务
|
||
// static const String baseFacePath = "https://qaaqwh.qhdsafety.com/whb_stu_face/";
|
||
|
||
// static const String basePath = "https://qaaqwh.qhdsafety.com/integrated_whb/";
|
||
// static const String baseImgPath = "https://file.zcloudchina.com/YTHFile";
|
||
// static const String adminPath = "https://qaaqwh.qhdsafety.com/integrated_whb/";
|
||
// static const String projectManagerUrl = 'https://pm.qhdsafety.com/zy-projectManage/';
|
||
// static const String publicKey = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDUoHAavCikaZxjlDM6Km8cX+ye78F4oF39AcEfnE1p2Yn9pJ9WFxYZ4Vkh6F8SKMi7k4nYsKceqB1RwG996SvHQ5C3pM3nbXCP4K15ad6QhN4a7lzlbLhiJcyIKszvvK8ncUDw8mVQ0j/2mwxv05yH6LN9OKU6Hzm1ninpWeE+awIDAQAB'
|
||
/// 人脸识别服务
|
||
static const String baseFacePath =
|
||
"https://qaaqwh.qhdsafety.com/whb_stu_face/";
|
||
|
||
/// 登录及其他管理后台接口
|
||
static const String basePath = "https://qaaqwh.qhdsafety.com/integrated_whb";
|
||
|
||
/// 图片文件服务
|
||
static const String baseImgPath = "https://file.zcloudchina.com/YTHFile";
|
||
|
||
/// 管理后台统一路径
|
||
static const String adminPath =
|
||
"https://qaaqwh.qhdsafety.com/integrated_whb/";
|
||
|
||
/// 项目管理系统
|
||
static const String projectManagerUrl =
|
||
'https://pm.qhdsafety.com/zy-projectManage';
|
||
|
||
/// RSA 公钥
|
||
static const publicKey = '''
|
||
-----BEGIN PUBLIC KEY-----
|
||
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDUoHAavCikaZxjlDM6Km8cX+ye
|
||
78F4oF39AcEfnE1p2Yn9pJ9WFxYZ4Vkh6F8SKMi7k4nYsKceqB1RwG996SvHQ5C3p
|
||
M3nbXCP4K15ad6QhN4a7lzlbLhiJcyIKszvvK8ncUDw8mVQ0j/2mwxv05yH6LN9OK
|
||
U6Hzm1ninpWeE+awIDAQAB
|
||
-----END PUBLIC KEY-----
|
||
''';
|
||
|
||
/// 登录验证接口
|
||
static Future<Map<String, dynamic>> loginCheck(String keydataVal) {
|
||
return HttpManager().request(
|
||
basePath,
|
||
'/admin/check',
|
||
method: Method.post,
|
||
data: {
|
||
'KEYDATA': keydataVal,
|
||
'SOURCE': '2',
|
||
'tm': DateTime.now().millisecondsSinceEpoch.toString(),
|
||
},
|
||
);
|
||
}
|
||
|
||
/// TODO -------------–-------------------- 首页 -------------–--------------------
|
||
/// 我的工作
|
||
static Future<Map<String, dynamic>> getWork() {
|
||
return HttpManager().request(
|
||
basePath,
|
||
'/app/hidden/getCountByUserId',
|
||
method: Method.post,
|
||
data: {
|
||
'userId': SessionService.instance.loginUserId,
|
||
'USER_NAME': SessionService.instance.username,
|
||
'CHECK_DEPARTMENT_ID': SessionService.instance.deptId,
|
||
'IS_MAIN': SessionService.instance.isRest,
|
||
'CORPINFO_ID': SessionService.instance.corpinfoId,
|
||
'USER_ID': SessionService.instance.loginUserId,
|
||
},
|
||
);
|
||
}
|
||
|
||
/// 特殊作业红点数量
|
||
static Future<Map<String, dynamic>> getRedPoint() {
|
||
return HttpManager().request(
|
||
basePath,
|
||
'/app/eightwork/checkWork',
|
||
method: Method.post,
|
||
data: {'USER_ID': SessionService.instance.loginUserId},
|
||
);
|
||
}
|
||
|
||
///
|
||
static Future<Map<String, dynamic>> getUserData() {
|
||
return HttpManager().request(
|
||
basePath,
|
||
'/app/hidden/getUserIndexData',
|
||
method: Method.post,
|
||
data: {
|
||
'userId': SessionService.instance.loginUserId,
|
||
'USER_NAME': SessionService.instance.username,
|
||
'CHECK_DEPARTMENT_ID': SessionService.instance.deptId,
|
||
'IS_MAIN': SessionService.instance.isRest,
|
||
'CORPINFO_ID': SessionService.instance.corpinfoId,
|
||
'USER_ID': SessionService.instance.loginUserId,
|
||
},
|
||
);
|
||
}
|
||
/// 安全检查
|
||
static Future<Map<String, dynamic>> getSafetyEnvironmentalInspectionCount() {
|
||
return HttpManager().request(
|
||
basePath,
|
||
'/app/safetyenvironmental/countCheck',
|
||
method: Method.post,
|
||
data: {
|
||
'CORPINFO_ID': SessionService.instance.corpinfoId,
|
||
'INSPECTION_USER_ID': SessionService.instance.loginUserId,
|
||
'INSPECTED_SITEUSER_ID': SessionService.instance.loginUserId,
|
||
'INSPECTION_ORIGINATOR_ID': SessionService.instance.loginUserId,
|
||
'tm': DateTime.now().millisecondsSinceEpoch.toString(),
|
||
},
|
||
);
|
||
}
|
||
|
||
static Future<Map<String, dynamic>> getUpdateInfo() {
|
||
return HttpManager().request(
|
||
projectManagerUrl,
|
||
'/projectDetails/findUpdate?code=cloud&type=APP',
|
||
method: Method.post,
|
||
data: {},
|
||
);
|
||
}
|
||
|
||
static Future<Map<String, dynamic>> getDeptData() {
|
||
return HttpManager().request(
|
||
basePath,
|
||
'/app/hidden/getDeptIndexData',
|
||
method: Method.post,
|
||
data: {
|
||
'userId': SessionService.instance.loginUserId,
|
||
'USER_NAME': SessionService.instance.username,
|
||
'DEPARTMENT_ID': SessionService.instance.deptId,
|
||
'IS_MAIN': SessionService.instance.isRest,
|
||
'CORPINFO_ID': SessionService.instance.corpinfoId,
|
||
'USER_ID': SessionService.instance.loginUserId,
|
||
},
|
||
);
|
||
}
|
||
|
||
/// 月隐患 1 月隐患,2年隐患
|
||
static Future<Map<String, dynamic>> getDanger(int type) {
|
||
return HttpManager().request(
|
||
basePath,
|
||
'/app/hidden/getIndexCount',
|
||
method: Method.post,
|
||
data: {
|
||
'userId': SessionService.instance.loginUserId,
|
||
'CORPINFO_ID': SessionService.instance.corpinfoId,
|
||
(type == 1 ? 'IS_MONTH' : 'IS_YEAR'): '1',
|
||
'USER_ID': SessionService.instance.loginUserId,
|
||
},
|
||
);
|
||
}
|
||
|
||
static Future<Map<String, dynamic>> getSurveyData() {
|
||
return HttpManager().request(
|
||
basePath,
|
||
'/app/survey/goEdit',
|
||
method: Method.post,
|
||
data: {
|
||
'CORPINFO_ID': SessionService.instance.corpinfoId,
|
||
'USER_ID': SessionService.instance.loginUserId,
|
||
},
|
||
);
|
||
}
|
||
|
||
static Future<Map<String, dynamic>> getUserId() {
|
||
return HttpManager().request(
|
||
basePath,
|
||
'/app/surveyanswer/getUserId',
|
||
method: Method.post,
|
||
data: {
|
||
'CORPINFO_ID': SessionService.instance.corpinfoId,
|
||
'USER_ID': SessionService.instance.loginUserId,
|
||
},
|
||
);
|
||
}
|
||
/// 获取清单数量
|
||
static Future<Map<String, dynamic>> getListData() {
|
||
return HttpManager().request(
|
||
basePath,
|
||
'/app/listmanager/checkList',
|
||
method: Method.post,
|
||
data: {
|
||
'userId': SessionService.instance.loginUserId,
|
||
'USER_NAME': SessionService.instance.username,
|
||
'CHECK_DEPARTMENT_ID': SessionService.instance.deptId,
|
||
'IS_MAIN': SessionService.instance.isRest,
|
||
'CORPINFO_ID': SessionService.instance.corpinfoId,
|
||
'USER_ID': SessionService.instance.loginUserId,
|
||
},
|
||
);
|
||
}
|
||
/// 获取滚动隐患
|
||
static Future<Map<String, dynamic>> getHiddenRoll() {
|
||
return HttpManager().request(
|
||
basePath,
|
||
'/app/hidden/getHiddenByCorp',
|
||
method: Method.post,
|
||
data: {
|
||
'CORPINFO_ID': SessionService.instance.corpinfoId,
|
||
'HIDDENLEVEL': 'hiddenLevel0001',
|
||
},
|
||
);
|
||
}
|
||
|
||
static Future<Map<String, dynamic>> getIsRest() {
|
||
return HttpManager().request(
|
||
basePath,
|
||
'/app/hidden/getHiddenByCorp',
|
||
method: Method.post,
|
||
data: {
|
||
'CORPINFO_ID': SessionService.instance.corpinfoId,
|
||
'USER_ID': SessionService.instance.loginUserId,
|
||
},
|
||
);
|
||
}
|
||
/// TODO -------------–-------------------- 首页学习园地 -------------–--------------------
|
||
/// 我的任务列表
|
||
static Future<Map<String, dynamic>> getStudyList(int page) {
|
||
return HttpManager().request(
|
||
basePath,
|
||
'/app/edu/stagestudentrelation/pageTaskByUser',
|
||
method: Method.post,
|
||
data: {
|
||
'CORPINFO_ID': SessionService.instance.corpinfoId,
|
||
'USER_ID': SessionService.instance.loginUserId,
|
||
'showCount':10,
|
||
'currentPage':page
|
||
},
|
||
);
|
||
}
|
||
/// 课程列表
|
||
static Future<Map<String, dynamic>> getClassList(String classId, String POST_ID) {
|
||
return HttpManager().request(
|
||
basePath,
|
||
'/app/edu/stagestudentrelation/getClassCurriculum',
|
||
method: Method.post,
|
||
data: {
|
||
'CORPINFO_ID': SessionService.instance.corpinfoId,
|
||
'USER_ID': SessionService.instance.loginUserId,
|
||
'showCount':9999,
|
||
'currentPage':1,
|
||
'CLASS_ID' : classId,
|
||
'POST_ID' : POST_ID
|
||
},
|
||
);
|
||
}
|
||
/// 学习详情视频列表
|
||
static Future<Map<String, dynamic>> getStudyDetailList(String CLASS_ID, String CLASSCURRICULUM_ID, String STUDENT_ID) {
|
||
print(CLASS_ID + '---' + CLASSCURRICULUM_ID + '---' + STUDENT_ID+ '---' + SessionService.instance.corpinfoId! + '---' + SessionService.instance.loginUserId!);
|
||
return HttpManager().request(
|
||
basePath,
|
||
'/app/edu/stagestudentrelation/getMyTask',
|
||
method: Method.post,
|
||
data: {
|
||
'CLASSCURRICULUM_ID': CLASSCURRICULUM_ID,
|
||
'CLASS_ID' : CLASS_ID,
|
||
'STUDENT_ID':STUDENT_ID,
|
||
'CORPINFO_ID': SessionService.instance.corpinfoId,
|
||
'USER_ID': SessionService.instance.loginUserId,
|
||
|
||
},
|
||
);
|
||
}
|
||
static Future<Map<String, dynamic>> fnGetVideoPlayInfo(String VIDEOCOURSEWARE_ID) {
|
||
return HttpManager().request(
|
||
basePath,
|
||
'/app/edu/audioOrVideo/getVideoPlayInfoApp',
|
||
method: Method.post,
|
||
data: {
|
||
'VIDEOCOURSEWARE_ID': VIDEOCOURSEWARE_ID,
|
||
'CORPINFO_ID': SessionService.instance.corpinfoId,
|
||
'USER_ID': SessionService.instance.loginUserId,
|
||
|
||
},
|
||
);
|
||
}
|
||
static Future<Map<String, dynamic>> fnSetUserFaceTime(String FACE_TIME) {
|
||
return HttpManager().request(
|
||
baseFacePath,
|
||
'/app/user/setUserFaceTime',
|
||
method: Method.post,
|
||
data: {
|
||
'loading':false,
|
||
'FACE_TIME': FACE_TIME,
|
||
'CORPINFO_ID': SessionService.instance.corpinfoId,
|
||
'USER_ID': SessionService.instance.loginUserId,
|
||
|
||
},
|
||
);
|
||
}
|
||
static Future<Map<String, dynamic>> fnGetVideoPlayProgress(String VIDEOCOURSEWARE_ID, String CURRICULUM_ID, String CLASS_ID, String STUDENT_ID) {
|
||
return HttpManager().request(
|
||
basePath,
|
||
'/app/edu/coursestudyvideorecord/getVideoProgress',
|
||
method: Method.post,
|
||
data: {
|
||
'VIDEOCOURSEWARE_ID': VIDEOCOURSEWARE_ID,
|
||
'CURRICULUM_ID' : CURRICULUM_ID,
|
||
'CLASS_ID':CLASS_ID,
|
||
'STUDENT_ID':STUDENT_ID,
|
||
'CORPINFO_ID': SessionService.instance.corpinfoId,
|
||
'USER_ID': SessionService.instance.loginUserId,
|
||
|
||
},
|
||
);
|
||
}
|
||
/// 上报播放进度或结束
|
||
static Future<Map<String, dynamic>> fnSubmitPlayTime(String VIDEOCOURSEWARE_ID, String CURRICULUM_ID,String IS_END,int RESOURCETIME,String CHAPTER_ID,String STUDENT_ID,String CLASSCURRICULUM_ID, String CLASS_ID) {
|
||
return HttpManager().request(
|
||
basePath,
|
||
'/app/edu/coursestudyvideorecord/save',
|
||
method: Method.post,
|
||
data: {
|
||
'VIDEOCOURSEWARE_ID': VIDEOCOURSEWARE_ID,
|
||
'CURRICULUM_ID': CURRICULUM_ID,
|
||
'CHAPTER_ID': CHAPTER_ID,
|
||
'RESOURCETIME': RESOURCETIME,
|
||
'IS_END':IS_END,
|
||
'CLASS_ID': CLASS_ID,
|
||
'CLASSCURRICULUM_ID': CLASSCURRICULUM_ID,
|
||
'STUDENT_ID': STUDENT_ID,
|
||
'loading': false,
|
||
'USER_NAME': SessionService.instance.username,
|
||
'CORPINFO_ID': SessionService.instance.corpinfoId,
|
||
'USER_ID': SessionService.instance.loginUserId,
|
||
|
||
},
|
||
);
|
||
}
|
||
/// 人脸比对上传接口
|
||
///
|
||
/// [imagePath] 本地图片文件路径
|
||
/// 返回后端完整 JSON
|
||
static Future<Map<String, dynamic>> getUserFace(String imagePath, String studentId) async {
|
||
final file = File(imagePath);
|
||
if (!await file.exists()) {
|
||
throw ApiException('file_not_found', '图片不存在:$imagePath');
|
||
}
|
||
final fileName = file.path.split(Platform.pathSeparator).last;
|
||
|
||
return HttpManager().uploadFaceImage(
|
||
baseUrl: baseFacePath,
|
||
path: '/app/user/compareFaceForH5V2',
|
||
fromData: {
|
||
'USER_ID' : SessionService.instance.loginUserId,
|
||
'STUDENT_ID' : studentId,
|
||
'CORPINFO_ID' : SessionService.instance.corpinfoId,
|
||
'FFILE' : await MultipartFile.fromFile(
|
||
file.path,
|
||
filename: fileName
|
||
)
|
||
},
|
||
|
||
);
|
||
}
|
||
/// 签名上传
|
||
static Future<Map<String, dynamic>> signUpdate(String signBase64, String CLASS_ID, String STAGESTUDENTRELATION_ID) {
|
||
return HttpManager().request(
|
||
basePath,
|
||
'/app/edu/stagestudentrelation/sign',
|
||
method: Method.post,
|
||
data: {
|
||
'FFILE':signBase64,
|
||
'STUDYSTATE':1,
|
||
'CLASS_ID' : CLASS_ID,
|
||
'STAGESTUDENTRELATION_ID': STAGESTUDENTRELATION_ID,
|
||
'OPERATOR': SessionService.instance.username,
|
||
'USER_ID': SessionService.instance.loginUserId,
|
||
},
|
||
);
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
///TODO -------------–-------------------- 我的 -------------–--------------------
|
||
|
||
/// 问题反馈
|
||
static Future<Map<String, dynamic>> setFeedBack(String backTitle,String backContent,String backType,String imgPaths) {
|
||
return HttpManager().request(
|
||
basePath,
|
||
'/app/feedback/upload',
|
||
method: Method.post,
|
||
data: {
|
||
"FEEDBACK_TITLE":backTitle,
|
||
"FEEDBACK_CONTENT":backContent,
|
||
"FEEDBACK_TYPE":backType,
|
||
"FEEDBACK_IMG" :imgPaths,
|
||
"loginUserId":SessionService.instance.loginUserId,
|
||
"CORPINFO_ID":SessionService.instance.corpinfoId,
|
||
"USER_ID":SessionService.instance.loginUserId,
|
||
},
|
||
);
|
||
}
|
||
|
||
/// 修改密码
|
||
static Future<Map<String, dynamic>> changePassWord(String oldPwd,String confirmPwd) {
|
||
return HttpManager().request(
|
||
basePath,
|
||
'/app/user/editUserPwd',
|
||
method: Method.post,
|
||
data: {
|
||
"USERNAME": SessionService.instance.loginUser?["USERNAME"]??"",
|
||
"PASSWORD": oldPwd,
|
||
"NOWPASSWORD": confirmPwd,
|
||
"CORPINFO_ID":SessionService.instance.corpinfoId,
|
||
"USER_ID":SessionService.instance.loginUserId,
|
||
},
|
||
);
|
||
}
|
||
|
||
/// 获取离岗管理列表
|
||
static Future<Map<String, dynamic>> getDutyManagement(int showCount, int currentPage) {
|
||
return HttpManager().request(
|
||
basePath,
|
||
'/app/user/editUserPwd?showCount=$showCount¤tPage=$currentPage',
|
||
method: Method.post,
|
||
data: {
|
||
"CORPINFO_ID":SessionService.instance.corpinfoId,
|
||
"USER_ID":SessionService.instance.loginUserId,
|
||
// ISMAIN:loginUser.ISMAIN,
|
||
// ISSUPERVISE:loginUser.ISSUPERVISE,
|
||
"DEPARTMENT_ID":SessionService.instance.deptId,
|
||
"TYPE": 'edit'
|
||
},
|
||
);
|
||
}
|
||
|
||
/// 通知列表
|
||
static Future<Map<String, dynamic>> getNotifList(String showCount, String currentPage,String keyWord) {
|
||
return HttpManager().request(
|
||
basePath,
|
||
'/app/notice/list',
|
||
method: Method.post,
|
||
data: {
|
||
"showCount" : showCount,
|
||
"currentPage" : currentPage,
|
||
"KEYWORDS":keyWord,
|
||
"corpinfoId" :SessionService.instance.corpinfoId,
|
||
"CORPINFO_ID":SessionService.instance.corpinfoId,
|
||
"USER_ID":SessionService.instance.loginUserId,
|
||
},
|
||
);
|
||
}
|
||
|
||
/// 通知列表-企业
|
||
static Future<Map<String, dynamic>> getNotifEnterprise(String showCount, String currentPage,String keyWord) {
|
||
return HttpManager().request(
|
||
basePath,
|
||
'/app/notice/listForCp',
|
||
method: Method.post,
|
||
data: {
|
||
"showCount" : showCount,
|
||
"currentPage" : currentPage,
|
||
"KEYWORDS":keyWord,
|
||
"loginUserId" :SessionService.instance.loginUserId,
|
||
"CORPINFO_ID":SessionService.instance.corpinfoId,
|
||
"USER_ID":SessionService.instance.loginUserId,
|
||
},
|
||
);
|
||
}
|
||
|
||
|
||
/// 通知详情
|
||
static Future<Map<String, dynamic>> getNotifDetail(String id) {
|
||
return HttpManager().request(
|
||
basePath,
|
||
'/app/notice/goEdit',
|
||
method: Method.post,
|
||
data: {
|
||
"NOTICECORPUSERID_ID":id,
|
||
"loginUserId":SessionService.instance.loginUserId,
|
||
"corpinfoId":SessionService.instance.corpinfoId,
|
||
"ISMAIN":"0",
|
||
"CORPINFO_ID":SessionService.instance.corpinfoId,
|
||
"USER_ID":SessionService.instance.loginUserId,
|
||
},
|
||
);
|
||
}
|
||
|
||
/// 通知详情-企业
|
||
static Future<Map<String, dynamic>> getNotifEnterpriseDetail(String id) {
|
||
return HttpManager().request(
|
||
basePath,
|
||
'/app/notice/goEditForPc',
|
||
method: Method.post,
|
||
data: {
|
||
"NOTICECORPUSERID_ID":id,
|
||
"loginUserId":SessionService.instance.loginUserId,
|
||
"corpinfoId":SessionService.instance.corpinfoId,
|
||
"ISMAIN":"0",
|
||
"CORPINFO_ID":SessionService.instance.corpinfoId,
|
||
"USER_ID":SessionService.instance.loginUserId,
|
||
},
|
||
);
|
||
}
|
||
/// 更新人脸信息
|
||
static Future<Map<String, dynamic>> reloadMyFace(String imagePath) async {
|
||
final file = File(imagePath);
|
||
if (!await file.exists()) {
|
||
throw ApiException('file_not_found', '图片不存在:$imagePath');
|
||
}
|
||
final fileName = file.path.split(Platform.pathSeparator).last;
|
||
|
||
return HttpManager().uploadFaceImage(
|
||
baseUrl: basePath,
|
||
path: '/app/user/editUserFaceV2',
|
||
fromData: {
|
||
'CORPINFO_ID': SessionService.instance.corpinfoId,
|
||
'USER_ID': SessionService.instance.loginUserId,
|
||
'FFILE': await MultipartFile.fromFile(
|
||
file.path,
|
||
filename: fileName
|
||
),
|
||
}
|
||
);
|
||
}
|
||
|
||
/// 删除通知-企业
|
||
static Future<Map<String, dynamic>> deleteNotif(String id) {
|
||
return HttpManager().request(
|
||
basePath,
|
||
'/app/notice/delete',
|
||
method: Method.post,
|
||
data: {
|
||
"NOTICECORPUSERID_ID":id,
|
||
},
|
||
);
|
||
}
|
||
|
||
/// 获取离岗管理列表
|
||
static Future<Map<String, dynamic>> getAiAlarmList(String showCount, String currentPage,String keyWord) {
|
||
|
||
return HttpManager().request(
|
||
basePath,
|
||
'/app/aiwarning/list?showCount=$showCount¤tPage=$currentPage',
|
||
method: Method.post,
|
||
data: {
|
||
"tm": DateTime.now().millisecondsSinceEpoch,
|
||
"KEYWORDS": keyWord, //关键字模糊查询
|
||
"CORPINFO_ID":SessionService.instance.corpinfoId,
|
||
"USER_ID":SessionService.instance.loginUserId,
|
||
},
|
||
);
|
||
}
|
||
|
||
|
||
}
|
||
|