package com.zcloud.controller.comprehensive; import com.zcloud.controller.base.BaseController; import com.zcloud.entity.Page; import com.zcloud.entity.PageData; import com.zcloud.service.comprehensive.TrafficSecurityNoticeService; import com.zcloud.service.comprehensive.TrafficSecurityReadDetailService; import com.zcloud.service.system.UsersService; import com.zcloud.util.*; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.multipart.MultipartFile; import java.util.*; @Controller @RequestMapping("/securitynotice") public class TrafficSecurityNoticeController extends BaseController { @Autowired private TrafficSecurityNoticeService securityNoticeService; @Autowired private TrafficSecurityReadDetailService securityReadDetail; @Autowired private Smb smb; @Autowired private UsersService usersService; //新增 @RequestMapping(value = "/add") @ResponseBody public Object add(@RequestParam(value="FFILE",required=false) MultipartFile file) throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = this.getPageData(); String notificationId = this.get32UUID(); pd.put("CREATOR", Jurisdiction.getUSER_ID()); // 创建人id pd.put("CREATORNAME", Jurisdiction.getName()); // 创建人姓名 pd.put("NOTIFICATION_ID", notificationId); // 主键 pd.put("CREATETIME", DateUtil.date2Str(new Date())); // 添加时间 pd.put("POSTSTATUS", "1"); // 发布状态 pd.put("REPLYSTATUS", "0"); // 回复状态 pd.put("SIGNEDSTATUS", "0"); // 签收状态 pd.put("ISDELETE", "0"); String ffile = DateUtil.getDays(); if (file != null && StringUtils.isNotBlank(pd.getString("CREATORNAME"))){ String suffixName = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1).toLowerCase(); if (!"pdf".equals(suffixName) && !"jpg".equals(suffixName) && !"jpeg".equals(suffixName) && !"png".equals(suffixName) && !"mp4".equals(suffixName)) { errInfo = "fail"; map.put("result", errInfo); map.put("msg", "文件格式不正确!"); return map; } String fileName = this.get32UUID() + file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")); smb.sshSftp(file, fileName, Const.FILEPATHFILE + pd.getString("CORPINFO_ID") + "/" + ffile); pd.put("CONFIRM_MESSAGE_SIGN_ROUTE", Const.FILEPATHFILE + pd.getString("CORPINFO_ID") + "/" + ffile + "/" + fileName); pd.put("CONFIRM_MESSAGE",pd.getString("CREATORNAME")); pd.put("CONFIRM_MESSAGE_TIME",DateUtil.date2Str(new Date())); } List notifications = securityNoticeService.getAllNotifications(pd); Map statusCount = new HashMap<>(); statusCount.put("total", notifications.size()); statusCount.put("signed", (int) notifications.stream().filter(n -> "1".equals(n.getString("SIGNEDSTATUS"))).count()); statusCount.put("replied", (int) notifications.stream().filter(n -> "1".equals(n.getString("REPLYSTATUS"))).count()); pd.put("SIGNING", statusCount.get("signed") + "/" + statusCount.get("total") + "人"); // 签收情况 pd.put("REPLY", statusCount.get("replied") + "/" + statusCount.get("total") + "人"); // 回复情况 securityNoticeService.save(pd); String[] persons = pd.getString("PERSON").split(","); for (String person : persons) { pd.put("NOTIFICATION_ID", notificationId); pd.put("PERSON", person.trim()); securityReadDetail.save(pd); } map.put("result", errInfo); map.put("pd", pd); return map; } //阅读情况 @RequestMapping(value = "/getAllReadDetail") // @RequiresPermissions("hidden:list") @ResponseBody public Object getAllReadDetail(Page page) throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); String PRACTITIONER = pd.getString("PRACTITIONER"); // 关键词检索条件 if (Tools.notEmpty(PRACTITIONER)) pd.put("PRACTITIONER", PRACTITIONER.trim()); String PRACTITIONERTYPE = pd.getString("PRACTITIONERTYPE"); // 关键词检索条件 if (Tools.notEmpty(PRACTITIONERTYPE)) pd.put("PRACTITIONERTYPE", PRACTITIONERTYPE.trim()); String SIGNEDSTATUS = pd.getString("SIGNEDSTATUS"); // 关键词检索条件 if (Tools.notEmpty(SIGNEDSTATUS)) pd.put("SIGNEDSTATUS", SIGNEDSTATUS.trim()); String REPLYSTATUS = pd.getString("REPLYSTATUS"); // 关键词检索条件 if (Tools.notEmpty(REPLYSTATUS)) pd.put("REPLYSTATUS", REPLYSTATUS.trim()); page.setPd(pd); List notifications = securityReadDetail.getAllReadDetail(page); map.put("varList", notifications); map.put("page", page); map.put("result", errInfo); return map; } //列表 @RequestMapping(value = "/listForSecurityNotice") @ResponseBody public Object listForSecurityNotice(Page page) throws Exception { Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); String TITLE = pd.getString("TITLE"); // 关键词检索条件 if (Tools.notEmpty(TITLE)) pd.put("TITLE", TITLE.trim()); String REPLYSTATUS = pd.getString("REPLYSTATUS"); // 关键词检索条件 if (Tools.notEmpty(REPLYSTATUS)) pd.put("REPLYSTATUS", REPLYSTATUS.trim()); page.setPd(pd); List varList = securityNoticeService.listForSecurityNotice(page); // 列出Hidden列表 map.put("varList", varList); map.put("page", page); map.put("result", errInfo); return map; } //详情 @RequestMapping(value="/goEdit") // @RequiresPermissions("traininginfo:edit") @ResponseBody public Object goEdit() throws Exception{ Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); pd = securityNoticeService.findById(pd); //根据ID读取 map.put("pd", pd); map.put("result", errInfo); return map; } /**删除 * @param * @throws Exception */ @RequestMapping(value="/delete") // @RequiresPermissions("traininginfo:del") @ResponseBody public Object delete() throws Exception{ Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); pd.put("DELETOR", Jurisdiction.getUSER_ID()); //删除人id pd.put("DELETORNAME", Jurisdiction.getUsername()); //删除人姓名 pd.put("DELETETIME", DateUtil.date2Str(new Date())); //删除时间 securityNoticeService.delete(pd); map.put("result", errInfo); //返回结果 return map; } }