Index: ssts-web/src/main/resources/systemset/operationDefine.xml =================================================================== diff -u -r27499 -r28131 --- ssts-web/src/main/resources/systemset/operationDefine.xml (.../operationDefine.xml) (revision 27499) +++ ssts-web/src/main/resources/systemset/operationDefine.xml (.../operationDefine.xml) (revision 28131) @@ -217,6 +217,7 @@ + Index: ssts-web/src/main/java/com/forgon/disinfectsystem/problemreportmanager/problemreport/service/ProblemManagerImpl.java =================================================================== diff -u -r18324 -r28131 --- ssts-web/src/main/java/com/forgon/disinfectsystem/problemreportmanager/problemreport/service/ProblemManagerImpl.java (.../ProblemManagerImpl.java) (revision 18324) +++ ssts-web/src/main/java/com/forgon/disinfectsystem/problemreportmanager/problemreport/service/ProblemManagerImpl.java (.../ProblemManagerImpl.java) (revision 28131) @@ -1,10 +1,39 @@ package com.forgon.disinfectsystem.problemreportmanager.problemreport.service; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.OutputStream; import java.util.ArrayList; +import java.util.Date; import java.util.List; +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; +import net.sf.json.JsonConfig; + +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.poi.hssf.usermodel.HSSFCellStyle; +import org.apache.poi.hssf.usermodel.HSSFFont; +import org.apache.poi.hssf.usermodel.HSSFRow; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.poifs.filesystem.POIFSFileSystem; +import org.apache.poi.ss.util.Region; + +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; +import com.forgon.excel.service.ExcelUtils; +import com.forgon.security.model.User; +import com.forgon.tools.Path; +import com.forgon.tools.date.DateTools; +import com.forgon.tools.db.DatabaseUtil; +import com.forgon.tools.excel.ExcelCellStyle; +import com.forgon.tools.excel.ExcelHelper; import com.forgon.tools.hibernate.ObjectDao; +import com.forgon.tools.json.JsonPropertyFilter; public class ProblemManagerImpl implements ProblemManager { @@ -60,4 +89,193 @@ return result.size(); } + @Override + public void replyProblem(Problem problem, String content) { + if(problem == null || !DatabaseUtil.isPoIdValid(problem.getId())){ + throw new RuntimeException("问题反馈记录不存在"); + } + if(StringUtils.isBlank(content)){ + throw new RuntimeException("回复内容不能为空"); + } + problem.setStatus(Problem.ALREADY_ANSWERING); + List answers = problem.getAnswers(); + // 获取当前登录科室 + String orgUnitCode = AcegiHelper.getCurrentOrgUnitCode(); + OrgUnit orgUnit = (OrgUnit) objectDao.getByProperty(OrgUnit.class.getSimpleName(), "orgUnitCoding", orgUnitCode); + // 获取当前登录用户 + User user = (User) objectDao.getById(User.class.getSimpleName(), AcegiHelper.getLoginUser().getUserId()); + Answer answer = new Answer(); + answer.setContent(content); + answer.setOrgUnitId(orgUnit.getId()); + answer.setUserId(user.getId()); + answer.setReplyTime(new Date()); + answers.add(answer); + this.saveOrUpdate(problem); + } + + @SuppressWarnings("unchecked") + @Override + public void exportProblemReocrds(OutputStream ops, String ids) { + if(StringUtils.isBlank(ids)){ + throw new RuntimeException("未选中科室问题反馈记录!"); + } + String sql = String.format(" where po.id in (%s)", ids); + List problems = objectDao.findBySql(Problem.class.getSimpleName(), sql, "reportTime"); + if(CollectionUtils.isEmpty(problems)){ + throw new RuntimeException("未找到科室问题反馈记录!"); + } + createProblemExportFile(problems, ops); + } + + /** + * 导出科室问题反馈记录excel文件 + * @param problems + * @param ops + */ + private void createProblemExportFile(List problems, OutputStream ops) { + HSSFWorkbook wb = buildExcelFile(ops); + HSSFSheet sheet = wb.getSheetAt(0); + JSONArray columnJsonArray = Problem.problemColumnNameAndPoPropertyNameArrray; + int sheetColumnSize = columnJsonArray.size(); + sheet.setColumnWidth(0, 2000); + sheet.setColumnWidth(1, 5000); + sheet.setColumnWidth(2, 5000); + sheet.setColumnWidth(3, 5000); + + sheet.setColumnWidth(4, 3000); + sheet.setColumnWidth(5, 5000); + sheet.setColumnWidth(6, 5000); + sheet.setColumnWidth(7, 5000); + sheet.setColumnWidth(8, 5000); + // + HSSFCellStyle nullCellStyle = buildNullCellStyle(wb); + //标题 + int rowspanLength = sheetColumnSize-1; + if(rowspanLength < 0){ + rowspanLength = 0; + } + sheet.addMergedRegion(new Region(0, (short)0, 0, (short)rowspanLength)); + sheet.addMergedRegion(new Region(1, (short)0, 1, (short)rowspanLength)); + HSSFRow operatingRow0 = sheet.createRow(0); + String title = "科室问题反馈"; + HSSFFont titleFont = wb.createFont(); + titleFont.setFontHeightInPoints((short) 22); // 设置字体大小为22,宋体,加粗 + titleFont.setFontName("宋体"); + titleFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); + nullCellStyle.setFont(titleFont); + ExcelUtils.createStringCell(operatingRow0, nullCellStyle, 0,title); + + //日期范围 + int row = 1; + Date startTime = problems.get(0).getReportTime(); + Date endTime = problems.get(problems.size()-1).getReportTime(); + HSSFRow operatingDateRow = sheet.createRow(row); + String dateStr = "日期:" + DateTools.getFormatDateStr(startTime, "yyyy-MM-dd") + "~"+ DateTools.getFormatDateStr(endTime, "yyyy-MM-dd"); + HSSFCellStyle nullCellStyle2 = buildNullCellStyle(wb);// 左对齐 + nullCellStyle2.setAlignment(HSSFCellStyle.ALIGN_LEFT); + ExcelUtils.createStringCell(operatingDateRow, nullCellStyle2, 0, dateStr); + row++; + + //列头 + HSSFRow operatingHeadRow = sheet.createRow(row); + HSSFCellStyle cellStyleOfHead = buildExcelStyle(wb); + HSSFFont fontOfHead = wb.createFont(); + fontOfHead.setFontHeightInPoints((short) 12); // 设置字体大小为22,宋体,加粗 + fontOfHead.setFontName("宋体"); + fontOfHead.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); + cellStyleOfHead.setFont(fontOfHead); + for(int i=0;i findProblemBySql(String sql); public int getUnAnsweredQuestion(); + + /** + * 问题回复 + * @param problem 问题 + * @param content 回复内容 + */ + public void replyProblem(Problem problem, String content); + + /** + * 导出科室问题反馈记录 + * @param ops + * @param ids:1,2,3 + */ + public void exportProblemReocrds(OutputStream ops,String ids); + } Index: ssts-web/src/main/java/com/forgon/disinfectsystem/problemreportmanager/problemreport/dwr/table/ProblemTableManager.java =================================================================== diff -u -r12331 -r28131 --- ssts-web/src/main/java/com/forgon/disinfectsystem/problemreportmanager/problemreport/dwr/table/ProblemTableManager.java (.../ProblemTableManager.java) (revision 12331) +++ ssts-web/src/main/java/com/forgon/disinfectsystem/problemreportmanager/problemreport/dwr/table/ProblemTableManager.java (.../ProblemTableManager.java) (revision 28131) @@ -3,23 +3,62 @@ import java.util.List; import java.util.Map; +import org.apache.commons.lang.StringUtils; + import com.forgon.component.grid.GridManager; +import com.forgon.databaseadapter.service.DateQueryAdapter; import com.forgon.disinfectsystem.entity.problemreportmanager.problemreport.model.Problem; +import com.forgon.tools.StrutsParamUtils; import com.forgon.tools.hibernate.ObjectDao; public class ProblemTableManager { private GridManager gridManager; private ObjectDao objectDao; + private DateQueryAdapter dateQueryAdapter; public void setObjectDao(ObjectDao objectDao) { this.objectDao = objectDao; } public void setGridManager(GridManager gridManager) { this.gridManager = gridManager; } + public void setDateQueryAdapter(DateQueryAdapter dateQueryAdapter) { + this.dateQueryAdapter = dateQueryAdapter; + } public String findProblemTableList( Map> parameterMap) { - String sql = ""; + Map sqlWhereParamMap = gridManager.getParamFromView(parameterMap); + //科室编码 + String orgUnitCode = sqlWhereParamMap.get("orgUnitCode"); + //科室时间 + String startTime = sqlWhereParamMap.get("startTime"); + //结束时间 + String endTime = sqlWhereParamMap.get("endTime"); + //问题类型 + String type = sqlWhereParamMap.get("type"); + //问题状态 + String status = sqlWhereParamMap.get("status"); + String sql = " where (1=1) "; + + if(StringUtils.isNotBlank(orgUnitCode)){ + sql += "and po.orgUnitCoding = '" + orgUnitCode + "'"; + } + + if(StringUtils.isNotBlank(startTime)){ + sql += " and po.reportTime >= " + dateQueryAdapter.dateAdapter(startTime); + } + + if(StringUtils.isNotBlank(endTime)){ + sql += " and po.reportTime <= " + dateQueryAdapter.dateAdapter(endTime); + } + + if(StringUtils.isNotBlank(status) && !StringUtils.equals("全部", status)){ + sql += " and po.status = '" + status + "'"; + } + + if(StringUtils.isNotBlank(type)){ + sql += " and po.type = '" + type + "'"; + } return gridManager.renderGrid(parameterMap, Problem.class.getSimpleName(), sql, new String[] { }); } Index: ssts-web/src/main/webapp/dataUpdater/sqls/4.9.44_4.9.45_sqlserver.sql =================================================================== diff -u --- ssts-web/src/main/webapp/dataUpdater/sqls/4.9.44_4.9.45_sqlserver.sql (revision 0) +++ ssts-web/src/main/webapp/dataUpdater/sqls/4.9.44_4.9.45_sqlserver.sql (revision 28131) @@ -0,0 +1,16 @@ +declare @answerCount numeric(20); +begin + begin tran + begin try + update Problem set status = '已完成' where status = '已回复'; + select @answerCount=count(*) from Answer; + if (@answerCount = 0) + begin + insert into Answer (content, replyTime, problem_id) select answer, answerTime, id from Problem; + end; + commit tran + end try + begin catch + rollback tran + end catch +end; \ No newline at end of file Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/problemreportmanager/problemreport/model/Answer.java =================================================================== diff -u --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/problemreportmanager/problemreport/model/Answer.java (revision 0) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/problemreportmanager/problemreport/model/Answer.java (revision 28131) @@ -0,0 +1,115 @@ +package com.forgon.disinfectsystem.entity.problemreportmanager.problemreport.model; + +import java.util.Date; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.Transient; + +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.CacheConcurrencyStrategy; +import org.hibernate.annotations.DynamicInsert; +import org.hibernate.annotations.DynamicUpdate; + +import com.forgon.directory.model.OrgUnit; +import com.forgon.security.model.User; +import com.forgon.tools.hibernate.ObjectDao; + +/** + * 问题回复类,记录问题回复内容 + * @author ZhouPeiMian + * + */ + +@Entity +@DynamicInsert(false) +@DynamicUpdate(true) +@Table(name = "Answer") +@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) +public class Answer { + + private Long id; + + /** + * 回复人Id + */ + private Long userId; + + /** + * 回复人当前登录科室Id + */ + private Long orgUnitId; + + /** + * 回复内容 + */ + private String content; + + /** + * 回复时间 + */ + private Date replyTime; + + @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 getOrgUnitId() { + return orgUnitId; + } + + public void setOrgUnitId(Long orgUnitId) { + this.orgUnitId = orgUnitId; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public Date getReplyTime() { + return replyTime; + } + + public void setReplyTime(Date replyTime) { + this.replyTime = replyTime; + } + + + @Transient + public User getUser(ObjectDao objectDao) { + if(this.userId == null){ + return null; + } + return (User) objectDao.getById(User.class.getSimpleName(), userId); + } + + @Transient + public OrgUnit getOrgUnit(ObjectDao objectDao) { + if(this.orgUnitId == null){ + return null; + } + return (OrgUnit) objectDao.getById(OrgUnit.class.getSimpleName(), orgUnitId); + } + +} Index: ssts-web/src/main/resources/systemset/portalPage.xml =================================================================== diff -u -r27159 -r28131 --- ssts-web/src/main/resources/systemset/portalPage.xml (.../portalPage.xml) (revision 27159) +++ ssts-web/src/main/resources/systemset/portalPage.xml (.../portalPage.xml) (revision 28131) @@ -46,14 +46,13 @@ - + - \ No newline at end of file Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/problemreportmanager/problemreport/model/Problem.java =================================================================== diff -u -r23492 -r28131 --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/problemreportmanager/problemreport/model/Problem.java (.../Problem.java) (revision 23492) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/problemreportmanager/problemreport/model/Problem.java (.../Problem.java) (revision 28131) @@ -1,18 +1,33 @@ package com.forgon.disinfectsystem.entity.problemreportmanager.problemreport.model; +import java.util.ArrayList; import java.util.Date; +import java.util.List; import javax.persistence.Entity; + +import net.sf.json.JSONArray; + +import org.hibernate.annotations.Cascade; import org.hibernate.annotations.DynamicInsert; import org.hibernate.annotations.DynamicUpdate; +import org.hibernate.annotations.CascadeType; + +import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.OneToMany; import javax.persistence.Table; +import javax.persistence.Transient; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.forgon.Constants; + /** * 问题定义类,用来描述科室向供应室上报的问题信息 * @author liujie @@ -47,8 +62,45 @@ //回复时间 private Date answerTime; + /** + * 完成时间JMSZXYY-84(页面点“已解决”时取值) + */ + private Date finishTime; + + /** + * 科室问题反馈类型JMSZXYY-84 + */ + private String type; + /** + * 问题回复记录 + */ + @JsonIgnore + private List answers = new ArrayList(); + public static final String AWAIT_FOR_ANSWER = "待回复"; - public static final String ALREADY_ANSWERED = "已回复"; + /** + * 状态:回复中(JMSZXYY-84新增状态:回复中) + */ + public static final String ALREADY_ANSWERING = "回复中"; + /** + * 状态:已完成(JMSZXYY-84原有状态待已回复改为已完成) + */ + public static final String ALREADY_ANSWERED = "已完成"; + + public static JSONArray problemColumnNameAndPoPropertyNameArrray = new JSONArray(); + + static { + problemColumnNameAndPoPropertyNameArrray.add("{header:'序号',dataIndex:'rowIndex',type:'int'}"); + problemColumnNameAndPoPropertyNameArrray.add("{header:'标题',dataIndex:'title',type:'string'}"); + problemColumnNameAndPoPropertyNameArrray.add("{header:'描述',dataIndex:'description',type:'string'}"); + problemColumnNameAndPoPropertyNameArrray.add("{header:'科室',dataIndex:'orgUnitName',type:'string'}"); + problemColumnNameAndPoPropertyNameArrray.add("{header:'状态',dataIndex:'status',type:'string'}"); + problemColumnNameAndPoPropertyNameArrray.add("{header:'问题类型',dataIndex:'type',type:'string'}"); + problemColumnNameAndPoPropertyNameArrray.add("{header:'报告人',dataIndex:'registerPerson',type:'string'}"); + problemColumnNameAndPoPropertyNameArrray.add("{header:'反馈时间',dataIndex:'reportTimeString',type:'string'}"); + problemColumnNameAndPoPropertyNameArrray.add("{header:'完成时间',dataIndex:'finishTimeString',type:'string'}"); + } + @Id @GeneratedValue(strategy = GenerationType.AUTO) public Long getId() { @@ -122,5 +174,45 @@ this.registerPerson = registerPerson; } + public Date getFinishTime() { + return finishTime; + } + public void setFinishTime(Date finishTime) { + this.finishTime = finishTime; + } + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + @OneToMany(fetch = FetchType.LAZY) + @Cascade(value = { CascadeType.ALL }) + @JoinColumn(name = "problem_id") + public List getAnswers() { + return answers; + } + public void setAnswers(List answers) { + this.answers = answers; + } + + @Transient + public String getReportTimeString(){ + if(reportTime != null){ + String str = Constants.SIMPLEDATEFORMAT_YYYYMMDD.format(reportTime); + return str; + } + return ""; + } + + @Transient + public String getFinishTimeString(){ + if(finishTime != null){ + String str = Constants.SIMPLEDATEFORMAT_YYYYMMDD.format(finishTime); + return str; + } + return ""; + } + } Index: ssts-web/src/main/java/com/forgon/disinfectsystem/problemreportmanager/problemreport/action/ProblemAction.java =================================================================== diff -u -r12331 -r28131 --- ssts-web/src/main/java/com/forgon/disinfectsystem/problemreportmanager/problemreport/action/ProblemAction.java (.../ProblemAction.java) (revision 12331) +++ ssts-web/src/main/java/com/forgon/disinfectsystem/problemreportmanager/problemreport/action/ProblemAction.java (.../ProblemAction.java) (revision 28131) @@ -4,22 +4,34 @@ import java.text.ParseException; import java.text.SimpleDateFormat; 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; +import org.apache.commons.collections.CollectionUtils; 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.directory.model.OrgUnit; +import com.forgon.disinfectsystem.entity.problemreportmanager.problemreport.model.Answer; import com.forgon.disinfectsystem.entity.problemreportmanager.problemreport.model.Problem; import com.forgon.disinfectsystem.problemreportmanager.problemreport.dwr.table.ProblemTableManager; import com.forgon.disinfectsystem.problemreportmanager.problemreport.service.ProblemManager; +import com.forgon.security.model.User; import com.forgon.tools.StrutsParamUtils; +import com.forgon.tools.StrutsResponseUtils; +import com.forgon.tools.hibernate.ObjectDao; +import com.forgon.tools.json.JSONUtil; +import com.forgon.tools.json.JsonPropertyFilter; import com.opensymphony.xwork2.ModelDriven; import com.opensymphony.xwork2.Preparable; @ParentPackage(value = "default") @@ -28,7 +40,8 @@ public class ProblemAction implements ModelDriven,Preparable{ private Problem problem; private ProblemManager problemManager; - public Problem getProblem() { + private ObjectDao objectDao; + public Problem getProblem() { return problem; } public void setProblem(Problem problem) { @@ -39,6 +52,11 @@ } public void setProblemTableManager(ProblemTableManager problemTableManager) { } + + public void setObjectDao(ObjectDao objectDao) { + this.objectDao = objectDao; + } + public void loadProblemData(){ String problemId = StrutsParamUtils.getPraramValue("id", ""); if (StringUtils.isNotBlank(problemId)) { @@ -50,7 +68,38 @@ } StrutsParamUtils.getResponse().setCharacterEncoding("UTF-8"); try { - JSONObject jsonObject = JSONObject.fromObject(map); + 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