| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375 |
- package cn.com.lzt.car.automaticCaptureManagement.controller;
- import cn.com.lzt.car.automaticCaptureManagement.entity.TBCarAutomaticCaptureManagement;
- import cn.com.lzt.car.automaticCaptureManagement.entity.TBCarShootReglas;
- import cn.com.lzt.car.automaticCaptureManagement.service.automaticCaptureManagementService;
- import com.xcgl.utils.UUID;
- import org.apache.commons.lang.xwork.StringUtils;
- import org.apache.log4j.Logger;
- import org.jeecgframework.core.common.controller.BaseController;
- import org.jeecgframework.core.common.exception.BusinessException;
- import org.jeecgframework.core.common.hibernate.qbc.CriteriaQuery;
- import org.jeecgframework.core.common.model.json.AjaxJson;
- import org.jeecgframework.core.common.model.json.DataGrid;
- import org.jeecgframework.core.constant.Globals;
- import org.jeecgframework.core.util.JeecgDataAutorUtils;
- import org.jeecgframework.core.util.ResourceUtil;
- import org.jeecgframework.tag.core.easyui.TagUtil;
- import org.jeecgframework.web.system.service.SystemService;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Controller;
- import org.springframework.transaction.annotation.Transactional;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.ResponseBody;
- import org.springframework.web.servlet.ModelAndView;
- import javax.annotation.Resource;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import java.text.SimpleDateFormat;
- import java.util.ArrayList;
- import java.util.Date;
- import java.util.List;
- import java.util.Map;
- /**
- * @author LiuMengxiang
- * @version V1.0
- * @Title: Controller
- * @Description: 自动抓拍、录像条件管理
- * @date 2021年11月16日10:03:04
- */
- @Controller
- @RequestMapping("/automaticCaptureManagementController")
- public class AutomaticCaptureManagementController extends BaseController {
- /**
- * Logger for this class
- */
- private static final Logger logger = Logger.getLogger(AutomaticCaptureManagementController.class);
- @Resource
- private automaticCaptureManagementService automaticCaptureManagementService;
- @Autowired
- private SystemService systemService;
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- /***
- * 页面跳转到自动抓拍管理index页面
- * @author 刘梦祥
- * @date 2021年11月16日10:08:25
- * @param request
- * @return ModelAndView
- */
- @RequestMapping(params = "autoSnapIndex")
- public ModelAndView autoSnapIndex(HttpServletRequest request) {
- return new ModelAndView("cn/com/lzt/jobimage/automaticCapture/autoSnapList");
- }
- /**
- * 车辆类型同步
- *
- * @author 刘梦祥
- * @Date 2021年12月30日13:44:10
- */
- public void carType() {
- // 添加操作
- String carTypeStr = "SELECT\n" +
- "\t\t\t*\n" +
- "\t\tFROM\n" +
- "\t\t\tt_s_type tsy\n" +
- "\t\tLEFT JOIN t_s_typegroup tsyg ON tsyg.id = tsy.typegroupid\n" +
- "\t\tWHERE\n" +
- "\t\t\ttsyg.typegroupcode = \"cartype\"\n" +
- "\t\tAND tsy.typename NOT IN (\n" +
- "\t\t\t\"皮卡\",\n" +
- "\t\t\t\"行政车\",\n" +
- "\t\t\t\"其他\",\n" +
- "\t\t\t\"铲车\",\n" +
- "\t\t\t\"洗桶车\"\n" +
- ") and tsy.typecode not in (select car_type_code from t_b_car_automatic_capture_management)";
- List<Map<String, Object>> carTypeData = systemService.findForJdbc(carTypeStr);
- if (carTypeData != null && carTypeData.size() > 0) {
- for (Map<String, Object> carTypeItem : carTypeData) {
- TBCarAutomaticCaptureManagement tbCarAutomaticCaptureManagement = new TBCarAutomaticCaptureManagement();
- // TBCarAutomaticCaptureManagement tbCarAutomaticCaptureManagement2 = new TBCarAutomaticCaptureManagement();
- tbCarAutomaticCaptureManagement.setCarTypeCode(carTypeItem.get("typecode").toString());
- tbCarAutomaticCaptureManagement.setCarTypeName(carTypeItem.get("typename").toString());
- tbCarAutomaticCaptureManagement.setSnapNum(0);
- tbCarAutomaticCaptureManagement.setCameraPosition(0);
- tbCarAutomaticCaptureManagement.setTimingSettings(new Date());
- tbCarAutomaticCaptureManagement.setTimingSettingsStatus("F");
- tbCarAutomaticCaptureManagement.setFixedAreaSetting("");
- tbCarAutomaticCaptureManagement.setFixedAreaSettingStatus("F");
- tbCarAutomaticCaptureManagement.setVehicleEnableSetting("");
- tbCarAutomaticCaptureManagement.setVehicleEnableSettingStatus("F");
- tbCarAutomaticCaptureManagement.setManagementType("snap");
- tbCarAutomaticCaptureManagement.setCreateUser("系统自动检查");
- tbCarAutomaticCaptureManagement.setCreateTime(new Date());
- tbCarAutomaticCaptureManagement.setId(UUID.randomUUID().toString());
- // del-刘梦祥-2022年7月4日13:25:13(录像回放页面重构、删除录像条件)
- /*tbCarAutomaticCaptureManagement2.setCarTypeCode(tbCarAutomaticCaptureManagement.getCarTypeCode());
- tbCarAutomaticCaptureManagement2.setCarTypeName(tbCarAutomaticCaptureManagement.getCarTypeName());
- tbCarAutomaticCaptureManagement2.setSnapNum(tbCarAutomaticCaptureManagement.getSnapNum());
- tbCarAutomaticCaptureManagement2.setCameraPosition(tbCarAutomaticCaptureManagement.getCameraPosition());
- tbCarAutomaticCaptureManagement2.setTimingSettings(new Date());
- tbCarAutomaticCaptureManagement2.setTimingSettingsStatus(tbCarAutomaticCaptureManagement.getTimingSettingsStatus());
- tbCarAutomaticCaptureManagement2.setFixedAreaSetting(tbCarAutomaticCaptureManagement.getFixedAreaSetting());
- tbCarAutomaticCaptureManagement2.setFixedAreaSettingStatus(tbCarAutomaticCaptureManagement.getFixedAreaSettingStatus());
- tbCarAutomaticCaptureManagement2.setVehicleEnableSetting(tbCarAutomaticCaptureManagement.getVehicleEnableSetting());
- tbCarAutomaticCaptureManagement2.setVehicleEnableSettingStatus(tbCarAutomaticCaptureManagement.getVehicleEnableSettingStatus());
- tbCarAutomaticCaptureManagement2.setManagementType("video");
- tbCarAutomaticCaptureManagement2.setCreateUser(tbCarAutomaticCaptureManagement.getCreateUser());
- tbCarAutomaticCaptureManagement2.setCreateTime(new Date());
- tbCarAutomaticCaptureManagement2.setId(UUID.randomUUID().toString());*/
- systemService.save(tbCarAutomaticCaptureManagement);
- // systemService.save(tbCarAutomaticCaptureManagement2);
- }
- }
- // 删除操作
- String carTypeDelSql = "SELECT\n" +
- "\t*\n" +
- "FROM\n" +
- "\tt_b_car_automatic_capture_management\n" +
- "WHERE\n" +
- "\tcar_type_code NOT IN (\n" +
- "\t\tSELECT\n" +
- "\t\t\ttsy.typecode\n" +
- "\t\tFROM\n" +
- "\t\t\tt_s_type tsy\n" +
- "\t\tLEFT JOIN t_s_typegroup tsyg ON tsyg.id = tsy.typegroupid\n" +
- "\t\tWHERE\n" +
- "\t\t\ttsyg.typegroupcode = \"cartype\"\n" +
- "\t\tAND tsy.typename NOT IN (\n" +
- "\t\t\t\"皮卡\",\n" +
- "\t\t\t\"行政车\",\n" +
- "\t\t\t\"其他\",\n" +
- "\t\t\t\"铲车\",\n" +
- "\t\t\t\"洗桶车\"\n" +
- "\t\t)\n" +
- "\t);";
- List<Map<String, Object>> carTypeData2 = systemService.findForJdbc(carTypeDelSql);
- if (carTypeData2 != null && carTypeData2.size() > 0) {
- for (Map<String, Object> carTypeItem : carTypeData) {
- systemService.deleteEntityById(TBCarAutomaticCaptureManagement.class, carTypeItem.get("id").toString());
- }
- }
- }
- /**
- * 摄像头转义
- * @author 刘梦祥
- * @Date 2021年12月30日16:59:52
- * @param cameraPosition
- * @param tbCarShootReglas
- */
- public void getCamaraNo1ByCameraPosition(int cameraPosition, TBCarShootReglas tbCarShootReglas) {
- if (cameraPosition - 4 >= 0) {
- // 前置摄像头
- tbCarShootReglas.setCamaraNo1(1);
- cameraPosition -= 4;
- } else {
- tbCarShootReglas.setCamaraNo1(0);
- }
- if (cameraPosition - 2 >= 0) {
- // 后置摄像头
- tbCarShootReglas.setCamaraNo3(1);
- cameraPosition -= 2;
- } else {
- tbCarShootReglas.setCamaraNo3(0);
- }
- if (cameraPosition - 1 >= 0) {
- // 驾驶室摄像头
- tbCarShootReglas.setCamaraNo2(1);
- } else {
- tbCarShootReglas.setCamaraNo2(0);
- }
- }
- /**
- * 每次查询时,都检查一下管理表和定时任务同步管理表的数据。(如果多的话,执行添加操作,如果少的话就执行删除操作)
- *
- * @author 刘梦祥
- * @Date 2021年12月30日16:27:32
- */
- public void carType2() {
- try {
- // 添加操作
- String carTypeStr = "select * from t_b_car_automatic_capture_management where CONCAT(car_type_code,IF(management_type = \"snap\",1,2)) not in (select CONCAT(car_type,`type`) from t_b_car_shoot_reglas)";
- List<Map<String, Object>> carTypeData = systemService.findForJdbc(carTypeStr);
- if (carTypeData != null && carTypeData.size() > 0) {
- for (Map<String, Object> carTypeItem : carTypeData) {
- TBCarShootReglas tbCarShootReglas = new TBCarShootReglas();
- tbCarShootReglas.setId(UUID.randomUUID().toString());
- tbCarShootReglas.setCarType(carTypeItem.get("car_type_code").toString());
- tbCarShootReglas.setNum(Integer.parseInt(carTypeItem.get("snap_num").toString()));
- tbCarShootReglas.setType("snap".equals(carTypeItem.get("management_type")) ? 1 : 2);
- int cameraPosition = Integer.parseInt(carTypeItem.get("camera_position").toString());
- getCamaraNo1ByCameraPosition(cameraPosition, tbCarShootReglas);
- if (carTypeItem.get("timing_settings") != null && StringUtils.isNotEmpty(carTypeItem.get("timing_settings").toString())) {
- tbCarShootReglas.setBeginTime(sdf.parse(carTypeItem.get("timing_settings").toString()));
- }
- tbCarShootReglas.setByTime("T".equals(carTypeItem.get("timing_settings_status").toString()) ? 1 : 0);
- tbCarShootReglas.setByArea("T".equals(carTypeItem.get("fixed_area_setting_status").toString()) ? 1 : 0);
- tbCarShootReglas.setByState("T".equals(carTypeItem.get("vehicle_enable_setting_status").toString()) ? 1 : 0);
- tbCarShootReglas.setCreateTime(new Date());
- systemService.save(tbCarShootReglas);
- }
- }
- // 删除操作
- String carTypeDelSql = "select * from t_b_car_shoot_reglas where CONCAT(car_type,`type`) not in (select CONCAT(car_type_code,IF(management_type = \"snap\",1,2)) from t_b_car_automatic_capture_management);";
- List<Map<String, Object>> carTypeData2 = systemService.findForJdbc(carTypeDelSql);
- if (carTypeData2 != null && carTypeData2.size() > 0) {
- for (Map<String, Object> carTypeItem : carTypeData) {
- systemService.deleteEntityById(TBCarShootReglas.class, carTypeItem.get("id").toString());
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- throw new BusinessException(e.getMessage());
- }
- }
- /***
- * 页面跳转到自动录像管理index页面
- * @author 刘梦祥
- * @date 2021年11月16日10:11:04
- * @param request
- * @return ModelAndView
- */
- @RequestMapping(params = "autoVideoIndex")
- public ModelAndView autoVideoIndex(HttpServletRequest request) {
- return new ModelAndView("cn/com/lzt/jobimage/automaticCapture/autoVideoList");
- }
- /**
- * 初始化请求接口
- *
- * @param tbCarAutomaticCaptureManagement
- * @param request
- * @param response
- * @param dataGrid
- * @author 刘梦祥
- * @date 2021年11月16日10:29:39
- */
- @RequestMapping(params = "datagrid")
- @Transactional(rollbackFor = Exception.class)
- public void datagrid(TBCarAutomaticCaptureManagement tbCarAutomaticCaptureManagement, HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
- // add-刘梦祥-2021年12月30日11:40:293-每次查询时,都检查一下字典表中的数据。(如果多的话,执行添加操作,如果少的话就执行删除操作)
- carType();
- // add-刘梦祥-2021年12月30日16:26:38-每次查询时,都检查一下管理表和定时任务同步管理表的数据。(如果多的话,执行添加操作,如果少的话就执行删除操作)
- carType2();
- CriteriaQuery cq = new CriteriaQuery(TBCarAutomaticCaptureManagement.class, dataGrid);
- String carTypeName = request.getParameter("carTypeName");
- // 查询条件组装器-车辆类型
- if (StringUtils.isNotBlank(carTypeName)) {
- cq.like("carTypeName", "%" + carTypeName + "%");
- tbCarAutomaticCaptureManagement.setCarTypeName(null);
- }
- //查询条件组装器
- org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, tbCarAutomaticCaptureManagement, request.getParameterMap());
- cq.add();
- automaticCaptureManagementService.getDataGridReturn(cq, true);
- TagUtil.datagrid(response, dataGrid);
- }
- /**
- * 车辆自动抓拍、录像条件管理更新
- *
- * @param
- * @return AjaxJson
- * @author 刘梦祥
- * @date 2021年11月16日10:29:47
- */
- @RequestMapping(params = "update")
- @Transactional(rollbackFor = Exception.class)
- @ResponseBody
- public AjaxJson update(TBCarAutomaticCaptureManagement tbCarAutomaticCaptureManagement) {
- String message = null;
- AjaxJson j = new AjaxJson();
- try {
- TBCarAutomaticCaptureManagement t = automaticCaptureManagementService.get(TBCarAutomaticCaptureManagement.class, tbCarAutomaticCaptureManagement.getId());
- // add-刘梦祥-2021年12月30日15:03:12-(经过确认添加关联字段)
- TBCarShootReglas tbCarShootReglas = new TBCarShootReglas();
- if (t != null && t.getCarTypeCode() != null && t.getManagementType() != null) {
- CriteriaQuery criteriaQuery = new CriteriaQuery(TBCarShootReglas.class, new DataGrid());
- // snap:1,video:2
- criteriaQuery.eq("type", "snap".equals(t.getManagementType()) ? 1 : 2);
- criteriaQuery.eq("carType", t.getCarTypeCode());
- criteriaQuery.add();
- List<TBCarShootReglas> tbCarShootReglasList = systemService.getListByCriteriaQuery(criteriaQuery, true);
- if (tbCarShootReglasList != null && tbCarShootReglasList.size() == 1) {
- // 存在记录,执行更新操作
- tbCarShootReglas = tbCarShootReglasList.get(0);
- tbCarShootReglas.setUpdateTime(new Date());
- } else {
- // 不存在记录,执行新增操作
- tbCarShootReglas.setId(UUID.randomUUID().toString());
- tbCarShootReglas.setNum(t.getSnapNum());
- tbCarShootReglas.setType("snap".equals(t.getManagementType()) ? 1 : 2);
- tbCarShootReglas.setCarType(t.getCarTypeCode());
- int cameraPosition = t.getCameraPosition();
- getCamaraNo1ByCameraPosition(cameraPosition, tbCarShootReglas);
- tbCarShootReglas.setBeginTime(t.getTimingSettings());
- tbCarShootReglas.setByTime("T".equals(t.getTimingSettingsStatus()) ? 1 : 0);
- tbCarShootReglas.setByArea("T".equals(t.getFixedAreaSettingStatus()) ? 1 : 0);
- tbCarShootReglas.setByState("T".equals(t.getVehicleEnableSettingStatus()) ? 1 : 0);
- tbCarShootReglas.setCreateTime(new Date());
- }
- }
- // 抓拍数量设置接收
- if (tbCarAutomaticCaptureManagement.getSnapNum() != null) {
- t.setSnapNum(tbCarAutomaticCaptureManagement.getSnapNum());
- tbCarShootReglas.setNum(tbCarAutomaticCaptureManagement.getSnapNum());
- }
- // 摄像头设置接收
- if (tbCarAutomaticCaptureManagement.getCameraPosition() != null) {
- t.setCameraPosition(tbCarAutomaticCaptureManagement.getCameraPosition());
- int cameraPosition = tbCarAutomaticCaptureManagement.getCameraPosition();
- getCamaraNo1ByCameraPosition(cameraPosition, tbCarShootReglas);
- }
- // 定时设置
- if (tbCarAutomaticCaptureManagement.getTimingSettings() != null) {
- tbCarShootReglas.setBeginTime(tbCarAutomaticCaptureManagement.getTimingSettings());
- t.setTimingSettings(tbCarAutomaticCaptureManagement.getTimingSettings());
- }
- // 定时器设置状态
- if (tbCarAutomaticCaptureManagement.getTimingSettingsStatus() != null) {
- tbCarShootReglas.setByTime("T".equals(tbCarAutomaticCaptureManagement.getTimingSettingsStatus()) ? 1 : 0);
- t.setTimingSettingsStatus(tbCarAutomaticCaptureManagement.getTimingSettingsStatus());
- }
- // 固定区域设置
- if (tbCarAutomaticCaptureManagement.getFixedAreaSetting() != null) {
- t.setFixedAreaSetting(tbCarAutomaticCaptureManagement.getFixedAreaSetting());
- }
- // 固定区域设置状态
- if (tbCarAutomaticCaptureManagement.getFixedAreaSettingStatus() != null) {
- tbCarShootReglas.setByArea("T".equals(tbCarAutomaticCaptureManagement.getFixedAreaSettingStatus()) ? 1 : 0);
- t.setFixedAreaSettingStatus(tbCarAutomaticCaptureManagement.getFixedAreaSettingStatus());
- }
- // 车辆启动设置
- if (tbCarAutomaticCaptureManagement.getVehicleEnableSetting() != null) {
- t.setVehicleEnableSetting(tbCarAutomaticCaptureManagement.getVehicleEnableSetting());
- }
- // 车辆启动设置状态
- if (tbCarAutomaticCaptureManagement.getVehicleEnableSettingStatus() != null) {
- tbCarShootReglas.setByState("T".equals(tbCarAutomaticCaptureManagement.getVehicleEnableSettingStatus()) ? 1 : 0);
- t.setVehicleEnableSettingStatus(tbCarAutomaticCaptureManagement.getVehicleEnableSettingStatus());
- }
- // 添加更新用户信息
- t.setUpdateUser(ResourceUtil.getSessionUser().getRealName());
- systemService.saveOrUpdate(tbCarShootReglas);
- automaticCaptureManagementService.saveOrUpdate(t);
- message = "车辆自动抓拍、录像条件管理更新成功";
- systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
- } catch (Exception e) {
- e.printStackTrace();
- throw new BusinessException(e.getMessage());
- }
- j.setMsg(message);
- return j;
- }
- }
|