Index: ssts-packing/src/main/java/com/forgon/disinfectsystem/packing/service/PackingManagerImpl.java =================================================================== diff -u -r35717 -r35720 --- ssts-packing/src/main/java/com/forgon/disinfectsystem/packing/service/PackingManagerImpl.java (.../PackingManagerImpl.java) (revision 35717) +++ ssts-packing/src/main/java/com/forgon/disinfectsystem/packing/service/PackingManagerImpl.java (.../PackingManagerImpl.java) (revision 35720) @@ -275,8 +275,7 @@ private StorageLocationManager storageLocationManager; private ClassifiedItemManager classifiedItemManager; - - private CleanMethodManager cleanMethodManager; + private InstrumentInstanceManager instrumentInstanceManager; private DiposableGoodsManager diposableGoodsManager; @@ -288,9 +287,6 @@ InstrumentInstanceManager instrumentInstanceManager) { this.instrumentInstanceManager = instrumentInstanceManager; } - public void setCleanMethodManager(CleanMethodManager cleanMethodManager) { - this.cleanMethodManager = cleanMethodManager; - } /** * 聚合包装配 */ @@ -1654,6 +1650,7 @@ Map invoicePlanIDToPatient = new HashMap();//申请单对应的病人map //收集装配任务的信息,统一查询申请单 collectPackingTaskInfo(invoicePlanIDToPatient, taskList); + StringBuffer sbf = new StringBuffer(); for (Object[] result : taskList) { PackingTask task = (PackingTask)result[0]; TousseDefinition td = (TousseDefinition)result[1]; @@ -1740,7 +1737,7 @@ if(StringUtils.isNotBlank(basketBarcode) && StringUtils.isNotBlank(itemVo.getBasketBarcode()) && !td.cleanedEntirely() && !basketBarcode.equals(itemVo.getBasketBarcode())){ String basketBarcodesStrOfitemVo = itemVo.getBasketBarcode(); String [] basketBarcodesOfitemVo = basketBarcodesStrOfitemVo.split(";"); - String msg = ""; + sbf.setLength(0); for (int i = 0; i < basketBarcodesOfitemVo.length; i++) { if(basketBarcode.equals(basketBarcodesOfitemVo[i])){ continue;//不查询扫描的条码 @@ -1753,14 +1750,14 @@ } if(unAWashedClassifyBasket != null){ unWashedClassifyBasketMap.put(unAWashedClassifyBasket.getContainerBarcode(), unAWashedClassifyBasket); - if(StringUtils.isNotBlank(msg)){ - msg += "、"; + if(sbf.length() > 0){ + sbf.append("、"); } - msg += "清洗篮筐" + classifyBasketManager.getClassifyBasket(basketBarcodesOfitemVo[i]).getContainerName(); + sbf.append("清洗篮筐" + classifyBasketManager.getClassifyBasket(basketBarcodesOfitemVo[i]).getContainerName()); } } //例子:清洗篮筐测试7141;测试7142临床大镊子包所在的清洗篮筐测试7141;测试7142 还未完成清洗,需要完成清洗后才能装配! - if(StringUtils.isNotBlank(msg)){ + if(sbf.length() > 0){ String tousseNameStr = null; if(StringUtils.isNotBlank(task.getIdNumber())){ tousseNameStr = tousseName + "-" + task.getIdNumber(); @@ -1769,11 +1766,11 @@ }else{ tousseNameStr = tousseName; } - msg = "【"+ tousseNameStr + "】所在的" + msg; + sbf.insert(0,"【"+ tousseNameStr + "】所在的"); if(StringUtils.isNotBlank(notWashedInfo)){ notWashedInfo += ","; } - notWashedInfo += msg; + notWashedInfo += sbf.toString(); continue;//该提示不能影响其他装配任务,所以不抛异常 } } @@ -1947,8 +1944,7 @@ } boolean isUrgent = false;//是否有加急 如果有 那么页面上看到的装配任务的文件夹要按照紧急程度排序 if(scanBasketTaskMap.size() > 0){ - for (String name : scanBasketTaskMap.keySet()) { - WaitPackingTaskVo vo = scanBasketTaskMap.get(name); + for(WaitPackingTaskVo vo : scanBasketTaskMap.values()){ if(enableUrgentFunction){ Integer urgentAmount = vo.getUrgentAmount(); if(urgentAmount != null && urgentAmount > 0){ @@ -1963,8 +1959,7 @@ } } if(unScanBasketTaskMap.size() > 0){ - for (String name : unScanBasketTaskMap.keySet()) { - WaitPackingTaskVo vo = unScanBasketTaskMap.get(name); + for(WaitPackingTaskVo vo : unScanBasketTaskMap.values()){ if(enableUrgentFunction){ Integer urgentAmount = vo.getUrgentAmount(); if(urgentAmount != null && urgentAmount > 0){ @@ -2285,18 +2280,15 @@ return 0; } Integer maxAmount = 0; - - Set mdIDset = map.keySet(); - List materialInstances = td.getMaterialInstances(); - - for (Long materialDefinitionID : mdIDset) { - if(materialInstances != null){ + if(materialInstances != null){ + for(Entry entry : map.entrySet()){ + Long materialDefinitionID = entry.getKey(); for (MaterialInstance ms : materialInstances) { if(ms.getMaterialDefinition() != null){ if(materialDefinitionID.toString().equals(ms.getMaterialDefinition().getId().toString())){ if(ms.getCount() > 0){ - Integer tousseAmount = MathTools.divide(map.get(materialDefinitionID), ms.getCount()); + Integer tousseAmount = MathTools.divide(entry.getValue(), ms.getCount()); if(maxAmount < tousseAmount){ maxAmount = tousseAmount; } @@ -2305,6 +2297,7 @@ } } } + } } return maxAmount; @@ -2353,7 +2346,7 @@ private List findPackingTaskFromCssdHandleToussesConfig(Long packingTaskId, boolean showRecyclingPeopleColumnInPackingTasksList, String taskGroup,String basketBarcode,SupplyRoomConfig config, List tousseNamesAndTaskTypes, String tousseOrDepart, String recyclingAmountConfirmSql) { boolean enableUrgentFunction = CssdUtils.getSystemSetConfigByNameBool("enableUrgentFunction", false); String orgCode = AcegiHelper.getLoginUser().getOrgUnitCodingFromSupplyRoomConfig(); - String sql = ""; + StringBuffer sbf = new StringBuffer(); String extraOrder = ""; String selectRecyclingUserSql = null; @@ -2367,7 +2360,7 @@ } if(enableUrgentFunction){ extraOrder = " ul.grade desc,"; - sql = "select distinct "+ selectRecyclingUserSql +"td.needInspectMaterials,td.printBOMwhenPrintLabel,po.washRecord_id,po.sourceId, po.recyclingItemRemark,po.serialNumber,po.urgentLevel,po.errorRemark,po.damageRemark, po.id as taskId,recyclingBasketName,basketBarcode,department,po.status,washTime,startTime,unPackAmount,taskType,idCardBarcode,idn.idNumber," + sbf.append("select distinct "+ selectRecyclingUserSql +"td.needInspectMaterials,td.printBOMwhenPrintLabel,po.washRecord_id,po.sourceId, po.recyclingItemRemark,po.serialNumber,po.urgentLevel,po.errorRemark,po.damageRemark, po.id as taskId,recyclingBasketName,basketBarcode,department,po.status,washTime,startTime,unPackAmount,taskType,idCardBarcode,idn.idNumber," + "td.id as tousseDefinitionId,td.invoicePlanID,td.name,td.allowModifyPackageType,td.isDisableIDCard,td.tousseType,td.packagetype,td.sterilingMethod,td.isTraceable,td.packageSize," + "po.remarkOfApplyGoods,td.isPrint,td.isReview,td.uuid_vedioNames,td.isUploadVideo,td.supplierName,urgentAmount,hidePackingTask" + " ,ul.id urgentLevelId,ul.name urgentLevelName,ul.colorCode,ul.grade " @@ -2385,11 +2378,11 @@ + "ct.tousseDefinitionId=td.ancestorID " //+ "and po.orgUnitCoding = ct.orgUnitCode " + "and (td.tousseType not in('"+TousseDefinition.PACKAGE_TYPE_FOREIGN+"','"+TousseDefinition.PACKAGE_TYPE_SPLIT+"','"+TousseDefinition.PACKAGE_TYPE_CUSTOM+"')) " //外来器械和自定义器械,有专门获取装配任务 - + "and ct.taskGroup = '"+taskGroup+"' and po.orgUnitCoding = '" + orgCode + "' and po.unPackAmount > 0 " + recyclingAmountConfirmSql; + + "and ct.taskGroup = '"+taskGroup+"' and po.orgUnitCoding = '" + orgCode + "' and po.unPackAmount > 0 " + recyclingAmountConfirmSql); }else{ extraOrder = " po.urgentAmount desc, "; - sql = "select distinct "+ selectRecyclingUserSql +"td.needInspectMaterials,td.printBOMwhenPrintLabel,po.washRecord_id,po.sourceId, po.recyclingItemRemark,po.serialNumber,po.urgentLevel,po.errorRemark,po.damageRemark, po.id as taskId,recyclingBasketName,basketBarcode,department,po.status,washTime,startTime,unPackAmount,taskType,idCardBarcode,idn.idNumber," + sbf.append("select distinct "+ selectRecyclingUserSql +"td.needInspectMaterials,td.printBOMwhenPrintLabel,po.washRecord_id,po.sourceId, po.recyclingItemRemark,po.serialNumber,po.urgentLevel,po.errorRemark,po.damageRemark, po.id as taskId,recyclingBasketName,basketBarcode,department,po.status,washTime,startTime,unPackAmount,taskType,idCardBarcode,idn.idNumber," + "td.id as tousseDefinitionId,td.invoicePlanID,td.name,td.allowModifyPackageType,td.isDisableIDCard,td.tousseType,td.packagetype,td.sterilingMethod,td.isTraceable,td.packageSize," + "po.remarkOfApplyGoods,td.isPrint,td.isReview,td.uuid_vedioNames,td.isUploadVideo,td.supplierName,urgentAmount,hidePackingTask " + "from PackingTask po " @@ -2401,50 +2394,50 @@ + leftJoinRecyclingRecordSql + "where po.orgUnitCoding = ct.orgUnitCode " + "and (td.tousseType not in('"+TousseDefinition.PACKAGE_TYPE_FOREIGN+"','"+TousseDefinition.PACKAGE_TYPE_SPLIT+"','"+TousseDefinition.PACKAGE_TYPE_CUSTOM+"')) " //外来器械和自定义器械,有专门获取装配任务 - + "and ct.taskGroup = '"+taskGroup+"' and po.orgUnitCoding = '" + orgCode + "' and po.unPackAmount > 0 " + recyclingAmountConfirmSql; + + "and ct.taskGroup = '"+taskGroup+"' and po.orgUnitCoding = '" + orgCode + "' and po.unPackAmount > 0 " + recyclingAmountConfirmSql); } if(DatabaseUtil.isPoIdValid(packingTaskId)){ - sql += " and po.id=" + packingTaskId; + sbf.append(" and po.id=" + packingTaskId); }else if(CollectionUtils.isNotEmpty(tousseNamesAndTaskTypes)){ - sql += " and ("; + sbf.append(" and ("); for (int i = 0; i < tousseNamesAndTaskTypes.size(); i++) { Object[] tousseNamesAndTaskType = tousseNamesAndTaskTypes.get(i); String name = (String)tousseNamesAndTaskType[0]; Integer taskType = (Integer)tousseNamesAndTaskType[1]; if(i > 0){ - sql += " or "; + sbf.append(" or "); } - sql += " td.name='"+ name +"' and po.taskType"; + sbf.append(" td.name='"+ name +"' and po.taskType"); if(taskType == PackingTask.TASK_RECYCLINGRECORD){ - sql += "=1 "; + sbf.append("=1 "); }else{ - sql += "<>1 "; + sbf.append("<>1 "); } } - sql += ") "; + sbf.append(") "); } if(StringUtils.isNotBlank(tousseOrDepart) && !DatabaseUtil.isPoIdValid(packingTaskId)){ // sqlServer如果字符串中有"[",进行转译 if(tousseOrDepart.contains("[") && dbConnection.isSqlServer()){ int index = tousseOrDepart.indexOf("["); tousseOrDepart = tousseOrDepart.substring(0, index) + "\\" + tousseOrDepart.substring(index, tousseOrDepart.length()); - sql += " and (td.spelling like '%" + tousseOrDepart + "%' "+ " escape '\\' " +" or td.wbCode like '%" + sbf.append(" and (td.spelling like '%" + tousseOrDepart + "%' "+ " escape '\\' " +" or td.wbCode like '%" + tousseOrDepart + "%' "+ " escape '\\' " +" or td.externalCode like '%" + tousseOrDepart - + "%' "+ " escape '\\' " +" or td.name like '%" + tousseOrDepart + "%' "+ " escape '\\' "; + + "%' "+ " escape '\\' " +" or td.name like '%" + tousseOrDepart + "%' "+ " escape '\\' "); }else{ - sql += " and (td.spelling like '%" + tousseOrDepart + "%' or td.wbCode like '%" + sbf.append(" and (td.spelling like '%" + tousseOrDepart + "%' or td.wbCode like '%" + tousseOrDepart + "%' or td.externalCode like '%" + tousseOrDepart - + "%' or td.name like '%" + tousseOrDepart + "%' "; + + "%' or td.name like '%" + tousseOrDepart + "%' "); } tousseOrDepart = StringTools.defaultString(tousseOrDepart).toUpperCase(); Pattern pat = Pattern.compile("[\\u4E00-\\u9FA5]+"); // 匹配中文字符的正则表达式 Matcher m = pat.matcher(tousseOrDepart); if (tousseOrDepart.trim().length() > 0) { if (m.find()) { - sql += " or po.departCoding in (select orgUnitCoding from OrgUnit where name like '%" + tousseOrDepart + "%')) "; + sbf.append(" or po.departCoding in (select orgUnitCoding from OrgUnit where name like '%" + tousseOrDepart + "%')) "); } else { - sql += " or po.departCoding in (select orgUnitCoding from OrgUnit where spelling like '%" + tousseOrDepart - + "%' or wbCode like '%" + tousseOrDepart + "%')) "; + sbf.append(" or po.departCoding in (select orgUnitCoding from OrgUnit where spelling like '%" + tousseOrDepart + + "%' or wbCode like '%" + tousseOrDepart + "%')) "); } } } @@ -2477,11 +2470,10 @@ if(!isPackingAfterWashTimeEnd(classifyBasket)){ throw new RuntimeException("该篮筐清洗未结束,请清洗结束后再扫描!"); } - sql += " and po.basketBarcode like '%" + basketBarcode + "%' "; + sbf.append(" and po.basketBarcode like '%" + basketBarcode + "%' "); } - - sql += " order by "+ extraOrder +"po.id asc"; - return findPackingTaskBySql(sql); + sbf.append(" order by "+ extraOrder +"po.id asc"); + return findPackingTaskBySql(sbf.toString()); } /** @@ -2547,7 +2539,8 @@ selectRecyclingUserSql = ""; leftJoinRecyclingRecordSql = ""; } - String sql = "select "+ selectRecyclingUserSql +"td.needInspectMaterials,td.printBOMwhenPrintLabel,po.classifyBasket_id,po.classifyBasketIds,po.washRecord_id,po.sourceId, po.recyclingItemRemark,po.serialNumber,po.errorRemark,po.damageRemark, po.id as taskId,recyclingBasketName,basketBarcode,department,po.status,washTime,startTime,unPackAmount,taskType,idCardBarcode,idn.idNumber," + StringBuffer sbf = new StringBuffer(); + sbf.append("select "+ selectRecyclingUserSql +"td.needInspectMaterials,td.printBOMwhenPrintLabel,po.classifyBasket_id,po.classifyBasketIds,po.washRecord_id,po.sourceId, po.recyclingItemRemark,po.serialNumber,po.errorRemark,po.damageRemark, po.id as taskId,recyclingBasketName,basketBarcode,department,po.status,washTime,startTime,unPackAmount,taskType,idCardBarcode,idn.idNumber," + "td.id as tousseDefinitionId,td.invoicePlanID,td.name,td.allowModifyPackageType,td.isDisableIDCard,td.tousseType,td.packagetype,td.sterilingMethod,td.isTraceable,td.packageSize," + "po.remarkOfApplyGoods,td.isPrint,td.isReview,td.uuid_vedioNames,td.isUploadVideo,td.supplierName,urgentAmount,urgentLevel,hidePackingTask " + urgentlevelQuery @@ -2559,7 +2552,7 @@ + urgentlevelJoin + leftJoinRecyclingRecordSql + " where (td.tousseType='"+TousseDefinition.PACKAGE_TYPE_FOREIGN + "' or td.tousseType='" + TousseDefinition.PACKAGE_TYPE_SPLIT + "')" - + " and po.orgUnitCoding = '" + orgCode + "' " + recyclingAmountConfirmSql; + + " and po.orgUnitCoding = '" + orgCode + "' " + recyclingAmountConfirmSql); Container basket = null; if(StringUtils.isNotBlank(basketBarcode)){ //验证篮筐是否清洗 @@ -2573,54 +2566,54 @@ || Container.CONTAINER_STATUS_WASHING.equals(status)) { return null; } - sql += " and po.basketBarcode like '%" + basketBarcode + "%' "; + sbf.append(" and po.basketBarcode like '%" + basketBarcode + "%' "); } if(DatabaseUtil.isPoIdValid(packingTaskId)){ - sql += " and po.id=" + packingTaskId; + sbf.append(" and po.id=" + packingTaskId); }else if(CollectionUtils.isNotEmpty(tousseNamesAndTaskTypes)){ - sql += " and ("; + sbf.append(" and ("); for (int i = 0; i < tousseNamesAndTaskTypes.size(); i++) { Object[] tousseNamesAndTaskType = tousseNamesAndTaskTypes.get(i); String name = (String)tousseNamesAndTaskType[0]; Integer taskType = (Integer)tousseNamesAndTaskType[1]; if(i > 0){ - sql += " or "; + sbf.append(" or "); } - sql += " td.name='"+ name +"' and po.taskType"; + sbf.append(" td.name='"+ name +"' and po.taskType"); if(taskType == PackingTask.TASK_RECYCLINGRECORD){ - sql += "=1 "; + sbf.append("=1 "); }else{ - sql += "<>1 "; + sbf.append("<>1 "); } } - sql += ") "; + sbf.append(") "); } if(StringUtils.isNotBlank(tousseOrDepart) && !DatabaseUtil.isPoIdValid(packingTaskId)){ // sqlServer如果字符串中有"[",进行转译 if(tousseOrDepart.contains("[") && dbConnection.isSqlServer()){ int index = tousseOrDepart.indexOf("["); tousseOrDepart = tousseOrDepart.substring(0, index) + "\\" + tousseOrDepart.substring(index, tousseOrDepart.length()); - sql += " and (td.spelling like '%" + tousseOrDepart + "%' "+ " escape '\\' " +" or td.wbCode like '%" + sbf.append(" and (td.spelling like '%" + tousseOrDepart + "%' "+ " escape '\\' " +" or td.wbCode like '%" + tousseOrDepart + "%' "+ " escape '\\' " +" or td.externalCode like '%" + tousseOrDepart - + "%' "+ " escape '\\' " +" or td.name like '%" + tousseOrDepart + "%' "+ " escape '\\' "; + + "%' "+ " escape '\\' " +" or td.name like '%" + tousseOrDepart + "%' "+ " escape '\\' "); }else{ - sql += " and (td.spelling like '%" + tousseOrDepart + "%' or td.wbCode like '%" + sbf.append(" and (td.spelling like '%" + tousseOrDepart + "%' or td.wbCode like '%" + tousseOrDepart + "%' or td.externalCode like '%" + tousseOrDepart - + "%' or td.name like '%" + tousseOrDepart + "%' "; + + "%' or td.name like '%" + tousseOrDepart + "%' "); } tousseOrDepart = StringTools.defaultString(tousseOrDepart).toUpperCase(); Pattern pat = Pattern.compile("[\\u4E00-\\u9FA5]+"); // 匹配中文字符的正则表达式 Matcher m = pat.matcher(tousseOrDepart); if (tousseOrDepart.trim().length() > 0) { if (m.find()) { - sql += " or po.departCoding in (select orgUnitCoding from OrgUnit where name like '%" + tousseOrDepart + "%')) "; + sbf.append(" or po.departCoding in (select orgUnitCoding from OrgUnit where name like '%" + tousseOrDepart + "%')) "); } else { - sql += " or po.departCoding in (select orgUnitCoding from OrgUnit where spelling like '%" + tousseOrDepart - + "%' or wbCode like '%" + tousseOrDepart + "%')) "; + sbf.append(" or po.departCoding in (select orgUnitCoding from OrgUnit where spelling like '%" + tousseOrDepart + + "%' or wbCode like '%" + tousseOrDepart + "%')) "); } } } - return findPackingTaskBySql(sql); + return findPackingTaskBySql(sbf.toString()); } /** @@ -2641,7 +2634,8 @@ selectRecyclingUserSql = ""; leftJoinRecyclingRecordSql = ""; } - String sql = "select "+ selectRecyclingUserSql +"td.needInspectMaterials,td.printBOMwhenPrintLabel,po.washRecord_id,po.sourceId, po.recyclingItemRemark,po.serialNumber, po.errorRemark,po.damageRemark, po.id as taskId,recyclingBasketName,basketBarcode,department,po.status,washTime,startTime,unPackAmount,taskType,idCardBarcode,idn.idNumber," + StringBuffer sbf = new StringBuffer(); + sbf.append("select "+ selectRecyclingUserSql +"td.needInspectMaterials,td.printBOMwhenPrintLabel,po.washRecord_id,po.sourceId, po.recyclingItemRemark,po.serialNumber, po.errorRemark,po.damageRemark, po.id as taskId,recyclingBasketName,basketBarcode,department,po.status,washTime,startTime,unPackAmount,taskType,idCardBarcode,idn.idNumber," + "td.id as tousseDefinitionId,td.invoicePlanID,td.name,td.allowModifyPackageType,td.isDisableIDCard,td.tousseType,td.packagetype,td.sterilingMethod,td.isTraceable,td.packageSize," + "po.remarkOfApplyGoods,td.isPrint,td.isReview,td.uuid_vedioNames,td.isUploadVideo,td.supplierName,urgentAmount,urgentLevel,hidePackingTask " + "from PackingTask po " @@ -2650,7 +2644,7 @@ + " left join IDCardInstance ii on ii.id=ifp.idCardInstanceID " + " left join IDCardDefinition idn on idn.id=ii.idCardDefinitionID " + leftJoinRecyclingRecordSql - + "where td.tousseType='"+TousseDefinition.PACKAGE_TYPE_CUSTOM+"' and po.orgUnitCoding = '" + orgCode + "' " + recyclingAmountConfirmSql; + + "where td.tousseType='"+TousseDefinition.PACKAGE_TYPE_CUSTOM+"' and po.orgUnitCoding = '" + orgCode + "' " + recyclingAmountConfirmSql); if(StringUtils.isNotBlank(basketBarcode)){ //验证篮筐是否清洗 Container basket = containerManager @@ -2661,54 +2655,54 @@ || Container.CONTAINER_STATUS_WASHING.equals(status)) { return null; } - sql += " and po.basketBarcode like '%" + basketBarcode + "%' "; + sbf.append(" and po.basketBarcode like '%" + basketBarcode + "%' "); } if(DatabaseUtil.isPoIdValid(packingTaskId)){ - sql += " and po.id=" + packingTaskId; + sbf.append(" and po.id=" + packingTaskId); }else if(CollectionUtils.isNotEmpty(tousseNamesAndTaskTypes)){ - sql += " and ("; + sbf.append(" and ("); for (int i = 0; i < tousseNamesAndTaskTypes.size(); i++) { Object[] tousseNamesAndTaskType = tousseNamesAndTaskTypes.get(i); String name = (String)tousseNamesAndTaskType[0]; Integer taskType = (Integer)tousseNamesAndTaskType[1]; if(i > 0){ - sql += " or "; + sbf.append(" or "); } - sql += " td.name='"+ name +"' and po.taskType"; + sbf.append(" td.name='\"+ name +\"' and po.taskType "); if(taskType == PackingTask.TASK_RECYCLINGRECORD){ - sql += "=1 "; + sbf.append("=1 "); }else{ - sql += "<>1 "; + sbf.append("<>1 "); } } - sql += ") "; + sbf.append(") "); } if(StringUtils.isNotBlank(tousseOrDepart) && !DatabaseUtil.isPoIdValid(packingTaskId)){ // sqlServer如果字符串中有"[",进行转译 if(tousseOrDepart.contains("[") && dbConnection.isSqlServer()){ int index = tousseOrDepart.indexOf("["); tousseOrDepart = tousseOrDepart.substring(0, index) + "\\" + tousseOrDepart.substring(index, tousseOrDepart.length()); - sql += " and (td.spelling like '%" + tousseOrDepart + "%' "+ " escape '\\' " +" or td.wbCode like '%" + sbf.append(" and (td.spelling like '%" + tousseOrDepart + "%' "+ " escape '\\' " +" or td.wbCode like '%" + tousseOrDepart + "%' "+ " escape '\\' " +" or td.externalCode like '%" + tousseOrDepart - + "%' "+ " escape '\\' " +" or td.name like '%" + tousseOrDepart + "%' "+ " escape '\\' "; + + "%' "+ " escape '\\' " +" or td.name like '%" + tousseOrDepart + "%' "+ " escape '\\' "); }else{ - sql += " and (td.spelling like '%" + tousseOrDepart + "%' or td.wbCode like '%" + sbf.append(" and (td.spelling like '%" + tousseOrDepart + "%' or td.wbCode like '%" + tousseOrDepart + "%' or td.externalCode like '%" + tousseOrDepart - + "%' or td.name like '%" + tousseOrDepart + "%' "; + + "%' or td.name like '%" + tousseOrDepart + "%' "); } tousseOrDepart = StringTools.defaultString(tousseOrDepart).toUpperCase(); Pattern pat = Pattern.compile("[\\u4E00-\\u9FA5]+"); // 匹配中文字符的正则表达式 Matcher m = pat.matcher(tousseOrDepart); if (tousseOrDepart.trim().length() > 0) { if (m.find()) { - sql += " or po.departCoding in (select orgUnitCoding from OrgUnit where name like '%" + tousseOrDepart + "%')) "; + sbf.append(" or po.departCoding in (select orgUnitCoding from OrgUnit where name like '%\" + tousseOrDepart + \"%')) "); } else { - sql += " or po.departCoding in (select orgUnitCoding from OrgUnit where spelling like '%" + tousseOrDepart - + "%' or wbCode like '%" + tousseOrDepart + "%')) "; + sbf.append(" or po.departCoding in (select orgUnitCoding from OrgUnit where spelling like '%" + tousseOrDepart + + "%' or wbCode like '%" + tousseOrDepart + "%')) "); } } } - return findPackingTaskBySql(sql); + return findPackingTaskBySql(sbf.toString()); } /** @@ -4502,8 +4496,9 @@ List result = new ArrayList(); Set splitIndexs = new HashSet<>(); - for (Long classifyBasketId : map.keySet()) { - ForeignTousseSplitVo packageItem = map.get(classifyBasketId); + for(Entry entry : map.entrySet()){ + Long classifyBasketId = entry.getKey(); + ForeignTousseSplitVo packageItem = entry.getValue(); List materials = packageItem.getMaterialsJsonArray(); int toolAmount = 0; int implantAmount = 0; @@ -5446,12 +5441,13 @@ } List newImageFileList = new ArrayList(); List deleteImageFileList = new ArrayList(); - for (Long packTaskId : packTaskIdToTousseInstanceIdMap.keySet()) { + for(Entry> entry : packTaskIdToTousseInstanceIdMap.entrySet()){ + Long packTaskId = entry.getKey(); List packingImageList = packingTaskIdToImageMap.get(packTaskId); if(CollectionUtils.isEmpty(packingImageList)){ continue; } - List tousseInstanceIdList = packTaskIdToTousseInstanceIdMap.get(packTaskId); + List tousseInstanceIdList = entry.getValue(); if(CollectionUtils.isEmpty(tousseInstanceIdList)){ continue; } @@ -5485,12 +5481,13 @@ } List newVideoFileList = new ArrayList(); List deleteVideoFileList = new ArrayList(); - for (Long packTaskId : packTaskIdToTousseInstanceIdMap.keySet()) { + for(Entry> entry : packTaskIdToTousseInstanceIdMap.entrySet()){ + Long packTaskId = entry.getKey(); List packingVideoList = packingTaskIdToVideoMap.get(packTaskId); if(CollectionUtils.isEmpty(packingVideoList)){ continue; } - List tousseInstanceIdList = packTaskIdToTousseInstanceIdMap.get(packTaskId); + List tousseInstanceIdList = entry.getValue(); if(CollectionUtils.isEmpty(tousseInstanceIdList)){ continue; } @@ -6273,13 +6270,13 @@ Integer currentUrgentAmount = urgentAmountJson.optInt("currentUrgentAmount"); if(currentUrgentAmount > 0){ boolean findUrgentTask = false; - String ids = ""; + StringBuffer idSbf = new StringBuffer(); //从现有的装配任务中找加急的任务 for(PackingTask packingTask : packingTaskList){ - if(StringUtils.isNotBlank(ids)){ - ids += ","; + if(idSbf.length() > 0){ + idSbf.append(","); } - ids += packingTask.getId(); + idSbf.append(packingTask.getId()); if(packingTask.getUrgentAmount() != null && packingTask.getUrgentAmount() > 0){ packingTask.setUrgentAmount(packingTask.getUrgentAmount() - 1); if(packingTask.getUrgentAmount() == null || packingTask.getUrgentAmount() == 0){ @@ -6295,17 +6292,18 @@ } //从数据库中找加急的任务 if(!findUrgentTask){ - String sql = String.format("select po.id as taskId from PackingTask po , CssdHandleTousses ct , TousseDefinition td" - + " where po.tousseDefinition_id = td.id and ct.tousseDefinitionId=td.ancestorID and po.orgUnitCoding = ct.orgUnitCode" - + " and ct.taskGroup = '%s' and po.orgUnitCoding = '%s' and td.ancestorID = %s and po.urgentAmount > 0" - + " and po.id not in(%s)", taskGroup,orgUnitCoding,tousseDefinition.getAncestorID(), ids); + StringBuffer sqlSbf = new StringBuffer(); + sqlSbf.append(String.format("select po.id as taskId from PackingTask po , CssdHandleTousses ct , TousseDefinition td" + + " where po.tousseDefinition_id = td.id and ct.tousseDefinitionId=td.ancestorID and po.orgUnitCoding = ct.orgUnitCode" + + " and ct.taskGroup = '%s' and po.orgUnitCoding = '%s' and td.ancestorID = %s and po.urgentAmount > 0" + + " and po.id not in(%s)", taskGroup,orgUnitCoding,tousseDefinition.getAncestorID(), idSbf.toString())); if(StringUtils.isNotBlank(basketBarcode)){ - sql += " and po.basketBarcode like '%" + basketBarcode + "%'"; + sqlSbf.append(" and po.basketBarcode like '%" + basketBarcode + "%'"); } - sql += " order by po.urgentAmount desc"; + sqlSbf.append(" order by po.urgentAmount desc"); - ResultSet rs = objectDao.executeSql(sql); + ResultSet rs = objectDao.executeSql(sqlSbf.toString()); try { while(rs.next()){ String taskId = rs.getString("taskId"); @@ -8457,6 +8455,7 @@ if(includeTousseJsonArray == null || includeTousseJsonArray.size() == 0){ throw new RuntimeException(comboTousseName + "内物品不能为空!"); } + StringBuffer sbf = new StringBuffer(); for(int j = 0 ; j < includeTousseJsonArray.size() ; j++){ JSONObject tousseJson = includeTousseJsonArray.optJSONObject(j); Long tousseDefinitionId = tousseJson.optLong("id"); @@ -8470,24 +8469,24 @@ }else{ taskList = findPackingTaskBySQL(tousseDefinitionId, handlerDepartCode, list,true); } - String ids = ""; + sbf.setLength(0); if(taskList != null){ for (PackingTask packingTask : taskList) { if(amount <= 0){ break; } - if(StringUtils.isNotBlank(ids)){ - ids += ";"; + if(sbf.length() > 0){ + sbf.append(";"); } - ids += packingTask.getId(); + sbf.append(packingTask.getId()); amount -= packingTask.getUnPackAmount(); } } if(taskList == null || amount > 0){ throw new RuntimeException(tousseName + "当前可装配数量小于" + packingAmount + ",装配失败!"); } //关联上装配任务id - tousseJson.put("taskIds", ids); + tousseJson.put("taskIds", sbf.toString()); tousseJson.put("packAmount", packingAmount); } } @@ -8916,8 +8915,9 @@ //丢失、报损项关联器械包实例 for (TousseInstance ti : tousseList) { Map errAmountMap = new HashMap(); - for (Long key : materialMap.keySet()) { - List result = materialMap.get(key); + for(Entry> entry : materialMap.entrySet()){ + Long key = entry.getKey(); + List result = entry.getValue(); if(result == null){ throw new RuntimeException("数据异常,请联系管理员!"); } @@ -8983,9 +8983,10 @@ String errorMsg = null; String damageMsg = null; String msg = ""; - for (String mapKey : errAmountMap.keySet()) { + for(Entry entry : errAmountMap.entrySet()){ + String mapKey = entry.getKey(); + Integer amount = entry.getValue(); String[] keyArr = mapKey.split("_"); - Integer amount = errAmountMap.get(mapKey); if(amount == null || amount.intValue() == 0){ continue; }