Commit bd9261f5 by java-lixy

导出、转为文档、发消息

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