This commit is contained in:
crusader 2018-04-24 21:57:15 +09:00
commit b5f0027c30
3 changed files with 16 additions and 11 deletions

View File

@ -11,6 +11,6 @@ import org.springframework.stereotype.Repository;
*/ */
@Repository @Repository
public interface InfraOSPortDAO extends JpaRepository<InfraOSPort, Long> { public interface InfraOSPortDAO extends JpaRepository<InfraOSPort, Long> {
@Query("SELECT p from com.loafle.overflow.central.module.infra.model.InfraOSPort p WHERE p.os.id = (:osId) AND p.port = (:portNumber) AND p.portType = (:portType)") @Query("SELECT p from InfraOSPort p WHERE p.os.id = (:osId) AND p.port = (:portNumber) AND p.portType = (:portType)")
InfraOSPort findByPort(@Param("osId") long osId,@Param("portNumber") int portNumber,@Param("portType") String portType); InfraOSPort findByPort(@Param("osId") long osId,@Param("portNumber") int portNumber,@Param("portType") String portType);
} }

View File

@ -1,10 +1,12 @@
package com.loafle.overflow.central.module.sensor.service; package com.loafle.overflow.central.module.sensor.service;
import com.loafle.overflow.central.module.sensor.dao.SensorItemDependencyDAO; import com.loafle.overflow.central.module.sensor.dao.SensorItemDependencyDAO;
import com.loafle.overflow.core.exception.OverflowException;
import com.loafle.overflow.model.meta.MetaSensorDisplayItem; import com.loafle.overflow.model.meta.MetaSensorDisplayItem;
import com.loafle.overflow.model.meta.MetaSensorItemKey; import com.loafle.overflow.model.meta.MetaSensorItemKey;
import com.loafle.overflow.model.sensor.SensorItemDependency; import com.loafle.overflow.model.sensor.SensorItemDependency;
import com.loafle.overflow.service.central.sensor.SensorItemDependencyService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -17,20 +19,21 @@ import java.util.Map;
*/ */
@Service("SensorItemDependencyService") @Service("SensorItemDependencyService")
public class CentralSensorItemDependencyService { public class CentralSensorItemDependencyService implements SensorItemDependencyService {
@Autowired @Autowired
private SensorItemDependencyDAO sensorItemDependencyDAO; private SensorItemDependencyDAO sensorItemDependencyDAO;
public SensorItemDependency regist(SensorItemDependency dependency) { public SensorItemDependency regist(SensorItemDependency dependency) throws OverflowException {
return this.sensorItemDependencyDAO.save(dependency); return this.sensorItemDependencyDAO.save(dependency);
} }
public List<MetaSensorItemKey> readAllByDisplayItem(MetaSensorDisplayItem displayItem) { public List<MetaSensorItemKey> readAllByDisplayItem(MetaSensorDisplayItem displayItem) throws OverflowException {
return this.sensorItemDependencyDAO.findAllByDisplayItem(displayItem); return this.sensorItemDependencyDAO.findAllByDisplayItem(displayItem);
} }
public Map<String, List<MetaSensorItemKey>> readAllByDisplayItems(List<MetaSensorDisplayItem> displayItems) { public Map<String, List<MetaSensorItemKey>> readAllByDisplayItems(
List<MetaSensorDisplayItem> displayItems) throws OverflowException {
Map<String, List<MetaSensorItemKey>> map = new HashMap<String, List<MetaSensorItemKey>>(); Map<String, List<MetaSensorItemKey>> map = new HashMap<String, List<MetaSensorItemKey>>();

View File

@ -3,10 +3,12 @@ package com.loafle.overflow.central.module.sensor.service;
import com.loafle.overflow.central.commons.utils.PageUtil; import com.loafle.overflow.central.commons.utils.PageUtil;
import com.loafle.overflow.central.module.sensor.dao.SensorDAO; import com.loafle.overflow.central.module.sensor.dao.SensorDAO;
import com.loafle.overflow.central.module.sensor.dao.SensorItemDAO; import com.loafle.overflow.central.module.sensor.dao.SensorItemDAO;
import com.loafle.overflow.core.exception.OverflowException;
import com.loafle.overflow.core.model.PageParams; import com.loafle.overflow.core.model.PageParams;
import com.loafle.overflow.model.sensor.Sensor; import com.loafle.overflow.model.sensor.Sensor;
import com.loafle.overflow.model.sensor.SensorItem; import com.loafle.overflow.model.sensor.SensorItem;
import com.loafle.overflow.service.central.sensor.SensorItemService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -18,7 +20,7 @@ import java.util.List;
* Created by insanity on 17. 6. 28. * Created by insanity on 17. 6. 28.
*/ */
@Service("SensorItemService") @Service("SensorItemService")
public class CentralSensorItemService { public class CentralSensorItemService implements SensorItemService {
@Autowired @Autowired
private SensorItemDAO sensorItemDAO; private SensorItemDAO sensorItemDAO;
@ -26,7 +28,7 @@ public class CentralSensorItemService {
private SensorDAO sensorDAO; private SensorDAO sensorDAO;
@Transactional @Transactional
public SensorItem regist(SensorItem sensorItem) { public SensorItem regist(SensorItem sensorItem) throws OverflowException {
Sensor s = sensorDAO.findOne(sensorItem.getSensor().getId()); Sensor s = sensorDAO.findOne(sensorItem.getSensor().getId());
// s.setItemCount((short)(s.getItemCount() + 1)); // s.setItemCount((short)(s.getItemCount() + 1));
this.sensorDAO.save(s); this.sensorDAO.save(s);
@ -34,7 +36,7 @@ public class CentralSensorItemService {
} }
@Transactional @Transactional
public boolean registAll(List<SensorItem> sensorItemList) { public boolean registAll(List<SensorItem> sensorItemList) throws OverflowException {
Sensor s = sensorDAO.findOne(sensorItemList.get(0).getSensor().getId()); Sensor s = sensorDAO.findOne(sensorItemList.get(0).getSensor().getId());
// s.setItemCount((short)sensorItemList.size()); // s.setItemCount((short)sensorItemList.size());
this.sensorDAO.save(s); this.sensorDAO.save(s);
@ -42,16 +44,16 @@ public class CentralSensorItemService {
return true; return true;
} }
public SensorItem read(String id) { public SensorItem read(String id) throws OverflowException {
return this.sensorItemDAO.findOne(Long.valueOf(id)); return this.sensorItemDAO.findOne(Long.valueOf(id));
} }
public Page<SensorItem> readAllBySensor(Sensor sensor, PageParams pageParams) { public Page<SensorItem> readAllBySensor(Sensor sensor, PageParams pageParams) throws OverflowException {
return this.sensorItemDAO.findAllBySensor(sensor, PageUtil.getPageRequest(pageParams)); return this.sensorItemDAO.findAllBySensor(sensor, PageUtil.getPageRequest(pageParams));
} }
@Transactional @Transactional
public void remove(SensorItem sensorItem) { public void remove(SensorItem sensorItem) throws OverflowException {
Sensor s = sensorItem.getSensor(); Sensor s = sensorItem.getSensor();
// s.setItemCount((short)(s.getItemCount() - 1)); // s.setItemCount((short)(s.getItemCount() - 1));
this.sensorDAO.save(s); this.sensorDAO.save(s);