| | |
| | | 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 = ""; |
| | |
| | | strArrays += "'" + split[i] + "',"; |
| | | } |
| | | String substring = strArrays.substring(0, strArrays.length() - 1); |
| | | equipment.setDeviceNumber(substring); |
| | | 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); |
| | | } |
| | | |
| | | |
| | | } |