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 | 15 | @RestController |
| 16 | 16 | @RequestMapping("carpark") |
| 17 | 17 | public class CarParkController extends BaseController<CarPark, Integer> { |
| 18 | - | |
| 19 | 18 | @Autowired |
| 20 | 19 | CarParkService service; |
| 21 | 20 | |
| ... | ... | @@ -26,16 +25,10 @@ public class CarParkController extends BaseController<CarPark, Integer> { |
| 26 | 25 | */ |
| 27 | 26 | @RequestMapping(value="getCarParkCode" , method = RequestMethod.GET) |
| 28 | 27 | public Map<String, Object> getStationCode() { |
| 29 | - | |
| 30 | 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 | 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 | 46 | */ |
| 54 | 47 | @RequestMapping(value="carParkSave" , method = RequestMethod.POST) |
| 55 | 48 | public Map<String, Object> stationSave(@RequestParam Map<String, Object> map) { |
| 56 | - | |
| 57 | 49 | map.put("createBy", ""); |
| 58 | - | |
| 59 | 50 | map.put("updateBy", ""); |
| 60 | - | |
| 61 | 51 | return service.carParkSave(map); |
| 62 | - | |
| 63 | 52 | } |
| 64 | - | |
| 65 | 53 | @RequestMapping(value = "findCarParkInfoFormId",method = RequestMethod.GET) |
| 66 | 54 | public List<Map<String, Object>> findCarParkInfoFormId(@RequestParam Map<String, Object> map) { |
| 67 | - | |
| 68 | 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 | 71 | */ |
| 86 | 72 | @RequestMapping(value="carParkUpdate" , method = RequestMethod.POST) |
| 87 | 73 | public Map<String, Object> carParkUpdate(@RequestParam Map<String, Object> map) { |
| 88 | - | |
| 89 | 74 | map.put("updateBy", ""); |
| 90 | - | |
| 91 | 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 | 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 | 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 | 101 | ps.setString(1, sch.getScheduleDateStr()); |
| 102 | 102 | ps.setString(2, sch.getXlBm()); |
| 103 | 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 | 108 | ps.setString(8, BasicData.nbbmCompanyPlateMap.get(sch.getClZbh())); |
| 109 | 109 | ps.setString(9, bcTypeMap.containsKey(sch.getBcType()) ? bcTypeMap.get(sch.getBcType()) : sch.getBcType()); |
| 110 | 110 | ps.setString(10, sch.getZdzName()); | ... | ... |
src/main/java/com/bsth/data/gpsdata/GpsRealData.java
| ... | ... | @@ -4,6 +4,7 @@ import com.bsth.Application; |
| 4 | 4 | import com.bsth.data.BasicData; |
| 5 | 5 | import com.bsth.data.forecast.ForecastRealServer; |
| 6 | 6 | import com.bsth.data.gpsdata.client.ClientApp; |
| 7 | +import com.bsth.data.gpsdata.client.GpsBeforeBuffer; | |
| 7 | 8 | import com.bsth.data.gpsdata.thread.GpsDataLoaderThread; |
| 8 | 9 | import com.bsth.data.gpsdata.thread.OfflineMonitorThread; |
| 9 | 10 | import com.bsth.data.schedule.DayOfSchedule; |
| ... | ... | @@ -17,6 +18,7 @@ import org.springframework.boot.CommandLineRunner; |
| 17 | 18 | import org.springframework.stereotype.Component; |
| 18 | 19 | |
| 19 | 20 | import java.util.*; |
| 21 | +import java.util.concurrent.ConcurrentHashMap; | |
| 20 | 22 | import java.util.concurrent.TimeUnit; |
| 21 | 23 | |
| 22 | 24 | /** |
| ... | ... | @@ -30,7 +32,7 @@ public class GpsRealData implements CommandLineRunner { |
| 30 | 32 | |
| 31 | 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 | 38 | private static TreeMultimap<String, String> lineCode2Devices; |
| ... | ... | @@ -51,12 +53,14 @@ public class GpsRealData implements CommandLineRunner { |
| 51 | 53 | * 构造函数 |
| 52 | 54 | */ |
| 53 | 55 | public GpsRealData() { |
| 54 | - gpsMap = new HashMap<>(); | |
| 56 | + gpsMap = new ConcurrentHashMap<>(); | |
| 55 | 57 | lineCode2Devices = TreeMultimap.create(); |
| 56 | 58 | } |
| 57 | 59 | |
| 58 | 60 | @Autowired |
| 59 | 61 | ClientApp clientApp; |
| 62 | + @Autowired | |
| 63 | + GpsBeforeBuffer gpsBeforeBuffer; | |
| 60 | 64 | @Override |
| 61 | 65 | public void run(String... arg0) throws Exception { |
| 62 | 66 | logger.info("gpsDataLoader,20,3"); |
| ... | ... | @@ -67,6 +71,7 @@ public class GpsRealData implements CommandLineRunner { |
| 67 | 71 | |
| 68 | 72 | //gps 客户端 |
| 69 | 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 | 11 | import org.springframework.beans.factory.annotation.Autowired; |
| 12 | 12 | import org.springframework.stereotype.Component; |
| 13 | 13 | |
| 14 | +import java.util.Collections; | |
| 15 | +import java.util.Comparator; | |
| 14 | 16 | import java.util.List; |
| 15 | 17 | import java.util.Set; |
| 16 | 18 | import java.util.concurrent.CountDownLatch; |
| ... | ... | @@ -42,25 +44,26 @@ public class GpsRealAnalyse { |
| 42 | 44 | @Autowired |
| 43 | 45 | GpsRealData gpsRealData; |
| 44 | 46 | |
| 45 | - //50个线程 | |
| 46 | - static ExecutorService threadPool = Executors.newFixedThreadPool(50); | |
| 47 | + static ExecutorService threadPool = Executors.newFixedThreadPool(100); | |
| 47 | 48 | |
| 48 | 49 | public void analyse(List<GpsEntity> list) { |
| 49 | 50 | //如果正在恢复数据 |
| 50 | 51 | if (GpsDataRecovery.run) |
| 51 | 52 | return; |
| 53 | + | |
| 54 | + long t = System.currentTimeMillis(); | |
| 52 | 55 | logger.info("analyse gps size: " + list.size()); |
| 53 | - //按车辆分组gps | |
| 56 | + //按线路分组gps | |
| 54 | 57 | ArrayListMultimap multimap = ArrayListMultimap.create(); |
| 55 | 58 | for(GpsEntity gps : list){ |
| 56 | - multimap.put(gps.getNbbm(), gps); | |
| 59 | + multimap.put(gps.getLineId(), gps); | |
| 57 | 60 | } |
| 58 | 61 | |
| 59 | 62 | Set<String> ks = multimap.keySet(); |
| 60 | 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 | 69 | try { |
| ... | ... | @@ -70,11 +73,15 @@ public class GpsRealAnalyse { |
| 70 | 73 | //加入实时gps对照 |
| 71 | 74 | for(GpsEntity gps: list) |
| 72 | 75 | gpsRealData.put(gps); |
| 76 | + | |
| 77 | + logger.info("time , " + (System.currentTimeMillis() - t)); | |
| 73 | 78 | } catch (InterruptedException e) { |
| 74 | 79 | logger.error("", e); |
| 75 | 80 | } |
| 76 | 81 | } |
| 77 | 82 | |
| 83 | + static GpsComp comp = new GpsComp(); | |
| 84 | + | |
| 78 | 85 | public class SignalHandleThread implements Runnable { |
| 79 | 86 | |
| 80 | 87 | List<GpsEntity> list; |
| ... | ... | @@ -89,6 +96,7 @@ public class GpsRealAnalyse { |
| 89 | 96 | public void run() { |
| 90 | 97 | |
| 91 | 98 | try { |
| 99 | + Collections.sort(list, comp); | |
| 92 | 100 | for(GpsEntity gps : list){ |
| 93 | 101 | //是否有任务 |
| 94 | 102 | boolean task; |
| ... | ... | @@ -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 | 21 | import org.springframework.stereotype.Component; |
| 22 | 22 | |
| 23 | 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 | 27 | * Created by panzhao on 2017/5/4. |
| ... | ... | @@ -43,17 +40,9 @@ public class ClientApp { |
| 43 | 40 | GpsBeforeBuffer gpsBeforeBuffer; |
| 44 | 41 | |
| 45 | 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 | 47 | public static boolean dconnect(String device) { |
| 59 | 48 | boolean flag = false; |
| ... | ... | @@ -85,12 +74,66 @@ public class ClientApp { |
| 85 | 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 | 109 | public static void pdreconn(){ |
| 89 | - dconnect(ConfigUtil.get("forward.device.name")); | |
| 110 | + pdconnect(ConfigUtil.get("forward.device.name")); | |
| 90 | 111 | } |
| 91 | 112 | |
| 92 | 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 | 139 | public static boolean fconnect(String device) { |
| ... | ... | @@ -111,7 +154,17 @@ public class ClientApp { |
| 111 | 154 | } |
| 112 | 155 | |
| 113 | 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 | 168 | sexec.scheduleAtFixedRate(new SessionChecker(), 1, 1, TimeUnit.MINUTES); |
| 116 | 169 | /*******************************浦东********************************/ |
| 117 | 170 | pdDataConnector = new NioSocketConnector(); |
| ... | ... | @@ -133,7 +186,7 @@ public class ClientApp { |
| 133 | 186 | |
| 134 | 187 | pdDataConnector.setHandler(pdClient); |
| 135 | 188 | |
| 136 | - dconnect(ConfigUtil.get("forward.device.name")); | |
| 189 | + pdconnect(ConfigUtil.get("forward.device.name")); | |
| 137 | 190 | /*******************************浦东转发********************************/ |
| 138 | 191 | pfDataConnector = new NioSocketConnector(); |
| 139 | 192 | |
| ... | ... | @@ -153,10 +206,7 @@ public class ClientApp { |
| 153 | 206 | config1.setIdleTime(IdleStatus.BOTH_IDLE, 60); |
| 154 | 207 | |
| 155 | 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 | 232 | logger.error("SessionChecker异常", e); |
| 183 | 233 | } |
| 184 | 234 | } |
| 185 | - | |
| 186 | 235 | } |
| 187 | 236 | } |
| 188 | 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 | import com.bsth.data.gpsdata.arrival.GpsRealAnalyse; |
| 7 | 7 | import com.bsth.data.gpsdata.client.pd.protocol.BasicInfo; |
| 8 | 8 | import org.apache.commons.lang3.StringUtils; |
| 9 | +import org.slf4j.Logger; | |
| 10 | +import org.slf4j.LoggerFactory; | |
| 9 | 11 | import org.springframework.beans.factory.annotation.Autowired; |
| 10 | 12 | import org.springframework.stereotype.Component; |
| 11 | 13 | |
| ... | ... | @@ -63,9 +65,10 @@ public class GpsBeforeBuffer { |
| 63 | 65 | } |
| 64 | 66 | |
| 65 | 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 | 72 | @Component |
| 70 | 73 | public static class GpsHandleThread extends Thread{ |
| 71 | 74 | |
| ... | ... | @@ -74,18 +77,33 @@ public class GpsBeforeBuffer { |
| 74 | 77 | @Autowired |
| 75 | 78 | GpsRealAnalyse gpsRealAnalyse; |
| 76 | 79 | |
| 80 | + @Autowired | |
| 81 | + ClientApp clientApp; | |
| 82 | + | |
| 83 | + Logger log = LoggerFactory.getLogger(this.getClass()); | |
| 84 | + | |
| 77 | 85 | @Override |
| 78 | 86 | public void run() { |
| 79 | - list = new ArrayList<>(100); | |
| 87 | + list = new ArrayList<>(200); | |
| 80 | 88 | |
| 81 | 89 | GpsEntity gps; |
| 82 | - for(int i = 0; i < 2000; i ++){ | |
| 90 | + for(int i = 0; i < 4000; i ++){ | |
| 83 | 91 | gps = linkedList.poll(); |
| 84 | 92 | if(gps == null) |
| 85 | 93 | break; |
| 86 | 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 | 107 | gpsRealAnalyse.analyse(list); |
| 90 | 108 | } |
| 91 | 109 | } | ... | ... |
src/main/java/com/bsth/data/gpsdata/client/pd/codec/MessageDecoder.java
| 1 | 1 | package com.bsth.data.gpsdata.client.pd.codec; |
| 2 | 2 | |
| 3 | +import com.bsth.data.gpsdata.client.pd.common.ConvertUtil; | |
| 3 | 4 | import com.bsth.data.gpsdata.client.pd.protocol.PdMessage; |
| 4 | 5 | import org.apache.mina.core.buffer.IoBuffer; |
| 5 | 6 | import org.apache.mina.core.session.IoSession; |
| 6 | 7 | import org.apache.mina.filter.codec.CumulativeProtocolDecoder; |
| 7 | 8 | import org.apache.mina.filter.codec.ProtocolDecoderOutput; |
| 9 | +import org.slf4j.Logger; | |
| 10 | +import org.slf4j.LoggerFactory; | |
| 8 | 11 | |
| 9 | 12 | |
| 10 | 13 | public class MessageDecoder extends CumulativeProtocolDecoder { |
| 11 | 14 | |
| 15 | + Logger log = LoggerFactory.getLogger(MessageDecoder.class); | |
| 16 | + | |
| 12 | 17 | @Override |
| 13 | 18 | protected boolean doDecode(IoSession session, IoBuffer in, |
| 14 | 19 | ProtocolDecoderOutput out) throws Exception { |
| ... | ... | @@ -19,15 +24,18 @@ public class MessageDecoder extends CumulativeProtocolDecoder { |
| 19 | 24 | int len = ((lenh & 0xff) << 8) + (lenl & 0xff); |
| 20 | 25 | if ((head1 & 0xff) == 0xfa && (head2 & 0xff) == 0xf5) { |
| 21 | 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 | 39 | } else { |
| 32 | 40 | in.reset(); |
| 33 | 41 | return false; | ... | ... |
src/main/java/com/bsth/data/gpsdata/client/pd/common/ConvertUtil.java
| ... | ... | @@ -126,4 +126,24 @@ public class ConvertUtil { |
| 126 | 126 | |
| 127 | 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
src/main/java/com/bsth/data/gpsdata/client/pf/codec/MessageDecoder.java
| 1 | 1 | package com.bsth.data.gpsdata.client.pf.codec; |
| 2 | 2 | |
| 3 | +import com.bsth.data.gpsdata.client.pd.common.ConvertUtil; | |
| 3 | 4 | import com.bsth.data.gpsdata.client.pf.protocol.PfMessage; |
| 4 | 5 | import org.apache.mina.core.buffer.IoBuffer; |
| 5 | 6 | import org.apache.mina.core.session.IoSession; |
| 6 | 7 | import org.apache.mina.filter.codec.CumulativeProtocolDecoder; |
| 7 | 8 | import org.apache.mina.filter.codec.ProtocolDecoderOutput; |
| 9 | +import org.slf4j.Logger; | |
| 10 | +import org.slf4j.LoggerFactory; | |
| 8 | 11 | |
| 9 | 12 | |
| 10 | 13 | public class MessageDecoder extends CumulativeProtocolDecoder { |
| 11 | 14 | |
| 15 | + Logger log = LoggerFactory.getLogger(MessageDecoder.class); | |
| 16 | + | |
| 12 | 17 | @Override |
| 13 | 18 | protected boolean doDecode(IoSession session, IoBuffer in, |
| 14 | 19 | ProtocolDecoderOutput out) throws Exception { |
| ... | ... | @@ -19,11 +24,18 @@ public class MessageDecoder extends CumulativeProtocolDecoder { |
| 19 | 24 | int len = ((lenh & 0xff) << 8) + (lenl & 0xff); |
| 20 | 25 | if ((head1 & 0xff) == 0xfa && (head2 & 0xff) == 0xf5) { |
| 21 | 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 | 39 | } else { |
| 28 | 40 | in.reset(); |
| 29 | 41 | return false; | ... | ... |
src/main/java/com/bsth/data/gpsdata/client/pf/handler/PfClientHandler.java
src/main/java/com/bsth/data/gpsdata/recovery/GpsDataRecovery.java
| ... | ... | @@ -45,11 +45,11 @@ public class GpsDataRecovery implements ApplicationContextAware { |
| 45 | 45 | public void recovery() { |
| 46 | 46 | List<GpsEntity> list = loadData(); |
| 47 | 47 | |
| 48 | - //按车辆分组数据 | |
| 48 | + //按线路分组数据 | |
| 49 | 49 | ArrayListMultimap<String, GpsEntity> listMap = ArrayListMultimap.create(); |
| 50 | 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 | 57 | |
| 58 | 58 | CountDownLatch count = new CountDownLatch(keys.size()); |
| 59 | 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 | 63 | /*if(nbbm.equals("W7C-001")) |
| 64 | 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 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
| 4 | 4 | |
| 5 | 5 | import javax.persistence.*; |
| 6 | + | |
| 7 | +import org.hibernate.annotations.Formula; | |
| 8 | + | |
| 6 | 9 | import java.util.Date; |
| 7 | 10 | |
| 8 | 11 | |
| ... | ... | @@ -77,6 +80,10 @@ public class CarPark { |
| 77 | 80 | // 分公司 |
| 78 | 81 | private String brancheCompany; |
| 79 | 82 | |
| 83 | + /** 组合公司分公司编码 */ | |
| 84 | + @Formula(" concat(company, '_', branche_company) ") | |
| 85 | + private String cgsbm; | |
| 86 | + | |
| 80 | 87 | // 是否撤销 |
| 81 | 88 | private Integer destroy; |
| 82 | 89 | |
| ... | ... | @@ -99,6 +106,14 @@ public class CarPark { |
| 99 | 106 | // 修改日期 |
| 100 | 107 | @Column(name = "update_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP") |
| 101 | 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 | 118 | public Integer getId() { |
| 104 | 119 | return id; | ... | ... |
src/main/java/com/bsth/repository/CarParkRepository.java
| ... | ... | @@ -107,4 +107,7 @@ public interface CarParkRepository extends BaseRepository<CarPark, Integer>{ |
| 107 | 107 | |
| 108 | 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 | 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
src/main/java/com/bsth/service/impl/CarParkServiceImpl.java
| ... | ... | @@ -26,55 +26,30 @@ public class CarParkServiceImpl extends BaseServiceImpl<CarPark, Integer> implem |
| 26 | 26 | |
| 27 | 27 | @Override |
| 28 | 28 | public Map<String, Object> carParkSave(Map<String, Object> map) { |
| 29 | - | |
| 30 | 29 | Map<String, Object> resultMap = new HashMap<String, Object>(); |
| 31 | - | |
| 32 | 30 | try { |
| 33 | - | |
| 34 | 31 | // 停车场编码 |
| 35 | 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 | 34 | String parkName = map.get("parkName").equals("") ? "" : map.get("parkName").toString(); |
| 42 | - | |
| 43 | 35 | // 地理位置(百度坐标集合) |
| 44 | 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 | 37 | // 多边形WGS坐标点集合 |
| 50 | 38 | String gParkPoint =""; |
| 51 | - | |
| 52 | 39 | if(!bParkPoint.equals("")) { |
| 53 | - | |
| 54 | 40 | String bPloygonGridArray[] = bParkPoint.split(","); |
| 55 | - | |
| 56 | 41 | int bLen_ = bPloygonGridArray.length; |
| 57 | - | |
| 58 | 42 | for(int b = 0 ;b<bLen_;b++) { |
| 59 | - | |
| 60 | 43 | String tempArray[]= bPloygonGridArray[b].split(" "); |
| 61 | - | |
| 62 | 44 | Location resultPoint = FromBDPointToWGSPoint(tempArray[0],tempArray[1]); |
| 63 | - | |
| 64 | 45 | if(b==0) { |
| 65 | - | |
| 66 | 46 | gParkPoint = resultPoint.getLng() + " " + resultPoint.getLat(); |
| 67 | - | |
| 68 | 47 | }else { |
| 69 | - | |
| 70 | 48 | gParkPoint = gParkPoint + ',' + resultPoint.getLng() + " " + resultPoint.getLat(); |
| 71 | - | |
| 72 | 49 | } |
| 73 | - | |
| 74 | 50 | } |
| 75 | 51 | |
| 76 | 52 | } |
| 77 | - | |
| 78 | 53 | if(bParkPoint.equals("")) |
| 79 | 54 | bParkPoint = null; |
| 80 | 55 | else |
| ... | ... | @@ -84,169 +59,92 @@ public class CarParkServiceImpl extends BaseServiceImpl<CarPark, Integer> implem |
| 84 | 59 | gParkPoint = null; |
| 85 | 60 | else |
| 86 | 61 | gParkPoint = "POLYGON((" + gParkPoint +"))"; |
| 87 | - | |
| 88 | - /*bParkPoint = "POLYGON((" + bParkPoint +"))"; | |
| 89 | - | |
| 90 | - gParkPoint = "POLYGON((" + gParkPoint +"))";*/ | |
| 91 | - | |
| 92 | 62 | // 地理位置中心点(百度坐标) |
| 93 | 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 | 64 | String bJwpointsArray[] =null; |
| 99 | - | |
| 100 | 65 | if(bCenterPoint!=null) { |
| 101 | - | |
| 102 | 66 | bJwpointsArray = bCenterPoint.split(" "); |
| 103 | - | |
| 104 | 67 | } |
| 105 | - | |
| 106 | 68 | String gCenterPoint = null; |
| 107 | - | |
| 108 | 69 | if(bJwpointsArray.length>0) { |
| 109 | - | |
| 110 | 70 | Location resultPoint = FromBDPointToWGSPoint(bJwpointsArray[0],bJwpointsArray[1]); |
| 111 | - | |
| 112 | 71 | gCenterPoint = String.valueOf(resultPoint.getLng()) + " " + String.valueOf(resultPoint.getLat()); |
| 113 | - | |
| 114 | 72 | } |
| 115 | - | |
| 116 | 73 | // 坐标类型 |
| 117 | 74 | String dbType = map.get("dbType").equals("") ? "" : map.get("dbType").toString(); |
| 118 | - | |
| 119 | 75 | // 图形类型 |
| 120 | 76 | String shapesType = map.get("shapesType").equals("") ? "" : map.get("shapesType").toString(); |
| 121 | - | |
| 122 | 77 | // 半径 |
| 123 | 78 | Integer radius = map.get("radius").equals("") ? null : Integer.parseInt(map.get("radius").toString()); |
| 124 | - | |
| 125 | 79 | // 面积 |
| 126 | 80 | Double area = map.get("area").equals("") ? 0.0 : Double.parseDouble(map.get("area").toString()); |
| 127 | - | |
| 128 | 81 | // 公司 |
| 129 | 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 | 86 | Integer destroy = map.get("destroy").equals("") ? null : Integer.parseInt(map.get("destroy").toString()); |
| 137 | - | |
| 138 | 87 | // 版本号 |
| 139 | 88 | Integer versions = map.get("versions").equals("") ? null : Integer.parseInt(map.get("versions").toString()); |
| 140 | - | |
| 141 | 89 | // 描述与说明 |
| 142 | 90 | String descriptions = map.get("descriptions").equals("") ? "" : map.get("descriptions").toString(); |
| 143 | - | |
| 144 | 91 | SimpleDateFormat formatter = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss"); |
| 145 | - | |
| 146 | 92 | Date date = new Date(); |
| 147 | - | |
| 148 | 93 | // 创建日期 |
| 149 | 94 | String createDate = formatter.format(date); |
| 150 | - | |
| 151 | 95 | // 修改日期 |
| 152 | 96 | String updateDate = formatter.format(date); |
| 153 | - | |
| 154 | 97 | // 创建人 |
| 155 | 98 | Integer createBy = map.get("createBy").equals("") ? null : Integer.parseInt(map.get("createBy").toString()); |
| 156 | - | |
| 157 | 99 | // 修改人 |
| 158 | 100 | Integer updateBy = map.get("updateBy").equals("") ? null : Integer.parseInt(map.get("updateBy").toString()); |
| 159 | - | |
| 160 | - | |
| 161 | - | |
| 162 | - | |
| 163 | 101 | carParkRepository.carParkSave(area, company, parkCode, parkName, |
| 164 | - | |
| 165 | 102 | brancheCompany, createBy, createDate, descriptions, destroy, |
| 166 | - | |
| 167 | 103 | updateBy, updateDate, versions, bCenterPoint, bParkPoint, |
| 168 | - | |
| 169 | 104 | dbType, gCenterPoint, gParkPoint, radius, shapesType); |
| 170 | - | |
| 171 | 105 | resultMap.put("status", ResponseCode.SUCCESS); |
| 172 | - | |
| 173 | 106 | } catch (Exception e) { |
| 174 | - | |
| 175 | 107 | resultMap.put("status", ResponseCode.ERROR); |
| 176 | - | |
| 177 | 108 | logger.error("save erro.", e); |
| 178 | - | |
| 179 | 109 | } |
| 180 | - | |
| 181 | 110 | return resultMap; |
| 182 | 111 | } |
| 183 | 112 | |
| 184 | 113 | @Override |
| 185 | 114 | public List<Map<String, Object>> findCarParkInfoFormId(Map<String, Object> map) { |
| 186 | - | |
| 187 | 115 | // 获取线路ID |
| 188 | 116 | Integer id = map.get("id").equals("") ? 0 : Integer.parseInt(map.get("id").toString()); |
| 189 | - | |
| 190 | 117 | List<Object[]> objects = carParkRepository.findCarParkInfoFormId(id); |
| 191 | - | |
| 192 | 118 | List<Map<String, Object>> resultList = new ArrayList<Map<String,Object>>(); |
| 193 | - | |
| 194 | 119 | int len = objects.size(); |
| 195 | - | |
| 196 | 120 | if(objects.size()>0) { |
| 197 | - | |
| 198 | 121 | for(int i = 0 ; i < len; i++) { |
| 199 | - | |
| 200 | 122 | Map<String, Object> tempM = new HashMap<String,Object>(); |
| 201 | - | |
| 202 | 123 | tempM.put("carParkId", objects.get(i)[0]); |
| 203 | - | |
| 204 | 124 | tempM.put("carParkArea", objects.get(i)[1]); |
| 205 | - | |
| 206 | 125 | tempM.put("carParkCompany", objects.get(i)[2]); |
| 207 | - | |
| 208 | 126 | tempM.put("carParkCode", objects.get(i)[3]); |
| 209 | - | |
| 210 | 127 | tempM.put("carParkName", objects.get(i)[4]); |
| 211 | - | |
| 212 | 128 | tempM.put("carParkBrancheCompany", objects.get(i)[5]); |
| 213 | - | |
| 214 | 129 | tempM.put("carParkCreateBy", objects.get(i)[6]); |
| 215 | - | |
| 216 | 130 | tempM.put("carParkCreateDate", objects.get(i)[7]); |
| 217 | - | |
| 218 | 131 | tempM.put("carParkDescriptions", objects.get(i)[8]); |
| 219 | - | |
| 220 | 132 | tempM.put("carParkDestroy", objects.get(i)[9]); |
| 221 | - | |
| 222 | 133 | tempM.put("carParkUpdate", objects.get(i)[10]); |
| 223 | - | |
| 224 | 134 | tempM.put("carParkUpdateDate", objects.get(i)[11]); |
| 225 | - | |
| 226 | 135 | tempM.put("carParkVersions", objects.get(i)[12]); |
| 227 | - | |
| 228 | 136 | tempM.put("carParkBcenterPoint", objects.get(i)[13]); |
| 229 | - | |
| 230 | 137 | tempM.put("carParkBparkPoint", objects.get(i)[14]); |
| 231 | - | |
| 232 | 138 | tempM.put("carParkGcenterPoint", objects.get(i)[15]); |
| 233 | - | |
| 234 | 139 | tempM.put("carParkGparkPoint", objects.get(i)[16]); |
| 235 | - | |
| 236 | 140 | tempM.put("carParkDBtype", objects.get(i)[17]); |
| 237 | - | |
| 238 | 141 | tempM.put("carParkRadius", objects.get(i)[18]); |
| 239 | - | |
| 240 | 142 | tempM.put("carParkShapesType", objects.get(i)[19]); |
| 241 | - | |
| 242 | 143 | resultList.add(tempM); |
| 243 | 144 | } |
| 244 | - | |
| 245 | 145 | } |
| 246 | - | |
| 247 | 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 | 163 | @Override |
| 266 | 164 | public Map<String, Object> carParkUpdate(Map<String, Object> map) { |
| 267 | 165 | Map<String, Object> resultMap = new HashMap<String, Object>(); |
| 268 | - | |
| 269 | 166 | try { |
| 270 | - | |
| 271 | 167 | // id |
| 272 | 168 | Integer id = map.get("id").equals("") ? null : Integer.parseInt(map.get("id").toString()); |
| 273 | - | |
| 274 | 169 | if(id!=null) { |
| 275 | - | |
| 276 | 170 | // 面积 |
| 277 | 171 | Double area = map.get("area").equals("") ? null : Double.parseDouble(map.get("area").toString()); |
| 278 | - | |
| 279 | 172 | // 中心点(百度坐标) |
| 280 | 173 | String bCenterPoint = map.get("bCenterPoint").equals("") ? "" : map.get("bCenterPoint").toString(); |
| 281 | - | |
| 282 | 174 | // 图形坐标点集合(百度坐标) |
| 283 | 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 | 180 | String company = map.get("company").equals("") ? "" : map.get("company").toString(); |
| 291 | - | |
| 292 | 181 | // 坐标类型 |
| 293 | 182 | String dbType = map.get("dbType").equals("") ? "" : map.get("dbType").toString(); |
| 294 | - | |
| 295 | 183 | // 描述与说明 |
| 296 | 184 | String descriptions = map.get("descriptions").equals("") ? "" : map.get("descriptions").toString(); |
| 297 | - | |
| 298 | 185 | // 是否撤销 |
| 299 | 186 | Integer destroy = map.get("destroy").equals("") ? null : Integer.parseInt(map.get("destroy").toString()); |
| 300 | - | |
| 301 | 187 | // 中心点(WGS坐标) |
| 302 | 188 | // String gCenterPoint = map.get("gCenterPoint").equals("") ? "" : map.get("gCenterPoint").toString(); |
| 303 | - | |
| 304 | 189 | String bJwpointsArray[] =null; |
| 305 | - | |
| 306 | 190 | if(bCenterPoint!=null) { |
| 307 | - | |
| 308 | 191 | bJwpointsArray = bCenterPoint.split(" "); |
| 309 | - | |
| 310 | 192 | } |
| 311 | - | |
| 312 | 193 | String gCenterPoint =null; |
| 313 | - | |
| 314 | 194 | if(bJwpointsArray.length>0) { |
| 315 | - | |
| 316 | 195 | Location resultPoint = FromBDPointToWGSPoint(bJwpointsArray[0],bJwpointsArray[1]); |
| 317 | - | |
| 318 | 196 | gCenterPoint = String.valueOf(resultPoint.getLng()) + " " + String.valueOf(resultPoint.getLat()); |
| 319 | - | |
| 320 | 197 | } |
| 321 | - | |
| 322 | 198 | // 图形坐标点集合(WGS坐标) |
| 323 | 199 | // String gParkPoint = map.get("gParkPoint").equals("") ? "" : map.get("gParkPoint").toString(); |
| 324 | - | |
| 325 | 200 | // 多边形WGS坐标点集合 |
| 326 | 201 | String gParkPoint =""; |
| 327 | - | |
| 328 | 202 | if(!bParkPoint.equals("")) { |
| 329 | - | |
| 330 | 203 | String bPloygonGridArray[] = bParkPoint.split(","); |
| 331 | - | |
| 332 | 204 | int bLen_ = bPloygonGridArray.length; |
| 333 | - | |
| 334 | 205 | for(int b = 0 ;b<bLen_;b++) { |
| 335 | - | |
| 336 | 206 | String tempArray[]= bPloygonGridArray[b].split(" "); |
| 337 | - | |
| 338 | 207 | Location resultPoint = FromBDPointToWGSPoint(tempArray[0],tempArray[1]); |
| 339 | - | |
| 340 | 208 | if(b==0) { |
| 341 | - | |
| 342 | 209 | gParkPoint = resultPoint.getLng() + " " + resultPoint.getLat(); |
| 343 | - | |
| 344 | 210 | }else { |
| 345 | - | |
| 346 | 211 | gParkPoint = gParkPoint + ',' + resultPoint.getLng() + " " + resultPoint.getLat(); |
| 347 | - | |
| 348 | 212 | } |
| 349 | - | |
| 350 | 213 | } |
| 351 | - | |
| 352 | 214 | } |
| 353 | 215 | if(bParkPoint.equals("")) |
| 354 | 216 | bParkPoint = null; |
| ... | ... | @@ -362,69 +224,51 @@ public class CarParkServiceImpl extends BaseServiceImpl<CarPark, Integer> implem |
| 362 | 224 | /*bParkPoint = "POLYGON((" + bParkPoint +"))"; |
| 363 | 225 | |
| 364 | 226 | gParkPoint = "POLYGON((" + gParkPoint +"))";*/ |
| 365 | - | |
| 366 | 227 | // 编码 |
| 367 | 228 | String parkCode = map.get("parkCode").equals("") ? "" : map.get("parkCode").toString(); |
| 368 | - | |
| 369 | 229 | // 名称 |
| 370 | 230 | String parkName = map.get("parkName").equals("") ? "" : map.get("parkName").toString(); |
| 371 | - | |
| 372 | 231 | // 半径 |
| 373 | 232 | Integer radius = map.get("radius").equals("") ? null : Integer.parseInt(map.get("radius").toString()); |
| 374 | - | |
| 375 | 233 | // 图形类型 |
| 376 | 234 | String shapesType = map.get("shapesType").equals("") ? "" : map.get("shapesType").toString(); |
| 377 | - | |
| 378 | 235 | // 版本 |
| 379 | 236 | Integer versions = map.get("versions").equals("") ? null : Integer.parseInt(map.get("versions").toString()); |
| 380 | - | |
| 381 | 237 | // 创建人 |
| 382 | 238 | Integer createBy = map.get("createBy").equals("") ? null : Integer.parseInt(map.get("createBy").toString()); |
| 383 | - | |
| 384 | 239 | // 创建日期 |
| 385 | 240 | String createDate = map.get("createDate").equals("") ? "" : map.get("createDate").toString(); |
| 386 | - | |
| 387 | 241 | Integer updateBy = map.get("updateBy").equals("") ? null : Integer.parseInt(map.get("updateBy").toString()); |
| 388 | - | |
| 389 | 242 | SimpleDateFormat formatter = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss"); |
| 390 | - | |
| 391 | 243 | Date date = new Date(); |
| 392 | - | |
| 393 | 244 | // 修改日期 |
| 394 | 245 | String updateDate = formatter.format(date); |
| 395 | - | |
| 396 | 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 | 248 | resultMap.put("status", ResponseCode.SUCCESS); |
| 401 | - | |
| 402 | 249 | } catch (Exception e) { |
| 403 | - | |
| 404 | 250 | resultMap.put("status", ResponseCode.ERROR); |
| 405 | - | |
| 406 | 251 | logger.error("save erro.", e); |
| 407 | - | |
| 408 | 252 | } |
| 409 | - | |
| 410 | 253 | return resultMap; |
| 411 | 254 | } |
| 412 | - | |
| 413 | 255 | /** 百度坐标转WGS坐标 */ |
| 414 | 256 | public Location FromBDPointToWGSPoint(String bLonx,String bLatx) { |
| 415 | - | |
| 416 | 257 | double lng = Double.parseDouble(bLonx); |
| 417 | - | |
| 418 | 258 | double lat = Double.parseDouble(bLatx); |
| 419 | - | |
| 420 | 259 | Location bdLoc = TransGPS.LocationMake(lng, lat); |
| 421 | - | |
| 422 | 260 | Location location = TransGPS.bd_decrypt(bdLoc); |
| 423 | - | |
| 424 | 261 | Location WGSPoint = TransGPS.transformFromGCJToWGS(location); |
| 425 | - | |
| 426 | 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 | 112 | public SchedulePlanRuleResult mapRow(ResultSet rs, int i) throws SQLException { |
| 113 | 113 | SchedulePlanRuleResult obj = new SchedulePlanRuleResult(); |
| 114 | 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 | 118 | obj.setScheduleDate(rs.getDate("schedule_date")); |
| 116 | 119 | obj.setGidindex(rs.getString("gidindex")); |
| 117 | 120 | obj.setEcindex(rs.getString("ecindex")); | ... | ... |
src/main/java/com/bsth/service/schedule/rules/shiftloop/ScheduleRule_input.java
| 1 | 1 | package com.bsth.service.schedule.rules.shiftloop; |
| 2 | 2 | |
| 3 | 3 | import com.bsth.entity.schedule.rule.ScheduleRule1Flat; |
| 4 | +import com.bsth.service.schedule.utils.Md5Util; | |
| 4 | 5 | import com.google.common.base.Splitter; |
| 5 | 6 | import org.apache.commons.lang3.StringUtils; |
| 6 | 7 | import org.joda.time.DateTime; |
| ... | ... | @@ -17,6 +18,12 @@ public class ScheduleRule_input { |
| 17 | 18 | |
| 18 | 19 | /** 规则Id */ |
| 19 | 20 | private String ruleId; |
| 21 | + /** | |
| 22 | + * 规则md5值(不使用id判定,使用md5判定) | |
| 23 | + * 使用,启用日期,路牌范围,人员范围 结合生成md5编码 | |
| 24 | + */ | |
| 25 | + private String ruleMd5; | |
| 26 | + | |
| 20 | 27 | /** 规则启用日期 */ |
| 21 | 28 | private DateTime qyrq; |
| 22 | 29 | |
| ... | ... | @@ -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 | 97 | this.self = scheduleRule1Flat; |
| 82 | 98 | } |
| 83 | 99 | |
| 100 | + | |
| 101 | + | |
| 84 | 102 | public String getRuleId() { |
| 85 | 103 | return ruleId; |
| 86 | 104 | } |
| ... | ... | @@ -160,4 +178,12 @@ public class ScheduleRule_input { |
| 160 | 178 | public void setSelf(ScheduleRule1Flat self) { |
| 161 | 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 | 10 | spring.datasource.driver-class-name= com.mysql.jdbc.Driver |
| 11 | 11 | spring.datasource.url= jdbc:mysql://127.0.0.1/control?useUnicode=true&characterEncoding=utf-8&useSSL=false |
| 12 | 12 | spring.datasource.username= root |
| 13 | -spring.datasource.password= root | |
| 13 | +spring.datasource.password= | |
| 14 | 14 | #spring.datasource.url= jdbc:mysql://192.168.168.117/pd_control?useUnicode=true&characterEncoding=utf-8&useSSL=false |
| 15 | 15 | #spring.datasource.username= root |
| 16 | 16 | #spring.datasource.password= root | ... | ... |