ImageManagementController.java 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. package cn.com.lzt.car.jobImageManagement.controller;
  2. import cn.afterturn.easypoi.entity.vo.NormalExcelConstants;
  3. import cn.com.lzt.car.jobImageManagement.entity.TBCarShoot;
  4. import cn.com.lzt.car.jobImageManagement.service.jobImageManagementService;
  5. import com.alibaba.fastjson.JSONObject;
  6. import org.apache.commons.lang.xwork.StringUtils;
  7. import org.apache.log4j.Logger;
  8. import org.jeecgframework.core.common.controller.BaseController;
  9. import org.jeecgframework.core.common.exception.BusinessException;
  10. import org.jeecgframework.core.common.hibernate.qbc.CriteriaQuery;
  11. import org.jeecgframework.core.common.model.json.AjaxJson;
  12. import org.jeecgframework.core.common.model.json.DataGrid;
  13. import org.jeecgframework.core.constant.Globals;
  14. import org.jeecgframework.core.util.JeecgDataAutorUtils;
  15. import org.jeecgframework.core.util.MyBeanUtils;
  16. import org.jeecgframework.core.util.ResourceUtil;
  17. import org.jeecgframework.core.util.StringUtil;
  18. import org.jeecgframework.tag.core.easyui.TagUtil;
  19. import org.jeecgframework.tag.vo.datatable.SortDirection;
  20. import org.jeecgframework.web.system.pojo.base.TSType;
  21. import org.jeecgframework.web.system.service.SystemService;
  22. import org.springframework.beans.factory.annotation.Autowired;
  23. import org.springframework.stereotype.Controller;
  24. import org.springframework.ui.ModelMap;
  25. import org.springframework.web.bind.annotation.RequestMapping;
  26. import org.springframework.web.bind.annotation.ResponseBody;
  27. import org.springframework.web.servlet.ModelAndView;
  28. import javax.annotation.Resource;
  29. import javax.servlet.http.HttpServletRequest;
  30. import javax.servlet.http.HttpServletResponse;
  31. import java.util.ArrayList;
  32. import java.util.HashMap;
  33. import java.util.List;
  34. import java.util.Map;
  35. /**
  36. * @author LiuMengxiang
  37. * @version V1.0
  38. * @Title: Controller
  39. * @Description: 作业车辆-抓拍图片管理
  40. * @date 2021年11月11日16:06:49
  41. */
  42. @Controller
  43. @RequestMapping("/imageManagementController")
  44. public class ImageManagementController extends BaseController {
  45. /**
  46. * Logger for this class
  47. */
  48. private static final Logger logger = Logger.getLogger(ImageManagementController.class);
  49. @Resource
  50. private jobImageManagementService jobImageManagementService;
  51. @Autowired
  52. private SystemService systemService;
  53. /***
  54. * 页面跳转到抓拍筛选index页面
  55. * @author 刘梦祥
  56. * @date 2021年11月12日10:30:08
  57. * @param request
  58. * @return ModelAndView
  59. */
  60. @RequestMapping(params = "screeningIndex")
  61. public ModelAndView screeningIndex(HttpServletRequest request) {
  62. return new ModelAndView("cn/com/lzt/jobimage/management/screeningList");
  63. }
  64. /***
  65. * 页面跳转到抓拍存证index页面
  66. * @author 刘梦祥
  67. * @date 2021年11月12日17:46:19
  68. * @param request
  69. * @return ModelAndView
  70. */
  71. @RequestMapping(params = "depositCertificateIndex")
  72. public ModelAndView depositCertificateIndex(HttpServletRequest request) {
  73. return new ModelAndView("cn/com/lzt/jobimage/management/depositCertificateList");
  74. }
  75. /***
  76. * 页面跳转到录像回放index页面
  77. * @author 刘梦祥
  78. * @date 2021年11月15日15:37:36
  79. * @param request
  80. * @return ModelAndView
  81. */
  82. @RequestMapping(params = "videoPlaybackIndex")
  83. public ModelAndView videoPlaybackIndex(HttpServletRequest request) {
  84. return new ModelAndView("cn/com/lzt/jobimage/management/videoPlaybackList2");
  85. }
  86. /**
  87. * 初始化请求接口
  88. *
  89. * @param tBCarShoot
  90. * @param request
  91. * @param response
  92. * @param dataGrid
  93. * @author 刘梦祥
  94. * @date 2021年11月12日10:29:43
  95. */
  96. @RequestMapping(params = "datagrid")
  97. public void datagrid(TBCarShoot tBCarShoot, HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
  98. CriteriaQuery cq = new CriteriaQuery(TBCarShoot.class, dataGrid);
  99. String plateNo = request.getParameter("plateNo");
  100. // 查询条件组装器-车牌号
  101. tBCarShoot.setPlateNo(null);
  102. if (StringUtils.isNotBlank(plateNo)) {
  103. cq.like("plateNo", "%" + plateNo + "%");
  104. }
  105. String position = request.getParameter("position");
  106. // 查询条件组装器-抓拍位置
  107. tBCarShoot.setPosition(null);
  108. if (StringUtils.isNotBlank(position)) {
  109. cq.like("position", "%" + position + "%");
  110. }
  111. String type = request.getParameter("type");
  112. // 查询条件组装器-车辆类型
  113. tBCarShoot.setType(null);
  114. if (StringUtils.isNotBlank(type)) {
  115. // 模糊查询
  116. cq.eq("type", type);
  117. }
  118. String camera = request.getParameter("camera");
  119. // 查询条件组装器-摄像头位置
  120. if (StringUtils.isNotBlank(camera)) {
  121. // 模糊查询
  122. cq.eq("camera", Integer.valueOf(camera));
  123. tBCarShoot.setCamera(null);
  124. }
  125. String status = request.getParameter("status");
  126. // 查询条件组装器-存证状态
  127. if (StringUtils.isNotBlank(status)) {
  128. // 模糊查询
  129. cq.eq("status", Integer.valueOf(status));
  130. tBCarShoot.setStatus(null);
  131. }
  132. Map<String,Object> map = new HashMap<>();
  133. map.put("uploadTime", "desc");
  134. cq.setOrder(map);
  135. //查询条件组装器
  136. org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, tBCarShoot, request.getParameterMap());
  137. cq.add();
  138. this.jobImageManagementService.getDataGridReturn(cq, true);
  139. List<TBCarShoot> tBCarShootData = dataGrid.getResults();
  140. // 得到文件服务器地址
  141. TSType tsType = systemService.getType("JobFileServerIpAddress","serverAddress");
  142. TSType tsType2 = systemService.getType("JobFileServerPortAddress","serverAddress");
  143. //查询出所有的车辆类型
  144. String getAllCarTypeList = "select * from t_s_type where typegroupid = (select id from t_s_typegroup where typegroupcode = \"cartype\");";
  145. List<Map<String,Object>> allCarTypeList = this.systemService.findForJdbc(getAllCarTypeList);
  146. Map<String,String> allCarTypeMap = new HashMap<>();
  147. if(allCarTypeList != null && allCarTypeList.size() > 0){
  148. for (Map<String,Object> carTypeItem : allCarTypeList){
  149. if(carTypeItem.containsKey("typecode") && carTypeItem.containsKey("typename") && carTypeItem.get("typecode") != null && carTypeItem.get("typename") != null){
  150. allCarTypeMap.put(String.valueOf(carTypeItem.get("typecode")),String.valueOf(carTypeItem.get("typename")));
  151. }
  152. }
  153. }
  154. for (TBCarShoot tbCarShoot : tBCarShootData){
  155. if(StringUtil.isNotEmpty(tbCarShoot.getType()) && allCarTypeMap.containsKey(tbCarShoot.getType())){
  156. tbCarShoot.setType(allCarTypeMap.get(tbCarShoot.getType()));
  157. }else{
  158. tbCarShoot.setType("未知车辆类型");
  159. }
  160. if(StringUtil.isNotEmpty(tbCarShoot.getShoot()) && !tbCarShoot.getShoot().contains("http")){
  161. tbCarShoot.setShoot(tsType.getTypename().concat(tsType2.getTypename()).concat(tbCarShoot.getShoot()));
  162. }
  163. }
  164. dataGrid.setResults(tBCarShootData);
  165. TagUtil.datagrid(response, dataGrid);
  166. }
  167. /**
  168. * 车辆抓拍档案存证更新(同时支持批量操作)
  169. *
  170. * @param
  171. * @return AjaxJson
  172. * @author 刘梦祥
  173. * @date 2021年11月12日10:30:38
  174. */
  175. @RequestMapping(params = "depositCertificate")
  176. @ResponseBody
  177. public AjaxJson depositCertificate(TBCarShoot tBCarShoot) {
  178. String message = null;
  179. AjaxJson j = new AjaxJson();
  180. try {
  181. // 批量对象操作
  182. if (tBCarShoot.getCheckIds() != null && tBCarShoot.getCheckIds().length() > 0) {
  183. String[] checkidsList = tBCarShoot.getCheckIds().split(",");
  184. for (String checkId : checkidsList) {
  185. TBCarShoot t = jobImageManagementService.get(TBCarShoot.class, checkId);
  186. // 防止多用户操作同一对象导致重复操作出现异常
  187. if (t != null) {
  188. MyBeanUtils.copyBeanNotNull2Bean(tBCarShoot, t);
  189. t.setStatus(1);
  190. jobImageManagementService.saveOrUpdate(t);
  191. message = "车辆抓拍档案更新成功";
  192. systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
  193. }
  194. }
  195. } else {
  196. // 单个对象操作
  197. TBCarShoot t = jobImageManagementService.get(TBCarShoot.class, tBCarShoot.getId());
  198. MyBeanUtils.copyBeanNotNull2Bean(tBCarShoot, t);
  199. t.setStatus(1);
  200. jobImageManagementService.saveOrUpdate(t);
  201. message = "车辆抓拍档案更新成功";
  202. systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
  203. }
  204. } catch (Exception e) {
  205. e.printStackTrace();
  206. throw new BusinessException(e.getMessage());
  207. }
  208. j.setMsg(message);
  209. return j;
  210. }
  211. /**
  212. * 车辆抓拍档案存证删除(同时支持批量操作)
  213. *
  214. * @return AjaxJson
  215. * @author 刘梦祥
  216. * @date 2021年11月12日10:31:40
  217. */
  218. @RequestMapping(params = "delDepositCertificate")
  219. @ResponseBody
  220. public AjaxJson delDepositCertificate(TBCarShoot tBCarShoot) {
  221. String message = null;
  222. AjaxJson j = new AjaxJson();
  223. try {
  224. // 批量对象操作
  225. if (tBCarShoot.getCheckIds() != null && tBCarShoot.getCheckIds().length() > 0) {
  226. String[] checkidsList = tBCarShoot.getCheckIds().split(",");
  227. for (String checkId : checkidsList) {
  228. TBCarShoot t = jobImageManagementService.get(TBCarShoot.class, checkId);
  229. // 防止多用户操作同一对象导致重复操作出现异常
  230. if (t != null) {
  231. jobImageManagementService.delete(t);
  232. message = "车辆抓拍档案删除成功";
  233. systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
  234. }
  235. }
  236. } else {
  237. // 单个对象操作
  238. tBCarShoot = systemService.getEntity(TBCarShoot.class, tBCarShoot.getId());
  239. jobImageManagementService.delete(tBCarShoot);
  240. message = "车辆抓拍档案删除成功";
  241. systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
  242. }
  243. } catch (Exception e) {
  244. e.printStackTrace();
  245. throw new BusinessException(e.getMessage());
  246. }
  247. j.setMsg(message);
  248. return j;
  249. }
  250. /**
  251. * 批量导出数据
  252. *
  253. * @param tBCarShoot
  254. * @return
  255. * @author 刘梦祥
  256. * @date 2021年11月15日13:17:24
  257. */
  258. @RequestMapping(params = "exportXls")
  259. public String exportXls(TBCarShoot tBCarShoot, HttpServletResponse response, HttpServletRequest request, DataGrid dataGrid, ModelMap modelMap) {
  260. String pageType = request.getParameter("pageType");
  261. modelMap.put(NormalExcelConstants.FILE_NAME, "jobImageManagementListTable".equals(pageType) ? "抓拍图片存证管理" : "抓拍录像管理");
  262. modelMap.put(NormalExcelConstants.CLASS, TBCarShoot.class);
  263. modelMap.put(NormalExcelConstants.PARAMS, new cn.afterturn.easypoi.excel.entity.ExportParams( "jobImageManagementListTable".equals(pageType) ? "抓拍图片存证管理列表" : "抓拍录像管理列表", "导出人:" + ResourceUtil.getSessionUser().getRealName(),
  264. "导出信息"));
  265. //批量对象操作
  266. List<TBCarShoot> list = new ArrayList<>();
  267. if (tBCarShoot.getCheckIds() != null && tBCarShoot.getCheckIds().length() > 0) {
  268. // 得到文件服务器地址
  269. TSType tsType = systemService.getType("JobFileServerIpAddress","serverAddress");
  270. TSType tsType2 = systemService.getType("JobFileServerPortAddress","serverAddress");
  271. //查询出所有的车辆类型
  272. String getAllCarTypeList = "select * from t_s_type where typegroupid = (select id from t_s_typegroup where typegroupcode = \"cartype\");";
  273. List<Map<String,Object>> allCarTypeList = this.systemService.findForJdbc(getAllCarTypeList);
  274. Map<String,String> allCarTypeMap = new HashMap<>();
  275. if(allCarTypeList != null && allCarTypeList.size() > 0){
  276. for (Map<String,Object> carTypeItem : allCarTypeList){
  277. if(carTypeItem.containsKey("typecode") && carTypeItem.containsKey("typename") && carTypeItem.get("typecode") != null && carTypeItem.get("typename") != null){
  278. allCarTypeMap.put(String.valueOf(carTypeItem.get("typecode")),String.valueOf(carTypeItem.get("typename")));
  279. }
  280. }
  281. }
  282. String[] checkidsList = tBCarShoot.getCheckIds().split(",");
  283. for (String checkId : checkidsList) {
  284. TBCarShoot t = jobImageManagementService.get(TBCarShoot.class, checkId);
  285. //防止多用户操作同一对象导致重复操作出现异常
  286. if (t != null) {
  287. TBCarShoot tBCarShoot1 = JSONObject.parseObject(JSONObject.toJSONString(t), TBCarShoot.class);
  288. if(tBCarShoot1.getCamera() != null){
  289. switch (tBCarShoot1.getCamera()){
  290. case 1:
  291. tBCarShoot1.setCameraStr("前置");
  292. break;
  293. case 2:
  294. tBCarShoot1.setCameraStr("后置");
  295. break;
  296. case 3:
  297. tBCarShoot1.setCameraStr("驾驶室");
  298. break;
  299. default:
  300. tBCarShoot1.setCameraStr("未知");
  301. break;
  302. }
  303. }
  304. // 转换车辆类型
  305. if(StringUtil.isNotEmpty(tBCarShoot1.getType()) && allCarTypeMap.containsKey(tBCarShoot1.getType())){
  306. tBCarShoot1.setType(allCarTypeMap.get(tBCarShoot1.getType()));
  307. }else{
  308. tBCarShoot1.setType("未知车辆类型");
  309. }
  310. // 转换文件路径
  311. if(StringUtil.isNotEmpty(tBCarShoot1.getShoot()) && !tBCarShoot1.getShoot().contains("http")){
  312. tBCarShoot1.setShoot(tsType.getTypename().concat(tsType2.getTypename()).concat(tBCarShoot1.getShoot()));
  313. }
  314. list.add(tBCarShoot1);
  315. }
  316. }
  317. }
  318. modelMap.put(NormalExcelConstants.DATA_LIST, list);
  319. return NormalExcelConstants.EASYPOI_EXCEL_VIEW;
  320. }
  321. }