diff --git a/os-ems/src/main/java/com/os/ems/base/domain/EmsBaseSharePrice.java b/os-ems/src/main/java/com/os/ems/base/domain/EmsBaseSharePrice.java index b20f9de..c4a6dff 100644 --- a/os-ems/src/main/java/com/os/ems/base/domain/EmsBaseSharePrice.java +++ b/os-ems/src/main/java/com/os/ems/base/domain/EmsBaseSharePrice.java @@ -34,16 +34,16 @@ public class EmsBaseSharePrice extends BaseEntity { private String priceType; /** - * 用电起始小时数 + * 用电起始小时 */ - @Excel(name = "用电起始小时数") - private Long startHour; + @Excel(name = "用电起始小时") + private String startHour; /** - * 用电结束小时数 + * 用电结束小时 */ - @Excel(name = "用电结束小时数") - private Long endHour; + @Excel(name = "用电结束小时") + private String endHour; /** * 电单价 @@ -75,19 +75,19 @@ public class EmsBaseSharePrice extends BaseEntity { return priceType; } - public void setStartHour(Long startHour) { + public void setStartHour(String startHour) { this.startHour = startHour; } - public Long getStartHour() { + public String getStartHour() { return startHour; } - public void setEndHour(Long endHour) { + public void setEndHour(String endHour) { this.endHour = endHour; } - public Long getEndHour() { + public String getEndHour() { return endHour; } diff --git a/os-ems/src/main/java/com/os/ems/base/service/impl/EmsBaseWorkUnitServiceImpl.java b/os-ems/src/main/java/com/os/ems/base/service/impl/EmsBaseWorkUnitServiceImpl.java index 18144c2..fe2181e 100644 --- a/os-ems/src/main/java/com/os/ems/base/service/impl/EmsBaseWorkUnitServiceImpl.java +++ b/os-ems/src/main/java/com/os/ems/base/service/impl/EmsBaseWorkUnitServiceImpl.java @@ -5,9 +5,12 @@ import java.util.Iterator; import java.util.List; import java.util.stream.Collectors; +import com.os.common.exception.ServiceException; import com.os.common.utils.DateUtils; import com.os.common.utils.StringUtils; +import com.os.ems.base.domain.EmsBaseMonitorWorkUnit; import com.os.ems.base.domain.TreeSelects; +import com.os.ems.base.mapper.EmsBaseMonitorWorkUnitMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.os.ems.base.mapper.EmsBaseWorkUnitMapper; @@ -26,6 +29,9 @@ public class EmsBaseWorkUnitServiceImpl implements IEmsBaseWorkUnitService @Autowired private EmsBaseWorkUnitMapper emsBaseWorkUnitMapper; + @Autowired + private EmsBaseMonitorWorkUnitMapper emsBaseMonitorWorkUnitMapper; + /** * 查询统计单元信息 * @@ -85,6 +91,15 @@ public class EmsBaseWorkUnitServiceImpl implements IEmsBaseWorkUnitService @Override public int deleteEmsBaseWorkUnitByObjIds(Long[] objIds) { + for (Long objId : objIds) { + EmsBaseWorkUnit baseWorkUnit = this.selectEmsBaseWorkUnitByObjId(objId); + EmsBaseMonitorWorkUnit monitorWorkUnit = new EmsBaseMonitorWorkUnit(); + monitorWorkUnit.setWorkUnitCode(baseWorkUnit.getWorkUnitCode()); + List workUnits = emsBaseMonitorWorkUnitMapper.selectEmsBaseMonitorWorkUnitList(monitorWorkUnit); + if (workUnits.size() > 0){ + throw new ServiceException(baseWorkUnit.getWorkUnitName() + "已关联计量设备,无法删除!"); + } + } return emsBaseWorkUnitMapper.deleteEmsBaseWorkUnitByObjIds(objIds); }