TSSysbugController.java 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  1. package cn.com.lzt.sysbug.controller;
  2. import java.io.IOException;
  3. import java.net.URI;
  4. import java.text.SimpleDateFormat;
  5. import java.util.ArrayList;
  6. import java.util.Collections;
  7. import java.util.List;
  8. import java.util.Map;
  9. import java.util.Set;
  10. import javax.servlet.http.HttpServletRequest;
  11. import javax.servlet.http.HttpServletResponse;
  12. import javax.servlet.http.HttpSession;
  13. import javax.validation.ConstraintViolation;
  14. import javax.validation.Validator;
  15. import org.apache.log4j.Logger;
  16. //import org.apache.tomcat.jni.Global;
  17. import org.jeecgframework.core.beanvalidator.BeanValidators;
  18. import org.jeecgframework.core.common.controller.BaseController;
  19. import org.jeecgframework.core.common.exception.BusinessException;
  20. import org.jeecgframework.core.common.hibernate.qbc.CriteriaQuery;
  21. import org.jeecgframework.core.common.model.json.AjaxJson;
  22. import org.jeecgframework.core.common.model.json.DataGrid;
  23. import org.jeecgframework.core.constant.Globals;
  24. import org.jeecgframework.core.util.ContextHolderUtils;
  25. import org.jeecgframework.core.util.ExceptionUtil;
  26. import org.jeecgframework.core.util.MyBeanUtils;
  27. import org.jeecgframework.core.util.ResourceUtil;
  28. import org.jeecgframework.core.util.StringUtil;
  29. import org.jeecgframework.poi.excel.ExcelImportUtil;
  30. import org.jeecgframework.poi.excel.entity.ExportParams;
  31. import org.jeecgframework.poi.excel.entity.ImportParams;
  32. import org.jeecgframework.poi.excel.entity.vo.NormalExcelConstants;
  33. import org.jeecgframework.tag.core.easyui.TagUtil;
  34. import org.jeecgframework.tag.vo.datatable.SortDirection;
  35. import org.jeecgframework.web.system.pojo.base.TSUser;
  36. import org.jeecgframework.web.system.service.SystemService;
  37. import org.springframework.beans.factory.annotation.Autowired;
  38. import org.springframework.http.HttpHeaders;
  39. import org.springframework.http.HttpStatus;
  40. import org.springframework.http.MediaType;
  41. import org.springframework.http.ResponseEntity;
  42. import org.springframework.stereotype.Controller;
  43. import org.springframework.ui.ModelMap;
  44. import org.springframework.web.bind.annotation.PathVariable;
  45. import org.springframework.web.bind.annotation.RequestBody;
  46. import org.springframework.web.bind.annotation.RequestMapping;
  47. import org.springframework.web.bind.annotation.RequestMethod;
  48. import org.springframework.web.bind.annotation.ResponseBody;
  49. import org.springframework.web.bind.annotation.ResponseStatus;
  50. import org.springframework.web.multipart.MultipartFile;
  51. import org.springframework.web.multipart.MultipartHttpServletRequest;
  52. import org.springframework.web.servlet.ModelAndView;
  53. import org.springframework.web.util.UriComponentsBuilder;
  54. import cn.com.lzt.sysbug.entity.TSSysbugEntity;
  55. import cn.com.lzt.sysbug.service.TSSysbugServiceI;
  56. import cn.com.lzt.sysbug.service.TSSysbugUtils;
  57. /**
  58. * @Title: Controller
  59. * @Description: 系统bug管理
  60. * @author onlineGenerator
  61. * @date 2019-04-05 11:33:43
  62. * @version V1.0
  63. *
  64. */
  65. @Controller
  66. @RequestMapping("/tSSysbugController")
  67. public class TSSysbugController extends BaseController {
  68. /**
  69. * Logger for this class
  70. */
  71. private static final Logger logger = Logger.getLogger(TSSysbugController.class);
  72. @Autowired
  73. private TSSysbugServiceI tSSysbugService;
  74. @Autowired
  75. private SystemService systemService;
  76. @Autowired
  77. private Validator validator;
  78. /**
  79. * 系统bug管理列表 页面跳转
  80. *
  81. * @return
  82. */
  83. @RequestMapping(params = "list")
  84. public ModelAndView list(HttpServletRequest request) {
  85. return new ModelAndView("cn/com/lzt/sysbug/tSSysbugList");
  86. }
  87. /**
  88. * easyui AJAX请求数据
  89. *
  90. * @param request
  91. * @param response
  92. * @param dataGrid
  93. * @param user
  94. */
  95. @RequestMapping(params = "datagrid")
  96. public void datagrid(TSSysbugEntity tSSysbug,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
  97. CriteriaQuery cq = new CriteriaQuery(TSSysbugEntity.class, dataGrid);
  98. //查询条件组装器
  99. org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, tSSysbug, request.getParameterMap());
  100. try{
  101. //自定义追加查询条件
  102. String query_createDate_begin = request.getParameter("createDate_begin");
  103. String query_createDate_end = request.getParameter("createDate_end");
  104. if(StringUtil.isNotEmpty(query_createDate_begin)){
  105. cq.ge("createDate", new SimpleDateFormat("yyyy-MM-dd").parse(query_createDate_begin));
  106. }
  107. if(StringUtil.isNotEmpty(query_createDate_end)){
  108. cq.le("createDate", new SimpleDateFormat("yyyy-MM-dd").parse(query_createDate_end));
  109. }
  110. String query_endTime_begin = request.getParameter("endTime_begin");
  111. String query_endTime_end = request.getParameter("endTime_end");
  112. if(StringUtil.isNotEmpty(query_endTime_begin)){
  113. cq.ge("endTime", Integer.parseInt(query_endTime_begin));
  114. }
  115. if(StringUtil.isNotEmpty(query_endTime_end)){
  116. cq.le("endTime", Integer.parseInt(query_endTime_end));
  117. }
  118. }catch (Exception e) {
  119. throw new BusinessException(e.getMessage());
  120. }
  121. cq.add();
  122. cq.addOrder("createDate",SortDirection.desc);
  123. // this.tSSysbugService.getDataGridReturn(cq, true);
  124. // TagUtil.datagrid(response, dataGrid);
  125. List result = this.systemService.getListByCriteriaQuery(cq, false);
  126. Collections.sort(result);
  127. dataGrid.setResults(result);
  128. TagUtil.datagrid(response, dataGrid);
  129. }
  130. /**
  131. * 删除系统bug管理
  132. *
  133. * @return
  134. */
  135. @RequestMapping(params = "doDel")
  136. @ResponseBody
  137. public AjaxJson doDel(TSSysbugEntity tSSysbug, HttpServletRequest request) {
  138. String message = null;
  139. AjaxJson j = new AjaxJson();
  140. tSSysbug = systemService.getEntity(TSSysbugEntity.class, tSSysbug.getId());
  141. message = "系统bug管理删除成功";
  142. try{
  143. tSSysbugService.delete(tSSysbug);
  144. systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
  145. }catch(Exception e){
  146. e.printStackTrace();
  147. message = "系统bug管理删除失败";
  148. throw new BusinessException(e.getMessage());
  149. }
  150. j.setMsg(message);
  151. return j;
  152. }
  153. /**
  154. * 批量删除系统bug管理
  155. *
  156. * @return
  157. */
  158. @RequestMapping(params = "doBatchDel")
  159. @ResponseBody
  160. public AjaxJson doBatchDel(String ids,HttpServletRequest request){
  161. String message = null;
  162. AjaxJson j = new AjaxJson();
  163. message = "系统bug管理删除成功";
  164. try{
  165. for(String id:ids.split(",")){
  166. TSSysbugEntity tSSysbug = systemService.getEntity(TSSysbugEntity.class,
  167. id
  168. );
  169. tSSysbugService.delete(tSSysbug);
  170. systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
  171. }
  172. }catch(Exception e){
  173. e.printStackTrace();
  174. message = "系统bug管理删除失败";
  175. throw new BusinessException(e.getMessage());
  176. }
  177. j.setMsg(message);
  178. return j;
  179. }
  180. /**
  181. * 添加系统bug管理
  182. *
  183. * @param ids
  184. * @return
  185. */
  186. @RequestMapping(params = "doAdd")
  187. @ResponseBody
  188. public AjaxJson doAdd(TSSysbugEntity tSSysbug, HttpServletRequest request) {
  189. String message = null;
  190. AjaxJson j = new AjaxJson();
  191. message = "系统bug提交成功";
  192. try{
  193. tSSysbug.setStatus(Globals.BUG_STATUS_NEW);
  194. HttpSession session = ContextHolderUtils.getSession();
  195. TSUser tuser = (TSUser)session.getAttribute("LOCAL_CLINET_USER");
  196. tSSysbug.setReporter(tuser.getId());
  197. tSSysbug.setReporterName(tuser.getRealName());
  198. tSSysbug.setProducter(Globals.BUG_CODER_PRODUCTER);
  199. TSUser producter = tSSysbugService.get(TSUser.class, Globals.BUG_CODER_PRODUCTER);
  200. tSSysbug.setProducterName(producter.getRealName());
  201. if(tSSysbug.getLoginPerson1() != null && tSSysbug.getLoginPerson1().length()>0) {
  202. TSUser login = tSSysbugService.get(TSUser.class, tSSysbug.getLoginPerson1());
  203. tSSysbug.setLoginPerson1Username(login.getUserNum());
  204. }
  205. if(tSSysbug.getBugPerson1() != null && tSSysbug.getBugPerson1().length()>0) {
  206. TSUser bugperson = tSSysbugService.get(TSUser.class, tSSysbug.getBugPerson1());
  207. tSSysbug.setBugPerson1Realname(bugperson.getRealName());
  208. }
  209. String id = (String)tSSysbugService.save(tSSysbug);
  210. TSSysbugUtils.sendBugMail(tSSysbug, tSSysbug.getProducter(),"新Bug通知");
  211. // systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO);
  212. }catch(Exception e){
  213. e.printStackTrace();
  214. message = "系统bug管理添加失败";
  215. throw new BusinessException(e.getMessage());
  216. }
  217. j.setMsg(message);
  218. return j;
  219. }
  220. /**
  221. * 更新系统bug管理
  222. *
  223. * @param ids
  224. * @return
  225. */
  226. @RequestMapping(params = "doUpdate")
  227. @ResponseBody
  228. public AjaxJson doUpdate(TSSysbugEntity tSSysbug, HttpServletRequest request) {
  229. String message = null;
  230. AjaxJson j = new AjaxJson();
  231. message = "系统bug管理更新成功";
  232. TSSysbugEntity t = tSSysbugService.get(TSSysbugEntity.class, tSSysbug.getId());
  233. try {
  234. if(tSSysbug.getLoginPerson1() != null && tSSysbug.getLoginPerson1().length()>0) {
  235. TSUser login = tSSysbugService.get(TSUser.class, tSSysbug.getLoginPerson1());
  236. tSSysbug.setLoginPerson1Username(login.getUserNum());
  237. }
  238. if(tSSysbug.getBugPerson1() != null && tSSysbug.getBugPerson1().length()>0) {
  239. TSUser bugperson = tSSysbugService.get(TSUser.class, tSSysbug.getBugPerson1());
  240. tSSysbug.setBugPerson1Realname(bugperson.getRealName());
  241. }
  242. MyBeanUtils.copyBeanNotNull2Bean(tSSysbug, t);
  243. tSSysbugService.saveOrUpdate(t);
  244. if(t.getReporter() != null) {
  245. TSSysbugUtils.sendBugMail(t, t.getReporter(),"更新Bug信息通知");
  246. }
  247. if(t.getProducter() != null) {
  248. TSSysbugUtils.sendBugMail(t, t.getProducter(),"更新Bug信息通知");
  249. }
  250. if(t.getCoder() != null) {
  251. TSSysbugUtils.sendBugMail(t, t.getCoder(),"更新Bug信息通知");
  252. }
  253. if(t.getTester() != null) {
  254. TSSysbugUtils.sendBugMail(t, t.getTester(),"更新Bug信息通知");
  255. }
  256. // systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
  257. } catch (Exception e) {
  258. e.printStackTrace();
  259. message = "系统bug管理更新失败";
  260. throw new BusinessException(e.getMessage());
  261. }
  262. j.setMsg(message);
  263. return j;
  264. }
  265. /**
  266. * 指派系统bug管理
  267. *
  268. * @param ids
  269. * @return
  270. */
  271. @RequestMapping(params = "doAssign")
  272. @ResponseBody
  273. public AjaxJson doAssign(TSSysbugEntity tSSysbug, HttpServletRequest request) {
  274. String message = null;
  275. AjaxJson j = new AjaxJson();
  276. message = "系统bug指派成功";
  277. TSSysbugEntity t = tSSysbugService.get(TSSysbugEntity.class, tSSysbug.getId());
  278. try {
  279. //MyBeanUtils.copyBeanNotNull2Bean(tSSysbug, t);
  280. t.setStatus(Globals.BUG_STATUS_ASSINGED);
  281. t.setCoder(tSSysbug.getCoder());
  282. TSUser coder = tSSysbugService.get(TSUser.class, tSSysbug.getCoder());
  283. t.setCoderName(coder.getRealName());
  284. tSSysbugService.saveOrUpdate(t);
  285. if(t.getReporter() != null) {
  286. TSSysbugUtils.sendBugMail(t, t.getReporter(),"Bug已指派给开发负责人");
  287. }
  288. if(t.getProducter() != null) {
  289. TSSysbugUtils.sendBugMail(t, t.getProducter(),"Bug已指派给开发负责人");
  290. }
  291. if(t.getCoder() != null) {
  292. TSSysbugUtils.sendBugMail(t, t.getCoder(),"Bug已指派给开发负责人");
  293. }
  294. // systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
  295. } catch (Exception e) {
  296. e.printStackTrace();
  297. message = "系统bug指派失败";
  298. throw new BusinessException(e.getMessage());
  299. }
  300. j.setMsg(message);
  301. return j;
  302. }
  303. /**
  304. * 修改系统bug管理
  305. *
  306. * @param ids
  307. * @return
  308. */
  309. @RequestMapping(params = "doOpen")
  310. public ModelAndView doOpen(TSSysbugEntity tSSysbug, HttpServletRequest request) {
  311. String message = null;
  312. AjaxJson j = new AjaxJson();
  313. TSSysbugEntity t = tSSysbugService.get(TSSysbugEntity.class, tSSysbug.getId());
  314. try {
  315. //MyBeanUtils.copyBeanNotNull2Bean(tSSysbug, t);
  316. t.setStatus(Globals.BUG_STATUS_OPEN);
  317. // t.setCoder(tSSysbug.getCoder());/*
  318. // TSUser coder = tSSysbugService.get(TSUser.class, tSSysbug.getCoder());
  319. // t.setCoderName(coder.getRealName());*/
  320. tSSysbugService.saveOrUpdate(t);
  321. if(t.getReporter() != null) {
  322. TSSysbugUtils.sendBugMail(t, t.getReporter(),"系统bug进入修改状态");
  323. }
  324. if(t.getProducter() != null) {
  325. TSSysbugUtils.sendBugMail(t, t.getProducter(),"系统bug进入修改状态");
  326. }
  327. if(t.getCoder() != null) {
  328. TSSysbugUtils.sendBugMail(t, t.getCoder(),"系统bug进入修改状态");
  329. }
  330. // systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
  331. } catch (Exception e) {
  332. e.printStackTrace();
  333. throw new BusinessException(e.getMessage());
  334. }
  335. return new ModelAndView("cn/com/lzt/sysbug/tSSysbugList");
  336. }
  337. /**
  338. * 完成修改系统bug管理
  339. *
  340. * @param ids
  341. * @return
  342. */
  343. @RequestMapping(params = "doFix")
  344. public ModelAndView doFix(TSSysbugEntity tSSysbug, HttpServletRequest request) {
  345. String message = null;
  346. AjaxJson j = new AjaxJson();
  347. message = "系统bug修改完成";
  348. TSSysbugEntity t = tSSysbugService.get(TSSysbugEntity.class, tSSysbug.getId());
  349. try {
  350. //MyBeanUtils.copyBeanNotNull2Bean(tSSysbug, t);
  351. t.setStatus(Globals.BUG_STATUS_FIXED);
  352. // t.setCoder(tSSysbug.getCoder());/*
  353. // TSUser coder = tSSysbugService.get(TSUser.class, tSSysbug.getCoder());
  354. // t.setCoderName(coder.getRealName());*/
  355. tSSysbugService.saveOrUpdate(t);
  356. if(t.getReporter() != null) {
  357. TSSysbugUtils.sendBugMail(t, t.getReporter(),"系统bug修改完成");
  358. }
  359. if(t.getProducter() != null) {
  360. TSSysbugUtils.sendBugMail(t, t.getProducter(),"系统bug修改完成");
  361. }
  362. if(t.getCoder() != null) {
  363. TSSysbugUtils.sendBugMail(t, t.getCoder(),"系统bug修改完成");
  364. }
  365. // systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
  366. } catch (Exception e) {
  367. e.printStackTrace();
  368. message = "系统bug修改完成状态失败";
  369. throw new BusinessException(e.getMessage());
  370. }
  371. j.setMsg(message);
  372. return new ModelAndView("cn/com/lzt/sysbug/tSSysbugList");
  373. }
  374. /**
  375. * 完成修改系统bug管理
  376. *
  377. * @param ids
  378. * @return
  379. */
  380. @RequestMapping(params = "doFinish")
  381. public ModelAndView doFinish(TSSysbugEntity tSSysbug, HttpServletRequest request) {
  382. String message = null;
  383. AjaxJson j = new AjaxJson();
  384. message = "系统bug验证通过";
  385. TSSysbugEntity t = tSSysbugService.get(TSSysbugEntity.class, tSSysbug.getId());
  386. try {
  387. //MyBeanUtils.copyBeanNotNull2Bean(tSSysbug, t);
  388. t.setStatus(Globals.BUG_STATUS_FINISH);
  389. // t.setCoder(tSSysbug.getCoder());/*
  390. // TSUser coder = tSSysbugService.get(TSUser.class, tSSysbug.getCoder());
  391. // t.setCoderName(coder.getRealName());*/
  392. tSSysbugService.saveOrUpdate(t);
  393. if(t.getReporter() != null) {
  394. TSSysbugUtils.sendBugMail(t, t.getReporter(),"系统bug修改完成");
  395. }
  396. if(t.getProducter() != null) {
  397. TSSysbugUtils.sendBugMail(t, t.getProducter(),"系统bug修改完成");
  398. }
  399. if(t.getCoder() != null) {
  400. TSSysbugUtils.sendBugMail(t, t.getCoder(),"系统bug修改完成");
  401. }
  402. // systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
  403. } catch (Exception e) {
  404. e.printStackTrace();
  405. message = "系统bug修改完成状态失败";
  406. throw new BusinessException(e.getMessage());
  407. }
  408. j.setMsg(message);
  409. return new ModelAndView("cn/com/lzt/sysbug/tSSysbugList");
  410. }
  411. /**
  412. * 系统bug管理新增页面跳转
  413. *
  414. * @return
  415. */
  416. @RequestMapping(params = "goAdd")
  417. public ModelAndView goAdd(TSSysbugEntity tSSysbug, HttpServletRequest req) {
  418. if (StringUtil.isNotEmpty(tSSysbug.getId())) {
  419. tSSysbug = tSSysbugService.getEntity(TSSysbugEntity.class, tSSysbug.getId());
  420. req.setAttribute("tSSysbugPage", tSSysbug);
  421. }
  422. return new ModelAndView("cn/com/lzt/sysbug/tSSysbug-add");
  423. }
  424. /**
  425. * 系统bug管理编辑页面跳转
  426. *
  427. * @return
  428. */
  429. @RequestMapping(params = "goUpdate")
  430. public ModelAndView goUpdate(TSSysbugEntity tSSysbug, HttpServletRequest req) {
  431. if (StringUtil.isNotEmpty(tSSysbug.getId())) {
  432. tSSysbug = tSSysbugService.getEntity(TSSysbugEntity.class, tSSysbug.getId());
  433. String login1 = tSSysbug.getLoginPerson1();
  434. if(login1 != null) {
  435. TSUser user1 = tSSysbugService.get(TSUser.class, login1);
  436. if(user1 != null) {
  437. tSSysbug.setLoginPerson1Username(user1.getUserName());
  438. }
  439. }
  440. String bugperson1 = tSSysbug.getBugPerson1();
  441. if(bugperson1 != null) {
  442. TSUser user2 = tSSysbugService.get(TSUser.class, bugperson1);
  443. if(user2 != null) {
  444. tSSysbug.setBugPerson1Realname(user2.getRealName());
  445. }
  446. }
  447. req.setAttribute("tSSysbugPage", tSSysbug);
  448. }
  449. return new ModelAndView("cn/com/lzt/sysbug/tSSysbug-update");
  450. }
  451. /**
  452. * 系统bug管理编辑页面跳转
  453. *
  454. * @return
  455. */
  456. @RequestMapping(params = "goDetail")
  457. public ModelAndView goDetail(TSSysbugEntity tSSysbug, HttpServletRequest req) {
  458. if (StringUtil.isNotEmpty(tSSysbug.getId())) {
  459. tSSysbug = tSSysbugService.getEntity(TSSysbugEntity.class, tSSysbug.getId());
  460. String login1 = tSSysbug.getLoginPerson1();
  461. if(login1 != null) {
  462. TSUser user1 = tSSysbugService.get(TSUser.class, login1);
  463. if(user1 != null) {
  464. tSSysbug.setLoginPerson1Username(user1.getUserName());
  465. }
  466. }
  467. String bugperson1 = tSSysbug.getBugPerson1();
  468. if(bugperson1 != null) {
  469. TSUser user2 = tSSysbugService.get(TSUser.class, bugperson1);
  470. if(user2 != null) {
  471. tSSysbug.setBugPerson1Realname(user2.getRealName());
  472. }
  473. }
  474. req.setAttribute("tSSysbugPage", tSSysbug);
  475. }
  476. return new ModelAndView("cn/com/lzt/sysbug/tSSysbug-detail");
  477. }
  478. /**
  479. * 系统bug管理编辑页面跳转
  480. *
  481. * @return
  482. */
  483. @RequestMapping(params = "goAssign")
  484. public ModelAndView goAssign(TSSysbugEntity tSSysbug, HttpServletRequest req) {
  485. if (StringUtil.isNotEmpty(tSSysbug.getId())) {
  486. tSSysbug = tSSysbugService.getEntity(TSSysbugEntity.class, tSSysbug.getId());
  487. String login1 = tSSysbug.getLoginPerson1();
  488. if(login1 != null) {
  489. TSUser user1 = tSSysbugService.get(TSUser.class, login1);
  490. if(user1 != null) {
  491. tSSysbug.setLoginPerson1Username(user1.getUserName());
  492. }
  493. }
  494. String bugperson1 = tSSysbug.getBugPerson1();
  495. if(bugperson1 != null) {
  496. TSUser user2 = tSSysbugService.get(TSUser.class, bugperson1);
  497. if(user2 != null) {
  498. tSSysbug.setBugPerson1Realname(user2.getRealName());
  499. }
  500. }
  501. req.setAttribute("tSSysbugPage", tSSysbug);
  502. }
  503. return new ModelAndView("cn/com/lzt/sysbug/tSSysbug-assign");
  504. }
  505. /**
  506. * 导入功能跳转
  507. *
  508. * @return
  509. */
  510. @RequestMapping(params = "upload")
  511. public ModelAndView upload(HttpServletRequest req) {
  512. req.setAttribute("controller_name","tSSysbugController");
  513. return new ModelAndView("common/upload/pub_excel_upload");
  514. }
  515. /**
  516. * 导出excel
  517. *
  518. * @param request
  519. * @param response
  520. */
  521. @RequestMapping(params = "exportXls")
  522. public String exportXls(TSSysbugEntity tSSysbug,HttpServletRequest request,HttpServletResponse response
  523. , DataGrid dataGrid,ModelMap modelMap) {
  524. CriteriaQuery cq = new CriteriaQuery(TSSysbugEntity.class, dataGrid);
  525. org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, tSSysbug, request.getParameterMap());
  526. List<TSSysbugEntity> tSSysbugs = this.tSSysbugService.getListByCriteriaQuery(cq,false);
  527. modelMap.put(NormalExcelConstants.FILE_NAME,"系统bug管理");
  528. modelMap.put(NormalExcelConstants.CLASS,TSSysbugEntity.class);
  529. modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("系统bug管理列表", "导出人:"+ResourceUtil.getSessionUser().getRealName(),
  530. "导出信息"));
  531. modelMap.put(NormalExcelConstants.DATA_LIST,tSSysbugs);
  532. return NormalExcelConstants.JEECG_EXCEL_VIEW;
  533. }
  534. /**
  535. * 导出excel 使模板
  536. *
  537. * @param request
  538. * @param response
  539. */
  540. @RequestMapping(params = "exportXlsByT")
  541. public String exportXlsByT(TSSysbugEntity tSSysbug,HttpServletRequest request,HttpServletResponse response
  542. , DataGrid dataGrid,ModelMap modelMap) {
  543. modelMap.put(NormalExcelConstants.FILE_NAME,"系统bug管理");
  544. modelMap.put(NormalExcelConstants.CLASS,TSSysbugEntity.class);
  545. modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("系统bug管理列表", "导出人:"+ResourceUtil.getSessionUser().getRealName(),
  546. "导出信息"));
  547. modelMap.put(NormalExcelConstants.DATA_LIST,new ArrayList());
  548. return NormalExcelConstants.JEECG_EXCEL_VIEW;
  549. }
  550. @SuppressWarnings("unchecked")
  551. @RequestMapping(params = "importExcel", method = RequestMethod.POST)
  552. @ResponseBody
  553. public AjaxJson importExcel(HttpServletRequest request, HttpServletResponse response) {
  554. AjaxJson j = new AjaxJson();
  555. MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
  556. Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
  557. for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
  558. MultipartFile file = entity.getValue();// 获取上传文件对象
  559. ImportParams params = new ImportParams();
  560. params.setTitleRows(2);
  561. params.setHeadRows(1);
  562. params.setNeedSave(true);
  563. try {
  564. List<TSSysbugEntity> listTSSysbugEntitys = ExcelImportUtil.importExcel(file.getInputStream(),TSSysbugEntity.class,params);
  565. for (TSSysbugEntity tSSysbug : listTSSysbugEntitys) {
  566. tSSysbugService.save(tSSysbug);
  567. }
  568. j.setMsg("文件导入成功!");
  569. } catch (Exception e) {
  570. j.setMsg("文件导入失败!");
  571. logger.error(ExceptionUtil.getExceptionMessage(e));
  572. }finally{
  573. try {
  574. file.getInputStream().close();
  575. } catch (IOException e) {
  576. e.printStackTrace();
  577. }
  578. }
  579. }
  580. return j;
  581. }
  582. @RequestMapping(method = RequestMethod.GET)
  583. @ResponseBody
  584. public List<TSSysbugEntity> list() {
  585. List<TSSysbugEntity> listTSSysbugs=tSSysbugService.getList(TSSysbugEntity.class);
  586. return listTSSysbugs;
  587. }
  588. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  589. @ResponseBody
  590. public ResponseEntity<?> get(@PathVariable("id") String id) {
  591. TSSysbugEntity task = tSSysbugService.get(TSSysbugEntity.class, id);
  592. if (task == null) {
  593. return new ResponseEntity(HttpStatus.NOT_FOUND);
  594. }
  595. return new ResponseEntity(task, HttpStatus.OK);
  596. }
  597. @RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
  598. @ResponseBody
  599. public ResponseEntity<?> create(@RequestBody TSSysbugEntity tSSysbug, UriComponentsBuilder uriBuilder) {
  600. //调用JSR303 Bean Validator进行校验,如果出错返回含400错误码及json格式的错误信息.
  601. Set<ConstraintViolation<TSSysbugEntity>> failures = validator.validate(tSSysbug);
  602. if (!failures.isEmpty()) {
  603. return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST);
  604. }
  605. //保存
  606. try{
  607. tSSysbugService.save(tSSysbug);
  608. } catch (Exception e) {
  609. e.printStackTrace();
  610. return new ResponseEntity(HttpStatus.NO_CONTENT);
  611. }
  612. //按照Restful风格约定,创建指向新任务的url, 也可以直接返回id或对象.
  613. String id = tSSysbug.getId();
  614. URI uri = uriBuilder.path("/rest/tSSysbugController/" + id).build().toUri();
  615. HttpHeaders headers = new HttpHeaders();
  616. headers.setLocation(uri);
  617. return new ResponseEntity(headers, HttpStatus.CREATED);
  618. }
  619. @RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
  620. public ResponseEntity<?> update(@RequestBody TSSysbugEntity tSSysbug) {
  621. //调用JSR303 Bean Validator进行校验,如果出错返回含400错误码及json格式的错误信息.
  622. Set<ConstraintViolation<TSSysbugEntity>> failures = validator.validate(tSSysbug);
  623. if (!failures.isEmpty()) {
  624. return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST);
  625. }
  626. //保存
  627. try{
  628. tSSysbugService.saveOrUpdate(tSSysbug);
  629. } catch (Exception e) {
  630. e.printStackTrace();
  631. return new ResponseEntity(HttpStatus.NO_CONTENT);
  632. }
  633. //按Restful约定,返回204状态码, 无内容. 也可以返回200状态码.
  634. return new ResponseEntity(HttpStatus.NO_CONTENT);
  635. }
  636. @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
  637. @ResponseStatus(HttpStatus.NO_CONTENT)
  638. public void delete(@PathVariable("id") String id) {
  639. tSSysbugService.deleteEntityById(TSSysbugEntity.class, id);
  640. }
  641. }