| | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.http.HttpRequest; |
| | | import cn.hutool.http.HttpResponse; |
| | | import cn.hutool.json.JSONObject; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.javaweb.cms.util.CmsConstants; |
| | | import com.javaweb.common.core.domain.AjaxResult; |
| | | import com.javaweb.common.utils.Arith; |
| | | import com.javaweb.common.utils.StringUtils; |
| | | import com.javaweb.geo.domain.Hole; |
| | | import com.javaweb.geo.domain.Project; |
| | | import com.javaweb.geo.mapper.HoleMapper; |
| | | import com.javaweb.geo.service.IProjectService; |
| | | import com.javaweb.geo.domain.*; |
| | | import com.javaweb.geo.enums.RecordType; |
| | | import com.javaweb.geo.mapper.ProjectCameraMapper; |
| | | import com.javaweb.geo.mapper.TubLogMapper; |
| | | import com.javaweb.geo.service.*; |
| | | import com.javaweb.geo.vo.DrillDateVo; |
| | | import com.javaweb.geo.vo.IndexVo; |
| | | import com.javaweb.geo.vo.ProjectProcessVO; |
| | | import com.javaweb.system.service.ISysConfigService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.ui.ModelMap; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import com.javaweb.common.config.Global; |
| | | import com.javaweb.common.core.controller.BaseController; |
| | | import com.javaweb.framework.util.ShiroUtils; |
| | |
| | | import com.javaweb.system.service.ISysMenuService; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | /** |
| | | * 首页 业务处理 |
| | | * |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Controller |
| | | public class SysIndexController extends BaseController |
| | | { |
| | | public class SysIndexController extends BaseController { |
| | | |
| | | private String prefix = "system/camera_tub"; |
| | | |
| | | |
| | | private String appkey = "af786eacc71d43ef9393c028cf4face7"; |
| | | private String secret = "9ad87671f63d2258af6fd9b2e5fa6005"; |
| | | private String postUrl ="https://open.ys7.com/api/lapp/token/get"; |
| | | |
| | | @Autowired |
| | | private ISysMenuService menuService; |
| | | |
| | |
| | | private IProjectService projectService; |
| | | |
| | | @Autowired |
| | | private HoleMapper holeMapper; |
| | | private IHoleService holeService; |
| | | |
| | | private String getAdminIndex(){ |
| | | @Autowired |
| | | private IHoleMediaService holeMediaService; |
| | | |
| | | @Autowired |
| | | private TubLogMapper tubLogMapper; |
| | | |
| | | @Autowired |
| | | private ProjectCameraMapper projectCameraMapper; |
| | | |
| | | @Autowired |
| | | private IProjectCameraService cameraService; |
| | | |
| | | @Autowired |
| | | private IHoleLogService holeLogService; |
| | | |
| | | |
| | | private String getAdminIndex() { |
| | | return configService.selectConfigByKey(CmsConstants.KEY_ADMIN_INDEX); |
| | | } |
| | | |
| | |
| | | return "forward:/index"; |
| | | } |
| | | |
| | | @RequestMapping("/system/camera") |
| | | public String cameraList() { |
| | | return prefix + "/camera_list"; |
| | | } |
| | | |
| | | @RequestMapping("/system/tub") |
| | | public String tubList() { |
| | | return prefix + "/tub_list"; |
| | | } |
| | | |
| | | // 系统首页 |
| | | @GetMapping("/index") |
| | | public String index(ModelMap mmap) |
| | | { |
| | | public String index(ModelMap mmap) { |
| | | // 取身份信息 |
| | | SysUser user = ShiroUtils.getSysUser(); |
| | | // 根据用户id取出菜单 |
| | |
| | | mmap.put("demoEnabled", Global.isDemoEnabled()); |
| | | |
| | | String indePage = this.getAdminIndex(); |
| | | if(CmsConstants.ADMIN_INDEX_TOP_MENU.equals(indePage)){ |
| | | if (CmsConstants.ADMIN_INDEX_TOP_MENU.equals(indePage)) { |
| | | return CmsConstants.ADMIN_INDEX_TOP_MENU; // index_topMenu |
| | | }else{ |
| | | } else { |
| | | return "index"; |
| | | } |
| | | } |
| | |
| | | // 系统首页顶部菜单 |
| | | @PostMapping("/index/getMenu") |
| | | @ResponseBody |
| | | public AjaxResult getMenu(HttpServletRequest request) |
| | | { |
| | | public AjaxResult getMenu(HttpServletRequest request) { |
| | | // 取身份信息 |
| | | SysUser user = ShiroUtils.getSysUser(); |
| | | // 根据用户id取出菜单 |
| | | List<SysMenu> menus = menuService.selectMenusByUser(user); |
| | | return AjaxResult.success(menus); |
| | | } |
| | | |
| | | // 切换主题 |
| | | @GetMapping("/system/switchSkin") |
| | | public String switchSkin(ModelMap mmap) |
| | | { |
| | | public String switchSkin(ModelMap mmap) { |
| | | return "skin"; |
| | | } |
| | | |
| | | |
| | | // 系统介绍 |
| | | @GetMapping("/system/main") |
| | | public String main(ModelMap mmap) |
| | | { |
| | | public String main(ModelMap mmap) { |
| | | mmap.put("version", Global.getVersion()); |
| | | |
| | | |
| | | String loginname = ShiroUtils.getLoginName(); |
| | | mmap.put("loginuser",loginname); |
| | | return "main"; |
| | | } |
| | | |
| | | // 系统介绍 |
| | | @ResponseBody |
| | | @GetMapping("/system/project") |
| | | public AjaxResult project() |
| | | { |
| | | @GetMapping("/system/stat/project") |
| | | public AjaxResult project() { |
| | | AjaxResult ajaxResult = AjaxResult.success(); |
| | | List<Project> projects = projectService.selectProjectList(new Project()); |
| | | ajaxResult.put("projects",projects); |
| | | ajaxResult.put("projects", projects); |
| | | return ajaxResult; |
| | | } |
| | | |
| | | /** |
| | | * 总进度 |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @GetMapping("/system/totalProcess") |
| | | public AjaxResult totalProcess() |
| | | { |
| | | @GetMapping("/system/stat/totalProcess") |
| | | public AjaxResult totalProcess() { |
| | | AjaxResult ajaxResult = AjaxResult.success(); |
| | | Hole hole = holeMapper.selectHoleTotalProcess(); |
| | | Double data = Arith.div(hole.getFootageCpl(),hole.getFootage(),2) ; |
| | | ajaxResult.put("pointerData",data); |
| | | Hole hole = holeService.selectHoleTotalProcess(); |
| | | Double data = Arith.div(hole.getFootageCpl(), hole.getFootage(), 2); |
| | | ajaxResult.put("pointerData", data); |
| | | return ajaxResult; |
| | | } |
| | | |
| | |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @GetMapping("/system/projectProcess") |
| | | public AjaxResult projectProcess() |
| | | { |
| | | @GetMapping("/system/stat/projectProcess") |
| | | public AjaxResult projectProcess() { |
| | | AjaxResult ajaxResult = AjaxResult.success(); |
| | | List<Hole> holes = holeMapper.selectHoleProjectProcess(); |
| | | Map<String,Double> holeMap = new HashMap<>(); |
| | | for(Hole hole : holes){ |
| | | Double val = Arith.div(hole.getFootageCpl(),hole.getFootage(),2) ; |
| | | val = Arith.round(val * 100,2); |
| | | holeMap.put(hole.getProjectId(),val) ; |
| | | List<Hole> holes = holeService.selectHoleProjectProcess(); |
| | | Map<String, Double> holeMap = new HashMap<>(); |
| | | for (Hole hole : holes) { |
| | | Double val =0.0d; |
| | | if(ObjectUtil.isNotEmpty(hole.getFootageCpl()) && ObjectUtil.isNotEmpty(hole.getFootage())) { |
| | | val = Arith.div(hole.getFootageCpl(), hole.getFootage(), 2); |
| | | val = Arith.round(val * 100, 2); |
| | | } |
| | | holeMap.put(hole.getProjectId(), val); |
| | | } |
| | | |
| | | List<Project> projects = projectService.selectProjectList(new Project()); |
| | | List<ProjectProcessVO> vos = new ArrayList<>(); |
| | | for(int i = 0 ; i<projects.size();i++ ){ |
| | | String ids= projects.get(i).getIds(); |
| | | Double val = holeMap.get(ids); |
| | | ProjectProcessVO vo = new ProjectProcessVO(); |
| | | vo.setRanking(i + 1); |
| | | vo.setStation(projects.get(i).getCode()); |
| | | vo.setValue(val); |
| | | if(val==null){ |
| | | vo.setValue(0.0d); |
| | | } |
| | | vos.add(vo); |
| | | } |
| | | List<ProjectProcessVO> vos = new ArrayList<>(); |
| | | ProjectProcessVO vo; |
| | | if (!ObjectUtils.isEmpty(projects)) { |
| | | for (int i = 0; i < projects.size(); i++) { |
| | | String ids = projects.get(i).getIds(); |
| | | Double val = holeMap.get(ids); |
| | | vo = new ProjectProcessVO(); |
| | | |
| | | ajaxResult.put("projectData",vos); |
| | | vo.setIds(projects.get(i).getIds()); |
| | | vo.setRanking(i + 1); |
| | | vo.setStation(projects.get(i).getFullName()); |
| | | vo.setValue(val); |
| | | vo.setLng(projects.get(i).getLng()); |
| | | vo.setLat(projects.get(i).getLat()); |
| | | |
| | | |
| | | if (val == null) { |
| | | vo.setValue(0.0d); |
| | | } |
| | | String []statusName ={"协调中","待开工","进行中"}; |
| | | String status = projects.get(i).getStatus(); |
| | | if(status.equals("0")){ |
| | | vo.setStatus(statusName[0]); |
| | | }else if(status.equals("1")){ |
| | | vo.setStatus(statusName[1]); |
| | | }else if(status.equals("2")){ |
| | | vo.setStatus(statusName[2]); |
| | | }else{ |
| | | vo.setStatus("未知"); |
| | | } |
| | | vos.add(vo); |
| | | } |
| | | } |
| | | ajaxResult.put("projectData", vos); |
| | | return ajaxResult; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 数量统计 |
| | | * |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @GetMapping("/system/stat/indexDataCount") |
| | | public AjaxResult indexDataCount() { |
| | | IndexVo result = new IndexVo(); |
| | | //=============================查询场地数量=============================== |
| | | List<Project> projectList = projectService.selectProjectCountByStatus(); |
| | | if (!ObjectUtils.isEmpty(projectList)) { |
| | | for (Project item : projectList) { |
| | | if (RecordType.projectStatus0.getId().equals(item.getStatus())) { |
| | | result.setProjectStatus0(item.getStatusNumber()); |
| | | } |
| | | if (RecordType.projectStatus1.getId().equals(item.getStatus())) { |
| | | result.setProjectStatus1(item.getStatusNumber()); |
| | | } |
| | | if (RecordType.projectStatus2.getId().equals(item.getStatus())) { |
| | | result.setProjectStatus2(item.getStatusNumber()); |
| | | } |
| | | } |
| | | } |
| | | if (ObjectUtils.isEmpty(result.getProjectStatus0())) { |
| | | result.setProjectStatus0(0); |
| | | } |
| | | if (ObjectUtils.isEmpty(result.getProjectStatus1())) { |
| | | result.setProjectStatus1(0); |
| | | } |
| | | if (ObjectUtils.isEmpty(result.getProjectStatus2())) { |
| | | result.setProjectStatus2(0); |
| | | } |
| | | //=============================查询进尺=============================== |
| | | Hole hole = holeService.selectHoleTotalProcess(); |
| | | result.setFootageCplCount(hole.getFootageCpl()); |
| | | result.setFootageCount(hole.getFootage()); |
| | | |
| | | //=============================查询资料=============================== |
| | | HoleMedia holeMedia = holeMediaService.selectHoleMediaNumber(); |
| | | result.setFileCount(holeMedia.getNumber()); |
| | | |
| | | Integer cameraCount = projectCameraMapper.count(); |
| | | result.setCameraCount(cameraCount); |
| | | return AjaxResult.success("查询成功",result); |
| | | } |
| | | |
| | | /** |
| | | * 统计材料的消耗 |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @GetMapping("/system/stat/tubLogData") |
| | | public AjaxResult tubLogData() { |
| | | AjaxResult ajaxResult = new AjaxResult(); |
| | | List<TubLog> tubLogs = tubLogMapper.countTubLogDate(null); |
| | | ajaxResult.put("tubLogs",tubLogs); |
| | | return ajaxResult; |
| | | } |
| | | |
| | | /** |
| | | * 获取在线摄像头的信息 |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @GetMapping("/system/stat/cameraData") |
| | | public AjaxResult cameraData() { |
| | | AjaxResult ajaxResult = new AjaxResult(); |
| | | List<ProjectCamera> cameraDataList = cameraService.selectCameraDataOnLine(); |
| | | ajaxResult.put("cameraData",cameraDataList); |
| | | return ajaxResult; |
| | | } |
| | | |
| | | /** |
| | | * 根据projectId获取在线摄像头的信息 |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @GetMapping("/system/stat/cameraData/{projectId}") |
| | | public AjaxResult cameraData2(@PathVariable("projectId") String projectId) { |
| | | AjaxResult ajaxResult = new AjaxResult(); |
| | | |
| | | ProjectCamera param = new ProjectCamera(); |
| | | param.setProjectId(projectId); |
| | | List<ProjectCamera> cameraDataList = cameraService.selectProjectCameraList(param); |
| | | if (!ObjectUtils.isEmpty(cameraDataList)){ |
| | | for (ProjectCamera item : cameraDataList) { |
| | | String url = item.getIp(); |
| | | Map<String, Object> paramMap = new HashMap<>(); |
| | | paramMap.put("appKey", appkey); |
| | | paramMap.put("appSecret", secret); |
| | | |
| | | HttpResponse response = HttpRequest.post(postUrl) .form(paramMap).execute(); |
| | | String body = response.body(); |
| | | JSONObject jsonObject = JSONUtil.parseObj(body); |
| | | String code = jsonObject.getStr("code"); |
| | | StringBuffer buffer = new StringBuffer(); |
| | | if(code.equals("200")){ |
| | | JSONObject data = (JSONObject) jsonObject.get("data"); |
| | | String token = data.getStr("accessToken"); |
| | | buffer.append("https://open.ys7.com/console/jssdk/pc.html?accessToken="); |
| | | buffer.append(token); |
| | | buffer.append("&url="); |
| | | buffer.append(url); |
| | | } |
| | | logger.debug(buffer.toString()); |
| | | item.setUrl(buffer.toString()); |
| | | } |
| | | } |
| | | ajaxResult.put("cameraDataList",cameraDataList); |
| | | return ajaxResult; |
| | | } |
| | | |
| | | /** |
| | | * 根据projectId获取在线摄像头的信息 |
| | | * @return |
| | | */ |
| | | @GetMapping("/player") |
| | | public String player(String projectId,ModelMap mmap) { |
| | | ProjectCamera param = new ProjectCamera(); |
| | | param.setProjectId(projectId); |
| | | List<ProjectCamera> cameraDataList = cameraService.selectProjectCameraList(param); |
| | | if (!ObjectUtils.isEmpty(cameraDataList)){ |
| | | for (ProjectCamera item : cameraDataList) { |
| | | String url = item.getIp(); |
| | | Map<String, Object> paramMap = new HashMap<>(); |
| | | paramMap.put("appKey", appkey); |
| | | paramMap.put("appSecret", secret); |
| | | |
| | | HttpResponse response = HttpRequest.post(postUrl) .form(paramMap).execute(); |
| | | String body = response.body(); |
| | | JSONObject jsonObject = JSONUtil.parseObj(body); |
| | | String code = jsonObject.getStr("code"); |
| | | StringBuffer buffer = new StringBuffer(); |
| | | if(code.equals("200")){ |
| | | JSONObject data = (JSONObject) jsonObject.get("data"); |
| | | String token = data.getStr("accessToken"); |
| | | buffer.append("https://open.ys7.com/console/jssdk/pc.html?accessToken="); |
| | | buffer.append(token); |
| | | buffer.append("&url="); |
| | | buffer.append(url); |
| | | } |
| | | item.setUrl(buffer.toString()); |
| | | } |
| | | } |
| | | |
| | | mmap.put("cameraDataList",cameraDataList); |
| | | return prefix + "/player2"; |
| | | } |
| | | |
| | | /** |
| | | * 统计最近10天进尺量 |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @GetMapping("/system/stat/sumHoleLog") |
| | | public AjaxResult sumHoleLog() { |
| | | AjaxResult ajaxResult = AjaxResult.success(); |
| | | List<DrillDateVo> drillDateList = holeLogService.SUMHoleLog(); |
| | | ajaxResult.put("drillDateList",drillDateList); |
| | | return ajaxResult; |
| | | } |
| | | |
| | | } |