Index: ssts-wash/src/main/java/com/forgon/disinfectsystem/washanddisinfectmanager/washanddisinfectrecord/service/WashAndDisinfectRecordManagerImpl.java =================================================================== diff -u -r34717 -r34968 --- ssts-wash/src/main/java/com/forgon/disinfectsystem/washanddisinfectmanager/washanddisinfectrecord/service/WashAndDisinfectRecordManagerImpl.java (.../WashAndDisinfectRecordManagerImpl.java) (revision 34717) +++ ssts-wash/src/main/java/com/forgon/disinfectsystem/washanddisinfectmanager/washanddisinfectrecord/service/WashAndDisinfectRecordManagerImpl.java (.../WashAndDisinfectRecordManagerImpl.java) (revision 34968) @@ -44,6 +44,8 @@ import com.forgon.databaseadapter.service.DateQueryAdapter; import com.forgon.directory.acegi.tools.AcegiHelper; import com.forgon.directory.model.BarcodeDevice; +import com.forgon.directory.model.OrgUnit; +import com.forgon.directory.model.OrgUserRelation; import com.forgon.directory.vo.LoginUserData; import com.forgon.disinfectsystem.barcode.service.BarcodeManager; import com.forgon.disinfectsystem.barcodepredicate.BarcodeOperators; @@ -5331,4 +5333,181 @@ } return result; } + + @Override + public void submitWashAndDisinfectRecord(String requestBody) { + if(StringUtils.isBlank(requestBody)){ + throw new SystemException("请求参数不能为空!"); + } + JSONObject requestJson = JSONObject.fromObject(requestBody); + if(requestJson == null){ + throw new SystemException("请求参数格式异常!"); + } + //内镜镜身号,对应标识牌定义的编号idNumber + String endoscopeIdentifier = requestJson.optString("endoscopeIdentifier"); + if(StringUtils.isBlank(endoscopeIdentifier)){ + throw new SystemException("内镜镜身号【endoscopeIdentifier】不能为空!"); + } + //内镜名 + String endoscopeName = requestJson.optString("endoscopeName"); + + //清洗机名称 + String washMachineName = requestJson.optString("washMachineName"); + if(StringUtils.isBlank(washMachineName)){ + throw new SystemException("清洗机名称【washMachineName】不能为空!"); + } + Rinser rinser = rinserManager.getRinserByName(washMachineName); + if(rinser == null){ + throw new SystemException("不存在名称为【" + washMachineName + "】的清洗机!"); + } + + //清洗步骤名称 + String processStepName = requestJson.optString("processStepName"); + if(StringUtils.isBlank(processStepName)){ + throw new SystemException("清洗步骤名称【processStepName】不能为空!"); + } + //检查清洗程序是否存在 + CleanMethod cleanMethod = cleanMethodManager.getCleanMethodByName(processStepName); + if(cleanMethod == null){ + throw new SystemException("清洗程序【" + processStepName + "】不存在!"); + } + //检查清洗程序是否被清洗机添加 + Set cleanMethods = rinser.getCleanMethods(); + if(CollectionUtils.isEmpty(cleanMethods)){ + throw new SystemException("清洗机【" + washMachineName + "】没有添加清洗程序!"); + } + boolean cleanMethodValid = false; + for(CleanMethod c : cleanMethods){ + if(StringUtils.equals(c.getCleanMethod(), processStepName)){ + cleanMethodValid = true; + break; + } + } + if(!cleanMethodValid){ + throw new SystemException("清洗机【" + washMachineName + "】没有添加清洗程序【" + processStepName + "】!"); + } + + //清洗开始时间 + Long startTime = requestJson.optLong("startTime"); + if(!DatabaseUtil.isPoIdValid(startTime)){ + throw new SystemException("清洗开始时间【startTime】无效!"); + } + //清洗结束时间 + Long finishTime = requestJson.optLong("finishTime"); + if(!DatabaseUtil.isPoIdValid(finishTime)){ + throw new SystemException("清洗结束时间【finishTime】无效!"); + } + if(finishTime <= startTime){ + throw new SystemException("清洗开始时间【startTime】不能大于清洗结束时间【finishTime】!"); + } + + //操作人 + String operator = requestJson.optString("operator"); + if(StringUtils.isBlank(operator)){ + throw new SystemException("操作人【operator】不能为空!"); + } + User operatorUser = getOperatorUser(operator, rinser.getOrgUnitCoding()); + if(operatorUser == null){ + throw new SystemException("不存在名称为【" + operator + "】,所属科室为【" + rinser.getDepartment() + "】的用户!"); + } + String operatorCode = operatorUser.getName(); + + //位置 + String location = requestJson.optString("location"); + + WashAndDisinfectRecord washRecord = new WashAndDisinfectRecord(); + washRecord.setOrgUnitCoding(rinser.getOrgUnitCoding()); + washRecord.setDisinfectIdentification(washMachineName); + washRecord.setDisinfectProgram(processStepName); + washRecord.setEndDate(new Date(startTime)); + washRecord.setOperator(operator); + washRecord.setOperatorCode(operatorCode); + washRecord.setStartDate(new Date(finishTime)); + //washRecord.setWashPersonInCharge(washPersonInCharge); + //washRecord.setWashPersonInChargeCode(washPersonInChargeCode); + + if(StringUtils.equals(rinser.getConCurrent(), Rinser.CONCURRENT_DISABLE)){ + //验证该清洗机上一次清洗是否已经结束,如果没有,则不允许添加新清洗记录 + boolean exist = validateWashIsEnd(washMachineName, washRecord.getStartDate(), washRecord.getEndDate()); + if (exist && !DatabaseUtil.isPoIdValid(washRecord.getId())) { + throw new RuntimeException(washMachineName + "正在清洗,不能添加清洗记录。"); + } + } + + //根据内镜镜身号,获取清洗篮筐 + Map classifyBasketInfoMap = getEndoscopeClassifyBasketInfoMap(endoscopeIdentifier, endoscopeName, location); + + //保存清洗记录 + this.saveOrUpdateWashAndDisinfectRecordAndMaterials(washRecord, classifyBasketInfoMap, null, null); + } + + /** + * 根据内镜镜身号获取清洗篮筐信息 + * @param endoscopeIdentifier + * @return + */ + private Map getEndoscopeClassifyBasketInfoMap( + String endoscopeIdentifier, String endoscopeName, String position) { + Map classifyBasketInfoMap = new HashMap(); + if(StringUtils.isNotBlank(endoscopeIdentifier)){ + ClassifyBasket classifyBasket = getEndoscopeClassifyBasket(endoscopeIdentifier, endoscopeName); + Long classifyBasketID = classifyBasket.getId(); + classifyBasket.setPosition(position); + classifyBasketInfoMap.put(classifyBasketID, classifyBasket); + } + return classifyBasketInfoMap; + } + + /** + * 根据内镜镜身号获取清洗篮筐实例 + * @param endoscopeIdentifier + * @return + */ + private ClassifyBasket getEndoscopeClassifyBasket(String endoscopeIdentifier, String endoscopeName) { + List IDCardDefinitionList = idCardDefinitionManager.getByProperty("idNumber", endoscopeIdentifier); + if(CollectionUtils.isEmpty(IDCardDefinitionList)){ + throw new SystemException("未找到编号为【" + endoscopeIdentifier + "】的标识牌!"); + } + if(IDCardDefinitionList.size() > 1){ + throw new SystemException("存在多个编号为【" + endoscopeIdentifier + "】的标识牌!"); + } + IDCardDefinition idCardDefinition = IDCardDefinitionList.get(0); + JSONObject basketJson = beCleanItemManager.loadContentOfJSONByBasketBarcode( + idCardDefinition.getContainerBarcode(), false, false); + if(basketJson == null){ + throw new SystemException("未找到【" + endoscopeName + "】对应的清洗篮筐!"); + } + if(!basketJson.optBoolean(JSONUtil.JSON_KEY_SUCCESS)){ + throw new SystemException("【" + endoscopeName + "】绑定的篮筐不能添加清洗记录," + basketJson.optString("message")); + } + Long classifyBasketId = basketJson.optLong("classifyBasketID"); + ClassifyBasket classifyBasket = classifyBasketManager.get(classifyBasketId); + if(classifyBasket == null){ + throw new SystemException("未找到【" + endoscopeName + "】对应的清洗篮筐!"); + } + return classifyBasket; + } + + /** + * 根据名称和科室查找用户 + * @param operator + * @param orgUnitCoding + * @return + */ + private User getOperatorUser(String operator, String orgUnitCoding) { + List userList = userManager.getByProperty("fullName", operator); + if(CollectionUtils.isEmpty(userList)){ + return null; + } + for (User user : userList) { + Set orgUserRelationSet = user.getOrgUserRelations(); + for (OrgUserRelation orgUserRelation : orgUserRelationSet) { + OrgUnit orgUnit = orgUserRelation.getOrgUnit(); + if(orgUnit != null && StringUtils.equals(orgUnit.getOrgUnitCoding(), orgUnitCoding)){ + return user; + } + } + } + return null; + } } Index: ssts-wash/src/main/java/com/forgon/disinfectsystem/washanddisinfectmanager/washanddisinfectrecord/controller/WashAndDisinfectRecordController.java =================================================================== diff -u -r28549 -r34968 --- ssts-wash/src/main/java/com/forgon/disinfectsystem/washanddisinfectmanager/washanddisinfectrecord/controller/WashAndDisinfectRecordController.java (.../WashAndDisinfectRecordController.java) (revision 28549) +++ ssts-wash/src/main/java/com/forgon/disinfectsystem/washanddisinfectmanager/washanddisinfectrecord/controller/WashAndDisinfectRecordController.java (.../WashAndDisinfectRecordController.java) (revision 34968) @@ -3,6 +3,8 @@ */ package com.forgon.disinfectsystem.washanddisinfectmanager.washanddisinfectrecord.controller; +import java.io.BufferedReader; +import java.io.InputStreamReader; import java.util.Map; import javax.servlet.http.HttpServletRequest; @@ -11,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import com.forgon.databaseadapter.service.DateQueryAdapter; @@ -22,15 +25,14 @@ import com.forgon.disinfectsystem.basedata.becleanitem.service.ClassifiedItemManager; import com.forgon.disinfectsystem.basedata.becleanitem.service.ClassifyBasketManager; import com.forgon.disinfectsystem.entity.basedatamanager.container.Container; -import com.forgon.disinfectsystem.entity.basedatamanager.deviceinterface.DeviceInterface; -import com.forgon.disinfectsystem.entity.basedatamanager.rinser.Rinser; import com.forgon.disinfectsystem.entity.becleanitem.ClassifyBasket; import com.forgon.disinfectsystem.entity.washanddisinfectmanager.washData.WashDataOfMarge; import com.forgon.disinfectsystem.entity.washanddisinfectmanager.washanddisinfectrecord.WashAndDisinfectRecord; import com.forgon.disinfectsystem.idcarddefinition.service.IDCardDefinitionManager; import com.forgon.disinfectsystem.tousse.materialdefinition.service.MaterialDefinitionManager; import com.forgon.disinfectsystem.washanddisinfectmanager.washanddisinfectrecord.service.WashAndDisinfectRecordManager; import com.forgon.exception.service.ExceptionHandler; +import com.forgon.log.model.Log; import com.forgon.log.service.LogManager; import com.forgon.tools.db.DatabaseUtil; import com.forgon.tools.hibernate.ObjectDao; @@ -227,4 +229,41 @@ result = JSONUtil.buildJsonObject(true, data); return result.toString(); } + + /** + * 【接收内镜系统推送的清洗记录】的接口(ZSWY-175) + */ + @RequestMapping(value = "/submitWashAndDisinfectRecord", method = RequestMethod.POST) + public String submitWashAndDisinfectRecord(HttpServletRequest request){ + JSONObject result = JSONUtil.buildJsonObject(true, "保存成功"); + BufferedReader streamReader = null; + InputStreamReader inputStreamReader = null; + try { + inputStreamReader = new InputStreamReader(request.getInputStream(), "UTF-8"); + streamReader = new BufferedReader(inputStreamReader); + StringBuilder requestStrBuilder = new StringBuilder(); + String inputStr = null; + while ((inputStr = streamReader.readLine()) != null){ + requestStrBuilder.append(inputStr); + } + String requestBody = requestStrBuilder.toString(); + appLogManager.saveLog(AcegiHelper.getLoginUser(), "调用接口" , Log.TYPE_WRITE, "调用清洗记录登记接口,请求参数:" + requestBody); + washAndDisinfectRecordManager.submitWashAndDisinfectRecord(requestBody); + } catch (Exception e) { + result = JSONUtil.buildJsonObject(false, "保存失败:" + e.getMessage()); + } finally { + if(inputStreamReader != null){ + try { + inputStreamReader.close(); + } catch (Exception e) {} + } + if(inputStreamReader != null){ + try { + inputStreamReader.close(); + } catch (Exception e) {} + } + } + appLogManager.saveLog(AcegiHelper.getLoginUser(), "调用接口" , Log.TYPE_WRITE, "调用清洗记录登记接口,返回参数:" + result.toString()); + return result.toString(); + } } Index: ssts-web/src/main/webapp/WEB-INF/spring/security-standard/applicationContext-acegi-security.xml =================================================================== diff -u -r34902 -r34968 --- ssts-web/src/main/webapp/WEB-INF/spring/security-standard/applicationContext-acegi-security.xml (.../applicationContext-acegi-security.xml) (revision 34902) +++ ssts-web/src/main/webapp/WEB-INF/spring/security-standard/applicationContext-acegi-security.xml (.../applicationContext-acegi-security.xml) (revision 34968) @@ -86,6 +86,7 @@ + Index: ssts-wash/src/main/java/com/forgon/disinfectsystem/washanddisinfectmanager/washanddisinfectrecord/service/WashAndDisinfectRecordManager.java =================================================================== diff -u -r34423 -r34968 --- ssts-wash/src/main/java/com/forgon/disinfectsystem/washanddisinfectmanager/washanddisinfectrecord/service/WashAndDisinfectRecordManager.java (.../WashAndDisinfectRecordManager.java) (revision 34423) +++ ssts-wash/src/main/java/com/forgon/disinfectsystem/washanddisinfectmanager/washanddisinfectrecord/service/WashAndDisinfectRecordManager.java (.../WashAndDisinfectRecordManager.java) (revision 34968) @@ -396,4 +396,33 @@ * @param releaseBasketAfterReturn 是否归还后释放清洗篮筐 */ public void timingAutoCompleteWashRecord(Integer useTime, WashAndDisinfectRecord washRecord, boolean releaseBasketAfterReturn, boolean sleep); + + /** + * 【接收内镜系统推送的清洗记录】的接口(ZSWY-175) + * @param requestBody 请求信息 + * 示例: + * + * { + "id":1, + "processStepName":"初洗", + "processStepType":6, + "startTime":1606787211000, + "finishTime":1606787241000, + "estimatedFinishTime":1606787241000, + "endoscopeName":"支气管镜1", + "endoscopeIdentifier":"EB-1", + "endoscopeId":91, + "endoscopeCycleInstanceId":1, + "operator":"张三", + "operatorId":81, + "finishOperator":"张三", + "finishOperatorId":81, + "washMachineName":"", + "washMachineId":0, + "location":"清洗室#2手洗槽", + "locationId":190, + "morningDisinfection":false + } + */ + public void submitWashAndDisinfectRecord(String requestBody); }