修改设备配置、参数组配置的bug
This commit is contained in:
parent
2de2689f00
commit
1a63de8b7d
@ -3,9 +3,13 @@ package com.imdroid.secapi.dto;
|
|||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Select;
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
import org.apache.ibatis.annotations.Update;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface GnssDeviceMapper extends BaseMapper<GnssDevice> {
|
public interface GnssDeviceMapper extends BaseMapper<GnssDevice> {
|
||||||
@Select({"select * from gnssdevices where deviceid = #{deviceId} limit 1"})
|
@Select({"select * from gnssdevices where deviceid = #{deviceId} limit 1"})
|
||||||
GnssDevice queryByDeviceId(String deviceId);
|
GnssDevice queryByDeviceId(String deviceId);
|
||||||
|
|
||||||
|
@Update({"update gnssdevices set syn=false where group_id=#{group_id}"})
|
||||||
|
int setSynFlagByGroupId(int group_id);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,4 +35,12 @@ public class GnssGroup implements Serializable {
|
|||||||
+HexUtil.Byte2HexString((byte) power_mode.shortValue());
|
+HexUtil.Byte2HexString((byte) power_mode.shortValue());
|
||||||
return cmd;
|
return cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean equals(GnssGroup group){
|
||||||
|
return (this.work_cycle.equals(group.work_cycle) &&
|
||||||
|
this.active_time.equals(group.active_time) &&
|
||||||
|
this.active_offset.equals(group.active_offset) &&
|
||||||
|
this.rs_adv.equals(group.rs_adv) &&
|
||||||
|
this.power_mode.equals(group.power_mode));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -127,7 +127,7 @@ public class GnssDeviceController extends BasicController{
|
|||||||
//新增或更新
|
//新增或更新
|
||||||
int num = 0;
|
int num = 0;
|
||||||
if(null != old_device) {
|
if(null != old_device) {
|
||||||
if(old_device.getGroup_id()!=device.getGroup_id()){
|
if(!old_device.getGroup_id().equals(device.getGroup_id())){
|
||||||
device.setSyn(false);
|
device.setSyn(false);
|
||||||
}
|
}
|
||||||
device.setId(old_device.getId());
|
device.setId(old_device.getId());
|
||||||
@ -144,10 +144,67 @@ public class GnssDeviceController extends BasicController{
|
|||||||
if (num == 0) {
|
if (num == 0) {
|
||||||
return HttpResult.failed();
|
return HttpResult.failed();
|
||||||
} else {
|
} else {
|
||||||
|
// 更新组参数的关联个数
|
||||||
|
updateBasicGroupAssociatedNum(device,old_device);
|
||||||
return HttpResult.ok();
|
return HttpResult.ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateBasicGroupAssociatedNum(GnssDevice newCfg, GnssDevice oldCfg){
|
||||||
|
updateBasicGroupAssociatedNum(newCfg.getGroup_id());
|
||||||
|
updateCalcGroupAssociatedNum(newCfg.getCalc_group_id());
|
||||||
|
updateFwdGroupAssociatedNum(newCfg.getFwd_group_id());
|
||||||
|
|
||||||
|
if(oldCfg!=null){
|
||||||
|
if(!oldCfg.getGroup_id().equals(newCfg.getGroup_id())){
|
||||||
|
updateBasicGroupAssociatedNum(oldCfg.getGroup_id());
|
||||||
|
}
|
||||||
|
if(!oldCfg.getCalc_group_id().equals(newCfg.getCalc_group_id())){
|
||||||
|
updateCalcGroupAssociatedNum(oldCfg.getCalc_group_id());
|
||||||
|
}
|
||||||
|
if(!oldCfg.getFwd_group_id().equals(newCfg.getFwd_group_id())){
|
||||||
|
updateFwdGroupAssociatedNum(oldCfg.getFwd_group_id());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateBasicGroupAssociatedNum(int groupId) {
|
||||||
|
// 更新基本参数组
|
||||||
|
QueryWrapper<GnssDevice> queryWrapper = new QueryWrapper<>();
|
||||||
|
|
||||||
|
queryWrapper.eq("group_id", groupId);
|
||||||
|
Long groupAssociatedNum = gnssDeviceMapper.selectCount(queryWrapper);
|
||||||
|
GnssGroup group = gnssGroupMapper.selectById(groupId);
|
||||||
|
if (group != null) {
|
||||||
|
group.setDevice_num(groupAssociatedNum.intValue());
|
||||||
|
gnssGroupMapper.updateById(group);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateCalcGroupAssociatedNum(int groupId) {
|
||||||
|
// 更新解算参数组
|
||||||
|
QueryWrapper<GnssDevice> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("calc_group_id", groupId);
|
||||||
|
Long groupAssociatedNum = gnssDeviceMapper.selectCount(queryWrapper);
|
||||||
|
GnssGroupCalc group = gnssGroupCalcMapper.selectById(groupId);
|
||||||
|
if (group != null) {
|
||||||
|
group.setDevice_num(groupAssociatedNum.intValue());
|
||||||
|
gnssGroupCalcMapper.updateById(group);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateFwdGroupAssociatedNum(int groupId) {
|
||||||
|
// 更新推送参数组
|
||||||
|
QueryWrapper<GnssDevice> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("fwd_group_id", groupId);
|
||||||
|
Long groupAssociatedNum = gnssDeviceMapper.selectCount(queryWrapper);
|
||||||
|
GnssGroupFwd group = gnssGroupFwdMapper.selectById(groupId);
|
||||||
|
if(group!=null) {
|
||||||
|
group.setDevice_num(groupAssociatedNum.intValue());
|
||||||
|
gnssGroupFwdMapper.updateById(group);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/gnss/device/delete")
|
@PostMapping("/gnss/device/delete")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String delete(@RequestParam String del_id) throws Exception {
|
public String delete(@RequestParam String del_id) throws Exception {
|
||||||
|
|||||||
@ -18,6 +18,9 @@ public class GnssGroupController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
GnssGroupFwdMapper gnssGroupFwdMapper;
|
GnssGroupFwdMapper gnssGroupFwdMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
GnssDeviceMapper deviceMapper;
|
||||||
|
|
||||||
/********* 推送页面 *********/
|
/********* 推送页面 *********/
|
||||||
@RequestMapping("/page/table/gnss_add_group")
|
@RequestMapping("/page/table/gnss_add_group")
|
||||||
public String gnssAddGroup() {
|
public String gnssAddGroup() {
|
||||||
@ -59,7 +62,12 @@ public class GnssGroupController {
|
|||||||
public String update(@RequestBody JSONObject object) throws Exception {
|
public String update(@RequestBody JSONObject object) throws Exception {
|
||||||
int num = 0;
|
int num = 0;
|
||||||
GnssGroup group = JSONObject.toJavaObject(object,GnssGroup.class);
|
GnssGroup group = JSONObject.toJavaObject(object,GnssGroup.class);
|
||||||
if(null != gnssGroupMapper.selectById(group.getId())) {
|
GnssGroup oldGroup = gnssGroupMapper.selectById(group.getId());
|
||||||
|
|
||||||
|
// no changed
|
||||||
|
if(oldGroup != null && oldGroup.equals(group)) return HttpResult.ok();
|
||||||
|
|
||||||
|
if(null != oldGroup) {
|
||||||
num = gnssGroupMapper.updateById(group);
|
num = gnssGroupMapper.updateById(group);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@ -67,12 +75,23 @@ public class GnssGroupController {
|
|||||||
}
|
}
|
||||||
if (num == 0) {
|
if (num == 0) {
|
||||||
return HttpResult.failed();
|
return HttpResult.failed();
|
||||||
} else return HttpResult.ok();
|
} else{
|
||||||
|
// 更新所有的device同步标志
|
||||||
|
deviceMapper.setSynFlagByGroupId(group.getId());
|
||||||
|
return HttpResult.ok();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/gnss/group/delete")
|
@PostMapping("/gnss/group/delete")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String delete(@RequestParam int del_id) throws Exception {
|
public String delete(@RequestParam int del_id) throws Exception {
|
||||||
|
GnssGroup group = gnssGroupMapper.selectById(del_id);
|
||||||
|
if(group == null) return HttpResult.failed();
|
||||||
|
|
||||||
|
if(group.getDevice_num() >0){
|
||||||
|
return HttpResult.result(HttpResult.HTTP_RSP_FAILED,"this group is in used");
|
||||||
|
}
|
||||||
|
|
||||||
int num = gnssGroupMapper.deleteById(del_id);
|
int num = gnssGroupMapper.deleteById(del_id);
|
||||||
if (num == 0) {
|
if (num == 0) {
|
||||||
return HttpResult.failed();
|
return HttpResult.failed();
|
||||||
@ -113,6 +132,13 @@ public class GnssGroupController {
|
|||||||
@PostMapping("/gnss/group/delete_calc")
|
@PostMapping("/gnss/group/delete_calc")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String deleteCalc(@RequestParam int del_id) {
|
public String deleteCalc(@RequestParam int del_id) {
|
||||||
|
GnssGroupCalc group = gnssGroupCalcMapper.selectById(del_id);
|
||||||
|
if(group == null) return HttpResult.failed();
|
||||||
|
|
||||||
|
if(group.getDevice_num() >0){
|
||||||
|
return HttpResult.result(HttpResult.HTTP_RSP_FAILED,"this group is in used");
|
||||||
|
}
|
||||||
|
|
||||||
int num = gnssGroupCalcMapper.deleteById(del_id);
|
int num = gnssGroupCalcMapper.deleteById(del_id);
|
||||||
if (num == 0) {
|
if (num == 0) {
|
||||||
return HttpResult.failed();
|
return HttpResult.failed();
|
||||||
@ -153,6 +179,13 @@ public class GnssGroupController {
|
|||||||
@PostMapping("/gnss/group/delete_fwd")
|
@PostMapping("/gnss/group/delete_fwd")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String deleteFwd(@RequestParam int del_id) {
|
public String deleteFwd(@RequestParam int del_id) {
|
||||||
|
GnssGroupFwd group = gnssGroupFwdMapper.selectById(del_id);
|
||||||
|
if(group == null) return HttpResult.failed();
|
||||||
|
|
||||||
|
if(group.getDevice_num() >0){
|
||||||
|
return HttpResult.result(HttpResult.HTTP_RSP_FAILED,"this group is in used");
|
||||||
|
}
|
||||||
|
|
||||||
int num = gnssGroupFwdMapper.deleteById(del_id);
|
int num = gnssGroupFwdMapper.deleteById(del_id);
|
||||||
if (num == 0) {
|
if (num == 0) {
|
||||||
return HttpResult.failed();
|
return HttpResult.failed();
|
||||||
|
|||||||
@ -1,64 +0,0 @@
|
|||||||
{
|
|
||||||
"code": 0,
|
|
||||||
"msg": "",
|
|
||||||
"count": 1000,
|
|
||||||
"data": [
|
|
||||||
{
|
|
||||||
"deviceid": "2307001",
|
|
||||||
"report_time": "2023-01-01 12:23:56",
|
|
||||||
"b562e": "22.12",
|
|
||||||
"b562n": "10.24",
|
|
||||||
"b562d": "5.1",
|
|
||||||
"roll": "0.1",
|
|
||||||
"pitch": "0.2",
|
|
||||||
"yaw": "90.1",
|
|
||||||
"resulte": "22.13",
|
|
||||||
"resultn": "10.11",
|
|
||||||
"resultd": "5.2",
|
|
||||||
"rb562e": "22.13",
|
|
||||||
"rb562n": "10.11",
|
|
||||||
"rb562d": "5.2",
|
|
||||||
"pps": "512",
|
|
||||||
"sat_count": "24",
|
|
||||||
"sat_used": "10"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"deviceid": "2307001",
|
|
||||||
"report_time": "2023-01-01 12:23:56",
|
|
||||||
"b562e": "22.12",
|
|
||||||
"b562n": "10.24",
|
|
||||||
"b562d": "5.1",
|
|
||||||
"roll": "0.1",
|
|
||||||
"pitch": "0.2",
|
|
||||||
"yaw": "90.1",
|
|
||||||
"resulte": "22.13",
|
|
||||||
"resultn": "10.11",
|
|
||||||
"resultd": "5.2",
|
|
||||||
"rb562e": "22.13",
|
|
||||||
"rb562n": "10.11",
|
|
||||||
"rb562d": "5.2",
|
|
||||||
"pps": "512",
|
|
||||||
"sat_count": "24",
|
|
||||||
"sat_used": "10"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"deviceid": "2307001",
|
|
||||||
"report_time": "2023-01-01 12:23:56",
|
|
||||||
"b562e": "22.12",
|
|
||||||
"b562n": "10.24",
|
|
||||||
"b562d": "5.1",
|
|
||||||
"roll": "0.1",
|
|
||||||
"pitch": "0.2",
|
|
||||||
"yaw": "90.1",
|
|
||||||
"resulte": "22.13",
|
|
||||||
"resultn": "10.11",
|
|
||||||
"resultd": "5.2",
|
|
||||||
"rb562e": "22.13",
|
|
||||||
"rb562n": "10.11",
|
|
||||||
"rb562d": "5.2",
|
|
||||||
"pps": "512",
|
|
||||||
"sat_count": "24",
|
|
||||||
"sat_used": "10"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@ -1,23 +0,0 @@
|
|||||||
{
|
|
||||||
"code": 0,
|
|
||||||
"msg": "",
|
|
||||||
"count": 16,
|
|
||||||
"data": [
|
|
||||||
{ "id":"001", "username":"张玉林", "sex":"女" },
|
|
||||||
{ "id":"002", "username":"刘晓军", "sex":"男" },
|
|
||||||
{ "id":"003", "username":"张恒", "sex":"男" },
|
|
||||||
{ "id":"004", "username":"朱一", "sex":"男" },
|
|
||||||
{ "id":"005", "username":"刘佳能", "sex":"女" },
|
|
||||||
{ "id":"006", "username":"晓梅", "sex":"女" },
|
|
||||||
{ "id":"007", "username":"马冬梅", "sex":"女" },
|
|
||||||
{ "id":"008", "username":"刘晓庆", "sex":"女" },
|
|
||||||
{ "id":"009", "username":"刘晓庆", "sex":"女" },
|
|
||||||
{ "id":"010", "username":"刘晓庆", "sex":"女" },
|
|
||||||
{ "id":"011", "username":"刘晓庆", "sex":"女" },
|
|
||||||
{ "id":"012", "username":"刘晓庆", "sex":"女" },
|
|
||||||
{ "id":"013", "username":"刘晓庆", "sex":"女" },
|
|
||||||
{ "id":"014", "username":"刘晓庆", "sex":"女" },
|
|
||||||
{ "id":"015", "username":"刘晓庆", "sex":"女" },
|
|
||||||
{ "id":"016", "username":"刘晓庆", "sex":"女" }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user