ComplainController.java 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. package cn.com.lzt.complain.controller;
  2. import cn.com.lzt.complain.service.ComplainRecordService;
  3. import cn.com.lzt.complain.service.impl.ComplainServiceImpl;
  4. import cn.com.lzt.sysmsg.service.SysMsgServiceI;
  5. import com.alibaba.fastjson.JSONObject;
  6. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  7. import com.daju.common.util.DataPage;
  8. import com.daju.mix.dao.entity.TBComplaint;
  9. import com.daju.mix.dao.entity.TBComplaintRecord;
  10. import com.daju.mix.dao.entity.TBScheduleSuperivse;
  11. import com.daju.mix.dao.mapper.TBComplaintMapper;
  12. import com.daju.mix.dao.mapper.TBComplaintRecordMapper;
  13. import com.xcgl.utils.OrderNumTools;
  14. import org.apache.commons.collections.CollectionUtils;
  15. import org.apache.commons.lang.StringUtils;
  16. import org.jeecgframework.core.common.exception.BusinessException;
  17. import org.jeecgframework.core.common.model.json.AjaxJson;
  18. import org.jeecgframework.core.common.model.json.DataGrid;
  19. import org.jeecgframework.core.constant.Globals;
  20. import org.jeecgframework.core.util.ResourceUtil;
  21. import org.jeecgframework.tag.core.easyui.TagUtil;
  22. import org.jeecgframework.web.system.pojo.base.TSUser;
  23. import org.jeecgframework.web.system.service.SystemService;
  24. import org.springframework.beans.factory.annotation.Autowired;
  25. import org.springframework.stereotype.Controller;
  26. import org.springframework.web.bind.annotation.RequestMapping;
  27. import org.springframework.web.bind.annotation.ResponseBody;
  28. import org.springframework.web.servlet.ModelAndView;
  29. import javax.annotation.Resource;
  30. import javax.servlet.http.HttpServletRequest;
  31. import javax.servlet.http.HttpServletResponse;
  32. import javax.transaction.Transactional;
  33. import java.text.SimpleDateFormat;
  34. import java.util.*;
  35. /**
  36. * @author :sahib.kio.m
  37. * @date :Created in 2021/8/13 下午3:20
  38. */
  39. @RequestMapping("/complainController")
  40. @Controller
  41. public class ComplainController {
  42. @Resource
  43. private ComplainServiceImpl complainService;
  44. @Resource
  45. private ComplainRecordService complainRecordService;
  46. @Resource
  47. private TBComplaintRecordMapper tbComplaintRecordMapper;
  48. @Resource
  49. private TBComplaintMapper tbComplaintMapper;
  50. // add-刘梦祥-2022年8月25日11:13:37(投诉业务添加系统消息提示)
  51. @Autowired
  52. private SysMsgServiceI sysMsgService;
  53. @Autowired
  54. private SystemService systemService;
  55. @RequestMapping(params = "list")
  56. public ModelAndView list(HttpServletRequest request) {
  57. for (String key : request.getParameterMap().keySet()){
  58. request.setAttribute(key, request.getParameter(key));
  59. }
  60. return new ModelAndView("cn/com/lzt/complain/complainList");
  61. }
  62. @RequestMapping(params = "goAdd")
  63. public ModelAndView goAdd(HttpServletRequest request) {
  64. return new ModelAndView("cn/com/lzt/complain/complainList-add");
  65. }
  66. @RequestMapping(params = "goUpdate")
  67. public ModelAndView goUpdate(HttpServletRequest request) {
  68. String id = request.getParameter("id");
  69. TBComplaint common = complainService.getById(id);
  70. common = scheduleImageUrl(common);
  71. request.setAttribute("common", common);
  72. return new ModelAndView("cn/com/lzt/complain/complainList-update");
  73. }
  74. public TBComplaint scheduleImageUrl(TBComplaint common) {
  75. if (common != null) {
  76. // add-刘梦祥-2022年1月13日19:02:31(新增视频和图片路径解析)
  77. if (common.getImgUrl() != null && StringUtils.isNotEmpty(common.getImgUrl())) {
  78. if (common.getImgUrl().contains("http") && common.getImgUrl().length() > 10) {
  79. try {
  80. List<String> imgUrlList = JSONObject.parseArray(common.getImgUrl(), String.class);
  81. common.setImgUrlList(imgUrlList);
  82. } catch (Exception e) {
  83. e.printStackTrace();
  84. }
  85. } else {
  86. List<String> imgUrlList = new ArrayList<>();
  87. if (!"[null]".equals(common.getImgUrl()) && !"[]".equals(common.getImgUrl())) {
  88. imgUrlList.add("http://47.100.210.233/" + common.getImgUrl());
  89. common.setImgUrlList(imgUrlList);
  90. }
  91. }
  92. }
  93. if (common.getVideos() != null && StringUtils.isNotEmpty(common.getVideos())) {
  94. if (common.getVideos().contains("http")) {
  95. try {
  96. List<String> videosList = JSONObject.parseArray(common.getVideos(), String.class);
  97. common.setVideosList(videosList);
  98. } catch (Exception e) {
  99. e.printStackTrace();
  100. }
  101. } else {
  102. List<String> videosList = new ArrayList<>();
  103. if (!"[null]".equals(common.getVideos()) && !"[]".equals(common.getVideos())) {
  104. videosList.add("http://47.100.210.233/" + common.getVideos());
  105. common.setVideosList(videosList);
  106. }
  107. }
  108. }
  109. }
  110. return common;
  111. }
  112. @RequestMapping(params = "goCheck")
  113. public ModelAndView goCheck(HttpServletRequest request) {
  114. String id = request.getParameter("id");
  115. List<TBComplaintRecord> list = complainRecordService.list(new QueryWrapper<TBComplaintRecord>(){{
  116. eq("complaint_id", id);
  117. orderByDesc("complaint_date");
  118. }});
  119. request.setAttribute("list", list);
  120. if (CollectionUtils.isEmpty(list)) {
  121. request.setAttribute("noRecord", "无整改记录");
  122. }
  123. return new ModelAndView("cn/com/lzt/complain/complainList-check");
  124. }
  125. @RequestMapping(params = "goDeal")
  126. public ModelAndView goDeal(HttpServletRequest request) {
  127. for (String key : request.getParameterMap().keySet()){
  128. request.setAttribute(key, request.getParameter(key));
  129. }
  130. return new ModelAndView("cn/com/lzt/complain/complainList-deal");
  131. }
  132. @RequestMapping(params = "goConfirm")
  133. public ModelAndView goConfirm(HttpServletRequest request) {
  134. for (String key : request.getParameterMap().keySet()){
  135. request.setAttribute(key, request.getParameter(key));
  136. }
  137. return new ModelAndView("cn/com/lzt/complain/complainList-confirm");
  138. }
  139. @RequestMapping(params = "datagrid")
  140. public void datagrid(HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
  141. Map<String, String> param = new HashMap<>();
  142. for (String key : request.getParameterMap().keySet()){
  143. param.put(key, request.getParameter(key));
  144. }
  145. DataPage result = complainService.list(param);
  146. TagUtil.datagrid(response, dataGrid, result);
  147. }
  148. @RequestMapping(params = "doAdd")
  149. @ResponseBody
  150. public AjaxJson doAdd(TBComplaint common, HttpServletRequest request) {
  151. String message = null;
  152. AjaxJson j = new AjaxJson();
  153. message = "档案添加成功";
  154. j.setSuccess(true);
  155. try{ // p_device_defend
  156. common.setCode(OrderNumTools.generateNextBillCode("" + getNowDate(),8, "t_b_complaint", "code", 4));
  157. if(StringUtils.isNotEmpty(common.getType())){
  158. // 判断投诉类型是不是垃圾清运,是的话就是清运科,否则是保洁科,默认是保洁科
  159. if(common.getType().equals("2")){
  160. common.setDepartId("清运科");
  161. }else{
  162. common.setDepartId("保洁科");
  163. }
  164. }
  165. TSUser user = ResourceUtil.getSessionUser();
  166. if (user != null){
  167. String userId = user.getId();
  168. common.setCreateDate(new Date());
  169. common.setCreateBy(userId);
  170. }
  171. common.setStatus("1");
  172. tbComplaintMapper.insert(common);
  173. }catch(Exception e){
  174. e.printStackTrace();
  175. message = "档案添加失败";
  176. j.setMsg(message);
  177. j.setSuccess(false);
  178. throw new BusinessException(e.getMessage());
  179. }
  180. j.setMsg(message);
  181. return j;
  182. }
  183. @RequestMapping(params = "doUpdate")
  184. @ResponseBody
  185. public AjaxJson doUpdate(TBComplaint common, HttpServletRequest request) {
  186. String message = null;
  187. AjaxJson j = new AjaxJson();
  188. message = "更新成功";
  189. j.setSuccess(true);
  190. try{
  191. complainService.updateById(common);
  192. }catch(Exception e){
  193. e.printStackTrace();
  194. message = "更新失败";
  195. j.setSuccess(false);
  196. throw new BusinessException(e.getMessage());
  197. }
  198. j.setMsg(message);
  199. return j;
  200. }
  201. @RequestMapping(params = "doDel")
  202. @ResponseBody
  203. public AjaxJson doDel(TBComplaint common, HttpServletRequest request){
  204. String message = null;
  205. AjaxJson j = new AjaxJson();
  206. message = "档案删除成功";
  207. try{
  208. complainService.removeById(common);
  209. }catch(Exception e){
  210. e.printStackTrace();
  211. message = "档案删除失败";
  212. throw new BusinessException(e.getMessage());
  213. }
  214. j.setMsg(message);
  215. return j;
  216. }
  217. /**
  218. * add-刘梦祥-2022年6月21日13:26:24
  219. * 投诉管理完善下发逻辑
  220. * @param common
  221. * @param request
  222. * @return
  223. */
  224. @RequestMapping(params = "turnTo")
  225. @ResponseBody
  226. @Transactional
  227. public AjaxJson turnTo(TBComplaint common, HttpServletRequest request){
  228. String message = null;
  229. AjaxJson j = new AjaxJson();
  230. message = "下发成功";
  231. try{
  232. common = complainService.getById(common.getId());
  233. if(common.getLeaderUserId() != null){
  234. common.setStatus("2");
  235. complainService.updateById(common);
  236. TSUser tSUser = ResourceUtil.getSessionUser();
  237. // 经确认下发后需要发送系统消息给责任人的科长和科室管理人员,可以写一个SQL获取到责任人的科室对应的科长和科室管理人员。
  238. String getPostUserId = "SELECT\n" +
  239. "\ttsu.id userId, tsd.departname, tbp.post_name\n" +
  240. "FROM\n" +
  241. "\tt_s_user tsu\n" +
  242. "LEFT JOIN t_s_user_org tsuo ON tsuo.user_id = tsu.id\n" +
  243. "LEFT JOIN t_bus_user_personnel tbup ON tbup.userid = tsu.id\n" +
  244. "LEFT JOIN t_s_depart tsd ON tsd.id = tsuo.org_id\n" +
  245. "LEFT JOIN t_bus_post tbp ON tbp.id = tbup.in_postid\n" +
  246. "WHERE\n" +
  247. "\ttsd.id in (select tsd.id from t_s_depart tsd LEFT JOIN t_s_user_org tsuo on tsuo.org_id = tsd.id where tsuo.user_id = '"+common.getResponsibleUserId()+"')\n" +
  248. "\tand tbp.post_name in ('科室科长','科室管理人员')\n;";
  249. List<Object[]> list = this.systemService.findListbySql(getPostUserId);
  250. if(list != null && list.size() > 0){
  251. for (Object[] item : list){
  252. if(item[0] != null){
  253. sysMsgService.saveSysMsg(Globals.MSG_TITLE_1,Globals.MSG_CONTENT_1,tSUser.getId(),item[0].toString());
  254. }
  255. }
  256. }
  257. }else{
  258. j.setSuccess(false);
  259. message = "下发失败!请指定责任人!";
  260. }
  261. }catch(Exception e){
  262. e.printStackTrace();
  263. message = "更新失败";
  264. j.setSuccess(false);
  265. }
  266. j.setMsg(message);
  267. return j;
  268. }
  269. @RequestMapping(params = "doBack")
  270. @ResponseBody
  271. public AjaxJson doBack(TBComplaint common, HttpServletRequest request){
  272. String message = null;
  273. AjaxJson j = new AjaxJson();
  274. message = "更新成功";
  275. try{
  276. common = complainService.getById(common.getId());
  277. common.setStatus("2");
  278. common.setBackStatus("1");
  279. complainService.updateById(common);
  280. }catch(Exception e){
  281. e.printStackTrace();
  282. message = "更新失败";
  283. throw new BusinessException(e.getMessage());
  284. }
  285. j.setMsg(message);
  286. return j;
  287. }
  288. @RequestMapping(params = "doDeal")
  289. @ResponseBody
  290. public AjaxJson doDeal(TBComplaintRecord common, HttpServletRequest request) {
  291. String message = null;
  292. AjaxJson j = new AjaxJson();
  293. message = "更新成功";
  294. j.setSuccess(true);
  295. try{
  296. common.setComplaintDate(getNowDateTime());
  297. tbComplaintRecordMapper.insert(common);
  298. TBComplaint tbComplain = complainService.getById(common.getComplaintId());
  299. tbComplain.setStatus("3");
  300. tbComplain.setBackStatus("");
  301. tbComplain.setDealDate(getNowDateTime());
  302. complainService.updateById(tbComplain);
  303. }catch(Exception e){
  304. e.printStackTrace();
  305. message = "更新失败";
  306. j.setSuccess(false);
  307. throw new BusinessException(e.getMessage());
  308. }
  309. j.setMsg(message);
  310. return j;
  311. }
  312. @RequestMapping(params = "confirm")
  313. @ResponseBody
  314. public AjaxJson confirm(TBComplaint common, HttpServletRequest request) {
  315. String message = null;
  316. AjaxJson j = new AjaxJson();
  317. message = "更新成功";
  318. j.setSuccess(true);
  319. try{
  320. common.setStatus("4");
  321. common.setBackStatus("2");
  322. complainService.updateById(common);
  323. }catch(Exception e){
  324. e.printStackTrace();
  325. message = "更新失败";
  326. j.setSuccess(false);
  327. throw new BusinessException(e.getMessage());
  328. }
  329. j.setMsg(message);
  330. return j;
  331. }
  332. private static SimpleDateFormat sdfDate = new SimpleDateFormat("yyyyMMdd");
  333. private static SimpleDateFormat sdfTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  334. public static String getNowDate(){
  335. Date now = new Date();
  336. String time = sdfDate.format(now);
  337. return time;
  338. }
  339. public static String getNowDateTime(){
  340. Date now = new Date();
  341. String time = sdfTime.format(now);
  342. return time;
  343. }
  344. }