2018-03-13 10:14:23 +08:00
|
|
|
|
package com.nis.web.controller.basics;
|
|
|
|
|
|
|
2018-12-17 00:21:27 +08:00
|
|
|
|
import java.lang.reflect.Field;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
import java.util.HashMap;
|
2018-03-13 10:14:23 +08:00
|
|
|
|
import java.util.List;
|
2018-12-17 00:21:27 +08:00
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
import java.util.Properties;
|
2018-03-13 10:14:23 +08:00
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
|
|
import org.springframework.ui.Model;
|
2018-12-24 19:16:17 +08:00
|
|
|
|
import org.springframework.util.StringUtils;
|
2018-12-17 00:21:27 +08:00
|
|
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
2018-03-13 10:14:23 +08:00
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
|
|
|
|
|
|
|
|
|
|
|
import com.nis.domain.Page;
|
2018-12-24 19:16:17 +08:00
|
|
|
|
import com.nis.domain.configuration.RequestInfo;
|
2018-03-13 10:14:23 +08:00
|
|
|
|
import com.nis.domain.configuration.TaskInfo;
|
2018-12-17 00:21:27 +08:00
|
|
|
|
import com.nis.util.Constants;
|
2018-12-24 19:16:17 +08:00
|
|
|
|
import com.nis.util.DateUtils;
|
2019-04-25 14:42:41 +08:00
|
|
|
|
import com.nis.util.LogUtils;
|
2018-12-17 00:21:27 +08:00
|
|
|
|
import com.nis.util.StringUtil;
|
|
|
|
|
|
import com.nis.util.excel.ExcelField;
|
2018-03-13 10:14:23 +08:00
|
|
|
|
import com.nis.web.controller.BaseController;
|
|
|
|
|
|
import com.nis.web.service.basics.TaskInfoService;
|
|
|
|
|
|
|
2018-12-17 00:21:27 +08:00
|
|
|
|
import jersey.repackaged.com.google.common.collect.Lists;
|
|
|
|
|
|
|
2018-03-13 10:14:23 +08:00
|
|
|
|
@Controller
|
|
|
|
|
|
@RequestMapping("${adminPath}/basics/taskInfo")
|
|
|
|
|
|
public class TaskInfoController extends BaseController{
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private TaskInfoService taskInfoService;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
*来函列表
|
|
|
|
|
|
*/
|
|
|
|
|
|
@RequestMapping(value = {"list",""})
|
|
|
|
|
|
public String list(TaskInfo taskInfo, HttpServletRequest request, HttpServletResponse response, Model model) {
|
2018-07-16 14:21:21 +08:00
|
|
|
|
Page<TaskInfo> page = taskInfoService.findTaskInfo(new Page<TaskInfo>(request, response,"r"), taskInfo);
|
2018-03-13 10:14:23 +08:00
|
|
|
|
model.addAttribute("page", page);
|
|
|
|
|
|
return "/basics/taskInfoList";
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 进入用户添加或修改页面
|
|
|
|
|
|
*/
|
|
|
|
|
|
@RequestMapping(value={"form"})
|
|
|
|
|
|
public String form(TaskInfo taskInfo, Model model) {
|
|
|
|
|
|
if(taskInfo.getId()!=null){
|
2018-12-17 00:21:27 +08:00
|
|
|
|
Integer functionId=taskInfo.getFunctionId();
|
2018-03-13 10:14:23 +08:00
|
|
|
|
taskInfo = taskInfoService.getTaskInfoById(taskInfo.getId());
|
2018-12-17 00:21:27 +08:00
|
|
|
|
taskInfo.setFunctionId(functionId);
|
2018-03-13 10:14:23 +08:00
|
|
|
|
model.addAttribute("taskInfo", taskInfo);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
model.addAttribute("taskInfo", taskInfo);
|
|
|
|
|
|
}
|
|
|
|
|
|
return "/basics/taskInfoForm";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 新增/修改
|
|
|
|
|
|
*/
|
|
|
|
|
|
@RequestMapping(value = "saveOrUpdate")
|
|
|
|
|
|
public String saveOrUpdate(TaskInfo taskInfo, HttpServletRequest request, Model model, RedirectAttributes redirectAttributes) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
if(taskInfo.getId()!=null){
|
|
|
|
|
|
// 保存用户信息
|
|
|
|
|
|
logger.info(taskInfo.getId()+"修改成功");
|
|
|
|
|
|
taskInfoService.saveOrUpdate(taskInfo);
|
2018-12-13 14:01:06 +08:00
|
|
|
|
addMessage(redirectAttributes,"success", "save_success");
|
2018-03-13 10:14:23 +08:00
|
|
|
|
}else{
|
|
|
|
|
|
if (!"true".equals(checkTaskName(taskInfo.getTaskName()))){
|
|
|
|
|
|
logger.info(taskInfo.getTaskName()+"重复数据");
|
2018-12-28 13:58:43 +06:00
|
|
|
|
Properties props=this.getMsgProp();
|
|
|
|
|
|
addMessage("error",model,props.getProperty("duplicate", "Duplicate")+" "+props.getProperty("task_name", "Task Name"));
|
2018-03-13 10:14:23 +08:00
|
|
|
|
return form(taskInfo, model);
|
|
|
|
|
|
}
|
|
|
|
|
|
// 保存用户信息
|
|
|
|
|
|
taskInfoService.saveOrUpdate(taskInfo);
|
2018-12-13 14:01:06 +08:00
|
|
|
|
addMessage(redirectAttributes,"success", "save_success");
|
2018-03-13 10:14:23 +08:00
|
|
|
|
logger.info(taskInfo.getId()+"保存成功");
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
logger.error(e.getMessage());
|
|
|
|
|
|
e.printStackTrace();
|
2018-12-13 14:01:06 +08:00
|
|
|
|
addMessage(redirectAttributes,"error", "save_failed");
|
2019-04-25 14:42:41 +08:00
|
|
|
|
LogUtils.saveLog(request, null, e, null);
|
2018-03-13 10:14:23 +08:00
|
|
|
|
}
|
2018-12-17 00:21:27 +08:00
|
|
|
|
return "redirect:" + adminPath + "/basics/taskInfo/list?functionId="+taskInfo.getFunctionId()+"&repage";
|
2018-03-13 10:14:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 验证是否有效
|
|
|
|
|
|
*/
|
|
|
|
|
|
@ResponseBody
|
|
|
|
|
|
@RequestMapping(value = "checkTaskName")
|
|
|
|
|
|
public String checkTaskName(String taskName) {
|
|
|
|
|
|
if (taskName !=null && taskInfoService.getTaskInfoByTaskName(taskName) == null) {
|
|
|
|
|
|
return "true";
|
|
|
|
|
|
}
|
|
|
|
|
|
return "false";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 审核通过
|
|
|
|
|
|
* @param taskInfo
|
|
|
|
|
|
* @param model
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
@RequestMapping(value = "taskExamine")
|
2018-12-17 00:21:27 +08:00
|
|
|
|
public String taskExamine(Integer functionId,String ids, Model model,RedirectAttributes redirectAttributes){
|
2018-03-13 10:14:23 +08:00
|
|
|
|
String[] exId = ids.split(",");
|
|
|
|
|
|
taskInfoService.taskExamine(exId);
|
2018-12-17 00:21:27 +08:00
|
|
|
|
addMessage(redirectAttributes,"success", "audit_success");
|
|
|
|
|
|
return "redirect:" + adminPath + "/basics/taskInfo/list?functionId="+functionId+"&repage";
|
2018-03-13 10:14:23 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 审核未通过
|
|
|
|
|
|
* @param taskInfo
|
|
|
|
|
|
* @param model
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
@RequestMapping(value = "taskExamineNo")
|
2018-12-17 00:21:27 +08:00
|
|
|
|
public String taskExamineNo(Integer functionId,String ids, Model model,RedirectAttributes redirectAttributes){
|
2018-03-13 10:14:23 +08:00
|
|
|
|
String[] noId = ids.split(",");
|
|
|
|
|
|
taskInfoService.taskExamineNo(noId);
|
2018-12-17 00:21:27 +08:00
|
|
|
|
addMessage(redirectAttributes,"success", "audit_success");
|
|
|
|
|
|
return "redirect:" + adminPath + "/basics/taskInfo/list?functionId="+functionId+"&repage";
|
2018-03-13 10:14:23 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 取消审核
|
|
|
|
|
|
* @param taskInfo
|
|
|
|
|
|
* @param model
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
@RequestMapping(value = "taskCancelExamine")
|
2018-12-17 00:21:27 +08:00
|
|
|
|
public String taskCancelExamine(Integer functionId,String ids, Model model,RedirectAttributes redirectAttributes){
|
2018-03-13 10:14:23 +08:00
|
|
|
|
String[] canclelId = ids.split(",");
|
|
|
|
|
|
taskInfoService.taskCancelExamine(canclelId);
|
2018-12-17 00:21:27 +08:00
|
|
|
|
addMessage(redirectAttributes,"success", "audit_success");
|
|
|
|
|
|
return "redirect:" + adminPath + "/basics/taskInfo/list?functionId="+functionId+"&repage";
|
2018-03-13 10:14:23 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 删除
|
|
|
|
|
|
* @param taskInfo
|
|
|
|
|
|
* @param model
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
@RequestMapping(value = "delete")
|
2018-12-17 00:21:27 +08:00
|
|
|
|
public String delete(Integer functionId,String ids, Model model,RedirectAttributes redirectAttributes){
|
2018-03-13 10:14:23 +08:00
|
|
|
|
String[] delId = ids.split(",");
|
|
|
|
|
|
taskInfoService.delete(delId);
|
2018-12-13 14:01:06 +08:00
|
|
|
|
addMessage(redirectAttributes,"success", "delete_success");
|
2018-12-17 00:21:27 +08:00
|
|
|
|
return "redirect:" + adminPath + "/basics/taskInfo/list?functionId="+functionId+"&repage";
|
2018-03-13 10:14:23 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
2018-12-17 00:21:27 +08:00
|
|
|
|
//配置导出
|
|
|
|
|
|
@RequestMapping(value = "exportTaskInfo")
|
2018-12-24 19:16:17 +08:00
|
|
|
|
public void exportTaskInfo(Model model,HttpServletRequest request,HttpServletResponse response,String hcolumn,String exType,
|
2018-12-17 00:21:27 +08:00
|
|
|
|
@ModelAttribute("cfg")TaskInfo entity,String ids,RedirectAttributes redirectAttributes){
|
|
|
|
|
|
try {
|
|
|
|
|
|
//export data info
|
|
|
|
|
|
List<String> titleList=new ArrayList<String>();
|
|
|
|
|
|
Map<String, Class<?>> classMap=new HashMap<String, Class<?>>();
|
|
|
|
|
|
Map<String, List> dataMap=new HashMap<String, List>();
|
|
|
|
|
|
Map<String, String> noExportMap=new HashMap<String, String>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//导出选中记录
|
|
|
|
|
|
List<TaskInfo> list=Lists.newArrayList();
|
|
|
|
|
|
titleList.add(entity.getMenuNameCode());
|
|
|
|
|
|
classMap.put(entity.getMenuNameCode(), TaskInfo.class);
|
|
|
|
|
|
Field[] fields=TaskInfo.class.getDeclaredFields();
|
|
|
|
|
|
StringBuffer column=new StringBuffer();
|
|
|
|
|
|
Properties props= this.getMsgProp();
|
|
|
|
|
|
for(Field f: fields) {
|
|
|
|
|
|
ExcelField ex=f.getAnnotation(ExcelField.class);
|
|
|
|
|
|
if(ex!=null) {
|
|
|
|
|
|
String title=ex.title();
|
|
|
|
|
|
if(entity.getColumns().indexOf(props.getProperty(title, title))==-1) {
|
|
|
|
|
|
column.append(","+title);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if(column.toString().length()>0) {
|
|
|
|
|
|
column.append(",");
|
|
|
|
|
|
}
|
2018-12-24 19:16:17 +08:00
|
|
|
|
|
|
|
|
|
|
if(entity.getBeginDate()==null ){
|
|
|
|
|
|
hcolumn+=",task_time,";
|
|
|
|
|
|
}
|
|
|
|
|
|
if(entity.getDobeginDate()==null){
|
|
|
|
|
|
hcolumn+=",edit_time,";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(!StringUtils.isEmpty(hcolumn)){
|
|
|
|
|
|
column.append(","+hcolumn+",");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-12-17 00:21:27 +08:00
|
|
|
|
noExportMap.put(entity.getMenuNameCode(),column.toString());
|
|
|
|
|
|
if(!StringUtil.isEmpty(ids)){
|
|
|
|
|
|
for(String id:ids.split(",")){
|
|
|
|
|
|
Long.parseLong(id);
|
|
|
|
|
|
}
|
|
|
|
|
|
list=taskInfoService.getTaskInfoByIds(ids);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
//条件导出数据大于最大导出数,只导出最大导出条数
|
|
|
|
|
|
Page<TaskInfo> pageInfo=new Page<TaskInfo>(request, response,"a");
|
|
|
|
|
|
pageInfo.setPageNo(1);
|
|
|
|
|
|
pageInfo.setPageSize(Constants.MAX_EXPORT_SIZE);
|
|
|
|
|
|
Page<TaskInfo> page = taskInfoService.findTaskInfo(pageInfo, entity);
|
|
|
|
|
|
list=page.getList();
|
|
|
|
|
|
}
|
|
|
|
|
|
dataMap.put(entity.getMenuNameCode(),list);
|
2018-12-24 19:16:17 +08:00
|
|
|
|
//获取国际化配置
|
|
|
|
|
|
String timeRange = initTaskMap(entity);
|
|
|
|
|
|
noExportMap.put("timeRange", timeRange);
|
|
|
|
|
|
if ("csv".equals(exType)) {
|
|
|
|
|
|
this._exportCsv(model, request, response, redirectAttributes, entity.getMenuNameCode(), titleList,
|
|
|
|
|
|
classMap, dataMap, noExportMap);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this._export(model, request, response, redirectAttributes, entity.getMenuNameCode(), titleList,
|
|
|
|
|
|
classMap, dataMap, noExportMap);
|
|
|
|
|
|
}
|
2018-12-17 00:21:27 +08:00
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
logger.error("ip addr export failed",e);
|
|
|
|
|
|
addMessage(redirectAttributes,"error", "export_failed");
|
2019-04-25 14:42:41 +08:00
|
|
|
|
LogUtils.saveLog(request, null, e, null);
|
2018-12-17 00:21:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
//return "redirect:" + adminPath +"/ntc/iplist/list?functionId="+entity.getFunctionId();
|
|
|
|
|
|
}
|
2018-12-24 19:16:17 +08:00
|
|
|
|
public String initTaskMap(TaskInfo info){
|
|
|
|
|
|
Properties msgProp = getMsgProp();
|
|
|
|
|
|
String logTime=msgProp.getProperty(info.getMenuNameCode(),info.getMenuNameCode());
|
|
|
|
|
|
if(info.getBeginDate()!=null){
|
|
|
|
|
|
logTime+=" "+msgProp.getProperty("task_time","task_time")+":"+DateUtils.formatDateTime(info.getBeginDate());
|
|
|
|
|
|
if(info.getEndDate()!=null){
|
|
|
|
|
|
logTime+="—"+DateUtils.formatDateTime(info.getEndDate());
|
|
|
|
|
|
}else{
|
|
|
|
|
|
logTime+="—"+DateUtils.getDateTime();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if(info.getDobeginDate()!=null){
|
|
|
|
|
|
logTime+=" "+msgProp.getProperty("edit_time","edit_time")+":"+DateUtils.formatDateTime(info.getDobeginDate());
|
|
|
|
|
|
if(info.getDoendDate()!=null){
|
|
|
|
|
|
logTime+="—"+DateUtils.formatDateTime(info.getDoendDate());
|
|
|
|
|
|
}else{
|
|
|
|
|
|
logTime+="—"+DateUtils.getDateTime();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return logTime;
|
|
|
|
|
|
}
|
2018-03-13 10:14:23 +08:00
|
|
|
|
|
|
|
|
|
|
}
|