Commit 17fb37ec authored by 赵啸非's avatar 赵啸非

添加海康api对接模块

parent 902ddd51
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<el-form ref="form" :model="form" :rules="rules" label-width="120px"> <el-form ref="form" :model="form" :rules="rules" label-width="120px">
<el-row> <el-row>
<Field label="员工姓名" prop="name" v-model="form.name" placeholder="请输入员工姓名"/> <Field label="员工姓名" prop="name" v-model="form.name" placeholder="请输入员工姓名"/>
<Field label="性别" prop="gender" v-model="form.gender" type="select" :enumData="dict.gender" placeholder="请选择性别"/> <Field label="性别" prop="gender" v-model="form.gender" type="radio" :enumData="dict.gender" placeholder="请选择性别"/>
<Field label="出生日期" prop="birthday" v-model="form.birthday" type="date" /> <Field label="出生日期" prop="birthday" v-model="form.birthday" type="date" />
<Field label="照片" prop="photoPath" v-model="form.photoPath" type="textarea" placeholder="请输入照片"/> <Field label="照片" prop="photoPath" v-model="form.photoPath" type="textarea" placeholder="请输入照片"/>
<Field label="联系电话" prop="phoneNumber" v-model="form.phoneNumber" placeholder="请输入联系电话"/> <Field label="联系电话" prop="phoneNumber" v-model="form.phoneNumber" placeholder="请输入联系电话"/>
......
...@@ -53,12 +53,12 @@ export default { ...@@ -53,12 +53,12 @@ export default {
// 操作菜单状态 // 操作菜单状态
changeStatus(row, column) { changeStatus(row, column) {
return ( return (
<my-switch <my-switch
confirm confirm
url='/menu/save' url='/menu/save'
row={row} row={row}
onChange={this.statusChange} onChange={this.statusChange}
value={this.tableData.data} value={this.tableData.data}
onInput={(data)=>{ onInput={(data)=>{
this.tableData.data = data; this.tableData.data = data;
}}/> }}/>
...@@ -113,6 +113,11 @@ export default { ...@@ -113,6 +113,11 @@ export default {
// toView(row) { // toView(row) {
// this.$refs.dialogform.view(row); // this.$refs.dialogform.view(row);
// }, // },
handAdd(row) {
this.$refs.dialogform.add(row);
},
}, },
data() { data() {
return { return {
...@@ -200,8 +205,19 @@ export default { ...@@ -200,8 +205,19 @@ export default {
onClick={() => { onClick={() => {
this.handleDown(row); this.handleDown(row);
}} }}
></el-link> ></el-link>
<el-button
size="mini"
type="text"
icon="el-icon-open"
onClick={() => {
this.handAdd(row);
}}
>
新增
</el-button>
<table-buttons noView row={row} onEdit={this.toEdit} onDel={this.toDel} /> <table-buttons noView row={row} onEdit={this.toEdit} onDel={this.toDel} />
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<profiles.server.path>/attendance</profiles.server.path> <profiles.server.path>/attendance</profiles.server.path>
<profiles.nacos.server-addr>127.0.0.1:8848</profiles.nacos.server-addr> <profiles.nacos.server-addr>127.0.0.1:8848</profiles.nacos.server-addr>
<profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group> <profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group>
<profiles.nacos.namespace>smart-gov</profiles.nacos.namespace> <profiles.nacos.namespace>smart-gov-dev</profiles.nacos.namespace>
<profiles.log.path>/mortals/app/logs</profiles.log.path> <profiles.log.path>/mortals/app/logs</profiles.log.path>
<profiles.log.level>info</profiles.log.level> <profiles.log.level>info</profiles.log.level>
<profiles.publish.path>/home/publish</profiles.publish.path> <profiles.publish.path>/home/publish</profiles.publish.path>
...@@ -115,6 +115,14 @@ ...@@ -115,6 +115,14 @@
<artifactId>jjwt</artifactId> <artifactId>jjwt</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.hikvision.ga</groupId>
<artifactId>artemis-http-client</artifactId>
<version>1.1.8</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/lib/artemis-http-client-1.1.8.jar</systemPath>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
......
package com.mortals.xhx.busiz.hik;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
import com.hikvision.artemis.sdk.config.ArtemisConfig;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import static com.hikvision.artemis.sdk.util.HttpUtil.wrapClient;
public class ArtemisPostTest {
/**
* 请根据技术支持提供的实际的平台IP/端口和API网关中的合作方信息更换static静态块中的三个参数.
* [1 host]
* host格式为IP:Port,如10.0.0.1:443
* 当使用https协议调用接口时,IP是平台(nginx)IP,Port是https协议的端口;
* 当使用http协议调用接口时,IP是artemis服务的IP,Port是artemis服务的端口(默认9016)。
* [2 appKey和appSecret]
* 请按照技术支持提供的合作方Key和合作方Secret修改
* appKey:合作方Key
* appSecret:合作方Secret
* 调用前看清接口传入的是什么,是传入json就用doPostStringArtemis方法,是表单提交就用doPostFromArtemis方法
*
*/
/**
* API网关的后端服务上下文为:/artemis
*/
private static final String ARTEMIS_PATH = "/artemis";
///irds/api/v1/person/personList
/**
* 调用POST请求类型接口,这里以获取组织列表为例
* 接口实际url:https://ip:port/artemis/api/resource/v1/org/orgList
* @return
*/
public static String callPostApiGetOrgList() throws Exception {
/**
* https://ip:port/artemis/api/resource/v1/org/orgList
* 通过查阅AI Cloud开放平台文档或网关门户的文档可以看到获取组织列表的接口定义,该接口为POST请求的Rest接口, 入参为JSON字符串,接口协议为https。
* ArtemisHttpUtil工具类提供了doPostStringArtemis调用POST请求的方法,入参可传JSON字符串, 请阅读开发指南了解方法入参,没有的参数可传null
*/
ArtemisConfig config = new ArtemisConfig();
config.setHost("8.136.255.30:8001"); // 代理API网关nginx服务器ip端口
config.setAppKey("25128371"); // 秘钥appkey
config.setAppSecret("2m9RcPJOKq5j2QPQM4v5");// 秘钥appSecret
final String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/org/orgList";
Map<String, String> paramMap = new HashMap<String, String>();// post请求Form表单参数
paramMap.put("pageNo", "1");
paramMap.put("pageSize", "2");
String body = JSON.toJSON(paramMap).toString();
Map<String, String> path = new HashMap<String, String>(2) {
{
put("http://", getCamsApi);
}
};
return ArtemisHttpUtil.doPostStringArtemis(config,path, body, null, null, "application/json");
}
public static String callPostApiGetPersonList() throws Exception {
/**
* https://ip:port/artemis/api/resource/v1/org/orgList
* 通过查阅AI Cloud开放平台文档或网关门户的文档可以看到获取组织列表的接口定义,该接口为POST请求的Rest接口, 入参为JSON字符串,接口协议为https。
* ArtemisHttpUtil工具类提供了doPostStringArtemis调用POST请求的方法,入参可传JSON字符串, 请阅读开发指南了解方法入参,没有的参数可传null
*/
ArtemisConfig config = new ArtemisConfig();
config.setHost("8.136.255.30:8001"); // 代理API网关nginx服务器ip端口
config.setAppKey("25128371"); // 秘钥appkey
config.setAppSecret("2m9RcPJOKq5j2QPQM4v5");// 秘钥appSecret
final String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/person/personList";
Map<String, String> paramMap = new HashMap<String, String>();// post请求Form表单参数
paramMap.put("pageNo", "1");
paramMap.put("pageSize", "10");
String body = JSON.toJSON(paramMap).toString();
Map<String, String> path = new HashMap<String, String>(2) {
{
put("http://", getCamsApi);
}
};
return ArtemisHttpUtil.doPostStringArtemis(config,path, body, null, null, "application/json");
}
/**
* 调用POST请求类型接口,这里以分页获取区域列表为例
* 接口实际url:https://ip:port/artemis/api/api/resource/v1/regions
* @return
*/
public static String callPostApiGetRegions() throws Exception {
/**
* https://ip:port/artemis/api/resource/v1/regions
* 过查阅AI Cloud开放平台文档或网关门户的文档可以看到分页获取区域列表的定义,这是一个POST请求的Rest接口, 入参为JSON字符串,接口协议为https。
* ArtemisHttpUtil工具类提供了doPostStringArtemis调用POST请求的方法,入参可传JSON字符串, 请阅读开发指南了解方法入参,没有的参数可传null
*/
ArtemisConfig config = new ArtemisConfig();
config.setHost("127.0.0.1"); // 代理API网关nginx服务器ip端口
config.setAppKey("20469790"); // 秘钥appkey
config.setAppSecret("lofnD6DbnBllHmk5YOyx");// 秘钥appSecret
final String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/regions";
Map<String, String> paramMap = new HashMap<String, String>();// post请求Form表单参数
paramMap.put("pageNo", "1");
paramMap.put("pageSize", "2");
paramMap.put("treeCode", "0");
String body = JSON.toJSON(paramMap).toString();
Map<String, String> path = new HashMap<String, String>(2) {
{
put("https://", getCamsApi);
}
};
return ArtemisHttpUtil.doPostStringArtemis(config,path, body, null, null, "application/json");
}
/**
* 调用POST接口,返回图片
* 接口实际url:https://ip:port/artemis/api/visitor/v1/record/pictures
* @return
*/
public static String callPostImgs() throws Exception {
ArtemisConfig config = new ArtemisConfig();
config.setHost("127.0.0.1"); // 代理API网关nginx服务器ip端口
config.setAppKey("20469790"); // 秘钥appkey
config.setAppSecret("lofnD6DbnBllHmk5YOyx");// 秘钥appSecret
final String getSecurityApi = "/artemis" + "/api/visitor/v1/record/pictures"; // 接口路径
Map<String, String> path = new HashMap<String, String>(2) {
{
put("https://", getSecurityApi);
}
};
Map<String, String> head = new HashMap<String, String>(2) { //get请求的head参数
{
put("headpost", "sky-test");
}
};
Map<String, String> query = new HashMap<String, String>(2) { //get请求的head参数
{
put("domainId", "0");
}
};
JSONObject jsonBody = new JSONObject();
jsonBody.put("svrIndexCode", "9ff58bc2-65a5-464b-b28c-daea67ba9569");
jsonBody.put("picUri", "/pic?9dda12i40-e*5b84626c4105m5ep=t=i3p*i=d1s*i=d3b*i1d3b*855925cea-96008b--2718943z855s=5i76=");
String body = jsonBody.toJSONString();
//参数根据接口实际情况设置
HttpResponse result = ArtemisHttpUtil.doPostStringImgArtemis(config, path, body, query, null,"application/json",head);
try {
HttpResponse resp = result;
if (302==resp.getStatusLine().getStatusCode()) {
/*
获取图片数据保存到本地
注:1.对于有时效的图片,必须尽快保存到本地
2.若无时效,则可以直接保存location,后续自行访问获取
*/
Header header= resp.getFirstHeader("location");
String newUrl = header.getValue();
HttpGet httpget = new HttpGet(newUrl);
HttpClient httpClient = wrapClient(httpget.getURI().getScheme()+"://"+httpget.getURI().getHost());
HttpResponse execute = httpClient.execute(httpget);
HttpEntity entity = execute.getEntity();
InputStream in = entity.getContent();
Tools.savePicToDisk(in, "d:/", "test311.jpg");
}else{
System.out.println("下载出错");
}
} catch (Exception e) {
e.printStackTrace();
}
return getSecurityApi;
}
public static void main(String[] args) throws Exception {
/* String result = callPostApiGetOrgList();
System.out.println(result);*/
// String VechicleDataResult = callPostApiGetRegions();
// System.out.println(VechicleDataResult);
String result = callPostApiGetPersonList();
System.out.println(result);
//callPostApiGetPersonList
}
}
package com.mortals.xhx.busiz.hik;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
/**
* 工具类
*
* @author
* @create 2019-01-11 17:06
**/
public class Tools {
/**
* 将图片写到 硬盘指定目录下
*
* @param in
* @param dirPath
* @param filePath
*/
public static void savePicToDisk(InputStream in, String dirPath,
String filePath) {
try {
File dir = new File(dirPath);
if (dir == null || !dir.exists()) {
dir.mkdirs();
}
//文件真实路径
String realPath = dirPath.concat(filePath);
File file = new File(realPath);
if (file == null || !file.exists()) {
file.createNewFile();
}
FileOutputStream fos = new FileOutputStream(file);
byte[] buf = new byte[1024];
int len = 0;
while ((len = in.read(buf)) != -1) {
fos.write(buf, 0, len);
}
fos.flush();
fos.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
package com.mortals.xhx.daemon.task;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.ITask;
import com.mortals.framework.service.ITaskExcuteService;
import com.mortals.xhx.base.system.user.service.UserService;
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.user.UserPdu;
import com.mortals.xhx.feign.user.IUserFeign;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
/**
* 同步用户
*/
@Slf4j
//@Service("SyncUserTask")
public class SyncUserTaskImpl implements ITaskExcuteService {
@Autowired
private UserService userService;
@Autowired
private IUserFeign userFeign;
@Override
public void excuteTask(ITask task) throws AppException {
log.info("同步用户");
}
@Override
public void stopTask(ITask task) throws AppException {
}
}
package com.mortals.xhx.module.attendance.service.impl; package com.mortals.xhx.module.attendance.service.impl;
import com.mortals.framework.service.ICacheService;
import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
...@@ -14,6 +17,25 @@ import com.mortals.xhx.module.attendance.service.AttendanceGroupService; ...@@ -14,6 +17,25 @@ import com.mortals.xhx.module.attendance.service.AttendanceGroupService;
* @date 2023-04-07 * @date 2023-04-07
*/ */
@Service("attendanceGroupService") @Service("attendanceGroupService")
public class AttendanceGroupServiceImpl extends AbstractCRUDServiceImpl<AttendanceGroupDao, AttendanceGroupEntity, Long> implements AttendanceGroupService { public class AttendanceGroupServiceImpl extends AbstractCRUDCacheServiceImpl<AttendanceGroupDao, AttendanceGroupEntity, Long> implements AttendanceGroupService {
@Autowired
private ICacheService cacheService;
@Override
protected AttendanceGroupEntity findBefore(AttendanceGroupEntity entity, Context context) throws AppException {
return super.findBefore(entity, context);
}
@Override
protected void saveBefore(AttendanceGroupEntity entity, Context context) throws AppException {
super.saveBefore(entity, context);
}
@Override
protected void saveAfter(AttendanceGroupEntity entity, Context context) throws AppException {
super.saveAfter(entity, context);
}
} }
\ No newline at end of file
...@@ -6,6 +6,9 @@ import com.mortals.framework.model.Context; ...@@ -6,6 +6,9 @@ import com.mortals.framework.model.Context;
import com.mortals.xhx.module.job.dao.JobDao; import com.mortals.xhx.module.job.dao.JobDao;
import com.mortals.xhx.module.job.model.JobEntity; import com.mortals.xhx.module.job.model.JobEntity;
import com.mortals.xhx.module.job.service.JobService; import com.mortals.xhx.module.job.service.JobService;
import java.util.List;
/** /**
* JobService * JobService
* 职位信息 service实现 * 职位信息 service实现
...@@ -15,5 +18,5 @@ import com.mortals.xhx.module.job.service.JobService; ...@@ -15,5 +18,5 @@ import com.mortals.xhx.module.job.service.JobService;
*/ */
@Service("jobService") @Service("jobService")
public class JobServiceImpl extends AbstractCRUDServiceImpl<JobDao, JobEntity, Long> implements JobService { public class JobServiceImpl extends AbstractCRUDServiceImpl<JobDao, JobEntity, Long> implements JobService {
} }
\ No newline at end of file
package com.mortals.xhx.module.job.web; package com.mortals.xhx.module.job.web;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService; import com.mortals.xhx.base.system.param.service.ParamService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -46,4 +47,10 @@ public class JobController extends BaseCRUDJsonBodyMappingController<JobService, ...@@ -46,4 +47,10 @@ public class JobController extends BaseCRUDJsonBodyMappingController<JobService,
} }
@Override
public void doImportDataBefore(List<JobEntity> list, boolean updateSupport, Context context) throws AppException {
super.doImportDataBefore(list, updateSupport, context);
}
} }
\ No newline at end of file
...@@ -17,5 +17,4 @@ import java.util.List; ...@@ -17,5 +17,4 @@ import java.util.List;
public class StaffRegularDaoImpl extends BaseCRUDDaoMybatis<StaffRegularEntity,Long> implements StaffRegularDao { public class StaffRegularDaoImpl extends BaseCRUDDaoMybatis<StaffRegularEntity,Long> implements StaffRegularDao {
} }
package com.mortals.xhx.module.staff.model.vo; package com.mortals.xhx.module.staff.model.vo;
import com.mortals.framework.model.BaseEntityLong; import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.staff.model.StaffEntity; import com.mortals.xhx.module.staff.model.StaffEntity;
import lombok.Data;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
...@@ -9,6 +11,9 @@ import java.util.List; ...@@ -9,6 +11,9 @@ import java.util.List;
* @author zxfei * @author zxfei
* @date 2023-04-07 * @date 2023-04-07
*/ */
@Data
public class StaffVo extends BaseEntityLong { public class StaffVo extends BaseEntityLong {
private List <Long> idList;
} }
\ No newline at end of file
package com.mortals.xhx.module.staff.web; package com.mortals.xhx.module.staff.web;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService; import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.code.StatusEnum;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -46,8 +48,17 @@ public class StaffController extends BaseCRUDJsonBodyMappingController<StaffServ ...@@ -46,8 +48,17 @@ public class StaffController extends BaseCRUDJsonBodyMappingController<StaffServ
this.addDict(model, "politicalstatus", paramService.getParamBySecondOrganize("Staff","politicalstatus")); this.addDict(model, "politicalstatus", paramService.getParamBySecondOrganize("Staff","politicalstatus"));
this.addDict(model, "staffType", paramService.getParamBySecondOrganize("Staff","staffType")); this.addDict(model, "staffType", paramService.getParamBySecondOrganize("Staff","staffType"));
this.addDict(model, "status", paramService.getParamBySecondOrganize("Staff","status")); this.addDict(model, "status", paramService.getParamBySecondOrganize("Staff","status"));
super.init(model, context); super.init(model, context);
} }
@Override
protected void doListBefore(StaffEntity query, Map<String, Object> model, Context context) throws AppException {
super.doListBefore(query, model, context);
}
@Override
protected int doListAfter(StaffEntity query, Map<String, Object> model, Context context) throws AppException {
return super.doListAfter(query, model, context);
}
} }
\ No newline at end of file
...@@ -15,15 +15,10 @@ client.global.set("authToken", JSON.parse(response.body).data.token); ...@@ -15,15 +15,10 @@ client.global.set("authToken", JSON.parse(response.body).data.token);
###员工基本信息列表 ###员工基本信息列表
POST {{baseUrl}}/staff/list POST {{baseUrl}}/staff/list
Authorization: {{authToken}}
Content-Type: application/json Content-Type: application/json
{ {
"name":"8d5kv9", "idList": [1,3],
"gender":1,
"politicalstatus":1,
"staffType":1,
"status":1,
"page":1, "page":1,
"size":10 "size":10
} }
...@@ -53,7 +48,7 @@ Content-Type: application/json ...@@ -53,7 +48,7 @@ Content-Type: application/json
"entryDate":"1680796800000", "entryDate":"1680796800000",
"regularDate":"1680796800000", "regularDate":"1680796800000",
"leaveDate":"1680796800000", "leaveDate":"1680796800000",
"remark":"g4kftd", "remark":"g4kftd"
} }
> {% > {%
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment