|
|
@ -5,6 +5,8 @@ import com.fasterxml.jackson.core.type.TypeReference; |
|
|
import com.fasterxml.jackson.databind.ObjectMapper; |
|
|
import com.fasterxml.jackson.databind.ObjectMapper; |
|
|
import com.inspect.analysis.domain.ResultAnalysis; |
|
|
import com.inspect.analysis.domain.ResultAnalysis; |
|
|
import com.inspect.analysis.mapper.ResultAnalysisMapper; |
|
|
import com.inspect.analysis.mapper.ResultAnalysisMapper; |
|
|
|
|
|
import com.inspect.base.core.sftp.SftpClient; |
|
|
|
|
|
import com.inspect.base.core.sftp.SftpUploadEntity; |
|
|
import com.inspect.base.core.utils.DateUtils; |
|
|
import com.inspect.base.core.utils.DateUtils; |
|
|
import com.inspect.base.core.utils.HttpClientUtils; |
|
|
import com.inspect.base.core.utils.HttpClientUtils; |
|
|
import com.inspect.base.core.utils.StringUtils; |
|
|
import com.inspect.base.core.utils.StringUtils; |
|
|
@ -33,6 +35,8 @@ import org.springframework.scheduling.annotation.EnableScheduling; |
|
|
import org.springframework.scheduling.annotation.Scheduled; |
|
|
import org.springframework.scheduling.annotation.Scheduled; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
@Slf4j |
|
|
@Slf4j |
|
|
@EnableScheduling |
|
|
@EnableScheduling |
|
|
@Service |
|
|
@Service |
|
|
@ -48,6 +52,8 @@ public class PatrolTaskServiceImpl implements IPatrolTaskService { |
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
private TaskCalendarGenerator taskCalendarGenerator; |
|
|
private TaskCalendarGenerator taskCalendarGenerator; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private SftpClient sftpClient; |
|
|
|
|
|
|
|
|
final ResultAnalysisMapper resultAnalysisMapper; |
|
|
final ResultAnalysisMapper resultAnalysisMapper; |
|
|
|
|
|
|
|
|
@ -110,7 +116,7 @@ public class PatrolTaskServiceImpl implements IPatrolTaskService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public int updatePatrolTask(PatrolTask patrolTask) { |
|
|
public int updatePatrolTask(PatrolTask patrolTask) { |
|
|
int count = this.patrolTaskMapper.updatePatrolTask(patrolTask); |
|
|
|
|
|
|
|
|
int count = this.patrolTaskMapper.updatePatrolTask(patrolTask); |
|
|
taskCalendarGenerator.onTaskChange(); |
|
|
taskCalendarGenerator.onTaskChange(); |
|
|
return count; |
|
|
return count; |
|
|
} |
|
|
} |
|
|
@ -153,16 +159,17 @@ public class PatrolTaskServiceImpl implements IPatrolTaskService { |
|
|
return this.resultAnalysisMapper.pointStatistics(); |
|
|
return this.resultAnalysisMapper.pointStatistics(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void correctionAlgorithm(PatrolData patrolData) { |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public boolean correctionAlgorithm(PatrolData patrolData) { |
|
|
log.info("controller correctionAlgorithm pointId: {}, resValue: {}", |
|
|
log.info("controller correctionAlgorithm pointId: {}, resValue: {}", |
|
|
patrolData.getPointId(), |
|
|
patrolData.getPointId(), |
|
|
patrolData.getResValue()); |
|
|
patrolData.getResValue()); |
|
|
final Map<String, Object> result = patrolTaskMapper.selectChannelCodeByPatrolPointId(patrolData.getPointId()); |
|
|
final Map<String, Object> result = patrolTaskMapper.selectChannelCodeByPatrolPointId(patrolData.getPointId()); |
|
|
final String channelCode = (String)result.get("channel_code"); |
|
|
|
|
|
final String presetPosCode = (String)result.get("preset_pos_code"); |
|
|
|
|
|
final String presetPosName = (String)result.get("preset_pos_name"); |
|
|
|
|
|
|
|
|
final String channelCode = (String) result.get("channel_code"); |
|
|
|
|
|
final String presetPosCode = (String) result.get("preset_pos_code"); |
|
|
|
|
|
final String presetPosName = (String) result.get("preset_pos_name"); |
|
|
final Integer patrolPointId = (Integer) result.get("patrol_point_id"); |
|
|
final Integer patrolPointId = (Integer) result.get("patrol_point_id"); |
|
|
final String videoNvrCode = (String)result.get("video_nvr_code"); |
|
|
|
|
|
|
|
|
final String videoNvrCode = (String) result.get("video_nvr_code"); |
|
|
log.info("controller correctionAlgorithm channelCode: {}, presetPosCode: {}, presetPosName: {}, patrolPointId: {}, videoNvrCode: {}", |
|
|
log.info("controller correctionAlgorithm channelCode: {}, presetPosCode: {}, presetPosName: {}, patrolPointId: {}, videoNvrCode: {}", |
|
|
channelCode, |
|
|
channelCode, |
|
|
presetPosCode, |
|
|
presetPosCode, |
|
|
@ -178,10 +185,10 @@ public class PatrolTaskServiceImpl implements IPatrolTaskService { |
|
|
+ "&name=" + URLEncoder.encode(presetPosName, ("UTF-8")) |
|
|
+ "&name=" + URLEncoder.encode(presetPosName, ("UTF-8")) |
|
|
+ "&id=" + patrolPointId |
|
|
+ "&id=" + patrolPointId |
|
|
+ "&host=" + "null" |
|
|
+ "&host=" + "null" |
|
|
+ "&port=" + "null" |
|
|
|
|
|
+ "&username=" + "null" |
|
|
|
|
|
+ "&password=" + "null" |
|
|
|
|
|
+ "&address=" + "null"; |
|
|
|
|
|
|
|
|
+ "&port=" + "null" |
|
|
|
|
|
+ "&username=" + "null" |
|
|
|
|
|
+ "&password=" + "null" |
|
|
|
|
|
+ "&address=" + "null"; |
|
|
log.info("controller correctionAlgorithm preset url2: {}, param2: {}", url2, param2); |
|
|
log.info("controller correctionAlgorithm preset url2: {}, param2: {}", url2, param2); |
|
|
HttpClientUtils.get(url2, param2); |
|
|
HttpClientUtils.get(url2, param2); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
@ -207,7 +214,7 @@ public class PatrolTaskServiceImpl implements IPatrolTaskService { |
|
|
|
|
|
|
|
|
String controlPara1 = ""; |
|
|
String controlPara1 = ""; |
|
|
String controlPara2 = ""; |
|
|
String controlPara2 = ""; |
|
|
if(list.size() == 2 && list.get(0).size() == 2 && list.get(1).size() == 2) { |
|
|
|
|
|
|
|
|
if (list.size() == 2 && list.get(0).size() == 2 && list.get(1).size() == 2) { |
|
|
controlPara1 = list.get(0).get(0) + "," + list.get(0).get(1); |
|
|
controlPara1 = list.get(0).get(0) + "," + list.get(0).get(1); |
|
|
controlPara2 = list.get(1).get(0) + "," + list.get(1).get(1); |
|
|
controlPara2 = list.get(1).get(0) + "," + list.get(1).get(1); |
|
|
} |
|
|
} |
|
|
@ -217,9 +224,9 @@ public class PatrolTaskServiceImpl implements IPatrolTaskService { |
|
|
+ "&code=" + channelCode |
|
|
+ "&code=" + channelCode |
|
|
+ "&controlCode=" + "31" |
|
|
+ "&controlCode=" + "31" |
|
|
+ "&controlPara1=" + controlPara1 |
|
|
+ "&controlPara1=" + controlPara1 |
|
|
+ "&controlPara2=" + controlPara2 |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
+ "&controlPara2=" + controlPara2; |
|
|
log.info("controller correctionAlgorithm correction param: {}", param); |
|
|
log.info("controller correctionAlgorithm correction param: {}", param); |
|
|
|
|
|
// 设置预置位 |
|
|
try { |
|
|
try { |
|
|
HttpClientUtils.get(url, param); |
|
|
HttpClientUtils.get(url, param); |
|
|
Thread.sleep(5000); |
|
|
Thread.sleep(5000); |
|
|
@ -228,8 +235,7 @@ public class PatrolTaskServiceImpl implements IPatrolTaskService { |
|
|
final String param3 = "command=correctionSet" |
|
|
final String param3 = "command=correctionSet" |
|
|
+ "&code=" + channelCode |
|
|
+ "&code=" + channelCode |
|
|
+ "&preset=" + presetPosCode |
|
|
+ "&preset=" + presetPosCode |
|
|
+ "&name=" + URLEncoder.encode(presetPosName, ("UTF-8")) |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
+ "&name=" + URLEncoder.encode(presetPosName, ("UTF-8")); |
|
|
try { |
|
|
try { |
|
|
HttpClientUtils.get(url3, param3); |
|
|
HttpClientUtils.get(url3, param3); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
@ -238,14 +244,37 @@ public class PatrolTaskServiceImpl implements IPatrolTaskService { |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
log.info("controller correctionAlgorithm HttpClientUtils.get execute exception: {}", e.getMessage()); |
|
|
log.info("controller correctionAlgorithm HttpClientUtils.get execute exception: {}", e.getMessage()); |
|
|
} |
|
|
} |
|
|
if(!StringUtils.isEmpty(patrolData.getLineId())) { |
|
|
|
|
|
|
|
|
// 抓拍新点位图片 |
|
|
|
|
|
final String urlCapture = "http://199.199.199.154:9906" + "/api/v1/device/channelsnap" |
|
|
|
|
|
+ "?serial=" + videoNvrCode |
|
|
|
|
|
+ "&realtime=true" |
|
|
|
|
|
+ "&code=" + channelCode; |
|
|
|
|
|
|
|
|
|
|
|
String fileTypeDir = "snap/"; |
|
|
|
|
|
String fileName = "correction_" + System.currentTimeMillis() + ".jpg"; |
|
|
|
|
|
String filePath = ""; |
|
|
|
|
|
try { |
|
|
|
|
|
String[] split = urlCapture.split("\\?"); |
|
|
|
|
|
SftpUploadEntity sftpUploadEntity = new SftpUploadEntity(HttpClientUtils.getStream(split[0], split[split.length - 1])); |
|
|
|
|
|
sftpUploadEntity.setFilePath(fileTypeDir); |
|
|
|
|
|
sftpUploadEntity.setFileName(fileName.split(StringUtils.HASHTAG)[0]); |
|
|
|
|
|
filePath = sftpClient.upload(sftpUploadEntity); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
log.info("correction ftp error:{}", e.getMessage()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 更新结果 |
|
|
|
|
|
if (!StringUtils.isEmpty(patrolData.getLineId()) && filePath != "") { |
|
|
ResultAnalysis resultAnalysis = new ResultAnalysis(); |
|
|
ResultAnalysis resultAnalysis = new ResultAnalysis(); |
|
|
resultAnalysis.setLineId(Long.valueOf(patrolData.getLineId())); |
|
|
resultAnalysis.setLineId(Long.valueOf(patrolData.getLineId())); |
|
|
resultAnalysis.setResStatus("4"); |
|
|
resultAnalysis.setResStatus("4"); |
|
|
resultAnalysis.setDescription("已完成纠偏"); |
|
|
resultAnalysis.setDescription("已完成纠偏"); |
|
|
log.info("controller correctionAlgorithm updateResultAnalysis: {}", resultAnalysis); |
|
|
|
|
|
|
|
|
resultAnalysis.setOriginalValue(filePath); |
|
|
resultAnalysisMapper.updateResultAnalysis(resultAnalysis); |
|
|
resultAnalysisMapper.updateResultAnalysis(resultAnalysis); |
|
|
|
|
|
log.info("controller correctionAlgorithm updateResultAnalysis: {}", resultAnalysis); |
|
|
|
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
|