From 1e90eceefceef5ea5c637785235bc587cf41e4c9 Mon Sep 17 00:00:00 2001
From: lyfO_o <764716047@qq.com>
Date: 星期四, 21 十月 2021 09:40:50 +0800
Subject: [PATCH] 模块:api接口 修改:发送实验室负责人改为实验室下课题组下的所有实验室负责人 提:秦老师

---
 src/main/java/com/nanometer/smartlab/service/InterfaceServiceImpl.java |   55 +++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 39 insertions(+), 16 deletions(-)

diff --git a/src/main/java/com/nanometer/smartlab/service/InterfaceServiceImpl.java b/src/main/java/com/nanometer/smartlab/service/InterfaceServiceImpl.java
index ee87d4d..0d496f9 100644
--- a/src/main/java/com/nanometer/smartlab/service/InterfaceServiceImpl.java
+++ b/src/main/java/com/nanometer/smartlab/service/InterfaceServiceImpl.java
@@ -22,6 +22,7 @@
 import org.apache.http.util.EntityUtils;
 import org.apache.log4j.Logger;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
@@ -39,7 +40,7 @@
 public class InterfaceServiceImpl implements InterfaceService {
 
     private static Logger logger = Logger.getLogger(ApiAction.class);
-
+    @Lazy
 	@Resource
 	private OpeUseFlowService opeUseFlowService;
 	@Resource
@@ -81,6 +82,8 @@
 
     @Resource
     SysLaboratoryContainerService sysLaboratoryContainer;
+    @Resource
+    SysLaboratoryService sysLaboratoryService;
 
     @Value("${message.url}")
     String url;
@@ -1008,7 +1011,7 @@
         }else{
           sysUser = sysUserDao.getSysUser(userID);
           // 如果是管理员也可以开柜
-          if(sysUser.getSeeFlag() == SeeFlag.MANAGE){
+          if(sysUser.getSeeFlag() == SeeFlag.MANAGE||sysUser.getSeeFlag() == SeeFlag.LEADING){
         	  return "1";
           } else {
 	          // 不可以打开柜子
@@ -1036,7 +1039,7 @@
         }
         List<String> projects = sysLaboratoryContainer.selectProjectsByContainerCode(containerCode);
         List<SysUser> userList = null;
-        if (projects != null) {
+        if (projects != null && projects.size() > 0){
             userList = new ArrayList<>();
             for (String project : projects) {
                 List<SysUser> dataList = sysUserDao.getUserListByProject(project, startTime, endTime);
@@ -1253,7 +1256,8 @@
                     logger.error("The containerCode has not been exists!");
                     continue;
                 }
-			} else if (status.equals(2)){
+			}
+			else if (status.equals(2)){
 				/*SysWarehouseContainer container = sysWarehouseContainerDao
 						.getSysWarehouseContainerByContainerCode(containerCode);
 				if (Objects.isNull(container) == false) {
@@ -1277,8 +1281,10 @@
 			if (status.equals(-1)){
                 continue;
             }
- 			opeReagentStatusDao.syncOpeReagentStatus(params);
-
+ 			int i = opeReagentStatusDao.syncOpeReagentStatus(params);
+            if (i < 1){
+                opeReagentStatusDao.syncOpeReagentStatus(params);
+            }
     	 }
     }
 
@@ -1485,7 +1491,20 @@
                 }
 
             if(enable && "2".equals(warningId) ) {
-                List<Map> personsInCharge = sysLaboratoryContainer.getContainerPersonInCharge(containerCode);
+                //1.根据containerCode获取lab
+                SysLaboratoryContainer container = sysLaboratoryContainer.getSysLaboratoryContainerByContainerCode(containerCode);
+                SysLaboratory sysLaboratory = sysLaboratoryService.getSysLaboratory(container.getLaboratoryId());
+                String project = sysLaboratory.getProject();
+                //2.根据Lab的课题组判断人员
+                List<Map> personsInCharge = null;
+                if (StringUtils.isBlank(project)) {
+                    //没有课题组就是实验室部门下的负责人
+                    personsInCharge = sysLaboratoryContainer.getContainerPersonInCharge(containerCode);
+                } else {
+                    //有课题组就是 所有课题组下的人员负责人
+                    personsInCharge = sysLaboratoryService.getPersonInChargeByProjects(project);
+                }
+
                 Map param = new HashMap();
                 param.put("groupId", "securityManager");
                 List<BaseMeta> managers = baseMetaDao.getBaseMetaList(param);
@@ -1533,15 +1552,16 @@
 
             }
                 sysAlarmPersonDao.insertSysAlarmPerson(sysAlarmPerson);
+                // 将人员扣分更新到人员表
+                if (warningPoint == null) {
+                    warningPoint = 0;
+                }
+                 //	SysUser user = sysUserDao.getSysUser(userId);
+                if (user != null) {
+                    sysUserDao.updateUserPointBySelective(user.getPoint() - warningPoint, user.getId());
+                }
 			}
-            // 将人员扣分更新到人员表
-			if (warningPoint == null) {
-				warningPoint = 0;
-			}
-//			SysUser user = sysUserDao.getSysUser(userId);
-			if (user != null) {
-				sysUserDao.updateUserPointBySelective(user.getPoint() - warningPoint, user.getId());
-			}
+
 
 		}
     }
@@ -1713,8 +1733,11 @@
 					continue;
 				}
 			}
+             int count = opeUseFlowService.getOpeUseFlow(opeUseFlow);
+             if (count < 1) {
 
-			this.opeUseFlowService.insertOpeUseFlow(opeUseFlow);
+                 this.opeUseFlowService.insertOpeUseFlow(opeUseFlow);
+             }
     	 }
     }
 

--
Gitblit v1.9.2