Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/departmentgroup/dwr/table/DepartmentGroupTableManager.java =================================================================== diff -u -r21962 -r35616 --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/departmentgroup/dwr/table/DepartmentGroupTableManager.java (.../DepartmentGroupTableManager.java) (revision 21962) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/departmentgroup/dwr/table/DepartmentGroupTableManager.java (.../DepartmentGroupTableManager.java) (revision 35616) @@ -1,11 +1,26 @@ package com.forgon.disinfectsystem.basedatamanager.departmentgroup.dwr.table; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; +import org.apache.commons.collections.MapUtils; +import org.apache.commons.collections4.CollectionUtils; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + import com.forgon.component.grid.GridManager; import com.forgon.disinfectsystem.entity.recycledepartmentgroup.DepartmentGroup; +import com.forgon.disinfectsystem.entity.recycledepartmentgroup.DepartmentGroupWarnUser; +import com.forgon.security.model.User; +import com.forgon.tools.db.DatabaseUtil; import com.forgon.tools.hibernate.ObjectDao; +import com.forgon.tools.string.StringTools; +import com.forgon.tools.util.ConfigUtils; +import com.forgon.tools.util.SqlUtils; public class DepartmentGroupTableManager { @@ -22,10 +37,99 @@ } public String findGroupTableList(Map> parameterMap) { - return gridManager.renderGrid(parameterMap, + String json = gridManager.renderGrid(parameterMap, DepartmentGroup.class.getSimpleName(), "where 1=1 ", new String[] {}); + boolean limitOneOperationRoomCanOnlyRegistOneUnAuditedUseRecord = + ConfigUtils.getSystemSetConfigByNameBool("limitOneOperationRoomCanOnlyRegistOneUnAuditedUseRecord"); + if(limitOneOperationRoomCanOnlyRegistOneUnAuditedUseRecord){ + json = searchDepartmentGroupWarnUser(json); + } + return json; } + /** + * 关联查询提醒用户 + * @param json + * @return + */ + private String searchDepartmentGroupWarnUser(String json) { + JSONObject jsonObject = JSONObject.fromObject(json); + if(jsonObject == null){ + return json; + } + JSONArray jsonArray = jsonObject.optJSONArray("rows"); + if (jsonArray == null || jsonArray.size() == 0) { + return json; + } + List departmentGroupIdList = new ArrayList(); + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject obj = jsonArray.optJSONObject(i); + if (obj == null) { + continue; + } + Long id = obj.optLong("id"); + if(DatabaseUtil.isPoIdValid(id)){ + departmentGroupIdList.add(id); + } + } + + if(CollectionUtils.isEmpty(departmentGroupIdList)){ + return json; + } + + Map> departmentGroupWarnUserMap = new HashMap>(); + String sql = String.format("select dg.id, u.fullName " + + "from %s dg " + + "join %s dgu on dg.id = dgu.departmentGroupId " + + "join SS_USERS u on dgu.userId = u.id " + + "where %s", + DepartmentGroup.class.getSimpleName(), + DepartmentGroupWarnUser.class.getSimpleName(), + SqlUtils.getNonStringFieldInLargeCollectionsPredicate("dg.id", departmentGroupIdList)); + ResultSet rs = null; + try { + rs = objectDao.executeSql(sql); + while(rs.next()){ + Long id = rs.getLong("id"); + String fullName = rs.getString("fullName"); + List warnUserNameList = departmentGroupWarnUserMap.get(id); + if(warnUserNameList == null){ + warnUserNameList = new ArrayList(); + } + if(!warnUserNameList.contains(fullName)){ + warnUserNameList.add(fullName); + } + departmentGroupWarnUserMap.put(id, warnUserNameList); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + DatabaseUtil.closeResultSetAndStatement(rs); + } + + if(MapUtils.isEmpty(departmentGroupWarnUserMap)){ + return json; + } + + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject obj = jsonArray.optJSONObject(i); + if (obj == null) { + continue; + } + String warningUserNames = ""; + Long id = obj.optLong("id"); + List warnUserList = departmentGroupWarnUserMap.get(id); + if(CollectionUtils.isNotEmpty(warnUserList)){ + warningUserNames = StringTools.join(warnUserList, ";"); + } + obj.put("warningUserNames", warningUserNames); + } + + jsonObject.put("rows", jsonArray); + + return jsonObject.toString(); + } + public void moveUpRecord(String number){ Integer numberOrder = Integer.parseInt(number); if(numberOrder>1){ Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/departmentgroup/service/DepartmentGroupManagerImpl.java =================================================================== diff -u -r32583 -r35616 --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/departmentgroup/service/DepartmentGroupManagerImpl.java (.../DepartmentGroupManagerImpl.java) (revision 32583) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/departmentgroup/service/DepartmentGroupManagerImpl.java (.../DepartmentGroupManagerImpl.java) (revision 35616) @@ -1,6 +1,7 @@ package com.forgon.disinfectsystem.basedatamanager.departmentgroup.service; import java.sql.ResultSet; +import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Map; @@ -9,10 +10,16 @@ import net.sf.json.JSONObject; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang.StringUtils; +import com.forgon.disinfectsystem.entity.qualitymonitoringmanager.qualitymonitoringconfig.QualityMonitoringWarnUser; import com.forgon.disinfectsystem.entity.recycledepartmentgroup.DepartmentGroup; +import com.forgon.disinfectsystem.entity.recycledepartmentgroup.DepartmentGroupWarnUser; +import com.forgon.exception.SystemException; +import com.forgon.security.model.User; import com.forgon.tools.db.DatabaseUtil; import com.forgon.tools.hibernate.BasePoManagerImpl; +import com.forgon.tools.string.StringTools; import com.forgon.tools.util.ExtJsUtil; public class DepartmentGroupManagerImpl extends BasePoManagerImpl implements DepartmentGroupManager { @@ -122,5 +129,39 @@ } return returnObj; } + + @SuppressWarnings("unchecked") + @Override + public void saveDepartmentGroup(DepartmentGroup departmentGroup) { + if(departmentGroup == null){ + throw new SystemException("参数异常"); + } + boolean update = DatabaseUtil.isPoIdValid(departmentGroup.getId()); + objectDao.saveOrUpdate(departmentGroup); + if(update){ + //删除“pda回收通知人”ZSRY-47 + List departmentGroupWarnUsers = objectDao.findByProperty(DepartmentGroupWarnUser.class.getSimpleName(), "departmentGroupId", departmentGroup.getId()); + if(CollectionUtils.isNotEmpty(departmentGroupWarnUsers)){ + objectDao.deleteAll(departmentGroupWarnUsers); + } + } + String warningUserIds = departmentGroup.getWarningUserIds(); + if(StringUtils.isNotBlank(warningUserIds)){ + //保存“pda回收通知人”ZSRY-47 + Collection warningUserIdCol = StringTools.parseToLongs(warningUserIds, ";"); + List warningUserIdList = new ArrayList(warningUserIdCol); + if(CollectionUtils.isNotEmpty(warningUserIdList)){ + List warningUserList = objectDao.getCollection(User.class.getSimpleName(), "id", warningUserIdList); + if(CollectionUtils.isNotEmpty(warningUserList)){ + for (User user : warningUserList) { + DepartmentGroupWarnUser departmentGroupWarnUser = new DepartmentGroupWarnUser(); + departmentGroupWarnUser.setDepartmentGroupId(departmentGroup.getId()); + departmentGroupWarnUser.setUserId(user.getId()); + objectDao.save(departmentGroupWarnUser); + } + } + } + } + } } Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/recycledepartmentgroup/DepartmentGroupWarnUser.java =================================================================== diff -u --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/recycledepartmentgroup/DepartmentGroupWarnUser.java (revision 0) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/recycledepartmentgroup/DepartmentGroupWarnUser.java (revision 35616) @@ -0,0 +1,65 @@ +package com.forgon.disinfectsystem.entity.recycledepartmentgroup; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Index; +import javax.persistence.Table; + +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.CacheConcurrencyStrategy; +import org.hibernate.annotations.DynamicInsert; +import org.hibernate.annotations.DynamicUpdate; + +/** + * “回收科室分组设置”的pda回收通知人ZSRY-47 + */ +@Entity +@DynamicInsert(false) +@DynamicUpdate(true) +@Table(indexes = {@Index(columnList = "departmentGroupId", name = "dpguser_dpgid_index"), + @Index(columnList = "userId", name = "dpguser_uid_index") +}) +@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) +public class DepartmentGroupWarnUser { + + private Long id; + + /** + * 回收科室分组设置ID + */ + private Long departmentGroupId; + + /** + * 用户ID + */ + private Long userId; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getDepartmentGroupId() { + return departmentGroupId; + } + + public void setDepartmentGroupId(Long departmentGroupId) { + this.departmentGroupId = departmentGroupId; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + +} Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/recycledepartmentgroup/DepartmentGroup.java =================================================================== diff -u -r23492 -r35616 --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/recycledepartmentgroup/DepartmentGroup.java (.../DepartmentGroup.java) (revision 23492) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/recycledepartmentgroup/DepartmentGroup.java (.../DepartmentGroup.java) (revision 35616) @@ -2,20 +2,28 @@ import java.util.Arrays; import java.util.Collection; +import java.util.List; import javax.persistence.Column; import javax.persistence.Entity; + +import org.apache.commons.collections4.CollectionUtils; import org.hibernate.annotations.DynamicInsert; import org.hibernate.annotations.DynamicUpdate; + import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Lob; import javax.persistence.Table; +import javax.persistence.Transient; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; +import com.forgon.disinfectsystem.entity.qualitymonitoringmanager.qualitymonitoringconfig.QualityMonitoringWarnUser; +import com.forgon.security.model.User; +import com.forgon.tools.hibernate.ObjectDao; import com.forgon.tools.string.StringTools; @@ -45,6 +53,34 @@ */ private String prepareRecycleType; + /** + * 提醒方式(“文字提醒”、“语音提醒”、“弹窗提醒(仅在待回收页面)”)ZSRY-47 + */ + private String warningWays = WARNING_WAY_TEXT; + + /** + * 提醒方式(“文字提醒”)ZSRY-47 + */ + public static final String WARNING_WAY_TEXT= "文字提醒"; + /** + * 提醒方式(“语音提醒”)ZSRY-47 + */ + public static final String WARNING_WAY_VOICE= "语音提醒"; + /** + * 提醒方式(“弹窗提醒”)(仅在待回收页面)ZSRY-47 + */ + public static final String WARNING_WAY_POPUP= "弹窗提醒"; + + /** + * 提醒人员Id,不保存到数据库(ZSRY-47) + */ + private String warningUserIds; + + /** + * 提醒人员姓名,不保存到数据库(ZSRY-47) + */ + private String warningUserNames; + @Id @GeneratedValue(strategy = GenerationType.AUTO) public Long getId() { @@ -108,4 +144,78 @@ } return null; } + + /** + * 获取分组下的所有提醒方式 + * @return + */ + public Collection warningWays(){ + if(StringTools.isNotBlank(warningWays)){ + return Arrays.asList(StringTools.split(warningWays, ';')); + } + return null; + } + + public String getWarningWays() { + return warningWays; + } + + public void setWarningWays(String warningWays) { + this.warningWays = warningWays; + } + + @Transient + public String getWarningUserIds() { + return warningUserIds; + } + + public void setWarningUserIds(String warningUserIds) { + this.warningUserIds = warningUserIds; + } + + @Transient + public String getWarningUserNames() { + return warningUserNames; + } + + public void setWarningUserNames(String warningUserNames) { + this.warningUserNames = warningUserNames; + } + + @Transient + public String getWarningUserNames(ObjectDao objectDao) { + List users = this.getWarningUser(objectDao); + warningUserNames = ""; + if(CollectionUtils.isNotEmpty(users)){ + for (User user : users) { + warningUserNames = StringTools.uniteTwoStringBySemicolon(warningUserNames, user.getFullName(), ";"); + } + } + return warningUserNames; + } + + @Transient + public String getWarningUserIds(ObjectDao objectDao) { + List users = this.getWarningUser(objectDao); + warningUserIds = ""; + if(CollectionUtils.isNotEmpty(users)){ + for (User user : users) { + warningUserIds = StringTools.uniteTwoStringBySemicolon(warningUserIds, user.getId()+"", ";"); + } + } + return warningUserIds; + } + + /** + * 查询提醒人员 + * @param objectDao + * @return + */ + @Transient + @SuppressWarnings("unchecked") + public List getWarningUser(ObjectDao objectDao){ + String hql = String.format("select po from %s po where po.id in (select userId from %s where departmentGroupId = %s)", + User.class.getSimpleName(), DepartmentGroupWarnUser.class.getSimpleName(), this.getId()); + return objectDao.findByHql(hql); + } } Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/departmentgroup/service/DepartmentGroupManager.java =================================================================== diff -u -r32583 -r35616 --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/departmentgroup/service/DepartmentGroupManager.java (.../DepartmentGroupManager.java) (revision 32583) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/departmentgroup/service/DepartmentGroupManager.java (.../DepartmentGroupManager.java) (revision 35616) @@ -50,4 +50,10 @@ * @return */ public JSONObject getDepartmentGroupIdAndName(); + + /** + * 保存回收科室分组 + * @param departmentGroup + */ + public void saveDepartmentGroup(DepartmentGroup departmentGroup); } Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/departmentgroup/action/DepartmentGroupAction.java =================================================================== diff -u -r32583 -r35616 --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/departmentgroup/action/DepartmentGroupAction.java (.../DepartmentGroupAction.java) (revision 32583) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/departmentgroup/action/DepartmentGroupAction.java (.../DepartmentGroupAction.java) (revision 35616) @@ -18,6 +18,7 @@ import com.forgon.disinfectsystem.entity.recycledepartmentgroup.DepartmentGroup; import com.forgon.tools.StrutsParamUtils; import com.forgon.tools.StrutsResponseUtils; +import com.forgon.tools.hibernate.ObjectDao; import com.forgon.tools.util.PageUtil; import com.opensymphony.xwork2.ModelDriven; import com.opensymphony.xwork2.Preparable; @@ -34,7 +35,14 @@ private DepartmentGroup departmentGroup; private DepartmentGroupManager departmentGroupManager; + + private ObjectDao objectDao; + public void setObjectDao(ObjectDao objectDao) { + this.objectDao = objectDao; + } + + protected final Logger logger = Logger.getLogger(this.getClass()); @@ -46,7 +54,7 @@ public void saveDepartmentGroup() { String message = "{success:true}"; try { - departmentGroupManager.save(departmentGroup); + departmentGroupManager.saveDepartmentGroup(departmentGroup); HttpServletResponse response = StrutsParamUtils.getResponse(); response.setCharacterEncoding("UTF-8"); response.getWriter().println(message); @@ -85,6 +93,8 @@ Map map = new HashMap(); map.put("success", true); if(departmentGroup != null){ + departmentGroup.getWarningUserIds(objectDao); + departmentGroup.getWarningUserNames(objectDao); map.put("data", departmentGroup); } try {