ScheduleSuperivseController.java 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. package cn.com.lzt.schedule.controller;
  2. import cn.com.lzt.common.util.StringUtil;
  3. import cn.com.lzt.schedule.service.impl.ScheduleSuperivseRecordServiceImpl;
  4. import cn.com.lzt.schedule.service.impl.ScheduleSuperivseServiceImpl;
  5. import cn.com.lzt.sysmsg.service.SysMsgServiceI;
  6. import com.alibaba.fastjson.JSON;
  7. import com.alibaba.fastjson.JSONArray;
  8. import com.alibaba.fastjson.JSONObject;
  9. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  10. import com.daju.common.util.DataPage;
  11. import com.daju.mix.dao.entity.TBScheduleSuperivse;
  12. import com.daju.mix.dao.entity.TBScheduleSuperivseRecord;
  13. import com.daju.mix.dao.service.impl.TSBaseUserServiceImpl;
  14. import com.xcgl.utils.OrderNumTools;
  15. import org.apache.commons.collections.CollectionUtils;
  16. import org.apache.commons.lang.StringUtils;
  17. import org.jeecgframework.core.common.exception.BusinessException;
  18. import org.jeecgframework.core.common.model.json.AjaxJson;
  19. import org.jeecgframework.core.common.model.json.DataGrid;
  20. import org.jeecgframework.core.constant.Globals;
  21. import org.jeecgframework.core.util.ResourceUtil;
  22. import org.jeecgframework.tag.core.easyui.TagUtil;
  23. import org.jeecgframework.web.system.pojo.base.TSUser;
  24. import org.jeecgframework.web.system.service.SystemService;
  25. import org.springframework.beans.factory.annotation.Autowired;
  26. import org.springframework.stereotype.Controller;
  27. import org.springframework.web.bind.annotation.RequestMapping;
  28. import org.springframework.web.bind.annotation.ResponseBody;
  29. import org.springframework.web.servlet.ModelAndView;
  30. import javax.annotation.Resource;
  31. import javax.servlet.http.HttpServletRequest;
  32. import javax.servlet.http.HttpServletResponse;
  33. import java.text.SimpleDateFormat;
  34. import java.util.*;
  35. import java.util.stream.Collectors;
  36. /**
  37. * @author :sahib.kio.m
  38. * @date :Created in 2021/8/10 下午3:11
  39. */
  40. @Controller
  41. @RequestMapping("/scheduleSuperivseController")
  42. public class ScheduleSuperivseController {
  43. @Resource
  44. private ScheduleSuperivseServiceImpl superivseService;
  45. @Resource
  46. private TSBaseUserServiceImpl baseUserService;
  47. @Resource
  48. private ScheduleSuperivseRecordServiceImpl superivseRecordService;
  49. @Autowired
  50. private SystemService systemService;
  51. @Autowired
  52. private SysMsgServiceI sysMsgService;
  53. @RequestMapping(params = "list")
  54. public ModelAndView list(HttpServletRequest request) {
  55. return new ModelAndView("cn/com/lzt/schedule/superivseList");
  56. }
  57. @RequestMapping(params = "datagrid")
  58. public void datagrid(HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
  59. Map<String, String> param = new HashMap<>();
  60. for (String key : request.getParameterMap().keySet()) {
  61. param.put(key, request.getParameter(key));
  62. }
  63. DataPage result = superivseService.superivseList(request,param);
  64. TagUtil.datagrid(response, dataGrid, result);
  65. }
  66. @RequestMapping(params = "goCheck")
  67. public ModelAndView goCheck(HttpServletRequest request) {
  68. String id = request.getParameter("id");
  69. TBScheduleSuperivse common = superivseService.getById(id);
  70. common = scheduleImageUrl(common);
  71. request.setAttribute("userName", baseUserService.getById(common.getUserId()).getRealname());
  72. request.setAttribute("common", common);
  73. request.setAttribute("responsibleUserName", common.getResponsibleUserId());
  74. request.setAttribute("leaderUserName", common.getLeaderUserId());
  75. List<TBScheduleSuperivseRecord> list = superivseRecordService.list(new QueryWrapper<TBScheduleSuperivseRecord>() {{
  76. eq("supervise_id", id);
  77. orderByDesc("deal_date");
  78. }});
  79. request.setAttribute("list", list);
  80. if (CollectionUtils.isEmpty(list)) {
  81. request.setAttribute("noRecord", "无整改记录");
  82. }
  83. return new ModelAndView("cn/com/lzt/schedule/superivseList-update");
  84. }
  85. @RequestMapping(params = "goAdd")
  86. public ModelAndView goAdd(HttpServletRequest request) {
  87. return new ModelAndView("cn/com/lzt/schedule/superivseList-add");
  88. }
  89. public TBScheduleSuperivse scheduleImageUrl(TBScheduleSuperivse common) {
  90. if (common != null) {
  91. // add-刘梦祥-2022年1月13日19:02:31(新增视频和图片路径解析)
  92. if (common.getImgUrl() != null && StringUtils.isNotEmpty(common.getImgUrl())) {
  93. if (common.getImgUrl().contains("http") && common.getImgUrl().length() > 10) {
  94. try {
  95. List<String> imgUrlList = JSONObject.parseArray(common.getImgUrl(), String.class);
  96. common.setImgUrlList(imgUrlList);
  97. } catch (Exception e) {
  98. e.printStackTrace();
  99. }
  100. } else {
  101. List<String> imgUrlList = new ArrayList<>();
  102. if (!"[null]".equals(common.getImgUrl()) && !"[]".equals(common.getImgUrl())) {
  103. imgUrlList.add("http://47.100.210.233/" + common.getImgUrl());
  104. common.setImgUrlList(imgUrlList);
  105. }
  106. }
  107. }
  108. if (common.getVideos() != null && StringUtils.isNotEmpty(common.getVideos())) {
  109. if (common.getVideos().contains("http")) {
  110. try {
  111. List<String> videosList = JSONObject.parseArray(common.getVideos(), String.class);
  112. common.setVideosList(videosList);
  113. } catch (Exception e) {
  114. e.printStackTrace();
  115. }
  116. } else {
  117. List<String> videosList = new ArrayList<>();
  118. if (!"[null]".equals(common.getVideos()) && !"[]".equals(common.getVideos())) {
  119. videosList.add("http://47.100.210.233/" + common.getVideos());
  120. common.setVideosList(videosList);
  121. }
  122. }
  123. }
  124. if (StringUtils.isNotEmpty(common.getResponsibleUserId())) {
  125. String getUserRealNameSql = "select realname from t_s_base_user where id = ?";
  126. Map<String, Object> userData = systemService.findOneForJdbc(getUserRealNameSql, common.getResponsibleUserId());
  127. if (userData != null && userData.containsKey("realname")) {
  128. common.setResponsibleUserId(String.valueOf(userData.get("realname")));
  129. }
  130. }
  131. if (StringUtils.isNotEmpty(common.getLeaderUserId())) {
  132. String getUserRealNameSql = "select realname from t_s_base_user where id = ?";
  133. Map<String, Object> userData = systemService.findOneForJdbc(getUserRealNameSql, common.getLeaderUserId());
  134. if (userData != null && userData.containsKey("realname")) {
  135. common.setLeaderUserId(String.valueOf(userData.get("realname")));
  136. }
  137. }
  138. }
  139. return common;
  140. }
  141. @RequestMapping(params = "goUpdate")
  142. public ModelAndView goUpdate(HttpServletRequest request) {
  143. String id = request.getParameter("id");
  144. TBScheduleSuperivse common = superivseService.getById(id);
  145. common = scheduleImageUrl(common);
  146. request.setAttribute("userName", baseUserService.getById(common.getUserId()).getRealname());
  147. request.setAttribute("common", common);
  148. request.setAttribute("responsibleUserName", common.getResponsibleUserId());
  149. request.setAttribute("leaderUserName", common.getLeaderUserId());
  150. return new ModelAndView("cn/com/lzt/schedule/superivseList-update");
  151. }
  152. @RequestMapping(params = "statusUpdate")
  153. public ModelAndView statusUpdate(HttpServletRequest request) {
  154. String id = request.getParameter("id");
  155. TBScheduleSuperivse common = superivseService.getById(id);
  156. common = scheduleImageUrl(common);
  157. request.setAttribute("common", common);
  158. return new ModelAndView("cn/com/lzt/schedule/superivseList-statusUpdate");
  159. }
  160. @RequestMapping(params = "doNoDeal")
  161. @ResponseBody
  162. public AjaxJson doNoDeal(TBScheduleSuperivse common, HttpServletRequest request) {
  163. String message = null;
  164. AjaxJson j = new AjaxJson();
  165. message = "修改成功";
  166. j.setSuccess(true);
  167. try {
  168. common = superivseService.getById(common.getId());
  169. if("3".equals(common.getStatus())){
  170. common.setDealStatus("3");
  171. common.setStatus("4");
  172. }else{
  173. common.setDealStatus("3");
  174. }
  175. superivseService.updateById(common);
  176. } catch (Exception e) {
  177. e.printStackTrace();
  178. message = "修改失败";
  179. j.setSuccess(false);
  180. throw new BusinessException(e.getMessage());
  181. }
  182. j.setMsg(message);
  183. return j;
  184. }
  185. /**
  186. * 督查管理确认按钮
  187. * 如果状态状态为3:只有经办人能看到或操作确认、退回按钮。状态修改为5(整改完))。
  188. * @author 刘梦祥
  189. * @Date 2022年11月28日16:43:33
  190. * @param common 督查管理记录实体类
  191. * @param request HttpServletRequest
  192. * @return AjaxJson
  193. */
  194. @RequestMapping(params = "doConfirm")
  195. @ResponseBody
  196. public AjaxJson doConfirm(TBScheduleSuperivse common, HttpServletRequest request) {
  197. String message = null;
  198. AjaxJson j = new AjaxJson();
  199. message = "修改成功";
  200. j.setSuccess(true);
  201. try {
  202. common = superivseService.getById(common.getId());
  203. TSUser user = ResourceUtil.getSessionUser();
  204. if("3".equals(common.getStatus()) && common.getUserId() != null){
  205. common.setStatus("5");
  206. superivseService.updateById(common);
  207. sysMsgService.saveSysMsg(Globals.MSG_TITLE_2,Globals.MSG_CONTENT_3,user.getId(),common.getResponsibleUserId());
  208. sysMsgService.saveSysMsgToDepart(Globals.MSG_TITLE_2,Globals.MSG_CONTENT_3,user.getId(),common.getResponsibleUserId());
  209. }else{
  210. j.setSuccess(false);
  211. message = "修改失败,请刷新后重试!";
  212. }
  213. } catch (Exception e) {
  214. e.printStackTrace();
  215. message = "修改失败";
  216. j.setSuccess(false);
  217. throw new BusinessException(e.getMessage());
  218. }
  219. j.setMsg(message);
  220. return j;
  221. }
  222. /**
  223. * 督查管理退回按钮
  224. * 如果状态状态为3:只有经办人能看到或操作确认、退回按钮。状态修改为1(初始状态:整改中)
  225. * @author 刘梦祥
  226. * @Date 2022年11月28日16:43:33
  227. * @param common 督查管理记录实体类
  228. * @param request HttpServletRequest
  229. * @return AjaxJson
  230. */
  231. @RequestMapping(params = "doBack")
  232. @ResponseBody
  233. public AjaxJson doBack(TBScheduleSuperivse common, HttpServletRequest request) {
  234. String message = null;
  235. AjaxJson j = new AjaxJson();
  236. message = "修改成功";
  237. j.setSuccess(true);
  238. try {
  239. common = superivseService.getById(common.getId());
  240. TSUser user = ResourceUtil.getSessionUser();
  241. if("3".equals(common.getStatus()) && common.getUserId() != null){
  242. common.setStatus("1");
  243. superivseService.updateById(common);
  244. sysMsgService.saveSysMsg(Globals.MSG_TITLE_2,Globals.MSG_CONTENT_4,user.getId(),common.getResponsibleUserId());
  245. sysMsgService.saveSysMsgToDepart(Globals.MSG_TITLE_2,Globals.MSG_CONTENT_4,user.getId(),common.getResponsibleUserId());
  246. }else{
  247. j.setSuccess(false);
  248. message = "修改失败,请刷新后重试!";
  249. }
  250. } catch (Exception e) {
  251. e.printStackTrace();
  252. message = "修改失败";
  253. j.setSuccess(false);
  254. throw new BusinessException(e.getMessage());
  255. }
  256. j.setMsg(message);
  257. return j;
  258. }
  259. @RequestMapping(params = "doUpdate")
  260. @ResponseBody
  261. public AjaxJson doUpdate(TBScheduleSuperivse common, HttpServletRequest request) {
  262. String message = null;
  263. AjaxJson j = new AjaxJson();
  264. message = "修改成功";
  265. j.setSuccess(true);
  266. try {
  267. common.setUpdateDate(getNowDateTime());
  268. //整改时间
  269. if (common.getResultUrl() != null) {
  270. common.setDealDate(getNowDateTime());
  271. TBScheduleSuperivseRecord record = new TBScheduleSuperivseRecord();
  272. record.setDealDate(getNowDateTime());
  273. record.setImgUrl(common.getResultUrl());
  274. record.setSuperviseId(common.getId());
  275. superivseRecordService.save(record);
  276. }
  277. //确认时间
  278. if (common.getStatus() == "2") {
  279. common.setConfirmDate(getNowDateTime());
  280. }
  281. Map<String, String> param = new HashMap<>();
  282. for (String key : request.getParameterMap().keySet()) {
  283. param.put(key, request.getParameter(key));
  284. }
  285. String pageTag = param.get("pageTag");
  286. if(StringUtils.isNotEmpty(pageTag) && "rectification".equals(pageTag)){
  287. common.setDealStatus("2");
  288. }
  289. superivseService.updateById(common);
  290. } catch (Exception e) {
  291. e.printStackTrace();
  292. message = "修改失败";
  293. j.setSuccess(false);
  294. throw new BusinessException(e.getMessage());
  295. }
  296. j.setMsg(message);
  297. return j;
  298. }
  299. @RequestMapping(params = "doAdd")
  300. @ResponseBody
  301. public AjaxJson doAdd(TBScheduleSuperivse common, HttpServletRequest request) {
  302. String message = null;
  303. AjaxJson j = new AjaxJson();
  304. message = "添加成功";
  305. j.setSuccess(true);
  306. try {
  307. // update-刘梦祥-2022年11月28日16:30:21(经确认新增的督查表单默认状态为待确认即数据字典中的2)
  308. common.setStatus("2");
  309. common.setCreateDate(getNowDateTime());
  310. common.setUpdateDate(getNowDateTime());
  311. common.setCode(OrderNumTools.generateNextBillCode("DC" + getNowDate(), 10, "t_b_schedule_superivse", "code", 4));
  312. superivseService.save(common);
  313. // add-刘梦祥-2022年11月28日16:12:35(经确认当用户添加督查管理表单时,需要提示用户)
  314. sysMsgService.saveSysMsg(Globals.MSG_TITLE_2,Globals.MSG_CONTENT_2,common.getUserId(),common.getResponsibleUserId());
  315. sysMsgService.saveSysMsgToDepart(Globals.MSG_TITLE_2,Globals.MSG_CONTENT_2,common.getUserId(),common.getResponsibleUserId());
  316. } catch (Exception e) {
  317. e.printStackTrace();
  318. message = "添加失败";
  319. j.setSuccess(false);
  320. throw new BusinessException(e.getMessage());
  321. }
  322. j.setMsg(message);
  323. return j;
  324. }
  325. private static SimpleDateFormat sdfDate = new SimpleDateFormat("yyyyMMdd");
  326. private static SimpleDateFormat sdfTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  327. public static String getNowDate() {
  328. Date now = new Date();
  329. String time = sdfDate.format(now);
  330. return time;
  331. }
  332. public static String getNowDateTime() {
  333. Date now = new Date();
  334. String time = sdfTime.format(now);
  335. return time;
  336. }
  337. @RequestMapping(params = "doDel")
  338. @ResponseBody
  339. public AjaxJson doDel(TBScheduleSuperivse common, HttpServletRequest request) {
  340. String message = null;
  341. AjaxJson j = new AjaxJson();
  342. message = "档案删除成功";
  343. try {
  344. superivseService.removeById(common);
  345. } catch (Exception e) {
  346. e.printStackTrace();
  347. message = "档案删除失败";
  348. throw new BusinessException(e.getMessage());
  349. }
  350. j.setMsg(message);
  351. return j;
  352. }
  353. @RequestMapping(params = "getName")
  354. @ResponseBody
  355. public List getName(HttpServletRequest request) {
  356. String name = request.getParameter("name");
  357. String sql = "select ID,realname from t_s_base_user where 1=1";
  358. if (!StringUtil.isEmpty(name)) {
  359. sql += " and realname like '%" + name + "%'";
  360. }
  361. List<Object[]> list = systemService.findListbySql(sql);
  362. List<Map<String, String>> values = list.stream().map(e -> {
  363. Map<String, String> map = new HashMap();
  364. map.put("code", e[0].toString());
  365. map.put("name", e[1].toString());
  366. return map;
  367. }).collect(Collectors.toList());
  368. return values;
  369. }
  370. }