|
@@ -1,6 +1,8 @@
|
|
package com.zglc.kg.service;
|
|
package com.zglc.kg.service;
|
|
-import com.zglc.kg.entity.DeviceEntity;
|
|
|
|
|
|
+import com.zglc.kg.entity.*;
|
|
import com.zglc.kg.dao.DeviceDao;
|
|
import com.zglc.kg.dao.DeviceDao;
|
|
|
|
+import com.zglc.kg.dao.AircraftDao;
|
|
|
|
+import com.zglc.kg.dao.AircraftSystemRelationDao;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import com.zglc.kg.base.Result;
|
|
import com.zglc.kg.base.Result;
|
|
import tk.mybatis.mapper.entity.Example;
|
|
import tk.mybatis.mapper.entity.Example;
|
|
@@ -10,17 +12,50 @@ import java.util.List;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
public class DeviceService {
|
|
public class DeviceService {
|
|
|
|
+
|
|
private DeviceDao deviceDao;
|
|
private DeviceDao deviceDao;
|
|
|
|
+ private AircraftDao aircraftDao;
|
|
|
|
+ private AircraftSystemRelationDao aircraftSystemRelationDao;
|
|
|
|
|
|
- public DeviceService(DeviceDao deviceDao) {
|
|
|
|
|
|
+ public DeviceService(DeviceDao deviceDao,AircraftSystemRelationDao aircraftSystemRelationDao,AircraftDao aircraftDao) {
|
|
this.deviceDao = deviceDao;
|
|
this.deviceDao = deviceDao;
|
|
|
|
+ this.aircraftSystemRelationDao = aircraftSystemRelationDao;
|
|
|
|
+ this.aircraftDao = aircraftDao;
|
|
}
|
|
}
|
|
|
|
|
|
public Result<String> add(DeviceEntity data) {
|
|
public Result<String> add(DeviceEntity data) {
|
|
data.setId(null);
|
|
data.setId(null);
|
|
boolean flag = true;
|
|
boolean flag = true;
|
|
|
|
+ Integer deviceType = data.getDevice_type();
|
|
String msg = "";
|
|
String msg = "";
|
|
int index = deviceDao.insertSelective(data);
|
|
int index = deviceDao.insertSelective(data);
|
|
|
|
+ switch (deviceType){
|
|
|
|
+ case 0:{
|
|
|
|
+ AircraftEntity aircraft = aircraftDao.selectByPrimaryKey(data.getAircraft_id());
|
|
|
|
+ AircraftSystemRelationEntity aircraftSystemRelation = new AircraftSystemRelationEntity();
|
|
|
|
+ Aircraft1Entity aircraft1 = new Aircraft1Entity();
|
|
|
|
+ aircraft1.setId(aircraft.getId().longValue());
|
|
|
|
+ aircraft1.setAircraft_type(aircraft.getAircraft_type());
|
|
|
|
+ aircraft1.setAircraft_describe(aircraft.getAircraft_describe());
|
|
|
|
+ aircraftSystemRelation.setStartNode(aircraft1);
|
|
|
|
+ DeviceEntity device = deviceDao.getLastInsert();
|
|
|
|
+ Device1Entity device1 = new Device1Entity();
|
|
|
|
+ device1.setId(device.getId().longValue());
|
|
|
|
+ device1.setDevice_name(device.getDevice_name());
|
|
|
|
+ device1.setDevice_type(device.getDevice_type());
|
|
|
|
+ device1.setDevice_describe(device.getDevice_describe());
|
|
|
|
+ device1.setAircraft_id(device.getAircraft_id());
|
|
|
|
+ device1.setAircraft_type(device.getAircraft_type());
|
|
|
|
+ device1.setSyst_id(device.getSyst_id());
|
|
|
|
+ device1.setSyst_name(device.getSubsys_name());
|
|
|
|
+ device1.setSubsys_id(device.getSubsys_id());
|
|
|
|
+ device1.setSubsys_name(device.getSubsys_name());
|
|
|
|
+ aircraftSystemRelation.setEndNode(device1);
|
|
|
|
+ aircraftSystemRelation.setRelation("包含");
|
|
|
|
+ aircraftSystemRelationDao.save(aircraftSystemRelation);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
if (index == 0) {
|
|
if (index == 0) {
|
|
flag = false;
|
|
flag = false;
|
|
msg = "添加信息失败!";
|
|
msg = "添加信息失败!";
|
|
@@ -30,6 +65,15 @@ public class DeviceService {
|
|
return Result.result(flag, msg, msg);
|
|
return Result.result(flag, msg, msg);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// public List<DeviceEntity> getLastInsert(){
|
|
|
|
+// return deviceDao.getLastInsert();
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+ public Result<String> addAircraftSystemRelation(AircraftSystemRelationEntity aircraftSystemRelationEntity){
|
|
|
|
+ aircraftSystemRelationDao.save(aircraftSystemRelationEntity);
|
|
|
|
+ return Result.success("添加成功!");
|
|
|
|
+ }
|
|
|
|
+
|
|
public Result<String> delete(List<Integer> ids) {
|
|
public Result<String> delete(List<Integer> ids) {
|
|
boolean flag = true;
|
|
boolean flag = true;
|
|
String msg = "";
|
|
String msg = "";
|