1、消防资源测试问题

main
shenzhidan 2026-02-24 08:49:16 +08:00
parent ab348c41c3
commit e233a762c6
15 changed files with 131 additions and 72 deletions

View File

@ -1,9 +1,10 @@
package com.zcloud.zcGbsServicer.command;
import cn.hutool.core.util.StrUtil;
import com.alibaba.cola.exception.BizException;
import com.zcloud.zcGbsServicer.domain.enums.DeviceTypeEnum;
import com.zcloud.zcGbsServicer.domain.enums.PersonTypeEnum;
import com.zcloud.zcGbsServicer.domain.gateway.ControlRoomGateway;
import com.alibaba.cola.exception.BizException;
import com.zcloud.zcGbsServicer.domain.gateway.ResourceDeviceGateway;
import com.zcloud.zcGbsServicer.domain.gateway.ResourcePersonGateway;
import com.zcloud.zcGbsServicer.persistence.dataobject.ControlRoomDO;
@ -12,8 +13,10 @@ import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* web-app
@ -31,10 +34,15 @@ public class ControlRoomRemoveExe {
@Transactional(rollbackFor = Exception.class)
public boolean execute(Long id) {
ControlRoomDO controlRoomDO = controlRoomRepository.getById(id);
if (controlRoomDO == null) {
throw new BizException("数据不存在");
}
boolean res = controlRoomGateway.deletedControlRoomById(id);
boolean resDelPer = resourcePersonGateway.deletedResourcePersonByBizId(controlRoomDO.getRoomId(), PersonTypeEnum.CONTROL_ROOM.getCode());
boolean resDelDev = resourceDeviceGateway.deletedResourceDeviceByBizId(controlRoomDO.getRoomId(), DeviceTypeEnum.CONTROL_ROOM.getCode());
if(!res || !resDelPer || !resDelDev){
boolean resDelPer = resourcePersonGateway.deletedResourcePersonByBizId(
controlRoomDO.getRoomId(), PersonTypeEnum.CONTROL_ROOM.getCode());
boolean resDelDev = resourceDeviceGateway.deletedResourceDeviceByBizId(
controlRoomDO.getRoomId(), DeviceTypeEnum.CONTROL_ROOM.getCode());
if (!res || !resDelPer || !resDelDev) {
throw new BizException("删除失败");
}
return true;
@ -42,11 +50,28 @@ public class ControlRoomRemoveExe {
@Transactional(rollbackFor = Exception.class)
public boolean execute(Long[] ids) {
if (ids == null || ids.length == 0) {
return true;
}
List<String> roomIds = Arrays.stream(ids)
.map(controlRoomRepository::getById)
.filter(Objects::nonNull)
.map(ControlRoomDO::getRoomId)
.filter(StrUtil::isNotBlank)
.collect(Collectors.toList());
boolean res = controlRoomGateway.deletedControlRoomByIds(ids);
if(!res){
throw new BizException("删除失败");
boolean resDelPer = true;
boolean resDelDev = true;
for (String roomId : roomIds) {
resDelPer = resDelPer && resourcePersonGateway.deletedResourcePersonByBizId(
roomId, PersonTypeEnum.CONTROL_ROOM.getCode());
resDelDev = resDelDev && resourceDeviceGateway.deletedResourceDeviceByBizId(
roomId, DeviceTypeEnum.CONTROL_ROOM.getCode());
}
if (!res || !resDelPer || !resDelDev) {
throw new BizException("Delete failed");
}
return true;
}
}

View File

@ -1,13 +1,19 @@
package com.zcloud.zcGbsServicer.command;
import com.zcloud.zcGbsServicer.domain.gateway.PumpRoomGateway;
import com.alibaba.cola.exception.BizException;
import com.zcloud.zcGbsServicer.domain.enums.DeviceTypeEnum;
import com.zcloud.zcGbsServicer.domain.gateway.PumpRoomGateway;
import com.zcloud.zcGbsServicer.domain.gateway.ResourceDeviceGateway;
import com.zcloud.zcGbsServicer.persistence.dataobject.PumpRoomDO;
import com.zcloud.zcGbsServicer.persistence.repository.PumpRoomRepository;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* web-app
@ -18,11 +24,19 @@ import org.springframework.transaction.annotation.Transactional;
@AllArgsConstructor
public class PumpRoomRemoveExe {
private final PumpRoomGateway pumpRoomGateway;
private final PumpRoomRepository pumpRoomRepository;
private final ResourceDeviceGateway resourceDeviceGateway;
@Transactional(rollbackFor = Exception.class)
public boolean execute(Long id) {
PumpRoomDO pumpRoomDO = pumpRoomRepository.getById(id);
if (pumpRoomDO == null) {
throw new BizException("数据不存在");
}
boolean res = pumpRoomGateway.deletedPumpRoomById(id);
if(!res){
boolean resDelDev = resourceDeviceGateway.deletedResourceDeviceByBizId(
pumpRoomDO.getPumpRoomId(), DeviceTypeEnum.PUMP_ROOM.getCode());
if (!res || !resDelDev) {
throw new BizException("删除失败");
}
return true;
@ -30,11 +44,24 @@ public class PumpRoomRemoveExe {
@Transactional(rollbackFor = Exception.class)
public boolean execute(Long[] ids) {
if (ids == null || ids.length == 0) {
return true;
}
List<String> pumpRoomIds = Arrays.stream(ids)
.map(pumpRoomRepository::getById)
.filter(Objects::nonNull)
.map(PumpRoomDO::getPumpRoomId)
.collect(Collectors.toList());
boolean res = pumpRoomGateway.deletedPumpRoomByIds(ids);
if(!res){
throw new BizException("删除失败");
boolean resDelDev = true;
for (String pumpRoomId : pumpRoomIds) {
resDelDev = resDelDev && resourceDeviceGateway.deletedResourceDeviceByBizId(
pumpRoomId, DeviceTypeEnum.PUMP_ROOM.getCode());
}
if (!res || !resDelDev) {
throw new BizException("Delete failed");
}
return true;
}
}

View File

@ -28,26 +28,26 @@ public class ControlRoomAddCmd extends Command {
private String roomName;
@ApiModelProperty(value = "消防控制室状态(字典码)", name = "roomStatus", required = true)
@NotEmpty(message = "消防控制室状态(字典码)不能为空")
// @NotEmpty(message = "消防控制室状态(字典码)不能为空")
private String roomStatus;
@ApiModelProperty(value = "消防控制室状态名称")
private String roomStatusName;
@ApiModelProperty(value = "负责人", name = "principalName", required = true)
@NotEmpty(message = "负责人不能为空")
// @NotEmpty(message = "负责人不能为空")
private String principalName;
@ApiModelProperty(value = "负责人手机号", name = "principalPhone", required = true)
@NotEmpty(message = "负责人手机号不能为空")
// @NotEmpty(message = "负责人手机号不能为空")
private String principalPhone;
@ApiModelProperty(value = "经度", name = "lng", required = true)
@NotNull(message = "经度不能为空")
// @NotNull(message = "经度不能为空")
private Double lng;
@ApiModelProperty(value = "纬度", name = "lat", required = true)
@NotNull(message = "纬度不能为空")
// @NotNull(message = "纬度不能为空")
private Double lat;
@ApiModelProperty(value = "设备信息")

View File

@ -26,24 +26,24 @@ public class ControlRoomUpdateCmd extends Command {
@NotEmpty(message = "业务主键ID不能为空")
private String roomId;
@ApiModelProperty(value = "消防控制室名称", name = "roomName", required = true)
@NotEmpty(message = "消防控制室名称不能为空")
// @NotEmpty(message = "消防控制室名称不能为空")
private String roomName;
@ApiModelProperty(value = "消防控制室状态(字典码)", name = "roomStatus", required = true)
@NotEmpty(message = "消防控制室状态(字典码)不能为空")
// @NotEmpty(message = "消防控制室状态(字典码)不能为空")
private String roomStatus;
@ApiModelProperty(value = "消防控制室状态名称")
private String roomStatusName;
@ApiModelProperty(value = "负责人", name = "principalName", required = true)
@NotEmpty(message = "负责人不能为空")
// @NotEmpty(message = "负责人不能为空")
private String principalName;
@ApiModelProperty(value = "负责人手机号", name = "principalPhone", required = true)
@NotEmpty(message = "负责人手机号不能为空")
// @NotEmpty(message = "负责人手机号不能为空")
private String principalPhone;
@ApiModelProperty(value = "经度", name = "lng", required = true)
@NotNull(message = "经度不能为空")
// @NotNull(message = "经度不能为空")
private Double lng;
@ApiModelProperty(value = "纬度", name = "lat", required = true)
@NotNull(message = "纬度不能为空")
// @NotNull(message = "纬度不能为空")
private Double lat;
@ApiModelProperty(value = "人员信息")

View File

@ -28,23 +28,23 @@ public class PumpRoomAddCmd extends Command {
private String pumpRoomName;
@ApiModelProperty(value = "消防泵房状态(字典码)", name = "pumpRoomStatus", required = true)
@NotEmpty(message = "消防泵房状态(字典码)不能为空")
// @NotEmpty(message = "消防泵房状态(字典码)不能为空")
private String pumpRoomStatus;
@ApiModelProperty(value = "负责人", name = "principalName", required = true)
@NotEmpty(message = "负责人不能为空")
// @NotEmpty(message = "负责人不能为空")
private String principalName;
@ApiModelProperty(value = "负责人手机号", name = "principalPhone", required = true)
@NotEmpty(message = "负责人手机号不能为空")
// @NotEmpty(message = "负责人手机号不能为空")
private String principalPhone;
@ApiModelProperty(value = "经度", name = "lng", required = true)
@NotNull(message = "经度不能为空")
// @NotNull(message = "经度不能为空")
private Double lng;
@ApiModelProperty(value = "纬度", name = "lat", required = true)
@NotNull(message = "纬度不能为空")
// @NotNull(message = "纬度不能为空")
private Double lat;
@ApiModelProperty(value = "设备集合")

View File

@ -29,19 +29,19 @@ public class PumpRoomUpdateCmd extends Command {
@NotEmpty(message = "消防泵房名称不能为空")
private String pumpRoomName;
@ApiModelProperty(value = "消防泵房状态(字典码)", name = "pumpRoomStatus", required = true)
@NotEmpty(message = "消防泵房状态(字典码)不能为空")
// @NotEmpty(message = "消防泵房状态(字典码)不能为空")
private String pumpRoomStatus;
@ApiModelProperty(value = "负责人", name = "principalName", required = true)
@NotEmpty(message = "负责人不能为空")
// @NotEmpty(message = "负责人不能为空")
private String principalName;
@ApiModelProperty(value = "负责人手机号", name = "principalPhone", required = true)
@NotEmpty(message = "负责人手机号不能为空")
// @NotEmpty(message = "负责人手机号不能为空")
private String principalPhone;
@ApiModelProperty(value = "经度", name = "lng", required = true)
@NotNull(message = "经度不能为空")
// @NotNull(message = "经度不能为空")
private Double lng;
@ApiModelProperty(value = "纬度", name = "lat", required = true)
@NotNull(message = "纬度不能为空")
// @NotNull(message = "纬度不能为空")
private Double lat;
@ApiModelProperty(value = "设备信息")

View File

@ -37,19 +37,19 @@ public class RescueTeamAddCmd extends Command {
private String teamTypeName;
@ApiModelProperty(value = "负责人单位或部门", name = "chargeOrgDept", required = true)
@NotEmpty(message = "负责人单位或部门不能为空")
// @NotEmpty(message = "负责人单位或部门不能为空")
private String chargeOrgDept;
@ApiModelProperty(value = "队长", name = "captainName", required = true)
@NotEmpty(message = "队长不能为空")
// @NotEmpty(message = "队长不能为空")
private String captainName;
@ApiModelProperty(value = "队长电话", name = "captainPhone", required = true)
@NotEmpty(message = "队长电话不能为空")
// @NotEmpty(message = "队长电话不能为空")
private String captainPhone;
@ApiModelProperty(value = "指挥人员")
@NotEmpty(message = "指挥人员不能为空")
// @NotEmpty(message = "指挥人员不能为空")
private String commandCrew;
@ApiModelProperty(value = "建立日期", name = "establishDate", required = true)
@ -64,7 +64,7 @@ public class RescueTeamAddCmd extends Command {
private String regionScopeName;
@ApiModelProperty(value = "职责和任务范围", name = "dutyScope", required = true)
@NotEmpty(message = "职责和任务范围不能为空")
// @NotEmpty(message = "职责和任务范围不能为空")
private String dutyScope;
@ApiModelProperty(value = "消防队员")

View File

@ -35,19 +35,19 @@ public class RescueTeamUpdateCmd extends Command {
@ApiModelProperty(value = "类型名称")
private String teamTypeName;
@ApiModelProperty(value = "负责人单位或部门", name = "chargeOrgDept", required = true)
@NotEmpty(message = "负责人单位或部门不能为空")
// @NotEmpty(message = "负责人单位或部门不能为空")
private String chargeOrgDept;
@ApiModelProperty(value = "队长", name = "captainName", required = true)
@NotEmpty(message = "队长不能为空")
// @NotEmpty(message = "队长不能为空")
private String captainName;
@ApiModelProperty(value = "队长电话", name = "captainPhone", required = true)
@NotEmpty(message = "队长电话不能为空")
// @NotEmpty(message = "队长电话不能为空")
private String captainPhone;
@ApiModelProperty(value = "指挥人员")
@NotEmpty(message = "指挥人员不能为空")
// @NotEmpty(message = "指挥人员不能为空")
private String commandCrew;;
@ApiModelProperty(value = "建立日期", name = "establishDate", required = true)
@NotNull(message = "建立日期不能为空")
// @NotNull(message = "建立日期不能为空")
private LocalDate establishDate;
@ApiModelProperty(value = "所属区域或范围(字典码)", name = "regionScope", required = true)
// @NotEmpty(message = "所属区域或范围(字典码)不能为空")
@ -55,7 +55,7 @@ public class RescueTeamUpdateCmd extends Command {
@ApiModelProperty(value = "所属区域或范围名称")
private String regionScopeName;
@ApiModelProperty(value = "职责和任务范围", name = "dutyScope", required = true)
@NotEmpty(message = "职责和任务范围不能为空")
// @NotEmpty(message = "职责和任务范围不能为空")
private String dutyScope;
@ApiModelProperty(value = "消防队员")
private List<ResourcePersonAddCmd> rescueMembers;

View File

@ -27,51 +27,51 @@ public class WaterSourceAddCmd extends Command {
private String waterSourceName;
@ApiModelProperty(value = "消防水源状态(字典码)", name = "waterSourceStatus", required = true)
@NotEmpty(message = "消防水源状态不能为空")
// @NotEmpty(message = "消防水源状态不能为空")
private String waterSourceStatus;
@ApiModelProperty(value = "所属单位或部门", name = "belongOrgDept", required = true)
@NotEmpty(message = "所属单位或部门不能为空")
// @NotEmpty(message = "所属单位或部门不能为空")
private String belongOrgDept;
@ApiModelProperty(value = "经度", name = "lng", required = true)
@NotNull(message = "经度不能为空")
// @NotNull(message = "经度不能为空")
private Double lng;
@ApiModelProperty(value = "纬度", name = "lat", required = true)
@NotNull(message = "纬度不能为空")
// @NotNull(message = "纬度不能为空")
private Double lat;
@ApiModelProperty(value = "水源位置", name = "waterLocation", required = true)
@NotEmpty(message = "水源位置不能为空")
// @NotEmpty(message = "水源位置不能为空")
private String waterLocation;
@ApiModelProperty(value = "接口形式", name = "interfaceForm", required = true)
@NotEmpty(message = "接口形式不能为空")
// @NotEmpty(message = "接口形式不能为空")
private String interfaceForm;
@ApiModelProperty(value = "水源类型", name = "waterType", required = true)
@NotEmpty(message = "水源类型不能为空")
// @NotEmpty(message = "水源类型不能为空")
private String waterType;
@ApiModelProperty(value = "水源编号", name = "waterCode", required = true)
@NotEmpty(message = "水源编号不能为空")
// @NotEmpty(message = "水源编号不能为空")
private String waterCode;
@ApiModelProperty(value = "吸水口规格", name = "suctionSpec", required = true)
@NotEmpty(message = "吸水口规格不能为空")
// @NotEmpty(message = "吸水口规格不能为空")
private String suctionSpec;
@ApiModelProperty(value = "水源容量", name = "capacity", required = true)
@NotEmpty(message = "水源容量不能为空")
// @NotEmpty(message = "水源容量不能为空")
private String capacity;
@ApiModelProperty(value = "供水能力", name = "supplyAbility", required = true)
@NotEmpty(message = "供水能力不能为空")
// @NotEmpty(message = "供水能力不能为空")
private String supplyAbility;
@ApiModelProperty(value = "设备清单", name = "equipmentList", required = true)
@NotEmpty(message = "设备清单不能为空")
// @NotEmpty(message = "设备清单不能为空")
private String equipmentList;
}

View File

@ -28,40 +28,40 @@ public class WaterSourceUpdateCmd extends Command {
@NotEmpty(message = "消防水源名称不能为空")
private String waterSourceName;
@ApiModelProperty(value = "消防水源状态(字典码)", name = "waterSourceStatus", required = true)
@NotEmpty(message = "消防水源状态(字典码)不能为空")
// @NotEmpty(message = "消防水源状态(字典码)不能为空")
private String waterSourceStatus;
@ApiModelProperty(value = "所属单位或部门", name = "belongOrgDept", required = true)
@NotEmpty(message = "所属单位或部门不能为空")
// @NotEmpty(message = "所属单位或部门不能为空")
private String belongOrgDept;
@ApiModelProperty(value = "经度", name = "lng", required = true)
@NotNull(message = "经度不能为空")
// @NotNull(message = "经度不能为空")
private Double lng;
@ApiModelProperty(value = "纬度", name = "lat", required = true)
@NotNull(message = "纬度不能为空")
// @NotNull(message = "纬度不能为空")
private Double lat;
@ApiModelProperty(value = "水源位置", name = "waterLocation", required = true)
@NotEmpty(message = "水源位置不能为空")
// @NotEmpty(message = "水源位置不能为空")
private String waterLocation;
@ApiModelProperty(value = "接口形式", name = "interfaceForm", required = true)
@NotEmpty(message = "接口形式不能为空")
// @NotEmpty(message = "接口形式不能为空")
private String interfaceForm;
@ApiModelProperty(value = "水源类型", name = "waterType", required = true)
@NotEmpty(message = "水源类型不能为空")
// @NotEmpty(message = "水源类型不能为空")
private String waterType;
@ApiModelProperty(value = "水源编号", name = "waterCode", required = true)
@NotEmpty(message = "水源编号不能为空")
// @NotEmpty(message = "水源编号不能为空")
private String waterCode;
@ApiModelProperty(value = "吸水口规格", name = "suctionSpec", required = true)
@NotEmpty(message = "吸水口规格不能为空")
// @NotEmpty(message = "吸水口规格不能为空")
private String suctionSpec;
@ApiModelProperty(value = "水源容量", name = "capacity", required = true)
@NotEmpty(message = "水源容量不能为空")
// @NotEmpty(message = "水源容量不能为空")
private String capacity;
@ApiModelProperty(value = "供水能力", name = "supplyAbility", required = true)
@NotEmpty(message = "供水能力不能为空")
// @NotEmpty(message = "供水能力不能为空")
private String supplyAbility;
@ApiModelProperty(value = "设备清单", name = "equipmentList", required = true)
@NotEmpty(message = "设备清单不能为空")
// @NotEmpty(message = "设备清单不能为空")
private String equipmentList;
}

View File

@ -68,6 +68,9 @@ public class ResourcePersonGatewayImpl implements ResourcePersonGateway {
@Override
public Boolean deletedResourcePersonByBizId(String bizId, Integer bizType) {
List<ResourcePersonDO> resourcePersonDOList = resourcePersonRepository.listByBizIdAndBizType(CollUtil.newArrayList(bizId), bizType);
if (CollUtil.isEmpty(resourcePersonDOList)) {
return true;
}
return resourcePersonRepository.removeBatchByIds(resourcePersonDOList.stream().map(ResourcePersonDO::getId).collect(Collectors.toList()));
}
}

View File

@ -10,6 +10,7 @@
FROM
control_room
<where>
delete_enum = 'FALSE'
<if test="ew != null and ew.sqlSegment != null and ew.sqlSegment != ''">
AND ${ew.sqlSegment}
</if>

View File

@ -10,6 +10,7 @@
FROM
pump_room
<where>
delete_enum = 'FALSE'
<if test="ew != null and ew.sqlSegment != null and ew.sqlSegment != ''">
AND ${ew.sqlSegment}
</if>

View File

@ -10,6 +10,7 @@
FROM
rescue_team
<where>
delete_enum = 'FALSE'
<if test="ew != null and ew.sqlSegment != null and ew.sqlSegment != ''">
AND ${ew.sqlSegment}
</if>

View File

@ -10,6 +10,7 @@
FROM
water_source
<where>
delete_enum = 'FALSE'
<if test="ew != null and ew.sqlSegment != null and ew.sqlSegment != ''">
AND ${ew.sqlSegment}
</if>