| | |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import io.swagger.annotations.*; |
| | | import lombok.AllArgsConstructor; |
| | | import org.omg.PortableInterceptor.INACTIVE; |
| | | import org.springblade.core.boot.ctrl.BladeController; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.jfpt.catalog.entitly.catalog; |
| | | import org.springblade.jfpt.catalog.service.catalogService; |
| | | import org.springblade.jfpt.deploy.service.IDeployService; |
| | | import org.springblade.jfpt.equipment.entity.Equipment; |
| | |
| | | import org.springblade.jfpt.equipment.vo.EquipmentVO; |
| | | import org.springblade.jfpt.equipment.vo.EquipmentVOS; |
| | | import org.springblade.jfpt.equipment.wrapper.EqWrapper; |
| | | import org.springblade.system.user.entity.User; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import springfox.documentation.annotations.ApiIgnore; |
| | | |
| | |
| | | //根据查询条件得到所有设备 |
| | | page = equipmentService.selectEquipmentPage(Condition.getPage(query), equipment, null); |
| | | } else { |
| | | List<Map<String, Object>> treedatas = catalogService.selectCatalogEqNUmber(); |
| | | List<Map<String, Object>> treedatas = catalogService.selectCatalogEqNUmber(null); |
| | | //根据传入的id递归出该节点下所有的设备 |
| | | List<Map<String, Object>> childList = treeIdList(treedatas, pid); |
| | | |
| | |
| | | //根据查询条件得到所有设备 |
| | | page = equipmentService.selectEquipmentPage(Condition.getPage(query), equipment, childList); |
| | | } else { |
| | | page = null; |
| | | List<Map<String, Object>> ces = catalogService.selectCatalogEqNUmber(pid); |
| | | List list = new ArrayList(); |
| | | list.add(ces.get(0).get("eqid")); |
| | | //根据查询条件得到所有设备 |
| | | page = equipmentService.selectEquipmentPage(Condition.getPage(query), equipment, list); |
| | | } |
| | | } |
| | | |
| | |
| | | return R.data(page); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 自定义分页 |
| | | * 自定义分页(部门挂接) |
| | | */ |
| | | @GetMapping("/page") |
| | | @GetMapping("/pageDept") |
| | | @ApiOperationSupport(order = 3) |
| | | @ApiOperation(value = "分页", notes = "传入equipment") |
| | | public R<IPage<EquipmentVO>> page(EquipmentVO equipment, Query query, String pid, HttpServletResponse response) throws ParseException { |
| | | public R<IPage<EquipmentVO>> pageDept(EquipmentVO equipment, Query query, String pid, HttpServletResponse response) throws ParseException { |
| | | response.setHeader("Access-Control-Allow-Origin", "*"); |
| | | response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); |
| | | response.setHeader("Access-Control-Allow-Credentials", "true"); |
| | | |
| | | //清空全局参数 |
| | | childMenu = new ArrayList(); |
| | | IPage<EquipmentVO> page = equipmentService.selectDeptPages(Condition.getPage(query), equipment, pid); |
| | | |
| | | //根据查询条件得到所有设备 |
| | | IPage<EquipmentVO> pageData = equipmentService.selectEquipmentPage(Condition.getPage(query), equipment, null); |
| | | for (int j = 0; j < page.getRecords().size(); j++) { |
| | | String expireTime = page.getRecords().get(j).getExpireTime(); |
| | | //1.获取当前时间 |
| | | Date dd = new Date(); |
| | | SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String end = sim.format(dd); |
| | | //把string类型转换为long类型的 |
| | | |
| | | List<EquipmentVO> pages = pageData.getRecords(); |
| | | List<EquipmentVO> datas = new ArrayList(); |
| | | |
| | | |
| | | if (pid == null || pid.equals("")) { |
| | | for (int j = 0; j < pages.size(); j++) { |
| | | String expireTime = pages.get(j).getExpireTime(); |
| | | //1.获取当前时间 |
| | | Date dd = new Date(); |
| | | SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String end = sim.format(dd); |
| | | //把string类型转换为long类型的 |
| | | if (expireTime != null){ |
| | | long st = sim.parse(expireTime).getTime(); |
| | | long en = sim.parse(end).getTime(); |
| | | //计算天数 |
| | | int day = (int) ((st - en) / 86400000); |
| | | if (day <= 30) { |
| | | pages.get(j).setType(1); |
| | | page.getRecords().get(j).setType(1); |
| | | } else { |
| | | pages.get(j).setType(0); |
| | | } |
| | | } |
| | | datas = pages; |
| | | } else { |
| | | List<Map<String, Object>> treedatas = catalogService.selectCatalogEqNUmber(); |
| | | //根据传入的id递归出该节点下所有的设备 |
| | | List<Map<String, Object>> childList = treeMenuList(treedatas, pid); |
| | | //将得到的设备与查询所得设备进行匹配 |
| | | for (int i = 0; i < childList.size(); i++) { |
| | | for (int j = 0; j < pages.size(); j++) { |
| | | String expireTime = pages.get(j).getExpireTime(); |
| | | //1.获取当前时间 |
| | | Date dd = new Date(); |
| | | SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String end = sim.format(dd); |
| | | //把string类型转换为long类型的 |
| | | long st = sim.parse(expireTime).getTime(); |
| | | long en = sim.parse(end).getTime(); |
| | | //计算天数 |
| | | int day = (int) ((st - en) / 86400000); |
| | | if (day <= 30) { |
| | | pages.get(j).setType(1); |
| | | } else { |
| | | pages.get(j).setType(0); |
| | | } |
| | | |
| | | if (childList.get(i).get("eqid") != null && !childList.get(i).get("eqid").equals("")) { |
| | | if (childList.get(i).get("eqid").equals(pages.get(j).getDeviceNumber())) { |
| | | datas.add(pages.get(j)); |
| | | } |
| | | } |
| | | page.getRecords().get(j).setType(0); |
| | | } |
| | | } |
| | | } |
| | | |
| | | pageData.setRecords(datas); |
| | | pageData.setTotal(datas.size()); |
| | | return R.data(pageData); |
| | | return R.data(page); |
| | | } |
| | | |
| | | |
| | | //子节点 |
| | | private static List childMenu = new ArrayList(); |
| | |
| | | @PostMapping("/submit") |
| | | @ApiOperationSupport(order = 6) |
| | | @ApiOperation(value = "新增或修改", notes = "传入equipment") |
| | | public R submit(@Valid @RequestBody Equipment equipment) { |
| | | public R submit(@Valid @RequestBody EquipmentVO equipment) { |
| | | if (equipment.getStime() != null && equipment.getStime().equals("")) { |
| | | equipment.setStime(null); |
| | | } |
| | |
| | | if (equipment.getHeartbeat() != null && equipment.getHeartbeat().equals("")) { |
| | | equipment.setHeartbeat(null); |
| | | } |
| | | String deviceName = equipment.getDeviceName(); |
| | | String deviceNumber = equipment.getDeviceNumber(); |
| | | catalogService.updateCatalog(deviceName,deviceNumber); |
| | | |
| | | // String deviceName = equipment.getDeviceName(); |
| | | // String deviceNumber = equipment.getDeviceNumber(); |
| | | // String pId = equipment.getPid(); |
| | | // if (equipment.getId() == null){ |
| | | // catalogService.addCatalog(deviceName,deviceNumber,pId); |
| | | // }else{ |
| | | // catalogService.updateCatalog(deviceName,deviceNumber,pId); |
| | | // } |
| | | |
| | | System.out.println(equipment.getDeptId()); |
| | | return R.status(equipmentService.saveOrUpdate(equipment)); |
| | | } |
| | | |
| | |
| | | return R.data(list); |
| | | } |
| | | |
| | | /** |
| | | * 修改 |
| | | */ |
| | | @PostMapping("/updateexpireTime") |
| | | @ApiOperationSupport(order = 5) |
| | | @ApiOperation(value = "修改", notes = "传入equipment") |
| | | public R updateexpireTime(String expireTime,String deviceNumber) { |
| | | equipmentService.updateexpireTime(expireTime,deviceNumber); |
| | | return R.success("修改成功"); |
| | | } |
| | | |
| | | /** |
| | | * 设备故障修改 |
| | | */ |
| | | @PostMapping("/updateExstate") |
| | | @ApiOperationSupport(order = 5) |
| | | @ApiOperation(value = "修改", notes = "传入equipment") |
| | | public R updateExstate(String state,String reason, String deviceNumber) { |
| | | equipmentService.updateExstate(state,reason,deviceNumber); |
| | | return R.success("修改成功"); |
| | | } |
| | | |
| | | } |