Commit bd9261f5 by java-lixy

导出、转为文档、发消息

parent de120831
...@@ -84,7 +84,16 @@ public class ExportExcel { ...@@ -84,7 +84,16 @@ public class ExportExcel {
public ExportExcel(String title, Class<?> cls){ public ExportExcel(String title, Class<?> cls){
this(title, cls, 1); this(title, cls, 1);
} }
/**
* 构造函数
* @param title 表格标题,传“空值”,表示无标题
* @param cls 实体对象,通过annotation.ExportField获取标题
*/
public ExportExcel(String title, Class<?> cls, boolean isAdmin){
this(title, cls, isAdmin,1);
}
/** /**
* 构造函数 * 构造函数
* @param title 表格标题,传“空值”,表示无标题 * @param title 表格标题,传“空值”,表示无标题
...@@ -93,7 +102,7 @@ public class ExportExcel { ...@@ -93,7 +102,7 @@ public class ExportExcel {
* @param groups 导入分组 * @param groups 导入分组
*/ */
public ExportExcel(String title, Class<?> cls, int type, int... groups){ public ExportExcel(String title, Class<?> cls, int type, int... groups){
// Get annotation field // Get annotation field
Field[] fs = cls.getDeclaredFields(); Field[] fs = cls.getDeclaredFields();
for (Field f : fs){ for (Field f : fs){
ExcelField ef = f.getAnnotation(ExcelField.class); ExcelField ef = f.getAnnotation(ExcelField.class);
...@@ -163,7 +172,92 @@ public class ExportExcel { ...@@ -163,7 +172,92 @@ public class ExportExcel {
} }
initialize(title, headerList); initialize(title, headerList);
} }
/**
* 构造函数
* @param title 表格标题,传“空值”,表示无标题
* @param cls 实体对象,通过annotation.ExportField获取标题
* @param type 导出类型(1:导出数据;2:导出模板)
* @param groups 导入分组
*/
public ExportExcel(String title, Class<?> cls, boolean isAdmin, int type, int... groups){
// Get annotation field
Field[] fs = cls.getDeclaredFields();
for (Field f : fs){
ExcelField ef = f.getAnnotation(ExcelField.class);
if (ef != null && (ef.type()==0 || ef.type()==type)){
if (groups!=null && groups.length>0){
boolean inGroup = false;
for (int g : groups){
if (inGroup){
break;
}
for (int efg : ef.groups()){
if (g == efg){
inGroup = true;
annotationList.add(new Object[]{ef, f});
break;
}
}
}
}else{
annotationList.add(new Object[]{ef, f});
}
}
}
// Get annotation method
Method[] ms = cls.getDeclaredMethods();
for (Method m : ms){
ExcelField ef = m.getAnnotation(ExcelField.class);
if (ef != null && (ef.type()==0 || ef.type()==type)){
if (groups!=null && groups.length>0){
boolean inGroup = false;
for (int g : groups){
if (inGroup){
break;
}
for (int efg : ef.groups()){
if (g == efg){
inGroup = true;
annotationList.add(new Object[]{ef, m});
break;
}
}
}
}else{
if (isAdmin){
annotationList.add(new Object[]{ef, m});
}else {
if (!m.getName().equals("getTransferName")){
annotationList.add(new Object[]{ef, m});
}
}
}
}
}
// Field sorting
Collections.sort(annotationList, new Comparator<Object[]>() {
public int compare(Object[] o1, Object[] o2) {
return new Integer(((ExcelField)o1[0]).sort()).compareTo(
new Integer(((ExcelField)o2[0]).sort()));
};
});
// Initialize
List<String> headerList = Lists.newArrayList();
for (Object[] os : annotationList){
String t = ((ExcelField)os[0]).title();
// 如果是导出,则去掉注释
if (type==1){
String[] ss = StringUtils.split(t, "**", 2);
if (ss.length==2){
t = ss[0];
}
}
headerList.add(t);
}
initialize(title, headerList);
}
/** /**
* 构造函数 * 构造函数
* @param title 表格标题,传“空值”,表示无标题 * @param title 表格标题,传“空值”,表示无标题
...@@ -172,7 +266,7 @@ public class ExportExcel { ...@@ -172,7 +266,7 @@ public class ExportExcel {
public ExportExcel(String title, String[] headers) { public ExportExcel(String title, String[] headers) {
initialize(title, Lists.newArrayList(headers)); initialize(title, Lists.newArrayList(headers));
} }
/** /**
* 构造函数 * 构造函数
* @param title 表格标题,传“空值”,表示无标题 * @param title 表格标题,传“空值”,表示无标题
...@@ -181,7 +275,7 @@ public class ExportExcel { ...@@ -181,7 +275,7 @@ public class ExportExcel {
public ExportExcel(String title, List<String> headerList) { public ExportExcel(String title, List<String> headerList) {
initialize(title, headerList); initialize(title, headerList);
} }
/** /**
* 初始化函数 * 初始化函数
* @param title 表格标题,传“空值”,表示无标题 * @param title 表格标题,传“空值”,表示无标题
......
...@@ -120,7 +120,7 @@ public interface ReportDao extends CrudDao<ReportEntity> { ...@@ -120,7 +120,7 @@ public interface ReportDao extends CrudDao<ReportEntity> {
* 查询管理员ID * 查询管理员ID
* @return * @return
*/ */
public String findAdmin(Office office); public List<String> findAdmin(Office office);
/** /**
* 举报状态数据 * 举报状态数据
......
...@@ -309,6 +309,7 @@ public class ReportEntity extends DataEntity<ReportEntity> { ...@@ -309,6 +309,7 @@ public class ReportEntity extends DataEntity<ReportEntity> {
this.types = types; this.types = types;
} }
@ExcelField(title="移交给", align=2, sort=42)
public String getTransferName() { public String getTransferName() {
return transferName; return transferName;
} }
......
...@@ -6,6 +6,7 @@ import com.ejweb.core.service.CrudService; ...@@ -6,6 +6,7 @@ import com.ejweb.core.service.CrudService;
import com.ejweb.core.utils.IdGen; import com.ejweb.core.utils.IdGen;
import com.ejweb.core.utils.SpringContextHolder; import com.ejweb.core.utils.SpringContextHolder;
import com.ejweb.core.utils.StringUtils; import com.ejweb.core.utils.StringUtils;
import com.ejweb.core.utils.excel.annotation.ExcelField;
import com.ejweb.modules.report.dao.ReportDao; import com.ejweb.modules.report.dao.ReportDao;
import com.ejweb.modules.report.entity.ReportAttachmentEntity; import com.ejweb.modules.report.entity.ReportAttachmentEntity;
import com.ejweb.modules.report.entity.ReportEntity; import com.ejweb.modules.report.entity.ReportEntity;
...@@ -17,12 +18,18 @@ import com.ejweb.modules.sys.entity.Role; ...@@ -17,12 +18,18 @@ import com.ejweb.modules.sys.entity.Role;
import com.ejweb.modules.sys.entity.User; import com.ejweb.modules.sys.entity.User;
import com.ejweb.modules.sys.utils.UserUtils; import com.ejweb.modules.sys.utils.UserUtils;
import com.ejweb.modules.workbench.entity.ReportNotice; import com.ejweb.modules.workbench.entity.ReportNotice;
import org.apache.ibatis.javassist.bytecode.AnnotationsAttribute;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.io.File; import java.io.File;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
...@@ -80,7 +87,9 @@ public class ReportService extends CrudService<ReportDao, ReportEntity> { ...@@ -80,7 +87,9 @@ public class ReportService extends CrudService<ReportDao, ReportEntity> {
reportEntity.setReportTime(reportTime); reportEntity.setReportTime(reportTime);
reportEntity.setReportStatus("0"); reportEntity.setReportStatus("0");
reportEntity.setExchangeBeforeUser(reportEntity.getCreateBy().getId()); reportEntity.setExchangeBeforeUser(reportEntity.getCreateBy().getId());
reportEntity.setExchangeAfterUser(reportEntity.getCreateBy().getId()); if (!this.checkRole(user)) {
reportEntity.setExchangeAfterUser(reportEntity.getCreateBy().getId());
}
dao.addReport(reportEntity); dao.addReport(reportEntity);
if (StringUtils.isNotBlank(reportEntity.getReportAttachment())) { if (StringUtils.isNotBlank(reportEntity.getReportAttachment())) {
...@@ -116,14 +125,13 @@ public class ReportService extends CrudService<ReportDao, ReportEntity> { ...@@ -116,14 +125,13 @@ public class ReportService extends CrudService<ReportDao, ReportEntity> {
* @param reportEntity * @param reportEntity
*/ */
@Transactional(readOnly = false) @Transactional(readOnly = false)
public void saveTrack(ReportEntity reportEntity) { public void saveTrack(ReportEntity reportEntity,String transferUser) {
//保存举报补充信息 //保存举报补充信息
reportEntity.preUpdate(); reportEntity.preUpdate();
User user = UserUtils.getUser(); User user = UserUtils.getUser();
if (StringUtils.isNotBlank(reportEntity.getExchangeAfterUser())){ if (StringUtils.isNotBlank(transferUser)){
reportEntity.setExchangeType("1"); reportEntity.setExchangeType("1");
}else { reportEntity.setExchangeAfterUser(transferUser);
reportEntity.setExchangeAfterUser(user.getId());
} }
dao.addTrack(reportEntity); dao.addTrack(reportEntity);
...@@ -240,7 +248,7 @@ public class ReportService extends CrudService<ReportDao, ReportEntity> { ...@@ -240,7 +248,7 @@ public class ReportService extends CrudService<ReportDao, ReportEntity> {
* @return * @return
*/ */
@Transactional(readOnly = false) @Transactional(readOnly = false)
public int addNotice(ReportEntity reportEntity,String flag){ public int addNotice(ReportEntity reportEntity,String flag,String ifDone){
User user = UserUtils.getUser(); User user = UserUtils.getUser();
Date date = new Date(); Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
...@@ -259,10 +267,16 @@ public class ReportService extends CrudService<ReportDao, ReportEntity> { ...@@ -259,10 +267,16 @@ public class ReportService extends CrudService<ReportDao, ReportEntity> {
reportNotice.setSendToId(reportEntity.getExchangeAfterUser()); reportNotice.setSendToId(reportEntity.getExchangeAfterUser());
reportNotice.setStatus("0"); reportNotice.setStatus("0");
if (flag.equals("answer")){ if (flag.equals("answer")){
reportNotice.setSendToId(reportDao.findAdmin(new Office())); //当前只有杨杨是系统管理员,处理后消息发给杨杨,以后如果新增了系统管理员需修改
//findAdmin()方法获取所有系统管理员
reportNotice.setSendToId("8434980248282724540228");
reportNotice.setTitle("“"+reportEntity.getSupplementTitle()+"”已由"+user.getName()+"于"+dateStr+"处理完成"); reportNotice.setTitle("“"+reportEntity.getSupplementTitle()+"”已由"+user.getName()+"于"+dateStr+"处理完成");
}if (flag.equals("meanWhile")){ }if (flag.equals("meanWhile")){
reportNotice.setTitle("“"+reportEntity.getSupplementTitle()+"”已由"+user.getName()+"于"+dateStr+"处理完成"); reportNotice.setTitle("“"+reportEntity.getSupplementTitle()+"”已由"+user.getName()+"于"+dateStr+"处理完成");
//没点完成,title为请处理
if (reportEntity.getDealResult().equals("3") && StringUtils.isBlank(ifDone)){
reportNotice.setTitle("请处理-“"+reportEntity.getSupplementTitle()+"”");
}
} }
reportDao.updateReportNotice(reportNotice); reportDao.updateReportNotice(reportNotice);
return 1; return 1;
...@@ -284,6 +298,10 @@ public class ReportService extends CrudService<ReportDao, ReportEntity> { ...@@ -284,6 +298,10 @@ public class ReportService extends CrudService<ReportDao, ReportEntity> {
}else if (flag.equals("meanWhile")){ }else if (flag.equals("meanWhile")){
reportNotice.setSendToId(reportEntity.getExchangeAfterUser()); reportNotice.setSendToId(reportEntity.getExchangeAfterUser());
reportNotice.setTitle("“"+reportEntity.getSupplementTitle()+"”已由"+user.getName()+"于"+dateStr+"处理完成"); reportNotice.setTitle("“"+reportEntity.getSupplementTitle()+"”已由"+user.getName()+"于"+dateStr+"处理完成");
//没点完成,title为请处理
if (reportEntity.getDealResult().equals("3") && StringUtils.isBlank(ifDone)){
reportNotice.setTitle("请处理-“"+reportEntity.getSupplementTitle()+"”");
}
}else{ }else{
//管理员转交或移交,消息标题为“请处理xxx” //管理员转交或移交,消息标题为“请处理xxx”
String title = reportEntity.getSupplementTitle(); String title = reportEntity.getSupplementTitle();
...@@ -412,6 +430,16 @@ public class ReportService extends CrudService<ReportDao, ReportEntity> { ...@@ -412,6 +430,16 @@ public class ReportService extends CrudService<ReportDao, ReportEntity> {
report.setSupplementArea(supplementArea); report.setSupplementArea(supplementArea);
report.setSupplementInformant(report.getSupplementInformant() == null?"--":report.getSupplementInformant()); report.setSupplementInformant(report.getSupplementInformant() == null?"--":report.getSupplementInformant());
report.setDealPersonName(report.getDealPersonName() == null?"--":report.getDealPersonName()); report.setDealPersonName(report.getDealPersonName() == null?"--":report.getDealPersonName());
User user = UserUtils.getUser();
if (this.checkRole(user)){
if (StringUtils.isBlank(report.getTransferName()) || StringUtils.isBlank(report.getExchangeType())){
report.setTransferName("--");
}else if (StringUtils.isNotBlank(report.getTransferName()) && StringUtils.isNotBlank(report.getExchangeType())){
report.setTransferName(report.getTransferName());
}
}else{
report.setTransferName("");
}
} }
return reportList; return reportList;
} }
...@@ -443,7 +471,7 @@ public class ReportService extends CrudService<ReportDao, ReportEntity> { ...@@ -443,7 +471,7 @@ public class ReportService extends CrudService<ReportDao, ReportEntity> {
reportEntity.setUpdateBy(user); reportEntity.setUpdateBy(user);
reportEntity.setUpdateDate(new Date()); reportEntity.setUpdateDate(new Date());
reportDao.updateExchangeUser(reportEntity); reportDao.updateExchangeUser(reportEntity);
this.addNotice(reportEntity,"deliver"); this.addNotice(reportEntity,"deliver",null);
this.addRecord(reportEntity,"2"); this.addRecord(reportEntity,"2");
} }
} }
......
...@@ -268,6 +268,7 @@ public class ReportController extends BaseController { ...@@ -268,6 +268,7 @@ public class ReportController extends BaseController {
@RequestMapping(value = "addTrack") @RequestMapping(value = "addTrack")
public String addTrack(ReportEntity reportEntity,HttpServletRequest request, Model model, RedirectAttributes redirectAttributes) { public String addTrack(ReportEntity reportEntity,HttpServletRequest request, Model model, RedirectAttributes redirectAttributes) {
String ifDone = request.getParameter("ifDone"); // 是否完成 String ifDone = request.getParameter("ifDone"); // 是否完成
String transferUser = request.getParameter("exchangeAfterUser"); //选择移交人员
if (!beanValidator(model, reportEntity)) { if (!beanValidator(model, reportEntity)) {
return form(reportEntity, model); return form(reportEntity, model);
} }
...@@ -286,18 +287,20 @@ public class ReportController extends BaseController { ...@@ -286,18 +287,20 @@ public class ReportController extends BaseController {
String exchangeAfterUser = reportService.findExchangeUser(reportEntity.getId()); String exchangeAfterUser = reportService.findExchangeUser(reportEntity.getId());
reportEntity.setExchangeAfterUser(exchangeAfterUser); reportEntity.setExchangeAfterUser(exchangeAfterUser);
} }
reportService.saveTrack(reportEntity); reportService.saveTrack(reportEntity,transferUser);
String exchangeAfterUser = request.getParameter("exchangeAfterUser");
if (StringUtils.isNotBlank(exchangeAfterUser) && StringUtils.isBlank(reportEntity.getDealResult())){ if (StringUtils.isNotBlank(transferUser) && StringUtils.isBlank(reportEntity.getDealResult())){
//管理员移交给他人处理 //管理员移交给他人处理
reportService.addNotice(reportEntity,"transfer"); reportService.addNotice(reportEntity,"transfer",ifDone);
reportService.addRecord(reportEntity,"1"); reportService.addRecord(reportEntity,"1");
}else if (StringUtils.isNotBlank(reportEntity.getDealResult()) && StringUtils.isBlank(exchangeAfterUser)){ }else if (StringUtils.isNotBlank(reportEntity.getDealResult()) && StringUtils.isBlank(transferUser)){
//自行处理 //自行处理
reportService.addNotice(reportEntity,"answer"); if (!(reportEntity.getDealResult().equals("3") && StringUtils.isBlank(ifDone))) {
}else if (StringUtils.isNotBlank(exchangeAfterUser) && StringUtils.isNotBlank(reportEntity.getDealResult())){ reportService.addNotice(reportEntity, "answer", ifDone);
}
}else if (StringUtils.isNotBlank(transferUser) && StringUtils.isNotBlank(reportEntity.getDealResult())){
//管理员进行处理,同时移交给他人 //管理员进行处理,同时移交给他人
reportService.addNotice(reportEntity,"meanWhile"); reportService.addNotice(reportEntity,"meanWhile",ifDone);
} }
addMessage(redirectAttributes, "补充举报"+ reportEntity.getSupplementTitle() + "'成功"); addMessage(redirectAttributes, "补充举报"+ reportEntity.getSupplementTitle() + "'成功");
return "redirect:" + adminPath + "/report/list/?repage&flag=0"; return "redirect:" + adminPath + "/report/list/?repage&flag=0";
...@@ -388,7 +391,8 @@ public class ReportController extends BaseController { ...@@ -388,7 +391,8 @@ public class ReportController extends BaseController {
public String export(ReportEntity reportEntity,String flag, HttpServletRequest request,HttpServletResponse response, RedirectAttributes redirectAttributes) { public String export(ReportEntity reportEntity,String flag, HttpServletRequest request,HttpServletResponse response, RedirectAttributes redirectAttributes) {
//判断登录人的角色 //判断登录人的角色
User user = UserUtils.getUser(); User user = UserUtils.getUser();
if (!reportService.checkRole(user)){ boolean isAdmin = reportService.checkRole(user);
if (!isAdmin){
reportEntity.setExchangeAfterUser(user.getId()); reportEntity.setExchangeAfterUser(user.getId());
} }
//判断标签状态 flag为空,跳转到核查中举报列表 flag为0,跳转到未处理举报列表 flag为1,跳转到举报列表 //判断标签状态 flag为空,跳转到核查中举报列表 flag为0,跳转到未处理举报列表 flag为1,跳转到举报列表
...@@ -406,7 +410,7 @@ public class ReportController extends BaseController { ...@@ -406,7 +410,7 @@ public class ReportController extends BaseController {
try { try {
String fileName = "举报列表" + DateUtils.getDate("yyyyMMddHHmmss") + ".xlsx"; String fileName = "举报列表" + DateUtils.getDate("yyyyMMddHHmmss") + ".xlsx";
List<ReportEntity> reportList = reportService.getReportList(reportEntity); List<ReportEntity> reportList = reportService.getReportList(reportEntity);
new ExportExcel("举报列表", ReportEntity.class).setDataList(reportList).write(request,response, fileName).dispose(); new ExportExcel("举报列表", ReportEntity.class, isAdmin).setDataList(reportList).write(request,response, fileName).dispose();
return null; return null;
} catch (Exception e) { } catch (Exception e) {
addMessage(redirectAttributes, "导出用户失败!失败信息:" + e.getMessage()); addMessage(redirectAttributes, "导出用户失败!失败信息:" + e.getMessage());
......
...@@ -132,7 +132,7 @@ public class ReportToWordController { ...@@ -132,7 +132,7 @@ public class ReportToWordController {
} }
} }
if (list.size() > 1) { if (list.size() > 1) {
mergeCellsVertically(basicInfoTable, 0, 5, 5 + list.size() - 1); mergeCellsVertically(basicInfoTable, 0, 6, 6 + list.size() - 1);
} }
this.setCellWidth(basicInfoTable); this.setCellWidth(basicInfoTable);
...@@ -318,11 +318,11 @@ public class ReportToWordController { ...@@ -318,11 +318,11 @@ public class ReportToWordController {
for (int i = 0; i < list1.size(); i++) { for (int i = 0; i < list1.size(); i++) {
XWPFTableRow reportAttachment = supplementInfoTable.createRow(); XWPFTableRow reportAttachment = supplementInfoTable.createRow();
reportAttachment.getCell(0).setText("附件:"); reportAttachment.getCell(0).setText("附件:");
reportAttachment.getCell(1).setText(list1.get(i).getAttachmentPath()); reportAttachment.createCell().setText(list1.get(i).getAttachmentPath());
} }
} }
if (list1.size() > 1) { if (list1.size() > 1) {
mergeCellsVertically(supplementInfoTable, 0, 6, 6 + list1.size() - 1); mergeCellsVertically(supplementInfoTable, 0, 4, 4 + list1.size() - 1);
} }
this.setCellWidth(supplementInfoTable); this.setCellWidth(supplementInfoTable);
supplementInfoTable.setCellMargins(0, 100, 0, 100); supplementInfoTable.setCellMargins(0, 100, 0, 100);
......
...@@ -383,8 +383,7 @@ ...@@ -383,8 +383,7 @@
LEFT JOIN ct_bbtc_sys_role sr ON sr.id = sur.role_id LEFT JOIN ct_bbtc_sys_role sr ON sr.id = sur.role_id
WHERE WHERE
sr.name = '系统管理员' sr.name = '系统管理员'
<if test="dbName == 'oracle'"> AND rownum &lt;= 1</if> AND SU.DEL_FLAG = '0'
<if test="dbName == 'mysql'"> limit 1</if>
</select> </select>
<insert id="addRecord"> <insert id="addRecord">
......
...@@ -184,7 +184,10 @@ ...@@ -184,7 +184,10 @@
<td><c:if test="${report.dealPersonName eq null}">--</c:if> <td><c:if test="${report.dealPersonName eq null}">--</c:if>
<c:if test="${report.dealPersonName ne null}">${report.dealPersonName}</c:if> <c:if test="${report.dealPersonName ne null}">${report.dealPersonName}</c:if>
</td> </td>
<td>${report.transferName}</td> <td>
<c:if test="${report.transferName eq null || report.exchangeType eq null}">--</c:if>
<c:if test="${report.transferName ne null && report.exchangeType ne null}">${report.transferName}</c:if>
</td>
<td> <td>
<a href="${ctx}/report/view?id=${report.id}">查看</a> <a href="${ctx}/report/view?id=${report.id}">查看</a>
</td> </td>
......
...@@ -193,8 +193,8 @@ ...@@ -193,8 +193,8 @@
</td> </td>
<c:if test="${isAdmin eq true}"> <c:if test="${isAdmin eq true}">
<td> <td>
<c:if test="${report.transferName eq null}">--</c:if> <c:if test="${report.transferName eq null || report.exchangeType eq null}">--</c:if>
<c:if test="${report.transferName ne null}">${report.transferName}</c:if> <c:if test="${report.transferName ne null && report.exchangeType ne null}">${report.transferName}</c:if>
</td> </td>
</c:if> </c:if>
<td> <td>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment