Commit fac71692afa73446ced0b3c566cd8d277597044e
Merge branch 'minhang' into pudong
Showing
22 changed files
with
312 additions
and
262 deletions
Too many changes to show.
To preserve performance only 22 of 55 files are displayed.
src/main/java/com/bsth/controller/CarParkController.java
| @@ -15,7 +15,6 @@ import org.springframework.web.bind.annotation.*; | @@ -15,7 +15,6 @@ import org.springframework.web.bind.annotation.*; | ||
| 15 | @RestController | 15 | @RestController |
| 16 | @RequestMapping("carpark") | 16 | @RequestMapping("carpark") |
| 17 | public class CarParkController extends BaseController<CarPark, Integer> { | 17 | public class CarParkController extends BaseController<CarPark, Integer> { |
| 18 | - | ||
| 19 | @Autowired | 18 | @Autowired |
| 20 | CarParkService service; | 19 | CarParkService service; |
| 21 | 20 | ||
| @@ -26,16 +25,10 @@ public class CarParkController extends BaseController<CarPark, Integer> { | @@ -26,16 +25,10 @@ public class CarParkController extends BaseController<CarPark, Integer> { | ||
| 26 | */ | 25 | */ |
| 27 | @RequestMapping(value="getCarParkCode" , method = RequestMethod.GET) | 26 | @RequestMapping(value="getCarParkCode" , method = RequestMethod.GET) |
| 28 | public Map<String, Object> getStationCode() { | 27 | public Map<String, Object> getStationCode() { |
| 29 | - | ||
| 30 | Map<String, Object> resultMap = new HashMap<String, Object>(); | 28 | Map<String, Object> resultMap = new HashMap<String, Object>(); |
| 31 | - | ||
| 32 | - resultMap.put("carParkCode", "FFFF" + GetUIDAndCode.getCarParkId()); | ||
| 33 | - | 29 | + resultMap.put("carParkCode", "FFFFFF" + GetUIDAndCode.getCarParkId()); |
| 34 | return resultMap; | 30 | return resultMap; |
| 35 | - | ||
| 36 | } | 31 | } |
| 37 | - | ||
| 38 | - | ||
| 39 | /** | 32 | /** |
| 40 | * 新增停车场信息 | 33 | * 新增停车场信息 |
| 41 | * | 34 | * |
| @@ -53,21 +46,14 @@ public class CarParkController extends BaseController<CarPark, Integer> { | @@ -53,21 +46,14 @@ public class CarParkController extends BaseController<CarPark, Integer> { | ||
| 53 | */ | 46 | */ |
| 54 | @RequestMapping(value="carParkSave" , method = RequestMethod.POST) | 47 | @RequestMapping(value="carParkSave" , method = RequestMethod.POST) |
| 55 | public Map<String, Object> stationSave(@RequestParam Map<String, Object> map) { | 48 | public Map<String, Object> stationSave(@RequestParam Map<String, Object> map) { |
| 56 | - | ||
| 57 | map.put("createBy", ""); | 49 | map.put("createBy", ""); |
| 58 | - | ||
| 59 | map.put("updateBy", ""); | 50 | map.put("updateBy", ""); |
| 60 | - | ||
| 61 | return service.carParkSave(map); | 51 | return service.carParkSave(map); |
| 62 | - | ||
| 63 | } | 52 | } |
| 64 | - | ||
| 65 | @RequestMapping(value = "findCarParkInfoFormId",method = RequestMethod.GET) | 53 | @RequestMapping(value = "findCarParkInfoFormId",method = RequestMethod.GET) |
| 66 | public List<Map<String, Object>> findCarParkInfoFormId(@RequestParam Map<String, Object> map) { | 54 | public List<Map<String, Object>> findCarParkInfoFormId(@RequestParam Map<String, Object> map) { |
| 67 | - | ||
| 68 | return service.findCarParkInfoFormId(map); | 55 | return service.findCarParkInfoFormId(map); |
| 69 | } | 56 | } |
| 70 | - | ||
| 71 | /** | 57 | /** |
| 72 | * 修改停车场信息 | 58 | * 修改停车场信息 |
| 73 | * | 59 | * |
| @@ -85,11 +71,12 @@ public class CarParkController extends BaseController<CarPark, Integer> { | @@ -85,11 +71,12 @@ public class CarParkController extends BaseController<CarPark, Integer> { | ||
| 85 | */ | 71 | */ |
| 86 | @RequestMapping(value="carParkUpdate" , method = RequestMethod.POST) | 72 | @RequestMapping(value="carParkUpdate" , method = RequestMethod.POST) |
| 87 | public Map<String, Object> carParkUpdate(@RequestParam Map<String, Object> map) { | 73 | public Map<String, Object> carParkUpdate(@RequestParam Map<String, Object> map) { |
| 88 | - | ||
| 89 | map.put("updateBy", ""); | 74 | map.put("updateBy", ""); |
| 90 | - | ||
| 91 | return service.carParkUpdate(map); | 75 | return service.carParkUpdate(map); |
| 92 | - | ||
| 93 | } | 76 | } |
| 94 | 77 | ||
| 78 | + @RequestMapping(value="isHaveParkCode",method=RequestMethod.GET) | ||
| 79 | + public boolean isHaveParkCode(@RequestParam Map<String,Object> map) { | ||
| 80 | + return service.selectTccInfoByCode(map); | ||
| 81 | + } | ||
| 95 | } | 82 | } |
src/main/java/com/bsth/controller/realcontrol/anomalyCheckController.java
| @@ -51,9 +51,26 @@ public class anomalyCheckController { | @@ -51,9 +51,26 @@ public class anomalyCheckController { | ||
| 51 | } | 51 | } |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | - @RequestMapping(value = "/gpsClientReconn", method = RequestMethod.POST) | 54 | + @Autowired |
| 55 | + ClientApp clientApp; | ||
| 56 | + | ||
| 57 | + @RequestMapping(value = "/gpsClientDestroy", method = RequestMethod.POST) | ||
| 55 | public void gpsClientReconn(){ | 58 | public void gpsClientReconn(){ |
| 56 | - ClientApp.pdreconn(); | ||
| 57 | - ClientApp.pfreconn(); | 59 | + clientApp.destroy(); |
| 60 | + } | ||
| 61 | + | ||
| 62 | + @RequestMapping(value = "/gpsClientInit", method = RequestMethod.POST) | ||
| 63 | + public void gpsClientInit(){ | ||
| 64 | + clientApp.init(); | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + @RequestMapping(value = "/pdClose", method = RequestMethod.POST) | ||
| 68 | + public void pdClose(){ | ||
| 69 | + ClientApp.pdClose(); | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + @RequestMapping(value = "/pfClose", method = RequestMethod.POST) | ||
| 73 | + public void pfClose(){ | ||
| 74 | + ClientApp.pfClose(); | ||
| 58 | } | 75 | } |
| 59 | } | 76 | } |
src/main/java/com/bsth/data/car_out_info/CarOutInfoHandler.java
| @@ -101,10 +101,10 @@ public class CarOutInfoHandler implements CommandLineRunner, CarOutInfo { | @@ -101,10 +101,10 @@ public class CarOutInfoHandler implements CommandLineRunner, CarOutInfo { | ||
| 101 | ps.setString(1, sch.getScheduleDateStr()); | 101 | ps.setString(1, sch.getScheduleDateStr()); |
| 102 | ps.setString(2, sch.getXlBm()); | 102 | ps.setString(2, sch.getXlBm()); |
| 103 | ps.setString(3, sch.getXlName()); | 103 | ps.setString(3, sch.getXlName()); |
| 104 | - ps.setString(4, sch.getLpName()); | ||
| 105 | - ps.setInt(5, sch.getFcno()); | ||
| 106 | - ps.setString(6, sch.getDfsj()); | ||
| 107 | - ps.setString(7, sch.getClZbh()); | 104 | + ps.setString(4, /*sch.getLpName()*/"0"); |
| 105 | + ps.setInt(5, sch.getFcno()==null?-1:sch.getFcno()); | ||
| 106 | + ps.setString(6, sch.getDfsj().replace(":", "")); | ||
| 107 | + ps.setString(7, sch.getClZbh().replace("-", "")); | ||
| 108 | ps.setString(8, BasicData.nbbmCompanyPlateMap.get(sch.getClZbh())); | 108 | ps.setString(8, BasicData.nbbmCompanyPlateMap.get(sch.getClZbh())); |
| 109 | ps.setString(9, bcTypeMap.containsKey(sch.getBcType()) ? bcTypeMap.get(sch.getBcType()) : sch.getBcType()); | 109 | ps.setString(9, bcTypeMap.containsKey(sch.getBcType()) ? bcTypeMap.get(sch.getBcType()) : sch.getBcType()); |
| 110 | ps.setString(10, sch.getZdzName()); | 110 | ps.setString(10, sch.getZdzName()); |
src/main/java/com/bsth/data/gpsdata/GpsRealData.java
| @@ -4,6 +4,7 @@ import com.bsth.Application; | @@ -4,6 +4,7 @@ import com.bsth.Application; | ||
| 4 | import com.bsth.data.BasicData; | 4 | import com.bsth.data.BasicData; |
| 5 | import com.bsth.data.forecast.ForecastRealServer; | 5 | import com.bsth.data.forecast.ForecastRealServer; |
| 6 | import com.bsth.data.gpsdata.client.ClientApp; | 6 | import com.bsth.data.gpsdata.client.ClientApp; |
| 7 | +import com.bsth.data.gpsdata.client.GpsBeforeBuffer; | ||
| 7 | import com.bsth.data.gpsdata.thread.GpsDataLoaderThread; | 8 | import com.bsth.data.gpsdata.thread.GpsDataLoaderThread; |
| 8 | import com.bsth.data.gpsdata.thread.OfflineMonitorThread; | 9 | import com.bsth.data.gpsdata.thread.OfflineMonitorThread; |
| 9 | import com.bsth.data.schedule.DayOfSchedule; | 10 | import com.bsth.data.schedule.DayOfSchedule; |
| @@ -17,6 +18,7 @@ import org.springframework.boot.CommandLineRunner; | @@ -17,6 +18,7 @@ import org.springframework.boot.CommandLineRunner; | ||
| 17 | import org.springframework.stereotype.Component; | 18 | import org.springframework.stereotype.Component; |
| 18 | 19 | ||
| 19 | import java.util.*; | 20 | import java.util.*; |
| 21 | +import java.util.concurrent.ConcurrentHashMap; | ||
| 20 | import java.util.concurrent.TimeUnit; | 22 | import java.util.concurrent.TimeUnit; |
| 21 | 23 | ||
| 22 | /** | 24 | /** |
| @@ -30,7 +32,7 @@ public class GpsRealData implements CommandLineRunner { | @@ -30,7 +32,7 @@ public class GpsRealData implements CommandLineRunner { | ||
| 30 | 32 | ||
| 31 | static Logger logger = LoggerFactory.getLogger(GpsRealData.class); | 33 | static Logger logger = LoggerFactory.getLogger(GpsRealData.class); |
| 32 | 34 | ||
| 33 | - private static Map<String, GpsEntity> gpsMap; | 35 | + private static ConcurrentHashMap<String, GpsEntity> gpsMap; |
| 34 | 36 | ||
| 35 | //按线路分组设备号 | 37 | //按线路分组设备号 |
| 36 | private static TreeMultimap<String, String> lineCode2Devices; | 38 | private static TreeMultimap<String, String> lineCode2Devices; |
| @@ -51,12 +53,14 @@ public class GpsRealData implements CommandLineRunner { | @@ -51,12 +53,14 @@ public class GpsRealData implements CommandLineRunner { | ||
| 51 | * 构造函数 | 53 | * 构造函数 |
| 52 | */ | 54 | */ |
| 53 | public GpsRealData() { | 55 | public GpsRealData() { |
| 54 | - gpsMap = new HashMap<>(); | 56 | + gpsMap = new ConcurrentHashMap<>(); |
| 55 | lineCode2Devices = TreeMultimap.create(); | 57 | lineCode2Devices = TreeMultimap.create(); |
| 56 | } | 58 | } |
| 57 | 59 | ||
| 58 | @Autowired | 60 | @Autowired |
| 59 | ClientApp clientApp; | 61 | ClientApp clientApp; |
| 62 | + @Autowired | ||
| 63 | + GpsBeforeBuffer gpsBeforeBuffer; | ||
| 60 | @Override | 64 | @Override |
| 61 | public void run(String... arg0) throws Exception { | 65 | public void run(String... arg0) throws Exception { |
| 62 | logger.info("gpsDataLoader,20,3"); | 66 | logger.info("gpsDataLoader,20,3"); |
| @@ -67,6 +71,7 @@ public class GpsRealData implements CommandLineRunner { | @@ -67,6 +71,7 @@ public class GpsRealData implements CommandLineRunner { | ||
| 67 | 71 | ||
| 68 | //gps 客户端 | 72 | //gps 客户端 |
| 69 | //clientApp.init(); | 73 | //clientApp.init(); |
| 74 | + //gpsBeforeBuffer.init(); | ||
| 70 | } | 75 | } |
| 71 | 76 | ||
| 72 | 77 |
src/main/java/com/bsth/data/gpsdata/arrival/GpsRealAnalyse.java
| @@ -11,6 +11,8 @@ import org.slf4j.LoggerFactory; | @@ -11,6 +11,8 @@ import org.slf4j.LoggerFactory; | ||
| 11 | import org.springframework.beans.factory.annotation.Autowired; | 11 | import org.springframework.beans.factory.annotation.Autowired; |
| 12 | import org.springframework.stereotype.Component; | 12 | import org.springframework.stereotype.Component; |
| 13 | 13 | ||
| 14 | +import java.util.Collections; | ||
| 15 | +import java.util.Comparator; | ||
| 14 | import java.util.List; | 16 | import java.util.List; |
| 15 | import java.util.Set; | 17 | import java.util.Set; |
| 16 | import java.util.concurrent.CountDownLatch; | 18 | import java.util.concurrent.CountDownLatch; |
| @@ -42,25 +44,26 @@ public class GpsRealAnalyse { | @@ -42,25 +44,26 @@ public class GpsRealAnalyse { | ||
| 42 | @Autowired | 44 | @Autowired |
| 43 | GpsRealData gpsRealData; | 45 | GpsRealData gpsRealData; |
| 44 | 46 | ||
| 45 | - //50个线程 | ||
| 46 | - static ExecutorService threadPool = Executors.newFixedThreadPool(50); | 47 | + static ExecutorService threadPool = Executors.newFixedThreadPool(100); |
| 47 | 48 | ||
| 48 | public void analyse(List<GpsEntity> list) { | 49 | public void analyse(List<GpsEntity> list) { |
| 49 | //如果正在恢复数据 | 50 | //如果正在恢复数据 |
| 50 | if (GpsDataRecovery.run) | 51 | if (GpsDataRecovery.run) |
| 51 | return; | 52 | return; |
| 53 | + | ||
| 54 | + long t = System.currentTimeMillis(); | ||
| 52 | logger.info("analyse gps size: " + list.size()); | 55 | logger.info("analyse gps size: " + list.size()); |
| 53 | - //按车辆分组gps | 56 | + //按线路分组gps |
| 54 | ArrayListMultimap multimap = ArrayListMultimap.create(); | 57 | ArrayListMultimap multimap = ArrayListMultimap.create(); |
| 55 | for(GpsEntity gps : list){ | 58 | for(GpsEntity gps : list){ |
| 56 | - multimap.put(gps.getNbbm(), gps); | 59 | + multimap.put(gps.getLineId(), gps); |
| 57 | } | 60 | } |
| 58 | 61 | ||
| 59 | Set<String> ks = multimap.keySet(); | 62 | Set<String> ks = multimap.keySet(); |
| 60 | CountDownLatch count = new CountDownLatch(ks.size()); | 63 | CountDownLatch count = new CountDownLatch(ks.size()); |
| 61 | 64 | ||
| 62 | - for(String nbbm : ks){ | ||
| 63 | - threadPool.execute(new SignalHandleThread(multimap.get(nbbm), count)); | 65 | + for(String lineCode : ks){ |
| 66 | + threadPool.execute(new SignalHandleThread(multimap.get(lineCode), count)); | ||
| 64 | } | 67 | } |
| 65 | 68 | ||
| 66 | try { | 69 | try { |
| @@ -70,11 +73,15 @@ public class GpsRealAnalyse { | @@ -70,11 +73,15 @@ public class GpsRealAnalyse { | ||
| 70 | //加入实时gps对照 | 73 | //加入实时gps对照 |
| 71 | for(GpsEntity gps: list) | 74 | for(GpsEntity gps: list) |
| 72 | gpsRealData.put(gps); | 75 | gpsRealData.put(gps); |
| 76 | + | ||
| 77 | + logger.info("time , " + (System.currentTimeMillis() - t)); | ||
| 73 | } catch (InterruptedException e) { | 78 | } catch (InterruptedException e) { |
| 74 | logger.error("", e); | 79 | logger.error("", e); |
| 75 | } | 80 | } |
| 76 | } | 81 | } |
| 77 | 82 | ||
| 83 | + static GpsComp comp = new GpsComp(); | ||
| 84 | + | ||
| 78 | public class SignalHandleThread implements Runnable { | 85 | public class SignalHandleThread implements Runnable { |
| 79 | 86 | ||
| 80 | List<GpsEntity> list; | 87 | List<GpsEntity> list; |
| @@ -89,6 +96,7 @@ public class GpsRealAnalyse { | @@ -89,6 +96,7 @@ public class GpsRealAnalyse { | ||
| 89 | public void run() { | 96 | public void run() { |
| 90 | 97 | ||
| 91 | try { | 98 | try { |
| 99 | + Collections.sort(list, comp); | ||
| 92 | for(GpsEntity gps : list){ | 100 | for(GpsEntity gps : list){ |
| 93 | //是否有任务 | 101 | //是否有任务 |
| 94 | boolean task; | 102 | boolean task; |
| @@ -119,4 +127,12 @@ public class GpsRealAnalyse { | @@ -119,4 +127,12 @@ public class GpsRealAnalyse { | ||
| 119 | } | 127 | } |
| 120 | } | 128 | } |
| 121 | } | 129 | } |
| 130 | + | ||
| 131 | + public static class GpsComp implements Comparator<GpsEntity> { | ||
| 132 | + | ||
| 133 | + @Override | ||
| 134 | + public int compare(GpsEntity g1, GpsEntity g2) { | ||
| 135 | + return g1.getTimestamp().compareTo(g2.getTimestamp()); | ||
| 136 | + } | ||
| 137 | + } | ||
| 122 | } | 138 | } |
src/main/java/com/bsth/data/gpsdata/client/ClientApp.java
| @@ -21,10 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired; | @@ -21,10 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired; | ||
| 21 | import org.springframework.stereotype.Component; | 21 | import org.springframework.stereotype.Component; |
| 22 | 22 | ||
| 23 | import java.net.InetSocketAddress; | 23 | import java.net.InetSocketAddress; |
| 24 | -import java.util.concurrent.Executors; | ||
| 25 | -import java.util.concurrent.ScheduledExecutorService; | ||
| 26 | -import java.util.concurrent.ThreadFactory; | ||
| 27 | -import java.util.concurrent.TimeUnit; | 24 | +import java.util.concurrent.*; |
| 28 | 25 | ||
| 29 | /** | 26 | /** |
| 30 | * Created by panzhao on 2017/5/4. | 27 | * Created by panzhao on 2017/5/4. |
| @@ -43,17 +40,9 @@ public class ClientApp { | @@ -43,17 +40,9 @@ public class ClientApp { | ||
| 43 | GpsBeforeBuffer gpsBeforeBuffer; | 40 | GpsBeforeBuffer gpsBeforeBuffer; |
| 44 | 41 | ||
| 45 | static Logger logger = LoggerFactory.getLogger(ClientApp.class); | 42 | static Logger logger = LoggerFactory.getLogger(ClientApp.class); |
| 43 | + private static ExecutorService exec; | ||
| 46 | 44 | ||
| 47 | - private ScheduledExecutorService sexec = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() { | ||
| 48 | - | ||
| 49 | - @Override | ||
| 50 | - public Thread newThread(Runnable r) { | ||
| 51 | - // TODO Auto-generated method stub | ||
| 52 | - Thread t = new Thread(r); | ||
| 53 | - t.setName("SessionCheckExecutor"); | ||
| 54 | - return t; | ||
| 55 | - } | ||
| 56 | - }); | 45 | + private ScheduledExecutorService sexec; |
| 57 | 46 | ||
| 58 | public static boolean dconnect(String device) { | 47 | public static boolean dconnect(String device) { |
| 59 | boolean flag = false; | 48 | boolean flag = false; |
| @@ -85,12 +74,66 @@ public class ClientApp { | @@ -85,12 +74,66 @@ public class ClientApp { | ||
| 85 | return flag; | 74 | return flag; |
| 86 | } | 75 | } |
| 87 | 76 | ||
| 77 | + public static void pdconnect(final String device) { | ||
| 78 | + exec.submit(new Runnable() { | ||
| 79 | + | ||
| 80 | + @Override | ||
| 81 | + public void run() { | ||
| 82 | + // TODO Auto-generated method stub | ||
| 83 | + long now = System.currentTimeMillis(); | ||
| 84 | + boolean flag = false; | ||
| 85 | + while (!flag) { | ||
| 86 | + flag = dconnect(device); | ||
| 87 | + } | ||
| 88 | + System.out.println("设备编号:" + device + "重连, cost time: " + (System.currentTimeMillis() - now)); | ||
| 89 | + } | ||
| 90 | + }); | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + public static void pfconnect(final String device) { | ||
| 94 | + exec.submit(new Runnable() { | ||
| 95 | + | ||
| 96 | + @Override | ||
| 97 | + public void run() { | ||
| 98 | + // TODO Auto-generated method stub | ||
| 99 | + long now = System.currentTimeMillis(); | ||
| 100 | + boolean flag = false; | ||
| 101 | + while (!flag) { | ||
| 102 | + flag = fconnect(device); | ||
| 103 | + } | ||
| 104 | + System.out.println("重连, cost time: " + (System.currentTimeMillis() - now)); | ||
| 105 | + } | ||
| 106 | + }); | ||
| 107 | + } | ||
| 108 | + | ||
| 88 | public static void pdreconn(){ | 109 | public static void pdreconn(){ |
| 89 | - dconnect(ConfigUtil.get("forward.device.name")); | 110 | + pdconnect(ConfigUtil.get("forward.device.name")); |
| 90 | } | 111 | } |
| 91 | 112 | ||
| 92 | public static void pfreconn(){ | 113 | public static void pfreconn(){ |
| 93 | - fconnect(ConfigUtil.get("forward.device.name")); | 114 | + pfconnect(ConfigUtil.get("forward.device.name")); |
| 115 | + } | ||
| 116 | + | ||
| 117 | + public void destroy(){ | ||
| 118 | + try { | ||
| 119 | + logger.warn("socket client destroy!!!"); | ||
| 120 | + exec.shutdownNow(); | ||
| 121 | + sexec.shutdownNow(); | ||
| 122 | + | ||
| 123 | + pdDataConnector.dispose(true); | ||
| 124 | + pfDataConnector.dispose(true); | ||
| 125 | + } catch (Exception e) { | ||
| 126 | + logger.error("", e); | ||
| 127 | + } | ||
| 128 | + } | ||
| 129 | + | ||
| 130 | + | ||
| 131 | + public static void pdClose(){ | ||
| 132 | + pdSession.closeNow(); | ||
| 133 | + } | ||
| 134 | + | ||
| 135 | + public static void pfClose(){ | ||
| 136 | + pfSession.closeNow(); | ||
| 94 | } | 137 | } |
| 95 | 138 | ||
| 96 | public static boolean fconnect(String device) { | 139 | public static boolean fconnect(String device) { |
| @@ -111,7 +154,17 @@ public class ClientApp { | @@ -111,7 +154,17 @@ public class ClientApp { | ||
| 111 | } | 154 | } |
| 112 | 155 | ||
| 113 | public void init() { | 156 | public void init() { |
| 114 | - //exec = Executors.newFixedThreadPool(4); | 157 | + logger.warn("socket client init..."); |
| 158 | + exec = Executors.newFixedThreadPool(50); | ||
| 159 | + sexec = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() { | ||
| 160 | + @Override | ||
| 161 | + public Thread newThread(Runnable r) { | ||
| 162 | + // TODO Auto-generated method stub | ||
| 163 | + Thread t = new Thread(r); | ||
| 164 | + t.setName("SessionCheckExecutor"); | ||
| 165 | + return t; | ||
| 166 | + } | ||
| 167 | + }); | ||
| 115 | sexec.scheduleAtFixedRate(new SessionChecker(), 1, 1, TimeUnit.MINUTES); | 168 | sexec.scheduleAtFixedRate(new SessionChecker(), 1, 1, TimeUnit.MINUTES); |
| 116 | /*******************************浦东********************************/ | 169 | /*******************************浦东********************************/ |
| 117 | pdDataConnector = new NioSocketConnector(); | 170 | pdDataConnector = new NioSocketConnector(); |
| @@ -133,7 +186,7 @@ public class ClientApp { | @@ -133,7 +186,7 @@ public class ClientApp { | ||
| 133 | 186 | ||
| 134 | pdDataConnector.setHandler(pdClient); | 187 | pdDataConnector.setHandler(pdClient); |
| 135 | 188 | ||
| 136 | - dconnect(ConfigUtil.get("forward.device.name")); | 189 | + pdconnect(ConfigUtil.get("forward.device.name")); |
| 137 | /*******************************浦东转发********************************/ | 190 | /*******************************浦东转发********************************/ |
| 138 | pfDataConnector = new NioSocketConnector(); | 191 | pfDataConnector = new NioSocketConnector(); |
| 139 | 192 | ||
| @@ -153,10 +206,7 @@ public class ClientApp { | @@ -153,10 +206,7 @@ public class ClientApp { | ||
| 153 | config1.setIdleTime(IdleStatus.BOTH_IDLE, 60); | 206 | config1.setIdleTime(IdleStatus.BOTH_IDLE, 60); |
| 154 | 207 | ||
| 155 | pfDataConnector.setHandler(pfClient); | 208 | pfDataConnector.setHandler(pfClient); |
| 156 | - fconnect(ConfigUtil.get("forward.device.name")); | ||
| 157 | - | ||
| 158 | - | ||
| 159 | - gpsBeforeBuffer.init(); | 209 | + pfconnect(ConfigUtil.get("forward.device.name")); |
| 160 | } | 210 | } |
| 161 | 211 | ||
| 162 | 212 | ||
| @@ -182,6 +232,5 @@ public class ClientApp { | @@ -182,6 +232,5 @@ public class ClientApp { | ||
| 182 | logger.error("SessionChecker异常", e); | 232 | logger.error("SessionChecker异常", e); |
| 183 | } | 233 | } |
| 184 | } | 234 | } |
| 185 | - | ||
| 186 | } | 235 | } |
| 187 | } | 236 | } |
| 188 | \ No newline at end of file | 237 | \ No newline at end of file |
src/main/java/com/bsth/data/gpsdata/client/DataMonitor.java deleted
100644 → 0
src/main/java/com/bsth/data/gpsdata/client/GpsBeforeBuffer.java
| @@ -6,6 +6,8 @@ import com.bsth.data.gpsdata.GpsEntity; | @@ -6,6 +6,8 @@ import com.bsth.data.gpsdata.GpsEntity; | ||
| 6 | import com.bsth.data.gpsdata.arrival.GpsRealAnalyse; | 6 | import com.bsth.data.gpsdata.arrival.GpsRealAnalyse; |
| 7 | import com.bsth.data.gpsdata.client.pd.protocol.BasicInfo; | 7 | import com.bsth.data.gpsdata.client.pd.protocol.BasicInfo; |
| 8 | import org.apache.commons.lang3.StringUtils; | 8 | import org.apache.commons.lang3.StringUtils; |
| 9 | +import org.slf4j.Logger; | ||
| 10 | +import org.slf4j.LoggerFactory; | ||
| 9 | import org.springframework.beans.factory.annotation.Autowired; | 11 | import org.springframework.beans.factory.annotation.Autowired; |
| 10 | import org.springframework.stereotype.Component; | 12 | import org.springframework.stereotype.Component; |
| 11 | 13 | ||
| @@ -63,9 +65,10 @@ public class GpsBeforeBuffer { | @@ -63,9 +65,10 @@ public class GpsBeforeBuffer { | ||
| 63 | } | 65 | } |
| 64 | 66 | ||
| 65 | public void init(){ | 67 | public void init(){ |
| 66 | - Application.mainServices.scheduleWithFixedDelay(gpsHandleThread, 20 * 1000, 1100, TimeUnit.MILLISECONDS); | 68 | + Application.mainServices.scheduleWithFixedDelay(gpsHandleThread, 20 * 1000, 1200, TimeUnit.MILLISECONDS); |
| 67 | } | 69 | } |
| 68 | 70 | ||
| 71 | + static int idleCount = 0; | ||
| 69 | @Component | 72 | @Component |
| 70 | public static class GpsHandleThread extends Thread{ | 73 | public static class GpsHandleThread extends Thread{ |
| 71 | 74 | ||
| @@ -74,18 +77,33 @@ public class GpsBeforeBuffer { | @@ -74,18 +77,33 @@ public class GpsBeforeBuffer { | ||
| 74 | @Autowired | 77 | @Autowired |
| 75 | GpsRealAnalyse gpsRealAnalyse; | 78 | GpsRealAnalyse gpsRealAnalyse; |
| 76 | 79 | ||
| 80 | + @Autowired | ||
| 81 | + ClientApp clientApp; | ||
| 82 | + | ||
| 83 | + Logger log = LoggerFactory.getLogger(this.getClass()); | ||
| 84 | + | ||
| 77 | @Override | 85 | @Override |
| 78 | public void run() { | 86 | public void run() { |
| 79 | - list = new ArrayList<>(100); | 87 | + list = new ArrayList<>(200); |
| 80 | 88 | ||
| 81 | GpsEntity gps; | 89 | GpsEntity gps; |
| 82 | - for(int i = 0; i < 2000; i ++){ | 90 | + for(int i = 0; i < 4000; i ++){ |
| 83 | gps = linkedList.poll(); | 91 | gps = linkedList.poll(); |
| 84 | if(gps == null) | 92 | if(gps == null) |
| 85 | break; | 93 | break; |
| 86 | list.add(gps); | 94 | list.add(gps); |
| 87 | } | 95 | } |
| 88 | 96 | ||
| 97 | + if(list.size() == 0){ | ||
| 98 | + idleCount ++; | ||
| 99 | + //连续40次没有数据,重建socket连接 | ||
| 100 | + if(idleCount == 40){ | ||
| 101 | + log.info("idleCount == 40"); | ||
| 102 | + idleCount = 0; | ||
| 103 | + clientApp.destroy(); | ||
| 104 | + clientApp.init(); | ||
| 105 | + } | ||
| 106 | + } | ||
| 89 | gpsRealAnalyse.analyse(list); | 107 | gpsRealAnalyse.analyse(list); |
| 90 | } | 108 | } |
| 91 | } | 109 | } |
src/main/java/com/bsth/data/gpsdata/client/pd/codec/MessageDecoder.java
| 1 | package com.bsth.data.gpsdata.client.pd.codec; | 1 | package com.bsth.data.gpsdata.client.pd.codec; |
| 2 | 2 | ||
| 3 | +import com.bsth.data.gpsdata.client.pd.common.ConvertUtil; | ||
| 3 | import com.bsth.data.gpsdata.client.pd.protocol.PdMessage; | 4 | import com.bsth.data.gpsdata.client.pd.protocol.PdMessage; |
| 4 | import org.apache.mina.core.buffer.IoBuffer; | 5 | import org.apache.mina.core.buffer.IoBuffer; |
| 5 | import org.apache.mina.core.session.IoSession; | 6 | import org.apache.mina.core.session.IoSession; |
| 6 | import org.apache.mina.filter.codec.CumulativeProtocolDecoder; | 7 | import org.apache.mina.filter.codec.CumulativeProtocolDecoder; |
| 7 | import org.apache.mina.filter.codec.ProtocolDecoderOutput; | 8 | import org.apache.mina.filter.codec.ProtocolDecoderOutput; |
| 9 | +import org.slf4j.Logger; | ||
| 10 | +import org.slf4j.LoggerFactory; | ||
| 8 | 11 | ||
| 9 | 12 | ||
| 10 | public class MessageDecoder extends CumulativeProtocolDecoder { | 13 | public class MessageDecoder extends CumulativeProtocolDecoder { |
| 11 | 14 | ||
| 15 | + Logger log = LoggerFactory.getLogger(MessageDecoder.class); | ||
| 16 | + | ||
| 12 | @Override | 17 | @Override |
| 13 | protected boolean doDecode(IoSession session, IoBuffer in, | 18 | protected boolean doDecode(IoSession session, IoBuffer in, |
| 14 | ProtocolDecoderOutput out) throws Exception { | 19 | ProtocolDecoderOutput out) throws Exception { |
| @@ -19,15 +24,18 @@ public class MessageDecoder extends CumulativeProtocolDecoder { | @@ -19,15 +24,18 @@ public class MessageDecoder extends CumulativeProtocolDecoder { | ||
| 19 | int len = ((lenh & 0xff) << 8) + (lenl & 0xff); | 24 | int len = ((lenh & 0xff) << 8) + (lenl & 0xff); |
| 20 | if ((head1 & 0xff) == 0xfa && (head2 & 0xff) == 0xf5) { | 25 | if ((head1 & 0xff) == 0xfa && (head2 & 0xff) == 0xf5) { |
| 21 | if (in.remaining() > len) { | 26 | if (in.remaining() > len) { |
| 22 | - byte[] bytes = new byte[len + 1]; | ||
| 23 | - in.get(bytes); | ||
| 24 | - PdMessage msg = new PdMessage(); | ||
| 25 | - msg.read(bytes); | ||
| 26 | - out.write(msg); | ||
| 27 | - /*if ("true".equals(ConfigUtil.getProperty("protocolup", "true"))) { | ||
| 28 | - UpProtocolDataService.getInstance().write(new byte[]{ head1, head2, lenh, lenl }); | ||
| 29 | - UpProtocolDataService.getInstance().write(bytes); | ||
| 30 | - }*/ | 27 | + try { |
| 28 | + byte[] bytes = new byte[len + 1]; | ||
| 29 | + in.get(bytes); | ||
| 30 | + PdMessage msg = new PdMessage(); | ||
| 31 | + msg.read(bytes); | ||
| 32 | + out.write(msg); | ||
| 33 | + | ||
| 34 | + //日志纪录 | ||
| 35 | + log.info("pd client receive: " + ConvertUtil.bytesToHexString(bytes)); | ||
| 36 | + }catch (Exception e){ | ||
| 37 | + log.error("pd message decoder:", e); | ||
| 38 | + } | ||
| 31 | } else { | 39 | } else { |
| 32 | in.reset(); | 40 | in.reset(); |
| 33 | return false; | 41 | return false; |
src/main/java/com/bsth/data/gpsdata/client/pd/common/ConvertUtil.java
| @@ -126,4 +126,24 @@ public class ConvertUtil { | @@ -126,4 +126,24 @@ public class ConvertUtil { | ||
| 126 | 126 | ||
| 127 | return val; | 127 | return val; |
| 128 | } | 128 | } |
| 129 | + | ||
| 130 | + /* Convert byte[] to hex string.这里我们可以将byte转换成int,然后利用Integer.toHexString(int)来转换成16进制字符串。 | ||
| 131 | + * @param src byte[] data | ||
| 132 | +* @return hex string | ||
| 133 | +*/ | ||
| 134 | + public static String bytesToHexString(byte[] src){ | ||
| 135 | + StringBuilder stringBuilder = new StringBuilder(""); | ||
| 136 | + if (src == null || src.length <= 0) { | ||
| 137 | + return null; | ||
| 138 | + } | ||
| 139 | + for (int i = 0; i < src.length; i++) { | ||
| 140 | + int v = src[i] & 0xFF; | ||
| 141 | + String hv = Integer.toHexString(v); | ||
| 142 | + if (hv.length() < 2) { | ||
| 143 | + stringBuilder.append(0); | ||
| 144 | + } | ||
| 145 | + stringBuilder.append(hv); | ||
| 146 | + } | ||
| 147 | + return stringBuilder.toString(); | ||
| 148 | + } | ||
| 129 | } | 149 | } |
src/main/java/com/bsth/data/gpsdata/client/pd/handler/PdClientHandler.java
| @@ -52,6 +52,7 @@ public class PdClientHandler extends IoHandlerAdapter{ | @@ -52,6 +52,7 @@ public class PdClientHandler extends IoHandlerAdapter{ | ||
| 52 | 52 | ||
| 53 | @Override | 53 | @Override |
| 54 | public void sessionIdle(IoSession session, IdleStatus status) throws Exception { | 54 | public void sessionIdle(IoSession session, IdleStatus status) throws Exception { |
| 55 | + log.warn("pd sessionIdle"); | ||
| 55 | session.closeNow(); | 56 | session.closeNow(); |
| 56 | } | 57 | } |
| 57 | 58 |
src/main/java/com/bsth/data/gpsdata/client/pf/codec/MessageDecoder.java
| 1 | package com.bsth.data.gpsdata.client.pf.codec; | 1 | package com.bsth.data.gpsdata.client.pf.codec; |
| 2 | 2 | ||
| 3 | +import com.bsth.data.gpsdata.client.pd.common.ConvertUtil; | ||
| 3 | import com.bsth.data.gpsdata.client.pf.protocol.PfMessage; | 4 | import com.bsth.data.gpsdata.client.pf.protocol.PfMessage; |
| 4 | import org.apache.mina.core.buffer.IoBuffer; | 5 | import org.apache.mina.core.buffer.IoBuffer; |
| 5 | import org.apache.mina.core.session.IoSession; | 6 | import org.apache.mina.core.session.IoSession; |
| 6 | import org.apache.mina.filter.codec.CumulativeProtocolDecoder; | 7 | import org.apache.mina.filter.codec.CumulativeProtocolDecoder; |
| 7 | import org.apache.mina.filter.codec.ProtocolDecoderOutput; | 8 | import org.apache.mina.filter.codec.ProtocolDecoderOutput; |
| 9 | +import org.slf4j.Logger; | ||
| 10 | +import org.slf4j.LoggerFactory; | ||
| 8 | 11 | ||
| 9 | 12 | ||
| 10 | public class MessageDecoder extends CumulativeProtocolDecoder { | 13 | public class MessageDecoder extends CumulativeProtocolDecoder { |
| 11 | 14 | ||
| 15 | + Logger log = LoggerFactory.getLogger(MessageDecoder.class); | ||
| 16 | + | ||
| 12 | @Override | 17 | @Override |
| 13 | protected boolean doDecode(IoSession session, IoBuffer in, | 18 | protected boolean doDecode(IoSession session, IoBuffer in, |
| 14 | ProtocolDecoderOutput out) throws Exception { | 19 | ProtocolDecoderOutput out) throws Exception { |
| @@ -19,11 +24,18 @@ public class MessageDecoder extends CumulativeProtocolDecoder { | @@ -19,11 +24,18 @@ public class MessageDecoder extends CumulativeProtocolDecoder { | ||
| 19 | int len = ((lenh & 0xff) << 8) + (lenl & 0xff); | 24 | int len = ((lenh & 0xff) << 8) + (lenl & 0xff); |
| 20 | if ((head1 & 0xff) == 0xfa && (head2 & 0xff) == 0xf5) { | 25 | if ((head1 & 0xff) == 0xfa && (head2 & 0xff) == 0xf5) { |
| 21 | if (in.remaining() > len) { | 26 | if (in.remaining() > len) { |
| 22 | - byte[] bytes = new byte[len + 1]; | ||
| 23 | - in.get(bytes); | ||
| 24 | - PfMessage msg = new PfMessage(); | ||
| 25 | - msg.read(bytes); | ||
| 26 | - out.write(msg); | 27 | + try { |
| 28 | + byte[] bytes = new byte[len + 1]; | ||
| 29 | + in.get(bytes); | ||
| 30 | + PfMessage msg = new PfMessage(); | ||
| 31 | + msg.read(bytes); | ||
| 32 | + | ||
| 33 | + //日志纪录 | ||
| 34 | + log.info("pf client receive: " + ConvertUtil.bytesToHexString(bytes)); | ||
| 35 | + out.write(msg); | ||
| 36 | + }catch (Exception e){ | ||
| 37 | + log.error("pf message decoder:", e); | ||
| 38 | + } | ||
| 27 | } else { | 39 | } else { |
| 28 | in.reset(); | 40 | in.reset(); |
| 29 | return false; | 41 | return false; |
src/main/java/com/bsth/data/gpsdata/client/pf/handler/PfClientHandler.java
| @@ -49,6 +49,7 @@ public class PfClientHandler extends IoHandlerAdapter{ | @@ -49,6 +49,7 @@ public class PfClientHandler extends IoHandlerAdapter{ | ||
| 49 | 49 | ||
| 50 | @Override | 50 | @Override |
| 51 | public void sessionIdle(IoSession session, IdleStatus status) throws Exception { | 51 | public void sessionIdle(IoSession session, IdleStatus status) throws Exception { |
| 52 | + log.warn("pf sessionIdle"); | ||
| 52 | session.closeNow(); | 53 | session.closeNow(); |
| 53 | } | 54 | } |
| 54 | 55 |
src/main/java/com/bsth/data/gpsdata/recovery/GpsDataRecovery.java
| @@ -45,11 +45,11 @@ public class GpsDataRecovery implements ApplicationContextAware { | @@ -45,11 +45,11 @@ public class GpsDataRecovery implements ApplicationContextAware { | ||
| 45 | public void recovery() { | 45 | public void recovery() { |
| 46 | List<GpsEntity> list = loadData(); | 46 | List<GpsEntity> list = loadData(); |
| 47 | 47 | ||
| 48 | - //按车辆分组数据 | 48 | + //按线路分组数据 |
| 49 | ArrayListMultimap<String, GpsEntity> listMap = ArrayListMultimap.create(); | 49 | ArrayListMultimap<String, GpsEntity> listMap = ArrayListMultimap.create(); |
| 50 | for (GpsEntity gps : list) { | 50 | for (GpsEntity gps : list) { |
| 51 | - if (gps.getNbbm() != null) | ||
| 52 | - listMap.put(gps.getNbbm(), gps); | 51 | + if (gps.getLineId() != null) |
| 52 | + listMap.put(gps.getLineId(), gps); | ||
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | 55 | ||
| @@ -57,9 +57,9 @@ public class GpsDataRecovery implements ApplicationContextAware { | @@ -57,9 +57,9 @@ public class GpsDataRecovery implements ApplicationContextAware { | ||
| 57 | 57 | ||
| 58 | CountDownLatch count = new CountDownLatch(keys.size()); | 58 | CountDownLatch count = new CountDownLatch(keys.size()); |
| 59 | GpsComp comp = new GpsComp(); | 59 | GpsComp comp = new GpsComp(); |
| 60 | - for (String nbbm : keys) { | ||
| 61 | - Collections.sort(listMap.get(nbbm), comp); | ||
| 62 | - threadPool.execute(new RecoveryThread(listMap.get(nbbm), count)); | 60 | + for (String lineId : keys) { |
| 61 | + Collections.sort(listMap.get(lineId), comp); | ||
| 62 | + threadPool.execute(new RecoveryThread(listMap.get(lineId), count)); | ||
| 63 | /*if(nbbm.equals("W7C-001")) | 63 | /*if(nbbm.equals("W7C-001")) |
| 64 | new RecoveryThread(listMap.get(nbbm), count).run();*/ | 64 | new RecoveryThread(listMap.get(nbbm), count).run();*/ |
| 65 | } | 65 | } |
src/main/java/com/bsth/entity/CarPark.java
| @@ -3,6 +3,9 @@ package com.bsth.entity; | @@ -3,6 +3,9 @@ package com.bsth.entity; | ||
| 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
| 4 | 4 | ||
| 5 | import javax.persistence.*; | 5 | import javax.persistence.*; |
| 6 | + | ||
| 7 | +import org.hibernate.annotations.Formula; | ||
| 8 | + | ||
| 6 | import java.util.Date; | 9 | import java.util.Date; |
| 7 | 10 | ||
| 8 | 11 | ||
| @@ -77,6 +80,10 @@ public class CarPark { | @@ -77,6 +80,10 @@ public class CarPark { | ||
| 77 | // 分公司 | 80 | // 分公司 |
| 78 | private String brancheCompany; | 81 | private String brancheCompany; |
| 79 | 82 | ||
| 83 | + /** 组合公司分公司编码 */ | ||
| 84 | + @Formula(" concat(company, '_', branche_company) ") | ||
| 85 | + private String cgsbm; | ||
| 86 | + | ||
| 80 | // 是否撤销 | 87 | // 是否撤销 |
| 81 | private Integer destroy; | 88 | private Integer destroy; |
| 82 | 89 | ||
| @@ -99,6 +106,14 @@ public class CarPark { | @@ -99,6 +106,14 @@ public class CarPark { | ||
| 99 | // 修改日期 | 106 | // 修改日期 |
| 100 | @Column(name = "update_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP") | 107 | @Column(name = "update_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP") |
| 101 | private Date updateDate; | 108 | private Date updateDate; |
| 109 | + | ||
| 110 | + public String getCgsbm() { | ||
| 111 | + return cgsbm; | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | + public void setCgsbm(String cgsbm) { | ||
| 115 | + this.cgsbm = cgsbm; | ||
| 116 | + } | ||
| 102 | 117 | ||
| 103 | public Integer getId() { | 118 | public Integer getId() { |
| 104 | return id; | 119 | return id; |
src/main/java/com/bsth/repository/CarParkRepository.java
| @@ -107,4 +107,7 @@ public interface CarParkRepository extends BaseRepository<CarPark, Integer>{ | @@ -107,4 +107,7 @@ public interface CarParkRepository extends BaseRepository<CarPark, Integer>{ | ||
| 107 | 107 | ||
| 108 | @Query(value = "select st_astext(g_park_point), shapes_type, g_center_point, radius,park_code,park_name from bsth_c_car_park where park_code=?1", nativeQuery = true) | 108 | @Query(value = "select st_astext(g_park_point), shapes_type, g_center_point, radius,park_code,park_name from bsth_c_car_park where park_code=?1", nativeQuery = true) |
| 109 | public Object[][] bufferAera(String parkCode); | 109 | public Object[][] bufferAera(String parkCode); |
| 110 | + | ||
| 111 | + @Query(value ="SELECT p.park_name,p.park_code from bsth_c_car_park p where p.park_code = ?1", nativeQuery=true) | ||
| 112 | + List<Object[]> selectTccInfoByCode(String parkCode); | ||
| 110 | } | 113 | } |
src/main/java/com/bsth/service/CarParkService.java
| @@ -28,5 +28,6 @@ public interface CarParkService extends BaseService<CarPark, Integer> { | @@ -28,5 +28,6 @@ public interface CarParkService extends BaseService<CarPark, Integer> { | ||
| 28 | * | 28 | * |
| 29 | */ | 29 | */ |
| 30 | Map<String, Object> carParkUpdate(Map<String, Object> map); | 30 | Map<String, Object> carParkUpdate(Map<String, Object> map); |
| 31 | - | 31 | + |
| 32 | + boolean selectTccInfoByCode(Map<String, Object> map); | ||
| 32 | } | 33 | } |
src/main/java/com/bsth/service/impl/CarParkServiceImpl.java
| @@ -26,55 +26,30 @@ public class CarParkServiceImpl extends BaseServiceImpl<CarPark, Integer> implem | @@ -26,55 +26,30 @@ public class CarParkServiceImpl extends BaseServiceImpl<CarPark, Integer> implem | ||
| 26 | 26 | ||
| 27 | @Override | 27 | @Override |
| 28 | public Map<String, Object> carParkSave(Map<String, Object> map) { | 28 | public Map<String, Object> carParkSave(Map<String, Object> map) { |
| 29 | - | ||
| 30 | Map<String, Object> resultMap = new HashMap<String, Object>(); | 29 | Map<String, Object> resultMap = new HashMap<String, Object>(); |
| 31 | - | ||
| 32 | try { | 30 | try { |
| 33 | - | ||
| 34 | // 停车场编码 | 31 | // 停车场编码 |
| 35 | String parkCode = map.get("parkCode").equals("") ? null : map.get("parkCode").toString(); | 32 | String parkCode = map.get("parkCode").equals("") ? null : map.get("parkCode").toString(); |
| 36 | - | ||
| 37 | - // 停车场id | ||
| 38 | - // Integer id = Integer.parseInt(parkCode); | ||
| 39 | - | ||
| 40 | // 停车场名称 | 33 | // 停车场名称 |
| 41 | String parkName = map.get("parkName").equals("") ? "" : map.get("parkName").toString(); | 34 | String parkName = map.get("parkName").equals("") ? "" : map.get("parkName").toString(); |
| 42 | - | ||
| 43 | // 地理位置(百度坐标集合) | 35 | // 地理位置(百度坐标集合) |
| 44 | String bParkPoint = map.get("bParkPoint").equals("") ? "" : map.get("bParkPoint").toString(); | 36 | String bParkPoint = map.get("bParkPoint").equals("") ? "" : map.get("bParkPoint").toString(); |
| 45 | - | ||
| 46 | - // 地理位置(WGS坐标集合) | ||
| 47 | - // String gParkPoint = map.get("gParkPoint").equals("") ? "" :map.get("gParkPoint").toString(); | ||
| 48 | - | ||
| 49 | // 多边形WGS坐标点集合 | 37 | // 多边形WGS坐标点集合 |
| 50 | String gParkPoint =""; | 38 | String gParkPoint =""; |
| 51 | - | ||
| 52 | if(!bParkPoint.equals("")) { | 39 | if(!bParkPoint.equals("")) { |
| 53 | - | ||
| 54 | String bPloygonGridArray[] = bParkPoint.split(","); | 40 | String bPloygonGridArray[] = bParkPoint.split(","); |
| 55 | - | ||
| 56 | int bLen_ = bPloygonGridArray.length; | 41 | int bLen_ = bPloygonGridArray.length; |
| 57 | - | ||
| 58 | for(int b = 0 ;b<bLen_;b++) { | 42 | for(int b = 0 ;b<bLen_;b++) { |
| 59 | - | ||
| 60 | String tempArray[]= bPloygonGridArray[b].split(" "); | 43 | String tempArray[]= bPloygonGridArray[b].split(" "); |
| 61 | - | ||
| 62 | Location resultPoint = FromBDPointToWGSPoint(tempArray[0],tempArray[1]); | 44 | Location resultPoint = FromBDPointToWGSPoint(tempArray[0],tempArray[1]); |
| 63 | - | ||
| 64 | if(b==0) { | 45 | if(b==0) { |
| 65 | - | ||
| 66 | gParkPoint = resultPoint.getLng() + " " + resultPoint.getLat(); | 46 | gParkPoint = resultPoint.getLng() + " " + resultPoint.getLat(); |
| 67 | - | ||
| 68 | }else { | 47 | }else { |
| 69 | - | ||
| 70 | gParkPoint = gParkPoint + ',' + resultPoint.getLng() + " " + resultPoint.getLat(); | 48 | gParkPoint = gParkPoint + ',' + resultPoint.getLng() + " " + resultPoint.getLat(); |
| 71 | - | ||
| 72 | } | 49 | } |
| 73 | - | ||
| 74 | } | 50 | } |
| 75 | 51 | ||
| 76 | } | 52 | } |
| 77 | - | ||
| 78 | if(bParkPoint.equals("")) | 53 | if(bParkPoint.equals("")) |
| 79 | bParkPoint = null; | 54 | bParkPoint = null; |
| 80 | else | 55 | else |
| @@ -84,169 +59,92 @@ public class CarParkServiceImpl extends BaseServiceImpl<CarPark, Integer> implem | @@ -84,169 +59,92 @@ public class CarParkServiceImpl extends BaseServiceImpl<CarPark, Integer> implem | ||
| 84 | gParkPoint = null; | 59 | gParkPoint = null; |
| 85 | else | 60 | else |
| 86 | gParkPoint = "POLYGON((" + gParkPoint +"))"; | 61 | gParkPoint = "POLYGON((" + gParkPoint +"))"; |
| 87 | - | ||
| 88 | - /*bParkPoint = "POLYGON((" + bParkPoint +"))"; | ||
| 89 | - | ||
| 90 | - gParkPoint = "POLYGON((" + gParkPoint +"))";*/ | ||
| 91 | - | ||
| 92 | // 地理位置中心点(百度坐标) | 62 | // 地理位置中心点(百度坐标) |
| 93 | String bCenterPoint = map.get("bCenterPoint").equals("") ? "" : map.get("bCenterPoint").toString(); | 63 | String bCenterPoint = map.get("bCenterPoint").equals("") ? "" : map.get("bCenterPoint").toString(); |
| 94 | - | ||
| 95 | - // 地理位置中心点(WGS坐标) | ||
| 96 | - // String gCenterPoint = map.get("gCenterPoint").equals("") ? "" : map.get("gCenterPoint").toString(); | ||
| 97 | - | ||
| 98 | String bJwpointsArray[] =null; | 64 | String bJwpointsArray[] =null; |
| 99 | - | ||
| 100 | if(bCenterPoint!=null) { | 65 | if(bCenterPoint!=null) { |
| 101 | - | ||
| 102 | bJwpointsArray = bCenterPoint.split(" "); | 66 | bJwpointsArray = bCenterPoint.split(" "); |
| 103 | - | ||
| 104 | } | 67 | } |
| 105 | - | ||
| 106 | String gCenterPoint = null; | 68 | String gCenterPoint = null; |
| 107 | - | ||
| 108 | if(bJwpointsArray.length>0) { | 69 | if(bJwpointsArray.length>0) { |
| 109 | - | ||
| 110 | Location resultPoint = FromBDPointToWGSPoint(bJwpointsArray[0],bJwpointsArray[1]); | 70 | Location resultPoint = FromBDPointToWGSPoint(bJwpointsArray[0],bJwpointsArray[1]); |
| 111 | - | ||
| 112 | gCenterPoint = String.valueOf(resultPoint.getLng()) + " " + String.valueOf(resultPoint.getLat()); | 71 | gCenterPoint = String.valueOf(resultPoint.getLng()) + " " + String.valueOf(resultPoint.getLat()); |
| 113 | - | ||
| 114 | } | 72 | } |
| 115 | - | ||
| 116 | // 坐标类型 | 73 | // 坐标类型 |
| 117 | String dbType = map.get("dbType").equals("") ? "" : map.get("dbType").toString(); | 74 | String dbType = map.get("dbType").equals("") ? "" : map.get("dbType").toString(); |
| 118 | - | ||
| 119 | // 图形类型 | 75 | // 图形类型 |
| 120 | String shapesType = map.get("shapesType").equals("") ? "" : map.get("shapesType").toString(); | 76 | String shapesType = map.get("shapesType").equals("") ? "" : map.get("shapesType").toString(); |
| 121 | - | ||
| 122 | // 半径 | 77 | // 半径 |
| 123 | Integer radius = map.get("radius").equals("") ? null : Integer.parseInt(map.get("radius").toString()); | 78 | Integer radius = map.get("radius").equals("") ? null : Integer.parseInt(map.get("radius").toString()); |
| 124 | - | ||
| 125 | // 面积 | 79 | // 面积 |
| 126 | Double area = map.get("area").equals("") ? 0.0 : Double.parseDouble(map.get("area").toString()); | 80 | Double area = map.get("area").equals("") ? 0.0 : Double.parseDouble(map.get("area").toString()); |
| 127 | - | ||
| 128 | // 公司 | 81 | // 公司 |
| 129 | String company = map.get("company").equals("") ? "" : map.get("company").toString(); | 82 | String company = map.get("company").equals("") ? "" : map.get("company").toString(); |
| 130 | - | ||
| 131 | // 分公司 | 83 | // 分公司 |
| 132 | - /*String brancheCompany = map.get("brancheCompany").equals("") ? "" : map.get("brancheCompany").toString();*/ | ||
| 133 | - String brancheCompany=""; | ||
| 134 | - | 84 | + String brancheCompany = map.get("brancheCompany").equals("") ? "" : map.get("brancheCompany").toString(); |
| 135 | // 是否撤销 | 85 | // 是否撤销 |
| 136 | Integer destroy = map.get("destroy").equals("") ? null : Integer.parseInt(map.get("destroy").toString()); | 86 | Integer destroy = map.get("destroy").equals("") ? null : Integer.parseInt(map.get("destroy").toString()); |
| 137 | - | ||
| 138 | // 版本号 | 87 | // 版本号 |
| 139 | Integer versions = map.get("versions").equals("") ? null : Integer.parseInt(map.get("versions").toString()); | 88 | Integer versions = map.get("versions").equals("") ? null : Integer.parseInt(map.get("versions").toString()); |
| 140 | - | ||
| 141 | // 描述与说明 | 89 | // 描述与说明 |
| 142 | String descriptions = map.get("descriptions").equals("") ? "" : map.get("descriptions").toString(); | 90 | String descriptions = map.get("descriptions").equals("") ? "" : map.get("descriptions").toString(); |
| 143 | - | ||
| 144 | SimpleDateFormat formatter = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss"); | 91 | SimpleDateFormat formatter = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss"); |
| 145 | - | ||
| 146 | Date date = new Date(); | 92 | Date date = new Date(); |
| 147 | - | ||
| 148 | // 创建日期 | 93 | // 创建日期 |
| 149 | String createDate = formatter.format(date); | 94 | String createDate = formatter.format(date); |
| 150 | - | ||
| 151 | // 修改日期 | 95 | // 修改日期 |
| 152 | String updateDate = formatter.format(date); | 96 | String updateDate = formatter.format(date); |
| 153 | - | ||
| 154 | // 创建人 | 97 | // 创建人 |
| 155 | Integer createBy = map.get("createBy").equals("") ? null : Integer.parseInt(map.get("createBy").toString()); | 98 | Integer createBy = map.get("createBy").equals("") ? null : Integer.parseInt(map.get("createBy").toString()); |
| 156 | - | ||
| 157 | // 修改人 | 99 | // 修改人 |
| 158 | Integer updateBy = map.get("updateBy").equals("") ? null : Integer.parseInt(map.get("updateBy").toString()); | 100 | Integer updateBy = map.get("updateBy").equals("") ? null : Integer.parseInt(map.get("updateBy").toString()); |
| 159 | - | ||
| 160 | - | ||
| 161 | - | ||
| 162 | - | ||
| 163 | carParkRepository.carParkSave(area, company, parkCode, parkName, | 101 | carParkRepository.carParkSave(area, company, parkCode, parkName, |
| 164 | - | ||
| 165 | brancheCompany, createBy, createDate, descriptions, destroy, | 102 | brancheCompany, createBy, createDate, descriptions, destroy, |
| 166 | - | ||
| 167 | updateBy, updateDate, versions, bCenterPoint, bParkPoint, | 103 | updateBy, updateDate, versions, bCenterPoint, bParkPoint, |
| 168 | - | ||
| 169 | dbType, gCenterPoint, gParkPoint, radius, shapesType); | 104 | dbType, gCenterPoint, gParkPoint, radius, shapesType); |
| 170 | - | ||
| 171 | resultMap.put("status", ResponseCode.SUCCESS); | 105 | resultMap.put("status", ResponseCode.SUCCESS); |
| 172 | - | ||
| 173 | } catch (Exception e) { | 106 | } catch (Exception e) { |
| 174 | - | ||
| 175 | resultMap.put("status", ResponseCode.ERROR); | 107 | resultMap.put("status", ResponseCode.ERROR); |
| 176 | - | ||
| 177 | logger.error("save erro.", e); | 108 | logger.error("save erro.", e); |
| 178 | - | ||
| 179 | } | 109 | } |
| 180 | - | ||
| 181 | return resultMap; | 110 | return resultMap; |
| 182 | } | 111 | } |
| 183 | 112 | ||
| 184 | @Override | 113 | @Override |
| 185 | public List<Map<String, Object>> findCarParkInfoFormId(Map<String, Object> map) { | 114 | public List<Map<String, Object>> findCarParkInfoFormId(Map<String, Object> map) { |
| 186 | - | ||
| 187 | // 获取线路ID | 115 | // 获取线路ID |
| 188 | Integer id = map.get("id").equals("") ? 0 : Integer.parseInt(map.get("id").toString()); | 116 | Integer id = map.get("id").equals("") ? 0 : Integer.parseInt(map.get("id").toString()); |
| 189 | - | ||
| 190 | List<Object[]> objects = carParkRepository.findCarParkInfoFormId(id); | 117 | List<Object[]> objects = carParkRepository.findCarParkInfoFormId(id); |
| 191 | - | ||
| 192 | List<Map<String, Object>> resultList = new ArrayList<Map<String,Object>>(); | 118 | List<Map<String, Object>> resultList = new ArrayList<Map<String,Object>>(); |
| 193 | - | ||
| 194 | int len = objects.size(); | 119 | int len = objects.size(); |
| 195 | - | ||
| 196 | if(objects.size()>0) { | 120 | if(objects.size()>0) { |
| 197 | - | ||
| 198 | for(int i = 0 ; i < len; i++) { | 121 | for(int i = 0 ; i < len; i++) { |
| 199 | - | ||
| 200 | Map<String, Object> tempM = new HashMap<String,Object>(); | 122 | Map<String, Object> tempM = new HashMap<String,Object>(); |
| 201 | - | ||
| 202 | tempM.put("carParkId", objects.get(i)[0]); | 123 | tempM.put("carParkId", objects.get(i)[0]); |
| 203 | - | ||
| 204 | tempM.put("carParkArea", objects.get(i)[1]); | 124 | tempM.put("carParkArea", objects.get(i)[1]); |
| 205 | - | ||
| 206 | tempM.put("carParkCompany", objects.get(i)[2]); | 125 | tempM.put("carParkCompany", objects.get(i)[2]); |
| 207 | - | ||
| 208 | tempM.put("carParkCode", objects.get(i)[3]); | 126 | tempM.put("carParkCode", objects.get(i)[3]); |
| 209 | - | ||
| 210 | tempM.put("carParkName", objects.get(i)[4]); | 127 | tempM.put("carParkName", objects.get(i)[4]); |
| 211 | - | ||
| 212 | tempM.put("carParkBrancheCompany", objects.get(i)[5]); | 128 | tempM.put("carParkBrancheCompany", objects.get(i)[5]); |
| 213 | - | ||
| 214 | tempM.put("carParkCreateBy", objects.get(i)[6]); | 129 | tempM.put("carParkCreateBy", objects.get(i)[6]); |
| 215 | - | ||
| 216 | tempM.put("carParkCreateDate", objects.get(i)[7]); | 130 | tempM.put("carParkCreateDate", objects.get(i)[7]); |
| 217 | - | ||
| 218 | tempM.put("carParkDescriptions", objects.get(i)[8]); | 131 | tempM.put("carParkDescriptions", objects.get(i)[8]); |
| 219 | - | ||
| 220 | tempM.put("carParkDestroy", objects.get(i)[9]); | 132 | tempM.put("carParkDestroy", objects.get(i)[9]); |
| 221 | - | ||
| 222 | tempM.put("carParkUpdate", objects.get(i)[10]); | 133 | tempM.put("carParkUpdate", objects.get(i)[10]); |
| 223 | - | ||
| 224 | tempM.put("carParkUpdateDate", objects.get(i)[11]); | 134 | tempM.put("carParkUpdateDate", objects.get(i)[11]); |
| 225 | - | ||
| 226 | tempM.put("carParkVersions", objects.get(i)[12]); | 135 | tempM.put("carParkVersions", objects.get(i)[12]); |
| 227 | - | ||
| 228 | tempM.put("carParkBcenterPoint", objects.get(i)[13]); | 136 | tempM.put("carParkBcenterPoint", objects.get(i)[13]); |
| 229 | - | ||
| 230 | tempM.put("carParkBparkPoint", objects.get(i)[14]); | 137 | tempM.put("carParkBparkPoint", objects.get(i)[14]); |
| 231 | - | ||
| 232 | tempM.put("carParkGcenterPoint", objects.get(i)[15]); | 138 | tempM.put("carParkGcenterPoint", objects.get(i)[15]); |
| 233 | - | ||
| 234 | tempM.put("carParkGparkPoint", objects.get(i)[16]); | 139 | tempM.put("carParkGparkPoint", objects.get(i)[16]); |
| 235 | - | ||
| 236 | tempM.put("carParkDBtype", objects.get(i)[17]); | 140 | tempM.put("carParkDBtype", objects.get(i)[17]); |
| 237 | - | ||
| 238 | tempM.put("carParkRadius", objects.get(i)[18]); | 141 | tempM.put("carParkRadius", objects.get(i)[18]); |
| 239 | - | ||
| 240 | tempM.put("carParkShapesType", objects.get(i)[19]); | 142 | tempM.put("carParkShapesType", objects.get(i)[19]); |
| 241 | - | ||
| 242 | resultList.add(tempM); | 143 | resultList.add(tempM); |
| 243 | } | 144 | } |
| 244 | - | ||
| 245 | } | 145 | } |
| 246 | - | ||
| 247 | return resultList; | 146 | return resultList; |
| 248 | } | 147 | } |
| 249 | - | ||
| 250 | /** | 148 | /** |
| 251 | * 修改停车场信息 | 149 | * 修改停车场信息 |
| 252 | * | 150 | * |
| @@ -265,90 +163,54 @@ public class CarParkServiceImpl extends BaseServiceImpl<CarPark, Integer> implem | @@ -265,90 +163,54 @@ public class CarParkServiceImpl extends BaseServiceImpl<CarPark, Integer> implem | ||
| 265 | @Override | 163 | @Override |
| 266 | public Map<String, Object> carParkUpdate(Map<String, Object> map) { | 164 | public Map<String, Object> carParkUpdate(Map<String, Object> map) { |
| 267 | Map<String, Object> resultMap = new HashMap<String, Object>(); | 165 | Map<String, Object> resultMap = new HashMap<String, Object>(); |
| 268 | - | ||
| 269 | try { | 166 | try { |
| 270 | - | ||
| 271 | // id | 167 | // id |
| 272 | Integer id = map.get("id").equals("") ? null : Integer.parseInt(map.get("id").toString()); | 168 | Integer id = map.get("id").equals("") ? null : Integer.parseInt(map.get("id").toString()); |
| 273 | - | ||
| 274 | if(id!=null) { | 169 | if(id!=null) { |
| 275 | - | ||
| 276 | // 面积 | 170 | // 面积 |
| 277 | Double area = map.get("area").equals("") ? null : Double.parseDouble(map.get("area").toString()); | 171 | Double area = map.get("area").equals("") ? null : Double.parseDouble(map.get("area").toString()); |
| 278 | - | ||
| 279 | // 中心点(百度坐标) | 172 | // 中心点(百度坐标) |
| 280 | String bCenterPoint = map.get("bCenterPoint").equals("") ? "" : map.get("bCenterPoint").toString(); | 173 | String bCenterPoint = map.get("bCenterPoint").equals("") ? "" : map.get("bCenterPoint").toString(); |
| 281 | - | ||
| 282 | // 图形坐标点集合(百度坐标) | 174 | // 图形坐标点集合(百度坐标) |
| 283 | String bParkPoint = map.get("bParkPoint").equals("") ? "" : map.get("bParkPoint").toString(); | 175 | String bParkPoint = map.get("bParkPoint").equals("") ? "" : map.get("bParkPoint").toString(); |
| 284 | - | ||
| 285 | // 分公司 | 176 | // 分公司 |
| 286 | - /*String brancheCompany = map.get("brancheCompany").equals("")? "" :map.get("brancheCompany").toString();*/ | ||
| 287 | - String brancheCompany = ""; | ||
| 288 | - | 177 | + String brancheCompany = map.get("brancheCompany").equals("")? "" :map.get("brancheCompany").toString(); |
| 178 | + //String brancheCompany = ""; | ||
| 289 | // 公司 | 179 | // 公司 |
| 290 | String company = map.get("company").equals("") ? "" : map.get("company").toString(); | 180 | String company = map.get("company").equals("") ? "" : map.get("company").toString(); |
| 291 | - | ||
| 292 | // 坐标类型 | 181 | // 坐标类型 |
| 293 | String dbType = map.get("dbType").equals("") ? "" : map.get("dbType").toString(); | 182 | String dbType = map.get("dbType").equals("") ? "" : map.get("dbType").toString(); |
| 294 | - | ||
| 295 | // 描述与说明 | 183 | // 描述与说明 |
| 296 | String descriptions = map.get("descriptions").equals("") ? "" : map.get("descriptions").toString(); | 184 | String descriptions = map.get("descriptions").equals("") ? "" : map.get("descriptions").toString(); |
| 297 | - | ||
| 298 | // 是否撤销 | 185 | // 是否撤销 |
| 299 | Integer destroy = map.get("destroy").equals("") ? null : Integer.parseInt(map.get("destroy").toString()); | 186 | Integer destroy = map.get("destroy").equals("") ? null : Integer.parseInt(map.get("destroy").toString()); |
| 300 | - | ||
| 301 | // 中心点(WGS坐标) | 187 | // 中心点(WGS坐标) |
| 302 | // String gCenterPoint = map.get("gCenterPoint").equals("") ? "" : map.get("gCenterPoint").toString(); | 188 | // String gCenterPoint = map.get("gCenterPoint").equals("") ? "" : map.get("gCenterPoint").toString(); |
| 303 | - | ||
| 304 | String bJwpointsArray[] =null; | 189 | String bJwpointsArray[] =null; |
| 305 | - | ||
| 306 | if(bCenterPoint!=null) { | 190 | if(bCenterPoint!=null) { |
| 307 | - | ||
| 308 | bJwpointsArray = bCenterPoint.split(" "); | 191 | bJwpointsArray = bCenterPoint.split(" "); |
| 309 | - | ||
| 310 | } | 192 | } |
| 311 | - | ||
| 312 | String gCenterPoint =null; | 193 | String gCenterPoint =null; |
| 313 | - | ||
| 314 | if(bJwpointsArray.length>0) { | 194 | if(bJwpointsArray.length>0) { |
| 315 | - | ||
| 316 | Location resultPoint = FromBDPointToWGSPoint(bJwpointsArray[0],bJwpointsArray[1]); | 195 | Location resultPoint = FromBDPointToWGSPoint(bJwpointsArray[0],bJwpointsArray[1]); |
| 317 | - | ||
| 318 | gCenterPoint = String.valueOf(resultPoint.getLng()) + " " + String.valueOf(resultPoint.getLat()); | 196 | gCenterPoint = String.valueOf(resultPoint.getLng()) + " " + String.valueOf(resultPoint.getLat()); |
| 319 | - | ||
| 320 | } | 197 | } |
| 321 | - | ||
| 322 | // 图形坐标点集合(WGS坐标) | 198 | // 图形坐标点集合(WGS坐标) |
| 323 | // String gParkPoint = map.get("gParkPoint").equals("") ? "" : map.get("gParkPoint").toString(); | 199 | // String gParkPoint = map.get("gParkPoint").equals("") ? "" : map.get("gParkPoint").toString(); |
| 324 | - | ||
| 325 | // 多边形WGS坐标点集合 | 200 | // 多边形WGS坐标点集合 |
| 326 | String gParkPoint =""; | 201 | String gParkPoint =""; |
| 327 | - | ||
| 328 | if(!bParkPoint.equals("")) { | 202 | if(!bParkPoint.equals("")) { |
| 329 | - | ||
| 330 | String bPloygonGridArray[] = bParkPoint.split(","); | 203 | String bPloygonGridArray[] = bParkPoint.split(","); |
| 331 | - | ||
| 332 | int bLen_ = bPloygonGridArray.length; | 204 | int bLen_ = bPloygonGridArray.length; |
| 333 | - | ||
| 334 | for(int b = 0 ;b<bLen_;b++) { | 205 | for(int b = 0 ;b<bLen_;b++) { |
| 335 | - | ||
| 336 | String tempArray[]= bPloygonGridArray[b].split(" "); | 206 | String tempArray[]= bPloygonGridArray[b].split(" "); |
| 337 | - | ||
| 338 | Location resultPoint = FromBDPointToWGSPoint(tempArray[0],tempArray[1]); | 207 | Location resultPoint = FromBDPointToWGSPoint(tempArray[0],tempArray[1]); |
| 339 | - | ||
| 340 | if(b==0) { | 208 | if(b==0) { |
| 341 | - | ||
| 342 | gParkPoint = resultPoint.getLng() + " " + resultPoint.getLat(); | 209 | gParkPoint = resultPoint.getLng() + " " + resultPoint.getLat(); |
| 343 | - | ||
| 344 | }else { | 210 | }else { |
| 345 | - | ||
| 346 | gParkPoint = gParkPoint + ',' + resultPoint.getLng() + " " + resultPoint.getLat(); | 211 | gParkPoint = gParkPoint + ',' + resultPoint.getLng() + " " + resultPoint.getLat(); |
| 347 | - | ||
| 348 | } | 212 | } |
| 349 | - | ||
| 350 | } | 213 | } |
| 351 | - | ||
| 352 | } | 214 | } |
| 353 | if(bParkPoint.equals("")) | 215 | if(bParkPoint.equals("")) |
| 354 | bParkPoint = null; | 216 | bParkPoint = null; |
| @@ -362,69 +224,51 @@ public class CarParkServiceImpl extends BaseServiceImpl<CarPark, Integer> implem | @@ -362,69 +224,51 @@ public class CarParkServiceImpl extends BaseServiceImpl<CarPark, Integer> implem | ||
| 362 | /*bParkPoint = "POLYGON((" + bParkPoint +"))"; | 224 | /*bParkPoint = "POLYGON((" + bParkPoint +"))"; |
| 363 | 225 | ||
| 364 | gParkPoint = "POLYGON((" + gParkPoint +"))";*/ | 226 | gParkPoint = "POLYGON((" + gParkPoint +"))";*/ |
| 365 | - | ||
| 366 | // 编码 | 227 | // 编码 |
| 367 | String parkCode = map.get("parkCode").equals("") ? "" : map.get("parkCode").toString(); | 228 | String parkCode = map.get("parkCode").equals("") ? "" : map.get("parkCode").toString(); |
| 368 | - | ||
| 369 | // 名称 | 229 | // 名称 |
| 370 | String parkName = map.get("parkName").equals("") ? "" : map.get("parkName").toString(); | 230 | String parkName = map.get("parkName").equals("") ? "" : map.get("parkName").toString(); |
| 371 | - | ||
| 372 | // 半径 | 231 | // 半径 |
| 373 | Integer radius = map.get("radius").equals("") ? null : Integer.parseInt(map.get("radius").toString()); | 232 | Integer radius = map.get("radius").equals("") ? null : Integer.parseInt(map.get("radius").toString()); |
| 374 | - | ||
| 375 | // 图形类型 | 233 | // 图形类型 |
| 376 | String shapesType = map.get("shapesType").equals("") ? "" : map.get("shapesType").toString(); | 234 | String shapesType = map.get("shapesType").equals("") ? "" : map.get("shapesType").toString(); |
| 377 | - | ||
| 378 | // 版本 | 235 | // 版本 |
| 379 | Integer versions = map.get("versions").equals("") ? null : Integer.parseInt(map.get("versions").toString()); | 236 | Integer versions = map.get("versions").equals("") ? null : Integer.parseInt(map.get("versions").toString()); |
| 380 | - | ||
| 381 | // 创建人 | 237 | // 创建人 |
| 382 | Integer createBy = map.get("createBy").equals("") ? null : Integer.parseInt(map.get("createBy").toString()); | 238 | Integer createBy = map.get("createBy").equals("") ? null : Integer.parseInt(map.get("createBy").toString()); |
| 383 | - | ||
| 384 | // 创建日期 | 239 | // 创建日期 |
| 385 | String createDate = map.get("createDate").equals("") ? "" : map.get("createDate").toString(); | 240 | String createDate = map.get("createDate").equals("") ? "" : map.get("createDate").toString(); |
| 386 | - | ||
| 387 | Integer updateBy = map.get("updateBy").equals("") ? null : Integer.parseInt(map.get("updateBy").toString()); | 241 | Integer updateBy = map.get("updateBy").equals("") ? null : Integer.parseInt(map.get("updateBy").toString()); |
| 388 | - | ||
| 389 | SimpleDateFormat formatter = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss"); | 242 | SimpleDateFormat formatter = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss"); |
| 390 | - | ||
| 391 | Date date = new Date(); | 243 | Date date = new Date(); |
| 392 | - | ||
| 393 | // 修改日期 | 244 | // 修改日期 |
| 394 | String updateDate = formatter.format(date); | 245 | String updateDate = formatter.format(date); |
| 395 | - | ||
| 396 | carParkRepository.carParkUpdate(area, company, parkCode, parkName, brancheCompany, createBy, createDate, descriptions, destroy, updateBy, updateDate, versions, bCenterPoint, gCenterPoint, bParkPoint, gParkPoint, dbType, radius, shapesType, id); | 246 | carParkRepository.carParkUpdate(area, company, parkCode, parkName, brancheCompany, createBy, createDate, descriptions, destroy, updateBy, updateDate, versions, bCenterPoint, gCenterPoint, bParkPoint, gParkPoint, dbType, radius, shapesType, id); |
| 397 | - | ||
| 398 | } | 247 | } |
| 399 | - | ||
| 400 | resultMap.put("status", ResponseCode.SUCCESS); | 248 | resultMap.put("status", ResponseCode.SUCCESS); |
| 401 | - | ||
| 402 | } catch (Exception e) { | 249 | } catch (Exception e) { |
| 403 | - | ||
| 404 | resultMap.put("status", ResponseCode.ERROR); | 250 | resultMap.put("status", ResponseCode.ERROR); |
| 405 | - | ||
| 406 | logger.error("save erro.", e); | 251 | logger.error("save erro.", e); |
| 407 | - | ||
| 408 | } | 252 | } |
| 409 | - | ||
| 410 | return resultMap; | 253 | return resultMap; |
| 411 | } | 254 | } |
| 412 | - | ||
| 413 | /** 百度坐标转WGS坐标 */ | 255 | /** 百度坐标转WGS坐标 */ |
| 414 | public Location FromBDPointToWGSPoint(String bLonx,String bLatx) { | 256 | public Location FromBDPointToWGSPoint(String bLonx,String bLatx) { |
| 415 | - | ||
| 416 | double lng = Double.parseDouble(bLonx); | 257 | double lng = Double.parseDouble(bLonx); |
| 417 | - | ||
| 418 | double lat = Double.parseDouble(bLatx); | 258 | double lat = Double.parseDouble(bLatx); |
| 419 | - | ||
| 420 | Location bdLoc = TransGPS.LocationMake(lng, lat); | 259 | Location bdLoc = TransGPS.LocationMake(lng, lat); |
| 421 | - | ||
| 422 | Location location = TransGPS.bd_decrypt(bdLoc); | 260 | Location location = TransGPS.bd_decrypt(bdLoc); |
| 423 | - | ||
| 424 | Location WGSPoint = TransGPS.transformFromGCJToWGS(location); | 261 | Location WGSPoint = TransGPS.transformFromGCJToWGS(location); |
| 425 | - | ||
| 426 | return WGSPoint; | 262 | return WGSPoint; |
| 427 | - | ||
| 428 | } | 263 | } |
| 429 | - | 264 | + |
| 265 | + @Override | ||
| 266 | + public boolean selectTccInfoByCode(Map<String, Object> map) { | ||
| 267 | + List<Object[]> arrayObj = carParkRepository.selectTccInfoByCode(map.get("parkCode").equals("") ? "" : map.get("parkCode").toString()); | ||
| 268 | + boolean tag = true; | ||
| 269 | + if(arrayObj.size()>0) { | ||
| 270 | + tag= false; | ||
| 271 | + } | ||
| 272 | + return tag; | ||
| 273 | + } | ||
| 430 | } | 274 | } |
src/main/java/com/bsth/service/schedule/rules/ScheduleRuleServiceImpl.java
| @@ -112,6 +112,9 @@ public class ScheduleRuleServiceImpl implements ScheduleRuleService { | @@ -112,6 +112,9 @@ public class ScheduleRuleServiceImpl implements ScheduleRuleService { | ||
| 112 | public SchedulePlanRuleResult mapRow(ResultSet rs, int i) throws SQLException { | 112 | public SchedulePlanRuleResult mapRow(ResultSet rs, int i) throws SQLException { |
| 113 | SchedulePlanRuleResult obj = new SchedulePlanRuleResult(); | 113 | SchedulePlanRuleResult obj = new SchedulePlanRuleResult(); |
| 114 | obj.setRuleId(rs.getString("rule_id")); | 114 | obj.setRuleId(rs.getString("rule_id")); |
| 115 | + obj.setCcZbh(rs.getString("cc_zbh")); | ||
| 116 | + obj.setGids(rs.getString("gids")); | ||
| 117 | + obj.setEcids(rs.getString("ecids")); | ||
| 115 | obj.setScheduleDate(rs.getDate("schedule_date")); | 118 | obj.setScheduleDate(rs.getDate("schedule_date")); |
| 116 | obj.setGidindex(rs.getString("gidindex")); | 119 | obj.setGidindex(rs.getString("gidindex")); |
| 117 | obj.setEcindex(rs.getString("ecindex")); | 120 | obj.setEcindex(rs.getString("ecindex")); |
src/main/java/com/bsth/service/schedule/rules/shiftloop/ScheduleRule_input.java
| 1 | package com.bsth.service.schedule.rules.shiftloop; | 1 | package com.bsth.service.schedule.rules.shiftloop; |
| 2 | 2 | ||
| 3 | import com.bsth.entity.schedule.rule.ScheduleRule1Flat; | 3 | import com.bsth.entity.schedule.rule.ScheduleRule1Flat; |
| 4 | +import com.bsth.service.schedule.utils.Md5Util; | ||
| 4 | import com.google.common.base.Splitter; | 5 | import com.google.common.base.Splitter; |
| 5 | import org.apache.commons.lang3.StringUtils; | 6 | import org.apache.commons.lang3.StringUtils; |
| 6 | import org.joda.time.DateTime; | 7 | import org.joda.time.DateTime; |
| @@ -17,6 +18,12 @@ public class ScheduleRule_input { | @@ -17,6 +18,12 @@ public class ScheduleRule_input { | ||
| 17 | 18 | ||
| 18 | /** 规则Id */ | 19 | /** 规则Id */ |
| 19 | private String ruleId; | 20 | private String ruleId; |
| 21 | + /** | ||
| 22 | + * 规则md5值(不使用id判定,使用md5判定) | ||
| 23 | + * 使用,启用日期,路牌范围,人员范围 结合生成md5编码 | ||
| 24 | + */ | ||
| 25 | + private String ruleMd5; | ||
| 26 | + | ||
| 20 | /** 规则启用日期 */ | 27 | /** 规则启用日期 */ |
| 21 | private DateTime qyrq; | 28 | private DateTime qyrq; |
| 22 | 29 | ||
| @@ -78,9 +85,20 @@ public class ScheduleRule_input { | @@ -78,9 +85,20 @@ public class ScheduleRule_input { | ||
| 78 | } | 85 | } |
| 79 | } | 86 | } |
| 80 | 87 | ||
| 88 | + /** 生成规则md5编码 */ | ||
| 89 | + ruleMd5 = Md5Util.getMd5( | ||
| 90 | + String.valueOf(qyrq.getMillis()) + "_" + | ||
| 91 | + scheduleRule1Flat.getLpIds() + "_" + | ||
| 92 | + scheduleRule1Flat.getRyConfigIds() | ||
| 93 | + ); | ||
| 94 | + | ||
| 95 | + System.out.println("rule的md5:" + ruleMd5 + " 车辆:" + scheduleRule1Flat.getCarConfigInfo().getCl().getInsideCode()); | ||
| 96 | + | ||
| 81 | this.self = scheduleRule1Flat; | 97 | this.self = scheduleRule1Flat; |
| 82 | } | 98 | } |
| 83 | 99 | ||
| 100 | + | ||
| 101 | + | ||
| 84 | public String getRuleId() { | 102 | public String getRuleId() { |
| 85 | return ruleId; | 103 | return ruleId; |
| 86 | } | 104 | } |
| @@ -160,4 +178,12 @@ public class ScheduleRule_input { | @@ -160,4 +178,12 @@ public class ScheduleRule_input { | ||
| 160 | public void setSelf(ScheduleRule1Flat self) { | 178 | public void setSelf(ScheduleRule1Flat self) { |
| 161 | this.self = self; | 179 | this.self = self; |
| 162 | } | 180 | } |
| 181 | + | ||
| 182 | + public String getRuleMd5() { | ||
| 183 | + return ruleMd5; | ||
| 184 | + } | ||
| 185 | + | ||
| 186 | + public void setRuleMd5(String ruleMd5) { | ||
| 187 | + this.ruleMd5 = ruleMd5; | ||
| 188 | + } | ||
| 163 | } | 189 | } |
src/main/java/com/bsth/service/schedule/utils/Md5Util.java
0 → 100644
| 1 | +package com.bsth.service.schedule.utils; | ||
| 2 | + | ||
| 3 | +import java.security.MessageDigest; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * Md5工具。 | ||
| 7 | + */ | ||
| 8 | +public class Md5Util { | ||
| 9 | + private static MessageDigest md5 = null; | ||
| 10 | + static { | ||
| 11 | + try { | ||
| 12 | + md5 = MessageDigest.getInstance("MD5"); | ||
| 13 | + } catch (Exception exp) { | ||
| 14 | + exp.printStackTrace(); | ||
| 15 | + } | ||
| 16 | + } | ||
| 17 | + | ||
| 18 | + /** | ||
| 19 | + * 用于获取一个String的md5值。 | ||
| 20 | + * @param str | ||
| 21 | + * @return | ||
| 22 | + */ | ||
| 23 | + public static String getMd5(String str) { | ||
| 24 | + byte[] bs = md5.digest(str.getBytes()); | ||
| 25 | + StringBuilder s = new StringBuilder(); | ||
| 26 | + for (byte x : bs) { | ||
| 27 | + if ((x & 0xff) >>4 == 0) { | ||
| 28 | + s.append("0").append(Integer.toHexString(x & 0xff)); | ||
| 29 | + } else { | ||
| 30 | + s.append(Integer.toHexString(x & 0xff)); | ||
| 31 | + } | ||
| 32 | + } | ||
| 33 | + return s.toString(); | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | +} |
src/main/resources/application-dev.properties
| @@ -10,7 +10,7 @@ spring.jpa.show-sql= true | @@ -10,7 +10,7 @@ spring.jpa.show-sql= true | ||
| 10 | spring.datasource.driver-class-name= com.mysql.jdbc.Driver | 10 | spring.datasource.driver-class-name= com.mysql.jdbc.Driver |
| 11 | spring.datasource.url= jdbc:mysql://127.0.0.1/control?useUnicode=true&characterEncoding=utf-8&useSSL=false | 11 | spring.datasource.url= jdbc:mysql://127.0.0.1/control?useUnicode=true&characterEncoding=utf-8&useSSL=false |
| 12 | spring.datasource.username= root | 12 | spring.datasource.username= root |
| 13 | -spring.datasource.password= root | 13 | +spring.datasource.password= |
| 14 | #spring.datasource.url= jdbc:mysql://192.168.168.117/pd_control?useUnicode=true&characterEncoding=utf-8&useSSL=false | 14 | #spring.datasource.url= jdbc:mysql://192.168.168.117/pd_control?useUnicode=true&characterEncoding=utf-8&useSSL=false |
| 15 | #spring.datasource.username= root | 15 | #spring.datasource.username= root |
| 16 | #spring.datasource.password= root | 16 | #spring.datasource.password= root |