From 15e9d370a9bdf0582212fe2e24be8e9c9542d2c5 Mon Sep 17 00:00:00 2001
From: 郑永安 <zyazyz250@sina.com>
Date: Thu, 06 Jul 2023 13:32:15 +0800
Subject: [PATCH] 修改采购价格级联修改试剂价格
---
src/main/java/com/nanometer/smartlab/service/SysWarehouseStatusServiceImpl.java | 78 ++++++++++++++++++++++++++++++++++++++
1 files changed, 77 insertions(+), 1 deletions(-)
diff --git a/src/main/java/com/nanometer/smartlab/service/SysWarehouseStatusServiceImpl.java b/src/main/java/com/nanometer/smartlab/service/SysWarehouseStatusServiceImpl.java
index 2ee7a2b..0d1db46 100644
--- a/src/main/java/com/nanometer/smartlab/service/SysWarehouseStatusServiceImpl.java
+++ b/src/main/java/com/nanometer/smartlab/service/SysWarehouseStatusServiceImpl.java
@@ -1,20 +1,96 @@
package com.nanometer.smartlab.service;
import com.nanometer.smartlab.dao.SysWarehouseStatusDao;
+import com.nanometer.smartlab.entity.SysWarehouse;
import com.nanometer.smartlab.entity.SysWarehouseStatus;
+import com.nanometer.smartlab.exception.BusinessException;
+import com.nanometer.smartlab.exception.ExceptionEnumCode;
+import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
-@Service
+@Service("sysWarehouseStatusService")
public class SysWarehouseStatusServiceImpl implements SysWarehouseStatusService {
@Resource
private SysWarehouseStatusDao sysWarehouseStatusDao;
+ @Resource
+ private SysWarehouseService sysWarehouseService;
@Override
public void addOne(SysWarehouseStatus one) {
+ if (one.getTemperature() == null || one.getHumidity() == null || one.getSelectDate() == null ||one.getWarehouseId() == null) {
+ throw new BusinessException(ExceptionEnumCode.PARAM_NULL, "参数不能为空");
+ }
+ if (StringUtils.isBlank(one.getName()) || StringUtils.isBlank(one.getType())) {
+ throw new BusinessException(ExceptionEnumCode.PARAM_NULL, "字符不能为空");
+ }
+ SysWarehouse sysWarehouse = sysWarehouseService.getSysWarehouse(one.getWarehouseId());
+ if (sysWarehouse == null) {
+ throw new BusinessException(ExceptionEnumCode.PARAM_NULL, "查询不到仓库");
+ }
+ //温度
+ BigDecimal temperatureMax = sysWarehouse.getTemperatureMax();
+ BigDecimal temperatureMin = sysWarehouse.getTemperatureMin();
+ if (temperatureMax == null || temperatureMin == null) {
+ throw new BusinessException(ExceptionEnumCode.PARAM_NULL, "仓库未设置温度阈值");
+ }
+ //湿度
+ BigDecimal humidityMax = sysWarehouse.getHumidityMax();
+ BigDecimal humidityMin = sysWarehouse.getHumidityMin();
+ if (humidityMax == null || humidityMin == null) {
+ throw new BusinessException(ExceptionEnumCode.PARAM_NULL, "仓库未设置湿度阈值");
+ }
+
+ BigDecimal temperature = one.getTemperature();
+ BigDecimal humidity = one.getHumidity();
+ StringBuffer warningSb = new StringBuffer();
+ if (temperature.compareTo(temperatureMin) < 0) {
+ warningSb.append("温度小于仓库设置最小值;");
+ }
+ if (temperature.compareTo(temperatureMax) > 0) {
+ warningSb.append("温度超过仓库设置最大值;");
+ }
+ if (humidity.compareTo(humidityMin) < 0) {
+ warningSb.append("湿度小于仓库设置最小值;");
+ }
+ if (humidity.compareTo(humidityMax) > 0) {
+ warningSb.append("湿度大于仓库设置最大值;");
+ }
+
+ one.setWarning(warningSb.toString());
sysWarehouseStatusDao.insertOne(one);
}
+
+ @Override
+ public int getCount(String name, Date startTime, Date endTime) {
+ Map<String,Object> params = new HashMap<>();
+ params.put("name", name);
+ params.put("startTime", startTime);
+ params.put("endTime", endTime);
+ return sysWarehouseStatusDao.selectCount(params);
+ }
+
+ @Override
+ public List<SysWarehouseStatus> selectList(String name, Date startTime, Date endTime, int first, int pageSize) {
+ Map<String,Object> params = new HashMap<>();
+ params.put("name", name);
+ params.put("startTime", startTime);
+ params.put("endTime", endTime);
+ params.put("first", first);
+ params.put("pageSize", pageSize);
+ return sysWarehouseStatusDao.selectList(params);
+ }
+
+ @Override
+ public SysWarehouseStatus getById(String rowKey) {
+ return sysWarehouseStatusDao.selectById(rowKey);
+ }
}
--
Gitblit v1.9.2