Index: ssts-web/src/main/java/com/forgon/disinfectsystem/systemwarning/service/SystemWarningManagerImpl.java =================================================================== diff -u -r36001 -r36252 --- ssts-web/src/main/java/com/forgon/disinfectsystem/systemwarning/service/SystemWarningManagerImpl.java (.../SystemWarningManagerImpl.java) (revision 36001) +++ ssts-web/src/main/java/com/forgon/disinfectsystem/systemwarning/service/SystemWarningManagerImpl.java (.../SystemWarningManagerImpl.java) (revision 36252) @@ -56,6 +56,9 @@ import com.forgon.disinfectsystem.entity.devicemaintenance.DeviceMaintenanceCusI; import com.forgon.disinfectsystem.entity.goodsstock.GoodsStock; import com.forgon.disinfectsystem.entity.goodsstock.OrgUnitGoodsWarnStock; +import com.forgon.disinfectsystem.entity.problemreportmanager.problemreport.model.Problem; +import com.forgon.disinfectsystem.entity.problemreportmanager.problemreport.model.ProblemNotifyRecord; +import com.forgon.disinfectsystem.entity.problemreportmanager.problemreport.model.ProblemNotifyUser; import com.forgon.disinfectsystem.entity.qualitymonitoringmanager.qualitymonitoringconfig.QualityMonitoringDefinition; import com.forgon.disinfectsystem.entity.recall.RecallRecord; import com.forgon.disinfectsystem.entity.recall.RecallRecordItem; @@ -1512,4 +1515,112 @@ return instrumentRepairMap; } + @Override + public JSONArray getProblemWarning() { + + JSONArray result = new JSONArray(); + + //拥有“问题反馈通知”权限的用户,被设置为通知用户时,登陆到系统将能够收到弹窗通知; + if(!operationManager.isCurrentUserHaveAnyOperation("SSTS_ProblemReport_Notify")){ + //return result; + } + + String currentOrgUnitCode = AcegiHelper.getCurrentOrgUnitCode(); + Long userId = AcegiHelper.getLoginUser().getUserId(); + @SuppressWarnings("unchecked") + List currentOrgUnitList = objectDao.findByProperty(OrgUnit.class.getSimpleName(), "orgUnitCoding", currentOrgUnitCode); + if(CollectionUtils.isEmpty(currentOrgUnitList)){ + return result; + } + if(!DatabaseUtil.isPoIdValid(userId)){ + return result; + } + Long currentOrgUnitId = currentOrgUnitList.get(0).getId(); + + String queryField = "select pro.id, pro.title, pro.orgUnitName, pro.registerPerson, pro.status "; + + //1、提醒通知科室下的通知用户 + String sql1 = String.format("%s from %s pro " + + "join %s u on pro.id = u.problemId " + + "where pro.notifyOrgUnitId = %s " + + "and u.userId = %s " + + "and pro.status in ('%s','%s') " + + "and u.userId <> pro.submitUserId " + + "and pro.id not in (select pnr.problemId from %s pnr where pnr.problemId = pro.id and pnr.userId = %s) ", + queryField, + Problem.class.getSimpleName(), + ProblemNotifyUser.class.getSimpleName(), + currentOrgUnitId, + userId, + Problem.AWAIT_FOR_ANSWER, + Problem.ALREADY_ANSWERING, + ProblemNotifyRecord.class.getSimpleName(), + userId); + + //2、提醒登记人(提交人不需要收到提醒) + String sql2 = String.format("%s from %s pro " + + "join SS_USERS u on u.id = pro.registerPersonId " + + "where pro.registerPersonId = %s " + + "and pro.status in ('%s','%s') " + + "and u.id <> pro.submitUserId " + + "and pro.id not in (select pnr.problemId from %s pnr where pnr.problemId = pro.id and pnr.userId = %s)", + queryField, + Problem.class.getSimpleName(), + userId, + Problem.AWAIT_FOR_ANSWER, + Problem.ALREADY_ANSWERING, + ProblemNotifyRecord.class.getSimpleName(), + userId); + + //3、提醒通知科室全部用户 + String sql3 = String.format("%s from %s pro " + + "where pro.notifyAllOrgUnitUser = '%s' " + + "and pro.notifyOrgUnitId = %s " + + "and pro.status in ('%s','%s') " + + "and pro.submitUserId <> %s " + + "and pro.id not in (select pnr.problemId from %s pnr where pnr.problemId = pro.id and pnr.userId = %s)", + queryField, + Problem.class.getSimpleName(), + Constants.STR_YES, + currentOrgUnitId, + Problem.AWAIT_FOR_ANSWER, + Problem.ALREADY_ANSWERING, + userId, + ProblemNotifyRecord.class.getSimpleName(), + userId); + + String sql = String.format("select * from ((%s) union all (%s) union all (%s)) rs", + sql1, + sql2, + sql3); + + List problemIdList = new ArrayList(); + ResultSet rs = null; + try { + rs = objectDao.executeSql(sql); + while(rs.next()){ + Long id = rs.getLong("id"); + String orgUnitName = rs.getString("orgUnitName"); + String registerPerson = rs.getString("registerPerson"); + if(problemIdList.contains(id)){ + continue; + } + JSONObject json = new JSONObject(); + json.put("id", id); + json.put("orgUnitName", orgUnitName); + json.put("registerPerson", registerPerson); + String title = rs.getString("title"); + json.put("title", title); + result.add(json); + problemIdList.add(id); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + DatabaseUtil.closeResultSetAndStatement(rs); + } + + return result; + } + } Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/supplyroomconfig/action/SupplyRoomConfigAction.java =================================================================== diff -u -r36167 -r36252 --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/supplyroomconfig/action/SupplyRoomConfigAction.java (.../SupplyRoomConfigAction.java) (revision 36167) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/basedatamanager/supplyroomconfig/action/SupplyRoomConfigAction.java (.../SupplyRoomConfigAction.java) (revision 36252) @@ -1761,6 +1761,36 @@ } /** + * 加载一级供应室科室信息 + */ + public void loadFirstSupplyRoomOrgUnit(){ + JSONObject result = JSONUtil.buildJsonObject(false); + try { + String hql = String.format("select po from %s po where po.orgUnitCoding in (select src.orgUnitCoding from %s src where src.supplyRoomType = %s)", + OrgUnit.class.getSimpleName(), + SupplyRoomConfig.class.getSimpleName(), + SupplyRoomConfig.SUPPLYROOM_TYPE_FIRST_SUPPLYROOM); + @SuppressWarnings("unchecked") + List orgUnitList = objectDao.findByHql(hql); + JSONArray data = new JSONArray(); + if(CollectionUtils.isNotEmpty(orgUnitList)){ + for (OrgUnit orgUnit : orgUnitList) { + JSONObject json = new JSONObject(); + json.put("id", orgUnit.getId()); + json.put("orgUnitCoding", orgUnit.getOrgUnitCoding()); + json.put("name", orgUnit.getName()); + data.add(json); + } + } + result = JSONUtil.buildJsonObject(true, data); + } catch (Exception e) { + e.printStackTrace(); + result = JSONUtil.buildJsonObject(false, "加载失败:" + e.getMessage()); + } + StrutsResponseUtils.output(result); + } + + /** * 获取一二级供应室 * type 根据页面传入参数获取对应供应室 */ Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/problemreportmanager/problemreport/model/Problem.java =================================================================== diff -u -r29275 -r36252 --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/problemreportmanager/problemreport/model/Problem.java (.../Problem.java) (revision 29275) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/problemreportmanager/problemreport/model/Problem.java (.../Problem.java) (revision 36252) @@ -8,6 +8,7 @@ import net.sf.json.JSONArray; +import org.apache.commons.collections.CollectionUtils; import org.hibernate.annotations.Cascade; import org.hibernate.annotations.DynamicInsert; import org.hibernate.annotations.DynamicUpdate; @@ -17,6 +18,7 @@ import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.Index; import javax.persistence.JoinColumn; import javax.persistence.Lob; import javax.persistence.OneToMany; @@ -28,6 +30,11 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.forgon.Constants; +import com.forgon.directory.model.OrgUnit; +import com.forgon.security.model.User; +import com.forgon.tools.db.DatabaseUtil; +import com.forgon.tools.hibernate.ObjectDao; +import com.forgon.tools.string.StringTools; /** * 问题定义类,用来描述科室向供应室上报的问题信息 @@ -38,7 +45,8 @@ @Entity @DynamicInsert(false) @DynamicUpdate(true) -@Table(name = "Problem") +@Table(name = "Problem", indexes = {@Index(columnList = "notifyOrgUnitId", name = "problem_orgid_index") +,@Index(columnList = "submitUserId", name = "problem_suid_index")}) @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) public class Problem { private Long id; @@ -54,6 +62,10 @@ private String orgUnitCoding; // 登记科室名称 private String orgUnitName; + /** + * 登记人ID + */ + private Long registerPersonId; // 登记人 private String registerPerson; //状态 0:待回复,1:已回复 @@ -78,6 +90,36 @@ @JsonIgnore private List answers = new ArrayList(); + /** + * 通知科室Id(CDSLQYQYYY-117) + */ + private Long notifyOrgUnitId; + + /** + * 通知科室名称(不保存到数据库)(CDSLQYQYYY-117) + */ + private String notifyOrgUnitName; + + /** + * 是否提醒通知科室的所有用户 + */ + private String notifyAllOrgUnitUser = Constants.STR_NO; + + /** + * 问题反馈的通知人Id,例如:1;2;3(不保存到数据库)(CDSLQYQYYY-117) + */ + private String notifyUserIds; + + /** + * 问题反馈的通知人姓名,例如:用户01;用户02;用户03(不保存到数据库)(CDSLQYQYYY-117) + */ + private String notifyUserNames; + + /** + * 提交用户ID(CDSLQYQYYY-117) + */ + private Long submitUserId; + public static final String AWAIT_FOR_ANSWER = "待回复"; /** * 状态:回复中(JMSZXYY-84新增状态:回复中) @@ -176,6 +218,12 @@ this.registerPerson = registerPerson; } + public Long getRegisterPersonId() { + return registerPersonId; + } + public void setRegisterPersonId(Long registerPersonId) { + this.registerPersonId = registerPersonId; + } public Date getFinishTime() { return finishTime; } @@ -217,4 +265,113 @@ return ""; } + public Long getNotifyOrgUnitId() { + return notifyOrgUnitId; + } + + public void setNotifyOrgUnitId(Long notifyOrgUnitId) { + this.notifyOrgUnitId = notifyOrgUnitId; + } + + @Transient + public String getNotifyOrgUnitName() { + return notifyOrgUnitName; + } + + public void setNotifyOrgUnitName(String notifyOrgUnitName) { + this.notifyOrgUnitName = notifyOrgUnitName; + } + + public String getNotifyAllOrgUnitUser() { + return notifyAllOrgUnitUser; + } + + public void setNotifyAllOrgUnitUser(String notifyAllOrgUnitUser) { + this.notifyAllOrgUnitUser = notifyAllOrgUnitUser; + } + + public Long getSubmitUserId() { + return submitUserId; + } + + public void setSubmitUserId(Long submitUserId) { + this.submitUserId = submitUserId; + } + + @Transient + public String getNotifyUserIds() { + return notifyUserIds; + } + + public void setNotifyUserIds(String notifyUserIds) { + this.notifyUserIds = notifyUserIds; + } + + @Transient + public String getNotifyUserNames() { + return notifyUserNames; + } + + public void setNotifyUserNames(String notifyUserNames) { + this.notifyUserNames = notifyUserNames; + } + + /** + * 查询通知科室名称 + * @return + */ + public String loadNotifyOrgUnitName(ObjectDao objectDao){ + OrgUnit orgUnit = this.loadNotifyOrgUnit(objectDao); + if(orgUnit != null){ + return orgUnit.getName(); + } + return ""; + } + + /** + * 查询通知科室 + * @return + */ + public OrgUnit loadNotifyOrgUnit(ObjectDao objectDao){ + if(DatabaseUtil.isPoIdValid(notifyOrgUnitId)){ + return (OrgUnit) objectDao.getById(OrgUnit.class.getSimpleName(), notifyOrgUnitId); + } + return null; + } + + /** + * 查询科室提醒用户列表 + * @param objectDao + * @return + */ + public String loadNotifyUserNames(ObjectDao objectDao){ + List userList = this.loadNotifyUser(objectDao); + if(CollectionUtils.isNotEmpty(userList)){ + List userFullNameList = new ArrayList(); + for (User user : userList) { + userFullNameList.add(user.getFullName()); + } + return StringTools.join(userFullNameList, ";"); + } + return ""; + } + + /** + * 查询科室提醒用户列表 + * @param objectDao + * @return + */ + @SuppressWarnings("unchecked") + public List loadNotifyUser(ObjectDao objectDao){ + List userList = new ArrayList(); + if(DatabaseUtil.isPoIdValid(id)){ + String sql = String.format("select po from %s po where exists (select 1 from %s where problemId = %s and userId = po.id)", + User.class.getSimpleName(), + ProblemNotifyUser.class.getSimpleName(), + id); + return objectDao.findByHql(sql); + } + return userList; + } + } Index: forgon-core/src/main/java/com/forgon/attachfile/model/AttachFile.java =================================================================== diff -u -r23608 -r36252 --- forgon-core/src/main/java/com/forgon/attachfile/model/AttachFile.java (.../AttachFile.java) (revision 23608) +++ forgon-core/src/main/java/com/forgon/attachfile/model/AttachFile.java (.../AttachFile.java) (revision 36252) @@ -14,7 +14,9 @@ private static final long serialVersionUID = 1L; public static final String ATTACH_TYPE_CONSTRACT = "合同附件"; - + + public static final String ATTACH_TYPE_QUESTION = "科室问题反馈附件"; + private Long id; private Blob attachFileBinary; // 附件 Index: ssts-web/src/main/webapp/disinfectsystem/problemReport/problemReportForm.js =================================================================== diff -u -r36251 -r36252 --- ssts-web/src/main/webapp/disinfectsystem/problemReport/problemReportForm.js (.../problemReportForm.js) (revision 36251) +++ ssts-web/src/main/webapp/disinfectsystem/problemReport/problemReportForm.js (.../problemReportForm.js) (revision 36252) @@ -75,7 +75,7 @@ } var dialog = new top.Ext.ux.UploadDialog.Dialog({ title: "上传附件", - url: WWWROOT + '/disinfectSystem/baseData/staffArchiveAction!uploadAttachFile.do?attachType=' + encodeURI("科室问题反馈附件") + '&objectId=' + id, + url: WWWROOT + '/disinfectSystem/problemAction!uploadAttachFile.do?attachType=' + encodeURI("科室问题反馈附件") + '&objectId=' + id, post_var_name: 'uploadFiles',//这里是自己定义的,默认的名字叫file width: 450, height: 300, Index: forgon-core/src/main/java/com/forgon/directory/action/UserAction.java =================================================================== diff -u -r32550 -r36252 --- forgon-core/src/main/java/com/forgon/directory/action/UserAction.java (.../UserAction.java) (revision 32550) +++ forgon-core/src/main/java/com/forgon/directory/action/UserAction.java (.../UserAction.java) (revision 36252) @@ -290,11 +290,16 @@ * @param departId 科室编码,如果为空或者为-1则返回所有科室的所有用户 */ public void loadUserByOrgId(){ + //科室编码 String id = StrutsParamUtils.getPraramValue("departId", "-1"); + //科室ID + String orgUnitId = StrutsParamUtils.getPraramValue("orgUnitId", "-1"); String spell = StrutsParamUtils.getPraramValue("spell", ""); String sql = " where 1=1 "; if(StringUtils.isNotBlank(id) && !id.equals("-1")){ sql += " and po.orgUnit.orgUnitCoding ='" + id +"' "; + }else if(DatabaseUtil.isPoIdValid(orgUnitId)){ + sql += " and po.orgUnit.id = " + orgUnitId +" "; } if(StringUtils.isNotBlank(spell)){ sql += " and (po.user.fullName like '%"+spell.toUpperCase() +"%'"; Index: ssts-web/src/main/java/com/forgon/disinfectsystem/systemwarning/service/SystemWarningManager.java =================================================================== diff -u -r35994 -r36252 --- ssts-web/src/main/java/com/forgon/disinfectsystem/systemwarning/service/SystemWarningManager.java (.../SystemWarningManager.java) (revision 35994) +++ ssts-web/src/main/java/com/forgon/disinfectsystem/systemwarning/service/SystemWarningManager.java (.../SystemWarningManager.java) (revision 36252) @@ -52,4 +52,10 @@ */ public JSONArray getInstrumentRepairWarning(PageEntity pageEntity); + /** + * 查询科室问题反馈提示信息(CDSLQYQYYY-117) + * @return + */ + public JSONArray getProblemWarning(); + } Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/problemreportmanager/problemreport/model/ProblemNotifyRecord.java =================================================================== diff -u --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/problemreportmanager/problemreport/model/ProblemNotifyRecord.java (revision 0) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/problemreportmanager/problemreport/model/ProblemNotifyRecord.java (revision 36252) @@ -0,0 +1,65 @@ +package com.forgon.disinfectsystem.entity.problemreportmanager.problemreport.model; + +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; + +/** + * 问题反馈提醒记录(CDSLQYQYYY-117) + * + */ +@Entity +@DynamicInsert(false) +@DynamicUpdate(true) +@Table(name = "ProblemNotifyRecord", indexes = {@Index(columnList = "problemId", name = "pronotifyrec_proid_index") +,@Index(columnList = "userId", name = "pronotifyrec_uid_index")}) +@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) +public class ProblemNotifyRecord { + + private Long id; + + /** + * 问题ID + */ + private Long problemId; + + /** + * 查看问题提醒用户ID + */ + private Long userId; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getProblemId() { + return problemId; + } + + public void setProblemId(Long problemId) { + this.problemId = problemId; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + +} Index: ssts-web/src/main/java/com/forgon/disinfectsystem/problemreportmanager/problemreport/action/ProblemAction.java =================================================================== diff -u -r32282 -r36252 --- ssts-web/src/main/java/com/forgon/disinfectsystem/problemreportmanager/problemreport/action/ProblemAction.java (.../ProblemAction.java) (revision 32282) +++ ssts-web/src/main/java/com/forgon/disinfectsystem/problemreportmanager/problemreport/action/ProblemAction.java (.../ProblemAction.java) (revision 36252) @@ -1,16 +1,13 @@ package com.forgon.disinfectsystem.problemreportmanager.problemreport.action; -import java.io.IOException; +import java.io.File; import java.text.ParseException; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Calendar; import java.util.Date; -import java.util.HashMap; import java.util.List; -import java.util.Map; -import javax.servlet.http.HttpServletResponse; - import net.sf.json.JSONArray; import net.sf.json.JSONObject; import net.sf.json.JsonConfig; @@ -21,7 +18,7 @@ import org.apache.struts2.convention.annotation.Namespace; import org.apache.struts2.convention.annotation.ParentPackage; -import com.forgon.attachfile.model.AttachFile; +import com.forgon.directory.acegi.tools.AcegiHelper; import com.forgon.directory.model.OrgUnit; import com.forgon.disinfectsystem.entity.problemreportmanager.problemreport.model.Answer; import com.forgon.disinfectsystem.entity.problemreportmanager.problemreport.model.Problem; @@ -33,6 +30,7 @@ import com.forgon.tools.hibernate.ObjectDao; import com.forgon.tools.json.JSONUtil; import com.forgon.tools.json.JsonPropertyFilter; +import com.forgon.tools.string.StringTools; import com.opensymphony.xwork2.ModelDriven; import com.opensymphony.xwork2.Preparable; @ParentPackage(value = "default") @@ -42,7 +40,18 @@ private Problem problem; private ProblemManager problemManager; private ObjectDao objectDao; - public Problem getProblem() { + + private File[] uploadFiles; + + private String[] uploadFilesFileName; + + public void setUploadFiles(File[] uploadFiles) { + this.uploadFiles = uploadFiles; + } + public void setUploadFilesFileName(String[] uploadFilesFileName) { + this.uploadFilesFileName = uploadFilesFileName; + } + public Problem getProblem() { return problem; } public void setProblem(Problem problem) { @@ -59,93 +68,116 @@ } public void loadProblemData(){ - String problemId = StrutsParamUtils.getPraramValue("id", ""); - if (StringUtils.isNotBlank(problemId)) { - problem = problemManager.getProblemById(problemId); - Map map = new HashMap(); - map.put("success", true); - if(problem != null){ - map.put("data", problem); + JSONObject result = JSONUtil.buildJsonObject(false); + try { + JSONObject data = loadProblemDataJson(problem); + if(data != null){ + result = JSONUtil.buildJsonObject(true, data); } - StrutsParamUtils.getResponse().setCharacterEncoding("UTF-8"); - try { - JsonConfig config = new JsonConfig(); - config.setJsonPropertyFilter(new JsonPropertyFilter(new String[] { - "problem","user","orgUnit"})); - JSONObject jsonObject = JSONObject.fromObject(map, config); - List answers = problem.getAnswers(); - JSONArray answerArr = jsonObject.optJSONObject("data").optJSONArray("answers"); - if(CollectionUtils.isNotEmpty(answers)){ - for(int i=0;i answers = problem.getAnswers(); + JSONArray answerArr = jsonObject.optJSONArray("answers"); + if(CollectionUtils.isNotEmpty(answers)){ + for(int i=0;i notifyUserIds = new ArrayList(); + List notifyUserNames = new ArrayList(); + List userList = problem.loadNotifyUser(objectDao); + if(CollectionUtils.isNotEmpty(userList)){ + for (User user : userList) { + notifyUserIds.add(user.getId()+""); + notifyUserNames.add(user.getFullName()); + } } - HttpServletResponse httpServletResponse = StrutsParamUtils - .getResponse(); - httpServletResponse.setCharacterEncoding("UTF-8"); + problem.setNotifyUserIds(StringTools.join(notifyUserIds, ";")); + problem.setNotifyUserNames(StringTools.join(notifyUserNames, ";")); + } + + public void saveProblem() throws ParseException{ + JSONObject result = JSONUtil.buildJsonObject(true); try { - httpServletResponse.getWriter().print(message); - } catch (IOException e) { - e.printStackTrace(); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + String action = StrutsParamUtils.getPraramValue("actionType", ""); + if(StringUtils.equals(action, "answered")){ + // 已解决问题 + problem.setAnswerTime(dateFormat.parse(StrutsParamUtils.getPraramValue("answer_Time", dateFormat.format(Calendar + .getInstance().getTime())))); + problem.setStatus(Problem.ALREADY_ANSWERED); + problem.setFinishTime(new Date()); + }else if(StringUtils.equals(action, "new")){ + // 登记问题 + problem.setReportTime(dateFormat.parse(StrutsParamUtils.getPraramValue("reportTime", dateFormat.format(Calendar + .getInstance().getTime())))); + problem.setStatus(Problem.AWAIT_FOR_ANSWER); + problem.setRegisterPersonId(AcegiHelper.getLoginUser().getUserId()); + problem.setRegisterPerson(AcegiHelper.getLoginUserFullName()); + }else if(StringUtils.equals(action, "update")){ + // 回复问题后,点保存 + problem.setStatus(Problem.ALREADY_ANSWERING); + } + String tempObjectID = StrutsParamUtils.getPraramValue("tempObjectID", ""); + problemManager.saveOrUpdate(problem, tempObjectID); + } catch (Exception e) { + result = JSONUtil.buildJsonObject(false, "保存失败:" + e.getMessage()); } + StrutsResponseUtils.output(result); } /** @@ -166,29 +198,55 @@ * 删除问题 */ public void deleteProblem() { - String ids = StrutsParamUtils.getPraramValue("ids", ""); - String message = ""; + JSONObject result = JSONUtil.buildJsonObject(true); try { + String ids = StrutsParamUtils.getPraramValue("ids", ""); if (StringUtils.isNotBlank(ids)) { String[] str = ids.split(";"); if(str.length != 0){ problemManager.deleteProblemByArray(Problem.class.getSimpleName(), str); } - message = "{success:true}"; } } catch (Exception e) { - message = "{success:false}"; + result = JSONUtil.buildJsonObject(false, "删除失败:" + e.getMessage()); e.printStackTrace(); } - HttpServletResponse httpServletResponse = StrutsParamUtils - .getResponse(); - httpServletResponse.setCharacterEncoding("UTF-8"); + StrutsResponseUtils.output(result); + } + + /** + * 查看问题反馈提醒信息的详细内容 + */ + public void viewProblemNotifyDetail(){ + JSONObject result = JSONUtil.buildJsonObject(true); try { - httpServletResponse.getWriter().print(message); - } catch (IOException e) { + problemManager.viewProblemNotifyDetail(problem, AcegiHelper.getLoginUser().getUserId()); + JSONObject problemJson = loadProblemDataJson(problem); + if(problemJson != null){ + result = JSONUtil.buildJsonObject(true, problemJson); + } + } catch (Exception e) { + result = JSONUtil.buildJsonObject(false, e.getMessage()); + } + StrutsResponseUtils.output(result); + } + + /** + * 上传附件 + */ + public void uploadAttachFile() { + JSONObject json = JSONUtil.buildJsonObject(true, "上传成功!"); + try { + String objectID = StrutsParamUtils.getPraramValue("objectId", null); + String objectType = StrutsParamUtils.getPraramValue("attachType", null); + problemManager.uploadAttachFile(objectID, objectType, uploadFiles, uploadFilesFileName); + }catch (Throwable e) { e.printStackTrace(); + json = JSONUtil.buildJsonObject(false, "上传失败:" + e.getMessage()); } - } + StrutsResponseUtils.output(json); + } + @Override public void prepare() throws Exception { iniInfo(); Index: ssts-web/src/main/java/com/forgon/disinfectsystem/systemwarning/action/SystemWarningAction.java =================================================================== diff -u -r35994 -r36252 --- ssts-web/src/main/java/com/forgon/disinfectsystem/systemwarning/action/SystemWarningAction.java (.../SystemWarningAction.java) (revision 35994) +++ ssts-web/src/main/java/com/forgon/disinfectsystem/systemwarning/action/SystemWarningAction.java (.../SystemWarningAction.java) (revision 36252) @@ -420,4 +420,21 @@ StrutsResponseUtils.output(result); } + /** + * 查询科室问题反馈提示信息(CDSLQYQYYY-117) + */ + public void getProblemWarning(){ + JSONObject result = JSONUtil.buildJsonObject(true); + try { + JSONArray data = systemWarningManager.getProblemWarning(); + if(data != null && data.size() > 0){ + result = JSONUtil.buildJsonObject(true, data); + } + } catch (Exception e) { + e.printStackTrace(); + result = JSONUtil.buildJsonObject(false, "加载失败:" + e.getMessage()); + } + StrutsResponseUtils.output(result); + } + } Index: ssts-web/src/main/java/com/forgon/disinfectsystem/problemreportmanager/problemreport/service/ProblemManagerImpl.java =================================================================== diff -u -r28131 -r36252 --- ssts-web/src/main/java/com/forgon/disinfectsystem/problemreportmanager/problemreport/service/ProblemManagerImpl.java (.../ProblemManagerImpl.java) (revision 28131) +++ ssts-web/src/main/java/com/forgon/disinfectsystem/problemreportmanager/problemreport/service/ProblemManagerImpl.java (.../ProblemManagerImpl.java) (revision 36252) @@ -1,11 +1,18 @@ package com.forgon.disinfectsystem.problemreportmanager.problemreport.service; +import java.io.BufferedOutputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; import java.io.FileInputStream; +import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; import java.io.OutputStream; +import java.sql.ResultSet; import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.UUID; import net.sf.json.JSONArray; import net.sf.json.JSONObject; @@ -21,11 +28,20 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.ss.util.Region; +import com.forgon.Constants; +import com.forgon.attachfile.model.AttachFile; import com.forgon.directory.acegi.tools.AcegiHelper; import com.forgon.directory.model.OrgUnit; +import com.forgon.directory.model.OrgUserRelation; +import com.forgon.directory.service.OrgUnitManager; +import com.forgon.disinfectsystem.basedatamanager.supplyroomconfig.service.SupplyRoomConfigManager; +import com.forgon.disinfectsystem.entity.basedatamanager.supplyroomconfig.SupplyRoomConfig; import com.forgon.disinfectsystem.entity.problemreportmanager.problemreport.model.Answer; import com.forgon.disinfectsystem.entity.problemreportmanager.problemreport.model.Problem; +import com.forgon.disinfectsystem.entity.problemreportmanager.problemreport.model.ProblemNotifyRecord; +import com.forgon.disinfectsystem.entity.problemreportmanager.problemreport.model.ProblemNotifyUser; import com.forgon.excel.service.ExcelUtils; +import com.forgon.exception.SystemException; import com.forgon.security.model.User; import com.forgon.tools.Path; import com.forgon.tools.date.DateTools; @@ -34,28 +50,180 @@ import com.forgon.tools.excel.ExcelHelper; import com.forgon.tools.hibernate.ObjectDao; import com.forgon.tools.json.JsonPropertyFilter; +import com.forgon.tools.string.StringTools; +import com.forgon.tools.util.SqlUtils; public class ProblemManagerImpl implements ProblemManager { private ObjectDao objectDao; + + private SupplyRoomConfigManager supplyRoomConfigManager; + + private OrgUnitManager orgUnitManager; + public void setOrgUnitManager(OrgUnitManager orgUnitManager) { + this.orgUnitManager = orgUnitManager; + } + + public void setSupplyRoomConfigManager( + SupplyRoomConfigManager supplyRoomConfigManager) { + this.supplyRoomConfigManager = supplyRoomConfigManager; + } + public void setObjectDao(ObjectDao objectDao) { this.objectDao = objectDao; } @Override public void saveOrUpdate(Problem problem) { + //保存问题反馈 objectDao.saveOrUpdate(problem); + //保存通知科室 + saveNotifyOrgUnit(problem); + //保存问题反馈的通知用户 + saveProblemNotifyUser(problem); + //删除已接收通知的用户的通知记录 + deleteProblemNotifyRecord(problem); + //保存修改人 + problem.setSubmitUserId(AcegiHelper.getLoginUser().getUserId()); } - @Override - public void saveOrUpdate(Problem problem, List needToRemove) { - if (needToRemove != null && needToRemove.size() > 0) { - objectDao.deleteAll(needToRemove); + /** + * 保存问题反馈的通知用户 + * @param problem + */ + private void saveProblemNotifyUser(Problem problem) { + if(problem == null || !DatabaseUtil.isPoIdValid(problem.getId())){ + return; } - objectDao.saveOrUpdate(problem); + + //删除旧的问题反馈的通知用户 + deleteProblemNotifyUser(problem); + String notifyUserIds = problem.getNotifyUserIds(); + if(StringUtils.isBlank(notifyUserIds) && !StringUtils.equals(problem.getNotifyAllOrgUnitUser(), Constants.STR_YES)){ + throw new SystemException("问题反馈的通知用户不能为空"); + } + if(StringUtils.isBlank(notifyUserIds)){ + //没有提醒用户或者提醒科室全部用户 + return; + } + List problemNotifyUserList = new ArrayList(); + //查询通知科室下的通知用户 + String userSql = String.format("select po.id from SS_USERS po join %s our on po.id = our.userId where our.orgUnitId = %s and %s", + OrgUserRelation.class.getSimpleName(), + problem.getNotifyOrgUnitId(), + SqlUtils.getNonStringFieldInLargeCollectionsPredicate("po.id", StringTools.toCollectionIgnoreNullAndBlank(notifyUserIds, ";"))); + ResultSet rs = null; + try { + rs = objectDao.executeSql(userSql); + while(rs.next()){ + Long id = rs.getLong("id"); + ProblemNotifyUser problemNotifyUser = new ProblemNotifyUser(); + problemNotifyUser.setProblemId(problem.getId()); + problemNotifyUser.setUserId(id); + problemNotifyUserList.add(problemNotifyUser); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + DatabaseUtil.closeResultSetAndStatement(rs); + } + if(CollectionUtils.isEmpty(problemNotifyUserList)){ + throw new SystemException("问题反馈的通知用户不能为空"); + } + for (ProblemNotifyUser problemNotifyUser : problemNotifyUserList) { + objectDao.saveOrUpdate(problemNotifyUser); + } } + /** + * 删除已接收通知的用户的通知记录 + * @param problem + */ + private void deleteProblemNotifyRecord(Problem problem) { + if(DatabaseUtil.isPoIdValid(problem.getId())){ + String deleteSql = String.format("delete from %s where problemId = %s", ProblemNotifyRecord.class.getSimpleName(), problem.getId()); + objectDao.excuteSQL(deleteSql); + } + } + + /** + * 批量删除已接收通知的用户的通知记录 + * @param problemIdList + */ + private void deleteProblemNotifyRecord(List problemIdList){ + if(CollectionUtils.isNotEmpty(problemIdList)){ + //删除用户接收提醒的提醒记录 + String deleteProblemNotifyRecordSql = String.format("delete from %s where %s", + ProblemNotifyRecord.class.getSimpleName(), + SqlUtils.getNonStringFieldInLargeCollectionsPredicate("problemId", problemIdList)); + objectDao.excuteSQL(deleteProblemNotifyRecordSql); + } + } + + /** + * 删除通知用户 + * @param problem + */ + private void deleteProblemNotifyUser(Problem problem) { + if(DatabaseUtil.isPoIdValid(problem.getId())){ + String deleteSql = String.format("delete from %s where problemId = %s", ProblemNotifyUser.class.getSimpleName(), problem.getId()); + objectDao.excuteSQL(deleteSql); + } + } + + /** + * 批量删除通知用户 + * @param problemIdList + */ + private void deleteProblemNotifyUser(List problemIdList){ + if(CollectionUtils.isNotEmpty(problemIdList)){ + //删除用户接收提醒的提醒记录 + String deleteProblemNotifyRecordSql = String.format("delete from %s where %s", + ProblemNotifyUser.class.getSimpleName(), + SqlUtils.getNonStringFieldInLargeCollectionsPredicate("problemId", problemIdList)); + objectDao.excuteSQL(deleteProblemNotifyRecordSql); + } + } + + /** + * 验证通知科室及登记科室是否合法 + * 1、登记科室为一级供应室,通知科室必须为除当前科室外的所有未停用科室; + * 2、登记科室为非一级供应室,通知科室固定为一级供应室 + * @param problem + */ + private void saveNotifyOrgUnit(Problem problem) { + if(problem == null){ + return; + } + //登记科室编码 + String orgUnitCoding = problem.getOrgUnitCoding(); + //通知科室Id + Long notifyOrgUnitId = problem.getNotifyOrgUnitId(); + if(StringUtils.isBlank(orgUnitCoding) || StringUtils.isBlank(problem.getOrgUnitName())){ + throw new SystemException("登记科室不能为空!"); + } + if(!DatabaseUtil.isPoIdValid(notifyOrgUnitId)){ + throw new SystemException("通知科室不能为空!"); + } + OrgUnit notifyOrgUnit = orgUnitManager.get(notifyOrgUnitId); + if(notifyOrgUnit == null){ + throw new SystemException("通知科室不能为空!"); + } + if(notifyOrgUnit.isDisable()){ + throw new SystemException("通知科室已被停用!"); + } + if(!supplyRoomConfigManager.isFirstSupplyRoomOrgUnit(orgUnitCoding)){ + //登记科室非一级供应室,通知科室固定为一级供应室 + if(!supplyRoomConfigManager.isFirstSupplyRoomOrgUnit(notifyOrgUnit.getOrgUnitCoding())){ + throw new SystemException("通知科室必须为一级供应室!"); + } + //通知科室固定为一级供应室时,默认通知所有供应室用户 + problem.setNotifyAllOrgUnitUser(Constants.STR_YES); + } + + } + @Override public Problem getProblemById(String id) { return (Problem) objectDao.getByProperty(Problem.class.getSimpleName(), "id", Long.valueOf(id)); @@ -79,13 +247,16 @@ idList.add(Long.valueOf(id)); } objectDao.delete(poName, idList); + this.deleteProblemNotifyRecord(idList); + this.deleteProblemNotifyUser(idList); } } @Override + @SuppressWarnings("unchecked") public int getUnAnsweredQuestion() { String sql = " where status='"+Problem.AWAIT_FOR_ANSWER+"'"; - List result = objectDao.findBySql(Problem.class.getSimpleName(), sql); + List result = objectDao.findBySql(Problem.class.getSimpleName(), sql); return result.size(); } @@ -110,7 +281,10 @@ answer.setUserId(user.getId()); answer.setReplyTime(new Date()); answers.add(answer); - this.saveOrUpdate(problem); + //更新最后修改人 + problem.setSubmitUserId(AcegiHelper.getLoginUser().getUserId()); + objectDao.saveOrUpdate(problem); + deleteProblemNotifyRecord(problem); } @SuppressWarnings("unchecked") @@ -278,4 +452,167 @@ return wb; } + @Override + public void saveOrUpdate(Problem problem, String tempObjectID) { + this.saveOrUpdate(problem); + if(DatabaseUtil.isPoIdValid(tempObjectID)){ + String sql = String.format("update %s set objectId = %s where objectId =%s ", + AttachFile.class.getSimpleName(), + problem.getId(), + tempObjectID); + objectDao.excuteSQL(sql); + } + } + + @Override + public void viewProblemNotifyDetail(Problem problem, Long userId) { + if(problem == null || !DatabaseUtil.isPoIdValid(problem.getId())|| !DatabaseUtil.isPoIdValid(userId)){ + throw new SystemException("参数异常!"); + } + ProblemNotifyRecord problemNotifyRecord = new ProblemNotifyRecord(); + problemNotifyRecord.setProblemId(problem.getId()); + problemNotifyRecord.setUserId(userId); + objectDao.save(problemNotifyRecord); + } + + @Override + public void uploadAttachFile(String objectID, String objectType, + File[] uploadFiles, String[] uploadFilesFileName) { + + if(uploadFiles == null || uploadFiles.length == 0){ + return; + } + + if(uploadFilesFileName == null || uploadFilesFileName.length == 0){ + return; + } + + if(!DatabaseUtil.isPoIdValid(objectID)){ + return; + } + + if(!StringUtils.equals(objectType, AttachFile.ATTACH_TYPE_QUESTION)){ + return; + } + + SupplyRoomConfig supplyRoomConfig = supplyRoomConfigManager + .getSystemParamsObj(); + String saveImageDirectory = supplyRoomConfig.getSaveImagePath(); + boolean isSavePathExist = supplyRoomConfigManager.isSavePathExist(); + if(isSavePathExist == false){ + throw new SystemException("文件保存目录不存在."); + } + int uploadSuccessFileSize = 0; + for(int i = 0,size = uploadFiles.length;i 0){ + //更新问题反馈的最后提交人 + updateProblemAfterUploadAttachFile(objectID, objectType); + } + } + } + + /** + * 更新上传人 + * @param attachFile + */ + private void updateProblemAfterUploadAttachFile(String objectID, String attachType) { + if(!DatabaseUtil.isPoIdValid(objectID)){ + return; + } + if(!StringUtils.equals(attachType, AttachFile.ATTACH_TYPE_QUESTION)){ + return; + } + Problem problem = (Problem) this.objectDao.getById(Problem.class.getSimpleName(), objectID); + if(problem != null){ + problem.setSubmitUserId(AcegiHelper.getLoginUser().getUserId()); + } + deleteProblemNotifyRecord(problem); + } + + /** + * 根据byte数组,生成文件 + */ + public void saveFile(byte[] bfile, String filePath,String fileName) { + BufferedOutputStream bos = null; + FileOutputStream fos = null; + File file = null; + try { +// new Directory() + File dir = new File(filePath); + if(!dir.exists()) + {//判断文件目录是否存在 + dir.mkdirs(); + } + file = new File(filePath+"\\"+fileName); + if( !file.exists()) + { + file.createNewFile(); + } + fos = new FileOutputStream(file); + bos = new BufferedOutputStream(fos); + bos.write(bfile); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (bos != null) { + try { + bos.close(); + } catch (IOException e1) { + e1.printStackTrace(); + } + } + if (fos != null) { + try { + fos.close(); + } catch (IOException e1) { + e1.printStackTrace(); + } + } + } + } + } Index: forgon-tools/src/main/java/com/forgon/Constants.java =================================================================== diff -u -r36111 -r36252 --- forgon-tools/src/main/java/com/forgon/Constants.java (.../Constants.java) (revision 36111) +++ forgon-tools/src/main/java/com/forgon/Constants.java (.../Constants.java) (revision 36252) @@ -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.9","5.0.10","5.0.11","5.0.12"}; + "5.0.8","5.0.9","5.0.10","5.0.11","5.0.12","5.0.13"}; // 版本列表(4.0版本升级4.1版需要分两步:先从4.0升到4.1.0、然后从4.1.0升级4.1最新版本) /*public final static String[] SOFTWARE_VERSION_ARRAY = new String[] { Index: ssts-web/src/main/java/com/forgon/disinfectsystem/problemreportmanager/problemreport/service/ProblemManager.java =================================================================== diff -u -r28131 -r36252 --- ssts-web/src/main/java/com/forgon/disinfectsystem/problemreportmanager/problemreport/service/ProblemManager.java (.../ProblemManager.java) (revision 28131) +++ ssts-web/src/main/java/com/forgon/disinfectsystem/problemreportmanager/problemreport/service/ProblemManager.java (.../ProblemManager.java) (revision 36252) @@ -1,5 +1,6 @@ package com.forgon.disinfectsystem.problemreportmanager.problemreport.service; +import java.io.File; import java.io.OutputStream; import java.util.List; @@ -9,9 +10,6 @@ public void saveOrUpdate(Problem problem); - public void saveOrUpdate(Problem problem, - List needToRemove); - public Problem getProblemById(String id); public void deleteProblemByArray(String poName,String[] ids); @@ -33,5 +31,30 @@ * @param ids:1,2,3 */ public void exportProblemReocrds(OutputStream ops,String ids); + + /** + * 保存科室问题反馈记录 + * @param problem + * @param tempObjectID + */ + public void saveOrUpdate(Problem problem, String tempObjectID); + + /** + * 查看问题反馈提醒信息的详细内容 + * @param problem + * @param userId + * @return + */ + public void viewProblemNotifyDetail(Problem problem, Long userId); + + /** + * 问题反馈上传附件 + * @param objectID + * @param objectType + * @param uploadFiles + * @param uploadFilesFileName + */ + public void uploadAttachFile(String objectID, String objectType, + File[] uploadFiles, String[] uploadFilesFileName); } Index: ssts-web/src/main/webapp/dataUpdater/sqls/5.0.12_5.0.13.sql =================================================================== diff -u --- ssts-web/src/main/webapp/dataUpdater/sqls/5.0.12_5.0.13.sql (revision 0) +++ ssts-web/src/main/webapp/dataUpdater/sqls/5.0.12_5.0.13.sql (revision 36252) @@ -0,0 +1,3 @@ +update Problem set notifyOrgUnitId = (select max(id) from OrgUnit where orgUnitCoding in (select src.orgUnitCoding from SupplyRoomConfig src where src.supplyRoomType = 1)), notifyAllOrgUnitUser = '是' where notifyOrgUnitId is null; +update Problem set registerPersonid = (select max(id) from SS_USERS where fullName = registerPerson) where registerPersonid is null; +update Problem set submitUserId = registerPersonid; \ No newline at end of file Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/problemreportmanager/problemreport/model/ProblemNotifyUser.java =================================================================== diff -u --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/problemreportmanager/problemreport/model/ProblemNotifyUser.java (revision 0) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/problemreportmanager/problemreport/model/ProblemNotifyUser.java (revision 36252) @@ -0,0 +1,65 @@ +package com.forgon.disinfectsystem.entity.problemreportmanager.problemreport.model; + +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; + +/** + * 问题反馈的通知人 + * + */ +@Entity +@DynamicInsert(false) +@DynamicUpdate(true) +@Table(name = "ProblemNotifyUser", indexes ={@Index(columnList = "userId", name = "pnu_nuid_index") +,@Index(columnList = "problemId", name = "pnu_proid_index")}) +@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) +public class ProblemNotifyUser { + + private Long id; + + /** + * 通知人ID + */ + private Long userId; + + /** + * 问题反馈ID + */ + private Long problemId; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + + public Long getProblemId() { + return problemId; + } + + public void setProblemId(Long problemId) { + this.problemId = problemId; + } + +}