kongzy
2024-07-01 47a751cb301d05276ae5d75145d57b2d090fe4e1
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;
@@ -82,6 +79,8 @@
    @Resource
    SysLaboratoryContainerService sysLaboratoryContainer;
    @Resource
    SysLaboratoryService sysLaboratoryService;
    @Value("${message.url}")
    String url;
@@ -104,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]");
        }
@@ -226,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) {
@@ -260,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
@@ -301,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
@@ -322,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")) {
@@ -450,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) {
@@ -477,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));
@@ -489,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);
@@ -521,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));
@@ -533,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);
            }
        }
@@ -556,7 +555,6 @@
        // containerRight 对应 DB character_right
        // createTimestamp 对应 DB create_time
        System.out.println("1111111111111111111111111");
//       注册接口没有之前的关系
//
//        //清除之前的记录,然后关联现在的关系
@@ -567,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]");
        }
@@ -646,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]");
        }
@@ -785,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) {
@@ -809,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());
@@ -821,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 {
@@ -846,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);
@@ -880,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());
@@ -892,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);
@@ -915,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);
@@ -942,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]");
        }
@@ -967,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]");
@@ -1079,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]");
            }
@@ -1146,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);
@@ -1161,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);
                }
@@ -1171,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);
@@ -1225,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);
@@ -1286,6 +1287,7 @@
        }
    }
    //货柜预警接口
    @Override
    @Transactional(propagation = Propagation.REQUIRED)
    public void alarm(JSONObject jsonObject) throws ApiException {
@@ -1313,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
@@ -1350,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){
@@ -1408,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){
@@ -1480,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 {
                        //请求错误打印日志
@@ -1489,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);
@@ -1606,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()) {
@@ -1621,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:报废-->
@@ -1697,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);
             }
        }
@@ -1773,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<>();
@@ -1789,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;
    }
}