package com.hxzk.controller; import com.hxzk.deo.TbPersonAndDepartment; import com.hxzk.pojo.TbPerson; import com.hxzk.pojo.tb_realpositoin; import com.hxzk.service.PersonService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; import java.text.SimpleDateFormat; import java.util.*; @RestController @RequestMapping("/") public class SanWeiController { @Autowired PersonService personService; private Map persons = new HashMap(); @RequestMapping(value = {"/getRealPositionsan2.do"}, method = {RequestMethod.POST, RequestMethod.GET}) @ResponseBody public List getRealPositionsan2(HttpServletRequest request) { long timeStart = 0L; List realLocationList = personService.findSanWei(); List finalPositionList = new ArrayList(); Iterator var6 = realLocationList.iterator(); while(var6.hasNext()) { TbPersonAndDepartment node = (TbPersonAndDepartment)var6.next(); double jiao = 0.0; if (this.persons.containsKey(node.getPTagid())) { double x1 = Double.valueOf(node.getPX()); double y1 = Double.valueOf(node.getPY()); double x2 = Double.valueOf(((String[])this.persons.get(node.getPTagid()))[0]); double y2 = Double.valueOf(((String[])this.persons.get(node.getPTagid()))[1]); double c = x1 - x2; double a = y1 - y2; if (node.getBaoliu22() != null && node.getBaoliu22() != "") { if (node.getBaoliu22().equals("0")) { jiao = Math.toDegrees(Math.atan2(c, a)); } else { String[] xy = node.getBaoliu23().split(","); jiao = Math.toDegrees(Math.atan2(Double.valueOf(xy[0]), Double.valueOf(xy[1]))); } if (String.valueOf(jiao).equals("0.0")) { jiao = Double.valueOf(((String[])this.persons.get(node.getPTagid()))[2]); } } } String tagid = node.getPTagid(); tb_realpositoin position = new tb_realpositoin(); position.setTagid(tagid); position.setPower(node.getPPower()); position.setLife(node.getPOnline()); position.setName(node.getPName()); position.setSex(node.getPSex()); position.setMinzu(node.getPMinzu()); position.setPhone(node.getPPhone()); position.setBumen(node.getPDepartment()); position.setPosx(node.getPX()); position.setPosy(node.getPY()); position.setSos(node.getPSos()); position.setTime(node.getPAddtiem()); position.setFence(node.getPFence()); position.setSousuo(node.getPSousuo()); position.setShipin(node.getPShipin()); position.setInkaoqing(node.getPKaoqing()); position.setJiao(String.valueOf(jiao)); position.setBaoliu19(node.getBaoliu19()); position.setBaoliu22(node.getBaoliu22()); position.setBaoliu23(node.getBaoliu23()); position.setBaoliu24(node.getBaoliu24()); position.setBaoliu2(node.getBaoliu2()); position.setBaoliu3(node.getBaoliu3()); position.setImage(node.getPImage()); position.setBumencolor(node.getBumencolor()); position.setBaoliu35(node.getBaoliu35()); String[] bb = new String[]{node.getPX(), node.getPY(), String.valueOf(jiao)}; this.persons.put(node.getPTagid(), bb); finalPositionList.add(position); } return finalPositionList; } public String gettime(){ Date now = new Date(); // 创建日期格式化对象,设置格式为 "yyyy-MM-dd HH:mm" SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); // 格式化日期对象,输出字符串结果 String formattedDate = sdf.format(now); return formattedDate; } }