Commit af74f424 authored by 赵啸非's avatar 赵啸非

修改同步业务逻辑

parent eaaf96bf
Pipeline #2870 canceled with stages
...@@ -4,6 +4,7 @@ import lombok.Data; ...@@ -4,6 +4,7 @@ import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.List;
@Data @Data
...@@ -135,4 +136,7 @@ public class DeviceReq implements Serializable { ...@@ -135,4 +136,7 @@ public class DeviceReq implements Serializable {
*/ */
private String deviceVersion; private String deviceVersion;
private List<Long> siteIdList;
} }
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
</activation> </activation>
<properties> <properties>
<profiles.active>develop</profiles.active> <profiles.active>develop</profiles.active>
<profiles.nacos.server-addr>192.168.0.252:8848</profiles.nacos.server-addr> <profiles.nacos.server-addr>127.0.0.1:8848</profiles.nacos.server-addr>
</properties> </properties>
</profile> </profile>
<profile> <profile>
......
...@@ -11,15 +11,21 @@ import com.mortals.xhx.common.pdu.device.DeviceReq; ...@@ -11,15 +11,21 @@ import com.mortals.xhx.common.pdu.device.DeviceReq;
import com.mortals.xhx.module.device.model.DeviceEntity; import com.mortals.xhx.module.device.model.DeviceEntity;
import com.mortals.xhx.module.device.model.DeviceQuery; import com.mortals.xhx.module.device.model.DeviceQuery;
import com.mortals.xhx.module.device.service.DeviceService; import com.mortals.xhx.module.device.service.DeviceService;
import com.mortals.xhx.module.matter.model.MatterDatumEntity;
import com.mortals.xhx.module.matter.model.MatterDatumQuery;
import com.mortals.xhx.module.matter.model.MatterEntity;
import com.mortals.xhx.module.matter.model.MatterQuery;
import com.mortals.xhx.module.matter.service.MatterDatumService;
import com.mortals.xhx.module.matter.service.MatterService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List;
import static com.mortals.xhx.common.key.ErrorCode.*; import static com.mortals.xhx.common.key.ErrorCode.*;
...@@ -30,6 +36,46 @@ public class DeviceCallbackController { ...@@ -30,6 +36,46 @@ public class DeviceCallbackController {
@Autowired @Autowired
private DeviceService deviceService; private DeviceService deviceService;
@Autowired
private MatterService matterService;
@Autowired
private MatterDatumService matterDatumService;
@GetMapping("copy")
@UnAuth
public void copy() {
List<MatterEntity> matterEntityList = matterService.find(new MatterQuery().siteId(1L));
List<Long> siteIdList = Arrays.asList(6L,7L);
for (Long copySiteId : siteIdList) {
for (MatterEntity matterEntity : matterEntityList) {
MatterDatumEntity matterDatumEntity = matterDatumService.selectOne(new MatterDatumQuery().matterId(matterEntity.getId()));
matterEntity.setId(null);
matterEntity.setSiteId(copySiteId);
matterService.save(matterEntity);
matterDatumEntity.setMatterId(matterEntity.getId());
matterDatumEntity.setId(null);
matterDatumEntity.setSiteId(copySiteId);
matterDatumService.save(matterDatumEntity);
}
}
}
@PostMapping("callback") @PostMapping("callback")
@UnAuth @UnAuth
......
...@@ -75,8 +75,7 @@ Content-Type: application/json ...@@ -75,8 +75,7 @@ Content-Type: application/json
###站点树 ###站点树
GET {{baseUrl}}/site/siteTree GET {{baseUrl}}//api/device/copy
Authorization: {{authToken}}
Content-Type: application/json Content-Type: application/json
{} {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment