|
@@ -1,9 +1,6 @@
|
|
|
package com.zglc.kg.service;
|
|
|
-import com.zglc.kg.dao.Aircraft1Dao;
|
|
|
+import com.zglc.kg.dao.*;
|
|
|
import com.zglc.kg.entity.*;
|
|
|
-import com.zglc.kg.dao.DeviceDao;
|
|
|
-import com.zglc.kg.dao.AircraftDao;
|
|
|
-import com.zglc.kg.dao.AircraftSystemRelationDao;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.zglc.kg.base.Result;
|
|
|
import tk.mybatis.mapper.entity.Example;
|
|
@@ -15,28 +12,20 @@ import java.util.List;
|
|
|
@Service
|
|
|
public class DeviceService {
|
|
|
|
|
|
-// private DeviceDao deviceDao;
|
|
|
-// private AircraftDao aircraftDao;
|
|
|
-// private Aircraft1Dao aircraft1Dao;
|
|
|
-// private AircraftSystemRelationDao aircraftSystemRelationDao;
|
|
|
-//
|
|
|
-// public DeviceService(DeviceDao deviceDao,AircraftSystemRelationDao aircraftSystemRelationDao,AircraftDao aircraftDao
|
|
|
-// ,Aircraft1Dao aircraft1Dao) {
|
|
|
-// this.deviceDao = deviceDao;
|
|
|
-// this.aircraftSystemRelationDao = aircraftSystemRelationDao;
|
|
|
-// this.aircraftDao = aircraftDao;
|
|
|
-// this.aircraft1Dao = aircraft1Dao;
|
|
|
-//
|
|
|
-// }
|
|
|
@Resource
|
|
|
private DeviceDao deviceDao;
|
|
|
@Resource
|
|
|
+ private Device1Dao device1Dao;
|
|
|
+ @Resource
|
|
|
private AircraftDao aircraftDao;
|
|
|
@Resource
|
|
|
private Aircraft1Dao aircraft1Dao;
|
|
|
@Resource
|
|
|
private AircraftSystemRelationDao aircraftSystemRelationDao;
|
|
|
-
|
|
|
+ @Resource
|
|
|
+ private SystemSubsystemRelationDao systemSubsystemRelationDao;
|
|
|
+ @Resource
|
|
|
+ private SubsystemDeviceRelationDao subsystemDeviceRelationDao;
|
|
|
|
|
|
|
|
|
public Result<String> add(DeviceEntity data) {
|
|
@@ -49,10 +38,7 @@ public class DeviceService {
|
|
|
case 0:{
|
|
|
AircraftEntity aircraft = aircraftDao.selectByPrimaryKey(data.getAircraft_id());
|
|
|
AircraftSystemRelationEntity aircraftSystemRelation = new AircraftSystemRelationEntity();
|
|
|
- Aircraft1Entity aircraft1 = aircraft1Dao.getAircraft1EntitiesByAircraftType(aircraft.getAircraft_type());
|
|
|
-// aircraft1.setId(aircraft.getId().longValue());
|
|
|
-// aircraft1.setAircraftType(aircraft.getAircraft_type());
|
|
|
-// aircraft1.setAircraftDescribe(aircraft.getAircraft_describe());
|
|
|
+ Aircraft1Entity aircraft1 = aircraft1Dao.getAircraft1EntitiesByMysqlId(aircraft.getId());
|
|
|
aircraftSystemRelation.setStartNode(aircraft1);
|
|
|
DeviceEntity device = deviceDao.getLastInsert();
|
|
|
Device1Entity device1 = new Device1Entity();
|
|
@@ -66,9 +52,53 @@ public class DeviceService {
|
|
|
device1.setSyst_name(device.getSubsys_name());
|
|
|
device1.setSubsys_id(device.getSubsys_id());
|
|
|
device1.setSubsys_name(device.getSubsys_name());
|
|
|
+ device1.setMysqlId(device.getId());
|
|
|
aircraftSystemRelation.setEndNode(device1);
|
|
|
- aircraftSystemRelation.setRelation1("包含");
|
|
|
+ aircraftSystemRelation.setRelationAS("包含");
|
|
|
aircraftSystemRelationDao.save(aircraftSystemRelation);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 1:{
|
|
|
+ SystemSubsystemRelationEntity systemSubsystemRelation = new SystemSubsystemRelationEntity();
|
|
|
+ Device1Entity device1 = device1Dao.getDevice1EntitiesByMysqlId(data.getSyst_id());
|
|
|
+ systemSubsystemRelation.setStartNode(device1);
|
|
|
+ DeviceEntity device = deviceDao.getLastInsert();
|
|
|
+ Device1Entity device2 = new Device1Entity();
|
|
|
+ device2.setDevice_name(device.getDevice_name());
|
|
|
+ device2.setDevice_type(device.getDevice_type());
|
|
|
+ device2.setDevice_describe(device.getDevice_describe());
|
|
|
+ device2.setAircraft_id(device.getAircraft_id());
|
|
|
+ device2.setAircraft_type(device.getAircraft_type());
|
|
|
+ device2.setSyst_id(device.getSyst_id());
|
|
|
+ device2.setSyst_name(device.getSubsys_name());
|
|
|
+ device2.setSubsys_id(device.getSubsys_id());
|
|
|
+ device2.setSubsys_name(device.getSubsys_name());
|
|
|
+ device2.setMysqlId(device.getId());
|
|
|
+ systemSubsystemRelation.setEndNode(device2);
|
|
|
+ systemSubsystemRelation.setRelationSysSub("包含");
|
|
|
+ systemSubsystemRelationDao.save(systemSubsystemRelation);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 2:{
|
|
|
+ SubsystemDeviceRelationEntity subsystemDeviceRelation = new SubsystemDeviceRelationEntity();
|
|
|
+ Device1Entity device1 = device1Dao.getDevice1EntitiesByMysqlId(data.getSubsys_id());
|
|
|
+ subsystemDeviceRelation.setStartNode(device1);
|
|
|
+ DeviceEntity device = deviceDao.getLastInsert();
|
|
|
+ Device1Entity device2 = new Device1Entity();
|
|
|
+ device2.setDevice_name(device.getDevice_name());
|
|
|
+ device2.setDevice_type(device.getDevice_type());
|
|
|
+ device2.setDevice_describe(device.getDevice_describe());
|
|
|
+ device2.setAircraft_id(device.getAircraft_id());
|
|
|
+ device2.setAircraft_type(device.getAircraft_type());
|
|
|
+ device2.setSyst_id(device.getSyst_id());
|
|
|
+ device2.setSyst_name(device.getSubsys_name());
|
|
|
+ device2.setSubsys_id(device.getSubsys_id());
|
|
|
+ device2.setSubsys_name(device.getSubsys_name());
|
|
|
+ device2.setMysqlId(device.getId());
|
|
|
+ subsystemDeviceRelation.setEndNode(device2);
|
|
|
+ subsystemDeviceRelation.setRelationSubD("包含");
|
|
|
+ subsystemDeviceRelationDao.save(subsystemDeviceRelation);
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -97,6 +127,9 @@ public class DeviceService {
|
|
|
while(iter.hasNext()) {
|
|
|
Integer id = (Integer)iter.next();
|
|
|
int index = deviceDao.deleteByPrimaryKey(id);
|
|
|
+// Device1Entity device1 = device1Dao.getDevice1EntitiesByMysqlId(id);
|
|
|
+// device1Dao.deleteById(device1.getId());
|
|
|
+ device1Dao.deleteNR(id);
|
|
|
if (index == 0) {
|
|
|
flag = false;
|
|
|
msg += "删除失败!" + id + ";";
|
|
@@ -113,6 +146,18 @@ public class DeviceService {
|
|
|
DeviceEntity tmpData = deviceDao.selectByPrimaryKey(data.getId());
|
|
|
if (tmpData != null) {
|
|
|
int index = deviceDao.updateByPrimaryKeySelective(data);
|
|
|
+ Device1Entity device1 = device1Dao.getDevice1EntitiesByMysqlId(data.getId());
|
|
|
+ device1.setDevice_name(data.getDevice_name());
|
|
|
+ device1.setDevice_type(data.getDevice_type());
|
|
|
+ device1.setDevice_describe(data.getDevice_describe());
|
|
|
+ device1.setAircraft_id(data.getAircraft_id());
|
|
|
+ device1.setAircraft_type(data.getAircraft_type());
|
|
|
+ device1.setSyst_id(data.getSyst_id());
|
|
|
+ device1.setSyst_name(data.getSubsys_name());
|
|
|
+ device1.setSubsys_id(data.getSubsys_id());
|
|
|
+ device1.setSubsys_name(data.getSubsys_name());
|
|
|
+ device1.setMysqlId(data.getId());
|
|
|
+ device1Dao.save(device1);
|
|
|
if (index == 0) {
|
|
|
flag = false;
|
|
|
msg = "信息修改失败";
|