Commit 4cd76de384455436a46e7de1fe8c89a7f7ea5599
Merge branch 'minhang' of 192.168.168.201:panzhaov5/bsth_control into
minhang # Conflicts: # src/main/resources/application-dev.properties
Showing
48 changed files
with
2200 additions
and
1175 deletions
Too many changes to show.
To preserve performance only 48 of 99 files are displayed.
src/main/java/com/bsth/controller/BaseController2.java
| 1 | -package com.bsth.controller; | |
| 2 | - | |
| 3 | - | |
| 4 | -import com.bsth.common.ResponseCode; | |
| 5 | -import com.bsth.service.BaseService; | |
| 6 | -import com.bsth.service.schedule.utils.DataImportExportService; | |
| 7 | -import com.google.common.base.Splitter; | |
| 8 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 9 | -import org.springframework.data.domain.Page; | |
| 10 | -import org.springframework.data.domain.PageRequest; | |
| 11 | -import org.springframework.data.domain.Sort; | |
| 12 | -import org.springframework.web.bind.annotation.*; | |
| 13 | -import org.springframework.web.multipart.MultipartFile; | |
| 14 | - | |
| 15 | -import javax.servlet.http.HttpServletResponse; | |
| 16 | -import java.io.*; | |
| 17 | -import java.util.ArrayList; | |
| 18 | -import java.util.HashMap; | |
| 19 | -import java.util.List; | |
| 20 | -import java.util.Map; | |
| 21 | - | |
| 22 | -/** | |
| 23 | - * Created by xu on 16/11/3. | |
| 24 | - */ | |
| 25 | -public class BaseController2<T, ID extends Serializable> { | |
| 26 | - | |
| 27 | - @Autowired | |
| 28 | - protected BaseService<T, ID> baseService; | |
| 29 | - @Autowired | |
| 30 | - DataImportExportService dataImportExportService; | |
| 31 | - | |
| 32 | - /** | |
| 33 | - * | |
| 34 | - * @Title: list | |
| 35 | - * @Description: TODO(多条件分页查询) | |
| 36 | - * @param @param map 查询条件 | |
| 37 | - * @param @param page 页码 | |
| 38 | - * @param @param size 每页显示数量 | |
| 39 | - * @throws | |
| 40 | - */ | |
| 41 | - @RequestMapping(method = RequestMethod.GET) | |
| 42 | - public Page<T> list(@RequestParam Map<String, Object> map, | |
| 43 | - @RequestParam(defaultValue = "0") int page, | |
| 44 | - @RequestParam(defaultValue = "10") int size, | |
| 45 | - @RequestParam(defaultValue = "id") String order, | |
| 46 | - @RequestParam(defaultValue = "DESC") String direction){ | |
| 47 | - | |
| 48 | - // 允许多个字段排序,order可以写单个字段,也可以写多个字段 | |
| 49 | - // 多个字段格式:{col1},{col2},{col3},....,{coln} | |
| 50 | - List<String> order_columns = Splitter.on(",").trimResults().splitToList(order); | |
| 51 | - // 多字段排序:DESC,ASC... | |
| 52 | - List<String> order_dirs = Splitter.on(",").trimResults().splitToList(direction); | |
| 53 | - | |
| 54 | - if (order_dirs.size() == 1) { // 所有字段采用一种排序 | |
| 55 | - if (null != order_dirs.get(0) && order_dirs.get(0).equals("ASC")) { | |
| 56 | - return baseService.list(map, new PageRequest(page, size, new Sort(Sort.Direction.ASC, order_columns))); | |
| 57 | - } else { | |
| 58 | - return baseService.list(map, new PageRequest(page, size, new Sort(Sort.Direction.DESC, order_columns))); | |
| 59 | - } | |
| 60 | - } else if (order_columns.size() == order_dirs.size()) { | |
| 61 | - List<Sort.Order> orderList = new ArrayList<>(); | |
| 62 | - for (int i = 0; i < order_columns.size(); i++) { | |
| 63 | - if (null != order_dirs.get(i) && order_dirs.get(i).equals("ASC")) { | |
| 64 | - orderList.add(new Sort.Order(Sort.Direction.ASC, order_columns.get(i))); | |
| 65 | - } else { | |
| 66 | - orderList.add(new Sort.Order(Sort.Direction.DESC, order_columns.get(i))); | |
| 67 | - } | |
| 68 | - } | |
| 69 | - return baseService.list(map, new PageRequest(page, size, new Sort(orderList))); | |
| 70 | - } else { | |
| 71 | - throw new RuntimeException("多字段排序参数格式问题,排序顺序和字段数不一致"); | |
| 72 | - } | |
| 73 | - } | |
| 74 | - | |
| 75 | - /** | |
| 76 | - * | |
| 77 | - * @Title: list | |
| 78 | - * @Description: TODO(多条件查询) | |
| 79 | - * @param @param map | |
| 80 | - * @throws | |
| 81 | - */ | |
| 82 | - @RequestMapping(value = "/all", method = RequestMethod.GET) | |
| 83 | - public Iterable<T> list(@RequestParam Map<String, Object> map){ | |
| 84 | - return baseService.list(map); | |
| 85 | - } | |
| 86 | - | |
| 87 | - /** | |
| 88 | - * 这里保存直接返回保存后的对象,不自己定义Map返回了,和前端angularjs配合。 | |
| 89 | - * form也可以提交,但是页面参数可能不全, | |
| 90 | - * json的化比较灵活,但是貌似有多余属性也会报错,或者碰到lazy属性值,也有问题 | |
| 91 | - * 不论form,还是json提交都能解决问题,就看哪个方便哪个来 | |
| 92 | - * | |
| 93 | - * @param t 参数需要使用@RequestBody转换json成对象 | |
| 94 | - * @return | |
| 95 | - */ | |
| 96 | - @RequestMapping(method = RequestMethod.POST) | |
| 97 | - public T save(@RequestBody T t) { | |
| 98 | - baseService.save(t); | |
| 99 | - return t; | |
| 100 | - } | |
| 101 | - | |
| 102 | - @RequestMapping(value="/{id}", method = RequestMethod.POST) | |
| 103 | - public T update(@RequestBody T t) { | |
| 104 | - baseService.save(t); | |
| 105 | - return t; | |
| 106 | - } | |
| 107 | - | |
| 108 | - /** | |
| 109 | - * | |
| 110 | - * @Title: findById | |
| 111 | - * @Description: TODO(根据主键获取单个对象) | |
| 112 | - * @param @param id | |
| 113 | - * @throws | |
| 114 | - */ | |
| 115 | - @RequestMapping(value="/{id}",method = RequestMethod.GET) | |
| 116 | - public T findById(@PathVariable("id") ID id){ | |
| 117 | - return baseService.findById(id); | |
| 118 | - } | |
| 119 | - | |
| 120 | - /** | |
| 121 | - * | |
| 122 | - * @Title: delete | |
| 123 | - * @Description: TODO(根据主键删除对象) | |
| 124 | - * @param @param id | |
| 125 | - * @throws | |
| 126 | - */ | |
| 127 | - @RequestMapping(value="/{id}",method = RequestMethod.DELETE) | |
| 128 | - public Map<String, Object> delete(@PathVariable("id") ID id){ | |
| 129 | - return baseService.delete(id); | |
| 130 | - } | |
| 131 | - | |
| 132 | - /** | |
| 133 | - * 上传数据文件,并使用ktr转换文件导入数据。 | |
| 134 | - * @param file | |
| 135 | - * @return | |
| 136 | - * @throws Exception | |
| 137 | - */ | |
| 138 | - @RequestMapping(value = "/dataImport", method = RequestMethod.POST) | |
| 139 | - public Map<String, Object> uploadDataAndImport(MultipartFile file) throws Exception { | |
| 140 | - Map<String, Object> resultMap = new HashMap<>(); | |
| 141 | - | |
| 142 | - try { | |
| 143 | - // 获取ktr转换文件绝对路径 | |
| 144 | - File ktrfile = new File(this.getClass().getResource(getDataImportKtrClasspath()).toURI()); | |
| 145 | - System.out.println(ktrfile.getAbsolutePath()); | |
| 146 | - // 导入数据 | |
| 147 | - dataImportExportService.fileDataImport(file, ktrfile); | |
| 148 | - | |
| 149 | - resultMap.put("status", ResponseCode.SUCCESS); | |
| 150 | - resultMap.put("msg", "导入成功"); | |
| 151 | - } catch (Exception exp) { | |
| 152 | - exp.printStackTrace(); | |
| 153 | - resultMap.put("status", ResponseCode.ERROR); | |
| 154 | - resultMap.put("msg", exp.getLocalizedMessage()); | |
| 155 | - } | |
| 156 | - | |
| 157 | - return resultMap; | |
| 158 | - } | |
| 159 | - | |
| 160 | - /** | |
| 161 | - * 使用ktr导出数据。 | |
| 162 | - * @param response | |
| 163 | - * @throws Exception | |
| 164 | - */ | |
| 165 | - @RequestMapping(value = "/dataExport", method = RequestMethod.GET) | |
| 166 | - public void dataExport(HttpServletResponse response) throws Exception { | |
| 167 | - // 1、使用ktr转换获取输出文件 | |
| 168 | - File ktrfile = new File(this.getClass().getResource(getDataExportKtrClasspath()).toURI()); | |
| 169 | - File outputfile = dataImportExportService.fileDataOutput( | |
| 170 | - getDataExportFilename(), | |
| 171 | - ktrfile); | |
| 172 | - | |
| 173 | - System.out.println(outputfile.getName()); | |
| 174 | - String filePath = outputfile.getAbsolutePath(); | |
| 175 | - String fp[] = filePath.split(File.separator); | |
| 176 | - String fileName = fp[fp.length - 1]; | |
| 177 | - | |
| 178 | - // TODO:使用ktr获取导出数据 | |
| 179 | - | |
| 180 | - response.setHeader("conent-type", "application/octet-stream"); | |
| 181 | - response.setContentType("application/octet-stream"); | |
| 182 | - response.setHeader("Content-Disposition", "attachment; filename=" + "东东"); | |
| 183 | - | |
| 184 | - OutputStream os = response.getOutputStream(); | |
| 185 | - BufferedOutputStream bos = new BufferedOutputStream(os); | |
| 186 | - | |
| 187 | - InputStream is = null; | |
| 188 | - | |
| 189 | - is = new FileInputStream(filePath); | |
| 190 | - BufferedInputStream bis = new BufferedInputStream(is); | |
| 191 | - | |
| 192 | - int length = 0; | |
| 193 | - byte[] temp = new byte[1 * 1024 * 10]; | |
| 194 | - | |
| 195 | - while ((length = bis.read(temp)) != -1) { | |
| 196 | - bos.write(temp, 0, length); | |
| 197 | - } | |
| 198 | - bos.flush(); | |
| 199 | - bis.close(); | |
| 200 | - bos.close(); | |
| 201 | - is.close(); | |
| 202 | - } | |
| 203 | - | |
| 204 | - /** | |
| 205 | - * @return 数据导出的ktr转换文件类路径。 | |
| 206 | - */ | |
| 207 | - protected String getDataExportKtrClasspath() { | |
| 208 | - // 默认返回异常,子类如果要使用导出功能,必须覆写此方法,指定ktr文件类路径 | |
| 209 | - throw new RuntimeException("必须override,并指定ktr classpath"); | |
| 210 | - } | |
| 211 | - | |
| 212 | - /** | |
| 213 | - * @return 导出文件名。 | |
| 214 | - */ | |
| 215 | - protected String getDataExportFilename() { | |
| 216 | - // 默认返回异常,子类如果要使用导出功能,必须覆写此方法,指定导出的文件路径名 | |
| 217 | - throw new RuntimeException("必须override,并指定导出文件名"); | |
| 218 | - } | |
| 219 | - | |
| 220 | - /** | |
| 221 | - * @return 数据导入的ktr转换文件类路径。 | |
| 222 | - */ | |
| 223 | - protected String getDataImportKtrClasspath() { | |
| 224 | - // 默认返回异常,子类如果要使用导入功能,必须覆写此方法,指定ktr文件类路径 | |
| 225 | - throw new RuntimeException("必须override,并指定ktr classpath"); | |
| 226 | - } | |
| 227 | - | |
| 228 | -} | |
| 1 | +package com.bsth.controller; | |
| 2 | + | |
| 3 | + | |
| 4 | +import com.bsth.common.ResponseCode; | |
| 5 | +import com.bsth.service.BaseService; | |
| 6 | +import com.bsth.service.schedule.utils.DataImportExportService; | |
| 7 | +import com.google.common.base.Splitter; | |
| 8 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 9 | +import org.springframework.data.domain.Page; | |
| 10 | +import org.springframework.data.domain.PageRequest; | |
| 11 | +import org.springframework.data.domain.Sort; | |
| 12 | +import org.springframework.web.bind.annotation.*; | |
| 13 | +import org.springframework.web.multipart.MultipartFile; | |
| 14 | + | |
| 15 | +import javax.servlet.http.HttpServletResponse; | |
| 16 | +import java.io.*; | |
| 17 | +import java.util.ArrayList; | |
| 18 | +import java.util.HashMap; | |
| 19 | +import java.util.List; | |
| 20 | +import java.util.Map; | |
| 21 | + | |
| 22 | +/** | |
| 23 | + * Created by xu on 16/11/3. | |
| 24 | + */ | |
| 25 | +public class BaseController2<T, ID extends Serializable> { | |
| 26 | + | |
| 27 | + @Autowired | |
| 28 | + protected BaseService<T, ID> baseService; | |
| 29 | + @Autowired | |
| 30 | + DataImportExportService dataImportExportService; | |
| 31 | + | |
| 32 | + /** | |
| 33 | + * | |
| 34 | + * @Title: list | |
| 35 | + * @Description: TODO(多条件分页查询) | |
| 36 | + * @param @param map 查询条件 | |
| 37 | + * @param @param page 页码 | |
| 38 | + * @param @param size 每页显示数量 | |
| 39 | + * @throws | |
| 40 | + */ | |
| 41 | + @RequestMapping(method = RequestMethod.GET) | |
| 42 | + public Page<T> list(@RequestParam Map<String, Object> map, | |
| 43 | + @RequestParam(defaultValue = "0") int page, | |
| 44 | + @RequestParam(defaultValue = "10") int size, | |
| 45 | + @RequestParam(defaultValue = "id") String order, | |
| 46 | + @RequestParam(defaultValue = "DESC") String direction){ | |
| 47 | + | |
| 48 | + // 允许多个字段排序,order可以写单个字段,也可以写多个字段 | |
| 49 | + // 多个字段格式:{col1},{col2},{col3},....,{coln} | |
| 50 | + List<String> order_columns = Splitter.on(",").trimResults().splitToList(order); | |
| 51 | + // 多字段排序:DESC,ASC... | |
| 52 | + List<String> order_dirs = Splitter.on(",").trimResults().splitToList(direction); | |
| 53 | + | |
| 54 | + if (order_dirs.size() == 1) { // 所有字段采用一种排序 | |
| 55 | + if (null != order_dirs.get(0) && order_dirs.get(0).equals("ASC")) { | |
| 56 | + return baseService.list(map, new PageRequest(page, size, new Sort(Sort.Direction.ASC, order_columns))); | |
| 57 | + } else { | |
| 58 | + return baseService.list(map, new PageRequest(page, size, new Sort(Sort.Direction.DESC, order_columns))); | |
| 59 | + } | |
| 60 | + } else if (order_columns.size() == order_dirs.size()) { | |
| 61 | + List<Sort.Order> orderList = new ArrayList<>(); | |
| 62 | + for (int i = 0; i < order_columns.size(); i++) { | |
| 63 | + if (null != order_dirs.get(i) && order_dirs.get(i).equals("ASC")) { | |
| 64 | + orderList.add(new Sort.Order(Sort.Direction.ASC, order_columns.get(i))); | |
| 65 | + } else { | |
| 66 | + orderList.add(new Sort.Order(Sort.Direction.DESC, order_columns.get(i))); | |
| 67 | + } | |
| 68 | + } | |
| 69 | + return baseService.list(map, new PageRequest(page, size, new Sort(orderList))); | |
| 70 | + } else { | |
| 71 | + throw new RuntimeException("多字段排序参数格式问题,排序顺序和字段数不一致"); | |
| 72 | + } | |
| 73 | + } | |
| 74 | + | |
| 75 | + /** | |
| 76 | + * | |
| 77 | + * @Title: list | |
| 78 | + * @Description: TODO(多条件查询) | |
| 79 | + * @param @param map | |
| 80 | + * @throws | |
| 81 | + */ | |
| 82 | + @RequestMapping(value = "/all", method = RequestMethod.GET) | |
| 83 | + public Iterable<T> list(@RequestParam Map<String, Object> map){ | |
| 84 | + return baseService.list(map); | |
| 85 | + } | |
| 86 | + | |
| 87 | + /** | |
| 88 | + * 这里保存直接返回保存后的对象,不自己定义Map返回了,和前端angularjs配合。 | |
| 89 | + * form也可以提交,但是页面参数可能不全, | |
| 90 | + * json的化比较灵活,但是貌似有多余属性也会报错,或者碰到lazy属性值,也有问题 | |
| 91 | + * 不论form,还是json提交都能解决问题,就看哪个方便哪个来 | |
| 92 | + * | |
| 93 | + * @param t 参数需要使用@RequestBody转换json成对象 | |
| 94 | + * @return | |
| 95 | + */ | |
| 96 | + @RequestMapping(method = RequestMethod.POST) | |
| 97 | + public T save(@RequestBody T t) { | |
| 98 | + baseService.save(t); | |
| 99 | + return t; | |
| 100 | + } | |
| 101 | + | |
| 102 | + @RequestMapping(value="/{id}", method = RequestMethod.POST) | |
| 103 | + public T update(@RequestBody T t) { | |
| 104 | + baseService.save(t); | |
| 105 | + return t; | |
| 106 | + } | |
| 107 | + | |
| 108 | + /** | |
| 109 | + * | |
| 110 | + * @Title: findById | |
| 111 | + * @Description: TODO(根据主键获取单个对象) | |
| 112 | + * @param @param id | |
| 113 | + * @throws | |
| 114 | + */ | |
| 115 | + @RequestMapping(value="/{id}",method = RequestMethod.GET) | |
| 116 | + public T findById(@PathVariable("id") ID id){ | |
| 117 | + return baseService.findById(id); | |
| 118 | + } | |
| 119 | + | |
| 120 | + /** | |
| 121 | + * | |
| 122 | + * @Title: delete | |
| 123 | + * @Description: TODO(根据主键删除对象) | |
| 124 | + * @param @param id | |
| 125 | + * @throws | |
| 126 | + */ | |
| 127 | + @RequestMapping(value="/{id}",method = RequestMethod.DELETE) | |
| 128 | + public Map<String, Object> delete(@PathVariable("id") ID id){ | |
| 129 | + return baseService.delete(id); | |
| 130 | + } | |
| 131 | + | |
| 132 | + /** | |
| 133 | + * 上传数据文件,并使用ktr转换文件导入数据。 | |
| 134 | + * @param file | |
| 135 | + * @return | |
| 136 | + * @throws Exception | |
| 137 | + */ | |
| 138 | + @RequestMapping(value = "/dataImport", method = RequestMethod.POST) | |
| 139 | + public Map<String, Object> uploadDataAndImport(MultipartFile file) throws Exception { | |
| 140 | + Map<String, Object> resultMap = new HashMap<>(); | |
| 141 | + | |
| 142 | + try { | |
| 143 | + // 获取ktr转换文件绝对路径 | |
| 144 | + File ktrfile = new File(this.getClass().getResource(getDataImportKtrClasspath()).toURI()); | |
| 145 | + System.out.println(ktrfile.getAbsolutePath()); | |
| 146 | + // 导入数据 | |
| 147 | + dataImportExportService.fileDataImport(file, ktrfile); | |
| 148 | + | |
| 149 | + resultMap.put("status", ResponseCode.SUCCESS); | |
| 150 | + resultMap.put("msg", "导入成功"); | |
| 151 | + } catch (Exception exp) { | |
| 152 | + exp.printStackTrace(); | |
| 153 | + resultMap.put("status", ResponseCode.ERROR); | |
| 154 | + resultMap.put("msg", exp.getLocalizedMessage()); | |
| 155 | + } | |
| 156 | + | |
| 157 | + return resultMap; | |
| 158 | + } | |
| 159 | + | |
| 160 | + /** | |
| 161 | + * 使用ktr导出数据。 | |
| 162 | + * @param response | |
| 163 | + * @throws Exception | |
| 164 | + */ | |
| 165 | + @RequestMapping(value = "/dataExport", method = RequestMethod.GET) | |
| 166 | + public void dataExport(HttpServletResponse response) throws Exception { | |
| 167 | + // 1、使用ktr转换获取输出文件 | |
| 168 | + File ktrfile = new File(this.getClass().getResource(getDataExportKtrClasspath()).toURI()); | |
| 169 | + File outputfile = dataImportExportService.fileDataOutput( | |
| 170 | + getDataExportFilename(), | |
| 171 | + ktrfile); | |
| 172 | + | |
| 173 | + System.out.println(outputfile.getName()); | |
| 174 | + String filePath = outputfile.getAbsolutePath(); | |
| 175 | + String fp[] = filePath.split(File.separator); | |
| 176 | + String fileName = fp[fp.length - 1]; | |
| 177 | + | |
| 178 | + // TODO:使用ktr获取导出数据 | |
| 179 | + | |
| 180 | + response.setHeader("conent-type", "application/octet-stream"); | |
| 181 | + response.setContentType("application/octet-stream"); | |
| 182 | + response.setHeader("Content-Disposition", "attachment; filename=" + "东东"); | |
| 183 | + | |
| 184 | + OutputStream os = response.getOutputStream(); | |
| 185 | + BufferedOutputStream bos = new BufferedOutputStream(os); | |
| 186 | + | |
| 187 | + InputStream is = null; | |
| 188 | + | |
| 189 | + is = new FileInputStream(filePath); | |
| 190 | + BufferedInputStream bis = new BufferedInputStream(is); | |
| 191 | + | |
| 192 | + int length = 0; | |
| 193 | + byte[] temp = new byte[1 * 1024 * 10]; | |
| 194 | + | |
| 195 | + while ((length = bis.read(temp)) != -1) { | |
| 196 | + bos.write(temp, 0, length); | |
| 197 | + } | |
| 198 | + bos.flush(); | |
| 199 | + bis.close(); | |
| 200 | + bos.close(); | |
| 201 | + is.close(); | |
| 202 | + } | |
| 203 | + | |
| 204 | + /** | |
| 205 | + * @return 数据导出的ktr转换文件类路径。 | |
| 206 | + */ | |
| 207 | + protected String getDataExportKtrClasspath() { | |
| 208 | + // 默认返回异常,子类如果要使用导出功能,必须覆写此方法,指定ktr文件类路径 | |
| 209 | + throw new RuntimeException("必须override,并指定ktr classpath"); | |
| 210 | + } | |
| 211 | + | |
| 212 | + /** | |
| 213 | + * @return 导出文件名。 | |
| 214 | + */ | |
| 215 | + protected String getDataExportFilename() { | |
| 216 | + // 默认返回异常,子类如果要使用导出功能,必须覆写此方法,指定导出的文件路径名 | |
| 217 | + throw new RuntimeException("必须override,并指定导出文件名"); | |
| 218 | + } | |
| 219 | + | |
| 220 | + /** | |
| 221 | + * @return 数据导入的ktr转换文件类路径。 | |
| 222 | + */ | |
| 223 | + protected String getDataImportKtrClasspath() { | |
| 224 | + // 默认返回异常,子类如果要使用导入功能,必须覆写此方法,指定ktr文件类路径 | |
| 225 | + throw new RuntimeException("必须override,并指定ktr classpath"); | |
| 226 | + } | |
| 227 | + | |
| 228 | +} | ... | ... |
src/main/java/com/bsth/controller/DeviceGpsController.java
| 1 | 1 | package com.bsth.controller; |
| 2 | 2 | |
| 3 | +import java.io.BufferedOutputStream; | |
| 3 | 4 | import java.io.BufferedReader; |
| 4 | 5 | import java.io.File; |
| 5 | 6 | import java.io.FileInputStream; |
| 6 | 7 | import java.io.IOException; |
| 7 | 8 | import java.io.InputStreamReader; |
| 9 | +import java.io.OutputStream; | |
| 10 | +import java.text.SimpleDateFormat; | |
| 8 | 11 | import java.util.ArrayList; |
| 12 | +import java.util.Date; | |
| 9 | 13 | import java.util.HashMap; |
| 10 | 14 | import java.util.List; |
| 11 | 15 | import java.util.Map; |
| 12 | 16 | |
| 13 | 17 | import javax.servlet.http.HttpServletRequest; |
| 18 | +import javax.servlet.http.HttpServletResponse; | |
| 14 | 19 | |
| 15 | 20 | import org.apache.commons.lang.StringEscapeUtils; |
| 21 | +import org.apache.poi.hssf.usermodel.HSSFCell; | |
| 22 | +import org.apache.poi.hssf.usermodel.HSSFRichTextString; | |
| 23 | +import org.apache.poi.hssf.usermodel.HSSFRow; | |
| 24 | +import org.apache.poi.hssf.usermodel.HSSFSheet; | |
| 25 | +import org.apache.poi.hssf.usermodel.HSSFWorkbook; | |
| 26 | +import org.springframework.beans.BeanUtils; | |
| 16 | 27 | import org.springframework.beans.factory.annotation.Autowired; |
| 17 | 28 | import org.springframework.util.StringUtils; |
| 18 | 29 | import org.springframework.web.bind.annotation.PathVariable; |
| ... | ... | @@ -27,6 +38,7 @@ import com.bsth.data.gpsdata.GpsRealData; |
| 27 | 38 | import com.fasterxml.jackson.core.JsonParseException; |
| 28 | 39 | import com.fasterxml.jackson.databind.JsonMappingException; |
| 29 | 40 | import com.fasterxml.jackson.databind.ObjectMapper; |
| 41 | +import com.fasterxml.jackson.databind.util.BeanUtil; | |
| 30 | 42 | |
| 31 | 43 | @RestController |
| 32 | 44 | @RequestMapping("devicegps") |
| ... | ... | @@ -101,8 +113,8 @@ public class DeviceGpsController { |
| 101 | 113 | } |
| 102 | 114 | |
| 103 | 115 | @SuppressWarnings("unchecked") |
| 104 | - @RequestMapping(value = "/open/filter", method = RequestMethod.POST) | |
| 105 | - public Map<String, Object> filter(@RequestParam(value = "json")String json) { | |
| 116 | + @RequestMapping(value = "/opened", method = RequestMethod.POST) | |
| 117 | + public Map<String, Object> opened(@RequestParam(value = "json")String json) { | |
| 106 | 118 | json = StringEscapeUtils.unescapeHtml(json); |
| 107 | 119 | Map<String, Object> res = new HashMap<>(); |
| 108 | 120 | List<Map<String, Object>> data = null; |
| ... | ... | @@ -127,4 +139,122 @@ public class DeviceGpsController { |
| 127 | 139 | |
| 128 | 140 | return res; |
| 129 | 141 | } |
| 142 | + | |
| 143 | + @SuppressWarnings("unchecked") | |
| 144 | + @RequestMapping(value = "/export", method = RequestMethod.POST) | |
| 145 | + public void export(@RequestParam(value = "json")String json, HttpServletResponse response) { | |
| 146 | + json = StringEscapeUtils.unescapeHtml(json); | |
| 147 | + List<Map<String, Object>> data = null; | |
| 148 | + OutputStream out = null; | |
| 149 | + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
| 150 | + try { | |
| 151 | + data = new ObjectMapper().readValue(json, List.class); | |
| 152 | + for (Map<String, Object> info : data) { | |
| 153 | + Map<String, Object> detail = (Map<String, Object>)info.get("detail"); | |
| 154 | + if (detail != null) { | |
| 155 | + info.put("lineId", detail.get("lineId")); | |
| 156 | + info.put("valid", (int)detail.get("valid") == 0 ? "有效" : "无效"); | |
| 157 | + info.put("timestamp", sdf.format(new Date((Long)detail.get("timestamp")))); | |
| 158 | + info.put("version", detail.get("version")); | |
| 159 | + } else { | |
| 160 | + info.put("lineId", ""); | |
| 161 | + info.put("valid", ""); | |
| 162 | + info.put("timestamp", ""); | |
| 163 | + info.put("version", ""); | |
| 164 | + } | |
| 165 | + } | |
| 166 | + | |
| 167 | + List<Header> head = new ArrayList<>(); | |
| 168 | + head.add(new Header("线路编码", "lineCode")); | |
| 169 | + head.add(new Header("线路名称", "lineName")); | |
| 170 | + head.add(new Header("内部编码", "inCode")); | |
| 171 | + head.add(new Header("识别码", "deviceId")); | |
| 172 | + head.add(new Header("线路ID", "lineId")); | |
| 173 | + head.add(new Header("GPS", "valid")); | |
| 174 | + head.add(new Header("report", "timestamp")); | |
| 175 | + head.add(new Header("版本", "version")); | |
| 176 | + | |
| 177 | + // 清空response | |
| 178 | + response.reset(); | |
| 179 | + // 设置response的Header | |
| 180 | + response.addHeader("Content-Disposition", "attachment;filename=" + System.currentTimeMillis() + ".xls"); | |
| 181 | + response.setContentType("application/vnd.ms-excel;charset=UTF-8"); | |
| 182 | + out = new BufferedOutputStream(response.getOutputStream()); | |
| 183 | + excel(head, data, out); | |
| 184 | + out.flush(); | |
| 185 | + } catch (JsonParseException e) { | |
| 186 | + // TODO Auto-generated catch block | |
| 187 | + e.printStackTrace(); | |
| 188 | + } catch (JsonMappingException e) { | |
| 189 | + // TODO Auto-generated catch block | |
| 190 | + e.printStackTrace(); | |
| 191 | + } catch (IOException e) { | |
| 192 | + // TODO Auto-generated catch block | |
| 193 | + e.printStackTrace(); | |
| 194 | + } finally { | |
| 195 | + try { | |
| 196 | + if (out != null) out.close(); | |
| 197 | + } catch (IOException e) { | |
| 198 | + e.printStackTrace(); | |
| 199 | + } | |
| 200 | + } | |
| 201 | + } | |
| 202 | + | |
| 203 | + private void excel(List<Header> head, List<Map<String, Object>> data, OutputStream out) throws IOException { | |
| 204 | + // 声明一个工作薄 | |
| 205 | + HSSFWorkbook wb = new HSSFWorkbook(); | |
| 206 | + // 生成一个表格 | |
| 207 | + HSSFSheet sheet = wb.createSheet("1"); | |
| 208 | + // 产生表格标题行 | |
| 209 | + HSSFRow row = sheet.createRow(0); | |
| 210 | + for (int i = 0;i < head.size();i++) { | |
| 211 | + HSSFCell cell = row.createCell(i); | |
| 212 | + HSSFRichTextString text = new HSSFRichTextString(head.get(i).getDescribe()); | |
| 213 | + cell.setCellValue(text); | |
| 214 | + } | |
| 215 | + | |
| 216 | + int rownum = 1; | |
| 217 | + for (Map<String, Object> map : data) { | |
| 218 | + HSSFRow r = sheet.createRow(rownum); | |
| 219 | + for (int i = 0;i < head.size();i++) { | |
| 220 | + HSSFCell cell = r.createCell(i); | |
| 221 | + HSSFRichTextString text = new HSSFRichTextString(String.valueOf(map.get(head.get(i).getField()))); | |
| 222 | + cell.setCellValue(text); | |
| 223 | + } | |
| 224 | + rownum++; | |
| 225 | + } | |
| 226 | + | |
| 227 | + wb.write(out); | |
| 228 | + wb.close(); | |
| 229 | + } | |
| 230 | + | |
| 231 | + final class Header { | |
| 232 | + private String describe; | |
| 233 | + private String field; | |
| 234 | + | |
| 235 | + Header(){ | |
| 236 | + | |
| 237 | + } | |
| 238 | + | |
| 239 | + Header(String describe, String field) { | |
| 240 | + this.describe = describe; | |
| 241 | + this.field = field; | |
| 242 | + } | |
| 243 | + | |
| 244 | + public String getDescribe() { | |
| 245 | + return describe; | |
| 246 | + } | |
| 247 | + | |
| 248 | + public void setDescribe(String describe) { | |
| 249 | + this.describe = describe; | |
| 250 | + } | |
| 251 | + | |
| 252 | + public String getField() { | |
| 253 | + return field; | |
| 254 | + } | |
| 255 | + | |
| 256 | + public void setField(String field) { | |
| 257 | + this.field = field; | |
| 258 | + } | |
| 259 | + } | |
| 130 | 260 | } | ... | ... |
src/main/java/com/bsth/controller/directive/DirectiveController.java
| ... | ... | @@ -71,6 +71,30 @@ public class DirectiveController { |
| 71 | 71 | SysUser user = SecurityUtils.getCurrentUser(); |
| 72 | 72 | return directiveService.lineChange(nbbm, lineId, user.getUserName()); |
| 73 | 73 | } |
| 74 | + | |
| 75 | + /** | |
| 76 | + * | |
| 77 | + * @Title: lineChangeByDevice | |
| 78 | + * @Description: TODO(切换线路) | |
| 79 | + * @param @param deviceId 设备编码 | |
| 80 | + * @param @param lineId 新线路编码 | |
| 81 | + * @throws | |
| 82 | + */ | |
| 83 | + @RequestMapping(value = "/lineChangeByDevice", method = RequestMethod.POST) | |
| 84 | + public int lineChangeByDevice(@RequestParam String deviceId, @RequestParam String lineId){ | |
| 85 | + SysUser user = SecurityUtils.getCurrentUser(); | |
| 86 | + return directiveService.lineChangeByDeviceId(deviceId, lineId, user.getUserName()); | |
| 87 | + } | |
| 88 | + | |
| 89 | + /** | |
| 90 | + * 刷新线路文件 | |
| 91 | + * @param deviceId 设备号 | |
| 92 | + * @return | |
| 93 | + */ | |
| 94 | + @RequestMapping(value = "/refreshLineFile", method = RequestMethod.POST) | |
| 95 | + public int refreshLineFile(@RequestParam String deviceId){ | |
| 96 | + return directiveService.refreshLineFile(deviceId); | |
| 97 | + } | |
| 74 | 98 | |
| 75 | 99 | /** |
| 76 | 100 | * | ... | ... |
src/main/java/com/bsth/controller/gps/GpsController.java
| ... | ... | @@ -4,10 +4,7 @@ import java.util.List; |
| 4 | 4 | import java.util.Map; |
| 5 | 5 | |
| 6 | 6 | import org.springframework.beans.factory.annotation.Autowired; |
| 7 | -import org.springframework.web.bind.annotation.PathVariable; | |
| 8 | -import org.springframework.web.bind.annotation.RequestMapping; | |
| 9 | -import org.springframework.web.bind.annotation.RequestParam; | |
| 10 | -import org.springframework.web.bind.annotation.RestController; | |
| 7 | +import org.springframework.web.bind.annotation.*; | |
| 11 | 8 | |
| 12 | 9 | import com.bsth.data.BasicData; |
| 13 | 10 | import com.bsth.data.gpsdata.GpsEntity; |
| ... | ... | @@ -46,6 +43,16 @@ public class GpsController { |
| 46 | 43 | return gpsRealData.get(Splitter.on(",").splitToList(lineCodes)); |
| 47 | 44 | } |
| 48 | 45 | |
| 46 | + @RequestMapping(value = "/allDevices") | |
| 47 | + public Iterable<String> allDevices(){ | |
| 48 | + return gpsRealData.allDevices(); | |
| 49 | + } | |
| 50 | + | |
| 51 | + @RequestMapping(value = "/removeRealGps", method = RequestMethod.POST) | |
| 52 | + public Map<String, Object> removeRealGps(@RequestParam String device){ | |
| 53 | + return gpsService.removeRealGps(device); | |
| 54 | + } | |
| 55 | + | |
| 49 | 56 | /** |
| 50 | 57 | * |
| 51 | 58 | * @Title: history @Description: TODO(这个方法给测试页面用) @throws | ... | ... |
src/main/java/com/bsth/controller/oil/YlbController.java
| ... | ... | @@ -125,4 +125,10 @@ public class YlbController extends BaseController<Ylb, Integer>{ |
| 125 | 125 | return baseService.list(map, new PageRequest(page, size, new Sort(d, list))); |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | + | |
| 129 | + @RequestMapping(value="/oilListMonth") | |
| 130 | + public List<Ylb> oilListMonth(@RequestParam String line,@RequestParam String date){ | |
| 131 | + return yblService.oilListMonth(line, date); | |
| 132 | + } | |
| 133 | + | |
| 128 | 134 | } | ... | ... |
src/main/java/com/bsth/controller/realcontrol/LineConfigController.java
| ... | ... | @@ -21,13 +21,13 @@ public class LineConfigController extends BaseController<LineConfig, Integer>{ |
| 21 | 21 | LineConfigService lineConfigService; |
| 22 | 22 | |
| 23 | 23 | @RequestMapping("/check") |
| 24 | - public Map<String, Object> check(@RequestParam Integer[] codeArray){ | |
| 24 | + public Map<String, Object> check(@RequestParam String[] codeArray){ | |
| 25 | 25 | return lineConfigService.check(codeArray); |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | @RequestMapping("/init/{lineCode}") |
| 29 | - public Integer init(@PathVariable("lineCode") Integer lineCode) throws Exception{ | |
| 30 | - return lineConfigService.inti(lineCode); | |
| 29 | + public Integer init(@PathVariable("lineCode") String lineCode) throws Exception{ | |
| 30 | + return lineConfigService.init(lineCode); | |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | @RequestMapping(value = "/editTime", method = RequestMethod.POST) | ... | ... |
src/main/java/com/bsth/controller/realcontrol/RealChartsController.java
0 → 100644
| 1 | +package com.bsth.controller.realcontrol; | |
| 2 | + | |
| 3 | +import com.bsth.service.realcontrol.RealChartsService; | |
| 4 | +import com.bsth.service.realcontrol.dto.CarOutRate; | |
| 5 | +import com.bsth.service.realcontrol.dto.DeviceOnlineRate; | |
| 6 | +import com.bsth.service.realcontrol.dto.StratEndPunctualityRate; | |
| 7 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 8 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 9 | +import org.springframework.web.bind.annotation.RequestParam; | |
| 10 | +import org.springframework.web.bind.annotation.RestController; | |
| 11 | + | |
| 12 | +import java.util.List; | |
| 13 | + | |
| 14 | +/** | |
| 15 | + * 线路调度统计图 | |
| 16 | + * Created by panzhao on 2016/11/9. | |
| 17 | + */ | |
| 18 | +@RestController | |
| 19 | +@RequestMapping("realCharts") | |
| 20 | +public class RealChartsController { | |
| 21 | + | |
| 22 | + @Autowired | |
| 23 | + RealChartsService realChartsService; | |
| 24 | + | |
| 25 | + @RequestMapping("deviceOnlineRate") | |
| 26 | + public List<DeviceOnlineRate> deviceOnlineRate(@RequestParam String idx, @RequestParam String month){ | |
| 27 | + return realChartsService.deviceOnlineRate(month, idx); | |
| 28 | + } | |
| 29 | + | |
| 30 | + @RequestMapping("carOutRate") | |
| 31 | + public List<CarOutRate> carOutRate(@RequestParam String idx, @RequestParam String month){ | |
| 32 | + return realChartsService.carOutRate(month, idx); | |
| 33 | + } | |
| 34 | + | |
| 35 | + @RequestMapping("stratEndPunctualityRate") | |
| 36 | + public List<StratEndPunctualityRate> stratEndPunctualityRate(@RequestParam String idx, @RequestParam String month){ | |
| 37 | + return realChartsService.stratEndPunctualityRate(month, idx); | |
| 38 | + } | |
| 39 | + | |
| 40 | + @RequestMapping("sePunctualityRateLine") | |
| 41 | + public List<StratEndPunctualityRate> sePunctualityRateLine(@RequestParam String idx, @RequestParam String month){ | |
| 42 | + return realChartsService.sePunctualityRateLine(month, idx); | |
| 43 | + } | |
| 44 | +} | ... | ... |
src/main/java/com/bsth/controller/sys/util/RSAUtils.java
| ... | ... | @@ -10,10 +10,14 @@ import java.security.interfaces.RSAPublicKey; |
| 10 | 10 | import javax.crypto.Cipher; |
| 11 | 11 | |
| 12 | 12 | import org.apache.commons.net.util.Base64; |
| 13 | +import org.slf4j.Logger; | |
| 14 | +import org.slf4j.LoggerFactory; | |
| 13 | 15 | |
| 14 | 16 | public class RSAUtils { |
| 15 | 17 | private static final KeyPair keyPair = initKey(); |
| 16 | - | |
| 18 | + | |
| 19 | + static Logger logger = LoggerFactory.getLogger(RSAUtils.class); | |
| 20 | + | |
| 17 | 21 | private static KeyPair initKey(){ |
| 18 | 22 | try { |
| 19 | 23 | Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); |
| ... | ... | @@ -41,6 +45,7 @@ public class RSAUtils { |
| 41 | 45 | * @return |
| 42 | 46 | */ |
| 43 | 47 | public static String decryptBase64(String string) { |
| 48 | + logger.info("decryptBase64 -[" + string + "]"); | |
| 44 | 49 | return new String(decrypt(Base64.decodeBase64(string))); |
| 45 | 50 | } |
| 46 | 51 | ... | ... |
src/main/java/com/bsth/data/LineConfigData.java
| ... | ... | @@ -77,7 +77,7 @@ public class LineConfigData implements CommandLineRunner { |
| 77 | 77 | * @Title: init |
| 78 | 78 | * @Description: TODO(初始化配置信息) |
| 79 | 79 | */ |
| 80 | - public void init(Integer lineCode) throws Exception{ | |
| 80 | + public void init(String lineCode) throws Exception{ | |
| 81 | 81 | LineConfig conf = new LineConfig(); |
| 82 | 82 | //线路 |
| 83 | 83 | Line line = lineService.findByLineCode(lineCode); | ... | ... |
src/main/java/com/bsth/data/arrival/ArrivalData_GPS.java
| ... | ... | @@ -50,8 +50,8 @@ public class ArrivalData_GPS implements CommandLineRunner{ |
| 50 | 50 | |
| 51 | 51 | @Override |
| 52 | 52 | public void run(String... arg0) throws Exception { |
| 53 | - logger.info("ArrivalData_GPS,30,10"); | |
| 54 | - //Application.mainServices.scheduleWithFixedDelay(dataLoaderThread, 40, 10, TimeUnit.SECONDS); | |
| 53 | + logger.info("ArrivalData_GPS,100,10 @11-11"); | |
| 54 | + //Application.mainServices.scheduleWithFixedDelay(dataLoaderThread, 100, 10, TimeUnit.SECONDS); | |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | @Component | ... | ... |
src/main/java/com/bsth/data/directive/DayOfDirectives.java
| ... | ... | @@ -91,9 +91,11 @@ public class DayOfDirectives { |
| 91 | 91 | break; |
| 92 | 92 | case 1: |
| 93 | 93 | d60.setReply46((short) 0);// 发送成功 |
| 94 | + d60.setReply46Time(System.currentTimeMillis()); | |
| 94 | 95 | break; |
| 95 | 96 | case 2: |
| 96 | 97 | d60.setReply47((short) 0);// 驾驶员阅读 |
| 98 | + d60.setReply47Time(System.currentTimeMillis()); | |
| 97 | 99 | break; |
| 98 | 100 | } |
| 99 | 101 | // 入库 | ... | ... |
src/main/java/com/bsth/data/directive/DirectiveCreator.java
| ... | ... | @@ -122,30 +122,33 @@ public class DirectiveCreator { |
| 122 | 122 | |
| 123 | 123 | /** |
| 124 | 124 | * |
| 125 | - * @Title: createDirective64 | |
| 125 | + * @Title: createD64 | |
| 126 | 126 | * @Description: TODO(创建线路切换指令 64) |
| 127 | 127 | * @param @param nbbm 车辆内部编码 |
| 128 | 128 | * @param @param lineId 线路编码 |
| 129 | 129 | * @param @param t 时间戳 |
| 130 | 130 | * @throws |
| 131 | - */ | |
| 131 | + | |
| 132 | 132 | public D64 createD64(String nbbm, String lineCode, long t){ |
| 133 | 133 | String deviceId = BasicData.deviceId2NbbmMap.inverse().get(nbbm); |
| 134 | + return create64(deviceId, lineCode, t); | |
| 135 | + }*/ | |
| 134 | 136 | |
| 137 | + public D64 create64(String deviceId, String lineCode, long t){ | |
| 135 | 138 | D64 change = new D64(); |
| 136 | 139 | D64Data data = new D64Data(); |
| 137 | 140 | data.setCityCode(cityCode); |
| 138 | 141 | data.setDeviceId(deviceId); |
| 139 | - | |
| 142 | + | |
| 140 | 143 | //线路编码补满6位数 |
| 141 | 144 | String lineCodeStr = padLeft(lineCode, 6, '0'); |
| 142 | 145 | data.setLineId(lineCodeStr); |
| 143 | - | |
| 146 | + | |
| 144 | 147 | change.setDeviceId(deviceId); |
| 145 | 148 | change.setOperCode((short) 0X64); |
| 146 | 149 | change.setTimestamp(t); |
| 147 | 150 | change.setData(data); |
| 148 | - | |
| 151 | + | |
| 149 | 152 | return change; |
| 150 | 153 | } |
| 151 | 154 | ... | ... |
src/main/java/com/bsth/data/forecast/ForecastRealServer.java
| ... | ... | @@ -61,7 +61,7 @@ public class ForecastRealServer implements CommandLineRunner { |
| 61 | 61 | @Override |
| 62 | 62 | public void run(String... arg0) throws Exception { |
| 63 | 63 | //2小时更新一次站点间耗时数据 |
| 64 | - //Application.mainServices.scheduleWithFixedDelay(dataLoader, 12, 120 * 60, TimeUnit.SECONDS); | |
| 64 | + Application.mainServices.scheduleWithFixedDelay(dataLoader, 12, 120 * 60, TimeUnit.SECONDS); | |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** | ... | ... |
src/main/java/com/bsth/data/gpsdata/GpsRealData.java
| ... | ... | @@ -2,12 +2,7 @@ package com.bsth.data.gpsdata; |
| 2 | 2 | |
| 3 | 3 | import java.io.BufferedReader; |
| 4 | 4 | import java.io.InputStreamReader; |
| 5 | -import java.util.ArrayList; | |
| 6 | -import java.util.Collection; | |
| 7 | -import java.util.HashMap; | |
| 8 | -import java.util.List; | |
| 9 | -import java.util.Map; | |
| 10 | -import java.util.NavigableSet; | |
| 5 | +import java.util.*; | |
| 11 | 6 | import java.util.concurrent.TimeUnit; |
| 12 | 7 | |
| 13 | 8 | import org.apache.commons.lang3.StringUtils; |
| ... | ... | @@ -137,6 +132,10 @@ public class GpsRealData implements CommandLineRunner{ |
| 137 | 132 | list.addAll(getByLine(code)); |
| 138 | 133 | return list; |
| 139 | 134 | } |
| 135 | + | |
| 136 | + public Set<String> allDevices(){ | |
| 137 | + return gpsMap.keySet(); | |
| 138 | + } | |
| 140 | 139 | |
| 141 | 140 | public GpsEntity findByDeviceId(String deviceId) { |
| 142 | 141 | return gpsMap.get(deviceId); |
| ... | ... | @@ -145,7 +144,10 @@ public class GpsRealData implements CommandLineRunner{ |
| 145 | 144 | public Collection<GpsEntity> all(){ |
| 146 | 145 | return gpsMap.values(); |
| 147 | 146 | } |
| 148 | - | |
| 147 | + | |
| 148 | + public void remove(String device){ | |
| 149 | + gpsMap.remove(device); | |
| 150 | + } | |
| 149 | 151 | @Component |
| 150 | 152 | public static class GpsDataLoader extends Thread{ |
| 151 | 153 | ... | ... |
src/main/java/com/bsth/data/pilot80/PilotReport.java
| ... | ... | @@ -85,13 +85,13 @@ public class PilotReport { |
| 85 | 85 | |
| 86 | 86 | //下发调度指令 |
| 87 | 87 | directiveService.send60Dispatch(outSch, dayOfSchedule.doneSum(nbbm), "请出@系统"); |
| 88 | - d80.setRemarks("计划出场时间:" + outSch.getDfsj()); | |
| 88 | +/* d80.setRemarks("计划出场时间:" + outSch.getDfsj()); | |
| 89 | 89 | //当前GPS位置 |
| 90 | 90 | GpsEntity gps = gpsRealData.get(d80.getDeviceId()); |
| 91 | 91 | if(null != gps) |
| 92 | - d80.addRemarks("<br> 位置:" + coordHtmlStr(gps)); | |
| 92 | + d80.addRemarks("<br> 位置:" + coordHtmlStr(gps));*/ | |
| 93 | 93 | |
| 94 | - sendUtils.refreshSch(outSch); | |
| 94 | + //sendUtils.refreshSch(outSch); | |
| 95 | 95 | }else |
| 96 | 96 | d80.setRemarks("没有出场计划"); |
| 97 | 97 | ... | ... |
src/main/java/com/bsth/data/schedule/DayOfSchedule.java
| 1 | 1 | package com.bsth.data.schedule; |
| 2 | 2 | |
| 3 | +import java.text.ParseException; | |
| 3 | 4 | import java.text.SimpleDateFormat; |
| 4 | 5 | import java.util.ArrayList; |
| 5 | 6 | import java.util.Collection; |
| ... | ... | @@ -13,6 +14,9 @@ import java.util.Map; |
| 13 | 14 | import java.util.Set; |
| 14 | 15 | import java.util.concurrent.TimeUnit; |
| 15 | 16 | |
| 17 | +import com.bsth.data.schedule.thread.SubmitToTrafficManage; | |
| 18 | +import org.apache.commons.lang3.StringUtils; | |
| 19 | +import org.joda.time.DateTime; | |
| 16 | 20 | import org.joda.time.format.DateTimeFormat; |
| 17 | 21 | import org.joda.time.format.DateTimeFormatter; |
| 18 | 22 | import org.slf4j.Logger; |
| ... | ... | @@ -115,6 +119,9 @@ public class DayOfSchedule implements CommandLineRunner { |
| 115 | 119 | @Autowired |
| 116 | 120 | ScheduleLateThread scheduleLateThread; |
| 117 | 121 | |
| 122 | + @Autowired | |
| 123 | + SubmitToTrafficManage submitToTrafficManage; | |
| 124 | + | |
| 118 | 125 | private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd") |
| 119 | 126 | ,fmtHHmm = DateTimeFormat.forPattern("HH:mm"); |
| 120 | 127 | |
| ... | ... | @@ -123,11 +130,19 @@ public class DayOfSchedule implements CommandLineRunner { |
| 123 | 130 | //翻班线程 |
| 124 | 131 | Application.mainServices.scheduleWithFixedDelay(scheduleRefreshThread, 15, 240, TimeUnit.SECONDS); |
| 125 | 132 | //入库 |
| 126 | - Application.mainServices.scheduleWithFixedDelay(schedulePstThread, 60, 60, TimeUnit.SECONDS); | |
| 133 | + //Application.mainServices.scheduleWithFixedDelay(schedulePstThread, 60, 60, TimeUnit.SECONDS); | |
| 127 | 134 | //首班出场指令补发器 |
| 128 | - Application.mainServices.scheduleWithFixedDelay(firstScheduleCheckThread, 30, 240, TimeUnit.SECONDS); | |
| 135 | + //Application.mainServices.scheduleWithFixedDelay(firstScheduleCheckThread, 30, 240, TimeUnit.SECONDS); | |
| 129 | 136 | //班次误点扫描 |
| 130 | 137 | //Application.mainServices.scheduleWithFixedDelay(scheduleLateThread, 60, 60, TimeUnit.SECONDS); |
| 138 | + | |
| 139 | + //每天凌晨2点20提交数据到运管处 | |
| 140 | + long diff = (DateUtils.getTimestamp() + 1000*60*140) - System.currentTimeMillis(); | |
| 141 | + if(diff < 0) | |
| 142 | + diff+=(1000*60*60*24); | |
| 143 | + | |
| 144 | + logger.info(diff/1000/60 + "分钟之后提交到运管处"); | |
| 145 | + //Application.mainServices.scheduleWithFixedDelay(submitToTrafficManage, diff / 1000, 60 * 60 * 24, TimeUnit.SECONDS); | |
| 131 | 146 | } |
| 132 | 147 | |
| 133 | 148 | public Map<String, String> getCurrSchDate() { |
| ... | ... | @@ -307,9 +322,28 @@ public class DayOfSchedule implements CommandLineRunner { |
| 307 | 322 | // 转换为实际排班 |
| 308 | 323 | realList = JSONArray.parseArray(JSON.toJSONString(planItr), ScheduleRealInfo.class); |
| 309 | 324 | |
| 325 | + SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); | |
| 326 | + String fcsj; | |
| 310 | 327 | for (ScheduleRealInfo sch : realList) { |
| 311 | 328 | sch.setScheduleDateStr(fmtyyyyMMdd.print(sch.getScheduleDate().getTime())); |
| 312 | 329 | sch.setRealExecDate(sch.getScheduleDateStr()); |
| 330 | + | |
| 331 | + if(StringUtils.isEmpty(sch.getFcsj())) | |
| 332 | + sch.setFcsj("00:00"); | |
| 333 | + | |
| 334 | + fcsj=sch.getFcsj().trim(); | |
| 335 | + //处理一下发车时间格式没有:号的问题 | |
| 336 | + if(fcsj.indexOf(":") == -1 && fcsj.length() >= 4){ | |
| 337 | + sch.setFcsj(fcsj.substring(0, 2) + ":" + fcsj.substring(2, 4)); | |
| 338 | + } | |
| 339 | + | |
| 340 | + try { | |
| 341 | + sdf.parse(sch.getFcsj()); | |
| 342 | + } catch (ParseException e) { | |
| 343 | + //发车时间仍然校验不过的,直接写成00:00 | |
| 344 | + sch.setFcsj("00:00"); | |
| 345 | + } | |
| 346 | + | |
| 313 | 347 | // 计划终点时间 |
| 314 | 348 | if (sch.getBcsj() != null) { |
| 315 | 349 | sch.setZdsj(fmtHHmm.print(fmtHHmm.parseMillis(sch.getFcsj()) + (sch.getBcsj() * 60 * 1000))); | ... | ... |
src/main/java/com/bsth/data/schedule/thread/SubmitToTrafficManage.java
0 → 100644
| 1 | +package com.bsth.data.schedule.thread; | |
| 2 | + | |
| 3 | +import com.bsth.service.TrafficManageService; | |
| 4 | +import org.slf4j.Logger; | |
| 5 | +import org.slf4j.LoggerFactory; | |
| 6 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 7 | +import org.springframework.stereotype.Component; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * 运营数据提交到运管处 | |
| 11 | + * Created by panzhao on 2016/11/9. | |
| 12 | + */ | |
| 13 | +@Component | |
| 14 | +public class SubmitToTrafficManage extends Thread{ | |
| 15 | + | |
| 16 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 17 | + | |
| 18 | + @Autowired | |
| 19 | + TrafficManageService trafficManageService; | |
| 20 | + | |
| 21 | + @Override | |
| 22 | + public void run() { | |
| 23 | + logger.info("开始提交数据到运管处..."); | |
| 24 | + try { | |
| 25 | + //路单 | |
| 26 | + trafficManageService.setLD(); | |
| 27 | + } catch (Exception e) { | |
| 28 | + logger.error("提交路单到运管处失败", e); | |
| 29 | + } | |
| 30 | + try { | |
| 31 | + //车辆里程、油耗 | |
| 32 | + trafficManageService.setLCYH(); | |
| 33 | + } catch (Exception e) { | |
| 34 | + logger.error("提交车辆里程、油耗到运管处失败", e); | |
| 35 | + } | |
| 36 | + try { | |
| 37 | + //线路调度日报 | |
| 38 | + trafficManageService.setDDRB(); | |
| 39 | + } catch (Exception e) { | |
| 40 | + logger.error("提交线路调度日报到运管处失败", e); | |
| 41 | + } | |
| 42 | + try { | |
| 43 | + //线路计划班次表 | |
| 44 | + trafficManageService.setJHBC(); | |
| 45 | + } catch (Exception e) { | |
| 46 | + logger.error("提交线路计划班次表到运管处失败", e); | |
| 47 | + } | |
| 48 | + logger.info("提交数据到运管处结束!"); | |
| 49 | + } | |
| 50 | +} | ... | ... |
src/main/java/com/bsth/oplog/db/DBHelper.java
| ... | ... | @@ -43,6 +43,6 @@ public class DBHelper implements CommandLineRunner{ |
| 43 | 43 | |
| 44 | 44 | @Override |
| 45 | 45 | public void run(String... arg0) throws Exception { |
| 46 | - Application.mainServices.scheduleWithFixedDelay(fixedTimeThread, fixedMinute, fixedMinute, TimeUnit.MINUTES); | |
| 46 | + //Application.mainServices.scheduleWithFixedDelay(fixedTimeThread, fixedMinute, fixedMinute, TimeUnit.MINUTES); | |
| 47 | 47 | } |
| 48 | 48 | } | ... | ... |
src/main/java/com/bsth/service/LineService.java
src/main/java/com/bsth/service/directive/DirectiveService.java
| ... | ... | @@ -55,8 +55,10 @@ public interface DirectiveService extends BaseService<D60, Integer>{ |
| 55 | 55 | * @throws |
| 56 | 56 | */ |
| 57 | 57 | int lineChange(String nbbm, String lineId, String sender); |
| 58 | - | |
| 59 | - /** | |
| 58 | + | |
| 59 | + int lineChangeByDeviceId(String deviceId, String lineCode, String sender); | |
| 60 | + | |
| 61 | + /** | |
| 60 | 62 | * |
| 61 | 63 | * @Title: upDownChange |
| 62 | 64 | * @Description: TODO(切换上下行) |
| ... | ... | @@ -89,4 +91,6 @@ public interface DirectiveService extends BaseService<D60, Integer>{ |
| 89 | 91 | int sendC0A3(DC0_A3 c0a4); |
| 90 | 92 | |
| 91 | 93 | int sendC0A5(String json); |
| 94 | + | |
| 95 | + int refreshLineFile(String deviceId); | |
| 92 | 96 | } | ... | ... |
src/main/java/com/bsth/service/directive/DirectiveServiceImpl.java
| ... | ... | @@ -222,18 +222,23 @@ public class DirectiveServiceImpl extends BaseServiceImpl<D60, Integer> implemen |
| 222 | 222 | */ |
| 223 | 223 | @Override |
| 224 | 224 | public int lineChange(String nbbm, String lineCode, String sender) { |
| 225 | + return lineChangeByDeviceId(BasicData.deviceId2NbbmMap.inverse().get(nbbm), lineCode, sender); | |
| 226 | + } | |
| 227 | + | |
| 228 | + | |
| 229 | + @Override | |
| 230 | + public int lineChangeByDeviceId(String deviceId, String lineCode, String sender){ | |
| 225 | 231 | DirectiveCreator crt = new DirectiveCreator(); |
| 226 | - | |
| 227 | 232 | Long t = System.currentTimeMillis(); |
| 228 | 233 | //生成64数据包 |
| 229 | - D64 d64 = crt.createD64(nbbm, lineCode, t); | |
| 230 | - | |
| 234 | + D64 d64 = crt.create64(deviceId, lineCode, t); | |
| 235 | + | |
| 231 | 236 | if(null != sender) |
| 232 | 237 | d64.setSender(sender); |
| 233 | 238 | else |
| 234 | 239 | d64.setSender("系统"); |
| 235 | 240 | |
| 236 | - String deviceId = d64.getDeviceId(); | |
| 241 | + //String deviceId = d64.getDeviceId(); | |
| 237 | 242 | int code = GatewayHttpUtils.postJson(JSON.toJSONString(d64)); |
| 238 | 243 | // 入库 |
| 239 | 244 | d64.setHttpCode(code); |
| ... | ... | @@ -332,6 +337,7 @@ public class DirectiveServiceImpl extends BaseServiceImpl<D60, Integer> implemen |
| 332 | 337 | Map<String, Object> sockMap = new HashMap<>(); |
| 333 | 338 | sockMap.put("fn", "d80Confirm"); |
| 334 | 339 | sockMap.put("id", d80.getId()); |
| 340 | + sockMap.put("lineId", d80.getData().getLineId()); | |
| 335 | 341 | socketHandler.sendMessageToLine(d80.getData().getLineId().toString(), JSON.toJSONString(sockMap)); |
| 336 | 342 | } |
| 337 | 343 | |
| ... | ... | @@ -463,7 +469,7 @@ public class DirectiveServiceImpl extends BaseServiceImpl<D60, Integer> implemen |
| 463 | 469 | |
| 464 | 470 | Map<String, Object> rsMap = new HashMap<>(); |
| 465 | 471 | rsMap.put("list", rs); |
| 466 | - rsMap.put("totalPages", count % size == 0 ? count / size : count / size + 1); | |
| 472 | + rsMap.put("totalPages", count % size == 0 ? count / size -1 : count / size); | |
| 467 | 473 | rsMap.put("page", page); |
| 468 | 474 | |
| 469 | 475 | return rsMap; |
| ... | ... | @@ -501,4 +507,13 @@ public class DirectiveServiceImpl extends BaseServiceImpl<D60, Integer> implemen |
| 501 | 507 | public int sendC0A5(String json) { |
| 502 | 508 | return GatewayHttpUtils.postJson(json); |
| 503 | 509 | } |
| 510 | + | |
| 511 | + @Override | |
| 512 | + public int refreshLineFile(String deviceId) { | |
| 513 | + GpsEntity gps = gpsRealDataBuffer.get(deviceId); | |
| 514 | + if(gps == null) | |
| 515 | + return -1; | |
| 516 | + | |
| 517 | + return GatewayHttpUtils.postJson(new DirectiveCreator().createDeviceRefreshData(deviceId, gps.getLineId())); | |
| 518 | + } | |
| 504 | 519 | } | ... | ... |
src/main/java/com/bsth/service/gps/GpsService.java
| ... | ... | @@ -12,4 +12,6 @@ public interface GpsService { |
| 12 | 12 | Map<String, Object> findBuffAeraByCode(String code, String type); |
| 13 | 13 | |
| 14 | 14 | Map<String, Object> search(Map<String, Object> map, int page, int size, String order, String direction); |
| 15 | + | |
| 16 | + Map<String,Object> removeRealGps(String device); | |
| 15 | 17 | } | ... | ... |
src/main/java/com/bsth/service/gps/GpsServiceImpl.java
| ... | ... | @@ -14,6 +14,7 @@ import java.util.HashMap; |
| 14 | 14 | import java.util.List; |
| 15 | 15 | import java.util.Map; |
| 16 | 16 | |
| 17 | +import org.apache.commons.lang3.StringUtils; | |
| 17 | 18 | import org.slf4j.Logger; |
| 18 | 19 | import org.slf4j.LoggerFactory; |
| 19 | 20 | import org.springframework.beans.factory.annotation.Autowired; |
| ... | ... | @@ -32,372 +33,398 @@ import com.bsth.util.TransGPS.Location; |
| 32 | 33 | import com.bsth.util.db.DBUtils_MS; |
| 33 | 34 | |
| 34 | 35 | @Service |
| 35 | -public class GpsServiceImpl implements GpsService{ | |
| 36 | - /** 历史gps查询最大范围 24小时 */ | |
| 37 | - final static Long GPS_RANGE = 60 * 60 * 24L; | |
| 38 | - | |
| 39 | - /** jdbc */ | |
| 40 | - Connection conn = null; | |
| 41 | - PreparedStatement ps = null; | |
| 42 | - ResultSet rs = null; | |
| 43 | - | |
| 44 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 45 | - | |
| 46 | - @Autowired | |
| 47 | - GpsRealData gpsRealData; | |
| 48 | - | |
| 49 | - // 历史gps查询 | |
| 50 | - @Override | |
| 51 | - public List<Map<String, Object>> history(String device, Long startTime, Long endTime, int directions) { | |
| 52 | - Calendar sCal = Calendar.getInstance(); | |
| 53 | - sCal.setTime(new Date(startTime)); | |
| 54 | - | |
| 55 | - Calendar eCal = Calendar.getInstance(); | |
| 56 | - eCal.setTime(new Date(endTime)); | |
| 57 | - | |
| 58 | - int dayOfYear = sCal.get(Calendar.DAY_OF_YEAR); | |
| 59 | - /* | |
| 36 | +public class GpsServiceImpl implements GpsService { | |
| 37 | + /** | |
| 38 | + * 历史gps查询最大范围 24小时 | |
| 39 | + */ | |
| 40 | + final static Long GPS_RANGE = 60 * 60 * 24L; | |
| 41 | + | |
| 42 | + /** | |
| 43 | + * jdbc | |
| 44 | + */ | |
| 45 | + Connection conn = null; | |
| 46 | + PreparedStatement ps = null; | |
| 47 | + ResultSet rs = null; | |
| 48 | + | |
| 49 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 50 | + | |
| 51 | + @Autowired | |
| 52 | + GpsRealData gpsRealData; | |
| 53 | + | |
| 54 | + // 历史gps查询 | |
| 55 | + @Override | |
| 56 | + public List<Map<String, Object>> history(String device, Long startTime, Long endTime, int directions) { | |
| 57 | + Calendar sCal = Calendar.getInstance(); | |
| 58 | + sCal.setTime(new Date(startTime)); | |
| 59 | + | |
| 60 | + Calendar eCal = Calendar.getInstance(); | |
| 61 | + eCal.setTime(new Date(endTime)); | |
| 62 | + | |
| 63 | + int dayOfYear = sCal.get(Calendar.DAY_OF_YEAR); | |
| 64 | + /* | |
| 60 | 65 | * if(dayOfYear != eCal.get(Calendar.DAY_OF_YEAR)){ |
| 61 | 66 | * System.out.println("暂时不支持跨天查询..."); return null; } |
| 62 | 67 | */ |
| 63 | 68 | |
| 64 | - String sql = "select DEVICE_ID,LON,LAT,TS,INOUT_STOP,SERVICE_STATE ,STOP_NO from bsth_c_gps_info where days_year=? and device_id=? and ts > ? and ts < ?"; | |
| 65 | - Connection conn = null; | |
| 66 | - PreparedStatement ps = null; | |
| 67 | - ResultSet rs = null; | |
| 68 | - List<Map<String, Object>> list = new ArrayList<>(); | |
| 69 | - Map<String, Object> map = null; | |
| 70 | - try { | |
| 71 | - conn = DBUtils_MS.getConnection(); | |
| 72 | - ps = conn.prepareStatement(sql); | |
| 73 | - ps.setInt(1, dayOfYear); | |
| 74 | - ps.setString(2, device); | |
| 75 | - ps.setLong(3, startTime); | |
| 76 | - ps.setLong(4, endTime); | |
| 77 | - | |
| 78 | - rs = ps.executeQuery(); | |
| 79 | - Float lon, lat; | |
| 80 | - Location location; | |
| 81 | - int upDown; | |
| 82 | - while (rs.next()) { | |
| 83 | - upDown = getUpOrDown(rs.getLong("SERVICE_STATE")); | |
| 84 | - if (upDown != directions) | |
| 85 | - continue; | |
| 86 | - | |
| 87 | - // to 百度坐标 | |
| 88 | - lon = rs.getFloat("LON"); | |
| 89 | - lat = rs.getFloat("LAT"); | |
| 90 | - location = TransGPS.LocationMake(lon, lat); | |
| 91 | - location = TransGPS.bd_encrypt(TransGPS.transformFromWGSToGCJ(location)); | |
| 92 | - | |
| 93 | - map = new HashMap<>(); | |
| 94 | - map.put("device", rs.getString("DEVICE_ID")); | |
| 95 | - map.put("lon", location.getLng()); | |
| 96 | - map.put("lat", location.getLat()); | |
| 97 | - map.put("ts", rs.getLong("TS")); | |
| 98 | - map.put("stopNo", rs.getString("STOP_NO")); | |
| 99 | - map.put("inout_stop", rs.getInt("INOUT_STOP")); | |
| 100 | - // 上下行 | |
| 101 | - map.put("upDown", upDown); | |
| 102 | - list.add(map); | |
| 103 | - } | |
| 104 | - } catch (Exception e) { | |
| 105 | - e.printStackTrace(); | |
| 106 | - } finally { | |
| 107 | - DBUtils_MS.close(rs, ps, conn); | |
| 108 | - } | |
| 109 | - return list; | |
| 110 | - } | |
| 111 | - | |
| 112 | - /** | |
| 113 | - * 王通 2016/6/29 9:23:24 获取车辆线路上下行 | |
| 114 | - * | |
| 115 | - * @return -1无效 0上行 1下行 | |
| 116 | - */ | |
| 117 | - public static byte getUpOrDown(long serviceState) { | |
| 118 | - if ((serviceState & 0x00020000) == 0x00020000 || (serviceState & 0x80000000) == 0x80000000 | |
| 119 | - || (serviceState & 0x01000000) == 0x01000000 || (serviceState & 0x08000000) == 0x08000000) | |
| 120 | - return -1; | |
| 121 | - return (byte) (((serviceState & 0x10000000) == 0x10000000) ? 1 : 0); | |
| 122 | - } | |
| 123 | - | |
| 124 | - @Override | |
| 125 | - public List<Map<String, Object>> history(String[] nbbmArray, Long st, Long et) { | |
| 126 | - List<Map<String, Object>> list = new ArrayList<>(); | |
| 127 | - // 超过最大查询范围,直接忽略 | |
| 128 | - if (et - st > GPS_RANGE) | |
| 129 | - return list; | |
| 130 | - | |
| 131 | - // 车辆编码转换成设备号 | |
| 132 | - String[] devices = new String[nbbmArray.length]; | |
| 133 | - for (int i = 0; i < nbbmArray.length; i++) { | |
| 134 | - devices[i] = BasicData.deviceId2NbbmMap.inverse().get(nbbmArray[i]); | |
| 135 | - } | |
| 136 | - // day_of_year | |
| 137 | - Calendar sCal = Calendar.getInstance(); | |
| 138 | - sCal.setTime(new Date(st * 1000)); | |
| 139 | - int sDayOfYear = sCal.get(Calendar.DAY_OF_YEAR)/* 200 */; | |
| 140 | - | |
| 141 | - Calendar eCal = Calendar.getInstance(); | |
| 142 | - eCal.setTime(new Date(et * 1000)); | |
| 143 | - int eDayOfYear = eCal.get(Calendar.DAY_OF_YEAR)/* 200 */; | |
| 144 | - | |
| 145 | - Calendar weekCal = Calendar.getInstance(); | |
| 146 | - | |
| 147 | - // 如果是同一天 | |
| 148 | - if (sDayOfYear == eDayOfYear) { | |
| 149 | - weekCal.setTimeInMillis(st * 1000); | |
| 150 | - list = findByTs(weekCal.get(Calendar.WEEK_OF_YEAR), sDayOfYear, st, et, devices); | |
| 151 | - } else { | |
| 152 | - // 跨天 | |
| 153 | - Long tempSt = 0L, tempEt = 0L; | |
| 154 | - for (int i = sDayOfYear; i <= eDayOfYear; i++) { | |
| 155 | - | |
| 156 | - if (i == sDayOfYear) { | |
| 157 | - tempSt = st; | |
| 158 | - tempEt = DateUtils.getTimesnight(sCal); | |
| 159 | - } else if (i == eDayOfYear) { | |
| 160 | - tempSt = DateUtils.getTimesmorning(sCal); | |
| 161 | - tempEt = et; | |
| 162 | - } else { | |
| 163 | - tempSt = DateUtils.getTimesmorning(sCal); | |
| 164 | - tempEt = DateUtils.getTimesnight(sCal); | |
| 165 | - } | |
| 166 | - | |
| 167 | - weekCal.setTimeInMillis(tempSt * 1000); | |
| 168 | - list.addAll(findByTs(weekCal.get(Calendar.WEEK_OF_YEAR), i, tempSt, tempEt, devices)); | |
| 169 | - // 加一天 | |
| 170 | - sCal.add(Calendar.DATE, 1); | |
| 171 | - } | |
| 172 | - } | |
| 173 | - | |
| 174 | - // 按时间排序 | |
| 175 | - Collections.sort(list, new Comparator<Map<String, Object>>() { | |
| 176 | - | |
| 177 | - @Override | |
| 178 | - public int compare(Map<String, Object> o1, Map<String, Object> o2) { | |
| 179 | - return (int) (Long.parseLong(o1.get("ts").toString()) - Long.parseLong(o2.get("ts").toString())); | |
| 180 | - } | |
| 181 | - }); | |
| 182 | - ; | |
| 183 | - return list; | |
| 184 | - } | |
| 185 | - | |
| 186 | - public List<Map<String, Object>> findByTs(int weekOfYear, int dayOfYear, Long st, Long et, String[] devices) { | |
| 187 | - List<Map<String, Object>> list = new ArrayList<>(); | |
| 188 | - Map<String, Object> map = null; | |
| 189 | - | |
| 190 | - // setArray 不好用,直接拼 in 语句 | |
| 191 | - String inv = ""; | |
| 192 | - for (String device : devices) | |
| 193 | - inv += ("'" + device + "',"); | |
| 194 | - inv = inv.substring(0, inv.length() - 1); | |
| 195 | - | |
| 196 | - // 查询到离站数据 | |
| 197 | - Map<String, ArrivalEntity> arrivalMap = findArrivalByTs(weekOfYear/* 30 */, st, et, inv); | |
| 198 | - | |
| 199 | - String sql = "select DEVICE_ID,LON,LAT,TS,INOUT_STOP,SERVICE_STATE ,STOP_NO from bsth_c_gps_info where days_year=? and device_id in (" | |
| 200 | - + inv + ") and ts > ? and ts < ?"; | |
| 201 | - try { | |
| 202 | - conn = DBUtils_MS.getConnection(); | |
| 203 | - ps = conn.prepareStatement(sql); | |
| 204 | - ps.setInt(1, dayOfYear); | |
| 69 | + String sql = "select DEVICE_ID,LON,LAT,TS,INOUT_STOP,SERVICE_STATE ,STOP_NO from bsth_c_gps_info where days_year=? and device_id=? and ts > ? and ts < ?"; | |
| 70 | + Connection conn = null; | |
| 71 | + PreparedStatement ps = null; | |
| 72 | + ResultSet rs = null; | |
| 73 | + List<Map<String, Object>> list = new ArrayList<>(); | |
| 74 | + Map<String, Object> map = null; | |
| 75 | + try { | |
| 76 | + conn = DBUtils_MS.getConnection(); | |
| 77 | + ps = conn.prepareStatement(sql); | |
| 78 | + ps.setInt(1, dayOfYear); | |
| 79 | + ps.setString(2, device); | |
| 80 | + ps.setLong(3, startTime); | |
| 81 | + ps.setLong(4, endTime); | |
| 82 | + | |
| 83 | + rs = ps.executeQuery(); | |
| 84 | + Float lon, lat; | |
| 85 | + Location location; | |
| 86 | + int upDown; | |
| 87 | + while (rs.next()) { | |
| 88 | + upDown = getUpOrDown(rs.getLong("SERVICE_STATE")); | |
| 89 | + if (upDown != directions) | |
| 90 | + continue; | |
| 91 | + | |
| 92 | + // to 百度坐标 | |
| 93 | + lon = rs.getFloat("LON"); | |
| 94 | + lat = rs.getFloat("LAT"); | |
| 95 | + location = TransGPS.LocationMake(lon, lat); | |
| 96 | + location = TransGPS.bd_encrypt(TransGPS.transformFromWGSToGCJ(location)); | |
| 97 | + | |
| 98 | + map = new HashMap<>(); | |
| 99 | + map.put("device", rs.getString("DEVICE_ID")); | |
| 100 | + map.put("lon", location.getLng()); | |
| 101 | + map.put("lat", location.getLat()); | |
| 102 | + map.put("ts", rs.getLong("TS")); | |
| 103 | + map.put("stopNo", rs.getString("STOP_NO")); | |
| 104 | + map.put("inout_stop", rs.getInt("INOUT_STOP")); | |
| 105 | + // 上下行 | |
| 106 | + map.put("upDown", upDown); | |
| 107 | + list.add(map); | |
| 108 | + } | |
| 109 | + } catch (Exception e) { | |
| 110 | + e.printStackTrace(); | |
| 111 | + } finally { | |
| 112 | + DBUtils_MS.close(rs, ps, conn); | |
| 113 | + } | |
| 114 | + return list; | |
| 115 | + } | |
| 116 | + | |
| 117 | + /** | |
| 118 | + * 王通 2016/6/29 9:23:24 获取车辆线路上下行 | |
| 119 | + * | |
| 120 | + * @return -1无效 0上行 1下行 | |
| 121 | + */ | |
| 122 | + public static byte getUpOrDown(long serviceState) { | |
| 123 | + if ((serviceState & 0x00020000) == 0x00020000 || (serviceState & 0x80000000) == 0x80000000 | |
| 124 | + || (serviceState & 0x01000000) == 0x01000000 || (serviceState & 0x08000000) == 0x08000000) | |
| 125 | + return -1; | |
| 126 | + return (byte) (((serviceState & 0x10000000) == 0x10000000) ? 1 : 0); | |
| 127 | + } | |
| 128 | + | |
| 129 | + @Override | |
| 130 | + public List<Map<String, Object>> history(String[] nbbmArray, Long st, Long et) { | |
| 131 | + List<Map<String, Object>> list = new ArrayList<>(); | |
| 132 | + // 超过最大查询范围,直接忽略 | |
| 133 | + if (et - st > GPS_RANGE) | |
| 134 | + return list; | |
| 135 | + | |
| 136 | + // 车辆编码转换成设备号 | |
| 137 | + String[] devices = new String[nbbmArray.length]; | |
| 138 | + for (int i = 0; i < nbbmArray.length; i++) { | |
| 139 | + devices[i] = BasicData.deviceId2NbbmMap.inverse().get(nbbmArray[i]); | |
| 140 | + } | |
| 141 | + // day_of_year | |
| 142 | + Calendar sCal = Calendar.getInstance(); | |
| 143 | + sCal.setTime(new Date(st * 1000)); | |
| 144 | + int sDayOfYear = sCal.get(Calendar.DAY_OF_YEAR)/* 200 */; | |
| 145 | + | |
| 146 | + Calendar eCal = Calendar.getInstance(); | |
| 147 | + eCal.setTime(new Date(et * 1000)); | |
| 148 | + int eDayOfYear = eCal.get(Calendar.DAY_OF_YEAR)/* 200 */; | |
| 149 | + | |
| 150 | + Calendar weekCal = Calendar.getInstance(); | |
| 151 | + | |
| 152 | + // 如果是同一天 | |
| 153 | + if (sDayOfYear == eDayOfYear) { | |
| 154 | + weekCal.setTimeInMillis(st * 1000); | |
| 155 | + list = findByTs(weekCal.get(Calendar.WEEK_OF_YEAR), sDayOfYear, st, et, devices); | |
| 156 | + } else { | |
| 157 | + // 跨天 | |
| 158 | + Long tempSt = 0L, tempEt = 0L; | |
| 159 | + for (int i = sDayOfYear; i <= eDayOfYear; i++) { | |
| 160 | + | |
| 161 | + if (i == sDayOfYear) { | |
| 162 | + tempSt = st; | |
| 163 | + tempEt = DateUtils.getTimesnight(sCal); | |
| 164 | + } else if (i == eDayOfYear) { | |
| 165 | + tempSt = DateUtils.getTimesmorning(sCal); | |
| 166 | + tempEt = et; | |
| 167 | + } else { | |
| 168 | + tempSt = DateUtils.getTimesmorning(sCal); | |
| 169 | + tempEt = DateUtils.getTimesnight(sCal); | |
| 170 | + } | |
| 171 | + | |
| 172 | + weekCal.setTimeInMillis(tempSt * 1000); | |
| 173 | + list.addAll(findByTs(weekCal.get(Calendar.WEEK_OF_YEAR), i, tempSt, tempEt, devices)); | |
| 174 | + // 加一天 | |
| 175 | + sCal.add(Calendar.DATE, 1); | |
| 176 | + } | |
| 177 | + } | |
| 178 | + | |
| 179 | + // 按时间排序 | |
| 180 | + Collections.sort(list, new Comparator<Map<String, Object>>() { | |
| 181 | + | |
| 182 | + @Override | |
| 183 | + public int compare(Map<String, Object> o1, Map<String, Object> o2) { | |
| 184 | + return (int) (Long.parseLong(o1.get("ts").toString()) - Long.parseLong(o2.get("ts").toString())); | |
| 185 | + } | |
| 186 | + }); | |
| 187 | + ; | |
| 188 | + return list; | |
| 189 | + } | |
| 190 | + | |
| 191 | + public List<Map<String, Object>> findByTs(int weekOfYear, int dayOfYear, Long st, Long et, String[] devices) { | |
| 192 | + List<Map<String, Object>> list = new ArrayList<>(); | |
| 193 | + Map<String, Object> map = null; | |
| 194 | + | |
| 195 | + // 直接拼 in 语句 | |
| 196 | + String inv = ""; | |
| 197 | + for (String device : devices) | |
| 198 | + inv += ("'" + device + "',"); | |
| 199 | + inv = inv.substring(0, inv.length() - 1); | |
| 200 | + | |
| 201 | + // 查询到离站数据 | |
| 202 | + Map<String, ArrivalEntity> arrivalMap = findArrivalByTs(weekOfYear/* 30 */, st, et, inv); | |
| 203 | + | |
| 204 | + String sql = "select DEVICE_ID,LON,LAT,TS,INOUT_STOP,SERVICE_STATE ,STOP_NO from bsth_c_gps_info where days_year=? and device_id in (" | |
| 205 | + + inv + ") and ts > ? and ts < ?"; | |
| 206 | + try { | |
| 207 | + conn = DBUtils_MS.getConnection(); | |
| 208 | + ps = conn.prepareStatement(sql); | |
| 209 | + ps.setInt(1, dayOfYear); | |
| 205 | 210 | /* ps.setArray(2, conn.createArrayOf("VARCHAR", devices)); */ |
| 206 | - ps.setLong(2, st * 1000); | |
| 207 | - ps.setLong(3, et * 1000); | |
| 208 | - | |
| 209 | - rs = ps.executeQuery(); | |
| 210 | - Float lon, lat; | |
| 211 | - Location bdLoc, gdLoc; | |
| 212 | - int upDown, inOutStop; | |
| 213 | - ArrivalEntity arrival; | |
| 214 | - while (rs.next()) { | |
| 215 | - upDown = getUpOrDown(rs.getLong("SERVICE_STATE")); | |
| 216 | - map = new HashMap<>(); | |
| 217 | - | |
| 218 | - lon = rs.getFloat("LON"); | |
| 219 | - lat = rs.getFloat("LAT"); | |
| 220 | - // 高德坐标 | |
| 221 | - gdLoc = TransGPS.transformFromWGSToGCJ(TransGPS.LocationMake(lon, lat)); | |
| 222 | - map.put("gcj_lon", gdLoc.getLng()); | |
| 223 | - map.put("gcj_lat", gdLoc.getLat()); | |
| 224 | - // 百度坐标 | |
| 225 | - bdLoc = TransGPS.bd_encrypt(gdLoc); | |
| 226 | - map.put("bd_lon", bdLoc.getLng()); | |
| 227 | - map.put("bd_lat", bdLoc.getLat()); | |
| 228 | - | |
| 229 | - map.put("deviceId", rs.getString("DEVICE_ID")); | |
| 230 | - map.put("ts", rs.getLong("TS")); | |
| 231 | - map.put("timestamp", rs.getLong("TS")); | |
| 232 | - map.put("stopNo", rs.getString("STOP_NO")); | |
| 233 | - | |
| 234 | - inOutStop = rs.getInt("INOUT_STOP"); | |
| 235 | - map.put("inout_stop", inOutStop); | |
| 236 | - | |
| 237 | - arrival = arrivalMap.get(rs.getString("DEVICE_ID") + "_" + rs.getLong("TS")); | |
| 238 | - if (arrival != null) { | |
| 239 | - map.put("inout_stop_info",arrival); | |
| 240 | - map.put("inout_stop", arrival.getInOut()); | |
| 241 | - } | |
| 242 | - map.put("nbbm", BasicData.deviceId2NbbmMap.get(rs.getString("DEVICE_ID"))); | |
| 243 | - map.put("state", 0); | |
| 244 | - // 上下行 | |
| 245 | - map.put("upDown", upDown); | |
| 246 | - list.add(map); | |
| 247 | - } | |
| 248 | - } catch (Exception e) { | |
| 249 | - logger.error("", e); | |
| 250 | - } finally { | |
| 251 | - DBUtils_MS.close(rs, ps, conn); | |
| 252 | - } | |
| 253 | - return list; | |
| 254 | - } | |
| 255 | - | |
| 256 | - public Map<String, ArrivalEntity> findArrivalByTs(int weekOfYear, Long st, Long et, String devicesInSql) { | |
| 257 | - Map<String, ArrivalEntity> map = new HashMap<>(); | |
| 258 | - | |
| 259 | - String sql = "SELECT DEVICE_ID,LINE_ID,STOP_NO,TS,UP_DOWN,IN_OUT,WEEKS_YEAR,CREATE_DATE FROM bsth_c_arrival_info where weeks_year=? and device_id in (" | |
| 260 | - + devicesInSql + ") and ts > ? and ts < ?"; | |
| 261 | - try { | |
| 262 | - conn = DBUtils_MS.getConnection(); | |
| 263 | - ps = conn.prepareStatement(sql); | |
| 264 | - ps.setInt(1, weekOfYear); | |
| 265 | - ps.setLong(2, st * 1000); | |
| 266 | - ps.setLong(3, et * 1000); | |
| 267 | - | |
| 268 | - rs = ps.executeQuery(); | |
| 269 | - ArrivalEntity arr; | |
| 270 | - int inOut; | |
| 271 | - while (rs.next()) { | |
| 272 | - arr = new ArrivalEntity(rs.getString("DEVICE_ID"), rs.getLong("TS"), rs.getString("LINE_ID"), | |
| 273 | - rs.getInt("UP_DOWN"), rs.getString("STOP_NO"), rs.getInt("IN_OUT"), rs.getLong("CREATE_DATE"), | |
| 274 | - rs.getInt("WEEKS_YEAR"), BasicData.stationCode2NameMap.get(rs.getString("STOP_NO"))); | |
| 275 | - | |
| 276 | - // 设备号_时间戳_进出状态 为key | |
| 277 | - // 反转进出状态 | |
| 278 | - inOut = arr.getInOut() == 0 ? 1 : 0; | |
| 279 | - map.put(arr.getDeviceId() + "_" + arr.getTs(), arr); | |
| 280 | - } | |
| 281 | - } catch (Exception e) { | |
| 282 | - logger.error("", e); | |
| 283 | - } finally { | |
| 284 | - DBUtils_MS.close(rs, ps, conn); | |
| 285 | - } | |
| 286 | - return map; | |
| 287 | - } | |
| 288 | - | |
| 289 | - | |
| 290 | - @Autowired | |
| 291 | - StationRepository stationRepository; | |
| 292 | - | |
| 293 | - @Autowired | |
| 294 | - CarParkRepository carParkRepository; | |
| 295 | - | |
| 296 | - @Override | |
| 297 | - public Map<String, Object> findBuffAeraByCode(String code, String type) { | |
| 298 | - Object[][] obj = null; | |
| 299 | - if(type.equals("station")) | |
| 300 | - obj = stationRepository.bufferAera(code); | |
| 301 | - else if(type.equals("park")) | |
| 302 | - obj = carParkRepository.bufferAera(code); | |
| 303 | - | |
| 304 | - Map<String, Object> rs = new HashMap<>(); | |
| 305 | - | |
| 306 | - Object[] subObj = obj[0]; | |
| 307 | - if(subObj != null && subObj.length == 6){ | |
| 308 | - rs.put("polygon", subObj[0]); | |
| 309 | - rs.put("type", subObj[1]); | |
| 310 | - rs.put("cPoint", subObj[2]); | |
| 311 | - rs.put("radius", subObj[3]); | |
| 312 | - rs.put("code", subObj[4]); | |
| 313 | - rs.put("text", subObj[5]); | |
| 314 | - } | |
| 315 | - | |
| 316 | - return rs; | |
| 317 | - } | |
| 318 | - | |
| 319 | - @Override | |
| 320 | - public Map<String, Object> search(Map<String, Object> map, int page, int size, String order, String direction) { | |
| 321 | - Map<String, Object> rsMap = new HashMap<>(); | |
| 322 | - try{ | |
| 323 | - //全量 | |
| 324 | - Collection<GpsEntity> list = gpsRealData.all(); | |
| 325 | - //过滤后的 | |
| 326 | - List<GpsEntity> rs = new ArrayList<>(); | |
| 327 | - Field[] fields = GpsEntity.class.getDeclaredFields(); | |
| 328 | - //排序字段 | |
| 329 | - Field orderField = null; | |
| 330 | - //参与过滤的字段 | |
| 331 | - List<Field> fs = new ArrayList<>(); | |
| 332 | - for(Field f : fields){ | |
| 333 | - f.setAccessible(true); | |
| 334 | - if(map.containsKey(f.getName())) | |
| 335 | - fs.add(f); | |
| 336 | - | |
| 337 | - if(f.getName().equals(order)) | |
| 338 | - orderField = f; | |
| 339 | - } | |
| 340 | - //过滤数据 | |
| 341 | - for(GpsEntity gps : list){ | |
| 342 | - if(fieldEquals(fs, gps, map)) | |
| 343 | - rs.add(gps); | |
| 344 | - } | |
| 345 | - | |
| 346 | - //排序 | |
| 347 | - if(null != orderField) | |
| 348 | - sortGpsList(orderField, rs); | |
| 349 | - | |
| 350 | - //分页 | |
| 351 | - int count = rs.size() | |
| 352 | - ,s = page * size, e = s + size; | |
| 353 | - if (e > count) | |
| 354 | - e = count; | |
| 355 | - | |
| 356 | - rsMap.put("list", rs.subList(s, e)); | |
| 357 | - rsMap.put("totalPages", count % size == 0 ? count / size : count / size + 1); | |
| 358 | - rsMap.put("page", page); | |
| 359 | - rsMap.put("status", ResponseCode.SUCCESS); | |
| 360 | - }catch(Exception e){ | |
| 361 | - logger.error("", e); | |
| 362 | - rsMap.put("status", ResponseCode.ERROR); | |
| 363 | - } | |
| 364 | - return rsMap; | |
| 365 | - } | |
| 366 | - | |
| 367 | - private void sortGpsList(final Field f, List<GpsEntity> rs) { | |
| 368 | - Collections.sort(rs, new Comparator<GpsEntity>() { | |
| 369 | - | |
| 370 | - @Override | |
| 371 | - public int compare(GpsEntity o1, GpsEntity o2) { | |
| 372 | - try { | |
| 373 | - if(f.get(o1) == f.get(o2)) | |
| 374 | - return 0; | |
| 375 | - | |
| 376 | - if(null == f.get(o1)) | |
| 377 | - return 1; | |
| 378 | - | |
| 379 | - if(null == f.get(o2)) | |
| 380 | - return -1; | |
| 381 | - | |
| 382 | - return f.get(o1).toString().compareTo(f.get(o2).toString()); | |
| 383 | - } catch (Exception e) { | |
| 384 | - logger.error("", e); | |
| 385 | - return -1; | |
| 386 | - } | |
| 387 | - } | |
| 388 | - }); | |
| 389 | - } | |
| 390 | - | |
| 391 | - public boolean fieldEquals(List<Field> fs, Object obj, Map<String, Object> map){ | |
| 392 | - try{ | |
| 393 | - for(Field f : fs){ | |
| 394 | - if(f.get(obj).toString().indexOf(map.get(f.getName()).toString()) == -1) | |
| 395 | - return false; | |
| 396 | - } | |
| 397 | - }catch(Exception e){ | |
| 398 | - logger.error("", e); | |
| 399 | - return false; | |
| 400 | - } | |
| 401 | - return true; | |
| 402 | - } | |
| 211 | + ps.setLong(2, st * 1000); | |
| 212 | + ps.setLong(3, et * 1000); | |
| 213 | + | |
| 214 | + rs = ps.executeQuery(); | |
| 215 | + Float lon, lat; | |
| 216 | + Location bdLoc, gdLoc; | |
| 217 | + int upDown, inOutStop; | |
| 218 | + ArrivalEntity arrival; | |
| 219 | + while (rs.next()) { | |
| 220 | + upDown = getUpOrDown(rs.getLong("SERVICE_STATE")); | |
| 221 | + map = new HashMap<>(); | |
| 222 | + | |
| 223 | + lon = rs.getFloat("LON"); | |
| 224 | + lat = rs.getFloat("LAT"); | |
| 225 | + // 高德坐标 | |
| 226 | + gdLoc = TransGPS.transformFromWGSToGCJ(TransGPS.LocationMake(lon, lat)); | |
| 227 | + map.put("gcj_lon", gdLoc.getLng()); | |
| 228 | + map.put("gcj_lat", gdLoc.getLat()); | |
| 229 | + // 百度坐标 | |
| 230 | + bdLoc = TransGPS.bd_encrypt(gdLoc); | |
| 231 | + map.put("bd_lon", bdLoc.getLng()); | |
| 232 | + map.put("bd_lat", bdLoc.getLat()); | |
| 233 | + | |
| 234 | + map.put("deviceId", rs.getString("DEVICE_ID")); | |
| 235 | + map.put("ts", rs.getLong("TS")); | |
| 236 | + map.put("timestamp", rs.getLong("TS")); | |
| 237 | + map.put("stopNo", rs.getString("STOP_NO")); | |
| 238 | + | |
| 239 | + inOutStop = rs.getInt("INOUT_STOP"); | |
| 240 | + map.put("inout_stop", inOutStop); | |
| 241 | + | |
| 242 | + arrival = arrivalMap.get(rs.getString("DEVICE_ID") + "_" + rs.getLong("TS")); | |
| 243 | + if (arrival != null) { | |
| 244 | + map.put("inout_stop_info", arrival); | |
| 245 | + map.put("inout_stop", arrival.getInOut()); | |
| 246 | + } | |
| 247 | + map.put("nbbm", BasicData.deviceId2NbbmMap.get(rs.getString("DEVICE_ID"))); | |
| 248 | + map.put("state", 0); | |
| 249 | + // 上下行 | |
| 250 | + map.put("upDown", upDown); | |
| 251 | + list.add(map); | |
| 252 | + } | |
| 253 | + } catch (Exception e) { | |
| 254 | + logger.error("", e); | |
| 255 | + } finally { | |
| 256 | + DBUtils_MS.close(rs, ps, conn); | |
| 257 | + } | |
| 258 | + return list; | |
| 259 | + } | |
| 260 | + | |
| 261 | + public Map<String, ArrivalEntity> findArrivalByTs(int weekOfYear, Long st, Long et, String devicesInSql) { | |
| 262 | + Map<String, ArrivalEntity> map = new HashMap<>(); | |
| 263 | + | |
| 264 | + String sql = "SELECT DEVICE_ID,LINE_ID,STOP_NO,TS,UP_DOWN,IN_OUT,WEEKS_YEAR,CREATE_DATE FROM bsth_c_arrival_info where weeks_year=? and device_id in (" | |
| 265 | + + devicesInSql + ") and ts > ? and ts < ?"; | |
| 266 | + try { | |
| 267 | + conn = DBUtils_MS.getConnection(); | |
| 268 | + ps = conn.prepareStatement(sql); | |
| 269 | + ps.setInt(1, weekOfYear); | |
| 270 | + ps.setLong(2, st * 1000); | |
| 271 | + ps.setLong(3, et * 1000); | |
| 272 | + | |
| 273 | + rs = ps.executeQuery(); | |
| 274 | + ArrivalEntity arr; | |
| 275 | + int inOut; | |
| 276 | + while (rs.next()) { | |
| 277 | + arr = new ArrivalEntity(rs.getString("DEVICE_ID"), rs.getLong("TS"), rs.getString("LINE_ID"), | |
| 278 | + rs.getInt("UP_DOWN"), rs.getString("STOP_NO"), rs.getInt("IN_OUT"), rs.getLong("CREATE_DATE"), | |
| 279 | + rs.getInt("WEEKS_YEAR"), BasicData.stationCode2NameMap.get(rs.getString("STOP_NO"))); | |
| 280 | + | |
| 281 | + // 设备号_时间戳_进出状态 为key | |
| 282 | + // 反转进出状态 | |
| 283 | + inOut = arr.getInOut() == 0 ? 1 : 0; | |
| 284 | + map.put(arr.getDeviceId() + "_" + arr.getTs(), arr); | |
| 285 | + } | |
| 286 | + } catch (Exception e) { | |
| 287 | + logger.error("", e); | |
| 288 | + } finally { | |
| 289 | + DBUtils_MS.close(rs, ps, conn); | |
| 290 | + } | |
| 291 | + return map; | |
| 292 | + } | |
| 293 | + | |
| 294 | + | |
| 295 | + @Autowired | |
| 296 | + StationRepository stationRepository; | |
| 297 | + | |
| 298 | + @Autowired | |
| 299 | + CarParkRepository carParkRepository; | |
| 300 | + | |
| 301 | + @Override | |
| 302 | + public Map<String, Object> findBuffAeraByCode(String code, String type) { | |
| 303 | + Object[][] obj = null; | |
| 304 | + if (type.equals("station")) | |
| 305 | + obj = stationRepository.bufferAera(code); | |
| 306 | + else if (type.equals("park")) | |
| 307 | + obj = carParkRepository.bufferAera(code); | |
| 308 | + | |
| 309 | + Map<String, Object> rs = new HashMap<>(); | |
| 310 | + | |
| 311 | + Object[] subObj = obj[0]; | |
| 312 | + if (subObj != null && subObj.length == 6) { | |
| 313 | + rs.put("polygon", subObj[0]); | |
| 314 | + rs.put("type", subObj[1]); | |
| 315 | + rs.put("cPoint", subObj[2]); | |
| 316 | + rs.put("radius", subObj[3]); | |
| 317 | + rs.put("code", subObj[4]); | |
| 318 | + rs.put("text", subObj[5]); | |
| 319 | + } | |
| 320 | + | |
| 321 | + return rs; | |
| 322 | + } | |
| 323 | + | |
| 324 | + @Override | |
| 325 | + public Map<String, Object> search(Map<String, Object> map, int page, int size, String order, String direction) { | |
| 326 | + Map<String, Object> rsMap = new HashMap<>(); | |
| 327 | + try { | |
| 328 | + //全量 | |
| 329 | + List<GpsEntity> list = new ArrayList<>(gpsRealData.all()); | |
| 330 | + //过滤后的 | |
| 331 | + List<GpsEntity> rs = new ArrayList<>(); | |
| 332 | + Field[] fields = GpsEntity.class.getDeclaredFields(); | |
| 333 | + //排序字段 | |
| 334 | + Field orderField = null; | |
| 335 | + //参与过滤的字段 | |
| 336 | + List<Field> fs = new ArrayList<>(); | |
| 337 | + for (Field f : fields) { | |
| 338 | + f.setAccessible(true); | |
| 339 | + if (map.containsKey(f.getName())) | |
| 340 | + fs.add(f); | |
| 341 | + | |
| 342 | + if (f.getName().equals(order)) | |
| 343 | + orderField = f; | |
| 344 | + } | |
| 345 | + //过滤数据 | |
| 346 | + for (GpsEntity gps : list) { | |
| 347 | + if (fieldEquals(fs, gps, map)) | |
| 348 | + rs.add(gps); | |
| 349 | + } | |
| 350 | + | |
| 351 | + //排序 | |
| 352 | +/* if (null != orderField) | |
| 353 | + sortGpsList(orderField, rs);*/ | |
| 354 | + //时间戳排序 | |
| 355 | + Collections.sort(rs, new Comparator<GpsEntity>() { | |
| 356 | + @Override | |
| 357 | + public int compare(GpsEntity o1, GpsEntity o2) { | |
| 358 | + return o2.getTimestamp().intValue() - o1.getTimestamp().intValue(); | |
| 359 | + } | |
| 360 | + }); | |
| 361 | + | |
| 362 | + //分页 | |
| 363 | + int count = rs.size(), s = page * size, e = s + size; | |
| 364 | + if (e > count) | |
| 365 | + e = count; | |
| 366 | + | |
| 367 | + rsMap.put("list", rs.subList(s, e)); | |
| 368 | + rsMap.put("totalPages", count % size == 0 ? count / size - 1 : count / size); | |
| 369 | + rsMap.put("page", page); | |
| 370 | + rsMap.put("status", ResponseCode.SUCCESS); | |
| 371 | + } catch (Exception e) { | |
| 372 | + logger.error("", e); | |
| 373 | + rsMap.put("status", ResponseCode.ERROR); | |
| 374 | + } | |
| 375 | + return rsMap; | |
| 376 | + } | |
| 377 | + | |
| 378 | + @Override | |
| 379 | + public Map<String, Object> removeRealGps(String device) { | |
| 380 | + Map<String, Object> rs = new HashMap<>(); | |
| 381 | + try { | |
| 382 | + | |
| 383 | + gpsRealData.remove(device); | |
| 384 | + rs.put("status", ResponseCode.SUCCESS); | |
| 385 | + }catch (Exception e){ | |
| 386 | + rs.put("status", ResponseCode.ERROR); | |
| 387 | + } | |
| 388 | + return rs; | |
| 389 | + } | |
| 390 | + | |
| 391 | + private void sortGpsList(final Field f, List<GpsEntity> rs) { | |
| 392 | + Collections.sort(rs, new Comparator<GpsEntity>() { | |
| 393 | + | |
| 394 | + @Override | |
| 395 | + public int compare(GpsEntity o1, GpsEntity o2) { | |
| 396 | + try { | |
| 397 | + if (f.get(o1) == f.get(o2)) | |
| 398 | + return 0; | |
| 399 | + | |
| 400 | + if (null == f.get(o1)) | |
| 401 | + return 1; | |
| 402 | + | |
| 403 | + if (null == f.get(o2)) | |
| 404 | + return -1; | |
| 405 | + | |
| 406 | + return f.get(o1).toString().compareTo(f.get(o2).toString()); | |
| 407 | + } catch (Exception e) { | |
| 408 | + logger.error("", e); | |
| 409 | + return -1; | |
| 410 | + } | |
| 411 | + } | |
| 412 | + }); | |
| 413 | + } | |
| 414 | + | |
| 415 | + public boolean fieldEquals(List<Field> fs, Object obj, Map<String, Object> map) { | |
| 416 | + try { | |
| 417 | + for (Field f : fs) { | |
| 418 | + if (StringUtils.isEmpty(map.get(f.getName()).toString())) | |
| 419 | + continue; | |
| 420 | + | |
| 421 | + if (f.get(obj) == null || f.get(obj).toString().indexOf(map.get(f.getName()).toString()) == -1) | |
| 422 | + return false; | |
| 423 | + } | |
| 424 | + } catch (Exception e) { | |
| 425 | + logger.error("", e); | |
| 426 | + return false; | |
| 427 | + } | |
| 428 | + return true; | |
| 429 | + } | |
| 403 | 430 | } | ... | ... |
src/main/java/com/bsth/service/impl/LineServiceImpl.java
| ... | ... | @@ -40,8 +40,8 @@ public class LineServiceImpl extends BaseServiceImpl<Line, Integer> implements L |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | @Override |
| 43 | - public Line findByLineCode(Integer lineCode) { | |
| 44 | - return repository.findByLineCode(lineCode + ""); | |
| 43 | + public Line findByLineCode(String lineCode) { | |
| 44 | + return repository.findByLineCode(lineCode); | |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | } | ... | ... |
src/main/java/com/bsth/service/impl/TrafficManageServiceImpl.java
| 1 | 1 | package com.bsth.service.impl; |
| 2 | 2 | |
| 3 | +import java.io.BufferedOutputStream; | |
| 4 | +import java.io.File; | |
| 5 | +import java.io.FileOutputStream; | |
| 6 | +import java.io.IOException; | |
| 3 | 7 | import java.sql.Connection; |
| 4 | 8 | import java.sql.PreparedStatement; |
| 5 | 9 | import java.sql.ResultSet; |
| 6 | 10 | import java.text.DecimalFormat; |
| 7 | 11 | import java.text.SimpleDateFormat; |
| 8 | -import java.util.ArrayList; | |
| 9 | -import java.util.Calendar; | |
| 10 | 12 | import java.util.Date; |
| 11 | 13 | import java.util.HashMap; |
| 12 | 14 | import java.util.Iterator; |
| ... | ... | @@ -20,7 +22,6 @@ import org.slf4j.LoggerFactory; |
| 20 | 22 | import org.springframework.beans.factory.annotation.Autowired; |
| 21 | 23 | import org.springframework.data.domain.Sort; |
| 22 | 24 | import org.springframework.data.domain.Sort.Direction; |
| 23 | -import org.springframework.jdbc.core.JdbcTemplate; | |
| 24 | 25 | import org.springframework.stereotype.Service; |
| 25 | 26 | |
| 26 | 27 | import com.bsth.data.BasicData; |
| ... | ... | @@ -54,70 +55,70 @@ import com.bsth.webService.trafficManage.org.tempuri.WebServiceLocator; |
| 54 | 55 | import com.bsth.webService.trafficManage.org.tempuri.WebServiceSoap; |
| 55 | 56 | import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; |
| 56 | 57 | /** |
| 57 | - * | |
| 58 | - * @ClassName: LineServiceImpl(线路service业务层实现类) | |
| 59 | - * | |
| 58 | + * | |
| 59 | + * @ClassName: TrafficManageServiceImpl(运管处接口service业务层实现类) | |
| 60 | + * | |
| 60 | 61 | * @Extends : BaseService |
| 61 | - * | |
| 62 | - * @Description: TODO(线路service业务层) | |
| 63 | - * | |
| 64 | - * @Author bsth@lq | |
| 65 | - * | |
| 66 | - * @Date 2016年4月28日 上午9:21:17 | |
| 62 | + * | |
| 63 | + * @Description: TODO(运管处接口service业务层) | |
| 64 | + * | |
| 65 | + * @Author bsth@z | |
| 66 | + * | |
| 67 | + * @Date 2016年10月28日 上午9:21:17 | |
| 67 | 68 | * |
| 68 | 69 | * @Version 公交调度系统BS版 0.1 |
| 69 | - * | |
| 70 | + * | |
| 70 | 71 | */ |
| 71 | 72 | |
| 72 | 73 | @Service |
| 73 | 74 | public class TrafficManageServiceImpl implements TrafficManageService{ |
| 74 | - | |
| 75 | + | |
| 75 | 76 | Logger logger = LoggerFactory.getLogger(this.getClass()); |
| 76 | - | |
| 77 | + | |
| 77 | 78 | // 线路repository |
| 78 | 79 | @Autowired |
| 79 | 80 | private LineRepository lineRepository; |
| 80 | - | |
| 81 | + | |
| 81 | 82 | // 站点路由repository |
| 82 | 83 | @Autowired |
| 83 | 84 | private StationRouteRepository stationRouteRepository; |
| 84 | - | |
| 85 | + | |
| 85 | 86 | // 线路标准信息repository |
| 86 | 87 | @Autowired |
| 87 | 88 | private LineInformationRepository lineInformationRepository; |
| 88 | - | |
| 89 | + | |
| 89 | 90 | // 车辆repository |
| 90 | 91 | @Autowired |
| 91 | 92 | private CarsRepository carsRepository; |
| 92 | - | |
| 93 | + | |
| 93 | 94 | // 人员repository |
| 94 | 95 | @Autowired |
| 95 | 96 | private PersonnelRepository personnelRepository; |
| 96 | - | |
| 97 | + | |
| 97 | 98 | // 时刻模板repository |
| 98 | 99 | @Autowired |
| 99 | 100 | private TTInfoRepository ttInfoRepository; |
| 100 | - | |
| 101 | + | |
| 101 | 102 | // 时刻模板明细repository |
| 102 | 103 | @Autowired |
| 103 | 104 | private TTInfoDetailRepository ttInfoDetailRepository; |
| 104 | - | |
| 105 | + | |
| 105 | 106 | // 车辆配置信息repository |
| 106 | 107 | @Autowired |
| 107 | 108 | private CarConfigInfoRepository carConfigInfoRepository; |
| 108 | - | |
| 109 | + | |
| 109 | 110 | // 人员配置信息repository |
| 110 | 111 | @Autowired |
| 111 | 112 | private EmployeeConfigInfoRepository employeeConfigInfoRepository; |
| 112 | - | |
| 113 | + | |
| 113 | 114 | // 排班计划明细repository |
| 114 | 115 | @Autowired |
| 115 | 116 | private SchedulePlanInfoRepository schedulePlanInfoRepository; |
| 116 | - | |
| 117 | + | |
| 117 | 118 | // 实际排班计划明细repository |
| 118 | 119 | @Autowired |
| 119 | 120 | private ScheduleRealInfoRepository scheduleRealInfoRepository; |
| 120 | - | |
| 121 | + | |
| 121 | 122 | // 运管处接口 |
| 122 | 123 | private InternalPortType portType = new Internal().getInternalHttpSoap11Endpoint(); |
| 123 | 124 | private WebServiceSoap ssop ; |
| ... | ... | @@ -130,18 +131,18 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 130 | 131 | } |
| 131 | 132 | // 格式化 年月日时分秒 nyrsfm是年月日时分秒的拼音首字母 |
| 132 | 133 | private SimpleDateFormat sdfnyrsfm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| 133 | - | |
| 134 | + | |
| 134 | 135 | // 格式化 年月日 |
| 135 | 136 | private SimpleDateFormat sdfnyr = new SimpleDateFormat("yyyy-MM-dd"); |
| 136 | - | |
| 137 | + | |
| 137 | 138 | // 数字格式化 |
| 138 | 139 | DecimalFormat format = new DecimalFormat("0.00"); |
| 139 | - | |
| 140 | + | |
| 140 | 141 | // 用户名 |
| 141 | 142 | private final String userNameXl = "pudong"; |
| 142 | 143 | // 密码 |
| 143 | 144 | private final String passwordXl = "pudong123"; |
| 144 | - | |
| 145 | + | |
| 145 | 146 | // 用户名 |
| 146 | 147 | private final String userNameOther = "user"; |
| 147 | 148 | // 密码 |
| ... | ... | @@ -151,7 +152,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 151 | 152 | */ |
| 152 | 153 | @Override |
| 153 | 154 | public String setXL() { |
| 154 | - String result = "success"; | |
| 155 | + String result = "failure"; | |
| 155 | 156 | try { |
| 156 | 157 | StringBuffer sBuffer = new StringBuffer(); ; |
| 157 | 158 | Iterator<Line> lineIterator = lineRepository.findAll().iterator(); |
| ... | ... | @@ -162,6 +163,9 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 162 | 163 | sBuffer.append("<XLs>"); |
| 163 | 164 | while(lineIterator.hasNext()){ |
| 164 | 165 | line = lineIterator.next(); |
| 166 | + if(line.getLinePlayType() == null){ | |
| 167 | + continue; | |
| 168 | + } | |
| 165 | 169 | if(BasicData.lineId2ShangHaiCodeMap.get(line.getId()) == null){ |
| 166 | 170 | continue; |
| 167 | 171 | } |
| ... | ... | @@ -199,23 +203,37 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 199 | 203 | sBuffer.append("</XL>"); |
| 200 | 204 | } |
| 201 | 205 | sBuffer.append("</XLs>"); |
| 206 | + System.out.println(sBuffer.toString()); | |
| 202 | 207 | if(sBuffer.indexOf("<XL>") != -1){ |
| 203 | 208 | logger.info("setXL:"+sBuffer.toString()); |
| 204 | - portType.setXL(userNameXl, passwordXl, sBuffer.toString()); | |
| 209 | + String portResult = portType.setXL(userNameXl, passwordXl, sBuffer.toString()); | |
| 210 | + String portArray[] = portResult.split("\n"); | |
| 211 | + if(portArray.length >= 4){ | |
| 212 | + // 返回数据的编码 | |
| 213 | + String returnCode = portArray[1].substring(portArray[1].indexOf(">")+1,portArray[1].indexOf("</")); | |
| 214 | + // 返回的信息 | |
| 215 | + String returnDescription = portArray[2].substring(portArray[2].indexOf(">")+1,portArray[2].indexOf("</")); | |
| 216 | + if(returnCode.equals("1")){ | |
| 217 | + result = "success"; | |
| 218 | + }else{ | |
| 219 | + result = returnDescription; | |
| 220 | + } | |
| 221 | + } | |
| 205 | 222 | } |
| 206 | 223 | } catch (Exception e) { |
| 207 | 224 | e.printStackTrace(); |
| 225 | + }finally{ | |
| 226 | + logger.info("setXL:"+result); | |
| 208 | 227 | } |
| 209 | - | |
| 210 | 228 | return result; |
| 211 | 229 | } |
| 212 | - | |
| 230 | + | |
| 213 | 231 | /** |
| 214 | 232 | * 上传车辆信息 |
| 215 | 233 | */ |
| 216 | 234 | @Override |
| 217 | 235 | public String setCL() { |
| 218 | - String result = "success"; | |
| 236 | + String result = "failure"; | |
| 219 | 237 | try { |
| 220 | 238 | StringBuffer sBuffer =new StringBuffer(); |
| 221 | 239 | sBuffer.append("<CLs>"); |
| ... | ... | @@ -238,19 +256,23 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 238 | 256 | } |
| 239 | 257 | sBuffer.append("</CLs>"); |
| 240 | 258 | logger.info("setCL:"+sBuffer.toString()); |
| 241 | - ssop.setCL(userNameOther, passwordOther, sBuffer.toString()); | |
| 259 | + if(ssop.setCL(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ | |
| 260 | + result = "success"; | |
| 261 | + } | |
| 242 | 262 | } catch (Exception e) { |
| 243 | 263 | e.printStackTrace(); |
| 264 | + }finally{ | |
| 265 | + logger.info("setCL:"+result); | |
| 244 | 266 | } |
| 245 | 267 | return result; |
| 246 | 268 | } |
| 247 | - | |
| 269 | + | |
| 248 | 270 | /** |
| 249 | 271 | * 上传司机信息 |
| 250 | 272 | */ |
| 251 | 273 | @Override |
| 252 | 274 | public String setSJ() { |
| 253 | - String result = "success"; | |
| 275 | + String result = "failure"; | |
| 254 | 276 | try { |
| 255 | 277 | StringBuffer sBuffer =new StringBuffer(); |
| 256 | 278 | sBuffer.append("<SJs>"); |
| ... | ... | @@ -271,191 +293,274 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 271 | 293 | } |
| 272 | 294 | sBuffer.append("</SJs>"); |
| 273 | 295 | logger.info("setSJ:"+sBuffer.toString()); |
| 274 | - ssop.setSJ(userNameOther, passwordOther, sBuffer.toString()); | |
| 296 | + if(ssop.setSJ(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ | |
| 297 | + result = "success"; | |
| 298 | + }; | |
| 275 | 299 | } catch (Exception e) { |
| 276 | 300 | e.printStackTrace(); |
| 301 | + }finally{ | |
| 302 | + logger.info("setSJ:"+result); | |
| 277 | 303 | } |
| 278 | 304 | return result; |
| 279 | 305 | } |
| 280 | - | |
| 306 | + | |
| 281 | 307 | /** |
| 282 | - * 上传超速数据 | |
| 308 | + * 上传路单 | |
| 309 | + * @param date | |
| 310 | + * @return xml格式的字符串 | |
| 283 | 311 | */ |
| 284 | - @Override | |
| 285 | - public String setCS() { | |
| 286 | - String result = "success"; | |
| 287 | - StringBuffer sBuffer =new StringBuffer(); | |
| 288 | - sBuffer.append("<CSs>"); | |
| 289 | - String sql = "SELECT * FROM bsth_c_speeding where DATE_FORMAT(create_date,'%Y-%m-%d') = ? order by create_date "; | |
| 290 | - Connection conn = null; | |
| 291 | - PreparedStatement ps = null; | |
| 292 | - ResultSet rs = null; | |
| 312 | + public String setLD(){ | |
| 313 | + String result = "failure"; | |
| 293 | 314 | // 取昨天 的日期 |
| 294 | - String yesterday = sdfnyr.format(DateUtils.addDays(new Date(), -1)); | |
| 315 | + String date = sdfnyr.format(DateUtils.addDays(new Date(), -1)); | |
| 295 | 316 | try { |
| 296 | - conn = DBUtils_MS.getConnection(); | |
| 297 | - ps = conn.prepareStatement(sql); | |
| 298 | - ps.setString(1, yesterday); | |
| 299 | - rs = ps.executeQuery(); | |
| 300 | - Float lon, lat; | |
| 301 | - String kssk; | |
| 302 | - String speed; | |
| 303 | - while (rs.next()) { | |
| 304 | - kssk = sdfnyrsfm.format(rs.getLong("TIMESTAMP")); | |
| 305 | - speed = rs.getString("SPEED"); | |
| 306 | - // 经纬度 | |
| 307 | - lon = rs.getFloat("LON"); | |
| 308 | - lat = rs.getFloat("LAT"); | |
| 309 | - sBuffer.append("<CS>"); | |
| 310 | - sBuffer.append("<RQ>").append(sdfnyr.format(rs.getDate("CREATE_DATE"))).append("</RQ>"); | |
| 311 | - sBuffer.append("<XLBM>").append(BasicData.lineCode2ShangHaiCodeMap.get(rs.getString("LINE"))).append("</XLBM>");//////// | |
| 312 | - sBuffer.append("<CPH>").append(rs.getString("VEHICLE")).append("</CPH>"); | |
| 313 | - sBuffer.append("<KSSK>").append(kssk).append("</KSSK>"); | |
| 314 | - sBuffer.append("<KSDDJD>").append(lon).append("</KSDDJD>"); | |
| 315 | - sBuffer.append("<KSDDWD>").append(lat).append("</KSDDWD>"); | |
| 316 | - sBuffer.append("<KSLD>").append("").append("</KSLD>");//********************** | |
| 317 | - sBuffer.append("<JSSK>").append(kssk).append("</JSSK>"); | |
| 318 | - sBuffer.append("<JSDDJD>").append(lon).append("</JSDDJD>"); | |
| 319 | - sBuffer.append("<JSDDWD>").append(lat).append("</JSDDWD>"); | |
| 320 | - sBuffer.append("<JSLD>").append("").append("</JSLD>");//********************** | |
| 321 | - sBuffer.append("<PJSD>").append(speed).append("</PJSD>"); | |
| 322 | - sBuffer.append("<ZGSS>").append(speed).append("</ZGSS>"); | |
| 323 | - sBuffer.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>"); | |
| 324 | - sBuffer.append("</CS>"); | |
| 317 | + StringBuffer sf = new StringBuffer(); | |
| 318 | + sf.append("<DLDS>"); | |
| 319 | + List<ScheduleRealInfo> list = scheduleRealInfoRepository.setLD(date); | |
| 320 | + List<ScheduleRealInfo> listGroup = scheduleRealInfoRepository.setLDGroup(date); | |
| 321 | + Map<String,Object> map = new HashMap<String,Object>(); | |
| 322 | + for(ScheduleRealInfo schRealInfo:listGroup){ | |
| 323 | + if(schRealInfo != null){ | |
| 324 | + //根据车辆自编号查询车牌号 | |
| 325 | + map.put("insideCode_eq", schRealInfo.getClZbh()); | |
| 326 | + Cars car = carsRepository.findOne(new CustomerSpecs<Cars>(map)); | |
| 327 | + sf.append("<DLD>"); | |
| 328 | + sf.append("<RQ>"+schRealInfo.getScheduleDateStr()+"</RQ>"); | |
| 329 | + sf.append("<XLBM>"+BasicData.lineCode2ShangHaiCodeMap.get(schRealInfo.getXlBm())+"</XLBM>"); | |
| 330 | + sf.append("<LPBH>"+schRealInfo.getLpName()+"</LPBH>"); | |
| 331 | + sf.append("<CPH>"+car.getCarPlate()+"</CPH>"); | |
| 332 | + sf.append("<UPDT>"+sdfnyrsfm.format(schRealInfo.getUpdateDate())+"</UPDT>"); | |
| 333 | + sf.append("<LDList>"); | |
| 334 | + | |
| 335 | + int seqNumber = 0; | |
| 336 | + for(ScheduleRealInfo scheduleRealInfo:list){ | |
| 337 | + if(schRealInfo.getXlBm().equals(scheduleRealInfo.getXlBm()) && schRealInfo.getLpName().equals(scheduleRealInfo.getLpName()) | |
| 338 | + && schRealInfo.getClZbh().equals(scheduleRealInfo.getClZbh())){ | |
| 339 | + scheduleRealInfo.getQdzCode(); | |
| 340 | + sf.append("<LD>"); | |
| 341 | + sf.append("<SJGH>"+scheduleRealInfo.getjGh()+"</SJGH>"); | |
| 342 | + sf.append("<SXX>"+scheduleRealInfo.getXlDir()+"</SXX>"); | |
| 343 | + sf.append("<FCZDMC>"+scheduleRealInfo.getQdzName()+"</FCZDMC>"); | |
| 344 | + sf.append("<FCZDXH>" + ++seqNumber + "</FCZDXH>"); | |
| 345 | + sf.append("<FCZDBM>"+scheduleRealInfo.getQdzCode()+"</FCZDBM>"); | |
| 346 | + sf.append("<JHFCSJ>"+scheduleRealInfo.getFcsj()+"</JHFCSJ>"); | |
| 347 | + sf.append("<DFSJ>"+scheduleRealInfo.getDfsj()+"</DFSJ>"); | |
| 348 | + sf.append("<SJFCSJ>"+scheduleRealInfo.getFcsjActual()+"</SJFCSJ>"); | |
| 349 | + sf.append("<FCZDLX>"+""+"</FCZDLX>"); | |
| 350 | + sf.append("<DDZDMC>"+scheduleRealInfo.getZdzName()+"</DDZDMC>"); | |
| 351 | + sf.append("<DDZDXH>"+ seqNumber +"</DDZDXH>"); | |
| 352 | + sf.append("<DDZDBM>"+scheduleRealInfo.getZdzCode()+"</DDZDBM>"); | |
| 353 | + sf.append("<JHDDSJ>"+scheduleRealInfo.getZdsj()+"</JHDDSJ>"); | |
| 354 | + sf.append("<SJDDSJ>"+scheduleRealInfo.getZdsjActual()+"</SJDDSJ>"); | |
| 355 | + sf.append("<DDZDLX>"+""+"</DDZDLX>"); | |
| 356 | + sf.append("<LDSCBZ>"+0+"</LDSCBZ>"); | |
| 357 | + sf.append("<DDBZ>"+scheduleRealInfo.getRemarks()+"</DDBZ>"); | |
| 358 | + sf.append("</LD>"); | |
| 359 | + } | |
| 360 | + } | |
| 361 | + | |
| 362 | + sf.append("</LDList>"); | |
| 363 | + sf.append("</DLD>"); | |
| 364 | + } | |
| 365 | + } | |
| 366 | + | |
| 367 | + sf.append("</DLDS>"); | |
| 368 | + logger.info("setLD:"+sf.toString()); | |
| 369 | + if(ssop.setLD(userNameOther, passwordOther, sf.toString()).isSuccess()){ | |
| 370 | + result = "success"; | |
| 325 | 371 | } |
| 326 | - sBuffer.append("</CSs>"); | |
| 327 | - logger.info("setCS:"+sBuffer.toString()); | |
| 328 | - ssop.setCS(userNameOther, passwordOther, sBuffer.toString()); | |
| 329 | 372 | } catch (Exception e) { |
| 330 | 373 | e.printStackTrace(); |
| 331 | - } finally { | |
| 332 | - DBUtils_MS.close(rs, ps, conn); | |
| 374 | + }finally{ | |
| 375 | + logger.info("setLD:"+result); | |
| 333 | 376 | } |
| 334 | 377 | return result; |
| 335 | 378 | } |
| 336 | - | |
| 379 | + | |
| 337 | 380 | /** |
| 338 | - * 上传线路班次时刻表数据 | |
| 381 | + * 上传里程油耗 | |
| 382 | + * @param date | |
| 383 | + * @return | |
| 339 | 384 | */ |
| 340 | - @Override | |
| 341 | - public String setSKB(String ids) { | |
| 342 | - String result = "success"; | |
| 385 | + public String setLCYH(){ | |
| 386 | + String result = "failure"; | |
| 387 | + // 取昨天 的日期 | |
| 388 | + String date = sdfnyr.format(DateUtils.addDays(new Date(), -1)); | |
| 343 | 389 | try { |
| 344 | - String[] idArray = ids.split(","); | |
| 345 | - StringBuffer sBuffer = new StringBuffer(); | |
| 346 | - TTInfo ttInfo; | |
| 347 | - TTInfoDetail ttInfoDetail; | |
| 348 | - Iterator<TTInfoDetail> ttInfoDetailIterator; | |
| 349 | - HashMap<String,Object> param = new HashMap<String, Object>(); | |
| 350 | - String ttinfoJhlc = null;//计划总里程 | |
| 351 | - sBuffer.append("<SKBs>"); | |
| 352 | - for (int i = 0; i < idArray.length; i++) { | |
| 353 | - ttInfo = ttInfoRepository.findOne(Long.valueOf(idArray[i])); | |
| 354 | - param.put("ttinfo.id_eq", ttInfo.getId()); | |
| 355 | - ttInfoDetailIterator = ttInfoDetailRepository.findAll(new CustomerSpecs<TTInfoDetail>(param), | |
| 356 | - new Sort(Direction.ASC, "xlDir")).iterator(); | |
| 357 | - sBuffer.append("<SKB>"); | |
| 358 | - sBuffer.append("<XLBM>").append(BasicData.lineId2ShangHaiCodeMap.get(ttInfo.getXl())).append("</XLBM>"); | |
| 359 | - ttinfoJhlc = new String(); | |
| 360 | - sBuffer.append("<JHZLC>").append(ttinfoJhlc).append("</JHZLC>"); | |
| 361 | - sBuffer.append("<JHYYLC>").append(ttinfoJhlc).append("</JHYYLC>"); | |
| 362 | - sBuffer.append("<KSRQ>").append(sdfnyr.format(ttInfo.getQyrq())).append("</KSRQ>"); | |
| 363 | - sBuffer.append("<JSRQ>").append(sdfnyr.format(ttInfo.getQyrq())).append("</JSRQ>");///////// | |
| 364 | - sBuffer.append("<ZJZX>").append(changeRuleDay(ttInfo.getRule_days())).append("</ZJZX>"); | |
| 365 | - sBuffer.append("<TBYY>").append("").append("</TBYY>"); | |
| 366 | - sBuffer.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>"); | |
| 367 | - int num = 1; | |
| 368 | - while (ttInfoDetailIterator.hasNext()) { | |
| 369 | - ttInfoDetail = ttInfoDetailIterator.next(); | |
| 370 | - ttinfoJhlc = ttInfoDetail.getJhlc()+"";// 设置计划总里程 | |
| 371 | - sBuffer.append("<BCList>"); | |
| 372 | - sBuffer.append("<BC>"); | |
| 373 | - sBuffer.append("<LPBH>").append(ttInfoDetail.getLp().getLpNo()).append("</LPBH>"); | |
| 374 | - sBuffer.append("<SXX>").append(ttInfoDetail.getXlDir()).append("</SXX>"); | |
| 375 | - sBuffer.append("<FCZDMC>").append(ttInfoDetail.getQdz()).append("</FCZDMC>"); | |
| 376 | - sBuffer.append("<ZDXH>").append(num).append("</ZDXH>"); | |
| 377 | - sBuffer.append("<JHFCSJ>").append(ttInfoDetail.getFcsj()).append("</JHFCSJ>"); | |
| 378 | - sBuffer.append("<DDZDMC>").append(ttInfoDetail.getZdz()).append("</DDZDMC>"); | |
| 379 | - sBuffer.append("<ZDXH>").append(num).append("</ZDXH>"); | |
| 380 | - sBuffer.append("<JHDDSJ>").append(calcDdsj(ttInfoDetail.getFcsj(),ttInfoDetail.getBcsj())).append("</JHDDSJ>"); | |
| 381 | - sBuffer.append("</BC>"); | |
| 382 | - sBuffer.append("</BCList>"); | |
| 383 | - num++; | |
| 390 | + StringBuffer sf = new StringBuffer(); | |
| 391 | + sf.append("<LCYHS>"); | |
| 392 | + List<ScheduleRealInfo> listGroup = scheduleRealInfoRepository.setLCYHGroup(date); | |
| 393 | + List<ScheduleRealInfo> list = scheduleRealInfoRepository.findByDate(date); | |
| 394 | + Map<String,Object> map = new HashMap<String,Object>(); | |
| 395 | + for(ScheduleRealInfo schRealInfo:listGroup){ | |
| 396 | + if(schRealInfo != null){ | |
| 397 | + //计算总公里和空驶公里,营运公里=总公里-空驶公里 | |
| 398 | + double totalKilometers = 0,emptyKilometers =0; | |
| 399 | + sf.append("<LCYH>"); | |
| 400 | + map.put("insideCode_eq", schRealInfo.getClZbh()); | |
| 401 | + Cars car = carsRepository.findOne(new CustomerSpecs<Cars>(map)); | |
| 402 | +// Cars car = carsRepository.findCarByClzbh(schRealInfo.getClZbh()); | |
| 403 | + sf.append("<RQ>"+schRealInfo.getScheduleDateStr()+"</RQ>"); | |
| 404 | + sf.append("<XLBM>"+BasicData.lineCode2ShangHaiCodeMap.get(schRealInfo.getXlBm())+"</XLBM>"); | |
| 405 | + sf.append("<CPH>"+car.getCarPlate()+"</CPH>"); | |
| 406 | + for(ScheduleRealInfo scheduleRealInfo:list){ | |
| 407 | + if(schRealInfo.getXlBm().equals(scheduleRealInfo.getXlBm()) && schRealInfo.getClZbh().equals(scheduleRealInfo.getClZbh())){ | |
| 408 | + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | |
| 409 | + //如果没有子任务,里程就是已执行(Status=2);有子任务的,忽略主任务,子任务的烂班 | |
| 410 | + if(childTaskPlans.isEmpty()){ | |
| 411 | + if(scheduleRealInfo.getStatus() == 2){ | |
| 412 | + totalKilometers += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc(); | |
| 413 | + if(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out") | |
| 414 | + || scheduleRealInfo.getBcType().equals("venting")){ | |
| 415 | + emptyKilometers += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc();; | |
| 416 | + } | |
| 417 | + } | |
| 418 | + }else{ | |
| 419 | + Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 420 | + while(it.hasNext()){ | |
| 421 | + ChildTaskPlan childTaskPlan = it.next(); | |
| 422 | + if(!childTaskPlan.isDestroy()){ | |
| 423 | + totalKilometers += childTaskPlan.getMileage()==null?0.0:childTaskPlan.getMileage(); | |
| 424 | + if(childTaskPlan.getMileageType().equals("empty")){ | |
| 425 | + emptyKilometers += childTaskPlan.getMileage()==null?0.0:childTaskPlan.getMileage();; | |
| 426 | + } | |
| 427 | + } | |
| 428 | + } | |
| 429 | + } | |
| 430 | + } | |
| 431 | + } | |
| 432 | + sf.append("<ZLC>"+totalKilometers+"</ZLC>"); | |
| 433 | + sf.append("<YYLC>"+emptyKilometers+"</YYLC>"); | |
| 434 | + sf.append("<YH>"+""+"</YH>"); | |
| 435 | + sf.append("<JZYL>"+""+"</JZYL>"); | |
| 436 | + sf.append("<DH>"+""+"</DH>"); | |
| 437 | + sf.append("<UPDT>"+sdfnyrsfm.format(schRealInfo.getUpdateDate())+"</UPDT>"); | |
| 438 | + sf.append("<BBSCBZ>"+0+"</BBSCBZ>"); | |
| 439 | + sf.append("</LCYH>"); | |
| 384 | 440 | } |
| 385 | - sBuffer.append("</SKB>"); | |
| 386 | 441 | } |
| 387 | - sBuffer.append("</SKBs>"); | |
| 388 | - logger.info("setSKB:"+sBuffer.toString()); | |
| 389 | - ssop.setSKB(userNameOther, passwordOther, sBuffer.toString()); | |
| 442 | + sf.append("</LCYHS>"); | |
| 443 | + logger.info("setLCYH:"+sf.toString()); | |
| 444 | + if(ssop.setLCYH(userNameOther, passwordOther, sf.toString()).isSuccess()){ | |
| 445 | + result = "success"; | |
| 446 | + } | |
| 390 | 447 | } catch (Exception e) { |
| 391 | 448 | e.printStackTrace(); |
| 449 | + }finally{ | |
| 450 | + logger.info("setLCYH:"+result); | |
| 392 | 451 | } |
| 393 | 452 | return result; |
| 394 | 453 | } |
| 395 | - | |
| 454 | + | |
| 396 | 455 | /** |
| 397 | - * 上传线路人员车辆配置信息 | |
| 456 | + * 上传线路调度日报 | |
| 457 | + * @return | |
| 398 | 458 | */ |
| 399 | - @Override | |
| 400 | - public String setXLPC() { | |
| 401 | - String result = "success"; | |
| 459 | + public String setDDRB(){ | |
| 460 | + String result = "failure"; | |
| 461 | + // 取昨天 的日期 | |
| 462 | + String date = sdfnyr.format(DateUtils.addDays(new Date(), -1)); | |
| 402 | 463 | try { |
| 403 | - StringBuffer sBuffer =new StringBuffer(); | |
| 404 | - sBuffer.append("<XLPCs>"); | |
| 405 | - // 声明变量 | |
| 406 | - Line line = null; | |
| 407 | - Cars cars = null; | |
| 408 | - List<Personnel> personnelList = null; | |
| 409 | - List<Cars> carsList = null; | |
| 410 | - int totalPersonnel,totalCar ;// 人员数量。车辆数量 | |
| 411 | - // 查询所有线路 | |
| 412 | - Iterator<Line> lineIterator = lineRepository.findAll().iterator(); | |
| 413 | - // 循环查找线路下的信息 | |
| 414 | - while(lineIterator.hasNext()){ | |
| 415 | - line = lineIterator.next(); | |
| 416 | - sBuffer.append("<XLPC>"); | |
| 417 | - sBuffer.append("<XLBM>").append(BasicData.lineId2ShangHaiCodeMap.get(line.getId())).append("</XLBM>"); | |
| 418 | - // 查询驾驶员数量 | |
| 419 | - personnelList = personnelRepository.findJsysByLineId(line.getId()); | |
| 420 | - totalPersonnel = personnelList != null ? personnelList.size():0; | |
| 421 | - sBuffer.append("<SJRS>").append(totalPersonnel).append("</SJRS>"); | |
| 422 | - // 查询售票员人员数量 | |
| 423 | - personnelList = personnelRepository.findSpysByLineId(line.getId()); | |
| 424 | - totalPersonnel = personnelList != null ? personnelList.size():0; | |
| 425 | - sBuffer.append("<SPYRS>").append(totalPersonnel).append("</SPYRS>"); | |
| 426 | - // 查询车辆 | |
| 427 | - carsList = carsRepository.findCarsByLineId(line.getId()); | |
| 428 | - totalCar = carsList != null ? carsList.size():0; | |
| 429 | - sBuffer.append("<PCSL>").append(totalCar).append("</PCSL>"); | |
| 430 | - sBuffer.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>"); | |
| 431 | - int carsNum = 0; | |
| 432 | - // 取车牌号 | |
| 433 | - if(carsList != null){ | |
| 434 | - carsNum = carsList.size(); | |
| 435 | - sBuffer.append("<CPHList>"); | |
| 436 | - for (int i = 0; i < carsNum; i++) { | |
| 437 | - cars = carsList.get(i); | |
| 438 | - sBuffer.append("<CPH>").append("沪").append(cars.getCarCode()).append("</CPH>"); | |
| 464 | + StringBuffer sf = new StringBuffer(); | |
| 465 | + sf.append("<DDRBS>"); | |
| 466 | + List<ScheduleRealInfo> listGroup = scheduleRealInfoRepository.setDDRBGroup(date); | |
| 467 | + List<ScheduleRealInfo> list = scheduleRealInfoRepository.findByDate(date); | |
| 468 | + for(ScheduleRealInfo schRealInfo:listGroup){ | |
| 469 | + if(schRealInfo != null){ | |
| 470 | + double jhlc = 0,zlc = 0,jhkslc = 0,sjkslc = 0; | |
| 471 | + int jhbc = 0,sjbc = 0,jhzgfbc = 0,sjzgfbc = 0,jhwgfbc = 0,sjwgfbc = 0; | |
| 472 | + sf.append("<DDRB>"); | |
| 473 | + sf.append("<RQ>"+schRealInfo.getScheduleDateStr()+"</RQ>"); | |
| 474 | + sf.append("<XLBM>"+BasicData.lineCode2ShangHaiCodeMap.get(schRealInfo.getXlBm())+"</XLBM>"); | |
| 475 | + for(ScheduleRealInfo scheduleRealInfo:list){ | |
| 476 | + if(scheduleRealInfo != null){ | |
| 477 | + if(scheduleRealInfo.getXlBm().equals(scheduleRealInfo.getXlBm())){ | |
| 478 | + //计划 | |
| 479 | + if(!scheduleRealInfo.isSflj()){ | |
| 480 | + jhlc += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc(); | |
| 481 | + //计划空驶 | |
| 482 | + if(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out")){ | |
| 483 | + jhkslc += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc(); | |
| 484 | + } | |
| 485 | + //计划早高峰,计划晚高峰 | |
| 486 | + if(TimeUtils.morningPeak(scheduleRealInfo.getFcsj())){ | |
| 487 | + jhzgfbc++; | |
| 488 | + } else if(TimeUtils.evenignPeak(scheduleRealInfo.getFcsj())){ | |
| 489 | + jhwgfbc++; | |
| 490 | + } | |
| 491 | + } | |
| 492 | + jhbc++; | |
| 493 | + | |
| 494 | + //实际 | |
| 495 | + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | |
| 496 | + //如果没有子任务,里程就是已执行(Status=2);有子任务的,忽略主任务,子任务的烂班 | |
| 497 | + if(childTaskPlans.isEmpty()){ | |
| 498 | + if(scheduleRealInfo.getStatus() == 2){ | |
| 499 | + sjbc++; | |
| 500 | + zlc += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc(); | |
| 501 | + if(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out") | |
| 502 | + || scheduleRealInfo.getBcType().equals("venting")){ | |
| 503 | + sjkslc += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc();; | |
| 504 | + } | |
| 505 | + } | |
| 506 | + }else{ | |
| 507 | + sjbc++; | |
| 508 | + Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 509 | + while(it.hasNext()){ | |
| 510 | + ChildTaskPlan childTaskPlan = it.next(); | |
| 511 | + if(!childTaskPlan.isDestroy()){ | |
| 512 | + zlc += childTaskPlan.getMileage()==null?0.0:childTaskPlan.getMileage(); | |
| 513 | + if(childTaskPlan.getMileageType().equals("empty")){ | |
| 514 | + sjkslc += childTaskPlan.getMileage()==null?0.0:childTaskPlan.getMileage();; | |
| 515 | + } | |
| 516 | + } | |
| 517 | + } | |
| 518 | + } | |
| 519 | + //实际早高峰,计划晚高峰 | |
| 520 | + if(scheduleRealInfo.getFcsjActual() != null){ | |
| 521 | + if(TimeUtils.morningPeak(scheduleRealInfo.getFcsj())){ | |
| 522 | + sjzgfbc++; | |
| 523 | + } else if(TimeUtils.evenignPeak(scheduleRealInfo.getFcsj())){ | |
| 524 | + sjwgfbc++; | |
| 525 | + } | |
| 526 | + } | |
| 527 | + } | |
| 528 | + } | |
| 439 | 529 | } |
| 440 | - sBuffer.append("</CPHList>"); | |
| 530 | + sf.append("<JHLC>"+format.format(jhlc)+"</JHLC>"); | |
| 531 | + sf.append("<SSLC>"+format.format((zlc-sjkslc))+"</SSLC>"); | |
| 532 | + sf.append("<JHKSLC>"+format.format(jhkslc)+"</JHKSLC>"); | |
| 533 | + sf.append("<SJKSLC>"+format.format(sjkslc)+"</SJKSLC>"); | |
| 534 | + sf.append("<JHBC>"+jhbc+"</JHBC>"); | |
| 535 | + sf.append("<SJBC>"+sjbc+"</SJBC>"); | |
| 536 | + sf.append("<JHZGFBC>"+jhzgfbc+"</JHZGFBC>"); | |
| 537 | + sf.append("<SJZGFBC>"+sjzgfbc+"</SJZGFBC>"); | |
| 538 | + sf.append("<JHWGFBC>"+jhwgfbc+"</JHWGFBC>"); | |
| 539 | + sf.append("<SJWGFBC>"+sjwgfbc+"</SJWGFBC>"); | |
| 540 | + sf.append("<UPDT>"+sdfnyrsfm.format(schRealInfo.getUpdateDate())+"</UPDT>"); | |
| 541 | + sf.append("<RBSCBZ>"+0+"</RBSCBZ>"); | |
| 542 | + sf.append("</DDRB>"); | |
| 441 | 543 | } |
| 442 | - sBuffer.append("</XLPC>"); | |
| 443 | 544 | } |
| 444 | - sBuffer.append("</XLPCs>"); | |
| 445 | - logger.info("setXLPC:"+sBuffer.toString()); | |
| 446 | - ssop.setXLPC(userNameOther, passwordOther, sBuffer.toString()); | |
| 545 | + sf.append("</DDRBS>"); | |
| 546 | + logger.info("setDDRB:"+sf.toString()); | |
| 547 | + if(ssop.setDDRB(userNameOther, passwordOther, sf.toString()).isSuccess()){ | |
| 548 | + result = "success"; | |
| 549 | + } | |
| 447 | 550 | } catch (Exception e) { |
| 448 | 551 | e.printStackTrace(); |
| 552 | + }finally{ | |
| 553 | + logger.info("setDDRB:"+result); | |
| 449 | 554 | } |
| 450 | 555 | return result; |
| 451 | 556 | } |
| 452 | - | |
| 557 | + | |
| 453 | 558 | /** |
| 454 | 559 | * 上传线路计划班次表 |
| 455 | 560 | */ |
| 456 | 561 | @Override |
| 457 | 562 | public String setJHBC() { |
| 458 | - String result = "success"; | |
| 563 | + String result = "failure"; | |
| 459 | 564 | try { |
| 460 | 565 | StringBuffer sBuffer =new StringBuffer(); |
| 461 | 566 | sBuffer.append("<JHBCs>"); |
| ... | ... | @@ -492,7 +597,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 492 | 597 | sBuffer.append("<DDZDMC>").append(schedulePlanInfo.getZdzName()).append("</DDZDMC>"); |
| 493 | 598 | sBuffer.append("<ZDXH>").append(++endSerialNum).append("</ZDXH>"); |
| 494 | 599 | sBuffer.append("<JHDDSJ>").append(calcDdsj(schedulePlanInfo.getFcsj(),schedulePlanInfo.getBcsj())) |
| 495 | - .append("</JHDDSJ>"); | |
| 600 | + .append("</JHDDSJ>"); | |
| 496 | 601 | sBuffer.append("</BC>"); |
| 497 | 602 | if(i == size -1 ){ |
| 498 | 603 | sBuffer.append("</BCList>"); |
| ... | ... | @@ -513,249 +618,286 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 513 | 618 | } |
| 514 | 619 | sBuffer.append("</JHBCs>"); |
| 515 | 620 | logger.info("setJHBC:"+sBuffer.toString()); |
| 516 | - ssop.setJHBC(userNameOther, passwordOther, sBuffer.toString()); | |
| 621 | + if(ssop.setJHBC(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ | |
| 622 | + result = "success"; | |
| 623 | + } | |
| 517 | 624 | } catch (Exception e) { |
| 518 | 625 | e.printStackTrace(); |
| 626 | + }finally{ | |
| 627 | + logger.info("setJHBC:"+result); | |
| 519 | 628 | } |
| 520 | 629 | return result; |
| 521 | 630 | } |
| 522 | - | |
| 631 | + | |
| 523 | 632 | /** |
| 524 | - * 上传路单 | |
| 525 | - * @param date | |
| 526 | - * @return xml格式的字符串 | |
| 633 | + * 上传线路班次时刻表数据 | |
| 527 | 634 | */ |
| 528 | - public String setLD(){ | |
| 529 | - // 取昨天 的日期 | |
| 530 | - String date = sdfnyr.format(DateUtils.addDays(new Date(), -1)); | |
| 635 | + @Override | |
| 636 | + public String setSKB(String ids) { | |
| 637 | + String result = "failure"; | |
| 531 | 638 | try { |
| 532 | - StringBuffer sf = new StringBuffer(); | |
| 533 | - sf.append("<DLDS>"); | |
| 534 | - List<ScheduleRealInfo> list = scheduleRealInfoRepository.setLD(date); | |
| 535 | - List<ScheduleRealInfo> listGroup = scheduleRealInfoRepository.setLDGroup(date); | |
| 536 | - Map<String,Object> map = new HashMap<String,Object>(); | |
| 537 | - for(ScheduleRealInfo schRealInfo:listGroup){ | |
| 538 | - if(schRealInfo != null){ | |
| 539 | - //根据车辆自编号查询车牌号 | |
| 540 | - map.put("insideCode_eq", schRealInfo.getClZbh()); | |
| 541 | - Cars car = carsRepository.findOne(new CustomerSpecs<Cars>(map)); | |
| 542 | - sf.append("<DLD>"); | |
| 543 | - sf.append("<RQ>"+schRealInfo.getScheduleDateStr()+"</RQ>"); | |
| 544 | - sf.append("<XLBM>"+schRealInfo.getXlBm()+"</XLBM>"); | |
| 545 | - sf.append("<LPBH>"+schRealInfo.getLpName()+"</LPBH>"); | |
| 546 | - sf.append("<CPH>"+car.getCarPlate()+"</CPH>"); | |
| 547 | - sf.append("<UPDT>"+sdfnyrsfm.format(schRealInfo.getUpdateDate())+"</UPDT>"); | |
| 548 | - sf.append("<LDList>"); | |
| 549 | - | |
| 550 | - int seqNumber = 0; | |
| 551 | - for(ScheduleRealInfo scheduleRealInfo:list){ | |
| 552 | - if(schRealInfo.getXlBm().equals(scheduleRealInfo.getXlBm()) && schRealInfo.getLpName().equals(scheduleRealInfo.getLpName()) | |
| 553 | - && schRealInfo.getClZbh().equals(scheduleRealInfo.getClZbh())){ | |
| 554 | - scheduleRealInfo.getQdzCode(); | |
| 555 | - sf.append("<LD>"); | |
| 556 | - sf.append("<SJGH>"+scheduleRealInfo.getjGh()+"</SJGH>"); | |
| 557 | - sf.append("<SXX>"+scheduleRealInfo.getXlDir()+"</SXX>"); | |
| 558 | - sf.append("<FCZDMC>"+scheduleRealInfo.getQdzName()+"</FCZDMC>"); | |
| 559 | - sf.append("<FCZDXH>" + ++seqNumber + "</FCZDXH>"); | |
| 560 | - sf.append("<FCZDBM>"+scheduleRealInfo.getQdzCode()+"</FCZDBM>"); | |
| 561 | - sf.append("<JHFCSJ>"+scheduleRealInfo.getFcsj()+"</JHFCSJ>"); | |
| 562 | - sf.append("<DFSJ>"+scheduleRealInfo.getDfsj()+"</DFSJ>"); | |
| 563 | - sf.append("<SJFCSJ>"+scheduleRealInfo.getFcsjActual()+"</SJFCSJ>"); | |
| 564 | - sf.append("<FCZDLX>"+""+"</FCZDLX>"); | |
| 565 | - sf.append("<DDZDMC>"+scheduleRealInfo.getZdzName()+"</DDZDMC>"); | |
| 566 | - sf.append("<DDZDXH>"+ seqNumber +"</DDZDXH>"); | |
| 567 | - sf.append("<DDZDBM>"+scheduleRealInfo.getZdzCode()+"</DDZDBM>"); | |
| 568 | - sf.append("<JHDDSJ>"+scheduleRealInfo.getZdsj()+"</JHDDSJ>"); | |
| 569 | - sf.append("<SJDDSJ>"+scheduleRealInfo.getZdsjActual()+"</SJDDSJ>"); | |
| 570 | - sf.append("<DDZDLX>"+""+"</DDZDLX>"); | |
| 571 | - sf.append("<LDSCBZ>"+0+"</LDSCBZ>"); | |
| 572 | - sf.append("<DDBZ>"+scheduleRealInfo.getRemarks()+"</DDBZ>"); | |
| 573 | - sf.append("</LD>"); | |
| 574 | - } | |
| 575 | - } | |
| 576 | - | |
| 577 | - sf.append("</LDList>"); | |
| 578 | - sf.append("</DLD>"); | |
| 639 | + String[] idArray = ids.split(","); | |
| 640 | + StringBuffer sBuffer = new StringBuffer(); | |
| 641 | + TTInfo ttInfo; | |
| 642 | + TTInfoDetail ttInfoDetail; | |
| 643 | + Iterator<TTInfoDetail> ttInfoDetailIterator; | |
| 644 | + HashMap<String,Object> param = new HashMap<String, Object>(); | |
| 645 | + String ttinfoJhlc = null;//计划总里程 | |
| 646 | + sBuffer.append("<SKBs>"); | |
| 647 | + for (int i = 0; i < idArray.length; i++) { | |
| 648 | + ttInfo = ttInfoRepository.findOne(Long.valueOf(idArray[i])); | |
| 649 | + if(ttInfo == null) | |
| 650 | + continue; | |
| 651 | + param.put("ttinfo.id_eq", ttInfo.getId()); | |
| 652 | + ttInfoDetailIterator = ttInfoDetailRepository.findAll(new CustomerSpecs<TTInfoDetail>(param), | |
| 653 | + new Sort(Direction.ASC, "xlDir")).iterator(); | |
| 654 | + sBuffer.append("<SKB>"); | |
| 655 | + sBuffer.append("<XLBM>").append(BasicData.lineId2ShangHaiCodeMap.get(ttInfo.getXl())).append("</XLBM>"); | |
| 656 | + ttinfoJhlc = new String(); | |
| 657 | + sBuffer.append("<JHZLC>").append(ttinfoJhlc).append("</JHZLC>"); | |
| 658 | + sBuffer.append("<JHYYLC>").append(ttinfoJhlc).append("</JHYYLC>"); | |
| 659 | + sBuffer.append("<KSRQ>").append(sdfnyr.format(ttInfo.getQyrq())).append("</KSRQ>"); | |
| 660 | + sBuffer.append("<JSRQ>").append(sdfnyr.format(ttInfo.getQyrq())).append("</JSRQ>");///////// | |
| 661 | + sBuffer.append("<ZJZX>").append(changeRuleDay(ttInfo.getRule_days())).append("</ZJZX>"); | |
| 662 | + sBuffer.append("<TBYY>").append("").append("</TBYY>"); | |
| 663 | + sBuffer.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>"); | |
| 664 | + int num = 1; | |
| 665 | + while (ttInfoDetailIterator.hasNext()) { | |
| 666 | + ttInfoDetail = ttInfoDetailIterator.next(); | |
| 667 | + ttinfoJhlc = ttInfoDetail.getJhlc()+"";// 设置计划总里程 | |
| 668 | + sBuffer.append("<BCList>"); | |
| 669 | + sBuffer.append("<BC>"); | |
| 670 | + sBuffer.append("<LPBH>").append(ttInfoDetail.getLp().getLpNo()).append("</LPBH>"); | |
| 671 | + sBuffer.append("<SXX>").append(ttInfoDetail.getXlDir()).append("</SXX>"); | |
| 672 | + sBuffer.append("<FCZDMC>").append(ttInfoDetail.getQdz()).append("</FCZDMC>"); | |
| 673 | + sBuffer.append("<ZDXH>").append(num).append("</ZDXH>"); | |
| 674 | + sBuffer.append("<JHFCSJ>").append(ttInfoDetail.getFcsj()).append("</JHFCSJ>"); | |
| 675 | + sBuffer.append("<DDZDMC>").append(ttInfoDetail.getZdz()).append("</DDZDMC>"); | |
| 676 | + sBuffer.append("<ZDXH>").append(num).append("</ZDXH>"); | |
| 677 | + sBuffer.append("<JHDDSJ>").append(calcDdsj(ttInfoDetail.getFcsj(),ttInfoDetail.getBcsj())).append("</JHDDSJ>"); | |
| 678 | + sBuffer.append("</BC>"); | |
| 679 | + sBuffer.append("</BCList>"); | |
| 680 | + num++; | |
| 579 | 681 | } |
| 682 | + sBuffer.append("</SKB>"); | |
| 683 | + } | |
| 684 | + sBuffer.append("</SKBs>"); | |
| 685 | + logger.info("setSKB:"+sBuffer.toString()); | |
| 686 | + if(ssop.setSKB(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ | |
| 687 | + result = "success"; | |
| 580 | 688 | } |
| 581 | - | |
| 582 | - sf.append("</DLDS>"); | |
| 583 | - logger.info("setLD:"+sf.toString()); | |
| 584 | - ssop.setLD(userNameOther, passwordOther, sf.toString()); | |
| 585 | 689 | } catch (Exception e) { |
| 586 | 690 | e.printStackTrace(); |
| 691 | + }finally{ | |
| 692 | + logger.info("setSKB:"+result); | |
| 587 | 693 | } |
| 588 | - return ""; | |
| 694 | + return result; | |
| 589 | 695 | } |
| 590 | - | |
| 696 | + | |
| 591 | 697 | /** |
| 592 | - * 上传里程油耗 | |
| 593 | - * @param date | |
| 594 | - * @return | |
| 698 | + * 上传线路人员车辆配置信息 | |
| 595 | 699 | */ |
| 596 | - public String setLCYH(){ | |
| 597 | - // 取昨天 的日期 | |
| 598 | - String date = sdfnyr.format(DateUtils.addDays(new Date(), -1)); | |
| 700 | + @Override | |
| 701 | + public String setXLPC() { | |
| 702 | + String result = "failure"; | |
| 599 | 703 | try { |
| 600 | - StringBuffer sf = new StringBuffer(); | |
| 601 | - sf.append("<LCYHS>"); | |
| 602 | - List<ScheduleRealInfo> listGroup = scheduleRealInfoRepository.setLCYHGroup(date); | |
| 603 | - List<ScheduleRealInfo> list = scheduleRealInfoRepository.findByDate(date); | |
| 604 | - Map<String,Object> map = new HashMap<String,Object>(); | |
| 605 | - for(ScheduleRealInfo schRealInfo:listGroup){ | |
| 606 | - if(schRealInfo != null){ | |
| 607 | - //计算总公里和空驶公里,营运公里=总公里-空驶公里 | |
| 608 | - double totalKilometers = 0,emptyKilometers =0; | |
| 609 | - sf.append("<LCYH>"); | |
| 610 | - map.put("insideCode_eq", schRealInfo.getClZbh()); | |
| 611 | - Cars car = carsRepository.findOne(new CustomerSpecs<Cars>(map)); | |
| 612 | -// Cars car = carsRepository.findCarByClzbh(schRealInfo.getClZbh()); | |
| 613 | - sf.append("<RQ>"+schRealInfo.getScheduleDateStr()+"</RQ>"); | |
| 614 | - sf.append("<XLBM>"+schRealInfo.getXlBm()+"</XLBM>"); | |
| 615 | - sf.append("<CPH>"+car.getCarPlate()+"</CPH>"); | |
| 616 | - for(ScheduleRealInfo scheduleRealInfo:list){ | |
| 617 | - if(schRealInfo.getXlBm().equals(scheduleRealInfo.getXlBm()) && schRealInfo.getClZbh().equals(scheduleRealInfo.getClZbh())){ | |
| 618 | - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | |
| 619 | - //如果没有子任务,里程就是已执行(Status=2);有子任务的,忽略主任务,子任务的烂班 | |
| 620 | - if(childTaskPlans.isEmpty()){ | |
| 621 | - if(scheduleRealInfo.getStatus() == 2){ | |
| 622 | - totalKilometers += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc(); | |
| 623 | - if(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out") | |
| 624 | - || scheduleRealInfo.getBcType().equals("venting")){ | |
| 625 | - emptyKilometers += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc();; | |
| 626 | - } | |
| 627 | - } | |
| 628 | - }else{ | |
| 629 | - Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 630 | - while(it.hasNext()){ | |
| 631 | - ChildTaskPlan childTaskPlan = it.next(); | |
| 632 | - if(!childTaskPlan.isDestroy()){ | |
| 633 | - totalKilometers += childTaskPlan.getMileage()==null?0.0:childTaskPlan.getMileage(); | |
| 634 | - if(childTaskPlan.getMileageType().equals("empty")){ | |
| 635 | - emptyKilometers += childTaskPlan.getMileage()==null?0.0:childTaskPlan.getMileage();; | |
| 636 | - } | |
| 637 | - } | |
| 638 | - } | |
| 639 | - } | |
| 640 | - } | |
| 704 | + StringBuffer sBuffer =new StringBuffer(); | |
| 705 | + sBuffer.append("<XLPCs>"); | |
| 706 | + // 声明变量 | |
| 707 | + Line line = null; | |
| 708 | + Cars cars = null; | |
| 709 | + List<Personnel> personnelList = null; | |
| 710 | + List<Cars> carsList = null; | |
| 711 | + int totalPersonnel,totalCar ;// 人员数量。车辆数量 | |
| 712 | + // 查询所有线路 | |
| 713 | + Iterator<Line> lineIterator = lineRepository.findAll().iterator(); | |
| 714 | + // 循环查找线路下的信息 | |
| 715 | + while(lineIterator.hasNext()){ | |
| 716 | + line = lineIterator.next(); | |
| 717 | + sBuffer.append("<XLPC>"); | |
| 718 | + sBuffer.append("<XLBM>").append(BasicData.lineId2ShangHaiCodeMap.get(line.getId())).append("</XLBM>"); | |
| 719 | + // 查询驾驶员数量 | |
| 720 | + personnelList = personnelRepository.findJsysByLineId(line.getId()); | |
| 721 | + totalPersonnel = personnelList != null ? personnelList.size():0; | |
| 722 | + sBuffer.append("<SJRS>").append(totalPersonnel).append("</SJRS>"); | |
| 723 | + // 查询售票员人员数量 | |
| 724 | + personnelList = personnelRepository.findSpysByLineId(line.getId()); | |
| 725 | + totalPersonnel = personnelList != null ? personnelList.size():0; | |
| 726 | + sBuffer.append("<SPYRS>").append(totalPersonnel).append("</SPYRS>"); | |
| 727 | + // 查询车辆 | |
| 728 | + carsList = carsRepository.findCarsByLineId(line.getId()); | |
| 729 | + totalCar = carsList != null ? carsList.size():0; | |
| 730 | + sBuffer.append("<PCSL>").append(totalCar).append("</PCSL>"); | |
| 731 | + sBuffer.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>"); | |
| 732 | + int carsNum = 0; | |
| 733 | + // 取车牌号 | |
| 734 | + if(carsList != null){ | |
| 735 | + carsNum = carsList.size(); | |
| 736 | + sBuffer.append("<CPHList>"); | |
| 737 | + for (int i = 0; i < carsNum; i++) { | |
| 738 | + cars = carsList.get(i); | |
| 739 | + sBuffer.append("<CPH>").append("沪").append(cars.getCarCode()).append("</CPH>"); | |
| 641 | 740 | } |
| 642 | - sf.append("<ZLC>"+totalKilometers+"</ZLC>"); | |
| 643 | - sf.append("<YYLC>"+emptyKilometers+"</YYLC>"); | |
| 644 | - sf.append("<YH>"+""+"</YH>"); | |
| 645 | - sf.append("<JZYL>"+""+"</JZYL>"); | |
| 646 | - sf.append("<DH>"+""+"</DH>"); | |
| 647 | - sf.append("<UPDT>"+sdfnyrsfm.format(schRealInfo.getUpdateDate())+"</UPDT>"); | |
| 648 | - sf.append("<BBSCBZ>"+0+"</BBSCBZ>"); | |
| 649 | - sf.append("</LCYH>"); | |
| 650 | - } | |
| 741 | + sBuffer.append("</CPHList>"); | |
| 742 | + } | |
| 743 | + sBuffer.append("</XLPC>"); | |
| 744 | + } | |
| 745 | + sBuffer.append("</XLPCs>"); | |
| 746 | + logger.info("setXLPC:"+sBuffer.toString()); | |
| 747 | + if(ssop.setXLPC(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ | |
| 748 | + result = "success"; | |
| 651 | 749 | } |
| 652 | - sf.append("</LCYHS>"); | |
| 653 | - logger.info("setLCYH:"+sf.toString()); | |
| 654 | - ssop.setLCYH(userNameOther, passwordOther, sf.toString()); | |
| 655 | 750 | } catch (Exception e) { |
| 656 | 751 | e.printStackTrace(); |
| 752 | + }finally{ | |
| 753 | + logger.info("setXLPC:"+result); | |
| 657 | 754 | } |
| 658 | - return date; | |
| 755 | + return result; | |
| 659 | 756 | } |
| 660 | - | |
| 757 | + | |
| 758 | + | |
| 661 | 759 | /** |
| 662 | - * 上传线路调度日报 | |
| 663 | - * @return | |
| 760 | + * 上传超速数据 | |
| 664 | 761 | */ |
| 665 | - public String setDDRB(){ | |
| 762 | + @Override | |
| 763 | + public String setCS() { | |
| 764 | + String result = "failure"; | |
| 765 | + StringBuffer sBuffer =new StringBuffer(); | |
| 766 | + sBuffer.append("<CSs>"); | |
| 767 | + String sql = "SELECT * FROM bsth_c_speeding where DATE_FORMAT(create_date,'%Y-%m-%d') = ? order by create_date "; | |
| 768 | + Connection conn = null; | |
| 769 | + PreparedStatement ps = null; | |
| 770 | + ResultSet rs = null; | |
| 666 | 771 | // 取昨天 的日期 |
| 667 | - String date = sdfnyr.format(DateUtils.addDays(new Date(), -1)); | |
| 772 | + String yesterday = sdfnyr.format(DateUtils.addDays(new Date(), -1)); | |
| 668 | 773 | try { |
| 669 | - StringBuffer sf = new StringBuffer(); | |
| 670 | - sf.append("<DDRBS>"); | |
| 671 | - List<ScheduleRealInfo> listGroup = scheduleRealInfoRepository.setDDRBGroup(date); | |
| 672 | - List<ScheduleRealInfo> list = scheduleRealInfoRepository.findByDate(date); | |
| 673 | - for(ScheduleRealInfo schRealInfo:listGroup){ | |
| 674 | - if(schRealInfo != null){ | |
| 675 | - double jhlc = 0,zlc = 0,jhkslc = 0,sjkslc = 0; | |
| 676 | - int jhbc = 0,sjbc = 0,jhzgfbc = 0,sjzgfbc = 0,jhwgfbc = 0,sjwgfbc = 0; | |
| 677 | - sf.append("<DDRB>"); | |
| 678 | - sf.append("<RQ>"+schRealInfo.getScheduleDateStr()+"</RQ>"); | |
| 679 | - sf.append("<XLBM>"+schRealInfo.getXlBm()+"</XLBM>"); | |
| 680 | - for(ScheduleRealInfo scheduleRealInfo:list){ | |
| 681 | - if(scheduleRealInfo != null){ | |
| 682 | - if(scheduleRealInfo.getXlBm().equals(scheduleRealInfo.getXlBm())){ | |
| 683 | - //计划 | |
| 684 | - if(!scheduleRealInfo.isSflj()){ | |
| 685 | - jhlc += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc(); | |
| 686 | - //计划空驶 | |
| 687 | - if(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out")){ | |
| 688 | - jhkslc += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc(); | |
| 689 | - } | |
| 690 | - //计划早高峰,计划晚高峰 | |
| 691 | - if(TimeUtils.morningPeak(scheduleRealInfo.getFcsj())){ | |
| 692 | - jhzgfbc++; | |
| 693 | - } else if(TimeUtils.evenignPeak(scheduleRealInfo.getFcsj())){ | |
| 694 | - jhwgfbc++; | |
| 695 | - } | |
| 696 | - } | |
| 697 | - jhbc++; | |
| 698 | - | |
| 699 | - //实际 | |
| 700 | - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | |
| 701 | - //如果没有子任务,里程就是已执行(Status=2);有子任务的,忽略主任务,子任务的烂班 | |
| 702 | - if(childTaskPlans.isEmpty()){ | |
| 703 | - if(scheduleRealInfo.getStatus() == 2){ | |
| 704 | - sjbc++; | |
| 705 | - zlc += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc(); | |
| 706 | - if(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out") | |
| 707 | - || scheduleRealInfo.getBcType().equals("venting")){ | |
| 708 | - sjkslc += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc();; | |
| 709 | - } | |
| 710 | - } | |
| 711 | - }else{ | |
| 712 | - sjbc++; | |
| 713 | - Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 714 | - while(it.hasNext()){ | |
| 715 | - ChildTaskPlan childTaskPlan = it.next(); | |
| 716 | - if(!childTaskPlan.isDestroy()){ | |
| 717 | - zlc += childTaskPlan.getMileage()==null?0.0:childTaskPlan.getMileage(); | |
| 718 | - if(childTaskPlan.getMileageType().equals("empty")){ | |
| 719 | - sjkslc += childTaskPlan.getMileage()==null?0.0:childTaskPlan.getMileage();; | |
| 720 | - } | |
| 721 | - } | |
| 722 | - } | |
| 723 | - } | |
| 724 | - //实际早高峰,计划晚高峰 | |
| 725 | - if(scheduleRealInfo.getFcsjActual() != null){ | |
| 726 | - if(TimeUtils.morningPeak(scheduleRealInfo.getFcsj())){ | |
| 727 | - sjzgfbc++; | |
| 728 | - } else if(TimeUtils.evenignPeak(scheduleRealInfo.getFcsj())){ | |
| 729 | - sjwgfbc++; | |
| 730 | - } | |
| 731 | - } | |
| 732 | - } | |
| 733 | - } | |
| 774 | + conn = DBUtils_MS.getConnection(); | |
| 775 | + ps = conn.prepareStatement(sql); | |
| 776 | + ps.setString(1, yesterday); | |
| 777 | + rs = ps.executeQuery(); | |
| 778 | + Float lon, lat; | |
| 779 | + String kssk; | |
| 780 | + String speed; | |
| 781 | + while (rs.next()) { | |
| 782 | + kssk = sdfnyrsfm.format(rs.getLong("TIMESTAMP")); | |
| 783 | + speed = rs.getString("SPEED"); | |
| 784 | + // 经纬度 | |
| 785 | + lon = rs.getFloat("LON"); | |
| 786 | + lat = rs.getFloat("LAT"); | |
| 787 | + sBuffer.append("<CS>"); | |
| 788 | + sBuffer.append("<RQ>").append(sdfnyr.format(rs.getDate("CREATE_DATE"))).append("</RQ>"); | |
| 789 | + sBuffer.append("<XLBM>").append(BasicData.lineCode2ShangHaiCodeMap.get(rs.getString("LINE"))).append("</XLBM>");//////// | |
| 790 | + sBuffer.append("<CPH>").append(rs.getString("VEHICLE")).append("</CPH>"); | |
| 791 | + sBuffer.append("<KSSK>").append(kssk).append("</KSSK>"); | |
| 792 | + sBuffer.append("<KSDDJD>").append(lon).append("</KSDDJD>"); | |
| 793 | + sBuffer.append("<KSDDWD>").append(lat).append("</KSDDWD>"); | |
| 794 | + sBuffer.append("<KSLD>").append("").append("</KSLD>");//********************** | |
| 795 | + sBuffer.append("<JSSK>").append(kssk).append("</JSSK>"); | |
| 796 | + sBuffer.append("<JSDDJD>").append(lon).append("</JSDDJD>"); | |
| 797 | + sBuffer.append("<JSDDWD>").append(lat).append("</JSDDWD>"); | |
| 798 | + sBuffer.append("<JSLD>").append("").append("</JSLD>");//********************** | |
| 799 | + sBuffer.append("<PJSD>").append(speed).append("</PJSD>"); | |
| 800 | + sBuffer.append("<ZGSS>").append(speed).append("</ZGSS>"); | |
| 801 | + sBuffer.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>"); | |
| 802 | + sBuffer.append("</CS>"); | |
| 803 | + } | |
| 804 | + sBuffer.append("</CSs>"); | |
| 805 | + logger.info("setCS:"+sBuffer.toString()); | |
| 806 | + if(ssop.setCS(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ | |
| 807 | + result = "success"; | |
| 808 | + } | |
| 809 | + } catch (Exception e) { | |
| 810 | + e.printStackTrace(); | |
| 811 | + } finally { | |
| 812 | + logger.info("setCS:"+result); | |
| 813 | + DBUtils_MS.close(rs, ps, conn); | |
| 814 | + } | |
| 815 | + return result; | |
| 816 | + } | |
| 817 | + | |
| 818 | + | |
| 819 | + /** | |
| 820 | + * 下载全量的公交基础数据 | |
| 821 | + */ | |
| 822 | + public String getDownLoadAllDataFile() { | |
| 823 | + String result = "success"; | |
| 824 | + try { | |
| 825 | + Runtime currRuntime = Runtime.getRuntime (); | |
| 826 | + | |
| 827 | + int nFreeMemory = ( int ) (currRuntime.freeMemory() / 1024 / 1024); | |
| 828 | + | |
| 829 | + int nTotalMemory = ( int ) (currRuntime.totalMemory() / 1024 / 1024); | |
| 830 | + | |
| 831 | + System.out.println("zzz:"+nFreeMemory + "M/" + nTotalMemory +"M(free/total)"); | |
| 832 | + | |
| 833 | + byte[] res = portType.downloadAllDataFile("down_pdgj", "down_pdgj123"); | |
| 834 | + String filePath = "E:\\ygc"; | |
| 835 | + BufferedOutputStream bos = null; | |
| 836 | + FileOutputStream fos = null; | |
| 837 | + File file = null; | |
| 838 | + try { | |
| 839 | + File dir = new File(filePath); | |
| 840 | + if(!dir.exists()&&dir.isDirectory()){//判断文件目录是否存在 | |
| 841 | + dir.mkdirs(); | |
| 842 | + } | |
| 843 | + file = new File(filePath+"\\abc.rar"); | |
| 844 | + fos = new FileOutputStream(file); | |
| 845 | + bos = new BufferedOutputStream(fos); | |
| 846 | + bos.write(res); | |
| 847 | + } catch (Exception e) { | |
| 848 | + e.printStackTrace(); | |
| 849 | + } finally { | |
| 850 | + if (bos != null) { | |
| 851 | + try { | |
| 852 | + bos.close(); | |
| 853 | + } catch (IOException e1) { | |
| 854 | + e1.printStackTrace(); | |
| 734 | 855 | } |
| 735 | - sf.append("<JHLC>"+format.format(jhlc)+"</JHLC>"); | |
| 736 | - sf.append("<SSLC>"+format.format((zlc-sjkslc))+"</SSLC>"); | |
| 737 | - sf.append("<JHKSLC>"+format.format(jhkslc)+"</JHKSLC>"); | |
| 738 | - sf.append("<SJKSLC>"+format.format(sjkslc)+"</SJKSLC>"); | |
| 739 | - sf.append("<JHBC>"+jhbc+"</JHBC>"); | |
| 740 | - sf.append("<SJBC>"+sjbc+"</SJBC>"); | |
| 741 | - sf.append("<JHZGFBC>"+jhzgfbc+"</JHZGFBC>"); | |
| 742 | - sf.append("<SJZGFBC>"+sjzgfbc+"</SJZGFBC>"); | |
| 743 | - sf.append("<JHWGFBC>"+jhwgfbc+"</JHWGFBC>"); | |
| 744 | - sf.append("<SJWGFBC>"+sjwgfbc+"</SJWGFBC>"); | |
| 745 | - sf.append("<UPDT>"+sdfnyrsfm.format(schRealInfo.getUpdateDate())+"</UPDT>"); | |
| 746 | - sf.append("<RBSCBZ>"+0+"</RBSCBZ>"); | |
| 747 | - sf.append("</DDRB>"); | |
| 748 | - } | |
| 856 | + } | |
| 857 | + if (fos != null) { | |
| 858 | + try { | |
| 859 | + fos.close(); | |
| 860 | + } catch (IOException e1) { | |
| 861 | + e1.printStackTrace(); | |
| 862 | + } | |
| 863 | + } | |
| 749 | 864 | } |
| 750 | - sf.append("</DDRBS>"); | |
| 751 | - logger.info("setDDRB:"+sf.toString()); | |
| 752 | - ssop.setDDRB(userNameOther, passwordOther, sf.toString()); | |
| 753 | 865 | } catch (Exception e) { |
| 754 | 866 | e.printStackTrace(); |
| 755 | 867 | } |
| 756 | - return date; | |
| 868 | + | |
| 869 | + return result; | |
| 870 | + } | |
| 871 | + | |
| 872 | + /** | |
| 873 | + * 下载增量的公交基础数据 | |
| 874 | + */ | |
| 875 | + public String getDownLoadIncreaseDataFile() { | |
| 876 | + String result = "success"; | |
| 877 | + try { | |
| 878 | + //System.out.println(portType.downloadIncreaseDataFile(args0, args1, args2)); | |
| 879 | + } catch (Exception e) { | |
| 880 | + e.printStackTrace(); | |
| 881 | + } | |
| 882 | + | |
| 883 | + return result; | |
| 884 | + } | |
| 885 | + | |
| 886 | + /** | |
| 887 | + * 指定线路查询方式公交基础数据下载 | |
| 888 | + */ | |
| 889 | + public String getDownLoadWarrantsBusLineStation() { | |
| 890 | + String result = "success"; | |
| 891 | + try { | |
| 892 | + | |
| 893 | + //portType.setXL(userNameXl, passwordXl, sBuffer.toString()); | |
| 894 | + } catch (Exception e) { | |
| 895 | + e.printStackTrace(); | |
| 896 | + } | |
| 897 | + | |
| 898 | + return result; | |
| 757 | 899 | } |
| 758 | - | |
| 900 | + | |
| 759 | 901 | /** |
| 760 | 902 | * 计算结束时间 |
| 761 | 903 | * @param fcsj 发车时间 |
| ... | ... | @@ -787,7 +929,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 787 | 929 | } |
| 788 | 930 | return result; |
| 789 | 931 | } |
| 790 | - | |
| 932 | + | |
| 791 | 933 | /** |
| 792 | 934 | * 拼装线路计划班次表的XML |
| 793 | 935 | * @param sBuffer | ... | ... |
src/main/java/com/bsth/service/oil/YlbService.java
| 1 | 1 | package com.bsth.service.oil; |
| 2 | 2 | |
| 3 | +import java.util.List; | |
| 3 | 4 | import java.util.Map; |
| 4 | 5 | |
| 5 | 6 | import com.bsth.entity.oil.Ylb; |
| ... | ... | @@ -13,4 +14,6 @@ public interface YlbService extends BaseService<Ylb, Integer>{ |
| 13 | 14 | Map<String, Object> outAndIn(Map<String, Object> map); |
| 14 | 15 | |
| 15 | 16 | Map<String, Object> checkYl(Map<String, Object> map); |
| 17 | + | |
| 18 | + List<Ylb> oilListMonth(String line,String date); | |
| 16 | 19 | } | ... | ... |
src/main/java/com/bsth/service/oil/impl/YlbServiceImpl.java
| ... | ... | @@ -390,6 +390,13 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 390 | 390 | |
| 391 | 391 | return newMap; |
| 392 | 392 | } |
| 393 | + | |
| 394 | + | |
| 395 | + @Override | |
| 396 | + public List<Ylb> oilListMonth(String line, String date) { | |
| 397 | + // TODO Auto-generated method stub | |
| 398 | + return null; | |
| 399 | + } | |
| 393 | 400 | |
| 394 | 401 | |
| 395 | 402 | } | ... | ... |
src/main/java/com/bsth/service/realcontrol/LineConfigService.java
| ... | ... | @@ -7,9 +7,9 @@ import com.bsth.service.BaseService; |
| 7 | 7 | |
| 8 | 8 | public interface LineConfigService extends BaseService<LineConfig, Integer>{ |
| 9 | 9 | |
| 10 | - Map<String, Object> check(Integer[] codeArray); | |
| 10 | + Map<String, Object> check(String[] codeArray); | |
| 11 | 11 | |
| 12 | - Integer inti(Integer lineCode) throws Exception; | |
| 12 | + Integer init(String lineCode) throws Exception; | |
| 13 | 13 | |
| 14 | 14 | Map<String, Object> editStartOptTime(String time, String lineCode); |
| 15 | 15 | ... | ... |
src/main/java/com/bsth/service/realcontrol/RealChartsService.java
0 → 100644
| 1 | +package com.bsth.service.realcontrol; | |
| 2 | + | |
| 3 | +import com.bsth.service.realcontrol.dto.CarOutRate; | |
| 4 | +import com.bsth.service.realcontrol.dto.DeviceOnlineRate; | |
| 5 | +import com.bsth.service.realcontrol.dto.StratEndPunctualityRate; | |
| 6 | + | |
| 7 | +import java.util.List; | |
| 8 | +import java.util.Map; | |
| 9 | + | |
| 10 | +/**线调图表 | |
| 11 | + * Created by panzhao on 2016/11/9. | |
| 12 | + */ | |
| 13 | +public interface RealChartsService { | |
| 14 | + List<DeviceOnlineRate> deviceOnlineRate(String month, String idx); | |
| 15 | + | |
| 16 | + List<CarOutRate> carOutRate(String month, String idx); | |
| 17 | + | |
| 18 | + List<StratEndPunctualityRate> stratEndPunctualityRate(String month, String idx); | |
| 19 | + | |
| 20 | + List<StratEndPunctualityRate> sePunctualityRateLine(String month, String idx); | |
| 21 | +} | ... | ... |
src/main/java/com/bsth/service/realcontrol/dto/CarOutRate.java
0 → 100644
| 1 | +package com.bsth.service.realcontrol.dto; | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * 出车率 | |
| 5 | + * Created by panzhao on 2016/11/9. | |
| 6 | + */ | |
| 7 | +public class CarOutRate { | |
| 8 | + | |
| 9 | + private String dateStr; | |
| 10 | + | |
| 11 | + private String lineCode; | |
| 12 | + | |
| 13 | + private String nbbm; | |
| 14 | + | |
| 15 | + private String firstOut; | |
| 16 | + | |
| 17 | + | |
| 18 | + public String getNbbm() { | |
| 19 | + return nbbm; | |
| 20 | + } | |
| 21 | + | |
| 22 | + public void setNbbm(String nbbm) { | |
| 23 | + this.nbbm = nbbm; | |
| 24 | + } | |
| 25 | + | |
| 26 | + public String getLineCode() { | |
| 27 | + return lineCode; | |
| 28 | + } | |
| 29 | + | |
| 30 | + public void setLineCode(String lineCode) { | |
| 31 | + this.lineCode = lineCode; | |
| 32 | + } | |
| 33 | + | |
| 34 | + public String getDateStr() { | |
| 35 | + return dateStr; | |
| 36 | + } | |
| 37 | + | |
| 38 | + public void setDateStr(String dateStr) { | |
| 39 | + this.dateStr = dateStr; | |
| 40 | + } | |
| 41 | + | |
| 42 | + public String getFirstOut() { | |
| 43 | + return firstOut; | |
| 44 | + } | |
| 45 | + | |
| 46 | + public void setFirstOut(String firstOut) { | |
| 47 | + this.firstOut = firstOut; | |
| 48 | + } | |
| 49 | +} | ... | ... |
src/main/java/com/bsth/service/realcontrol/dto/DeviceOnlineRate.java
0 → 100644
| 1 | +package com.bsth.service.realcontrol.dto; | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * 设备上线率dto | |
| 5 | + * Created by panzhao on 2016/11/9. | |
| 6 | + */ | |
| 7 | +public class DeviceOnlineRate { | |
| 8 | + | |
| 9 | + private String lineCode; | |
| 10 | + | |
| 11 | + private String dateStr; | |
| 12 | + | |
| 13 | + private Integer dayOfYear; | |
| 14 | + | |
| 15 | + private String nbbm; | |
| 16 | + | |
| 17 | + private boolean online; | |
| 18 | + | |
| 19 | + public boolean isOnline() { | |
| 20 | + return online; | |
| 21 | + } | |
| 22 | + | |
| 23 | + public void setOnline(boolean online) { | |
| 24 | + this.online = online; | |
| 25 | + } | |
| 26 | + | |
| 27 | + public String getNbbm() { | |
| 28 | + return nbbm; | |
| 29 | + } | |
| 30 | + | |
| 31 | + public void setNbbm(String nbbm) { | |
| 32 | + this.nbbm = nbbm; | |
| 33 | + } | |
| 34 | + | |
| 35 | + public String getDateStr() { | |
| 36 | + return dateStr; | |
| 37 | + } | |
| 38 | + | |
| 39 | + public void setDateStr(String dateStr) { | |
| 40 | + this.dateStr = dateStr; | |
| 41 | + } | |
| 42 | + | |
| 43 | + public String getLineCode() { | |
| 44 | + return lineCode; | |
| 45 | + } | |
| 46 | + | |
| 47 | + public void setLineCode(String lineCode) { | |
| 48 | + this.lineCode = lineCode; | |
| 49 | + } | |
| 50 | + | |
| 51 | + public Integer getDayOfYear() { | |
| 52 | + return dayOfYear; | |
| 53 | + } | |
| 54 | + | |
| 55 | + public void setDayOfYear(Integer dayOfYear) { | |
| 56 | + this.dayOfYear = dayOfYear; | |
| 57 | + } | |
| 58 | +} | ... | ... |
src/main/java/com/bsth/service/realcontrol/dto/RealOnline.java
0 → 100644
| 1 | +package com.bsth.service.realcontrol.dto; | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * 实际上线设备 | |
| 5 | + * Created by panzhao on 2016/11/9. | |
| 6 | + */ | |
| 7 | +public class RealOnline { | |
| 8 | + | |
| 9 | + private Integer dayOfYear; | |
| 10 | + | |
| 11 | + private String nbbm; | |
| 12 | + | |
| 13 | + private String device; | |
| 14 | + | |
| 15 | + | |
| 16 | + public Integer getDayOfYear() { | |
| 17 | + return dayOfYear; | |
| 18 | + } | |
| 19 | + | |
| 20 | + public void setDayOfYear(Integer dayOfYear) { | |
| 21 | + this.dayOfYear = dayOfYear; | |
| 22 | + } | |
| 23 | + | |
| 24 | + public String getNbbm() { | |
| 25 | + return nbbm; | |
| 26 | + } | |
| 27 | + | |
| 28 | + public void setNbbm(String nbbm) { | |
| 29 | + this.nbbm = nbbm; | |
| 30 | + } | |
| 31 | + | |
| 32 | + public String getDevice() { | |
| 33 | + return device; | |
| 34 | + } | |
| 35 | + | |
| 36 | + public void setDevice(String device) { | |
| 37 | + this.device = device; | |
| 38 | + } | |
| 39 | +} | ... | ... |
src/main/java/com/bsth/service/realcontrol/dto/StratEndPunctualityRate.java
0 → 100644
| 1 | +package com.bsth.service.realcontrol.dto; | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * 首末班正点率 | |
| 5 | + * Created by panzhao on 2016/11/10. | |
| 6 | + */ | |
| 7 | +public class StratEndPunctualityRate { | |
| 8 | + | |
| 9 | + private String dateStr; | |
| 10 | + | |
| 11 | + private String lineCode; | |
| 12 | + | |
| 13 | + private String nbbm; | |
| 14 | + | |
| 15 | + //首班时间 06:00/06:01 | |
| 16 | + private String startTime; | |
| 17 | + | |
| 18 | + //末班时间 20:30/20:31 | |
| 19 | + private String endTime; | |
| 20 | + | |
| 21 | + //末班真实执行日期 | |
| 22 | + private String etRealExecDate; | |
| 23 | + | |
| 24 | + | |
| 25 | + public String getDateStr() { | |
| 26 | + return dateStr; | |
| 27 | + } | |
| 28 | + | |
| 29 | + public void setDateStr(String dateStr) { | |
| 30 | + this.dateStr = dateStr; | |
| 31 | + } | |
| 32 | + | |
| 33 | + public String getLineCode() { | |
| 34 | + return lineCode; | |
| 35 | + } | |
| 36 | + | |
| 37 | + public void setLineCode(String lineCode) { | |
| 38 | + this.lineCode = lineCode; | |
| 39 | + } | |
| 40 | + | |
| 41 | + public String getNbbm() { | |
| 42 | + return nbbm; | |
| 43 | + } | |
| 44 | + | |
| 45 | + public void setNbbm(String nbbm) { | |
| 46 | + this.nbbm = nbbm; | |
| 47 | + } | |
| 48 | + | |
| 49 | + public String getStartTime() { | |
| 50 | + return startTime; | |
| 51 | + } | |
| 52 | + | |
| 53 | + public void setStartTime(String startTime) { | |
| 54 | + this.startTime = startTime; | |
| 55 | + } | |
| 56 | + | |
| 57 | + public String getEndTime() { | |
| 58 | + return endTime; | |
| 59 | + } | |
| 60 | + | |
| 61 | + public void setEndTime(String endTime) { | |
| 62 | + this.endTime = endTime; | |
| 63 | + } | |
| 64 | + | |
| 65 | + public String getEtRealExecDate() { | |
| 66 | + return etRealExecDate; | |
| 67 | + } | |
| 68 | + | |
| 69 | + public void setEtRealExecDate(String etRealExecDate) { | |
| 70 | + this.etRealExecDate = etRealExecDate; | |
| 71 | + } | |
| 72 | +} | ... | ... |
src/main/java/com/bsth/service/realcontrol/impl/LineConfigServiceImpl.java
| ... | ... | @@ -25,11 +25,11 @@ public class LineConfigServiceImpl extends BaseServiceImpl<LineConfig, Integer> |
| 25 | 25 | LineConfigData lineConfigData; |
| 26 | 26 | |
| 27 | 27 | @Override |
| 28 | - public Map<String, Object> check(Integer[] codeArray) { | |
| 28 | + public Map<String, Object> check(String[] codeArray) { | |
| 29 | 29 | Map<String, Object> rs = new HashMap<>(); |
| 30 | - List<Integer> notArr = new ArrayList<>(); | |
| 30 | + List<String> notArr = new ArrayList<>(); | |
| 31 | 31 | |
| 32 | - for(Integer lineCode : codeArray){ | |
| 32 | + for(String lineCode : codeArray){ | |
| 33 | 33 | if(null == lineConfigData.get(lineCode + "")) |
| 34 | 34 | notArr.add(lineCode); |
| 35 | 35 | } |
| ... | ... | @@ -44,8 +44,8 @@ public class LineConfigServiceImpl extends BaseServiceImpl<LineConfig, Integer> |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | @Override |
| 47 | - public Integer inti(Integer lineCode) throws Exception{ | |
| 48 | - LineConfig conf = lineConfigData.get(lineCode + ""); | |
| 47 | + public Integer init(String lineCode) throws Exception{ | |
| 48 | + LineConfig conf = lineConfigData.get(lineCode ); | |
| 49 | 49 | |
| 50 | 50 | if(conf == null) |
| 51 | 51 | lineConfigData.init(lineCode); | ... | ... |
src/main/java/com/bsth/service/realcontrol/impl/RealChartsServiceImpl.java
0 → 100644
| 1 | +package com.bsth.service.realcontrol.impl; | |
| 2 | + | |
| 3 | +import com.bsth.data.BasicData; | |
| 4 | +import com.bsth.data.LineConfigData; | |
| 5 | +import com.bsth.entity.realcontrol.LineConfig; | |
| 6 | +import com.bsth.service.realcontrol.RealChartsService; | |
| 7 | +import com.bsth.service.realcontrol.dto.CarOutRate; | |
| 8 | +import com.bsth.service.realcontrol.dto.DeviceOnlineRate; | |
| 9 | +import com.bsth.service.realcontrol.dto.RealOnline; | |
| 10 | +import com.bsth.service.realcontrol.dto.StratEndPunctualityRate; | |
| 11 | +import com.bsth.util.db.DBUtils_MS; | |
| 12 | +import com.google.common.base.Splitter; | |
| 13 | +import org.apache.commons.lang3.StringUtils; | |
| 14 | +import org.joda.time.format.DateTimeFormat; | |
| 15 | +import org.joda.time.format.DateTimeFormatter; | |
| 16 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 17 | +import org.springframework.jdbc.core.JdbcTemplate; | |
| 18 | +import org.springframework.jdbc.core.RowMapper; | |
| 19 | +import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; | |
| 20 | +import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; | |
| 21 | +import org.springframework.stereotype.Service; | |
| 22 | + | |
| 23 | +import java.sql.ResultSet; | |
| 24 | +import java.sql.SQLException; | |
| 25 | +import java.util.*; | |
| 26 | + | |
| 27 | +/** | |
| 28 | + * Created by panzhao on 2016/11/9. | |
| 29 | + */ | |
| 30 | +@Service | |
| 31 | +public class RealChartsServiceImpl implements RealChartsService { | |
| 32 | + | |
| 33 | + @Autowired | |
| 34 | + NamedParameterJdbcTemplate jdbcTemplate; | |
| 35 | + | |
| 36 | + @Autowired | |
| 37 | + LineConfigData lineConfigData; | |
| 38 | + | |
| 39 | + | |
| 40 | + private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd"); | |
| 41 | + | |
| 42 | + private final static long DAY_TIME = 1000 * 60 * 60 * 24L; | |
| 43 | + /** | |
| 44 | + * 设备上线率 | |
| 45 | + * | |
| 46 | + * @param | |
| 47 | + * @param idx 线路id字符串 | |
| 48 | + * @return | |
| 49 | + */ | |
| 50 | + @Override | |
| 51 | + public List<DeviceOnlineRate> deviceOnlineRate(String month, String idx) { | |
| 52 | + List<String> idArray = Splitter.on(",").splitToList(idx); | |
| 53 | + //拼接in语句 | |
| 54 | + String inStr = ""; | |
| 55 | + for (String code : idArray) { | |
| 56 | + inStr += (",'" + code+"'"); | |
| 57 | + } | |
| 58 | + inStr = " (" + inStr.substring(1) + ")"; | |
| 59 | + | |
| 60 | + String sql = "select DISTINCT XL_BM,SCHEDULE_DATE_STR, CL_ZBH from bsth_c_s_sp_info_real s where s.schedule_date_str like :month and xl_bm in " + inStr; | |
| 61 | + MapSqlParameterSource parameters = new MapSqlParameterSource(); | |
| 62 | + parameters.addValue("month", month+"-%"); | |
| 63 | + | |
| 64 | + final DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd"); | |
| 65 | + //应该上线的设备 | |
| 66 | + List<DeviceOnlineRate> mustList = jdbcTemplate.query(sql, parameters, new RowMapper<DeviceOnlineRate>() { | |
| 67 | + @Override | |
| 68 | + public DeviceOnlineRate mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 69 | + DeviceOnlineRate obj = new DeviceOnlineRate(); | |
| 70 | + obj.setLineCode(rs.getString("XL_BM")); | |
| 71 | + obj.setDateStr(rs.getString("SCHEDULE_DATE_STR")); | |
| 72 | + obj.setNbbm(rs.getString("CL_ZBH")); | |
| 73 | + obj.setDayOfYear(fmtyyyyMMdd.parseDateTime(obj.getDateStr()).getDayOfYear()); | |
| 74 | + return obj; | |
| 75 | + } | |
| 76 | + }); | |
| 77 | + | |
| 78 | + if(mustList.size() == 0) | |
| 79 | + return mustList; | |
| 80 | + | |
| 81 | + //查询ms 库 gps信息 | |
| 82 | + JdbcTemplate msJdbcTemplate = new JdbcTemplate(DBUtils_MS.getDataSource()); | |
| 83 | + //要in的 days_year ,gps表分区字段 | |
| 84 | + Set<Integer> daysSet = new HashSet<>(); | |
| 85 | + | |
| 86 | + Map<String, DeviceOnlineRate> groupData = new HashMap<>(); | |
| 87 | + for(DeviceOnlineRate obj : mustList){ | |
| 88 | + daysSet.add(obj.getDayOfYear()); | |
| 89 | + //分组数据 | |
| 90 | + groupData.put(obj.getDayOfYear()+"_"+obj.getNbbm(), obj); | |
| 91 | + } | |
| 92 | + | |
| 93 | + | |
| 94 | + //拼接 days_year in 语句 | |
| 95 | + inStr=""; | |
| 96 | + for(Integer daysOfYear : daysSet){ | |
| 97 | + inStr += (",'" + daysOfYear+"'"); | |
| 98 | + } | |
| 99 | + inStr = " (" + inStr.substring(1) + ")"; | |
| 100 | + //查询gps表,获取实际上线设备 | |
| 101 | + sql = "select DISTINCT DEVICE_ID, DAYS_YEAR from bsth_c_gps_info where days_year in " + inStr; | |
| 102 | + List<RealOnline> realList = msJdbcTemplate.query(sql, new RowMapper<RealOnline>() { | |
| 103 | + @Override | |
| 104 | + public RealOnline mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 105 | + RealOnline obj = new RealOnline(); | |
| 106 | + obj.setDayOfYear(rs.getInt("DAYS_YEAR")); | |
| 107 | + obj.setDevice(rs.getString("DEVICE_ID")); | |
| 108 | + obj.setNbbm(BasicData.deviceId2NbbmMap.get(obj.getDevice())); | |
| 109 | + return obj; | |
| 110 | + } | |
| 111 | + }); | |
| 112 | + DeviceOnlineRate donline; | |
| 113 | + for(RealOnline obj : realList){ | |
| 114 | + if(StringUtils.isEmpty(obj.getNbbm())) | |
| 115 | + continue; | |
| 116 | + | |
| 117 | + donline = groupData.get(obj.getDayOfYear() + "_" + obj.getNbbm()); | |
| 118 | + if(donline != null) | |
| 119 | + donline.setOnline(true); | |
| 120 | + } | |
| 121 | + | |
| 122 | + return mustList; | |
| 123 | + } | |
| 124 | + | |
| 125 | + /** | |
| 126 | + * 出车率 | |
| 127 | + * @param month | |
| 128 | + * @param idx | |
| 129 | + * @return | |
| 130 | + */ | |
| 131 | + @Override | |
| 132 | + public List<CarOutRate> carOutRate(String month, String idx) { | |
| 133 | + List<String> idArray = Splitter.on(",").splitToList(idx); | |
| 134 | + //拼接in语句 | |
| 135 | + String inStr = ""; | |
| 136 | + for (String code : idArray) { | |
| 137 | + inStr += (",'" + code+"'"); | |
| 138 | + } | |
| 139 | + inStr = " (" + inStr.substring(1) + ")"; | |
| 140 | + | |
| 141 | + String sql = "SELECT DISTINCT XL_BM,SCHEDULE_DATE_STR,CL_ZBH,right(min(concat(REAL_EXEC_DATE,fcsj_actual)),5) as FIRST_OUT FROM bsth_c_s_sp_info_real s WHERE s.schedule_date_str LIKE :month AND xl_bm IN "+inStr+" group by XL_BM,SCHEDULE_DATE_STR,CL_ZBH"; | |
| 142 | + | |
| 143 | + MapSqlParameterSource parameters = new MapSqlParameterSource(); | |
| 144 | + parameters.addValue("month", month+"-%"); | |
| 145 | + | |
| 146 | + List<CarOutRate> list = jdbcTemplate.query(sql, parameters, new RowMapper<CarOutRate>() { | |
| 147 | + @Override | |
| 148 | + public CarOutRate mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 149 | + CarOutRate obj = new CarOutRate(); | |
| 150 | + obj.setDateStr(rs.getString("SCHEDULE_DATE_STR")); | |
| 151 | + obj.setNbbm(rs.getString("CL_ZBH")); | |
| 152 | + obj.setLineCode(rs.getString("XL_BM")); | |
| 153 | + obj.setFirstOut(rs.getString("FIRST_OUT")); | |
| 154 | + return obj; | |
| 155 | + } | |
| 156 | + }); | |
| 157 | + | |
| 158 | + return list; | |
| 159 | + } | |
| 160 | + | |
| 161 | + /** | |
| 162 | + * 首末班次准点率 | |
| 163 | + * @param month | |
| 164 | + * @param idx | |
| 165 | + * @return | |
| 166 | + */ | |
| 167 | + @Override | |
| 168 | + public List<StratEndPunctualityRate> stratEndPunctualityRate(String month, String idx) { | |
| 169 | + List<String> idArray = Splitter.on(",").splitToList(idx); | |
| 170 | + //拼接in语句 | |
| 171 | + String inStr = ""; | |
| 172 | + for (String code : idArray) { | |
| 173 | + inStr += (",'" + code+"'"); | |
| 174 | + } | |
| 175 | + inStr = " (" + inStr.substring(1) + ")"; | |
| 176 | + | |
| 177 | + String sql = "select SCHEDULE_DATE_STR,XL_BM,CL_ZBH, min(sj) as STARTDATE, max(sj) as ENDDATE " + | |
| 178 | + "from (select SCHEDULE_DATE_STR,dfsj, concat_ws('/',dfsj, fcsj_actual) as sj,XL_BM,CL_ZBH from bsth_c_s_sp_info_real " + | |
| 179 | + "where schedule_date_str like :month and bc_type='normal' and dfsj is not null and xl_bm in "+inStr+") t group by SCHEDULE_DATE_STR,XL_BM,CL_ZBH"; | |
| 180 | + | |
| 181 | + | |
| 182 | + MapSqlParameterSource parameters = new MapSqlParameterSource(); | |
| 183 | + parameters.addValue("month", month+"-%"); | |
| 184 | + | |
| 185 | + List<StratEndPunctualityRate> list = jdbcTemplate.query(sql, parameters, new RowMapper<StratEndPunctualityRate>() { | |
| 186 | + @Override | |
| 187 | + public StratEndPunctualityRate mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 188 | + StratEndPunctualityRate obj = new StratEndPunctualityRate(); | |
| 189 | + obj.setLineCode(rs.getString("XL_BM")); | |
| 190 | + obj.setDateStr(rs.getString("SCHEDULE_DATE_STR")); | |
| 191 | + obj.setNbbm(rs.getString("CL_ZBH")); | |
| 192 | + obj.setStartTime(rs.getString("STARTDATE")); | |
| 193 | + obj.setEndTime(rs.getString("ENDDATE")); | |
| 194 | + obj.setEtRealExecDate(obj.getDateStr()); | |
| 195 | + | |
| 196 | + if(obj.getEndTime().length() == 11){ | |
| 197 | + //末班真实执行日期 | |
| 198 | + LineConfig conf =lineConfigData.get(obj.getLineCode()); | |
| 199 | + String fcsjActual=obj.getEndTime().split("/")[1]; | |
| 200 | + | |
| 201 | + if(fcsjActual.compareTo(conf.getStartOpt()) < 0){ | |
| 202 | + //加一天 | |
| 203 | + obj.setEtRealExecDate(fmtyyyyMMdd.print(fmtyyyyMMdd.parseMillis(obj.getEtRealExecDate()) + DAY_TIME)); | |
| 204 | + } | |
| 205 | + } | |
| 206 | + | |
| 207 | + return obj; | |
| 208 | + } | |
| 209 | + }); | |
| 210 | + return list; | |
| 211 | + } | |
| 212 | + | |
| 213 | + @Override | |
| 214 | + public List<StratEndPunctualityRate> sePunctualityRateLine(String month, String idx) { | |
| 215 | + List<String> idArray = Splitter.on(",").splitToList(idx); | |
| 216 | + //拼接in语句 | |
| 217 | + String inStr = ""; | |
| 218 | + for (String code : idArray) { | |
| 219 | + inStr += (",'" + code+"'"); | |
| 220 | + } | |
| 221 | + inStr = " (" + inStr.substring(1) + ")"; | |
| 222 | + | |
| 223 | + String sql = "select SCHEDULE_DATE_STR,XL_BM, min(sj) as STARTDATE, max(sj) as ENDDATE " + | |
| 224 | + "from (select SCHEDULE_DATE_STR,dfsj, concat_ws('/',dfsj, fcsj_actual) as sj,XL_BM from bsth_c_s_sp_info_real " + | |
| 225 | + "where schedule_date_str like :month and bc_type='normal' and dfsj is not null and xl_bm in "+inStr+") t group by SCHEDULE_DATE_STR,XL_BM"; | |
| 226 | + | |
| 227 | + MapSqlParameterSource parameters = new MapSqlParameterSource(); | |
| 228 | + parameters.addValue("month", month+"-%"); | |
| 229 | + | |
| 230 | + List<StratEndPunctualityRate> list = jdbcTemplate.query(sql, parameters, new RowMapper<StratEndPunctualityRate>() { | |
| 231 | + @Override | |
| 232 | + public StratEndPunctualityRate mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 233 | + StratEndPunctualityRate obj = new StratEndPunctualityRate(); | |
| 234 | + obj.setLineCode(rs.getString("XL_BM")); | |
| 235 | + obj.setDateStr(rs.getString("SCHEDULE_DATE_STR")); | |
| 236 | + obj.setStartTime(rs.getString("STARTDATE")); | |
| 237 | + obj.setEndTime(rs.getString("ENDDATE")); | |
| 238 | + obj.setEtRealExecDate(obj.getDateStr()); | |
| 239 | + | |
| 240 | + if(obj.getEndTime().length() == 11){ | |
| 241 | + //末班真实执行日期 | |
| 242 | + LineConfig conf =lineConfigData.get(obj.getLineCode()); | |
| 243 | + String fcsjActual=obj.getEndTime().split("/")[1]; | |
| 244 | + | |
| 245 | + if(fcsjActual.compareTo(conf.getStartOpt()) < 0){ | |
| 246 | + //加一天 | |
| 247 | + obj.setEtRealExecDate(fmtyyyyMMdd.print(fmtyyyyMMdd.parseMillis(obj.getEtRealExecDate()) + DAY_TIME)); | |
| 248 | + } | |
| 249 | + } | |
| 250 | + | |
| 251 | + return obj; | |
| 252 | + } | |
| 253 | + }); | |
| 254 | + return list; | |
| 255 | + } | |
| 256 | +} | ... | ... |
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
| ... | ... | @@ -1332,6 +1332,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 1332 | 1332 | map.put("ssgl_yw", ssgl_yw==0?0:format.format(ssgl_yw)); |
| 1333 | 1333 | map.put("ssgl_other", ssgl_other==0?0:format.format(ssgl_other)); |
| 1334 | 1334 | map.put("ljgl", ljgl==0?0:format.format(ljgl)); |
| 1335 | + map.put("jhbc", jhbc); | |
| 1335 | 1336 | map.put("jhbc_m", jhbc_m); |
| 1336 | 1337 | map.put("jhbc_a", jhbc_a); |
| 1337 | 1338 | map.put("sjbc", sjbc); | ... | ... |
src/main/java/com/bsth/util/db/DBUtils_MS.java
src/main/resources/application-dev.properties
| ... | ... | @@ -8,7 +8,7 @@ spring.jpa.hibernate.naming_strategy= org.hibernate.cfg.ImprovedNamingStrategy |
| 8 | 8 | spring.jpa.database= MYSQL |
| 9 | 9 | spring.jpa.show-sql= false |
| 10 | 10 | spring.datasource.driver-class-name= com.mysql.jdbc.Driver |
| 11 | -spring.datasource.url= jdbc:mysql://192.168.168.201:3306/mh_control?useUnicode=true&characterEncoding=utf-8&useSSL=false | |
| 11 | +spring.datasource.url= jdbc:mysql://192.168.168.201/mh_control?useUnicode=true&characterEncoding=utf-8&useSSL=false | |
| 12 | 12 | spring.datasource.username= root |
| 13 | 13 | spring.datasource.password= 123456 |
| 14 | 14 | #DATASOURCE |
| ... | ... | @@ -29,4 +29,4 @@ spring.datasource.validation-query=select 1 |
| 29 | 29 | http.gps.real.url= http://192.168.168.201:9090/transport_server/rtgps/ |
| 30 | 30 | #http.gps.real.url= http://27.115.69.123:8800/transport_server/rtgps/ |
| 31 | 31 | ##\u6D88\u606F\u4E0B\u53D1 |
| 32 | -http.send.directive = http://192.168.168.201:9090/transport_server/message/ | |
| 32 | +http.send.directive = http://192.168.168.201:9090/transport_server/message/ | |
| 33 | 33 | \ No newline at end of file | ... | ... |
src/main/resources/application-prod.properties
| ... | ... | @@ -8,9 +8,9 @@ spring.jpa.hibernate.naming_strategy= org.hibernate.cfg.ImprovedNamingStrategy |
| 8 | 8 | spring.jpa.database= MYSQL |
| 9 | 9 | spring.jpa.show-sql= true |
| 10 | 10 | spring.datasource.driver-class-name= com.mysql.jdbc.Driver |
| 11 | -spring.datasource.url= jdbc:mysql://192.168.40.100:3306/qp_control?useUnicode=true&characterEncoding=utf-8&useSSL=false | |
| 11 | +spring.datasource.url= jdbc:mysql://192.168.168.171:3306/control?useUnicode=true&characterEncoding=utf-8&useSSL=false | |
| 12 | 12 | spring.datasource.username= root |
| 13 | -spring.datasource.password= root@JSP2jsp | |
| 13 | +spring.datasource.password= root2jsp | |
| 14 | 14 | #DATASOURCE |
| 15 | 15 | spring.datasource.max-active=100 |
| 16 | 16 | spring.datasource.max-idle=8 |
| ... | ... | @@ -26,6 +26,6 @@ spring.datasource.validation-query=select 1 |
| 26 | 26 | ## |
| 27 | 27 | #222.66.0.204:5555 |
| 28 | 28 | ##\u5B9E\u65F6gps |
| 29 | -http.gps.real.url= http://192.168.40.82:8080/transport_server/rtgps/ | |
| 29 | +http.gps.real.url= http://192.168.168.171:8080/transport_server/rtgps/ | |
| 30 | 30 | ##\u6D88\u606F\u4E0B\u53D1 |
| 31 | -http.send.directive = http://192.168.40.82:8080/transport_server/message/ | |
| 32 | 31 | \ No newline at end of file |
| 32 | +http.send.directive = http://192.168.168.171:8080/transport_server/message/ | |
| 33 | 33 | \ No newline at end of file | ... | ... |
src/main/resources/datatools/config-prod.properties
| ... | ... | @@ -3,14 +3,15 @@ |
| 3 | 3 | # 1、kettle配置文件路径(类路径) |
| 4 | 4 | datatools.kettle_properties=/datatools/kettle.properties |
| 5 | 5 | # 2、ktr文件通用配置变量(数据库连接,根据不同的环境需要修正) |
| 6 | + | |
| 6 | 7 | #数据库ip地址 |
| 7 | -datatools.kvars_dbip=192.168.40.100 | |
| 8 | +datatools.kvars_dbip=192.168.168.171 | |
| 8 | 9 | #数据库用户名 |
| 9 | 10 | datatools.kvars_dbuname=root |
| 10 | 11 | #数据库密码 |
| 11 | -datatools.kvars_dbpwd=root@JSP2jsp | |
| 12 | +datatools.kvars_dbpwd=root2jsp | |
| 12 | 13 | #数据库库名 |
| 13 | -datatools.kvars_dbdname=qp_control | |
| 14 | +datatools.kvars_dbdname=control | |
| 14 | 15 | |
| 15 | 16 | # 3、上传数据配置信息 |
| 16 | 17 | # 上传文件目录配置(根据不同的环境需要修正) | ... | ... |
src/main/resources/ms-jdbc.properties
| 1 | -#ms.mysql.driver= com.mysql.jdbc.Driver | |
| 2 | -#ms.mysql.url= jdbc:mysql://192.168.40.82:3306/ms?useUnicode=true&characterEncoding=utf-8&useSSL=false | |
| 3 | -#ms.mysql.username= root | |
| 4 | -#ms.mysql.password= 123456 | |
| 5 | - | |
| 6 | 1 | ms.mysql.driver= com.mysql.jdbc.Driver |
| 7 | 2 | ms.mysql.url= jdbc:mysql://192.168.168.201:3306/ms?useUnicode=true&characterEncoding=utf-8&useSSL=false |
| 8 | 3 | ms.mysql.username= root |
| 9 | 4 | ms.mysql.password= 123456 |
| 5 | + | |
| 6 | +#ms.mysql.driver= com.mysql.jdbc.Driver | |
| 7 | +#ms.mysql.url= jdbc:mysql://192.168.168.171:3306/ms?useUnicode=true&characterEncoding=utf-8 | |
| 8 | +#ms.mysql.username= root | |
| 9 | +#ms.mysql.password= root2jsp | ... | ... |
src/main/resources/static/index.html
| ... | ... | @@ -145,7 +145,7 @@ tr.row-active td { |
| 145 | 145 | <div class="page-header-inner "> |
| 146 | 146 | <!-- LOGO --> |
| 147 | 147 | <div class="page-logo"> |
| 148 | - <a href="index.html" class="logo-default logo-default-text" > 青浦公交调度系统 </a> | |
| 148 | + <a href="index.html" class="logo-default logo-default-text" > 闵行公交调度系统 </a> | |
| 149 | 149 | <div class="menu-toggler sidebar-toggler"> |
| 150 | 150 | </div> |
| 151 | 151 | </div> |
| ... | ... | @@ -314,8 +314,8 @@ tr.row-active td { |
| 314 | 314 | <script src="/metronic_v4.5.4/plugins/bootstrap-datetimepicker-2/js/bootstrap-datetimepicker.min.js" ></script> |
| 315 | 315 | <!-- 表格控件 --> |
| 316 | 316 | <!-- 统计图控件 --> |
| 317 | -<script src="/assets/global/getEchart.js"></script> | |
| 318 | -<script src="/assets/global/echarts.js"></script> | |
| 317 | +<!--<script src="/assets/global/getEchart.js"></script> | |
| 318 | +<script src="/assets/global/echarts.js"></script> --> | |
| 319 | 319 | <script src="/assets/js/common.js"></script> |
| 320 | 320 | <script src="/assets/js/dictionary.js"></script> |
| 321 | 321 | ... | ... |
src/main/resources/static/login.html
| ... | ... | @@ -180,7 +180,7 @@ h3.logo-text{ |
| 180 | 180 | <div class="wrapper ng-scope"> |
| 181 | 181 | <div id="loginPanel" class="dialog dialog-shadow"> |
| 182 | 182 | <br> |
| 183 | - <h3 class="logo-text">青浦公交调度系统 </h3> | |
| 183 | + <h3 class="logo-text">闵行公交调度系统 </h3> | |
| 184 | 184 | <hr> |
| 185 | 185 | <form style="padding: 0px 35px;"> |
| 186 | 186 | <div class="form-group" style="margin-bottom: 0"> |
| ... | ... | @@ -238,7 +238,7 @@ window.onload=function(){ |
| 238 | 238 | $('input', form).on('keyup', checkBtnStatus); |
| 239 | 239 | |
| 240 | 240 | var keys; |
| 241 | - $.get('/user/login/jCryptionKey', function(data){ | |
| 241 | + $.get('/user/login/jCryptionKey?t='+Math.random(), function(data){ | |
| 242 | 242 | keys = data.publickey; |
| 243 | 243 | }); |
| 244 | 244 | ... | ... |
src/main/resources/static/pages/control/line/index.html
| ... | ... | @@ -18,7 +18,7 @@ |
| 18 | 18 | <div class="portlet-title banner" > |
| 19 | 19 | <div class="caption col_hide_1280" style="color: #FFF;"> |
| 20 | 20 | <i class="fa fa-life-ring" style="font-size: 22px;color: #FFF;"></i> <span |
| 21 | - class="caption-subject bold" style="font-size: 24px;">青浦公交线路调度系统</span> | |
| 21 | + class="caption-subject bold" style="font-size: 24px;">闵行公交线路调度系统</span> | |
| 22 | 22 | </div> |
| 23 | 23 | <div class="col_hide_1440" style="color: white;font-size: 18px;position: absolute;right: 25px;top: 75px;"> |
| 24 | 24 | <span class="top_username"></span> <span class="operation_mode_text animated" ></span> | ... | ... |
src/main/resources/static/pages/device/connection_search.html
| ... | ... | @@ -71,6 +71,9 @@ |
| 71 | 71 | </div> |
| 72 | 72 | </div> |
| 73 | 73 | </div> |
| 74 | + <form id="export_form" action="/devicegps/export" method="post" style="display:none;"> | |
| 75 | + <input type="text" id="json" name="json"> | |
| 76 | + </form> | |
| 74 | 77 | <div class="tab-pane fade" id="tab2"> |
| 75 | 78 | <div class="row"> |
| 76 | 79 | <div class="col-md-12"> |
| ... | ... | @@ -98,6 +101,8 @@ |
| 98 | 101 | <label class="checkbox-inline"> |
| 99 | 102 | <input type="radio" name="filterOption" value="5">版本不等于 |
| 100 | 103 | <input type="text" id="version" name="version" size="5"> |
| 104 | + | |
| 105 | + <a id="export_btn" class="btn btn-circle blue" href="#" data-pjax> 导出</a> | |
| 101 | 106 | </label> |
| 102 | 107 | </div> |
| 103 | 108 | </div> |
| ... | ... | @@ -227,7 +232,7 @@ |
| 227 | 232 | </script> |
| 228 | 233 | <script> |
| 229 | 234 | $(function(){ |
| 230 | - var opened; | |
| 235 | + var opened,filtered; | |
| 231 | 236 | $('#myTab li:eq(0) a').tab('show'); |
| 232 | 237 | $('#fileinput').fileinput({ |
| 233 | 238 | 'showPreview' : false, |
| ... | ... | @@ -247,10 +252,11 @@ $(function(){ |
| 247 | 252 | $(this).html(moment(parseInt($(this).html())).format('YYYY-M-D HH:mm:ss')); |
| 248 | 253 | }); |
| 249 | 254 | opened = new Array(); |
| 255 | + filtered = new Array(); | |
| 250 | 256 | for (var j = 0,len = r.data.length;j < len;j++) { |
| 251 | 257 | var item = r.data[j]; |
| 252 | - delete item.detail; | |
| 253 | 258 | opened.push(item); |
| 259 | + filtered.push(item); | |
| 254 | 260 | } |
| 255 | 261 | } |
| 256 | 262 | $(this).fileinput('clear').fileinput('enable'); |
| ... | ... | @@ -265,15 +271,19 @@ $(function(){ |
| 265 | 271 | $('input[type=radio][name=filterOption]').change(function() { |
| 266 | 272 | importDeviceSearch(); |
| 267 | 273 | }); |
| 274 | + | |
| 275 | + $('#export_btn').on('click', function(e){ | |
| 276 | + exportResult(); | |
| 277 | + }); | |
| 268 | 278 | |
| 269 | 279 | function importDeviceSearch(){ |
| 270 | 280 | if (!opened) return false; |
| 271 | 281 | var params = { json : JSON.stringify(opened) }; |
| 272 | - $post('/devicegps/open/filter', params, function(r){ | |
| 273 | - debugger; | |
| 282 | + $post('/devicegps/opened', params, function(r){ | |
| 274 | 283 | if(r.errCode) layer.msg(r.msg); |
| 275 | 284 | else { |
| 276 | - var filtered = new Array(), val = $('input[type=radio][name=filterOption]:checked').val(), version = $('#version').val(), i = 0,item = null; | |
| 285 | + var val = $('input[type=radio][name=filterOption]:checked').val(), version = $('#version').val(), i = 0,item = null; | |
| 286 | + filtered = new Array(); | |
| 277 | 287 | switch(val) { |
| 278 | 288 | case '1': |
| 279 | 289 | filtered = r.data; |
| ... | ... | @@ -313,6 +323,13 @@ $(function(){ |
| 313 | 323 | } |
| 314 | 324 | }); |
| 315 | 325 | } |
| 326 | + | |
| 327 | + function exportResult() { | |
| 328 | + if (!filtered) return false; | |
| 329 | + $('#json').val(JSON.stringify(filtered)); | |
| 330 | + var form = $('#export_form'); | |
| 331 | + form.submit(); | |
| 332 | + } | |
| 316 | 333 | |
| 317 | 334 | var page = 0, initPagination; |
| 318 | 335 | var icheckOptions = { | ... | ... |
src/main/resources/static/pages/forms/statement/scheduleDaily.html
| ... | ... | @@ -301,7 +301,7 @@ |
| 301 | 301 | //查询 |
| 302 | 302 | $("#query").on('click',function(){ |
| 303 | 303 | var line = $("#line").val(); |
| 304 | - var xlName = $("#line").text(); | |
| 304 | + var xlName = $("#select2-line-container").html(); | |
| 305 | 305 | var date = $("#date").val(); |
| 306 | 306 | $get('/realSchedule/statisticsDaily',{line:line,date:date,xlName:xlName},function(result){ |
| 307 | 307 | var scheduleDaily_1 = template('scheduleDaily_1',{list:result}); | ... | ... |
src/main/resources/static/pages/scheduleApp/module/common/dts1/upload/saFileuploadTemplate.html
| 1 | -<div class="input-group"> | |
| 2 | - <input type="file" name="file" id="file"/> | |
| 3 | - | |
| 4 | - <input type="file" class="form-control" nv-file-select="" uploader="ctrl.uploader"/> | |
| 5 | - <span class="input-group-btn"> | |
| 6 | - <button type="button" ng-click="ctrl.clearInputFile()" class="btn btn-default"> | |
| 7 | - <span class="glyphicon glyphicon-trash"></span> | |
| 8 | - </button> | |
| 9 | - <button type="button" class="btn btn-success"> | |
| 10 | - <span class="glyphicon glyphicon-upload"></span> 上传 | |
| 11 | - </button> | |
| 12 | - </span> | |
| 13 | - | |
| 14 | - | |
| 15 | - | |
| 16 | - | |
| 1 | +<div class="input-group"> | |
| 2 | + <input type="file" name="file" id="file"/> | |
| 3 | + | |
| 4 | + <input type="file" class="form-control" nv-file-select="" uploader="ctrl.uploader"/> | |
| 5 | + <span class="input-group-btn"> | |
| 6 | + <button type="button" ng-click="ctrl.clearInputFile()" class="btn btn-default"> | |
| 7 | + <span class="glyphicon glyphicon-trash"></span> | |
| 8 | + </button> | |
| 9 | + <button type="button" class="btn btn-success"> | |
| 10 | + <span class="glyphicon glyphicon-upload"></span> 上传 | |
| 11 | + </button> | |
| 12 | + </span> | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | 17 | </div> |
| 18 | 18 | \ No newline at end of file | ... | ... |
src/main/resources/static/pages/scheduleApp/module/common/dts1/validation/remoteValidationt2.js
| 1 | -/** | |
| 2 | - * remoteValidatiot2指令,远程数据验证验证,作为属性放在某个指令上,依赖与指令的ngModel(专门用于时刻表sheet验证)。 | |
| 3 | - * 属性如下: | |
| 4 | - * remotevtype(必须):验证类型(在service中有对应映射),如rvtype="xl" | |
| 5 | - * remotevparam(必须):后端判定查询参数,如rvparam={{ {'xl.id_eq': '123'} | json }} | |
| 6 | - * | |
| 7 | - */ | |
| 8 | -angular.module('ScheduleApp').directive('remoteValidationt2', [ | |
| 9 | - '$$SearchInfoService_g', | |
| 10 | - function($$SearchInfoService_g) { | |
| 11 | - return { | |
| 12 | - restrict: "A", // 属性 | |
| 13 | - require: "^ngModel", // 依赖所属指令的ngModel | |
| 14 | - compile: function(tElem, tAttrs) { | |
| 15 | - // 验证属性 | |
| 16 | - if (!tAttrs["remotevtype"]) { // 验证类型 | |
| 17 | - throw new Error("remotevtype属性必须填写"); | |
| 18 | - } else if (!$$SearchInfoService_g.validate[tAttrs["remotevtype"]]) { | |
| 19 | - throw new Error(!tAttrs["remotevtype"] + "验证类型不存在"); | |
| 20 | - } | |
| 21 | - if (!tAttrs["remotevparam"]) { // 查询参数 | |
| 22 | - throw new Error("remotevparam属性必须填写"); | |
| 23 | - } | |
| 24 | - | |
| 25 | - // 监听获取的数据 | |
| 26 | - var $watch_rvtype = undefined; | |
| 27 | - var $watch_rvparam_obj = undefined; | |
| 28 | - | |
| 29 | - // 验证数据 | |
| 30 | - var $$internal_validate = function(ngModelCtrl, scope) { | |
| 31 | - if ($watch_rvtype && $watch_rvparam_obj) { | |
| 32 | - // 获取查询参数模版 | |
| 33 | - var paramTemplate = $$SearchInfoService_g.validate[$watch_rvtype].template; | |
| 34 | - if (!paramTemplate) { | |
| 35 | - throw new Error($watch_rvtype + "查询模版不存在"); | |
| 36 | - } | |
| 37 | - // 判定如果参数对象不全,没有完全和模版参数里对应上,则不验证 | |
| 38 | - var isParamAll = true; | |
| 39 | - for (var key in paramTemplate) { | |
| 40 | - if (!$watch_rvparam_obj[key]) { | |
| 41 | - isParamAll = false; | |
| 42 | - break; | |
| 43 | - } | |
| 44 | - } | |
| 45 | - if (!isParamAll) { | |
| 46 | - ngModelCtrl.$setValidity('remote', true); | |
| 47 | - } else { // 开始验证 | |
| 48 | - $$SearchInfoService_g.validate[$watch_rvtype].remote.do( | |
| 49 | - $watch_rvparam_obj, | |
| 50 | - function(result) { | |
| 51 | - if (result.status == "SUCCESS") { | |
| 52 | - ngModelCtrl.$setValidity('remote', true); | |
| 53 | - } else { | |
| 54 | - ngModelCtrl.$setValidity('remote', false); | |
| 55 | - scope.ctrl.ttInfoDetailManageForForm.sheetvaliddesc = result.msg; | |
| 56 | - } | |
| 57 | - }, | |
| 58 | - function(result) { | |
| 59 | - alert("出错拉"); | |
| 60 | - ngModelCtrl.$setValidity('remote', true); | |
| 61 | - } | |
| 62 | - ); | |
| 63 | - } | |
| 64 | - } | |
| 65 | - }; | |
| 66 | - | |
| 67 | - return { | |
| 68 | - pre: function(scope, element, attr) { | |
| 69 | - | |
| 70 | - }, | |
| 71 | - | |
| 72 | - post: function(scope, element, attr, ngModelCtrl) { | |
| 73 | - /** | |
| 74 | - * 监控验证类型属性变化。 | |
| 75 | - */ | |
| 76 | - attr.$observe("remotevtype", function(value) { | |
| 77 | - if (value && value != "") { | |
| 78 | - $watch_rvtype = value; | |
| 79 | - $$internal_validate(ngModelCtrl, scope); | |
| 80 | - } | |
| 81 | - }); | |
| 82 | - /** | |
| 83 | - * 监控查询结果属性变化。 | |
| 84 | - */ | |
| 85 | - attr.$observe("remotevparam", function(value) { | |
| 86 | - if (value && value != "") { | |
| 87 | - //if (!ngModelCtrl.$dirty) { // 没有修改过模型数据,不验证 | |
| 88 | - // return; | |
| 89 | - //} | |
| 90 | - $watch_rvparam_obj = JSON.parse(value); | |
| 91 | - $$internal_validate(ngModelCtrl, scope); | |
| 92 | - } | |
| 93 | - }); | |
| 94 | - } | |
| 95 | - }; | |
| 96 | - } | |
| 97 | - } | |
| 98 | - } | |
| 99 | -]); | |
| 1 | +/** | |
| 2 | + * remoteValidatiot2指令,远程数据验证验证,作为属性放在某个指令上,依赖与指令的ngModel(专门用于时刻表sheet验证)。 | |
| 3 | + * 属性如下: | |
| 4 | + * remotevtype(必须):验证类型(在service中有对应映射),如rvtype="xl" | |
| 5 | + * remotevparam(必须):后端判定查询参数,如rvparam={{ {'xl.id_eq': '123'} | json }} | |
| 6 | + * | |
| 7 | + */ | |
| 8 | +angular.module('ScheduleApp').directive('remoteValidationt2', [ | |
| 9 | + '$$SearchInfoService_g', | |
| 10 | + function($$SearchInfoService_g) { | |
| 11 | + return { | |
| 12 | + restrict: "A", // 属性 | |
| 13 | + require: "^ngModel", // 依赖所属指令的ngModel | |
| 14 | + compile: function(tElem, tAttrs) { | |
| 15 | + // 验证属性 | |
| 16 | + if (!tAttrs["remotevtype"]) { // 验证类型 | |
| 17 | + throw new Error("remotevtype属性必须填写"); | |
| 18 | + } else if (!$$SearchInfoService_g.validate[tAttrs["remotevtype"]]) { | |
| 19 | + throw new Error(!tAttrs["remotevtype"] + "验证类型不存在"); | |
| 20 | + } | |
| 21 | + if (!tAttrs["remotevparam"]) { // 查询参数 | |
| 22 | + throw new Error("remotevparam属性必须填写"); | |
| 23 | + } | |
| 24 | + | |
| 25 | + // 监听获取的数据 | |
| 26 | + var $watch_rvtype = undefined; | |
| 27 | + var $watch_rvparam_obj = undefined; | |
| 28 | + | |
| 29 | + // 验证数据 | |
| 30 | + var $$internal_validate = function(ngModelCtrl, scope) { | |
| 31 | + if ($watch_rvtype && $watch_rvparam_obj) { | |
| 32 | + // 获取查询参数模版 | |
| 33 | + var paramTemplate = $$SearchInfoService_g.validate[$watch_rvtype].template; | |
| 34 | + if (!paramTemplate) { | |
| 35 | + throw new Error($watch_rvtype + "查询模版不存在"); | |
| 36 | + } | |
| 37 | + // 判定如果参数对象不全,没有完全和模版参数里对应上,则不验证 | |
| 38 | + var isParamAll = true; | |
| 39 | + for (var key in paramTemplate) { | |
| 40 | + if (!$watch_rvparam_obj[key]) { | |
| 41 | + isParamAll = false; | |
| 42 | + break; | |
| 43 | + } | |
| 44 | + } | |
| 45 | + if (!isParamAll) { | |
| 46 | + ngModelCtrl.$setValidity('remote', true); | |
| 47 | + } else { // 开始验证 | |
| 48 | + $$SearchInfoService_g.validate[$watch_rvtype].remote.do( | |
| 49 | + $watch_rvparam_obj, | |
| 50 | + function(result) { | |
| 51 | + if (result.status == "SUCCESS") { | |
| 52 | + ngModelCtrl.$setValidity('remote', true); | |
| 53 | + } else { | |
| 54 | + ngModelCtrl.$setValidity('remote', false); | |
| 55 | + scope.ctrl.ttInfoDetailManageForForm.sheetvaliddesc = result.msg; | |
| 56 | + } | |
| 57 | + }, | |
| 58 | + function(result) { | |
| 59 | + alert("出错拉"); | |
| 60 | + ngModelCtrl.$setValidity('remote', true); | |
| 61 | + } | |
| 62 | + ); | |
| 63 | + } | |
| 64 | + } | |
| 65 | + }; | |
| 66 | + | |
| 67 | + return { | |
| 68 | + pre: function(scope, element, attr) { | |
| 69 | + | |
| 70 | + }, | |
| 71 | + | |
| 72 | + post: function(scope, element, attr, ngModelCtrl) { | |
| 73 | + /** | |
| 74 | + * 监控验证类型属性变化。 | |
| 75 | + */ | |
| 76 | + attr.$observe("remotevtype", function(value) { | |
| 77 | + if (value && value != "") { | |
| 78 | + $watch_rvtype = value; | |
| 79 | + $$internal_validate(ngModelCtrl, scope); | |
| 80 | + } | |
| 81 | + }); | |
| 82 | + /** | |
| 83 | + * 监控查询结果属性变化。 | |
| 84 | + */ | |
| 85 | + attr.$observe("remotevparam", function(value) { | |
| 86 | + if (value && value != "") { | |
| 87 | + //if (!ngModelCtrl.$dirty) { // 没有修改过模型数据,不验证 | |
| 88 | + // return; | |
| 89 | + //} | |
| 90 | + $watch_rvparam_obj = JSON.parse(value); | |
| 91 | + $$internal_validate(ngModelCtrl, scope); | |
| 92 | + } | |
| 93 | + }); | |
| 94 | + } | |
| 95 | + }; | |
| 96 | + } | |
| 97 | + } | |
| 98 | + } | |
| 99 | +]); | ... | ... |