SyncOldAllController.java 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. package com.szwl.controller;
  2. import com.szwl.feign.bean.SyncOldFeign;
  3. import com.szwl.model.bo.R;
  4. import com.szwl.model.bo.ResponseModel;
  5. import com.szwl.model.entity.TAdmin;
  6. import com.szwl.model.entity.TEquipment;
  7. import com.szwl.service.TAdminService;
  8. import com.szwl.service.TEquipmentService;
  9. import io.swagger.annotations.Api;
  10. import io.swagger.annotations.ApiOperation;
  11. import lombok.extern.slf4j.Slf4j;
  12. import org.apache.commons.lang.StringUtils;
  13. import org.springframework.web.bind.annotation.*;
  14. import java.lang.annotation.ElementType;
  15. import java.util.Map;
  16. import java.util.Optional;
  17. @Slf4j
  18. @Api(value = "/syncOldAll", tags = {"根据设备&用户同步旧系统数据"})
  19. @RestController
  20. @RequestMapping("/syncOldAll")
  21. public class SyncOldAllController {
  22. SyncOldFeign syncOldFeign;
  23. TAdminService adminService;
  24. TEquipmentService equipmentService;
  25. public SyncOldAllController(SyncOldFeign syncOldFeign, TAdminService adminService, TEquipmentService equipmentService) {
  26. this.syncOldFeign = syncOldFeign;
  27. this.adminService = adminService;
  28. this.equipmentService = equipmentService;
  29. }
  30. // @ApiOperation(value = "")
  31. // @GetMapping("/getAllDataByAdminIdClientId")
  32. // public ResponseModel<?> getAllDataByAdminIdClientId(Long adminId, String clientId) {
  33. // if (StringUtils.isEmpty(clientId) || adminId == null) {
  34. // return R.fail("参数不能为空");
  35. // }
  36. //
  37. // // 先设置这个账户的权限
  38. // String s = adminService.addSysRole(adminId);
  39. // if ("success".equals(s)) {
  40. //// return R.ok("添加" + adminId + "的权限成功");
  41. // } else {
  42. // return R.fail("设备权限失败");
  43. // }
  44. //
  45. // // 同步该设备信息
  46. // Optional<String> result = equipmentService.syncOneEquipmentByClientId(clientId);
  47. // if (result.isPresent() && "success".equals(result.get())) {
  48. // return R.ok("同步设备编号" + clientId + "的 equipment 信息成功");
  49. // } else {
  50. // return R.fail("同步设备数据失败");
  51. // }
  52. //
  53. //
  54. //// if("success".equals(s1)) {
  55. //// return R.ok();
  56. ////
  57. //// }
  58. //// if ("success".equals(s1)) {
  59. //// return R.ok("同步设备编号" + clientId + "的 equipment 信息成功");
  60. //// } else {
  61. //// return R.fail("设备权限失败");
  62. //// }
  63. //
  64. //
  65. // // 同步花型
  66. //
  67. // // 同步分销
  68. //
  69. // // 同步汇聚支付
  70. //
  71. // // 同步订单
  72. //
  73. //// return R.ok();
  74. // }
  75. @ApiOperation(value = "根据设备同步旧系统所有数据")
  76. @PostMapping("/byClient")
  77. public ResponseModel<?> byClient(@RequestBody Map<String, String> params) {
  78. // 查询 2023-03-19 开始到现在的所有表信息
  79. String clientId = params.get("clientId");
  80. String adminId = params.get("adminId");
  81. // 查旧系统的admin信息
  82. // ResponseModel<?> adminOld = syncOldFeign.getAdminById(adminId);
  83. // adminOld.getData();
  84. // 查旧系统的equipment信息
  85. syncOldFeign.getEquipmentByClientId(clientId);
  86. // 插入到新系统数据库
  87. TAdmin adminNew = new TAdmin();
  88. TEquipment equipmentNew = new TEquipment();
  89. TAdmin adminOld = R.getDataIfSuccess(syncOldFeign.getAdminById(adminId));
  90. // System.out.println(adminOld);
  91. adminService.saveOrUpdate(adminOld);
  92. return R.ok("同步成功");
  93. }
  94. @ApiOperation(value = "同步某一时间段内的所有数据")
  95. @PostMapping("/inTime")
  96. public ResponseModel<?> inTime(@RequestBody Map<String, String> params) {
  97. return R.ok("同步成功");
  98. }
  99. }