Commit 5ce951f1 authored by zhangsen's avatar zhangsen

批量删除API提交

parent 973b1e1f
......@@ -31,6 +31,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.http.MediaType;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
......@@ -199,6 +200,29 @@ public class FireFightingSystemController extends AbstractBaseController {
return result;
}
/**
* 装备卡片批量删除
*
* @return
*/
@DeleteMapping(value = "/delEquipmentSpecificByIds")
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "DELETE", value = "装备卡片批量删除")
@Transactional
public ResponseModel delEquipmentSpecific(@RequestBody List<Long> specificIds) {
if (CollectionUtils.isEmpty(specificIds)) {
throw new BadRequest("所选装备不能为空");
}
Set<String> bizOrgCodes = new HashSet<>();
specificIds.forEach(specId -> {
EquipmentSpecific equipmentSpecific = equipmentSpecificSerivce.getById(specId);
equipmentSpecificSerivce.delEquipmentSpecificByIdNew(equipmentSpecific);
bizOrgCodes.add(equipmentSpecific.getBizOrgCode());
});
bizOrgCodes.forEach(this::refreshCount);
return CommonResponseUtil.success(Boolean.TRUE);
}
private void refreshCount(String bizOrgCode) {
equipmentSpecificSerivce.refreshStaData();
......
......@@ -75,6 +75,12 @@ public interface IEquipmentSpecificSerivce extends IService<EquipmentSpecific> {
Boolean delEquipmentSpecific(Long id);
/**
* 批量清除调用
* @param equipmentSpecific 装备信息
*/
Boolean delEquipmentSpecificByIdNew(EquipmentSpecific equipmentSpecific);
/**
* 组装组态使用的卡片数据
*
* @param id
......
......@@ -49,6 +49,7 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.DateTimeUtil;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.io.IOException;
......@@ -1010,6 +1011,52 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM
}
}
@Override
public Boolean delEquipmentSpecificByIdNew(EquipmentSpecific equipmentSpecific) {
Long id = equipmentSpecific.getId();
QueryWrapper<StockDetail> stockDetailQueryWrapper = new QueryWrapper<>();
stockDetailQueryWrapper.eq("equipment_specific_id", equipmentSpecific.getId());
if (stockDetailService.count(stockDetailQueryWrapper) > 0) {
throw new BadRequest("所选设备中存在已入库设备,无法删除,请重新选择,装备名称:" + equipmentSpecific.getName());
}
String code = this.getSystemCodeBySpeId(equipmentSpecific.getSystemId());
int res = this.baseMapper.deleteById(id);
if (StringUtil.isNotEmpty(code)) {
this.integrationPageSysDataRefresh(code);
}
if (res > 0 && Boolean.TRUE.equals(syncSwitch)) {
//数据同步
delEquipmentSpecificSyncData(id);
}
//判断装备表剩余数量,无剩余删除模板
QueryWrapper<EquipmentSpecific> wrapper = new QueryWrapper<>();
wrapper.eq("equipment_detail_id", equipmentSpecific.getEquipmentDetailId());
List<String> sys = this.baseMapper.selectSystemList(id);
List<String> build = this.baseMapper.selectBuildList(id);
String sysErrorMeg = "";
String buildErrorMeg = "";
if (!CollectionUtils.isEmpty(sys) || !CollectionUtils.isEmpty(build)) {
for (String s : sys) {
sysErrorMeg = sysErrorMeg.equals("") ? s : sysErrorMeg + "," + s;
}
for (String s : build) {
buildErrorMeg = buildErrorMeg.equals("") ? s : buildErrorMeg + "," + s;
}
sysErrorMeg = sysErrorMeg.equals("") ? sysErrorMeg : "系统:" + sysErrorMeg + ",";
buildErrorMeg = buildErrorMeg.equals("") ? buildErrorMeg : "建筑:" + buildErrorMeg + ",";
throw new BadRequest("所选设备中有与" + sysErrorMeg + buildErrorMeg + "存在绑定关系,无法删除,装备名称:" + equipmentSpecific.getName());
}
if (this.baseMapper.selectCount(wrapper) == 0) {
equipmentDetailService.removeById(equipmentSpecific.getEquipmentDetailId());
}
if (res > 0) {
// 删除设备动态表单扩展属性
return formInstanceEquipService.deleteInstanceById(id);
} else {
return false;
}
}
private String getSystemCodeBySpeId(String sysIds) {
if (StringUtil.isNotEmpty(sysIds)) {
List<FireFightingSystemEntity> sys = fireFightingSystemMapper.getFightingSysByIds(sysIds.split(","));
......
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