HeXunDataServiceImpl.java 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package com.warewms.service.impl;
  2. import com.warewms.common.utils.HttpRequest;
  3. import com.warewms.common.utils.JsonUtils;
  4. import com.warewms.model.HeXunAlarmData;
  5. import com.warewms.model.MachAlarmRecords;
  6. import com.warewms.service.HeXunDataService;
  7. import com.warewms.service.MachAlarmRecordsService;
  8. import lombok.extern.slf4j.Slf4j;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.stereotype.Service;
  11. import java.util.List;
  12. /**
  13. * PackageName:com.warewms.service.impl
  14. * Description:
  15. * Author:Gizmo
  16. * Date:2022/9/30
  17. */
  18. @Slf4j
  19. @Service
  20. public class HeXunDataServiceImpl implements HeXunDataService {
  21. @Autowired
  22. private MachAlarmRecordsService machAlarmRecordsService;
  23. @Override
  24. public void uploadAlarmData() {
  25. MachAlarmRecords queryRecord = new MachAlarmRecords();
  26. queryRecord.setUploadFlag("0");
  27. List<MachAlarmRecords> machAlarmRecordsList = machAlarmRecordsService.findByModel(queryRecord);
  28. for (MachAlarmRecords machAlarmRecords : machAlarmRecordsList) {
  29. HeXunAlarmData heXunAlarmData = new HeXunAlarmData();
  30. heXunAlarmData.setPrivate_key("E46C9E1EB7");
  31. heXunAlarmData.setRobotCode(machAlarmRecords.getMachNo());
  32. heXunAlarmData.setMapOrientation(machAlarmRecords.getAlarmMark());
  33. heXunAlarmData.setXCoord(machAlarmRecords.getXCoordinate());
  34. heXunAlarmData.setYCoord(machAlarmRecords.getYCoordinate());
  35. heXunAlarmData.setAddTime(machAlarmRecords.getTimestamp());
  36. heXunAlarmData.setVideoAddress(machAlarmRecords.getVideoUrl());
  37. heXunAlarmData.setAlarmType(machAlarmRecords.getDeviceType());
  38. heXunAlarmData.setAlarmLevel(machAlarmRecords.getAlarmLevel());
  39. heXunAlarmData.setAlarmContent(machAlarmRecords.getAlarmMsg());
  40. heXunAlarmData.setSystemType(machAlarmRecords.getSysType());
  41. heXunAlarmData.setDeviceCode(machAlarmRecords.getDeviceName());
  42. heXunAlarmData.setAlarmImg(machAlarmRecords.getImgUrl());
  43. try {
  44. String response = HttpRequest.postData("http://hxetm.com:20974/Interface_JCHGJT/info/addAlarm.do", JsonUtils.toJson(heXunAlarmData));
  45. log.info("http response:" + response);
  46. } catch (Exception e) {
  47. e.printStackTrace();
  48. }
  49. }
  50. }
  51. }