From 47a751cb301d05276ae5d75145d57b2d090fe4e1 Mon Sep 17 00:00:00 2001
From: kongzy <kongzy>
Date: 星期一, 01 七月 2024 10:58:35 +0800
Subject: [PATCH] change

---
 src/main/java/com/nanometer/smartlab/service/InterfaceServiceImpl.java |  260 ++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 171 insertions(+), 89 deletions(-)

diff --git a/src/main/java/com/nanometer/smartlab/service/InterfaceServiceImpl.java b/src/main/java/com/nanometer/smartlab/service/InterfaceServiceImpl.java
index fed7f24..76adaf4 100644
--- a/src/main/java/com/nanometer/smartlab/service/InterfaceServiceImpl.java
+++ b/src/main/java/com/nanometer/smartlab/service/InterfaceServiceImpl.java
@@ -5,17 +5,14 @@
 import com.nanometer.smartlab.api.ApiAction;
 import com.nanometer.smartlab.dao.*;
 import com.nanometer.smartlab.entity.*;
-import com.nanometer.smartlab.entity.enumtype.ApiStatus;
-import com.nanometer.smartlab.entity.enumtype.ArrivalStatus;
-import com.nanometer.smartlab.entity.enumtype.SeeFlag;
-import com.nanometer.smartlab.entity.enumtype.ValidFlag;
-import com.nanometer.smartlab.entity.enumtype.WarningLevel;
+import com.nanometer.smartlab.entity.enumtype.*;
 import com.nanometer.smartlab.exception.ApiException;
 import com.nanometer.smartlab.util.IDUtils;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.http.client.methods.CloseableHttpResponse;
 import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.utils.DateUtils;
 import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClients;
@@ -106,7 +103,7 @@
 
     @Override
     @Transactional(propagation = Propagation.REQUIRED)
-	public void AutheTestCabinet(String userId, JSONObject jsonObject) throws ApiException {
+	public void AutheTestCabinet(Long userId, JSONObject jsonObject) throws ApiException {
     	if (!jsonObject.containsKey("createTime")) {
             throw new ApiException(ApiStatus.PARAM_NO_EXIST, ApiStatus.PARAM_NO_EXIST.getRetMsg() + "[createTime]");
         }
@@ -228,8 +225,8 @@
                 throw new ApiException(ApiStatus.PARAM_NULL, ApiStatus.PARAM_NULL.getRetMsg() + "[barCode]");
             }
 
-            Integer containerLeft = containerDateJson.getInteger("left");
-            Integer containerRight = containerDateJson.getInteger("right");
+            Long containerLeft = containerDateJson.getLong("left");
+            Long containerRight = containerDateJson.getLong("right");
 
             // 仓库试剂柜场合
             if (containerPlace == 0) {
@@ -262,10 +259,10 @@
 
 				// 可能不能直接存,需要转换成数据字典
 				if (containerLeft != null) {
-					sysWarehouseContainer.setCharacterLeft(String.valueOf(containerLeft));
+					sysWarehouseContainer.setCharacterLeft(containerLeft);
 				}
 				if (containerRight != null) {
-					sysWarehouseContainer.setCharacterRight(String.valueOf(containerRight));
+					sysWarehouseContainer.setCharacterRight(containerRight);
 				}
 
 				sysWarehouseContainerDao
@@ -303,11 +300,11 @@
 
 				// 可能不能直接存,需要转换成数据字典
 				if (containerLeft != null) {
-					sysLaboratoryContainer.setCharacterLeft(String.valueOf(containerLeft));
+					sysLaboratoryContainer.setCharacterLeft(containerLeft);
 				}
 
 				if (containerRight != null) {
-					sysLaboratoryContainer.setCharacterRight(String.valueOf(containerRight));
+					sysLaboratoryContainer.setCharacterRight(containerRight);
 				}
 
 				int containerCount = sysLaboratoryContainerDao
@@ -324,7 +321,7 @@
 
 	@Override
     @Transactional(propagation = Propagation.REQUIRED)
-    public void registerTestCabinet(String userId, JSONObject jsonObject) throws ApiException {
+    public void registerTestCabinet(Long userId, JSONObject jsonObject) throws ApiException {
         long createTimestamp = jsonObject.getLong("createTime");
 
         if (!jsonObject.containsKey("controllerData")) {
@@ -452,8 +449,8 @@
                 throw new ApiException(ApiStatus.PARAM_NULL, ApiStatus.PARAM_NULL.getRetMsg() + "[place]");
             }
 
-            Integer containerLeft = containerDateJson.getInteger("left");
-            Integer containerRight = containerDateJson.getInteger("right");
+            Long containerLeft = containerDateJson.getLong("left");
+            Long containerRight = containerDateJson.getLong("right");
 
 
             if (containerPlace == 0) {
@@ -479,7 +476,7 @@
 
                 SysWarehouseContainer tempSysWarehouseContainer = new SysWarehouseContainer();
                 tempSysWarehouseContainer.setWarehouseId(sysWarehouse.getId());
-                tempSysWarehouseContainer.setType(baseMetaList.get(0).getMetaValue());
+                tempSysWarehouseContainer.setType(Long.valueOf(baseMetaList.get(0).getMetaValue()));
                 tempSysWarehouseContainer.setContainerCode(containerCode);
                 tempSysWarehouseContainer.setCreateTime(new Timestamp(createTimestamp));
                 tempSysWarehouseContainer.setUpdateTime(new Timestamp(createTimestamp));
@@ -491,14 +488,14 @@
                 tempSysWarehouseContainer.setValidFlag(ValidFlag.parse(containerValidFlag));
                 tempSysWarehouseContainer.setControllerCode(controllerCode);
                 if (containerLeft != null) {
-                    tempSysWarehouseContainer.setCharacterLeft(String.valueOf(containerLeft));
+                    tempSysWarehouseContainer.setCharacterLeft(containerLeft);
                 }
 
                 if (containerRight != null) {
-                    tempSysWarehouseContainer.setCharacterRight(String.valueOf(containerRight));
+                    tempSysWarehouseContainer.setCharacterRight(containerRight);
                 }
 
-                tempSysWarehouseContainer.setId(IDUtils.uuid());
+            //    tempSysWarehouseContainer.setId(IDUtils.uuid());
                 sysWarehouseContainerDao.insertSysWarehouseContainer(tempSysWarehouseContainer);
             } else if (containerPlace == 1) {
                 SysLaboratoryContainer sysLaboratoryContainer = sysLaboratoryContainerDao.getSysLaboratoryContainerByContainerCode(containerCode);
@@ -523,7 +520,7 @@
 
                 SysLaboratoryContainer tempSysLaboratoryContainer = new SysLaboratoryContainer();
                 tempSysLaboratoryContainer.setLaboratoryId(sysLaboratory.getId());
-                tempSysLaboratoryContainer.setType(baseMetaList.get(0).getMetaValue());
+                tempSysLaboratoryContainer.setType(Long.valueOf(baseMetaList.get(0).getMetaValue()));
                 tempSysLaboratoryContainer.setContainerCode(containerCode);
                 tempSysLaboratoryContainer.setCreateTime(new Timestamp(createTimestamp));
                 tempSysLaboratoryContainer.setUpdateTime(new Timestamp(createTimestamp));
@@ -535,13 +532,13 @@
                 tempSysLaboratoryContainer.setValidFlag(ValidFlag.parse(containerValidFlag));
                 tempSysLaboratoryContainer.setControllerCode(controllerCode);
                 if (containerLeft != null) {
-                    tempSysLaboratoryContainer.setCharacterLeft(String.valueOf(containerLeft));
+                    tempSysLaboratoryContainer.setCharacterLeft(containerLeft);
                 }
 
                 if (containerRight != null) {
-                    tempSysLaboratoryContainer.setCharacterRight(String.valueOf(containerRight));
+                    tempSysLaboratoryContainer.setCharacterRight(containerRight);
                 }
-                sysLaboratoryContainer.setId(IDUtils.uuid());
+            //    sysLaboratoryContainer.setId(IDUtils.uuid());
                 sysLaboratoryContainerDao.insertSysLaboratoryContainer(sysLaboratoryContainer);
             }
         }
@@ -568,7 +565,7 @@
 
     @Override
     @Transactional(propagation = Propagation.REQUIRED)
-    public void logoutTestCabinet(String userId, JSONObject jsonObject) throws ApiException {
+    public void logoutTestCabinet(Long userId, JSONObject jsonObject) throws ApiException {
         if (!jsonObject.containsKey("controllerCode")) {
             throw new ApiException(ApiStatus.PARAM_NO_EXIST, ApiStatus.PARAM_NO_EXIST.getRetMsg() + "[controllerCode]");
         }
@@ -647,7 +644,7 @@
 
     @Transactional(propagation = Propagation.REQUIRED)
     @Override
-    public void updateTestCabinet(String userId, JSONObject jsonObject) throws ApiException {
+    public void updateTestCabinet(Long userId, JSONObject jsonObject) throws ApiException {
         if (!jsonObject.containsKey("updateTime")) {
             throw new ApiException(ApiStatus.PARAM_NO_EXIST, ApiStatus.PARAM_NO_EXIST.getRetMsg() + "[updateTime]");
         }
@@ -786,8 +783,8 @@
                 throw new ApiException(ApiStatus.PARAM_NULL, ApiStatus.PARAM_NULL.getRetMsg() + "[barCode]");
             }
 
-            Integer containerLeft = containerDateJson.getInteger("left");
-            Integer containerRight = containerDateJson.getInteger("right");
+            Long containerLeft = containerDateJson.getLong("left");
+            Long containerRight = containerDateJson.getLong("right");
             String containerName = containerDateJson.getString("containerName");
 
             if (containerPlace == 0) {
@@ -810,7 +807,7 @@
 
                 if (sysWarehouseContainer == null) {
                     SysWarehouseContainer tempSysWarehouseContainer = new SysWarehouseContainer();
-                    tempSysWarehouseContainer.setId(IDUtils.uuid());
+                  //  tempSysWarehouseContainer.setId(IDUtils.uuid());
                     tempSysWarehouseContainer.setWarehouseId(sysWarehouse.getId());
 //                    tempSysWarehouseContainer.setType(baseMetaList.get(0).getMetaValue());
                     tempSysWarehouseContainer.setType(baseMetaList.get(0).getId());
@@ -822,11 +819,11 @@
                     tempSysWarehouseContainer.setValidFlag(containerValidFlag);
                     tempSysWarehouseContainer.setControllerCode(controllerCode);
                     if (containerLeft != null) {
-                        tempSysWarehouseContainer.setCharacterLeft(String.valueOf(containerLeft));
+                        tempSysWarehouseContainer.setCharacterLeft(containerLeft);
                     }
 
                     if (containerRight != null) {
-                        tempSysWarehouseContainer.setCharacterRight(String.valueOf(containerRight));
+                        tempSysWarehouseContainer.setCharacterRight(containerRight);
                     }
 
                     try {
@@ -847,11 +844,11 @@
                     sysWarehouseContainer.setValidFlag(containerValidFlag);
                     sysWarehouseContainer.setControllerCode(controllerCode);
                     if (containerLeft != null) {
-                        sysWarehouseContainer.setCharacterLeft(String.valueOf(containerLeft));
+                        sysWarehouseContainer.setCharacterLeft(containerLeft);
                     }
 
                     if (containerRight != null) {
-                        sysWarehouseContainer.setCharacterRight(String.valueOf(containerRight));
+                        sysWarehouseContainer.setCharacterRight(containerRight);
                     }
 
                     int containerCount = sysWarehouseContainerDao.updateSysWarehouseContainerForInterface(sysWarehouseContainer);
@@ -881,7 +878,7 @@
 
                 if (sysLaboratoryContainer == null) {
                     SysLaboratoryContainer tempSysLaboratoryContainer = new SysLaboratoryContainer();
-                    tempSysLaboratoryContainer.setId(IDUtils.uuid());
+               //     tempSysLaboratoryContainer.setId(IDUtils.uuid());
                     tempSysLaboratoryContainer.setLaboratoryId(sysLaboratory.getId());
 //                    tempSysLaboratoryContainer.setType(baseMetaList.get(0).getMetaValue());
                     tempSysLaboratoryContainer.setType(baseMetaList.get(0).getId());
@@ -893,11 +890,11 @@
                     tempSysLaboratoryContainer.setValidFlag(containerValidFlag);
                     tempSysLaboratoryContainer.setControllerCode(controllerCode);
                     if (containerLeft != null) {
-                        tempSysLaboratoryContainer.setCharacterLeft(String.valueOf(containerLeft));
+                        tempSysLaboratoryContainer.setCharacterLeft(containerLeft);
                     }
 
                     if (containerRight != null) {
-                        tempSysLaboratoryContainer.setCharacterRight(String.valueOf(containerRight));
+                        tempSysLaboratoryContainer.setCharacterRight(containerRight);
                     }
                     try {
                         sysLaboratoryContainerDao.insertSysLaboratoryContainer(sysLaboratoryContainer);
@@ -916,11 +913,11 @@
                     sysLaboratoryContainer.setValidFlag(containerValidFlag);
                     sysLaboratoryContainer.setControllerCode(controllerCode);
                     if (containerLeft != null) {
-                        sysLaboratoryContainer.setCharacterLeft(String.valueOf(containerLeft));
+                        sysLaboratoryContainer.setCharacterLeft(containerLeft);
                     }
 
                     if (containerRight != null) {
-                        sysLaboratoryContainer.setCharacterRight(String.valueOf(containerRight));
+                        sysLaboratoryContainer.setCharacterRight(containerRight);
                     }
 
                     int containerCount = sysLaboratoryContainerDao.updateSysLaboratoryContainerForInterface(sysLaboratoryContainer);
@@ -943,7 +940,7 @@
 
     @Override
     @Transactional(propagation = Propagation.REQUIRED)
-    public String openCabinetDoor(String userId, JSONObject jsonObject) throws ApiException {
+    public String openCabinetDoor(Long userId, JSONObject jsonObject) throws ApiException {
         if (!jsonObject.containsKey("controllerCode")) {
             throw new ApiException(ApiStatus.PARAM_NO_EXIST, ApiStatus.PARAM_NO_EXIST.getRetMsg() + "[contollerCode]");
         }
@@ -968,7 +965,7 @@
             throw new ApiException(ApiStatus.PARAM_NO_EXIST, ApiStatus.PARAM_NO_EXIST.getRetMsg() + "[userID]");
         }
 
-        String userID = jsonObject.getString("userID");
+        Long userID = Long.valueOf(jsonObject.getString("userID"));
 
         if (userID == null || "".equals(userID)) {
             throw new ApiException(ApiStatus.PARAM_NULL, ApiStatus.PARAM_NULL.getRetMsg() + "[userID]");
@@ -1080,9 +1077,9 @@
             if (!dataJson.containsKey("userID")) {
                 throw new ApiException(ApiStatus.PARAM_NO_EXIST, ApiStatus.PARAM_NO_EXIST.getRetMsg() + "[userID]");
             }
-            String userId = dataJson.getString("userID");
+            Long userId = dataJson.getString("userID")!=null?Long.valueOf(dataJson.getString("userID")):null;
 
-            if (userId == null || "".equals(userId)) {
+            if (userId == null) {
                 throw new ApiException(ApiStatus.PARAM_NULL, ApiStatus.PARAM_NULL.getRetMsg() + "[userID]");
             }
 
@@ -1147,12 +1144,12 @@
                     opeReagentStatus.setReagentCode(reagentCode);
                     opeReagentStatus.setUserId(userId);
                     opeReagentStatus.setContainerId(sysLaboratoryContainer.getId());
-                    opeReagentStatus.setStatus(ArrivalStatus.parse(status));
+                    opeReagentStatus.setStatus(status);
                     opeReagentStatusDao.updateOpeReagentStatusDao(opeReagentStatus);
 
                     OpeUseFlow opeUseFlow = new OpeUseFlow();
                     opeUseFlow.setReagentCode(reagentCode);
-                    opeUseFlow.setStatus(ArrivalStatus.parse(status));
+                    opeUseFlow.setStatus(status);
                     opeUseFlow.setHouseId(queryOpeReagentStatus.getHouseId());
                     opeUseFlow.setContainerId(sysLaboratoryContainer.getId());
                     opeUseFlow.setUserId(userId);
@@ -1162,7 +1159,7 @@
                     opeUseFlow.setPlace(queryOpeReagentStatus.getPlace());
                     opeUseFlow.setStoreType(queryOpeReagentStatus.getStoreType());
                     opeUseFlow.setValidFlag(queryOpeReagentStatus.getValidFlag());
-                    opeUseFlow.setId(IDUtils.uuid());
+                //    opeUseFlow.setId(IDUtils.uuid());
                     opeUseFlowDao.insertOpeUseFlow(opeUseFlow);
                 }
 
@@ -1172,13 +1169,13 @@
                 opeReagentStatus.setReagentCode(reagentCode);
                 opeReagentStatus.setUserId(userId);
                 opeReagentStatus.setContainerId(sysWarehouseContainer.getId());
-                opeReagentStatus.setStatus(ArrivalStatus.parse(status));
+                opeReagentStatus.setStatus(status);
                 opeReagentStatusDao.updateOpeReagentStatusDao(opeReagentStatus);
 
                 OpeUseFlow opeUseFlow = new OpeUseFlow();
-                opeUseFlow.setId(IDUtils.uuid());
+            //    opeUseFlow.setId(IDUtils.uuid());
                 opeUseFlow.setReagentCode(reagentCode);
-                opeUseFlow.setStatus(ArrivalStatus.parse(status));
+                opeUseFlow.setStatus(status);
                 opeUseFlow.setHouseId(queryOpeReagentStatus.getHouseId());
                 opeUseFlow.setContainerId(sysWarehouseContainer.getId());
                 opeUseFlow.setUserId(userId);
@@ -1558,7 +1555,7 @@
                         JSONObject res = data2.getJSONObject("data");
                         String refId = res.getString("id");
                         if (StringUtils.isNotBlank(refId)) {
-                            sysAlarmPerson.setRefId(refId);
+                            sysAlarmPerson.setRefId(Long.valueOf(refId));
                         }
                     } else {
                         //请求错误打印日志
@@ -1697,7 +1694,7 @@
 
 	@Override
     @Transactional(propagation = Propagation.REQUIRED)
-    public void cabinetData(JSONArray jsonObject) throws ApiException {
+    public void cabinetData(JSONArray jsonObject,Long userId) throws ApiException {
 
     	Iterator<Object> dataIt = jsonObject.iterator();
     	 while(dataIt.hasNext()) {
@@ -1712,49 +1709,59 @@
 			//    		 操作状态	operateState	Integer	○
     		 // 非空检查
              if (!dataJson.containsKey("status")
-                     || !dataJson.containsKey("realstatus")
-                     || !dataJson.containsKey("containerCode")
                      || !dataJson.containsKey("reagentCode")
                      || !dataJson.containsKey("updateTime")
+                     || !dataJson.containsKey("labContainerId")
                      || !dataJson.containsKey("operateState")
             		 ) {
                  throw new ApiException(ApiStatus.PARAM_NO_EXIST);
              }
 
-			Integer status = dataJson.getInteger("status");
-			Integer realstatus = dataJson.getInteger("realstatus");
-			String containerCode = dataJson.getString("containerCode");
+			ArrivalStatus status = ArrivalStatus.parse(Integer.valueOf(String.valueOf(dataJson.get("status"))));
+
+
+            Long labContainerId = Long.valueOf(dataJson.getString("labContainerId"));
 			String reagentCode = dataJson.getString("reagentCode");
-			String idcard = dataJson.getString("idcard");
-			String updateTime = dataJson.getString("updateTime");
+             String updateTime = dataJson.getString("updateTime");
 			BigDecimal remainder = dataJson.getBigDecimal("remainder");
-			String operateState = dataJson.getString("operateState");
+			Integer operateState = Integer.valueOf(dataJson.getString("operateState"));
              BigDecimal volume = dataJson.getBigDecimal("volume");
+             Date createtime = null;
+             SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+             try {
+                 createtime = sdf.parse(updateTime);
+             } catch (ParseException e) {
+                 throw new ApiException(ApiStatus.PARAM_ERR);
+             }
 
-			Map<String, String> metaMap = new HashMap<>();
-            metaMap.put("groupId", "operate_status");
-            metaMap.put("metaKey", String.valueOf(operateState));
-            List<BaseMeta> baseMetaList = baseMetaDao.getBaseMetaList(metaMap);
-
-			Date createtime = null;
-			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-			try {
-				 createtime = sdf.parse(updateTime);
-			} catch (ParseException e) {
-				throw new ApiException(ApiStatus.PARAM_ERR);
+			SysUser user = sysUserDao.getUser(userId);
+			if (user == null ) {
+				throw new ApiException(ApiStatus.PARAM_ERR, "userid: "+userId);
 			}
-
-			SysUser user = sysUserDao.getSysUserByIdCard(idcard);
-
-			if (user == null || user.getIdCard() == null) {
-				throw new ApiException(ApiStatus.PARAM_ERR, "idcard: "+idcard);
-			}
+            if(operateState==OperateStatus.STORE.getKey()){
+                List<OpeUseFlow> useFlowList = opeUseFlowDao.getUseFlowByCodeAndStatus(reagentCode,OperateStatus.WAREHOUSEOUT.getKey());
+                if(useFlowList.size()==0){
+                    throw new ApiException(ApiStatus.PARAM_ERR, "仓库领用后才能进行存放操作");
+                }
+            }
+             if(operateState==OperateStatus.USE.getKey()){
+                 List<OpeUseFlow> useFlowList = opeUseFlowDao.getUseFlowByCodeAndStatus(reagentCode,OperateStatus.STORE.getKey());
+                 if(useFlowList.size()==0){
+                     throw new ApiException(ApiStatus.PARAM_ERR, "存放的试剂才能进行领用操作");
+                 }
+             }
+             if(operateState==OperateStatus.SCRAP.getKey()){
+                 List<OpeUseFlow> useFlowList = opeUseFlowDao.getUseFlowByCodeAndStatuses(reagentCode,Arrays.asList(new Integer[]{OperateStatus.STORE.getKey(),OperateStatus.USE.getKey()}));
+                 if(useFlowList.size()==0){
+                     throw new ApiException(ApiStatus.PARAM_ERR, "存放或者领用的试剂才能进行报废操作");
+                 }
+             }
 
 			OpeUseFlow opeUseFlow = new OpeUseFlow();
 			opeUseFlow.setReagentCode(reagentCode);
-			opeUseFlow.setUserId(user.getId());
+			opeUseFlow.setUserId(userId);
 			opeUseFlow.setRemainder(remainder);
-			opeUseFlow.setOperateState(baseMetaList.get(0).getId());
+			opeUseFlow.setOperateState(Integer.valueOf(operateState));
 			opeUseFlow.setCreateTime(new java.sql.Timestamp(createtime.getTime()));
             opeUseFlow.setVolume(volume);
 
@@ -1790,30 +1797,44 @@
 //					continue;
 //				}
 //			}
-
-			opeUseFlow.setStatus(ArrivalStatus.parse(Integer.valueOf(String.valueOf(dataJson.get("status")))));
-			SysLaboratoryContainer sysLaboratoryContainer = sysLaboratoryContainerDao
-					.getSysLaboratoryContainerByContainerCode(containerCode);
+             OpeReagentStatus opeReagentStatus = new OpeReagentStatus();
+             opeReagentStatus.setReagentCode(reagentCode);
+             opeReagentStatus.setUserId(user.getId());
+             Integer reagentStatus=null;
+             if(operateState==OperateStatus.SCRAP.getKey()){//试剂报废
+                 reagentStatus=ArrivalStatus.SCRAP.getKey();
+             }else if(operateState==OperateStatus.USE.getKey()){
+                 reagentStatus=ArrivalStatus.PERSONAL.getKey();
+             }else if(operateState==OperateStatus.LABORATORYIN.getKey()){
+                 reagentStatus=ArrivalStatus.WAREHOUSE.getKey();
+             }else if(operateState==OperateStatus.STORE.getKey()){
+                 reagentStatus=ArrivalStatus.LABORATORY.getKey();
+             }else if(operateState==OperateStatus.WAREHOUSEOUT.getKey()){
+                 reagentStatus=ArrivalStatus.NOREGISTER.getKey();
+             }
+             if(reagentStatus!=null){
+                 opeReagentStatus.setStatus(reagentStatus);
+                 opeReagentStatusDao.updateOpeReagentStatusByCode(opeReagentStatus);
+             }
+			opeUseFlow.setStatus(reagentStatus);
+			SysLaboratoryContainer sysLaboratoryContainer = sysLaboratoryContainerDao.getSysLaboratoryContainer(labContainerId);
 
 			if (Objects.isNull(sysLaboratoryContainer) == false) {
 				opeUseFlow.setContainerId(sysLaboratoryContainer.getId());
 				opeUseFlow.setHouseId(sysLaboratoryContainer.getLaboratoryId());
 			} else {
-				SysWarehouseContainer container = sysWarehouseContainerDao
-						.getSysWarehouseContainerByContainerCode(containerCode);
+				SysWarehouseContainer container = sysWarehouseContainerDao.getSysWarehouseContainer(labContainerId);
 				if (Objects.isNull(container) == false) {
-
 					opeUseFlow.setContainerId(container.getId());
 					opeUseFlow.setHouseId(container.getWarehouseId());
 
 				} else {
-					logger.error("The containerCode has not been exists!");
-					continue;
+                    logger.error("The containerCode has not been exists!");
+                    throw new ApiException(ApiStatus.PARAM_NO_EXIST,"The containerCode has not been exists!");
 				}
 			}
              int count = opeUseFlowService.getOpeUseFlow(opeUseFlow);
              if (count < 1) {
-
                  this.opeUseFlowService.insertOpeUseFlow(opeUseFlow);
              }
     	 }
@@ -1866,11 +1887,12 @@
                 sysAlarmPerson.setWarningId(baseMetaList.get(0).getId());
                 List<SysAlarmPerson> sysAlarmPersonList = sysAlarmPersonDao.selectByCode(containerCode, baseMetaList.get(0).getId());
                 for (SysAlarmPerson sysAlarm : sysAlarmPersonList) {
-                    if (!"".equals(alarmUrl) && StringUtils.isNotBlank(sysAlarm.getRefId()) && ("1".equals(warning) || "2".equals(warning))) {
+                    if (!"".equals(alarmUrl) && sysAlarm.getRefId()!= null && ("1".equals(warning) || "2".equals(warning))) {
                         SysWarning sysWarning = new SysWarning();
-                        sysWarning.setId(String.valueOf(sysAlarm.getId()));
+                        //-----------------待改善---------------------20230408
+                        sysWarning.setId(sysAlarm.getId());
                         sysWarning.setStatus(1);
-                        sysWarning.setAlarmId(sysAlarm.getRefId());
+                        sysWarning.setDapingAlarmId(sysAlarm.getRefId());
                         sysWarningService.updateSysWarning(sysWarning);
                     }else {
                         Map<String,Object> params = new HashMap<>();
@@ -1882,4 +1904,64 @@
             }
         }
     }
+
+    @Override
+    public List<SysLaboratory> getLabAndContainerByUserId(Long userId) throws ApiException {
+        SysUser user=sysUserDao.getSysUser(userId);
+        if(user==null){
+            throw new ApiException(ApiStatus.SYS_ERR,"用户不存在");
+        }
+        Long projectId=user.getProjectId();
+        if(projectId==null){
+            throw new ApiException(ApiStatus.SYS_ERR,"用户未选择课题组");
+        }
+        List<SysLaboratory> sysLaboratoryList=this.sysLaboratoryDao.getLaboratoryByProjectId(projectId);
+        return sysLaboratoryList;
+    }
+
+    @Override
+    public List<OpeUseFlow> getReagentUseFlowList(String reagentCode) throws ApiException {
+        return this.opeUseFlowDao.getOpeUseFlowByCode2(reagentCode);
+    }
+
+    @Override
+    public List<SysLaboratory> getLaboratoryByUserId(Long userId) throws ApiException {
+        SysUser user=sysUserDao.getSysUser(userId);
+        if(user==null){
+            throw new ApiException(ApiStatus.SYS_ERR,"用户不存在");
+        }
+        Long projectId=user.getProjectId();
+        if(projectId==null){
+            throw new ApiException(ApiStatus.SYS_ERR,"用户未选择课题组");
+        }
+        return this.opeReagentStatusDao.getLabNoContainerByProjectId(projectId);
+    }
+
+    @Override
+    public Map<String,Object> getOpeUseFlowByUserId(Integer pageNum,Integer pageSize,Long userId,Integer operatestate,String startDate,String endDate) throws ApiException, ParseException {
+        Map<String,Object> params=new HashMap();
+        params.put("userId",userId);
+        params.put("first", (pageNum-1)*pageSize);
+        params.put("pageSize", pageSize);
+        if(operatestate!=null){
+            params.put("operatestate",operatestate);
+        }
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        if(startDate!=null){
+            params.put("startDate", sdf.format(sdf.parse(startDate)));
+        }
+        if(endDate!=null){
+            params.put("endDate", sdf.format(sdf.parse(endDate)));
+        }
+        Long totalCunt=opeUseFlowDao.getOpeUseFlowSimpleInfoCount(params);
+        List<OpeUseFlow> opeUseFlowList= opeUseFlowDao.getOpeUseFlowSimpleInfoList(params);
+        Map<String,Object> resMap=new HashMap<>();
+        resMap.put("totalCount",totalCunt);
+        resMap.put("pageNum",pageNum);
+        resMap.put("pageSize",pageSize);
+        resMap.put("list",opeUseFlowList);
+        return resMap;
+    }
+
+
 }

--
Gitblit v1.9.2