139 lines
7.1 KiB
Java
139 lines
7.1 KiB
Java
|
|
package com.zhgd.xmgl.async;
|
||
|
|
|
||
|
|
import cn.hutool.http.HttpUtil;
|
||
|
|
import cn.hutool.json.JSONObject;
|
||
|
|
import cn.hutool.json.JSONUtil;
|
||
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||
|
|
import com.zhgd.jeecg.common.mybatis.EntityMap;
|
||
|
|
import com.zhgd.xmgl.modules.basicdata.entity.ThirdPartyPlatformService;
|
||
|
|
import com.zhgd.xmgl.modules.basicdata.mapper.ThirdPartyPlatformServiceMapper;
|
||
|
|
import com.zhgd.xmgl.modules.project.entity.Project;
|
||
|
|
import com.zhgd.xmgl.modules.project.entity.ProjectUfaceConfig;
|
||
|
|
import com.zhgd.xmgl.modules.project.entity.ProjectVideoConfig;
|
||
|
|
import com.zhgd.xmgl.modules.project.mapper.ProjectExtendMapper;
|
||
|
|
import com.zhgd.xmgl.modules.project.mapper.ProjectMapper;
|
||
|
|
import com.zhgd.xmgl.modules.project.mapper.ProjectUfaceConfigMapper;
|
||
|
|
import com.zhgd.xmgl.modules.project.mapper.ProjectVideoConfigMapper;
|
||
|
|
import com.zhgd.xmgl.modules.video.mapper.VideoItemMapper;
|
||
|
|
import com.zhgd.xmgl.modules.worker.mapper.EnterpriseInfoMapper;
|
||
|
|
import lombok.extern.slf4j.Slf4j;
|
||
|
|
import org.apache.commons.collections.MapUtils;
|
||
|
|
import org.apache.commons.lang3.StringUtils;
|
||
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
||
|
|
import org.springframework.beans.factory.annotation.Value;
|
||
|
|
import org.springframework.scheduling.annotation.Async;
|
||
|
|
import org.springframework.stereotype.Component;
|
||
|
|
|
||
|
|
import java.util.HashMap;
|
||
|
|
import java.util.List;
|
||
|
|
import java.util.Map;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @program: wisdomSite
|
||
|
|
* @description: 异步项目数据
|
||
|
|
* @author: Mr.Peng
|
||
|
|
* @create: 2021-09-16 17:22
|
||
|
|
**/
|
||
|
|
|
||
|
|
@Slf4j
|
||
|
|
@Component
|
||
|
|
public class AsyncProject {
|
||
|
|
@Autowired
|
||
|
|
private ProjectMapper projectMapper;
|
||
|
|
@Autowired
|
||
|
|
private ProjectUfaceConfigMapper projectUfaceConfigMapper;
|
||
|
|
@Autowired
|
||
|
|
private ThirdPartyPlatformServiceMapper thirdPartyPlatformServiceMapper;
|
||
|
|
@Autowired
|
||
|
|
private VideoItemMapper videoItemMapper;
|
||
|
|
@Autowired
|
||
|
|
private ProjectVideoConfigMapper projectVideoConfigMapper;
|
||
|
|
@Autowired
|
||
|
|
private ProjectExtendMapper projectExtendMapper;
|
||
|
|
@Autowired
|
||
|
|
private EnterpriseInfoMapper enterpriseInfoMapper;
|
||
|
|
@Value("${serverUrl}")
|
||
|
|
private String serverUrl;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 发送项目基本信息数据
|
||
|
|
*/
|
||
|
|
@Async("sendWorkerExecutor")
|
||
|
|
public void sendProjectInfo(String projectSn) {
|
||
|
|
try {
|
||
|
|
QueryWrapper<ProjectUfaceConfig> queryWrapper =new QueryWrapper<>();
|
||
|
|
queryWrapper.lambda().eq(ProjectUfaceConfig::getProjectSn, projectSn);
|
||
|
|
ProjectUfaceConfig tempProjectUfaceConfig=projectUfaceConfigMapper.selectOne(queryWrapper);
|
||
|
|
if(tempProjectUfaceConfig!=null&& StringUtils.isNotEmpty(tempProjectUfaceConfig.getHousing())&&!"0".equals(tempProjectUfaceConfig.getHousing())) {
|
||
|
|
QueryWrapper<Project> queryWrapper1 =new QueryWrapper<>();
|
||
|
|
queryWrapper1.lambda().eq(Project::getProjectSn, projectSn);
|
||
|
|
Project project=projectMapper.selectOne(queryWrapper1);
|
||
|
|
String[] arr = tempProjectUfaceConfig.getHousing().split(",");
|
||
|
|
Map<String,Object> data=new HashMap<>();
|
||
|
|
Map<String, Object> param=new HashMap<>();
|
||
|
|
param.put("projectSn",projectSn);
|
||
|
|
EntityMap extendInfo=projectExtendMapper.getProjectExtendInfo(param);
|
||
|
|
List<EntityMap> enterpriseList=enterpriseInfoMapper.getEnterpriseInfoList(param);
|
||
|
|
JSONObject projectObj=JSONUtil.parseObj(project);
|
||
|
|
projectObj.set("supervisorUnit", MapUtils.getString(extendInfo, "supervisorUnit"));
|
||
|
|
projectObj.set("designUnit", MapUtils.getString(extendInfo,"designUnit"));
|
||
|
|
projectObj.set("bidWinner", MapUtils.getString(extendInfo,"bidWinner"));
|
||
|
|
projectObj.set("constructionUnit", MapUtils.getString(extendInfo,"constructionUnit"));
|
||
|
|
data.put("projectSn",project.getProjectSn());
|
||
|
|
data.put("project",projectObj);
|
||
|
|
data.put("enterpriseList",enterpriseList);
|
||
|
|
data.put("projectAuditUrl",serverUrl+"/projectApi/updateProjectAuditStatus");
|
||
|
|
for (String housingId : arr) {
|
||
|
|
ThirdPartyPlatformService dictionariesRecord = thirdPartyPlatformServiceMapper.selectById(housingId);
|
||
|
|
if (dictionariesRecord != null && StringUtils.isNotEmpty(dictionariesRecord.getServiceUrl())&&dictionariesRecord.getProjectSystem()==1) {
|
||
|
|
log.info("-----下发执行项目基本信息数据下发----" + dictionariesRecord.getServiceName());
|
||
|
|
String result = HttpUtil.post(dictionariesRecord.getServiceUrl() + "/saveProject", JSONUtil.toJsonStr(data));
|
||
|
|
log.info("-----下发执行接口地址----" + dictionariesRecord.getServiceUrl() + "/saveProject");
|
||
|
|
log.info("-----下发执行项目基本信息数据结果----" + result);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}catch (Exception e){
|
||
|
|
e.printStackTrace();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 发视频数据
|
||
|
|
*/
|
||
|
|
@Async("sendWorkerExecutor")
|
||
|
|
public void sendVideoInfo(String projectSn) {
|
||
|
|
try {
|
||
|
|
QueryWrapper<ProjectUfaceConfig> queryWrapper =new QueryWrapper<>();
|
||
|
|
queryWrapper.lambda().eq(ProjectUfaceConfig::getProjectSn, projectSn);
|
||
|
|
ProjectUfaceConfig tempProjectUfaceConfig=projectUfaceConfigMapper.selectOne(queryWrapper);
|
||
|
|
if(tempProjectUfaceConfig!=null&& StringUtils.isNotEmpty(tempProjectUfaceConfig.getHousing())&&!"0".equals(tempProjectUfaceConfig.getHousing())) {
|
||
|
|
QueryWrapper<ProjectVideoConfig> qu=new QueryWrapper<>();
|
||
|
|
qu.lambda().eq(ProjectVideoConfig::getProjectSn, projectSn)
|
||
|
|
.eq(ProjectVideoConfig::getIsEnable,1);
|
||
|
|
ProjectVideoConfig projectVideoConfig=projectVideoConfigMapper.selectOne(qu);
|
||
|
|
List<EntityMap> list=null;
|
||
|
|
if(projectVideoConfig!=null){
|
||
|
|
list=videoItemMapper.selectVideoItemListByVideoId(projectVideoConfig.getId(),null);
|
||
|
|
}
|
||
|
|
String[] arr = tempProjectUfaceConfig.getHousing().split(",");
|
||
|
|
Map<String,Object> data=new HashMap<>();
|
||
|
|
data.put("projectSn",projectSn);
|
||
|
|
data.put("projectVideoConfig",projectVideoConfig);
|
||
|
|
data.put("videoList",list);
|
||
|
|
for (String housingId : arr) {
|
||
|
|
ThirdPartyPlatformService dictionariesRecord = thirdPartyPlatformServiceMapper.selectById(housingId);
|
||
|
|
if (dictionariesRecord != null && StringUtils.isNotEmpty(dictionariesRecord.getServiceUrl())&&dictionariesRecord.getVideoSystem()==1) {
|
||
|
|
log.info("-----下发执行视频数据下发----" + dictionariesRecord.getServiceName());
|
||
|
|
String result = HttpUtil.post(dictionariesRecord.getServiceUrl() + "/saveVideo", JSONUtil.toJsonStr(data));
|
||
|
|
log.info("-----下发执行视频数据下发URL----" + dictionariesRecord.getServiceUrl() + "/saveVideo");
|
||
|
|
log.info("-----下发执行视频数据结果----" + result);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}catch (Exception e){
|
||
|
|
e.printStackTrace();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|