| | |
| | | //根据查询条件得到所有设备 |
| | | List<EquipmentVO> pages = null; |
| | | |
| | | List<Map<String, Object>> treedatas = catalogService.selectCatalogEqNUmber(); |
| | | List<Map<String, Object>> treedatas = catalogService.selectCatalogEqNUmber(null); |
| | | //根据传入的id递归出该节点下所有的设备 |
| | | List<Map<String, Object>> childList = treeMenuList(treedatas, Integer.parseInt(pid)); |
| | | |
| | |
| | | //根据查询条件得到所有设备 |
| | | List<EquipmentVO> pages = null; |
| | | |
| | | List<Map<String, Object>> treedatas = catalogService.selectCatalogEqNUmber(); |
| | | List<Map<String, Object>> treedatas = catalogService.selectCatalogEqNUmber(null); |
| | | //根据传入的id递归出该节点下所有的设备 |
| | | List<Map<String, Object>> childList = treeMenuList(treedatas, Integer.parseInt(pid)); |
| | | |
| | |
| | | List<catalogVO> tree = catalogService.lazyTree(Func.toStrWithEmpty(tenantId, bladeUser.getTenantId()), parentId); |
| | | return R.data(tree); |
| | | } |
| | | |
| | | /** |
| | | * 获取部门树形结构 |
| | | * @return |
| | | */ |
| | | @GetMapping("/tree") |
| | | @ApiOperationSupport(order = 4) |
| | | @ApiOperation(value = "树形结构", notes = "树形结构") |
| | | public R<List<catalogVO>> tree() { |
| | | List<catalogVO> tree = catalogService.tree(); |
| | | return R.data(tree); |
| | | } |
| | | |
| | | } |
| | |
| | | List<Map<String, Object>> selectEq(); |
| | | List<Map<String, Object>> selectWar(String beginTime,String endTime); |
| | | |
| | | List<Map<String, Object>> selectCatalogEqNUmber(); |
| | | List<Map<String, Object>> selectCatalogEqNUmber(String id); |
| | | |
| | | List<catalogVO> lazyTree(String tenantId, Long parentId); |
| | | void updateCatalog(String name, String eqid); |
| | | void updateCatalog(String name, String eqid,String pid); |
| | | void addCatalog(String name, String eqid,String pid); |
| | | |
| | | List<catalogVO> tree(); |
| | | } |
| | |
| | | SELECT |
| | | id,name,pId,eqid |
| | | FROM |
| | | sys_catalog |
| | | sys_catalog where 1 = 1 |
| | | <if test="id!=null"> |
| | | and id = #{id} |
| | | </if> |
| | | |
| | | </select> |
| | | |
| | |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="tree" resultMap="treeNodeResultMap"> |
| | | select id, pId as parent_id, name as title, id as "value", id as "key" from sys_catalog |
| | | </select> |
| | | |
| | | <update id="updateCatalog"> |
| | | update sys_catalog SET name=#{name} where eqid=#{eqid} |
| | | </update> |
| | | update sys_catalog SET name=#{name},eqid=#{eqid} |
| | | <if test="pid!=null and pid!=''"> |
| | | ,pId=#{pid} |
| | | </if> |
| | | where eqid=#{eqid} |
| | | </update> |
| | | |
| | | <insert id="addCatalog"> |
| | | INSERT INTO sys_catalog (name,eqid,pId) VALUES (#{name},#{eqid},#{pid}) |
| | | </insert> |
| | | |
| | | </mapper> |
| | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.springblade.jfpt.catalog.entitly.catalog; |
| | | import org.springblade.jfpt.catalog.vo.catalogVO; |
| | | import org.springblade.system.vo.DeptVO; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | */ |
| | | public interface catalogService extends IService<catalog> { |
| | | List<Map<String, Object>> selectCatalogList(); |
| | | List<Map<String, Object>> selectCatalogEqNUmber(); |
| | | List<Map<String, Object>> selectCatalogEqNUmber(String id); |
| | | List<Map<String, Object>> selectCount(); |
| | | List<Map<String, Object>> selectAddvcd(); |
| | | List<Map<String, Object>> selectEq(); |
| | | List<Map<String, Object>> selectWar(String beginTime,String endTime); |
| | | List<catalogVO> lazyTree(String tenantId, Long parentId); |
| | | void updateCatalog(String name, String eqid); |
| | | void updateCatalog(String name, String eqid,String pid); |
| | | void addCatalog(String name, String eqid,String pid); |
| | | |
| | | List<catalogVO> tree(); |
| | | } |
| | |
| | | |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springblade.core.tool.node.ForestNodeMerger; |
| | | import org.springblade.jfpt.catalog.entitly.catalog; |
| | | import org.springblade.jfpt.catalog.mapper.catalogMapper; |
| | | import org.springblade.jfpt.catalog.service.catalogService; |
| | | import org.springblade.jfpt.catalog.vo.catalogVO; |
| | | import org.springblade.system.vo.DeptVO; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List selectCatalogEqNUmber() { |
| | | return baseMapper.selectCatalogEqNUmber(); |
| | | public List selectCatalogEqNUmber(String id) { |
| | | return baseMapper.selectCatalogEqNUmber(id); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void updateCatalog(String name, String eqid) { |
| | | baseMapper.updateCatalog(name, eqid); |
| | | public List<catalogVO> tree() { |
| | | return ForestNodeMerger.merge(baseMapper.tree()); |
| | | } |
| | | |
| | | @Override |
| | | public void updateCatalog(String name, String eqid,String pid) { |
| | | baseMapper.updateCatalog(name, eqid,pid); |
| | | } |
| | | |
| | | @Override |
| | | public void addCatalog(String name, String eqid,String pid) { |
| | | baseMapper.addCatalog(name, eqid,pid); |
| | | } |
| | | } |
| | |
| | | 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; |
| | |
| | | //根据查询条件得到所有设备 |
| | | 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") |
| | | @ApiOperationSupport(order = 3) |
| | | @ApiOperation(value = "分页", notes = "传入equipment") |
| | | public R<IPage<EquipmentVO>> page(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> pageData = equipmentService.selectEquipmentPage(Condition.getPage(query), equipment, null); |
| | | |
| | | 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类型的 |
| | | 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); |
| | | } |
| | | } |
| | | 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)); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | pageData.setRecords(datas); |
| | | pageData.setTotal(datas.size()); |
| | | return R.data(pageData); |
| | | } |
| | | |
| | | //子节点 |
| | | 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 pId = equipment.getPid(); |
| | | if (equipment.getId() == null){ |
| | | catalogService.addCatalog(deviceName,deviceNumber,pId); |
| | | }else{ |
| | | catalogService.updateCatalog(deviceName,deviceNumber,pId); |
| | | } |
| | | |
| | | |
| | | return R.status(equipmentService.saveOrUpdate(equipment)); |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | <select id="selectEquipmentPage" resultMap="equipmentResultMap"> |
| | | select id,deviceName,deviceNumber,deviceType,ownership,ownerId,devicestate,stime,dtype,heartbeat,expireTime,pay, |
| | | parent_id,district,province,city,serialNumber,channelNumber, |
| | | jd , |
| | | wd , |
| | | street, |
| | | addvcd,pay,expireTime from sys_equipment where 1=1 |
| | | select equipment.id,equipment.deviceName,equipment.deviceNumber,equipment.deviceType,equipment.ownership |
| | | ,equipment.ownerId,equipment.devicestate,equipment.stime,equipment.dtype,equipment.heartbeat,equipment.expireTime, |
| | | equipment.parent_id,equipment.district,equipment.province,equipment.city,equipment.serialNumber,equipment.channelNumber, |
| | | equipment.jd , |
| | | equipment.wd , |
| | | equipment.street,catalog.pid, |
| | | equipment.addvcd,equipment.pay,equipment.expireTime from sys_equipment equipment |
| | | left join sys_catalog catalog on catalog.eqid = equipment.deviceNumber |
| | | |
| | | where 1=1 |
| | | |
| | | <if test="equipment.deviceName!=null"> |
| | | and (deviceName like concat('%',#{equipment.deviceName},'%') or deviceNumber like |
| | | concat('%',#{equipment.deviceName},'%')) |
| | |
| | | String expireTime; |
| | | private String beginTime; |
| | | private String endTime; |
| | | private String pid; |
| | | |
| | | } |