bug修复
This commit is contained in:
parent
4df0347038
commit
079a7ef249
@ -1,13 +1,9 @@
|
||||
package com.zhgd.xmgl.async;
|
||||
|
||||
import com.zhgd.xmgl.call.HikvisionCall;
|
||||
import com.zhgd.xmgl.call.HousingDataCall;
|
||||
import com.zhgd.xmgl.call.WkServiceuCall;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.INoticeService;
|
||||
import com.zhgd.xmgl.modules.car.entity.CarInfo;
|
||||
import com.zhgd.xmgl.modules.project.service.IProjectUfaceConfigService;
|
||||
import com.zhgd.xmgl.modules.worker.entity.EnterpriseInfo;
|
||||
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
|
||||
import com.zhgd.xmgl.modules.worker.mapper.WorkerInfoMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
@ -77,4 +73,31 @@ public class AsyncHikvision {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Async
|
||||
public void addEnterpriseInfoForHikvision(EnterpriseInfo enterpriseInfo) {
|
||||
try {
|
||||
hikvisionCall.addEnterpriseInfoForHikvision(enterpriseInfo);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Async
|
||||
public void editEnterpriseInfoForHikvision(EnterpriseInfo enterpriseInfo) {
|
||||
try {
|
||||
hikvisionCall.editEnterpriseInfoForHikvision(enterpriseInfo);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Async
|
||||
public void deleteEnterpriseInfoForHikvision(String enterpriseInfo, String projectSn) {
|
||||
try {
|
||||
hikvisionCall.deleteEnterpriseInfoForHikvision(enterpriseInfo, projectSn);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,19 @@
|
||||
package com.zhgd.xmgl.base;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class HikvisionEnterpriseInfo {
|
||||
|
||||
@JsonProperty("clientId")
|
||||
private Long clientId;
|
||||
@JsonProperty("orgIndexCode")
|
||||
private String orgIndexCode;
|
||||
@JsonProperty("orgName")
|
||||
private String orgName;
|
||||
@JsonProperty("parentIndexCode")
|
||||
private String parentIndexCode;
|
||||
|
||||
|
||||
}
|
||||
@ -9,6 +9,7 @@ import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.xmgl.base.HikvisionCarInfo;
|
||||
import com.zhgd.xmgl.base.HikvisionEnterpriseInfo;
|
||||
import com.zhgd.xmgl.base.HikvisionEventsPictureRq;
|
||||
import com.zhgd.xmgl.base.SubscribeEventQo;
|
||||
import com.zhgd.xmgl.modules.car.entity.CarInfo;
|
||||
@ -16,6 +17,7 @@ import com.zhgd.xmgl.modules.car.entity.CarPassRecord;
|
||||
import com.zhgd.xmgl.modules.car.mapper.CarPassRecordMapper;
|
||||
import com.zhgd.xmgl.modules.project.entity.Project;
|
||||
import com.zhgd.xmgl.modules.project.mapper.ProjectMapper;
|
||||
import com.zhgd.xmgl.modules.worker.entity.EnterpriseInfo;
|
||||
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
|
||||
import com.zhgd.xmgl.modules.worker.mapper.WorkerInfoMapper;
|
||||
import com.zhgd.xmgl.modules.worker.service.IWorkerAttendanceService;
|
||||
@ -330,4 +332,55 @@ public class HikvisionCall {
|
||||
String rs = HikvisionUtil.doPost(host, path, jo.toJSONString(), null, qo.getArtemisConfigAppKey(), qo.getArtemisConfigAppSecret());
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
public void addEnterpriseInfoForHikvision(EnterpriseInfo enterpriseInfo) {
|
||||
Project project = projectMapper.selectOne(new LambdaQueryWrapper<Project>().eq(Project::getProjectSn, enterpriseInfo.getProjectSn()));
|
||||
if (project == null || !Objects.equals(project.getSyncHikvision(), 1)) {
|
||||
return;
|
||||
}
|
||||
final String ARTEMIS_PATH = "/artemis";
|
||||
final String path = ARTEMIS_PATH + "/api/resource/v1/org/batch/add";
|
||||
String host = "https://" + project.getArtemisConfigHost();
|
||||
HikvisionEnterpriseInfo hikvisionEnterpriseInfo = getHikvisionEnterpriseInfo(enterpriseInfo);
|
||||
JsonArray array = new JsonArray();
|
||||
array.add(BeanUtil.toBean(hikvisionEnterpriseInfo, JsonObject.class));
|
||||
String body = array.toString();
|
||||
HikvisionUtil.doPost(host, path, body, null, project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret());
|
||||
}
|
||||
|
||||
private HikvisionEnterpriseInfo getHikvisionEnterpriseInfo(EnterpriseInfo enterpriseInfo) {
|
||||
HikvisionEnterpriseInfo hikvisionEnterpriseInfo = new HikvisionEnterpriseInfo();
|
||||
hikvisionEnterpriseInfo.setClientId(null);
|
||||
hikvisionEnterpriseInfo.setOrgIndexCode(String.valueOf(enterpriseInfo.getId()));
|
||||
hikvisionEnterpriseInfo.setOrgName(enterpriseInfo.getEnterpriseName());
|
||||
hikvisionEnterpriseInfo.setParentIndexCode(null);
|
||||
return hikvisionEnterpriseInfo;
|
||||
}
|
||||
|
||||
public void editEnterpriseInfoForHikvision(EnterpriseInfo enterpriseInfo) {
|
||||
Project project = projectMapper.selectOne(new LambdaQueryWrapper<Project>().eq(Project::getProjectSn, enterpriseInfo.getProjectSn()));
|
||||
if (project == null || !Objects.equals(project.getSyncHikvision(), 1)) {
|
||||
return;
|
||||
}
|
||||
final String ARTEMIS_PATH = "/artemis";
|
||||
final String path = ARTEMIS_PATH + "/api/resource/v1/org/single/update";
|
||||
String host = "https://" + project.getArtemisConfigHost();
|
||||
HikvisionEnterpriseInfo hikvisionEnterpriseInfo = getHikvisionEnterpriseInfo(enterpriseInfo);
|
||||
HikvisionUtil.doPost(host, path, JSONArray.toJSONString(hikvisionEnterpriseInfo), null, project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret());
|
||||
}
|
||||
|
||||
|
||||
public void deleteEnterpriseInfoForHikvision(String enterpriseInfo, String projectSn) {
|
||||
Project project = projectMapper.selectOne(new LambdaQueryWrapper<Project>().eq(Project::getProjectSn, projectSn));
|
||||
if (project == null || !Objects.equals(project.getSyncHikvision(), 1)) {
|
||||
return;
|
||||
}
|
||||
final String ARTEMIS_PATH = "/artemis";
|
||||
final String path = ARTEMIS_PATH + "/api/resource/v1/org/batch/delete";
|
||||
String host = "https://" + project.getArtemisConfigHost();
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("indexCodes", Arrays.asList(enterpriseInfo));
|
||||
HikvisionUtil.doPost(host, path, jo.toJSONString(), null, project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.jeecg.common.execption.OpenAlertException;
|
||||
import com.zhgd.jeecg.common.mybatis.EntityMap;
|
||||
import com.zhgd.xmgl.async.AsyncHikvision;
|
||||
import com.zhgd.xmgl.async.AsyncJiLianDa;
|
||||
import com.zhgd.xmgl.async.AsyncWorker;
|
||||
import com.zhgd.xmgl.base.CompanyVo;
|
||||
@ -61,6 +62,8 @@ public class EnterpriseInfoServiceImpl extends ServiceImpl<EnterpriseInfoMapper,
|
||||
private AsyncWorker asyncWorker;
|
||||
@Autowired
|
||||
private AsyncJiLianDa asyncJiLianDa;
|
||||
@Autowired
|
||||
private AsyncHikvision asyncHikvision;
|
||||
|
||||
@Override
|
||||
public List<EntityMap> getEnterpriseInfoList(Map<String, Object> map) {
|
||||
@ -111,6 +114,9 @@ public class EnterpriseInfoServiceImpl extends ServiceImpl<EnterpriseInfoMapper,
|
||||
asyncWorker.addEnterpriseInfo(enterpriseInfo);
|
||||
asyncJiLianDa.saveEnterpriseInfo(enterpriseInfo);
|
||||
userEnterpriseService.addEnterpriseIdForSubProject(String.valueOf(enterpriseInfo.getId()));
|
||||
|
||||
//同步海康
|
||||
asyncHikvision.addEnterpriseInfoForHikvision(enterpriseInfo);
|
||||
return enterpriseInfo;
|
||||
}
|
||||
|
||||
@ -123,22 +129,26 @@ public class EnterpriseInfoServiceImpl extends ServiceImpl<EnterpriseInfoMapper,
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void removeEnterpriseInfo(Map<String, Object> map) {
|
||||
QueryWrapper<TeamInfo> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().eq(TeamInfo::getEnterpriseId, MapUtils.getString(map, "enterpriseId"))
|
||||
.eq(TeamInfo::getProjectSn, MapUtils.getString(map, "projectSn"));
|
||||
String enterpriseId = MapUtils.getString(map, "enterpriseId");
|
||||
String projectSn = MapUtils.getString(map, "projectSn");
|
||||
wrapper.lambda().eq(TeamInfo::getEnterpriseId, enterpriseId)
|
||||
.eq(TeamInfo::getProjectSn, projectSn);
|
||||
int count = teamInfoMapper.selectCount(wrapper);
|
||||
if (count > 0) {
|
||||
throw new OpenAlertException(MessageUtil.get("notDeleteEnterpriseErr"));
|
||||
}
|
||||
QueryWrapper<ProjectEnterprise> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(ProjectEnterprise::getEnterpriseId, MapUtils.getString(map, "enterpriseId"))
|
||||
.eq(ProjectEnterprise::getProjectSn, MapUtils.getString(map, "projectSn"));
|
||||
queryWrapper.lambda().eq(ProjectEnterprise::getEnterpriseId, enterpriseId)
|
||||
.eq(ProjectEnterprise::getProjectSn, projectSn);
|
||||
ProjectEnterprise projectEnterprise = projectEnterpriseMapper.selectOne(queryWrapper);
|
||||
if (projectEnterprise != null) {
|
||||
//projectEnterpriseMapper.delete(queryWrapper);
|
||||
projectEnterpriseMapper.deleteById(projectEnterprise.getId());
|
||||
asyncWorker.removeEnterpriseInfo(projectEnterprise);
|
||||
asyncJiLianDa.removeEnterpriseInfo(projectEnterprise);
|
||||
}
|
||||
|
||||
//同步海康
|
||||
asyncHikvision.deleteEnterpriseInfoForHikvision(enterpriseId, projectSn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -186,6 +196,9 @@ public class EnterpriseInfoServiceImpl extends ServiceImpl<EnterpriseInfoMapper,
|
||||
|
||||
}*/
|
||||
asyncJiLianDa.saveEnterpriseInfo(enterpriseInfo);
|
||||
|
||||
//同步海康
|
||||
asyncHikvision.editEnterpriseInfoForHikvision(enterpriseInfo);
|
||||
return enterpriseInfo;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user