Quellcode durchsuchen

添加设备时根据型号判断货道数量和货道容量

LuoDLeo vor 3 Monaten
Ursprung
Commit
c115f18b14

+ 3 - 3
src/main/java/org/springblade/modules/business/entity/Facility.java

@@ -46,10 +46,10 @@ public class Facility extends BaseEntity {
 	@ApiModelProperty(value = "设备名称")
 	private String facilityName;
 	/**
-	* 设备型号
+	* 设备型号id
 	*/
-	@ApiModelProperty(value = "设备型号")
-	private String facilityType;
+	@ApiModelProperty(value = "设备型号id")
+	private Long facilityType;
 	/**
 	 * 设备地址
 	 */

+ 15 - 16
src/main/java/org/springblade/modules/business/service/impl/FacilityServiceImpl.java

@@ -19,10 +19,13 @@ package org.springblade.modules.business.service.impl;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springblade.common.enums.StatusEnum;
+import org.springblade.core.log.exception.ServiceException;
 import org.springblade.modules.business.entity.Facility;
 import org.springblade.modules.business.entity.FacilityCargoWay;
+import org.springblade.modules.business.entity.FacilityModel;
 import org.springblade.modules.business.mapper.FacilityMapper;
 import org.springblade.modules.business.service.IFacilityCargoWayService;
+import org.springblade.modules.business.service.IFacilityModelService;
 import org.springblade.modules.business.service.IFacilityService;
 import org.springblade.modules.business.vo.FacilityVO;
 import org.springblade.modules.mall.vo.GoodsInfoVO;
@@ -32,6 +35,7 @@ import org.springframework.transaction.annotation.Transactional;
 import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Objects;
 
 /**
  * 售货设备表 服务实现类
@@ -44,6 +48,8 @@ public class FacilityServiceImpl extends ServiceImpl<FacilityMapper, Facility> i
 
 	@Resource
 	private IFacilityCargoWayService iFacilityCargoWayService;
+	@Resource
+	private IFacilityModelService iFacilityModelService;
 
 	@Override
 	public IPage<FacilityVO> selectFacilityPage(IPage<FacilityVO> page, FacilityVO facility) {
@@ -61,11 +67,18 @@ public class FacilityServiceImpl extends ServiceImpl<FacilityMapper, Facility> i
 		this.save(facility);
 		List<FacilityCargoWay> list = new ArrayList<>();
 
-		for (int i = 1; i <= this.getCargoQuantity(); i++) {
+		//获取设备型号信息
+		FacilityModel facilityModel = iFacilityModelService.getById(facility.getFacilityType());
+
+		if (Objects.isNull(facilityModel)){
+			throw new ServiceException("设备型号不存在!");
+		}
+
+		for (int i = 1; i <= facilityModel.getChannelQuantity(); i++) {
 			FacilityCargoWay facilityCargoWay = new FacilityCargoWay();
 			facilityCargoWay.setFacilityId(facility.getId());
 			facilityCargoWay.setCargoNo(i + "");
-			facilityCargoWay.setVolume(this.getCargoCapacity());
+			facilityCargoWay.setVolume(facilityModel.getChannelCapacity());
 			facilityCargoWay.setCargoStatus(StatusEnum.ENABLE.getValue());
 			facilityCargoWay.setEnable(StatusEnum.ENABLE.getValue());
 			facilityCargoWay.setDiscount(0.0);
@@ -84,18 +97,4 @@ public class FacilityServiceImpl extends ServiceImpl<FacilityMapper, Facility> i
 				.list();
 	}
 
-	/**
-	 * 获取货道数量
-	 */
-	private Integer getCargoQuantity() {
-		return 8;
-	}
-
-	/**
-	 * 获取货道容量
-	 */
-	private Integer getCargoCapacity() {
-		return 8;
-	}
-
 }