| | |
| | | import io.swagger.annotations.*; |
| | | import lombok.AllArgsConstructor; |
| | | import org.omg.PortableInterceptor.INACTIVE; |
| | | import org.springblade.common.vo.DeptVo; |
| | | import org.springblade.core.boot.ctrl.BladeController; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | |
| | | 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.feign.DeptFeignApi; |
| | | import org.springblade.jfpt.equipment.service.IEquipmentService; |
| | | import org.springblade.jfpt.equipment.vo.EquipmentVO; |
| | | import org.springblade.jfpt.equipment.vo.EquipmentVOS; |
| | |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 控制器 |
| | | * 设备管理控制器 |
| | | * |
| | | * @author BladeX |
| | | * @since 2020-07-01 |
| | |
| | | private final IEquipmentService equipmentService; |
| | | private final IDeployService iDeployService; |
| | | private final org.springblade.jfpt.catalog.service.catalogService catalogService; |
| | | |
| | | private final DeptFeignApi deptFeignApi; |
| | | |
| | | /** |
| | | * 详情 |
| | |
| | | @GetMapping("/listAll") |
| | | @ApiOperationSupport(order = 2) |
| | | @ApiOperation(value = "分页", notes = "传入equipment") |
| | | public R<List<EquipmentVO>> listAll(Equipment equipment, Query query) throws ParseException { |
| | | List<EquipmentVO> pages = equipmentService.listAll(); |
| | | public R<List<EquipmentVO>> listAll(EquipmentVO equipment, Query query) throws ParseException { |
| | | List<EquipmentVO> pages = equipmentService.listAll(equipment); |
| | | |
| | | for (int j = 0; j < pages.size(); j++) { |
| | | String expireTime = pages.get(j).getExpireTime(); |
| | |
| | | |
| | | /** |
| | | * 自定义分页(部门挂接) |
| | | * @param dxtype ??? |
| | | * @param equipment 设备对象信息 |
| | | * @param query 查询参数 |
| | | * @param pid 组织机构Id |
| | | * @param response servlet 响应对象 |
| | | */ |
| | | @GetMapping("/pageDept") |
| | | @ApiOperationSupport(order = 3) |
| | |
| | | response.setHeader("Access-Control-Allow-Origin", "*"); |
| | | response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); |
| | | response.setHeader("Access-Control-Allow-Credentials", "true"); |
| | | |
| | | //获取部门数据 |
| | | List<DeptVo> deptVos = deptFeignApi.selDeptList(); |
| | | //获取设备数据信息 |
| | | IPage<EquipmentVO> page = equipmentService.selectDeptPages(Condition.getPage(query), equipment, pid, dxtype); |
| | | |
| | | //遍历数据 |
| | | for (int j = 0; j < page.getRecords().size(); j++) { |
| | | if (null!=page.getRecords().get(j).getDeptId()){ |
| | | String[] split = page.getRecords().get(j).getDeptId().split(","); |
| | | List<String> list = Arrays.asList(split); |
| | | StringBuffer deptNameBuiffer = new StringBuffer(); |
| | | //数据匹配封装 |
| | | for (String deptId:list) { |
| | | for (DeptVo deptVo:deptVos) { |
| | | if (deptId.equals(deptVo.getId().toString())){ |
| | | deptNameBuiffer.append(deptVo.getDeptName()).append(","); |
| | | } |
| | | } |
| | | } |
| | | //封装部门名称数据 |
| | | page.getRecords().get(j).setDeptName(deptNameBuiffer.substring(0,deptNameBuiffer.length()-1)); |
| | | } |
| | | |
| | | String expireTime = page.getRecords().get(j).getExpireTime(); |
| | | //1.获取当前时间 |
| | | Date dd = new Date(); |
| | |
| | | // catalogService.updateCatalog(deviceName,deviceNumber,pId); |
| | | // } |
| | | |
| | | System.out.println(equipment.getDeptId()); |
| | | return R.status(equipmentService.saveOrUpdate(equipment)); |
| | | } |
| | | |
| | | /** |
| | | * APP新增或修改 |
| | | */ |
| | | @PostMapping("/AppSubmit") |
| | | @ApiOperationSupport(order = 6) |
| | | @ApiOperation(value = "新增或修改", notes = "传入equipment") |
| | | public R AppSubmit(@Valid EquipmentVO equipment) { |
| | | if (equipment.getStime() != null && equipment.getStime().equals("")) { |
| | | equipment.setStime(null); |
| | | } |
| | | |
| | | if (equipment.getExpireTime() != null && equipment.getExpireTime().equals("")) { |
| | | equipment.setExpireTime(null); |
| | | } |
| | | |
| | | if (equipment.getHeartbeat() != null && equipment.getHeartbeat().equals("")) { |
| | | equipment.setHeartbeat(null); |
| | | } |
| | | |
| | | // 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); |
| | | // } |
| | | |
| | | if (equipment.getPaddress() != null && !equipment.getPaddress().equals("")) { |
| | | equipmentService.saveImg(equipment); |
| | | } |
| | | |
| | | return R.status(equipmentService.saveOrUpdate(equipment)); |
| | | } |
| | | |