From 47a751cb301d05276ae5d75145d57b2d090fe4e1 Mon Sep 17 00:00:00 2001
From: kongzy <kongzy>
Date: Mon, 01 Jul 2024 10:58:35 +0800
Subject: [PATCH] change
---
src/main/java/com/nanometer/smartlab/service/InterfaceServiceImpl.java | 452 +++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 344 insertions(+), 108 deletions(-)
diff --git a/src/main/java/com/nanometer/smartlab/service/InterfaceServiceImpl.java b/src/main/java/com/nanometer/smartlab/service/InterfaceServiceImpl.java
index ddf7301..76adaf4 100644
--- a/src/main/java/com/nanometer/smartlab/service/InterfaceServiceImpl.java
+++ b/src/main/java/com/nanometer/smartlab/service/InterfaceServiceImpl.java
@@ -5,23 +5,21 @@
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;
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;
@@ -33,15 +31,19 @@
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
+import java.util.stream.Collectors;
@Service("interfaceService")
public class InterfaceServiceImpl implements InterfaceService {
private static Logger logger = Logger.getLogger(ApiAction.class);
-
+ @Lazy
@Resource
private OpeUseFlowService opeUseFlowService;
-
+ @Resource
+ private SysWarningService sysWarningService;
+ @Resource(name = "sysWarningDao")
+ SysWarningDao sysWarningDao;
@Resource(name = "sysWarehouseDao")
SysWarehouseDao sysWarehouseDao;
@@ -77,6 +79,8 @@
@Resource
SysLaboratoryContainerService sysLaboratoryContainer;
+ @Resource
+ SysLaboratoryService sysLaboratoryService;
@Value("${message.url}")
String url;
@@ -99,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]");
}
@@ -221,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) {
@@ -255,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
@@ -296,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
@@ -317,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")) {
@@ -445,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) {
@@ -472,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));
@@ -484,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);
@@ -516,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));
@@ -528,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);
}
}
@@ -551,7 +555,6 @@
// containerRight 对应 DB character_right
// createTimestamp 对应 DB create_time
- System.out.println("1111111111111111111111111");
// 注册接口没有之前的关系
//
// //清除之前的记录,然后关联现在的关系
@@ -562,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]");
}
@@ -641,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]");
}
@@ -780,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) {
@@ -804,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());
@@ -816,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 {
@@ -841,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);
@@ -875,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());
@@ -887,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);
@@ -910,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);
@@ -937,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]");
}
@@ -962,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]");
@@ -1004,7 +1007,7 @@
}else{
sysUser = sysUserDao.getSysUser(userID);
// 如果是管理员也可以开柜
- if(sysUser.getSeeFlag() == SeeFlag.MANAGE){
+ if(sysUser.getSeeFlag() == SeeFlag.MANAGE||sysUser.getSeeFlag() == SeeFlag.LEADING){
return "1";
} else {
// 不可以打开柜子
@@ -1032,7 +1035,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);
@@ -1074,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]");
}
@@ -1141,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);
@@ -1156,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);
}
@@ -1166,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);
@@ -1220,6 +1223,9 @@
SysUser user = sysUserDao.getSysUserByIdCard(idcard);
LinkedHashMap params = new LinkedHashMap();
+ if (user == null) {
+ throw new ApiException(ApiStatus.PARAM_ERR,"无相关人员卡号");
+ }
params.put("userId", user.getId());
params.put("realstatus", realstatus);
params.put("reagentCode", reagentCode);
@@ -1249,7 +1255,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) {
@@ -1273,11 +1280,14 @@
if (status.equals(-1)){
continue;
}
- opeReagentStatusDao.syncOpeReagentStatus(params);
-
+ int i = opeReagentStatusDao.syncOpeReagentStatus(params);
+ if (i < 1){
+ opeReagentStatusDao.syncOpeReagentStatus(params);
+ }
}
}
+ //货柜预警接口
@Override
@Transactional(propagation = Propagation.REQUIRED)
public void alarm(JSONObject jsonObject) throws ApiException {
@@ -1305,7 +1315,7 @@
String containerCode = dataJson.getString("containerCode");
//check containerCode是否存在
- SysLaboratoryContainer sysLaboratoryContainer = sysLaboratoryContainerDao
+ SysLaboratoryContainer LaboratoryContainer = sysLaboratoryContainerDao
.getSysLaboratoryContainerByContainerCode(containerCode);
if (Objects.isNull(sysLaboratoryContainer) == true) {
SysWarehouseContainer container = sysWarehouseContainerDao
@@ -1342,8 +1352,82 @@
} catch (ParseException e) {
throw new ApiException(ApiStatus.PARAM_ERR);
}
-
+ //判断是否重复
+ logger.info("测试");
+ if (sysAlarmDao.selectOne(containerCode, controllerCode, sysAlarm.getWarningId(), sysAlarm.getWarningTime()) > 0) {
+ continue;
+ }
sysAlarmDao.insertSysAlarm(sysAlarm);
+ try {
+ if (enable && "01".equals(warningId)) {
+ SysLaboratory sysLaboratory = sysLaboratoryService.getSysLaboratory(LaboratoryContainer.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);
+ StringBuffer phones = new StringBuffer();
+
+ //实验室负责人手机号
+ if (personsInCharge != null && personsInCharge.size() > 0) {
+ personsInCharge.forEach(person -> {
+ Object phone = person.get("phone");
+ if (phone != null && !"".equals(phone)) {
+ phones.append(phone);
+ phones.append(",");
+ }
+
+ });
+ }
+ //所及负责人手机号
+ if (managers != null && managers.size() > 0) {
+ managers.forEach(manager -> {
+ String phone = manager.getMetaValue();
+ if (phone != null && !"".equals(phone)) {
+ phones.append(phone);
+ phones.append(",");
+ }
+ });
+ }
+ if (phones.length() > 0) {
+ phones.deleteCharAt(phones.length() - 1);
+
+ }
+
+ Map location = sysLaboratoryContainer.selectLocationByContainerCode(containerCode);
+ String messageFormat = "名称:%s,具体地点:%s,柜号:%s,";
+ String content = String.format(messageFormat, location.get("name"),location.get("location"), containerCode);
+
+ String suffix = String.format("?head=%s&signature=%s&content=%s&telnumber=%s", head, signature, content + baseMetaList.get(0).getMetaValue(), phones.toString().replace(" ", ""));
+ CloseableHttpClient client = HttpClients.createDefault();
+ HttpPost post = new HttpPost(url + suffix);
+ post.setHeader("Content-Type", "application/json;charset=UTF-8");
+ CloseableHttpResponse response = client.execute(post);
+ String resData = EntityUtils.toString(response.getEntity(), "UTF-8");
+ client.close();
+ JSONObject res = JSONObject.parseObject(resData);
+ if ("200".equals(res.getString("code")) && phones.length() > 0) {
+ String memo = String.format("短信已发送[%s]", phones);
+ }
+ logger.info(resData);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ logger.warn(e);
+ }
+ //增加发送短信接口 key:01 value:主电掉电,备电工作
+
+
+
//
// Integer warningPoint = dataJson.getInteger("warningPoint");
// if(warningPoint == null){
@@ -1400,7 +1484,6 @@
Integer warningPoint = dataJson.getInteger("warningPoint");
SysUser user = sysUserDao.getSysUserByIdCard(idcard);
- System.out.println("====="+user);
if(user==null){
System.out.println(idcard.length());
if(idcard.length()==20){
@@ -1448,7 +1531,7 @@
}
//给daping系统发送信息
- if(!"".equals(alarmUrl) && ("1".equals(warningId) || "2".equals(warningId)|| "6".equals(warningId)) ) {
+ if(!"".equals(alarmUrl) && ("1".equals(warningId) || "2".equals(warningId))){
JSONObject json = new JSONObject();
json.put("barCode", location.get("barCode"));
json.put("type", alarmType);
@@ -1472,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 {
//请求错误打印日志
@@ -1481,7 +1564,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);
@@ -1529,15 +1625,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());
- }
+
}
}
@@ -1597,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()) {
@@ -1612,49 +1709,61 @@
// 操作状态 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);
// <!--0:个人领用 1:在仓库sys_warehouse_container
// 2:在实验室sys_laboratory_container 3:报废-->
@@ -1688,29 +1797,46 @@
// 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!");
}
}
-
- this.opeUseFlowService.insertOpeUseFlow(opeUseFlow);
+ int count = opeUseFlowService.getOpeUseFlow(opeUseFlow);
+ if (count < 1) {
+ this.opeUseFlowService.insertOpeUseFlow(opeUseFlow);
+ }
}
}
@@ -1728,4 +1854,114 @@
public JSONObject getUserInfo(JSONObject jsonObject) {
return null;
}
+
+ // 人员违规预警接口
+ @Override
+ public void delalarmperson(JSONObject jsonObject) throws Exception {
+ JSONArray dataArr = jsonObject.getJSONArray("data");
+ Iterator<Object> dataIt = dataArr.iterator();
+ while (dataIt.hasNext()) {
+ JSONObject dataJson = JSONObject.parseObject(dataIt.next().toString());
+ // 货柜条码 containerCode String ○
+ // 报警类别 warningId Integer ○
+ if (!dataJson.containsKey("warningId") || !dataJson.containsKey("containerCode")) {
+ throw new ApiException(ApiStatus.PARAM_NO_EXIST);
+ }
+ String containerCode = dataJson.getString("containerCode");
+ String warningId = dataJson.getString("warningId");
+ List<String> warningList = Arrays.asList(warningId.split(","));
+ List<String> warningList1 = new ArrayList<>(Arrays.asList("1","2","3","4","5","6"));
+ List<String> delWarnings = warningList1.stream().filter(o->!warningList.contains(o)).collect(Collectors.toList());//新的不在原有里面的
+
+ for (String warning : delWarnings){
+ Map<String, String> metaMap = new HashMap<>();
+ metaMap.put("groupId", "user_violate_type");
+ metaMap.put("metaKey", warning);
+
+ List<BaseMeta> baseMetaList = baseMetaDao.getBaseMetaList(metaMap);
+ if (baseMetaList == null || baseMetaList.size() != 1) {
+ throw new ApiException(ApiStatus.PARAM_ERR, ApiStatus.PARAM_ERR.getRetMsg() + "[warningId]");
+ }
+ SysAlarmPerson sysAlarmPerson = new SysAlarmPerson();
+ sysAlarmPerson.setContainerCode(containerCode);
+ sysAlarmPerson.setWarningId(baseMetaList.get(0).getId());
+ List<SysAlarmPerson> sysAlarmPersonList = sysAlarmPersonDao.selectByCode(containerCode, baseMetaList.get(0).getId());
+ for (SysAlarmPerson sysAlarm : sysAlarmPersonList) {
+ if (!"".equals(alarmUrl) && sysAlarm.getRefId()!= null && ("1".equals(warning) || "2".equals(warning))) {
+ SysWarning sysWarning = new SysWarning();
+ //-----------------待改善---------------------20230408
+ sysWarning.setId(sysAlarm.getId());
+ sysWarning.setStatus(1);
+ sysWarning.setDapingAlarmId(sysAlarm.getRefId());
+ sysWarningService.updateSysWarning(sysWarning);
+ }else {
+ Map<String,Object> params = new HashMap<>();
+ params.put("status",1);
+ params.put("id", String.valueOf(sysAlarm.getId()));
+ sysWarningDao.updateSysWarning(params);
+ }
+ }
+ }
+ }
+ }
+
+ @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