|
|
@@ -34,6 +34,8 @@ import com.zksy.cockpit.point.BusinessCockpitDeviceFactResolver;
|
|
|
import com.zksy.drainage.domain.DrainageFacilityBase;
|
|
|
import com.zksy.drainage.service.DrainageGateInfoService;
|
|
|
import com.zksy.drainage.service.DrainageStorageInfoService;
|
|
|
+import com.zksy.ops.domain.WorkOrder;
|
|
|
+import com.zksy.ops.service.WorkOrderService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -68,6 +70,7 @@ public class CockpitEntityDetailService {
|
|
|
private final IWaterSourceInfoService waterSources;
|
|
|
private final EquipmentTypeService equipmentTypes;
|
|
|
private final BusinessCockpitDeviceFactResolver deviceFacts;
|
|
|
+ private final WorkOrderService workOrders;
|
|
|
|
|
|
@Autowired
|
|
|
public CockpitEntityDetailService(PipeNetworkBaseService pipes, IWaterPlantInfoService plants,
|
|
|
@@ -75,12 +78,12 @@ public class CockpitEntityDetailService {
|
|
|
DrainageGateInfoService gates, DrainageStorageInfoService storages,
|
|
|
EquipmentStatusService equipmentStatuses, HazardHiddenAccountService hazards, RiskAssessmentService risks, ManholeBaseService manholes,
|
|
|
IWaterUserInfoService users, IWaterFireHydrantInfoService hydrants, IWaterSourceInfoService waterSources,
|
|
|
- EquipmentTypeService equipmentTypes, BusinessCockpitDeviceFactResolver deviceFacts) {
|
|
|
+ EquipmentTypeService equipmentTypes, BusinessCockpitDeviceFactResolver deviceFacts, WorkOrderService workOrders) {
|
|
|
this.pipes = pipes; this.plants = plants; this.stations = stations;
|
|
|
this.equipment = equipment; this.gates = gates; this.storages = storages;
|
|
|
this.equipmentStatuses = equipmentStatuses; this.hazards = hazards; this.risks = risks; this.manholes = manholes;
|
|
|
this.users = users; this.hydrants = hydrants; this.waterSources = waterSources;
|
|
|
- this.equipmentTypes = equipmentTypes; this.deviceFacts = deviceFacts;
|
|
|
+ this.equipmentTypes = equipmentTypes; this.deviceFacts = deviceFacts; this.workOrders = workOrders;
|
|
|
}
|
|
|
|
|
|
public CockpitEntityDetailResponse load(String requestId, String categoryValue, String entityId) {
|
|
|
@@ -391,21 +394,53 @@ public class CockpitEntityDetailService {
|
|
|
return deviceFacts.resolve(device,deviceTypeName).getPublishedDeviceStatus();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 关联管网引用:只给业务编码与名称,内部主键不下发(规格 §5);查不到就留空,不编造。
|
|
|
+ */
|
|
|
+ private Map<String,Object> networkReference(String networkId) {
|
|
|
+ if(blank(networkId)) return null;
|
|
|
+ PipeNetworkBase row=pipes.getById(networkId);
|
|
|
+ return row==null?null:reference(row.getNetworkCode(),row.getNetworkName());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 关联工单引用:工单的业务身份就是工单号。{@code work_order} 表没有名称列,
|
|
|
+ * 所以只给 code —— 编一个「名称」等于造假(规格 §5:workOrder 只列 code)。
|
|
|
+ */
|
|
|
+ private Map<String,Object> workOrderReference(Long workOrderId) {
|
|
|
+ if(workOrderId==null) return null;
|
|
|
+ WorkOrder row=workOrders.getById(workOrderId);
|
|
|
+ return row==null?null:reference(row.getOrderNo(),null);
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 引用对象只保留有值的字段;两样都空就算没有这个引用,让前端如实显示「未提供」。 */
|
|
|
+ private static Map<String,Object> reference(String code,String name) {
|
|
|
+ Map<String,Object> ref=map();
|
|
|
+ if(!blank(code)) ref.put("code",code);
|
|
|
+ if(!blank(name)) ref.put("name",name);
|
|
|
+ return ref.isEmpty()?null:ref;
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 危险源详情(票 06):关联设备/管网/工单给业务引用,内部主键不再出现在响应里。 */
|
|
|
private CockpitEntityDetailResponse hazard(String requestId,String id) {
|
|
|
HazardHiddenAccount v=hazards.getById(id); if(v==null) throw missing();
|
|
|
+ // 关联设备只读一次:片区与业务引用都从这一行派生。
|
|
|
+ EquipmentBase linked=blank(v.getEquipmentId())?null:equipment.getById(v.getEquipmentId());
|
|
|
Map<String,Object>a=map(); put(a,"hazardType",v.getHazardType()); put(a,"level",v.getHazardLevel()); put(a,"source",v.getHazardSource()); put(a,"description",v.getHazardDesc());
|
|
|
- put(a,"networkId",v.getNetworkId()); put(a,"equipmentId",v.getEquipmentId()); put(a,"workOrderId",v.getWorkOrderId()); put(a,"reportTime",v.getReportTime());
|
|
|
+ put(a,"equipment",linked==null?null:reference(linked.getEquipmentCode(),linked.getEquipmentName()));
|
|
|
+ put(a,"network",networkReference(v.getNetworkId())); put(a,"workOrder",workOrderReference(v.getWorkOrderId())); put(a,"reportTime",v.getReportTime());
|
|
|
put(a,"rectifyPlan",v.getRectifyPlan()); put(a,"rectifyDeadline",v.getRectifyDeadline()); put(a,"rectifyPerson",v.getRectifyPerson()); put(a,"rectifyFeedback",v.getRectifyFeedback()); put(a,"images",v.getHazardImages()); put(a,"remark",v.getRemark());
|
|
|
- Integer district=null; if(!blank(v.getEquipmentId())) { EquipmentBase e=equipment.getById(v.getEquipmentId()); if(e!=null) district=CockpitDistrict.codeOf(e.getDistrict()); }
|
|
|
+ Integer district=linked==null?null:CockpitDistrict.codeOf(linked.getDistrict());
|
|
|
return response(requestId,"HAZARD",v.getHazardId(),v.getHazardNo(),v.getHazardDesc(),v.getHazardStatus(),null,district,
|
|
|
new CockpitEntityDetailResponse.Coordinates(v.getLongitude(),v.getLatitude(),null,null),a,v.getUpdateTime());
|
|
|
}
|
|
|
|
|
|
private CockpitEntityDetailResponse target(String requestId,String id) {
|
|
|
RiskAssessment v=risks.getById(id); if(v==null||blank(v.getProtectiveTargets())) throw missing();
|
|
|
- Map<String,Object>a=map(); put(a,"networkId",v.getNetworkId()); put(a,"riskLevel",v.getRiskLevel()); put(a,"riskScore",v.getRiskScore()); put(a,"riskColor",v.getRiskColor());
|
|
|
+ Map<String,Object>a=map(); put(a,"network",networkReference(v.getNetworkId())); put(a,"riskLevel",v.getRiskLevel()); put(a,"riskScore",v.getRiskScore()); put(a,"riskColor",v.getRiskColor());
|
|
|
put(a,"assessmentModel",v.getAssessmentModel()); put(a,"assessmentTime",v.getAssessmentTime()); put(a,"riskFactors",v.getRiskFactors()); put(a,"hazardSources",v.getHazardSources()); put(a,"remark",v.getRemark());
|
|
|
- return response(requestId,"PROTECTION_TARGET",v.getRiskId(),v.getRiskId(),v.getProtectiveTargets(),v.getRiskLevel(),null,null,null,a,v.getUpdateTime());
|
|
|
+ // riskId 是风险评估表主键、不是业务编码:code 留空,别把 risk001 当编码发出去(规格 §5 / US-25)。
|
|
|
+ return response(requestId,"PROTECTION_TARGET",v.getRiskId(),null,v.getProtectiveTargets(),v.getRiskLevel(),null,null,null,a,v.getUpdateTime());
|
|
|
}
|
|
|
|
|
|
private static CockpitEntityDetailResponse response(String requestId,String category,String id,String code,String name,String status,String location,Integer district,CockpitEntityDetailResponse.Coordinates coordinates,Map<String,Object> attributes,LocalDateTime updatedAt) {
|