Commit ae6dec26 by 刘宇峰

围栏同步

1 parent 9e457ce8
...@@ -128,8 +128,8 @@ public class ElectricFenceController { ...@@ -128,8 +128,8 @@ public class ElectricFenceController {
@GetMapping(value = "/syncdata") @GetMapping(value = "/syncdata")
@ApiOperation(value = "同步围栏到数据侧") @ApiOperation(value = "同步围栏到数据侧")
public R syncData(@RequestParam("fenceId") Long fenceId) { public R syncData(@RequestParam("fenceIds") List<Long> fenceIds) {
electricFenceService.syncFence(fenceId); electricFenceService.syncFences(fenceIds);
return R.ok(); return R.ok();
} }
......
...@@ -24,6 +24,10 @@ public interface ElectricFenceMapper extends CommonBaseMapper<ElectricFence> { ...@@ -24,6 +24,10 @@ public interface ElectricFenceMapper extends CommonBaseMapper<ElectricFence> {
List<ElectricFence> selectAllNotDel(); List<ElectricFence> selectAllNotDel();
List<ElectricFence> selectAllNotSync();
int updateSyncFlagById(@Param("id") Long id);
ElectricFence selectByFenceNameAndBizType(@Param("fenceName") String fenceName, @Param("bizFenceType") Integer bizFenceType); ElectricFence selectByFenceNameAndBizType(@Param("fenceName") String fenceName, @Param("bizFenceType") Integer bizFenceType);
/** /**
......
...@@ -568,19 +568,27 @@ public class ElectricFenceService { ...@@ -568,19 +568,27 @@ public class ElectricFenceService {
} }
public void syncAllFences() { public void syncAllFences() {
List<ElectricFence> fenceList = electricFenceMapper.selectAllNotDel(); List<ElectricFence> fenceList = electricFenceMapper.selectAllNotSync();
fenceList.forEach(fence -> { fenceList.forEach(fence -> {
System.out.println(JSON.toJSONString(fence)); log.info(JSON.toJSONString(fence));
eFenceComponent.addElectricFence(fence); eFenceComponent.addElectricFence(fence);
electricFenceMapper.updateSyncFlagById(fence.getId());
}); });
} }
public void syncFence(Long fenceId) { public void syncFences(List<Long> fenceIds) {
ElectricFence fence = electricFenceMapper.selectById(fenceId); fenceIds.forEach(fenceId -> {
if (fence != null) { ElectricFence fence = electricFenceMapper.selectById(fenceId);
System.out.println(JSON.toJSONString(fence)); if (fence != null) {
eFenceComponent.addElectricFence(fence); log.info(JSON.toJSONString(fence));
}
eFenceComponent.addElectricFence(fence);
electricFenceMapper.updateSyncFlagById(fence.getId());
}
});
} }
} }
...@@ -69,6 +69,18 @@ public class TrialDriveShopService { ...@@ -69,6 +69,18 @@ public class TrialDriveShopService {
public PageInfo<TrialDriveShopDTO> search(TrialDriveShopSearch search) { public PageInfo<TrialDriveShopDTO> search(TrialDriveShopSearch search) {
Page page = PageHelper.startPage(search.getPageNumber(), search.getPageSize()); Page page = PageHelper.startPage(search.getPageNumber(), search.getPageSize());
// if (search.getArea() != null) {
// R<List<User>> byOrg = userService.findAllByOrg(new FindUserRequest().setOrgIds(Lists.newArrayList(search.getArea())));
// List<User> userList = byOrg.getDataList(new TypeToken<List<User>>() {
// }.getType());
// search.setUserIds(StringUtils.join(userList.stream().map(User::getId).toArray(), ","));
// }
// if (search.getProvince() != null) {
// R<List<User>> byOrg = userService.findAllByOrg(new FindUserRequest().setOrgIds(Lists.newArrayList(search.getProvince())));
// List<User> userList = byOrg.getDataList(new TypeToken<List<User>>() {
// }.getType());
// search.setUserIds(StringUtils.join(userList.stream().map(User::getId).toArray(), ","));
// }
if (search.getCity() != null) { if (search.getCity() != null) {
R<List<User>> byOrg = userService.findAllByOrg(new FindUserRequest().setOrgIds(Lists.newArrayList(search.getCity()))); R<List<User>> byOrg = userService.findAllByOrg(new FindUserRequest().setOrgIds(Lists.newArrayList(search.getCity())));
List<User> userList = byOrg.getDataList(new TypeToken<List<User>>() { List<User> userList = byOrg.getDataList(new TypeToken<List<User>>() {
...@@ -82,14 +94,6 @@ public class TrialDriveShopService { ...@@ -82,14 +94,6 @@ public class TrialDriveShopService {
} }
public List<TrialDriveShopExport> export(TrialDriveShopSearch search) { public List<TrialDriveShopExport> export(TrialDriveShopSearch search) {
if (search.getCity() != null) {
R<List<User>> byOrg = userService.findAllByOrg(new FindUserRequest().setOrgIds(Lists.newArrayList(search.getCity())));
List<User> userList = byOrg.getDataList(new TypeToken<List<User>>() {
}.getType());
search.setUserIds(StringUtils.join(userList.stream().map(User::getId).toArray(), ","));
}
List<TrialDriveShopExport> list = trialDriveShopMapper.export(search); List<TrialDriveShopExport> list = trialDriveShopMapper.export(search);
organizaService.drawOrganization(list); organizaService.drawOrganization(list);
return list; return list;
......
...@@ -77,6 +77,21 @@ ...@@ -77,6 +77,21 @@
where del_flag = 0 where del_flag = 0
</select> </select>
<select id="selectAllNotSync" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>,
<include refid="Blob_Column_List"/>
from t_electric_fence
where del_flag = 0
and sync_flag = 0
</select>
<update id="updateSyncFlagById">
update t_electric_fence
set sync_flag = 1
where id = #{id}
</update>
<select id="search" resultType="cn.com.glsx.admin.modules.model.ElectricFenceDTO"> <select id="search" resultType="cn.com.glsx.admin.modules.model.ElectricFenceDTO">
select tef.id fenceId, select tef.id fenceId,
tef.fence_name fenceName, tef.fence_name fenceName,
...@@ -92,7 +107,8 @@ ...@@ -92,7 +107,8 @@
left join t_user tu on tu.id = tef.created_by left join t_user tu on tu.id = tef.created_by
left join t_trial_drive_shop ttds on ttds.created_by = tu.id and ttds.del_flag = 0 left join t_trial_drive_shop ttds on ttds.created_by = tu.id and ttds.del_flag = 0
left join t_electric_fence_copy tefc on tefc.fence_id = tef.id left join t_electric_fence_copy tefc on tefc.fence_id = tef.id
left join (select * from t_approval where id in (select MAX(id) from t_approval group by biz_id,biz_type)) ta on ta.biz_id = tefc.id and ta.biz_type = 1 left join (select * from t_approval where id in (select MAX(id) from t_approval group by biz_id,biz_type)) ta on
ta.biz_id = tefc.id and ta.biz_type = 1
where tef.del_flag = 0 where tef.del_flag = 0
and tef.biz_fence_type = 12 and tef.biz_fence_type = 12
<if test="term != null and term !=''"> <if test="term != null and term !=''">
...@@ -122,7 +138,8 @@ ...@@ -122,7 +138,8 @@
left join t_user tu on tu.id = tef.created_by left join t_user tu on tu.id = tef.created_by
left join t_trial_drive_shop ttds on ttds.created_by = tu.id left join t_trial_drive_shop ttds on ttds.created_by = tu.id
left join t_electric_fence_copy tefc on tefc.fence_id = tef.id left join t_electric_fence_copy tefc on tefc.fence_id = tef.id
left join (select * from t_approval where id in (select MAX(id) from t_approval group by biz_id,biz_type)) ta on ta.biz_id = tefc.id and ta.biz_type = 1 left join (select * from t_approval where id in (select MAX(id) from t_approval group by biz_id,biz_type)) ta on
ta.biz_id = tefc.id and ta.biz_type = 1
where tef.del_flag = 0 and ttds.del_flag = 0 where tef.del_flag = 0 and ttds.del_flag = 0
and tef.biz_fence_type = 12 and tef.biz_fence_type = 12
<if test="term != null and term !=''"> <if test="term != null and term !=''">
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!