| | |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.Valid; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.regex.Pattern; |
| | |
| | | return R.data(list); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 总数 |
| | | * @param response |
| | | * @return |
| | | */ |
| | | @GetMapping("/selectCount") |
| | | public R selectCount(HttpServletResponse response) { |
| | | response.setHeader("Access-Control-Allow-Origin", "*"); |
| | | response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); |
| | | response.setHeader("Access-Control-Allow-Credentials","true"); |
| | | List<Map<String, Object>> lists = new ArrayList<>(); |
| | | List<Map<String, Object>> list1 = catalogService.selectCount(); |
| | | Map<String, Object> mapa = new HashMap<String, Object>(); |
| | | Map<String, Object> mape = new HashMap<String, Object>(); |
| | | Map<String, Object> maps = new HashMap<String, Object>(); |
| | | Map<String, Object> mapse = new HashMap<String, Object>(); |
| | | mapa.put("value",list1.get(0).get("counta")); |
| | | mapa.put("backgroundColor","#FF0000"); |
| | | mapa.put("prefixText","警情总数"); |
| | | mapa.put("suffixText","条"); |
| | | mape.put("value",list1.get(1).get("counta")); |
| | | mape.put("backgroundColor","#000000"); |
| | | mape.put("prefixText","设备总数"); |
| | | mape.put("suffixText","个"); |
| | | |
| | | maps.put("value",list1.get(2).get("counta")); |
| | | maps.put("backgroundColor","#6CDEFF"); |
| | | maps.put("prefixText","用户总数"); |
| | | maps.put("suffixText","个"); |
| | | |
| | | mapse.put("value",list1.get(3).get("counta")); |
| | | mapse.put("backgroundColor","#FF9900"); |
| | | mapse.put("prefixText","出警队伍总数"); |
| | | mapse.put("suffixText","队"); |
| | | lists.add(mapa); |
| | | lists.add(mape); |
| | | lists.add(maps); |
| | | lists.add(mapse); |
| | | return R.data(lists); |
| | | } |
| | | |
| | | } |
| | |
| | | */ |
| | | public interface catalogMapper extends BaseMapper<catalog> { |
| | | List<Map<String, Object>> selectCatalogList(); |
| | | List<Map<String, Object>> selectCount(); |
| | | |
| | | String selectCatalogEqNUmber(String pid); |
| | | } |
| | |
| | | SELECT GROUP_CONCAT(eqid) FROM sys_catalog WHERE pId=#{pid} and eqid is NOT NULL; |
| | | </select> |
| | | |
| | | <select id="selectCount" resultType="java.util.HashMap"> |
| | | SELECT |
| | | COUNT( * ) AS counta |
| | | FROM |
| | | sys_alarm UNION |
| | | SELECT |
| | | COUNT( * ) |
| | | FROM |
| | | sys_equipment |
| | | WHERE |
| | | parent_id != 0 UNION |
| | | SELECT |
| | | COUNT( * ) |
| | | FROM |
| | | sys_suser UNION |
| | | SELECT |
| | | COUNT( * ) |
| | | FROM |
| | | sys_security WHERE type=1 |
| | | </select> |
| | | |
| | | |
| | | </mapper> |
| | |
| | | public interface catalogService extends IService<catalog> { |
| | | List<Map<String, Object>> selectCatalogList(); |
| | | String selectCatalogEqNUmber(String pid); |
| | | List<Map<String, Object>> selectCount(); |
| | | } |
| | |
| | | public String selectCatalogEqNUmber(String pid) { |
| | | return baseMapper.selectCatalogEqNUmber(pid); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> selectCount() { |
| | | return baseMapper.selectCount(); |
| | | } |
| | | } |
| | |
| | | import org.springblade.core.boot.ctrl.BladeController; |
| | | import springfox.documentation.annotations.ApiIgnore; |
| | | |
| | | import java.text.DateFormat; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 控制器 |
| | |
| | | @GetMapping("/page") |
| | | @ApiOperationSupport(order = 3) |
| | | @ApiOperation(value = "分页", notes = "传入equipment") |
| | | public R<List<EquipmentVO>> page(EquipmentVO equipment, Query query, String pid, HttpServletResponse response) { |
| | | public R<List<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"); |
| | | List<EquipmentVO> pages; |
| | | if (pid == null) { |
| | | pages = equipmentService.selectEquipmentPage(equipment.getDeviceName(), equipment.getAddvcd(), equipment.getDtype(), equipment.getDevicestate()); |
| | | for(int i=0;i<pages.size();i++){ |
| | | String expireTime = pages.get(i).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(i).setType(1); |
| | | } |
| | | } |
| | | } else { |
| | | String s = catalogService.selectCatalogEqNUmber(pid); |
| | | if (s == null) { |
| | | pages = equipmentService.selectEquipmentPage(equipment.getDeviceName(), equipment.getAddvcd(), equipment.getDtype(), equipment.getDevicestate()); |
| | | for(int i=0;i<pages.size();i++){ |
| | | String expireTime = pages.get(i).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(i).setType(1); |
| | | } |
| | | } |
| | | } else { |
| | | String[] split = s.split(","); |
| | | String strArrays = ""; |
| | |
| | | String substring = strArrays.substring(0, strArrays.length() - 1); |
| | | equipment.setDeviceName(substring); |
| | | pages = equipmentService.selectEquipmentPage(equipment.getDeviceName(), equipment.getAddvcd(), equipment.getDtype(), equipment.getDevicestate()); |
| | | for(int i=0;i<pages.size();i++){ |
| | | String expireTime = pages.get(i).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(i).setType(1); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | return R.data(list); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | private String serialNumber; |
| | | private String stype; |
| | | private String channelNumber; |
| | | private String pay; |
| | | private String expireTime; |
| | | |
| | | |
| | | } |
| | |
| | | <mapper namespace="org.springblade.modules.equipment.mapper.EquipmentMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="equipmentResultMap" type="org.springblade.modules.equipment.entity.Equipment"> |
| | | <resultMap id="equipmentResultMap" type="org.springblade.modules.equipment.vo.EquipmentVO"> |
| | | <id column="id" property="id"/> |
| | | <result column="deviceName" property="deviceName"/> |
| | | <result column="deviceNumber" property="deviceNumber"/> |
| | |
| | | <result column="serialNumber" property="serialNumber"/> |
| | | <result column="stype" property="stype"/> |
| | | <result column="channelNumber" property="channelNumber"/> |
| | | <result column="pay" property="pay"/> |
| | | <result column="expireTime" property="expireTime"/> |
| | | </resultMap> |
| | | |
| | | <resultMap id="treeNodeResultMap" type="org.springblade.core.tool.node.TreeNode"> |
| | |
| | | FORMAT( jd, 6 ) AS jd, |
| | | FORMAT( wd, 6 ) AS wd, |
| | | street, |
| | | addvcd from sys_equipment where 1=1 |
| | | addvcd,pay,expireTime from sys_equipment where 1=1 |
| | | <if test="deviceName!=null"> |
| | | and (deviceName like concat('%',#{deviceName},'%') or deviceNumber like |
| | | concat('%',#{deviceName},'%')) |
| | |
| | | @ApiModel(value = "EquipmentVO对象", description = "EquipmentVO对象") |
| | | public class EquipmentVO extends Equipment { |
| | | private static final long serialVersionUID = 1L; |
| | | int type; |
| | | String pay; |
| | | String expireTime; |
| | | |
| | | } |