LApiTest.java 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. package com.jpsoft.smart;
  2. import cn.hutool.core.date.DateUtil;
  3. import cn.hutool.json.JSONObject;
  4. import com.github.pagehelper.Page;
  5. import com.jpsoft.smart.modules.base.dao.PersonInfoDAO;
  6. import com.jpsoft.smart.modules.base.dao.WarningPusherDAO;
  7. import com.jpsoft.smart.modules.base.dto.PersonDeviceLogDTO;
  8. import com.jpsoft.smart.modules.base.entity.*;
  9. import com.jpsoft.smart.modules.base.service.CompanyInfoService;
  10. import com.jpsoft.smart.modules.base.service.PersonDeviceLogService;
  11. import com.jpsoft.smart.modules.base.service.impl.PersonDeviceLogServiceImpl;
  12. import com.jpsoft.smart.modules.common.dto.MessageResult;
  13. import com.jpsoft.smart.modules.common.service.IRedisService;
  14. import com.jpsoft.smart.modules.common.utils.WechatMessageUtil;
  15. import com.jpsoft.smart.modules.lapi.service.ILapiService;
  16. import com.jpsoft.smart.modules.lapi.service.impl.LapiServiceImpl;
  17. import com.jpsoft.smart.modules.lapi.vo.LapiMsgResult;
  18. import com.jpsoft.smart.modules.lapi.vo.LapiResult;
  19. import jdk.nashorn.internal.objects.annotations.Setter;
  20. import org.junit.Test;
  21. import org.junit.runner.RunWith;
  22. import org.springframework.beans.factory.annotation.Autowired;
  23. import org.springframework.boot.test.context.SpringBootTest;
  24. import org.springframework.test.context.junit4.SpringRunner;
  25. import java.math.BigDecimal;
  26. import java.util.*;
  27. /**
  28. * @author 墨鱼_mo
  29. * @date 2020-3-15 9:58
  30. */
  31. @RunWith(SpringRunner.class)
  32. @SpringBootTest
  33. public class LApiTest {
  34. @Autowired
  35. private ILapiService lapiService;
  36. @Autowired
  37. private WarningPusherDAO warningPusherDAO;
  38. @Autowired
  39. private PersonInfoDAO personInfoDAO;
  40. @Autowired
  41. private PersonDeviceLogServiceImpl personDeviceLogService;
  42. @Autowired
  43. private IRedisService redisService;
  44. @Autowired
  45. private CompanyInfoService companyInfoService;
  46. @Test
  47. public void testKeepLive(){
  48. try {
  49. Boolean result = lapiService.keepAlive("9f254a38-2b6c-4169-a53c-765ec5e16c51");
  50. System.out.println(result);
  51. } catch (Exception e) {
  52. e.printStackTrace();
  53. String message = e.getMessage();
  54. }
  55. }
  56. @Test
  57. public void testAddPerson(){
  58. try {
  59. //List<LapiMsgResult> result = lapiService.addPerson(11838L);
  60. //System.out.println(result);
  61. } catch (Exception e) {
  62. e.printStackTrace();
  63. String message = e.getMessage();
  64. }
  65. }
  66. @Test
  67. public void testGetFaceDB(){
  68. try {
  69. DeviceInfo deviceInfo = new DeviceInfo();
  70. deviceInfo.setIpAddress("192.168.11.13");
  71. deviceInfo.setPort("80");
  72. lapiService.getFaceDbId(deviceInfo,"荆鹏软件");
  73. System.out.println();
  74. } catch (Exception e) {
  75. e.printStackTrace();
  76. String message = e.getMessage();
  77. }
  78. }
  79. @Test
  80. public void testDeletPerson(){
  81. try {
  82. List<LapiMsgResult> result = lapiService.deletePerson(1111L);
  83. System.out.println(result);
  84. } catch (Exception e) {
  85. e.printStackTrace();
  86. String message = e.getMessage();
  87. }
  88. }
  89. @Test
  90. public void testDeletDevicePerson(){
  91. try {
  92. List<LapiMsgResult> result = lapiService.deleteDevicePerson(10013L,"9f254a38-2b6c-4169-a53c-765ec5e16c51");
  93. System.out.println(result);
  94. } catch (Exception e) {
  95. e.printStackTrace();
  96. String message = e.getMessage();
  97. }
  98. }
  99. @Test
  100. public void testRemoteOpened(){
  101. try {
  102. Boolean success = lapiService.phoneOpenDoor("4b40b1e3-57b9-4119-828e-9d42d56e5b57");
  103. System.out.println(success);
  104. } catch (Exception e) {
  105. e.printStackTrace();
  106. String message = e.getMessage();
  107. }
  108. }
  109. @Test
  110. public void testReBoot(){
  111. try {
  112. Boolean success = lapiService.phoneOpenDoor("4b40b1e3-57b9-4119-828e-9d42d56e5b57");
  113. System.out.println(success);
  114. } catch (Exception e) {
  115. e.printStackTrace();
  116. String message = e.getMessage();
  117. }
  118. }
  119. @Test
  120. public void testAddLibrary(){
  121. try {
  122. List<LapiResult> list = lapiService.addCompanyLib("c6083ba7-6025-11ea-9760-f0761c318e91","4b40b1e3-57b9-4119-828e-9d42d56e5b57");
  123. System.out.println(list);
  124. } catch (Exception e) {
  125. e.printStackTrace();
  126. String message = e.getMessage();
  127. }
  128. }
  129. @Test
  130. public void testDeleteLibrary(){
  131. try {
  132. LapiResult lapiResult = lapiService.deleteCompanyLib("4b40b1e3-57b9-4119-828e-9d42d56e5b57","1584502940");
  133. System.out.println(lapiResult);
  134. } catch (Exception e) {
  135. e.printStackTrace();
  136. String message = e.getMessage();
  137. }
  138. }
  139. @Test
  140. public void testUpdateCompanyLib(){
  141. try {
  142. LapiResult lapiResult = lapiService.updateCompanyLib("c6083ba7-6025-11ea-9760-f0761c318e91","4b40b1e3-57b9-4119-828e-9d42d56e5b57","1584429125");
  143. System.out.println(lapiResult);
  144. } catch (Exception e) {
  145. e.printStackTrace();
  146. String message = e.getMessage();
  147. }
  148. }
  149. @Test
  150. public void testDeleteDeviceAllCompanyLib(){
  151. try {
  152. List<LapiResult> list = lapiService.deleteDeviceAllCompanyLib("4b40b1e3-57b9-4119-828e-9d42d56e5b57");
  153. System.out.println(list);
  154. } catch (Exception e) {
  155. e.printStackTrace();
  156. String message = e.getMessage();
  157. }
  158. }
  159. @Test
  160. public void testWarningPushFindByIdList(){
  161. try {
  162. String ids = "c6083b40-6025-11ea-9760-f0761c318e92,5cebd719-9e0e-4f0b-8414-4d7abe430ebf";
  163. List<String> idList = Arrays.asList(ids.split(","));
  164. List<WarningPusher> list = warningPusherDAO.findByCompanyIdList(idList);
  165. System.out.println(list);
  166. } catch (Exception e) {
  167. e.printStackTrace();
  168. String message = e.getMessage();
  169. }
  170. }
  171. @Test
  172. public void testSendTemperatureAlarmsyncTask(){
  173. try {
  174. // WechatMessageUtil.sendTemperatureAlarmInfo("oLowyuOQ9ULF3LUGt6h3fTrsnbVE","荆鹏软件_门房考勤机","wx0b3c41a903053808","43557bd62f77b0c3d6670e991872f0e7","Mg9Ldk_kaoHAUwXFHEatrGugTlOz3yrMmMk7VoBca4M");
  175. PersonDeviceLog personDeviceLog = new PersonDeviceLog();
  176. personDeviceLog.setDeviceNo("210235C4C33203000165");
  177. personDeviceLog.setPersonId(11622);
  178. personDeviceLog.setRecordTime(new Date());
  179. personDeviceLog.setId("000733db-2945-4a1f-862f-86c24b50f84c");
  180. personDeviceLogService.sendTemperatureAlarmsyncTask(personDeviceLog);
  181. } catch (Exception e) {
  182. e.printStackTrace();
  183. String message = e.getMessage();
  184. }
  185. }
  186. @Test
  187. public void testgetDeviceRule(){
  188. try {
  189. Map<String,Object> map= lapiService.getDeviceRule("32acfc7d-e7d4-4ebb-8170-035d00dc92a8");
  190. System.out.println(map);
  191. } catch (Exception e) {
  192. e.printStackTrace();
  193. String message = e.getMessage();
  194. }
  195. }
  196. @Test
  197. public void testSetDeviceRule(){
  198. try {
  199. redisService.put("personInfo","11130","99898",-1);
  200. // List list = redisService.getAll("personInfo");
  201. // Boolean success = lapiService.setDeviceRule("32acfc7d-e7d4-4ebb-8170-035d00dc92a8",0,1,1,1,new BigDecimal(30),new BigDecimal(45),new BigDecimal(37.3));
  202. // System.out.println(list);
  203. } catch (Exception e) {
  204. e.printStackTrace();
  205. String message = e.getMessage();
  206. }
  207. }
  208. @Test
  209. public void testFindLastPersonLogByCompanyList(){
  210. try {
  211. List<CompanyInfo> list = companyInfoService.list();
  212. Page<PersonDeviceLog> personDeviceLogList = personDeviceLogService.findLastPersonLogByCompanyList(DateUtil.beginOfDay(new Date()), DateUtil.endOfDay(new Date()), list,0,1);
  213. System.out.println(personDeviceLogList);
  214. } catch (Exception e) {
  215. e.printStackTrace();
  216. String message = e.getMessage();
  217. }
  218. }
  219. @Test
  220. public void testGetDeviceDateServer(){
  221. try {
  222. lapiService.getDeviceDateServer("210235C4C53203006756");
  223. System.out.println("11");
  224. } catch (Exception e) {
  225. e.printStackTrace();
  226. String message = e.getMessage();
  227. }
  228. }
  229. }