123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- package com.szwl.controller;
- import com.szwl.feign.bean.SyncOldFeign;
- import com.szwl.model.bo.R;
- import com.szwl.model.bo.ResponseModel;
- import com.szwl.model.entity.TAdmin;
- import com.szwl.model.entity.TEquipment;
- import com.szwl.service.TAdminService;
- import com.szwl.service.TEquipmentService;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import lombok.extern.slf4j.Slf4j;
- import org.apache.commons.lang.StringUtils;
- import org.springframework.web.bind.annotation.*;
- import java.lang.annotation.ElementType;
- import java.util.Map;
- import java.util.Optional;
- @Slf4j
- @Api(value = "/syncOldAll", tags = {"根据设备&用户同步旧系统数据"})
- @RestController
- @RequestMapping("/syncOldAll")
- public class SyncOldAllController {
- SyncOldFeign syncOldFeign;
- TAdminService adminService;
- TEquipmentService equipmentService;
- public SyncOldAllController(SyncOldFeign syncOldFeign, TAdminService adminService, TEquipmentService equipmentService) {
- this.syncOldFeign = syncOldFeign;
- this.adminService = adminService;
- this.equipmentService = equipmentService;
- }
- // @ApiOperation(value = "")
- // @GetMapping("/getAllDataByAdminIdClientId")
- // public ResponseModel<?> getAllDataByAdminIdClientId(Long adminId, String clientId) {
- // if (StringUtils.isEmpty(clientId) || adminId == null) {
- // return R.fail("参数不能为空");
- // }
- //
- // // 先设置这个账户的权限
- // String s = adminService.addSysRole(adminId);
- // if ("success".equals(s)) {
- //// return R.ok("添加" + adminId + "的权限成功");
- // } else {
- // return R.fail("设备权限失败");
- // }
- //
- // // 同步该设备信息
- // Optional<String> result = equipmentService.syncOneEquipmentByClientId(clientId);
- // if (result.isPresent() && "success".equals(result.get())) {
- // return R.ok("同步设备编号" + clientId + "的 equipment 信息成功");
- // } else {
- // return R.fail("同步设备数据失败");
- // }
- //
- //
- //// if("success".equals(s1)) {
- //// return R.ok();
- ////
- //// }
- //// if ("success".equals(s1)) {
- //// return R.ok("同步设备编号" + clientId + "的 equipment 信息成功");
- //// } else {
- //// return R.fail("设备权限失败");
- //// }
- //
- //
- // // 同步花型
- //
- // // 同步分销
- //
- // // 同步汇聚支付
- //
- // // 同步订单
- //
- //// return R.ok();
- // }
- @ApiOperation(value = "根据设备同步旧系统所有数据")
- @PostMapping("/byClient")
- public ResponseModel<?> byClient(@RequestBody Map<String, String> params) {
- // 查询 2023-03-19 开始到现在的所有表信息
- String clientId = params.get("clientId");
- String adminId = params.get("adminId");
- // 查旧系统的admin信息
- // ResponseModel<?> adminOld = syncOldFeign.getAdminById(adminId);
- // adminOld.getData();
- // 查旧系统的equipment信息
- syncOldFeign.getEquipmentByClientId(clientId);
- // 插入到新系统数据库
- TAdmin adminNew = new TAdmin();
- TEquipment equipmentNew = new TEquipment();
- TAdmin adminOld = R.getDataIfSuccess(syncOldFeign.getAdminById(adminId));
- // System.out.println(adminOld);
- adminService.saveOrUpdate(adminOld);
- return R.ok("同步成功");
- }
- @ApiOperation(value = "同步某一时间段内的所有数据")
- @PostMapping("/inTime")
- public ResponseModel<?> inTime(@RequestBody Map<String, String> params) {
- return R.ok("同步成功");
- }
- }
|