e98581cd sonin

设备台账 删除逻辑 修改

1 个父辈 3d30ef3b
......@@ -10,6 +10,7 @@ import javax.servlet.http.HttpServletResponse;
import cn.hutool.json.JSONObject;
import com.skua.core.context.BaseContextHandler;
import com.skua.core.query.QueryGenerator;
import com.skua.modules.equipment.service.IEquipmentAssetService;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Sheet;
......@@ -109,6 +110,8 @@ public class EquipmentController {
@Autowired
private IEquipmentInfoService equipmentInfoService;
@Autowired
private IEquipmentAssetService equipmentAssetService;
@Autowired
private Key2ValueService key2ValueService;
......@@ -384,17 +387,26 @@ public class EquipmentController {
Result<?> result = new Result<>();
Equipment equipment = EquipmentUtils.equipDTO2Entity(equipmentDTO);
// todo 前端未传,特殊处理
equipment.getEquipmentInfo().setAssetId(equipment.getEquipmentAsset().getId());
// equipment.getEquipmentInfo().setAssetId(equipment.getEquipmentAsset().getId());
// equipment.getEquipmentExt().setInfoId(equipment.getEquipmentInfo().getId());
// 校验ID是否一致
JoinSqlUtils.checkSqlIdFunc(equipment);
// JoinSqlUtils.checkSqlIdFunc(equipment);
// 与点表有关联的台账不允许删除
List<SysMonitorMetricInfo> monitorMetricInfo = sysMonitorMetricInfoService.list(new QueryWrapper<SysMonitorMetricInfo>().eq("equipment_code", equipmentDTO.getEquipmentInfo().getId()));
if (monitorMetricInfo!=null&&monitorMetricInfo.size()>0) {
result.error500("与运行点表有关联的设备台账不允许删除");
return result;
}
iCrudSqlService.delete(equipment);
// iCrudSqlService.delete(equipment);
transactionTemplate.execute((transactionStatus -> {
if (StringUtils.isNotEmpty(equipment.getEquipmentInfo().getId())) {
equipmentInfoService.removeById(equipment.getEquipmentInfo().getId());
}
if (StringUtils.isNotEmpty(equipment.getEquipmentAsset().getId())) {
equipmentAssetService.removeById(equipment.getEquipmentAsset().getId());
}
return 1;
}));
return Result.ok("删除成功!");
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!