Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/washmethod/action/WashMethodHttpOptionAction.java =================================================================== diff -u --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/washmethod/action/WashMethodHttpOptionAction.java (revision 0) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/washmethod/action/WashMethodHttpOptionAction.java (revision 35751) @@ -0,0 +1,141 @@ +package com.forgon.disinfectsystem.basedatamanager.washmethod.action; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import net.sf.json.JSONObject; +import net.sf.json.JsonConfig; +import net.sf.json.util.CycleDetectionStrategy; + +import org.apache.commons.lang.StringUtils; +import org.apache.struts2.convention.annotation.Action; +import org.apache.struts2.convention.annotation.Namespace; +import org.apache.struts2.convention.annotation.ParentPackage; + +import com.forgon.systemsetting.model.HttpOption; +import com.forgon.systemsetting.service.HttpOptionManager; +import com.forgon.tools.StrutsParamUtils; +import com.forgon.tools.StrutsResponseUtils; +import com.forgon.tools.db.DatabaseUtil; +import com.forgon.tools.json.JSONUtil; +import com.opensymphony.xwork2.ModelDriven; +import com.opensymphony.xwork2.Preparable; + +/** + * 清洗方式的action(ZSSXLRMYY-221) + */ +@ParentPackage(value = "default") +@Namespace(value = "/disinfectSystem/baseData") +@Action(value = "washMethodHttpOptionAction") +public class WashMethodHttpOptionAction implements ModelDriven, Preparable { + + private HttpOption washMethodHttpOption; + + /** + * 修改前的名称 + */ + private String originalWashMethodGroupName; + + private HttpOptionManager httpOptionManager; + + public void setHttpOptionManager(HttpOptionManager httpOptionManager) { + this.httpOptionManager = httpOptionManager; + } + + /** + * 加载清洗方式列表 + */ + public void loadWashMethodHttpOption(){ + List washMethodList = new ArrayList(); + JSONObject result = JSONUtil.buildJsonObject(true); + try { + String id = StrutsParamUtils.getPraramValue("id", ""); + if(DatabaseUtil.isPoIdValid(id)){ + HttpOption washMethod = httpOptionManager.get(id); + washMethodList.add(washMethod); + }else{ + washMethodList = httpOptionManager.getHttpOptionListById(HttpOption.SYSTEMSETTING_WASHMETHOD); + } + + JsonConfig config = new JsonConfig(); + config.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT); + Map map = new HashMap(); + map.put("success", true); + map.put("data", washMethodList); + result = JSONObject.fromObject(map, config); + } catch (Exception e) { + e.printStackTrace(); + result = JSONUtil.buildJsonObject(false, "加载失败:" + e.getMessage()); + } + StrutsResponseUtils.output(result.toString()); + } + + /** + * 保存清洗方式 + */ + public void saveWashMethodHttpOption(){ + JSONObject result = JSONUtil.buildJsonObject(true, "保存成功"); + try { + httpOptionManager.saveWashMethodHttpOption(originalWashMethodGroupName, washMethodHttpOption); + } catch (Exception e) { + e.printStackTrace(); + result = JSONUtil.buildJsonObject(false, "保存失败:" + e.getMessage()); + } + StrutsResponseUtils.output(result.toString()); + } + + /** + * 清洗方式设置 排序 + */ + public void sortWashMethodHttpOption(){ + JSONObject result = JSONUtil.buildJsonObject(true); + //up/down + String orderType = StrutsParamUtils.getPraramValue("orderType", null); + try { + Long id = StrutsParamUtils.getPraramLongValue("id", null); + if(DatabaseUtil.isPoIdValid(id)){ + HttpOption httpOption = httpOptionManager.get(id); + httpOptionManager.sortHttpOption(httpOption, orderType); + } + } catch (Exception e) { + result = JSONUtil.buildJsonObject(false, "操作失败:" + e.getMessage()); + } + StrutsResponseUtils.output(result); + } + + /** + * 删除灭菌炉分组设置 + */ + public void deleteWashMethodHttpHttpOption(){ + JSONObject result = JSONUtil.buildJsonObject(true, "删除成功"); + try { + String ids = StrutsParamUtils.getPraramValue("ids", null); + httpOptionManager.deleteWashMethodHttpHttpOption(ids); + } catch (Exception e) { + result = JSONUtil.buildJsonObject(false, "删除失败:" + e.getMessage()); + } + StrutsResponseUtils.output(result); + } + + @Override + public void prepare() throws Exception { + String id = StrutsParamUtils.getPraramValue("id", ""); + if (StringUtils.isNotBlank(id) && !id.equals("0")) { + washMethodHttpOption = httpOptionManager.get(id); + if(washMethodHttpOption != null){ + originalWashMethodGroupName = washMethodHttpOption.getOptionText(); + } + } else { + washMethodHttpOption = new HttpOption(); + washMethodHttpOption.setOptionListId(HttpOption.SYSTEMSETTING_WASHMETHOD); + } + } + + @Override + public HttpOption getModel() { + return washMethodHttpOption; + } + +} Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/basedatamanager/materialdefinition/MaterialDefinition.java =================================================================== diff -u -r35378 -r35751 --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/basedatamanager/materialdefinition/MaterialDefinition.java (.../MaterialDefinition.java) (revision 35378) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/basedatamanager/materialdefinition/MaterialDefinition.java (.../MaterialDefinition.java) (revision 35751) @@ -177,6 +177,11 @@ private Integer sequence = 0; /** + * 清洗方式ID(ZSSXLRMYY-221【清洗方式设置】关联ID) + */ + private Long washMethodId; + + /** * 清洗方式 */ private String washMethod ; @@ -649,6 +654,14 @@ this.sequence = sequence; } + public Long getWashMethodId() { + return washMethodId; + } + + public void setWashMethodId(Long washMethodId) { + this.washMethodId = washMethodId; + } + public String getWashMethod() { return washMethod; } Index: ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/materialdefinition/action/MaterialDefinitionAction.java =================================================================== diff -u -r35378 -r35751 --- ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/materialdefinition/action/MaterialDefinitionAction.java (.../MaterialDefinitionAction.java) (revision 35378) +++ ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/materialdefinition/action/MaterialDefinitionAction.java (.../MaterialDefinitionAction.java) (revision 35751) @@ -45,6 +45,7 @@ import com.forgon.disinfectsystem.tousse.toussedefinition.service.TousseDefinitionManager; import com.forgon.log.model.Log; import com.forgon.log.service.LogManager; +import com.forgon.systemsetting.model.HttpOption; import com.forgon.systemsetting.service.HttpOptionManager; import com.forgon.tools.FileSystemHelper; import com.forgon.tools.ImageUtils; @@ -338,12 +339,13 @@ public void getHttpOptionResultSet() { String optionType = StrutsParamUtils.getPraramValue("optionType", null); - List list = httpOptionManager.getHttpOptionTextById(optionType); + List httpOptionList = httpOptionManager.getHttpOptionListById(optionType); JSONArray array = new JSONArray(); - if (list != null) { - for (int i = 0; i < list.size(); i++) { + if (httpOptionList != null) { + for (int i = 0; i < httpOptionList.size(); i++) { JSONObject obj = new JSONObject(); - obj.put("value", list.get(i)); + obj.put("id", httpOptionList.get(i).getId()); + obj.put("value", httpOptionList.get(i).getOptionText()); array.add(obj); } } Index: forgon-tools/src/main/java/com/forgon/Constants.java =================================================================== diff -u -r35560 -r35751 --- forgon-tools/src/main/java/com/forgon/Constants.java (.../Constants.java) (revision 35560) +++ forgon-tools/src/main/java/com/forgon/Constants.java (.../Constants.java) (revision 35751) @@ -28,7 +28,7 @@ "4.9.45","4.9.46","4.9.47","4.9.48","4.9.49","4.9.50","4.9.51","4.9.52","4.9.53","4.9.54","4.9.55","4.9.56","4.9.57","4.9.58","4.9.59","4.9.60","4.9.61","4.9.62", "4.9.63","4.9.64","4.9.65","4.9.66","4.9.67","4.9.68","4.9.69","4.9.70","4.9.71","4.9.72","4.9.73","4.9.74","4.9.75","4.9.76","4.9.77","4.9.78","4.9.79","4.9.80","4.9.81","4.9.82","4.9.83","4.9.84","4.9.85", "4.9.86","4.9.87","4.9.88","4.9.89","4.9.90","4.9.91","4.9.92","4.9.93","4.9.94","4.9.95","4.9.96","4.9.97","4.9.98","4.9.99","5.0.0","5.0.1","5.0.2","5.0.3","5.0.4","5.0.5","5.0.6","5.0.7", - "5.0.8"}; + "5.0.8","5.0.9"}; // 版本列表(4.0版本升级4.1版需要分两步:先从4.0升到4.1.0、然后从4.1.0升级4.1最新版本) /*public final static String[] SOFTWARE_VERSION_ARRAY = new String[] { Index: forgon-core/src/main/java/com/forgon/systemsetting/service/HttpOptionManager.java =================================================================== diff -u -r34530 -r35751 --- forgon-core/src/main/java/com/forgon/systemsetting/service/HttpOptionManager.java (.../HttpOptionManager.java) (revision 34530) +++ forgon-core/src/main/java/com/forgon/systemsetting/service/HttpOptionManager.java (.../HttpOptionManager.java) (revision 35751) @@ -118,5 +118,18 @@ * @return */ public List getSterilizerGroupHttpOption(String orgUnitCode); + + /** + * 保存清洗方式设置 + * @param originalWashMethodGroupName + * @param washMethodHttpOption + */ + public void saveWashMethodHttpOption(String originalWashMethodGroupName, HttpOption washMethodHttpOption); + + /** + * 删除清洗方式设置 + * @param ids + */ + public void deleteWashMethodHttpHttpOption(String ids); } Index: ssts-maintain/src/main/java/com/forgon/disinfectsystem/maintain/basic/service/MaintainManagerImpl.java =================================================================== diff -u -r35688 -r35751 --- ssts-maintain/src/main/java/com/forgon/disinfectsystem/maintain/basic/service/MaintainManagerImpl.java (.../MaintainManagerImpl.java) (revision 35688) +++ ssts-maintain/src/main/java/com/forgon/disinfectsystem/maintain/basic/service/MaintainManagerImpl.java (.../MaintainManagerImpl.java) (revision 35751) @@ -211,6 +211,7 @@ import com.forgon.serialnumber.model.SerialNum; import com.forgon.serialnumber.service.SerialNumManager; import com.forgon.systemsetting.model.HttpOption; +import com.forgon.systemsetting.service.HttpOptionManager; import com.forgon.tools.GB2Alpha; import com.forgon.tools.GB2WB; import com.forgon.tools.MathTools; @@ -267,6 +268,12 @@ private SerialNumManager serialNumManager; + private HttpOptionManager httpOptionManager; + + public void setHttpOptionManager(HttpOptionManager httpOptionManager) { + this.httpOptionManager = httpOptionManager; + } + public void setSerialNumManager(SerialNumManager serialNumManager) { this.serialNumManager = serialNumManager; } @@ -1580,6 +1587,9 @@ case "5.0.5_5.0.6": updateData_5_0_5_5_0_6(updateDataContext); break; + case "5.0.8_5.0.9": + UpdateData_5_0_8_5_0_9(updateDataContext); + break; } return false; } @@ -3031,6 +3041,63 @@ dataUpdater.logInfo(msg); } + /** + * 1、存在部分选项值不存在于现有的“清洗方式设置”中,则在“清洗方式设置”中新增一个对应名称的清洗方式,确保数据的完整性; + * 2、材料定义MaterialDefinition新加washMethodId关联清洗方式设置(ZSSXLRMYY-221【清洗方式设置】界面以及存储方式改进) + * @param updateDataContext + */ + private void UpdateData_5_0_8_5_0_9(UpdateDataContext updateDataContext) { + DataUpdater dataUpdater = updateDataContext.getDataUpdater(); + String msg = null; + msg = String + .format("已执行方法(%s.%s)!", MaintainManagerImpl.class.getName(), + "UpdateData_5_0_8_5_0_9()"); + //1、存在部分选项值不存在于现有的“清洗方式设置”中,则在“清洗方式设置”中新增一个对应名称的清洗方式,确保数据的完整性; + List washMethodList = new ArrayList(); + String washMethodSql = String.format("select md.washMethod " + + "from %s md where md.washMethod not in (" + + "select ho.optionText from %s ho where ho.optionListId = '%s') " + + "group by md.washMethod", + MaterialDefinition.class.getSimpleName(), + HttpOption.class.getSimpleName(), + HttpOption.SYSTEMSETTING_WASHMETHOD); + ResultSet rs = null; + try { + rs = objectDao.executeSql(washMethodSql); + while(rs.next()){ + String washMethod = rs.getString("washMethod"); + if(StringUtils.isNotBlank(washMethod)){ + washMethodList.add(washMethod); + } + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + DatabaseUtil.closeResultSetAndStatement(rs); + } + + if(CollectionUtils.isNotEmpty(washMethodList)){ + int maxSequence = httpOptionManager.getMaxSequence(HttpOption.SYSTEMSETTING_WASHMETHOD); + for (String washMethod : washMethodList) { + HttpOption httpOption = new HttpOption(); + httpOption.setOptionListId(HttpOption.SYSTEMSETTING_WASHMETHOD); + httpOption.setSequence(++maxSequence); + httpOption.setOptionText(washMethod); + objectDao.save(httpOption); + } + } + + objectDao.flush(); + //2、材料定义MaterialDefinition新加washMethodId关联清洗方式设置 + String updateSql = String.format("update %s set washMethodId = (select max(id) from %s ho where ho.optionListId = '%s' and ho.optionText = MaterialDefinition.washMethod) where washMethodId is null and washMethod is not null", + MaterialDefinition.class.getSimpleName(), + HttpOption.class.getSimpleName(), + HttpOption.SYSTEMSETTING_WASHMETHOD); + objectDao.excuteSQL(updateSql); + + dataUpdater.logInfo(msg); + } + @Override public void updateForeignTousseInfo() { //外来器械材料定义 Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/systemsetting/service/HttpOptionManagerSSTSImpl.java =================================================================== diff -u -r35339 -r35751 --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/systemsetting/service/HttpOptionManagerSSTSImpl.java (.../HttpOptionManagerSSTSImpl.java) (revision 35339) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/systemsetting/service/HttpOptionManagerSSTSImpl.java (.../HttpOptionManagerSSTSImpl.java) (revision 35751) @@ -13,6 +13,7 @@ import net.sf.json.JSONObject; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import com.forgon.directory.model.OrgUnit; @@ -673,6 +674,11 @@ String sql = String.format("update %s set ownGroup = '%s' where ownGroup = '%s'", Sterilizer.class.getSimpleName(), sterilizerGroup.getOptionText(), originalSterilizerGroupName); objectDao.executeUpdate(sql); } + //设置顺序号 + if(!DatabaseUtil.isPoIdValid(sterilizerGroup.getId())){ + int maxSequence = getMaxSequence(sterilizerGroup.getOptionListId()); + sterilizerGroup.setSequence(maxSequence + 1); + } } /** @@ -716,4 +722,93 @@ return objectDao.findByHql(sql); } + + @Override + public void saveWashMethodHttpOption(String originalWashMethodGroupName, HttpOption washMethodHttpOption){ + if(StringUtils.isBlank(washMethodHttpOption.getOptionText())){ + throw new SystemException("名称不能为空!"); + } + //名称不能重复 + String idSql = ""; + if(DatabaseUtil.isPoIdValid(washMethodHttpOption.getId())){ + idSql = " and id <> " + washMethodHttpOption.getId(); + } + String countSql = String.format("select count(*) from %s po where po.optionText = '%s' %s ", + HttpOption.class.getSimpleName(), + washMethodHttpOption.getOptionText(), + idSql); + if(objectDao.countBySql(countSql) > 0){ + throw new SystemException("已经存在名称为“" + washMethodHttpOption.getOptionText() + "”的清洗方式!"); + } + + //联动修改材料定义的清洗方式 + if(DatabaseUtil.isPoIdValid(washMethodHttpOption.getId()) && StringUtils.isNotBlank(originalWashMethodGroupName)){ + String updateSql = String.format("update %s set washMethod = '%s' where washMethod = '%s'", + MaterialDefinition.class.getSimpleName(), + washMethodHttpOption.getOptionText(), + originalWashMethodGroupName); + objectDao.excuteSQL(updateSql); + } + //设置顺序号 + if(!DatabaseUtil.isPoIdValid(washMethodHttpOption.getId())){ + int maxSequence = getMaxSequence(washMethodHttpOption.getOptionListId()); + washMethodHttpOption.setSequence(maxSequence + 1); + } + //保存清洗方式 + this.save(washMethodHttpOption); + } + + @Override + public void deleteWashMethodHttpHttpOption(String ids) { + if(StringUtils.isBlank(ids)){ + throw new SystemException("id不能为空!"); + } + List httpOptionList = this.getCollection(ids, ";"); + if(CollectionUtils.isEmpty(httpOptionList)){ + throw new RuntimeException("数据不存在"); + } + //验证是否被材料定义引用 + Map materialDefinitionAmountMap = getMaterialDefinitionAmountMapByWashMethodId(ids); + for (HttpOption httpOption : httpOptionList) { + if(!StringUtils.equals(httpOption.getOptionListId(), HttpOption.SYSTEMSETTING_WASHMETHOD)){ + throw new SystemException(httpOption.getOptionText() + "不是清洗方式设置 ,不能删除!"); + } + if(MapUtils.isNotEmpty(materialDefinitionAmountMap)){ + Integer mdAmount = materialDefinitionAmountMap.get(httpOption.getId()); + if(mdAmount != null && mdAmount.intValue() > 0){ + throw new SystemException("存在清洗方式为“" +httpOption.getOptionText()+ "的材料定义”,不能删除清洗方式!"); + } + } + this.delete(httpOption); + } + } + + /** + * 查询引用了清洗方式的材料定义的数量 + * @param ids + * @return + */ + private Map getMaterialDefinitionAmountMapByWashMethodId( String ids) { + Map materialDefinitionAmountMap = new HashMap(); + if(StringUtils.isBlank(ids)){ + return materialDefinitionAmountMap; + } + String materialDefinitionSql = String.format("select md.washMethodId, count(md.id) mdAmount from %s md where %s group by md.washMethodId ", + MaterialDefinition.class.getSimpleName(), + SqlUtils.getNonStringFieldInLargeCollectionsPredicate("md.washMethodId", StringTools.parseToLongs(ids, ";"))); + ResultSet rs = null; + try { + rs = objectDao.executeSql(materialDefinitionSql); + while(rs.next()){ + Long washMethodId = rs.getLong("washMethodId"); + Integer mdAmount = rs.getInt("mdAmount"); + materialDefinitionAmountMap.put(washMethodId, mdAmount); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + DatabaseUtil.closeResultSetAndStatement(rs); + } + return materialDefinitionAmountMap; + } }