Commit fef9b8c583aa485a9ac1cdb837a71d056894b960
Merge branch 'minhang' of http://222.66.0.204:8090/panzhaov5/bsth_control into minhang
# Conflicts: # src/main/java/com/bsth/data/schedule/late_adjust/LateAdjustHandle.java
Showing
31 changed files
with
724 additions
and
1173 deletions
src/main/java/com/bsth/controller/BaseController.java
| 1 | package com.bsth.controller; | 1 | package com.bsth.controller; |
| 2 | 2 | ||
| 3 | -import com.bsth.common.ResponseCode; | ||
| 4 | import com.bsth.service.BaseService; | 3 | import com.bsth.service.BaseService; |
| 5 | -import com.bsth.service.schedule.utils.DataImportExportService; | ||
| 6 | import com.google.common.base.Splitter; | 4 | import com.google.common.base.Splitter; |
| 7 | import org.springframework.beans.factory.annotation.Autowired; | 5 | import org.springframework.beans.factory.annotation.Autowired; |
| 8 | import org.springframework.data.domain.Page; | 6 | import org.springframework.data.domain.Page; |
| 9 | import org.springframework.data.domain.PageRequest; | 7 | import org.springframework.data.domain.PageRequest; |
| 10 | import org.springframework.data.domain.Sort; | 8 | import org.springframework.data.domain.Sort; |
| 11 | import org.springframework.data.domain.Sort.Direction; | 9 | import org.springframework.data.domain.Sort.Direction; |
| 12 | -import org.springframework.util.CollectionUtils; | ||
| 13 | import org.springframework.web.bind.annotation.PathVariable; | 10 | import org.springframework.web.bind.annotation.PathVariable; |
| 14 | import org.springframework.web.bind.annotation.RequestMapping; | 11 | import org.springframework.web.bind.annotation.RequestMapping; |
| 15 | import org.springframework.web.bind.annotation.RequestMethod; | 12 | import org.springframework.web.bind.annotation.RequestMethod; |
| 16 | import org.springframework.web.bind.annotation.RequestParam; | 13 | import org.springframework.web.bind.annotation.RequestParam; |
| 17 | -import org.springframework.web.multipart.MultipartFile; | ||
| 18 | 14 | ||
| 19 | -import javax.servlet.http.HttpServletResponse; | ||
| 20 | -import java.io.*; | 15 | +import java.io.Serializable; |
| 21 | import java.util.ArrayList; | 16 | import java.util.ArrayList; |
| 22 | -import java.util.HashMap; | ||
| 23 | import java.util.List; | 17 | import java.util.List; |
| 24 | import java.util.Map; | 18 | import java.util.Map; |
| 25 | 19 | ||
| @@ -35,8 +29,6 @@ public class BaseController<T, ID extends Serializable> { | @@ -35,8 +29,6 @@ public class BaseController<T, ID extends Serializable> { | ||
| 35 | 29 | ||
| 36 | @Autowired | 30 | @Autowired |
| 37 | protected BaseService<T, ID> baseService; | 31 | protected BaseService<T, ID> baseService; |
| 38 | - @Autowired | ||
| 39 | - DataImportExportService dataImportExportService; | ||
| 40 | 32 | ||
| 41 | /** | 33 | /** |
| 42 | * @param @param map 查询条件 | 34 | * @param @param map 查询条件 |
| @@ -126,115 +118,4 @@ public class BaseController<T, ID extends Serializable> { | @@ -126,115 +118,4 @@ public class BaseController<T, ID extends Serializable> { | ||
| 126 | return baseService.delete(id); | 118 | return baseService.delete(id); |
| 127 | } | 119 | } |
| 128 | 120 | ||
| 129 | - /** | ||
| 130 | - * 上传数据文件,并使用ktr转换文件导入数据。 | ||
| 131 | - * | ||
| 132 | - * @param file | ||
| 133 | - * @return | ||
| 134 | - * @throws Exception | ||
| 135 | - */ | ||
| 136 | - @RequestMapping(value = "/dataImport", method = RequestMethod.POST) | ||
| 137 | - public Map<String, Object> uploadDataAndImport(MultipartFile file) throws Exception { | ||
| 138 | - Map<String, Object> resultMap = new HashMap<>(); | ||
| 139 | - | ||
| 140 | - try { | ||
| 141 | - // 获取ktr转换文件绝对路径 | ||
| 142 | - File ktrfile = new File(this.getClass().getResource(getDataImportKtrClasspath()).toURI()); | ||
| 143 | - System.out.println(ktrfile.getAbsolutePath()); | ||
| 144 | - // 导入数据 | ||
| 145 | - dataImportExportService.fileDataImport(file, ktrfile); | ||
| 146 | - | ||
| 147 | - resultMap.put("status", ResponseCode.SUCCESS); | ||
| 148 | - resultMap.put("msg", "导入成功"); | ||
| 149 | - } catch (Exception exp) { | ||
| 150 | - exp.printStackTrace(); | ||
| 151 | - resultMap.put("status", ResponseCode.ERROR); | ||
| 152 | - resultMap.put("msg", exp.getLocalizedMessage()); | ||
| 153 | - } | ||
| 154 | - | ||
| 155 | - return resultMap; | ||
| 156 | - } | ||
| 157 | - | ||
| 158 | - /** | ||
| 159 | - * 使用ktr导出数据。 | ||
| 160 | - * | ||
| 161 | - * @param response | ||
| 162 | - * @throws Exception | ||
| 163 | - */ | ||
| 164 | - @RequestMapping(value = "/dataExport", method = RequestMethod.GET) | ||
| 165 | - public void dataExport(HttpServletResponse response) throws Exception { | ||
| 166 | - dataExport(response, null); | ||
| 167 | - } | ||
| 168 | - | ||
| 169 | - @RequestMapping(value = "/dataExportExt", method = RequestMethod.GET) | ||
| 170 | - public void dataExport(HttpServletResponse response, @RequestParam Map<String, Object> param) throws Exception { | ||
| 171 | - // 1、使用ktr转换获取输出文件 | ||
| 172 | - File ktrfile = new File(this.getClass().getResource(getDataExportKtrClasspath()).toURI()); | ||
| 173 | - File outputfile = null; | ||
| 174 | - if (!CollectionUtils.isEmpty(param)) { | ||
| 175 | - outputfile = dataImportExportService.fileDataOutput( | ||
| 176 | - getDataExportFilename(), | ||
| 177 | - ktrfile, | ||
| 178 | - param); | ||
| 179 | - } else { | ||
| 180 | - outputfile = dataImportExportService.fileDataOutput( | ||
| 181 | - getDataExportFilename(), | ||
| 182 | - ktrfile); | ||
| 183 | - } | ||
| 184 | - | ||
| 185 | - System.out.println(outputfile.getName()); | ||
| 186 | - String filePath = outputfile.getAbsolutePath(); | ||
| 187 | - String fp[] = filePath.split(File.separator); | ||
| 188 | - String fileName = fp[fp.length - 1]; | ||
| 189 | - | ||
| 190 | - // TODO:使用ktr获取导出数据 | ||
| 191 | - | ||
| 192 | - response.setHeader("conent-type", "application/octet-stream"); | ||
| 193 | - response.setContentType("application/octet-stream"); | ||
| 194 | - response.setHeader("Content-Disposition", "attachment; filename=" + "东东"); | ||
| 195 | - | ||
| 196 | - OutputStream os = response.getOutputStream(); | ||
| 197 | - BufferedOutputStream bos = new BufferedOutputStream(os); | ||
| 198 | - | ||
| 199 | - InputStream is = null; | ||
| 200 | - | ||
| 201 | - is = new FileInputStream(filePath); | ||
| 202 | - BufferedInputStream bis = new BufferedInputStream(is); | ||
| 203 | - | ||
| 204 | - int length = 0; | ||
| 205 | - byte[] temp = new byte[1 * 1024 * 10]; | ||
| 206 | - | ||
| 207 | - while ((length = bis.read(temp)) != -1) { | ||
| 208 | - bos.write(temp, 0, length); | ||
| 209 | - } | ||
| 210 | - bos.flush(); | ||
| 211 | - bis.close(); | ||
| 212 | - bos.close(); | ||
| 213 | - is.close(); | ||
| 214 | - } | ||
| 215 | - | ||
| 216 | - /** | ||
| 217 | - * @return 数据导出的ktr转换文件类路径。 | ||
| 218 | - */ | ||
| 219 | - protected String getDataExportKtrClasspath() { | ||
| 220 | - // 默认返回异常,子类如果要使用导出功能,必须覆写此方法,指定ktr文件类路径 | ||
| 221 | - throw new RuntimeException("必须override,并指定ktr classpath"); | ||
| 222 | - } | ||
| 223 | - | ||
| 224 | - /** | ||
| 225 | - * @return 导出文件名。 | ||
| 226 | - */ | ||
| 227 | - protected String getDataExportFilename() { | ||
| 228 | - // 默认返回异常,子类如果要使用导出功能,必须覆写此方法,指定导出的文件路径名 | ||
| 229 | - throw new RuntimeException("必须override,并指定导出文件名"); | ||
| 230 | - } | ||
| 231 | - | ||
| 232 | - /** | ||
| 233 | - * @return 数据导入的ktr转换文件类路径。 | ||
| 234 | - */ | ||
| 235 | - protected String getDataImportKtrClasspath() { | ||
| 236 | - // 默认返回异常,子类如果要使用导入功能,必须覆写此方法,指定ktr文件类路径 | ||
| 237 | - throw new RuntimeException("必须override,并指定ktr classpath"); | ||
| 238 | - } | ||
| 239 | - | ||
| 240 | } | 121 | } |
src/main/java/com/bsth/controller/BaseController2.java deleted
100644 → 0
| 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 jxl.Sheet; | ||
| 9 | -import jxl.Workbook; | ||
| 10 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 11 | -import org.springframework.data.domain.Page; | ||
| 12 | -import org.springframework.data.domain.PageRequest; | ||
| 13 | -import org.springframework.data.domain.Sort; | ||
| 14 | -import org.springframework.util.CollectionUtils; | ||
| 15 | -import org.springframework.web.bind.annotation.*; | ||
| 16 | -import org.springframework.web.multipart.MultipartFile; | ||
| 17 | - | ||
| 18 | -import javax.servlet.http.HttpServletResponse; | ||
| 19 | -import java.io.*; | ||
| 20 | -import java.util.ArrayList; | ||
| 21 | -import java.util.HashMap; | ||
| 22 | -import java.util.List; | ||
| 23 | -import java.util.Map; | ||
| 24 | - | ||
| 25 | -/** | ||
| 26 | - * Created by xu on 16/11/3. | ||
| 27 | - */ | ||
| 28 | -public class BaseController2<T, ID extends Serializable> { | ||
| 29 | - | ||
| 30 | - @Autowired | ||
| 31 | - protected BaseService<T, ID> baseService; | ||
| 32 | - @Autowired | ||
| 33 | - DataImportExportService dataImportExportService; | ||
| 34 | - | ||
| 35 | - /** | ||
| 36 | - * | ||
| 37 | - * @Title: list | ||
| 38 | - * @Description: TODO(多条件分页查询) | ||
| 39 | - * @param @param map 查询条件 | ||
| 40 | - * @param @param page 页码 | ||
| 41 | - * @param @param size 每页显示数量 | ||
| 42 | - * @throws | ||
| 43 | - */ | ||
| 44 | - @RequestMapping(method = RequestMethod.GET) | ||
| 45 | - public Page<T> list(@RequestParam Map<String, Object> map, | ||
| 46 | - @RequestParam(defaultValue = "0") int page, | ||
| 47 | - @RequestParam(defaultValue = "10") int size, | ||
| 48 | - @RequestParam(defaultValue = "id") String order, | ||
| 49 | - @RequestParam(defaultValue = "DESC") String direction){ | ||
| 50 | - | ||
| 51 | - // 允许多个字段排序,order可以写单个字段,也可以写多个字段 | ||
| 52 | - // 多个字段格式:{col1},{col2},{col3},....,{coln} | ||
| 53 | - List<String> order_columns = Splitter.on(",").trimResults().splitToList(order); | ||
| 54 | - // 多字段排序:DESC,ASC... | ||
| 55 | - List<String> order_dirs = Splitter.on(",").trimResults().splitToList(direction); | ||
| 56 | - | ||
| 57 | - if (order_dirs.size() == 1) { // 所有字段采用一种排序 | ||
| 58 | - if (null != order_dirs.get(0) && order_dirs.get(0).equals("ASC")) { | ||
| 59 | - return baseService.list(map, new PageRequest(page, size, new Sort(Sort.Direction.ASC, order_columns))); | ||
| 60 | - } else { | ||
| 61 | - return baseService.list(map, new PageRequest(page, size, new Sort(Sort.Direction.DESC, order_columns))); | ||
| 62 | - } | ||
| 63 | - } else if (order_columns.size() == order_dirs.size()) { | ||
| 64 | - List<Sort.Order> orderList = new ArrayList<>(); | ||
| 65 | - for (int i = 0; i < order_columns.size(); i++) { | ||
| 66 | - if (null != order_dirs.get(i) && order_dirs.get(i).equals("ASC")) { | ||
| 67 | - orderList.add(new Sort.Order(Sort.Direction.ASC, order_columns.get(i))); | ||
| 68 | - } else { | ||
| 69 | - orderList.add(new Sort.Order(Sort.Direction.DESC, order_columns.get(i))); | ||
| 70 | - } | ||
| 71 | - } | ||
| 72 | - return baseService.list(map, new PageRequest(page, size, new Sort(orderList))); | ||
| 73 | - } else { | ||
| 74 | - throw new RuntimeException("多字段排序参数格式问题,排序顺序和字段数不一致"); | ||
| 75 | - } | ||
| 76 | - } | ||
| 77 | - | ||
| 78 | - /** | ||
| 79 | - * | ||
| 80 | - * @Title: list | ||
| 81 | - * @Description: TODO(多条件查询) | ||
| 82 | - * @param @param map | ||
| 83 | - * @throws | ||
| 84 | - */ | ||
| 85 | - @RequestMapping(value = "/all", method = RequestMethod.GET) | ||
| 86 | - public Iterable<T> list(@RequestParam Map<String, Object> map){ | ||
| 87 | - return baseService.list(map); | ||
| 88 | - } | ||
| 89 | - | ||
| 90 | - /** | ||
| 91 | - * 这里保存直接返回保存后的对象,不自己定义Map返回了,和前端angularjs配合。 | ||
| 92 | - * form也可以提交,但是页面参数可能不全, | ||
| 93 | - * json的化比较灵活,但是貌似有多余属性也会报错,或者碰到lazy属性值,也有问题 | ||
| 94 | - * 不论form,还是json提交都能解决问题,就看哪个方便哪个来 | ||
| 95 | - * | ||
| 96 | - * @param t 参数需要使用@RequestBody转换json成对象 | ||
| 97 | - * @return | ||
| 98 | - */ | ||
| 99 | - @RequestMapping(method = RequestMethod.POST) | ||
| 100 | - public T save(@RequestBody T t) { | ||
| 101 | - baseService.save(t); | ||
| 102 | - return t; | ||
| 103 | - } | ||
| 104 | - | ||
| 105 | - @RequestMapping(value="/{id}", method = RequestMethod.POST) | ||
| 106 | - public T update(@RequestBody T t) { | ||
| 107 | - baseService.save(t); | ||
| 108 | - return t; | ||
| 109 | - } | ||
| 110 | - | ||
| 111 | - /** | ||
| 112 | - * | ||
| 113 | - * @Title: findById | ||
| 114 | - * @Description: TODO(根据主键获取单个对象) | ||
| 115 | - * @param @param id | ||
| 116 | - * @throws | ||
| 117 | - */ | ||
| 118 | - @RequestMapping(value="/{id}",method = RequestMethod.GET) | ||
| 119 | - public T findById(@PathVariable("id") ID id){ | ||
| 120 | - return baseService.findById(id); | ||
| 121 | - } | ||
| 122 | - | ||
| 123 | - /** | ||
| 124 | - * | ||
| 125 | - * @Title: delete | ||
| 126 | - * @Description: TODO(根据主键删除对象) | ||
| 127 | - * @param @param id | ||
| 128 | - * @throws | ||
| 129 | - */ | ||
| 130 | - @RequestMapping(value="/{id}",method = RequestMethod.DELETE) | ||
| 131 | - public Map<String, Object> delete(@PathVariable("id") ID id){ | ||
| 132 | - return baseService.delete(id); | ||
| 133 | - } | ||
| 134 | - | ||
| 135 | - /** | ||
| 136 | - * 上传数据文件,并使用ktr转换文件导入数据。 | ||
| 137 | - * @param file | ||
| 138 | - * @return | ||
| 139 | - * @throws Exception | ||
| 140 | - */ | ||
| 141 | - @RequestMapping(value = "/dataImport", method = RequestMethod.POST) | ||
| 142 | - public Map<String, Object> uploadDataAndImport(MultipartFile file) throws Exception { | ||
| 143 | - Map<String, Object> resultMap = new HashMap<>(); | ||
| 144 | - | ||
| 145 | - try { | ||
| 146 | - // 获取ktr转换文件绝对路径 | ||
| 147 | - File ktrfile = new File(this.getClass().getResource(getDataImportKtrClasspath()).toURI()); | ||
| 148 | - System.out.println(ktrfile.getAbsolutePath()); | ||
| 149 | - // 导入数据 | ||
| 150 | - dataImportExportService.fileDataImport(file, ktrfile); | ||
| 151 | - | ||
| 152 | - resultMap.put("status", ResponseCode.SUCCESS); | ||
| 153 | - resultMap.put("msg", "导入成功"); | ||
| 154 | - } catch (Exception exp) { | ||
| 155 | - exp.printStackTrace(); | ||
| 156 | - resultMap.put("status", ResponseCode.ERROR); | ||
| 157 | - resultMap.put("msg", exp.getLocalizedMessage()); | ||
| 158 | - } | ||
| 159 | - | ||
| 160 | - return resultMap; | ||
| 161 | - } | ||
| 162 | - | ||
| 163 | - /** | ||
| 164 | - * 使用ktr导出数据。 | ||
| 165 | - * @param response | ||
| 166 | - * @throws Exception | ||
| 167 | - */ | ||
| 168 | - @RequestMapping(value = "/dataExport", method = RequestMethod.GET) | ||
| 169 | - public void dataExport(HttpServletResponse response) throws Exception { | ||
| 170 | - dataExport(response, null); | ||
| 171 | - } | ||
| 172 | - | ||
| 173 | - @RequestMapping(value = "/dataExportExt", method = RequestMethod.GET) | ||
| 174 | - public void dataExport(HttpServletResponse response, @RequestParam Map<String, Object> param) throws Exception { | ||
| 175 | - // 1、使用ktr转换获取输出文件 | ||
| 176 | - File ktrfile = new File(this.getClass().getResource(getDataExportKtrClasspath()).toURI()); | ||
| 177 | - File outputfile = null; | ||
| 178 | - if (!CollectionUtils.isEmpty(param)) { | ||
| 179 | - outputfile = dataImportExportService.fileDataOutput( | ||
| 180 | - getDataExportFilename(), | ||
| 181 | - ktrfile, | ||
| 182 | - param); | ||
| 183 | - } else { | ||
| 184 | - outputfile = dataImportExportService.fileDataOutput( | ||
| 185 | - getDataExportFilename(), | ||
| 186 | - ktrfile); | ||
| 187 | - } | ||
| 188 | - | ||
| 189 | - System.out.println(outputfile.getName()); | ||
| 190 | - System.out.println(outputfile.getAbsolutePath()); | ||
| 191 | - | ||
| 192 | - String filePath = outputfile.getAbsolutePath(); | ||
| 193 | -// String fp[] = filePath.split(File.separator); | ||
| 194 | -// String fileName = fp[fp.length - 1]; | ||
| 195 | - | ||
| 196 | - // TODO:使用ktr获取导出数据 | ||
| 197 | - | ||
| 198 | - response.setHeader("conent-type", "application/octet-stream"); | ||
| 199 | - response.setContentType("application/octet-stream"); | ||
| 200 | - response.setHeader("Content-Disposition", "attachment; filename=" + "东东"); | ||
| 201 | - | ||
| 202 | - OutputStream os = response.getOutputStream(); | ||
| 203 | - BufferedOutputStream bos = new BufferedOutputStream(os); | ||
| 204 | - | ||
| 205 | - InputStream is = null; | ||
| 206 | - | ||
| 207 | - is = new FileInputStream(filePath); | ||
| 208 | - BufferedInputStream bis = new BufferedInputStream(is); | ||
| 209 | - | ||
| 210 | - int length = 0; | ||
| 211 | - byte[] temp = new byte[1 * 1024 * 10]; | ||
| 212 | - | ||
| 213 | - while ((length = bis.read(temp)) != -1) { | ||
| 214 | - bos.write(temp, 0, length); | ||
| 215 | - } | ||
| 216 | - bos.flush(); | ||
| 217 | - bis.close(); | ||
| 218 | - bos.close(); | ||
| 219 | - is.close(); | ||
| 220 | - } | ||
| 221 | - | ||
| 222 | - /** | ||
| 223 | - * @return 数据导出的ktr转换文件类路径。 | ||
| 224 | - */ | ||
| 225 | - protected String getDataExportKtrClasspath() { | ||
| 226 | - // 默认返回异常,子类如果要使用导出功能,必须覆写此方法,指定ktr文件类路径 | ||
| 227 | - throw new RuntimeException("必须override,并指定ktr classpath"); | ||
| 228 | - } | ||
| 229 | - | ||
| 230 | - /** | ||
| 231 | - * @return 导出文件名。 | ||
| 232 | - */ | ||
| 233 | - protected String getDataExportFilename() { | ||
| 234 | - // 默认返回异常,子类如果要使用导出功能,必须覆写此方法,指定导出的文件路径名 | ||
| 235 | - throw new RuntimeException("必须override,并指定导出文件名"); | ||
| 236 | - } | ||
| 237 | - | ||
| 238 | - /** | ||
| 239 | - * @return 数据导入的ktr转换文件类路径。 | ||
| 240 | - */ | ||
| 241 | - protected String getDataImportKtrClasspath() { | ||
| 242 | - // 默认返回异常,子类如果要使用导入功能,必须覆写此方法,指定ktr文件类路径 | ||
| 243 | - throw new RuntimeException("必须override,并指定ktr classpath"); | ||
| 244 | - } | ||
| 245 | - | ||
| 246 | - | ||
| 247 | - public static class ExcelFileOutput { | ||
| 248 | - private String fileName; | ||
| 249 | - private List<Map<String, Object>> sheetnames = new ArrayList<>(); | ||
| 250 | - | ||
| 251 | - public String getFileName() { | ||
| 252 | - return fileName; | ||
| 253 | - } | ||
| 254 | - | ||
| 255 | - public void setFileName(String fileName) { | ||
| 256 | - this.fileName = fileName; | ||
| 257 | - } | ||
| 258 | - | ||
| 259 | - public List<Map<String, Object>> getSheetnames() { | ||
| 260 | - return sheetnames; | ||
| 261 | - } | ||
| 262 | - | ||
| 263 | - public void setSheetnames(List<Map<String, Object>> sheetnames) { | ||
| 264 | - this.sheetnames = sheetnames; | ||
| 265 | - } | ||
| 266 | - } | ||
| 267 | - | ||
| 268 | - /** | ||
| 269 | - * 上传Excel文件,返回文件全路径名,工作区名称列表。 | ||
| 270 | - * @param file | ||
| 271 | - * @return | ||
| 272 | - * @throws Exception | ||
| 273 | - */ | ||
| 274 | - @RequestMapping(value = "/uploadFile", method = RequestMethod.POST) | ||
| 275 | - public ExcelFileOutput fileUpload(MultipartFile file) throws Exception { | ||
| 276 | - // 返回对象 | ||
| 277 | - ExcelFileOutput rs = new ExcelFileOutput(); | ||
| 278 | - | ||
| 279 | - // 上传文件 | ||
| 280 | - File file1 = dataImportExportService.uploadFile(file); | ||
| 281 | - // 获取文件的sheet | ||
| 282 | - Workbook book = Workbook.getWorkbook(file1); | ||
| 283 | - for (Sheet sheet : book.getSheets()) { | ||
| 284 | - String sheetname = sheet.getName(); | ||
| 285 | - Map<String, Object> s = new HashMap<>(); | ||
| 286 | - s.put("name", sheetname); | ||
| 287 | - rs.getSheetnames().add(s); | ||
| 288 | - } | ||
| 289 | - | ||
| 290 | - rs.setFileName(file1.getAbsolutePath()); | ||
| 291 | - return rs; | ||
| 292 | - } | ||
| 293 | - | ||
| 294 | -} |
src/main/java/com/bsth/controller/CarsController.java
| 1 | package com.bsth.controller; | 1 | package com.bsth.controller; |
| 2 | 2 | ||
| 3 | -import com.bsth.common.ResponseCode; | ||
| 4 | import com.bsth.entity.Cars; | 3 | import com.bsth.entity.Cars; |
| 5 | -import com.bsth.service.schedule.utils.DataImportExportService; | ||
| 6 | -import com.bsth.service.schedule.utils.DataToolsProperties; | ||
| 7 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 8 | -import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
| 9 | import org.springframework.web.bind.annotation.RequestMapping; | 4 | import org.springframework.web.bind.annotation.RequestMapping; |
| 10 | -import org.springframework.web.bind.annotation.RequestMethod; | ||
| 11 | -import org.springframework.web.bind.annotation.RequestParam; | ||
| 12 | import org.springframework.web.bind.annotation.RestController; | 5 | import org.springframework.web.bind.annotation.RestController; |
| 13 | 6 | ||
| 14 | -import java.io.File; | ||
| 15 | -import java.util.HashMap; | ||
| 16 | -import java.util.Map; | ||
| 17 | - | ||
| 18 | /** | 7 | /** |
| 19 | * Created by xu on 16/5/31. | 8 | * Created by xu on 16/5/31. |
| 20 | */ | 9 | */ |
| 21 | @RestController | 10 | @RestController |
| 22 | @RequestMapping("cars") | 11 | @RequestMapping("cars") |
| 23 | -@EnableConfigurationProperties(DataToolsProperties.class) | ||
| 24 | -public class CarsController extends BaseController2<Cars, Integer> { | ||
| 25 | - | ||
| 26 | - @Autowired | ||
| 27 | - private DataToolsProperties dataToolsProperties; | ||
| 28 | - @Autowired | ||
| 29 | - private DataImportExportService dataImportExportService; | ||
| 30 | - | ||
| 31 | - /** | ||
| 32 | - * 验证。 | ||
| 33 | - * @param map | ||
| 34 | - * @return | ||
| 35 | - */ | ||
| 36 | - @RequestMapping(value = "/validate/equale", method = RequestMethod.GET) | ||
| 37 | - public Map<String, Object> validateData(@RequestParam Map<String, Object> map) { | ||
| 38 | - // 一般比较自编号是否重复 | ||
| 39 | - return baseService.validateEquale(map); | ||
| 40 | - } | ||
| 41 | - | ||
| 42 | - // uploadFile post | ||
| 43 | - | ||
| 44 | - // 验证excel sheet | ||
| 45 | - @RequestMapping(value = "/validate/sheet", method = RequestMethod.GET) | ||
| 46 | - public Map<String, Object> validateSheet() throws Exception { | ||
| 47 | - Map<String, Object> rtn = new HashMap<>(); | ||
| 48 | - | ||
| 49 | - // TODO: | ||
| 50 | - | ||
| 51 | - rtn.put("status", ResponseCode.SUCCESS); | ||
| 52 | - return rtn; | ||
| 53 | - } | ||
| 54 | - | ||
| 55 | - @RequestMapping(value = "/importfile", method = RequestMethod.POST) | ||
| 56 | - public Map<String, Object> importData( | ||
| 57 | - @RequestParam Map<String, Object> form) | ||
| 58 | - throws Exception { | ||
| 59 | - Map<String, Object> rtn = new HashMap<>(); | ||
| 60 | - | ||
| 61 | - // TODO: | ||
| 62 | - String filename = (String) form.get("filename"); | ||
| 63 | - | ||
| 64 | - | ||
| 65 | - try { | ||
| 66 | - // 获取ktr转换文件绝对路径 | ||
| 67 | - File ktrfile = new File(this.getClass().getResource(getDataImportKtrClasspath()).toURI()); | ||
| 68 | - System.out.println(ktrfile.getAbsolutePath()); | ||
| 69 | - // 导入数据 | ||
| 70 | - dataImportExportService.fileDataImport(new File(filename), ktrfile); | ||
| 71 | - | ||
| 72 | - rtn.put("status", ResponseCode.SUCCESS); | ||
| 73 | - rtn.put("msg", "导入成功"); | ||
| 74 | - } catch (Exception exp) { | ||
| 75 | - exp.printStackTrace(); | ||
| 76 | - rtn.put("status", ResponseCode.ERROR); | ||
| 77 | - rtn.put("msg", exp.getLocalizedMessage()); | ||
| 78 | - } | ||
| 79 | - | ||
| 80 | - return rtn; | ||
| 81 | - } | ||
| 82 | - | ||
| 83 | - | ||
| 84 | - @Override | ||
| 85 | - protected String getDataImportKtrClasspath() { | ||
| 86 | - return dataToolsProperties.getCarsDatainputktr(); | ||
| 87 | - } | ||
| 88 | - | ||
| 89 | - @Override | ||
| 90 | - protected String getDataExportKtrClasspath() { | ||
| 91 | - return dataToolsProperties.getCarsDataoutputktr(); | ||
| 92 | - } | 12 | +public class CarsController extends BaseController<Cars, Integer> { |
| 93 | 13 | ||
| 94 | - @Override | ||
| 95 | - protected String getDataExportFilename() { | ||
| 96 | - return "车辆基础数据"; | ||
| 97 | - } | ||
| 98 | } | 14 | } |
src/main/java/com/bsth/controller/PersonnelController.java
| @@ -2,10 +2,11 @@ package com.bsth.controller; | @@ -2,10 +2,11 @@ package com.bsth.controller; | ||
| 2 | 2 | ||
| 3 | import com.bsth.entity.Personnel; | 3 | import com.bsth.entity.Personnel; |
| 4 | import com.bsth.service.PersonnelService; | 4 | import com.bsth.service.PersonnelService; |
| 5 | -import com.bsth.service.schedule.utils.DataToolsProperties; | ||
| 6 | import org.springframework.beans.factory.annotation.Autowired; | 5 | import org.springframework.beans.factory.annotation.Autowired; |
| 7 | -import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
| 8 | -import org.springframework.web.bind.annotation.*; | 6 | +import org.springframework.web.bind.annotation.RequestMapping; |
| 7 | +import org.springframework.web.bind.annotation.RequestMethod; | ||
| 8 | +import org.springframework.web.bind.annotation.RequestParam; | ||
| 9 | +import org.springframework.web.bind.annotation.RestController; | ||
| 9 | 10 | ||
| 10 | import java.util.List; | 11 | import java.util.List; |
| 11 | import java.util.Map; | 12 | import java.util.Map; |
| @@ -15,54 +16,11 @@ import java.util.Map; | @@ -15,54 +16,11 @@ import java.util.Map; | ||
| 15 | */ | 16 | */ |
| 16 | @RestController | 17 | @RestController |
| 17 | @RequestMapping("personnel") | 18 | @RequestMapping("personnel") |
| 18 | -@EnableConfigurationProperties(DataToolsProperties.class) | ||
| 19 | public class PersonnelController extends BaseController<Personnel, Integer> { | 19 | public class PersonnelController extends BaseController<Personnel, Integer> { |
| 20 | 20 | ||
| 21 | @Autowired | 21 | @Autowired |
| 22 | - private DataToolsProperties dataToolsProperties; | ||
| 23 | - | ||
| 24 | - @Autowired | ||
| 25 | private PersonnelService service; | 22 | private PersonnelService service; |
| 26 | - /** | ||
| 27 | - * 覆写方法,因为form提交的方式参数不全,改用 json形式提交 @RequestBody | ||
| 28 | - * @Title: save | ||
| 29 | - * @Description: TODO(持久化对象) | ||
| 30 | - * @param @param t | ||
| 31 | - * @param @return 设定文件 | ||
| 32 | - * @return Map<String,Object> {status: 1(成功),-1(失败)} | ||
| 33 | - * @throws | ||
| 34 | - */ | ||
| 35 | - @RequestMapping(method = RequestMethod.POST) | ||
| 36 | - public Map<String, Object> save(@RequestBody Personnel t){ | ||
| 37 | - return baseService.save(t); | ||
| 38 | - } | ||
| 39 | - | ||
| 40 | - /** | ||
| 41 | - * 验证。 | ||
| 42 | - * @param map | ||
| 43 | - * @return | ||
| 44 | - */ | ||
| 45 | - @RequestMapping(value = "/validate/equale", method = RequestMethod.GET) | ||
| 46 | - public Map<String, Object> validateData(@RequestParam Map<String, Object> map) { | ||
| 47 | - // 一般比较相同公司下工号是否相同 | ||
| 48 | - return baseService.validateEquale(map); | ||
| 49 | - } | ||
| 50 | - | ||
| 51 | - @Override | ||
| 52 | - protected String getDataImportKtrClasspath() { | ||
| 53 | - return dataToolsProperties.getEmployeesDatainputktr(); | ||
| 54 | - } | ||
| 55 | - | ||
| 56 | - @Override | ||
| 57 | - protected String getDataExportKtrClasspath() { | ||
| 58 | - return dataToolsProperties.getEmployeesDataoutputktr(); | ||
| 59 | - } | ||
| 60 | 23 | ||
| 61 | - @Override | ||
| 62 | - protected String getDataExportFilename() { | ||
| 63 | - return "人员基础信息"; | ||
| 64 | - } | ||
| 65 | - | ||
| 66 | @RequestMapping(value = "/sreachPersonnel", method = RequestMethod.GET) | 24 | @RequestMapping(value = "/sreachPersonnel", method = RequestMethod.GET) |
| 67 | public List<Map<String, String>> sreachPersonnel(@RequestParam String jobCode) { | 25 | public List<Map<String, String>> sreachPersonnel(@RequestParam String jobCode) { |
| 68 | return service.sreachPersonnel(jobCode); | 26 | return service.sreachPersonnel(jobCode); |
src/main/java/com/bsth/data/schedule/late_adjust/LateAdjustHandle.java
src/main/java/com/bsth/entity/schedule/rule/ScheduleRule1Flat.java
| @@ -67,6 +67,7 @@ public class ScheduleRule1Flat extends BEntity { | @@ -67,6 +67,7 @@ public class ScheduleRule1Flat extends BEntity { | ||
| 67 | private String ryDbbms; | 67 | private String ryDbbms; |
| 68 | /** 对应的人员配置ids(用逗号隔开,如果分班,就先-隔开再逗号隔开) */ | 68 | /** 对应的人员配置ids(用逗号隔开,如果分班,就先-隔开再逗号隔开) */ |
| 69 | @NotNull | 69 | @NotNull |
| 70 | + @Column(length = 1000) | ||
| 70 | private String ryConfigIds; | 71 | private String ryConfigIds; |
| 71 | /** 起始人员(从0开始) */ | 72 | /** 起始人员(从0开始) */ |
| 72 | @NotNull | 73 | @NotNull |
src/main/java/com/bsth/entity/schedule/temp/SchedulePlanRuleResult.java
| @@ -2,10 +2,7 @@ package com.bsth.entity.schedule.temp; | @@ -2,10 +2,7 @@ package com.bsth.entity.schedule.temp; | ||
| 2 | 2 | ||
| 3 | import com.bsth.entity.schedule.SchedulePlan; | 3 | import com.bsth.entity.schedule.SchedulePlan; |
| 4 | 4 | ||
| 5 | -import javax.persistence.Entity; | ||
| 6 | -import javax.persistence.GeneratedValue; | ||
| 7 | -import javax.persistence.Id; | ||
| 8 | -import javax.persistence.Table; | 5 | +import javax.persistence.*; |
| 9 | import java.util.Date; | 6 | import java.util.Date; |
| 10 | 7 | ||
| 11 | /** | 8 | /** |
| @@ -32,12 +29,14 @@ public class SchedulePlanRuleResult { | @@ -32,12 +29,14 @@ public class SchedulePlanRuleResult { | ||
| 32 | private String ccZbh; | 29 | private String ccZbh; |
| 33 | 30 | ||
| 34 | /** 路牌id列表字符串 */ | 31 | /** 路牌id列表字符串 */ |
| 32 | + @Column(length = 1000) | ||
| 35 | private String gids; | 33 | private String gids; |
| 36 | /** 路牌名字列表字符串 */ | 34 | /** 路牌名字列表字符串 */ |
| 37 | private String gnames; | 35 | private String gnames; |
| 38 | /** 翻到哪个路牌索引 */ | 36 | /** 翻到哪个路牌索引 */ |
| 39 | private String gidindex; | 37 | private String gidindex; |
| 40 | /** 人员配置id列表字符串 */ | 38 | /** 人员配置id列表字符串 */ |
| 39 | + @Column(length = 1000) | ||
| 41 | private String ecids; | 40 | private String ecids; |
| 42 | /** 人员配置搭班编码列表字符串 */ | 41 | /** 人员配置搭班编码列表字符串 */ |
| 43 | private String ecdbbms; | 42 | private String ecdbbms; |
src/main/java/com/bsth/service/forms/impl/FormsServiceImpl.java
| @@ -219,13 +219,11 @@ public class FormsServiceImpl implements FormsService { | @@ -219,13 +219,11 @@ public class FormsServiceImpl implements FormsService { | ||
| 219 | // if(d.getJgh().equals(s.getjGh()) && d.getZbh().equals(s.getClZbh())){ | 219 | // if(d.getJgh().equals(s.getjGh()) && d.getZbh().equals(s.getClZbh())){ |
| 220 | // sList.add(s); | 220 | // sList.add(s); |
| 221 | // } | 221 | // } |
| 222 | - | ||
| 223 | if(empnames.equals("驾驶员")){ | 222 | if(empnames.equals("驾驶员")){ |
| 224 | - if(d.getJgh().equals(s.getjGh()) && d.getZbh().equals(s.getClZbh())){ | 223 | + if(d.getJgh().equals(s.getjGh())){ |
| 225 | sList.add(s); | 224 | sList.add(s); |
| 226 | } | 225 | } |
| 227 | }else if(empnames.equals("售票员")){ | 226 | }else if(empnames.equals("售票员")){ |
| 228 | -// shif.setjName(arg0.getString("s_name")==null ? "":arg0.getString("s_name")); | ||
| 229 | String sgh=s.getsGh()==null?"":s.getsGh(); | 227 | String sgh=s.getsGh()==null?"":s.getsGh(); |
| 230 | if(d.getSgh().equals(sgh) && d.getZbh().equals(s.getClZbh())){ | 228 | if(d.getSgh().equals(sgh) && d.getZbh().equals(s.getClZbh())){ |
| 231 | sList.add(s); | 229 | sList.add(s); |
| @@ -244,16 +242,17 @@ public class FormsServiceImpl implements FormsService { | @@ -244,16 +242,17 @@ public class FormsServiceImpl implements FormsService { | ||
| 244 | double ljgl=culateMileageService.culateLjgl(sList); | 242 | double ljgl=culateMileageService.culateLjgl(sList); |
| 245 | double sjgl=culateMileageService.culateSjgl(sList); | 243 | double sjgl=culateMileageService.culateSjgl(sList); |
| 246 | double zyygl=Arith.add(ljgl, sjgl); | 244 | double zyygl=Arith.add(ljgl, sjgl); |
| 247 | - double cjbc=culateMileageService.culateLbbc(sList); | ||
| 248 | - double Ljbc=culateMileageService.culateLjbc(sList,""); | 245 | + int cjbc=culateMileageService.culateLbbc(sList); |
| 246 | + int ljbc=culateMileageService.culateLjbc(sList,""); | ||
| 247 | + int sjbc=culateMileageService.culateSjbc(sList, ""); | ||
| 249 | double cjgl=culateMileageService.culateLbgl(sList); | 248 | double cjgl=culateMileageService.culateLbgl(sList); |
| 250 | double zjgl=culateMileageService.culateLjgl(sList); | 249 | double zjgl=culateMileageService.culateLjgl(sList); |
| 251 | d.setEmptMileage(String.valueOf(zksgl));//空驶公里 | 250 | d.setEmptMileage(String.valueOf(zksgl));//空驶公里 |
| 252 | d.setTotalm(String.valueOf(Arith.add(zksgl, zyygl)));//总公里 | 251 | d.setTotalm(String.valueOf(Arith.add(zksgl, zyygl)));//总公里 |
| 253 | - d.setSjbc(String.valueOf(culateMileageService.culateSjbc(sList, "")+culateMileageService.culateLjbc(sList, ""))); | 252 | + d.setSjbc(String.valueOf(sjbc+ljbc)); |
| 254 | d.setJhlc(String.valueOf(zyygl));//运营里程 | 253 | d.setJhlc(String.valueOf(zyygl));//运营里程 |
| 255 | d.setCjbc(String.valueOf(cjbc));//抽检班次 | 254 | d.setCjbc(String.valueOf(cjbc));//抽检班次 |
| 256 | - d.setLjbc(String.valueOf(Ljbc));//增加班次 | 255 | + d.setLjbc(String.valueOf(ljbc));//增加班次 |
| 257 | d.setRemMileage(String.valueOf(cjgl));//抽检里程 | 256 | d.setRemMileage(String.valueOf(cjgl));//抽检里程 |
| 258 | d.setAddMileage(String.valueOf(zjgl));//增加里程 | 257 | d.setAddMileage(String.valueOf(zjgl));//增加里程 |
| 259 | 258 | ||
| @@ -330,22 +329,23 @@ public class FormsServiceImpl implements FormsService { | @@ -330,22 +329,23 @@ public class FormsServiceImpl implements FormsService { | ||
| 330 | double zyygl=Arith.add(ljgl, sjgl); | 329 | double zyygl=Arith.add(ljgl, sjgl); |
| 331 | double jhgl=culateMileageService.culateJhgl(sList); | 330 | double jhgl=culateMileageService.culateJhgl(sList); |
| 332 | double cjgl=culateMileageService.culateLbgl(sList); | 331 | double cjgl=culateMileageService.culateLbgl(sList); |
| 333 | - double jhbc =culateMileageService.culateJhbc(sList,""); | ||
| 334 | - double cjbc=culateMileageService.culateLbbc(sList); | ||
| 335 | - double Ljbc=culateMileageService.culateLjbc(sList,""); | 332 | + int jhbc =culateMileageService.culateJhbc(sList,""); |
| 333 | + int cjbc=culateMileageService.culateLbbc(sList); | ||
| 334 | + int ljbc=culateMileageService.culateLjbc(sList,""); | ||
| 335 | + int sjbc=culateMileageService.culateSjbc(sList, ""); | ||
| 336 | double zjgl=culateMileageService.culateLjgl(sList); | 336 | double zjgl=culateMileageService.culateLjgl(sList); |
| 337 | d.setEmptMileage(String.valueOf(zksgl));//空驶公里 | 337 | d.setEmptMileage(String.valueOf(zksgl));//空驶公里 |
| 338 | d.setTotalm(String.valueOf(Arith.add(zksgl, zyygl)));//总公里 | 338 | d.setTotalm(String.valueOf(Arith.add(zksgl, zyygl)));//总公里 |
| 339 | - d.setSjbc(String.valueOf(culateMileageService.culateSjbc(sList, "")+culateMileageService.culateLjbc(sList, ""))); | 339 | + d.setSjbc(String.valueOf(sjbc+ljbc)); |
| 340 | d.setJhlc(String.valueOf(jhgl));//计划里程 | 340 | d.setJhlc(String.valueOf(jhgl));//计划里程 |
| 341 | d.setYygl(String.valueOf(zyygl));//运营公里 | 341 | d.setYygl(String.valueOf(zyygl));//运营公里 |
| 342 | d.setSjjhlc(String.valueOf(sjgl));//实际计划里程 | 342 | d.setSjjhlc(String.valueOf(sjgl));//实际计划里程 |
| 343 | d.setRemMileage(String.valueOf(cjgl));//抽减里程 | 343 | d.setRemMileage(String.valueOf(cjgl));//抽减里程 |
| 344 | d.setJhbc(String.valueOf(jhbc));//计划班次 | 344 | d.setJhbc(String.valueOf(jhbc));//计划班次 |
| 345 | d.setCjbc(String.valueOf(cjbc));//抽检班次 | 345 | d.setCjbc(String.valueOf(cjbc));//抽检班次 |
| 346 | - d.setLjbc(String.valueOf(Ljbc));//增加班次 | 346 | + d.setLjbc(String.valueOf(ljbc));//增加班次 |
| 347 | d.setAddMileage(String.valueOf(zjgl));//增加公里 | 347 | d.setAddMileage(String.valueOf(zjgl));//增加公里 |
| 348 | - d.setSjjhbc(String.valueOf(culateMileageService.culateSjbc(sList, "")));//实际计划班次 | 348 | + d.setSjjhbc(String.valueOf(sjbc));//实际计划班次 |
| 349 | } | 349 | } |
| 350 | return list; | 350 | return list; |
| 351 | } | 351 | } |
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
| @@ -510,7 +510,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | @@ -510,7 +510,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | ||
| 510 | + " from bsth_c_s_sp_info_real s " | 510 | + " from bsth_c_s_sp_info_real s " |
| 511 | + " where s.xl_Bm = '" + line + "' and DATE_FORMAT(s.schedule_Date,'%Y-%m-%d') ='" + date + "' " | 511 | + " where s.xl_Bm = '" + line + "' and DATE_FORMAT(s.schedule_Date,'%Y-%m-%d') ='" + date + "' " |
| 512 | + " GROUP BY s.j_Gh,s.cl_Zbh,s.lp_Name ,s.j_Name" | 512 | + " GROUP BY s.j_Gh,s.cl_Zbh,s.lp_Name ,s.j_Name" |
| 513 | - + " order by (" + state + "),schedule_date_str,fcsj " + type; | 513 | + + " order by (" + state + "),dateStr,fcsj " + type; |
| 514 | List<ScheduleRealInfo> list = jdbcTemplate.query(sqlPlan, | 514 | List<ScheduleRealInfo> list = jdbcTemplate.query(sqlPlan, |
| 515 | new RowMapper<ScheduleRealInfo>() { | 515 | new RowMapper<ScheduleRealInfo>() { |
| 516 | @Override | 516 | @Override |
| @@ -1403,7 +1403,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | @@ -1403,7 +1403,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | ||
| 1403 | lists.add(s); | 1403 | lists.add(s); |
| 1404 | } | 1404 | } |
| 1405 | } | 1405 | } |
| 1406 | - double ksgl=culateService.culateKsgl(lists); | 1406 | + double ksgl=culateService.culateKsgl(list); |
| 1407 | double sjgl=culateService.culateSjgl(lists); | 1407 | double sjgl=culateService.culateSjgl(lists); |
| 1408 | double jccgl=culateService.culateJccgl(lists); | 1408 | double jccgl=culateService.culateJccgl(lists); |
| 1409 | double ljgl=culateService.culateLjgl(lists); | 1409 | double ljgl=culateService.culateLjgl(lists); |
src/main/java/com/bsth/service/report/impl/CulateMileageServiceImpl.java
| 1 | package com.bsth.service.report.impl; | 1 | package com.bsth.service.report.impl; |
| 2 | 2 | ||
| 3 | import java.util.ArrayList; | 3 | import java.util.ArrayList; |
| 4 | +import java.util.Collections; | ||
| 4 | import java.util.HashMap; | 5 | import java.util.HashMap; |
| 5 | import java.util.Iterator; | 6 | import java.util.Iterator; |
| 6 | import java.util.List; | 7 | import java.util.List; |
| @@ -14,6 +15,7 @@ import com.bsth.entity.realcontrol.ChildTaskPlan; | @@ -14,6 +15,7 @@ import com.bsth.entity.realcontrol.ChildTaskPlan; | ||
| 14 | import com.bsth.entity.realcontrol.ScheduleRealInfo; | 15 | import com.bsth.entity.realcontrol.ScheduleRealInfo; |
| 15 | import com.bsth.service.report.CulateMileageService; | 16 | import com.bsth.service.report.CulateMileageService; |
| 16 | import com.bsth.util.Arith; | 17 | import com.bsth.util.Arith; |
| 18 | +import com.bsth.util.ComparableJob; | ||
| 17 | 19 | ||
| 18 | @Service | 20 | @Service |
| 19 | public class CulateMileageServiceImpl implements CulateMileageService{ | 21 | public class CulateMileageServiceImpl implements CulateMileageService{ |
| @@ -25,6 +27,7 @@ public class CulateMileageServiceImpl implements CulateMileageService{ | @@ -25,6 +27,7 @@ public class CulateMileageServiceImpl implements CulateMileageService{ | ||
| 25 | @Override | 27 | @Override |
| 26 | public List<Map<String, Object>> jobFwqk(List<ScheduleRealInfo> lists) { | 28 | public List<Map<String, Object>> jobFwqk(List<ScheduleRealInfo> lists) { |
| 27 | // TODO Auto-generated method stub | 29 | // TODO Auto-generated method stub |
| 30 | + String[] lblxs = {"配车", "保养","故障","肇事","路阻","纠纷","缺人","客稀","缺车","气候","援外","吊慢","抽减","其他" }; | ||
| 28 | List<Map<String, Object>> list=new ArrayList<Map<String,Object>>(); | 31 | List<Map<String, Object>> list=new ArrayList<Map<String,Object>>(); |
| 29 | for (int i = 0; i < lists.size(); i++) { | 32 | for (int i = 0; i < lists.size(); i++) { |
| 30 | ScheduleRealInfo scheduleRealInfo = lists.get(i); | 33 | ScheduleRealInfo scheduleRealInfo = lists.get(i); |
| @@ -47,7 +50,7 @@ public class CulateMileageServiceImpl implements CulateMileageService{ | @@ -47,7 +50,7 @@ public class CulateMileageServiceImpl implements CulateMileageService{ | ||
| 47 | newMap.put("dz", scheduleRealInfo.getQdzName()); | 50 | newMap.put("dz", scheduleRealInfo.getQdzName()); |
| 48 | newMap.put("sj", scheduleRealInfo.getFcsj()); | 51 | newMap.put("sj", scheduleRealInfo.getFcsj()); |
| 49 | newMap.put("lbbc", 1); | 52 | newMap.put("lbbc", 1); |
| 50 | - newMap.put("lblc", scheduleRealInfo.getJhlcOrig()); | 53 | + newMap.put("lblc", scheduleRealInfo.getJhlcOrig()==null?0:scheduleRealInfo.getJhlcOrig()); |
| 51 | newMap.put("jyqp", scheduleRealInfo.getRealMileage()); | 54 | newMap.put("jyqp", scheduleRealInfo.getRealMileage()); |
| 52 | list.add(newMap); | 55 | list.add(newMap); |
| 53 | } | 56 | } |
| @@ -71,7 +74,7 @@ public class CulateMileageServiceImpl implements CulateMileageService{ | @@ -71,7 +74,7 @@ public class CulateMileageServiceImpl implements CulateMileageService{ | ||
| 71 | newMap.put("dz", childTaskPlan.getStartStationName()); | 74 | newMap.put("dz", childTaskPlan.getStartStationName()); |
| 72 | newMap.put("sj", childTaskPlan.getStartDate()); | 75 | newMap.put("sj", childTaskPlan.getStartDate()); |
| 73 | newMap.put("lbbc", 0); | 76 | newMap.put("lbbc", 0); |
| 74 | - newMap.put("lblc", childTaskPlan.getMileage()); | 77 | + newMap.put("lblc", childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage()); |
| 75 | newMap.put("jyqp", scheduleRealInfo.getRealMileage()); | 78 | newMap.put("jyqp", scheduleRealInfo.getRealMileage()); |
| 76 | list.add(newMap); | 79 | list.add(newMap); |
| 77 | 80 | ||
| @@ -80,7 +83,33 @@ public class CulateMileageServiceImpl implements CulateMileageService{ | @@ -80,7 +83,33 @@ public class CulateMileageServiceImpl implements CulateMileageService{ | ||
| 80 | } | 83 | } |
| 81 | } | 84 | } |
| 82 | } | 85 | } |
| 83 | - return list; | 86 | + List<Map<String, Object>> listNew=new ArrayList<Map<String,Object>>(); |
| 87 | + for (int i = 0; i < lblxs.length; i++) { | ||
| 88 | + String lx=lblxs[i]; | ||
| 89 | + double lblc=0.0; | ||
| 90 | + int lbbc=0; | ||
| 91 | + for (int j = 0; j < list.size(); j++) { | ||
| 92 | + Map<String, Object> m1=list.get(j); | ||
| 93 | + m1.put("lx", 0); | ||
| 94 | + listNew.add(m1); | ||
| 95 | + if(lx.equals(m1.get("nr").toString())){ | ||
| 96 | + lblc =Arith.add(lblc,Double.parseDouble(m1.get("lblc").toString())); | ||
| 97 | + lbbc += Integer.parseInt(m1.get("lbbc").toString()); | ||
| 98 | + } | ||
| 99 | + } | ||
| 100 | + Map<String, Object> newMap = new HashMap<String, Object>(); | ||
| 101 | + newMap.put("lx", 1); | ||
| 102 | + newMap.put("nr", lx); | ||
| 103 | + newMap.put("lp", "小计"); | ||
| 104 | + newMap.put("nbbm", "少驶公里"); | ||
| 105 | + newMap.put("dz", lbbc); | ||
| 106 | + newMap.put("sj", "少驶公里"); | ||
| 107 | + newMap.put("lblc", lblc); | ||
| 108 | + listNew.add(newMap); | ||
| 109 | + | ||
| 110 | + } | ||
| 111 | + Collections.sort(listNew, new ComparableJob()); | ||
| 112 | + return listNew; | ||
| 84 | } | 113 | } |
| 85 | 114 | ||
| 86 | @Override | 115 | @Override |
src/main/java/com/bsth/service/report/impl/ReportServiceImpl.java
| @@ -8,6 +8,7 @@ import java.text.ParseException; | @@ -8,6 +8,7 @@ import java.text.ParseException; | ||
| 8 | import java.text.SimpleDateFormat; | 8 | import java.text.SimpleDateFormat; |
| 9 | import java.util.ArrayList; | 9 | import java.util.ArrayList; |
| 10 | import java.util.Calendar; | 10 | import java.util.Calendar; |
| 11 | +import java.util.Collections; | ||
| 11 | import java.util.Date; | 12 | import java.util.Date; |
| 12 | import java.util.HashMap; | 13 | import java.util.HashMap; |
| 13 | import java.util.Iterator; | 14 | import java.util.Iterator; |
| @@ -38,6 +39,7 @@ import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; | @@ -38,6 +39,7 @@ import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; | ||
| 38 | import com.bsth.service.report.CulateMileageService; | 39 | import com.bsth.service.report.CulateMileageService; |
| 39 | import com.bsth.service.report.ReportService; | 40 | import com.bsth.service.report.ReportService; |
| 40 | import com.bsth.util.Arith; | 41 | import com.bsth.util.Arith; |
| 42 | +import com.bsth.util.ComparableJob; | ||
| 41 | import com.bsth.util.db.DBUtils_MS; | 43 | import com.bsth.util.db.DBUtils_MS; |
| 42 | 44 | ||
| 43 | @Service | 45 | @Service |
| @@ -1150,6 +1152,7 @@ public class ReportServiceImpl implements ReportService{ | @@ -1150,6 +1152,7 @@ public class ReportServiceImpl implements ReportService{ | ||
| 1150 | @Override | 1152 | @Override |
| 1151 | public List<Map<String, Object>> jobFwqk(Map<String, Object> map) { | 1153 | public List<Map<String, Object>> jobFwqk(Map<String, Object> map) { |
| 1152 | // TODO Auto-generated method stub | 1154 | // TODO Auto-generated method stub |
| 1155 | + String[] lblxs = {"配车", "保养","故障","肇事","路阻","纠纷","缺人","客稀","缺车","气候","援外","吊慢","抽减","其他" }; | ||
| 1153 | String line=map.get("line").toString(); | 1156 | String line=map.get("line").toString(); |
| 1154 | String date=map.get("date").toString(); | 1157 | String date=map.get("date").toString(); |
| 1155 | map.put("bcType", "normal"); | 1158 | map.put("bcType", "normal"); |
| @@ -1179,7 +1182,7 @@ public class ReportServiceImpl implements ReportService{ | @@ -1179,7 +1182,7 @@ public class ReportServiceImpl implements ReportService{ | ||
| 1179 | newMap.put("sj", scheduleRealInfo.getFcsj()); | 1182 | newMap.put("sj", scheduleRealInfo.getFcsj()); |
| 1180 | newMap.put("lbbc", 1); | 1183 | newMap.put("lbbc", 1); |
| 1181 | newMap.put("lblc", scheduleRealInfo.getJhlcOrig()); | 1184 | newMap.put("lblc", scheduleRealInfo.getJhlcOrig()); |
| 1182 | - newMap.put("jyqp", scheduleRealInfo.getRealMileage()); | 1185 | + newMap.put("jyqp", scheduleRealInfo.getRemarks()); |
| 1183 | list.add(newMap); | 1186 | list.add(newMap); |
| 1184 | } | 1187 | } |
| 1185 | 1188 | ||
| @@ -1205,7 +1208,7 @@ public class ReportServiceImpl implements ReportService{ | @@ -1205,7 +1208,7 @@ public class ReportServiceImpl implements ReportService{ | ||
| 1205 | newMap.put("sj", childTaskPlan.getStartDate()); | 1208 | newMap.put("sj", childTaskPlan.getStartDate()); |
| 1206 | newMap.put("lbbc", 0); | 1209 | newMap.put("lbbc", 0); |
| 1207 | newMap.put("lblc", childTaskPlan.getMileage()); | 1210 | newMap.put("lblc", childTaskPlan.getMileage()); |
| 1208 | - newMap.put("jyqp", scheduleRealInfo.getRealMileage()); | 1211 | + newMap.put("jyqp", childTaskPlan.getRemarks()); |
| 1209 | list.add(newMap); | 1212 | list.add(newMap); |
| 1210 | 1213 | ||
| 1211 | } | 1214 | } |
| @@ -1213,7 +1216,36 @@ public class ReportServiceImpl implements ReportService{ | @@ -1213,7 +1216,36 @@ public class ReportServiceImpl implements ReportService{ | ||
| 1213 | } | 1216 | } |
| 1214 | } | 1217 | } |
| 1215 | } | 1218 | } |
| 1216 | - return list; | 1219 | + List<Map<String, Object>> listNew=new ArrayList<Map<String,Object>>(); |
| 1220 | + for (int i = 0; i < lblxs.length; i++) { | ||
| 1221 | + String lx=lblxs[i]; | ||
| 1222 | + double lblc=0.0; | ||
| 1223 | + int lbbc=0; | ||
| 1224 | + for (int j = 0; j < list.size(); j++) { | ||
| 1225 | + Map<String, Object> m1=list.get(j); | ||
| 1226 | + if(lx.equals(m1.get("nr").toString())){ | ||
| 1227 | + m1.put("lx", 0); | ||
| 1228 | + listNew.add(m1); | ||
| 1229 | + lblc =Arith.add(lblc,Double.parseDouble(m1.get("lblc").toString())); | ||
| 1230 | + lbbc += Integer.parseInt(m1.get("lbbc").toString()); | ||
| 1231 | + } | ||
| 1232 | + } | ||
| 1233 | + if(lblc>0){ | ||
| 1234 | + Map<String, Object> newMap = new HashMap<String, Object>(); | ||
| 1235 | + newMap.put("lx", 1); | ||
| 1236 | + newMap.put("nr", lx); | ||
| 1237 | + newMap.put("lp", "小计"); | ||
| 1238 | + newMap.put("nbbm", "少驶班次"); | ||
| 1239 | + newMap.put("jgh", lbbc); | ||
| 1240 | + newMap.put("sj", "少驶公里"); | ||
| 1241 | + newMap.put("lblc", lblc); | ||
| 1242 | + listNew.add(newMap); | ||
| 1243 | + } | ||
| 1244 | + | ||
| 1245 | + | ||
| 1246 | + } | ||
| 1247 | + Collections.sort(listNew, new ComparableJob()); | ||
| 1248 | + return listNew; | ||
| 1217 | } | 1249 | } |
| 1218 | 1250 | ||
| 1219 | //统计临加班次详细信息 | 1251 | //统计临加班次详细信息 |
src/main/java/com/bsth/service/schedule/impl/SchedulePlanServiceImpl.java
| @@ -65,7 +65,7 @@ public class SchedulePlanServiceImpl extends BServiceImpl<SchedulePlan, Long> im | @@ -65,7 +65,7 @@ public class SchedulePlanServiceImpl extends BServiceImpl<SchedulePlan, Long> im | ||
| 65 | * @param schedulePlan 排班计划对象 | 65 | * @param schedulePlan 排班计划对象 |
| 66 | * @param lpInfoResults_output 时刻表每日路牌的情况 | 66 | * @param lpInfoResults_output 时刻表每日路牌的情况 |
| 67 | */ | 67 | */ |
| 68 | - private ScheduleResults_output loopRuleOutput( | 68 | + public ScheduleResults_output loopRuleOutput( |
| 69 | SchedulePlan schedulePlan, | 69 | SchedulePlan schedulePlan, |
| 70 | LpInfoResults_output lpInfoResults_output) { | 70 | LpInfoResults_output lpInfoResults_output) { |
| 71 | // 1-1、构造drools规则输入数据,输出数据 | 71 | // 1-1、构造drools规则输入数据,输出数据 |
| @@ -116,7 +116,7 @@ public class SchedulePlanServiceImpl extends BServiceImpl<SchedulePlan, Long> im | @@ -116,7 +116,7 @@ public class SchedulePlanServiceImpl extends BServiceImpl<SchedulePlan, Long> im | ||
| 116 | * @param schedulePlan 排班计划对象 | 116 | * @param schedulePlan 排班计划对象 |
| 117 | * @return TTInfoResults_output, LpInfoResults_output | 117 | * @return TTInfoResults_output, LpInfoResults_output |
| 118 | */ | 118 | */ |
| 119 | - private Object[] ttInfoOutput(SchedulePlan schedulePlan) { | 119 | + public Object[] ttInfoOutput(SchedulePlan schedulePlan) { |
| 120 | // 获取线路的所有未作废的时刻表 | 120 | // 获取线路的所有未作废的时刻表 |
| 121 | List<TTInfo> ttInfos = ttInfoRepository.findInCanceledByXl(schedulePlan.getXl()); | 121 | List<TTInfo> ttInfos = ttInfoRepository.findInCanceledByXl(schedulePlan.getXl()); |
| 122 | 122 | ||
| @@ -174,7 +174,7 @@ public class SchedulePlanServiceImpl extends BServiceImpl<SchedulePlan, Long> im | @@ -174,7 +174,7 @@ public class SchedulePlanServiceImpl extends BServiceImpl<SchedulePlan, Long> im | ||
| 174 | * @param ttInfoResults_output ttInfoOutput方法规则输出 | 174 | * @param ttInfoResults_output ttInfoOutput方法规则输出 |
| 175 | * @return PlanResult | 175 | * @return PlanResult |
| 176 | */ | 176 | */ |
| 177 | - private PlanResult planResultOutput( | 177 | + public PlanResult planResultOutput( |
| 178 | SchedulePlan schedulePlan, | 178 | SchedulePlan schedulePlan, |
| 179 | ScheduleResults_output scheduleResults_output, | 179 | ScheduleResults_output scheduleResults_output, |
| 180 | TTInfoResults_output ttInfoResults_output) { | 180 | TTInfoResults_output ttInfoResults_output) { |
src/main/java/com/bsth/service/schedule/rules/MyDroolsConfiguration.java
| @@ -4,7 +4,6 @@ import org.kie.api.KieBase; | @@ -4,7 +4,6 @@ import org.kie.api.KieBase; | ||
| 4 | import org.kie.api.KieBaseConfiguration; | 4 | import org.kie.api.KieBaseConfiguration; |
| 5 | import org.kie.api.KieServices; | 5 | import org.kie.api.KieServices; |
| 6 | import org.kie.api.builder.*; | 6 | import org.kie.api.builder.*; |
| 7 | -import org.kie.api.builder.Message; | ||
| 8 | import org.kie.api.builder.model.KieBaseModel; | 7 | import org.kie.api.builder.model.KieBaseModel; |
| 9 | import org.kie.api.builder.model.KieModuleModel; | 8 | import org.kie.api.builder.model.KieModuleModel; |
| 10 | import org.kie.api.builder.model.KieSessionModel; | 9 | import org.kie.api.builder.model.KieSessionModel; |
| @@ -12,6 +11,8 @@ import org.kie.api.conf.EqualityBehaviorOption; | @@ -12,6 +11,8 @@ import org.kie.api.conf.EqualityBehaviorOption; | ||
| 12 | import org.kie.api.conf.EventProcessingOption; | 11 | import org.kie.api.conf.EventProcessingOption; |
| 13 | import org.kie.api.runtime.KieContainer; | 12 | import org.kie.api.runtime.KieContainer; |
| 14 | import org.kie.api.runtime.conf.ClockTypeOption; | 13 | import org.kie.api.runtime.conf.ClockTypeOption; |
| 14 | +import org.slf4j.Logger; | ||
| 15 | +import org.slf4j.LoggerFactory; | ||
| 15 | import org.springframework.context.annotation.Bean; | 16 | import org.springframework.context.annotation.Bean; |
| 16 | import org.springframework.context.annotation.Configuration; | 17 | import org.springframework.context.annotation.Configuration; |
| 17 | 18 | ||
| @@ -20,6 +21,9 @@ import org.springframework.context.annotation.Configuration; | @@ -20,6 +21,9 @@ import org.springframework.context.annotation.Configuration; | ||
| 20 | */ | 21 | */ |
| 21 | @Configuration | 22 | @Configuration |
| 22 | public class MyDroolsConfiguration { | 23 | public class MyDroolsConfiguration { |
| 24 | + /** 日志记录器 */ | ||
| 25 | + private static final Logger logger = LoggerFactory.getLogger(MyDroolsConfiguration.class); | ||
| 26 | + | ||
| 23 | /** | 27 | /** |
| 24 | * 返回一个kiebase知识库,直接冲文件系统读入drl规则文件, | 28 | * 返回一个kiebase知识库,直接冲文件系统读入drl规则文件, |
| 25 | * TODO:以后需要从数据库读入规则文件,并重新创建kbase知识库。 | 29 | * TODO:以后需要从数据库读入规则文件,并重新创建kbase知识库。 |
| @@ -72,8 +76,12 @@ public class MyDroolsConfiguration { | @@ -72,8 +76,12 @@ public class MyDroolsConfiguration { | ||
| 72 | // 4、创建KieBuilder,使用KieFileSystem构建 | 76 | // 4、创建KieBuilder,使用KieFileSystem构建 |
| 73 | KieBuilder kieBuilder = kieServices.newKieBuilder(kfs).buildAll(); | 77 | KieBuilder kieBuilder = kieServices.newKieBuilder(kfs).buildAll(); |
| 74 | Results results = kieBuilder.getResults(); | 78 | Results results = kieBuilder.getResults(); |
| 75 | - if (results.hasMessages(Message.Level.ERROR)) | ||
| 76 | - throw new IllegalStateException("构建drools6错误:" + results.getMessages()); | 79 | +// if (results.hasMessages(Message.Level.ERROR)) |
| 80 | +// throw new IllegalStateException("构建drools6错误:" + results.getMessages()); | ||
| 81 | + if (results.hasMessages(Message.Level.ERROR)) { | ||
| 82 | + logger.info("构建drools6错误:" + results.getMessages()); | ||
| 83 | + return null; | ||
| 84 | + } | ||
| 77 | 85 | ||
| 78 | // 5、获取KieContainer | 86 | // 5、获取KieContainer |
| 79 | // TODO:ReleaseId用处很大,以后再议 | 87 | // TODO:ReleaseId用处很大,以后再议 |
src/main/java/com/bsth/service/schedule/utils/DataImportExportService.java deleted
100644 → 0
| 1 | -package com.bsth.service.schedule.utils; | ||
| 2 | - | ||
| 3 | -import org.springframework.web.multipart.MultipartFile; | ||
| 4 | - | ||
| 5 | -import java.io.File; | ||
| 6 | -import java.util.Map; | ||
| 7 | - | ||
| 8 | -/** | ||
| 9 | - * 数据导入导出服务。 | ||
| 10 | - */ | ||
| 11 | -public interface DataImportExportService { | ||
| 12 | - /** | ||
| 13 | - * 上传文件。 | ||
| 14 | - * @param file mutipartFile | ||
| 15 | - * @return 上传后的文件路径 | ||
| 16 | - * @throws Exception | ||
| 17 | - */ | ||
| 18 | - File uploadFile(MultipartFile file) throws Exception; | ||
| 19 | - | ||
| 20 | - /** | ||
| 21 | - * 上传文件,并导入文件数据。 | ||
| 22 | - * @param datafile 上传的文件 | ||
| 23 | - * @param ktrFile 导入的逻辑ktr文件 | ||
| 24 | - * @throws Exception | ||
| 25 | - */ | ||
| 26 | - void fileDataImport(MultipartFile datafile, File ktrFile) throws Exception; | ||
| 27 | - void fileDataImport(File datafile, File ktrFile) throws Exception; | ||
| 28 | - | ||
| 29 | - /** | ||
| 30 | - * 数据导出。 | ||
| 31 | - * @param fileName 文件名 | ||
| 32 | - * @param ktrFile 导出的逻辑ktr文件 | ||
| 33 | - * @return 导出的文件 | ||
| 34 | - * @throws Exception | ||
| 35 | - */ | ||
| 36 | - File fileDataOutput(String fileName, File ktrFile) throws Exception; | ||
| 37 | - | ||
| 38 | - | ||
| 39 | - File fileDataOutput(String fileName, File ktrFile, Map<String, Object> param) throws Exception; | ||
| 40 | -} |
src/main/java/com/bsth/service/schedule/utils/DataImportExportServiceImpl.java deleted
100644 → 0
| 1 | -package com.bsth.service.schedule.utils; | ||
| 2 | - | ||
| 3 | -import com.google.common.io.Files; | ||
| 4 | -import org.joda.time.DateTime; | ||
| 5 | -import org.pentaho.di.core.KettleEnvironment; | ||
| 6 | -import org.pentaho.di.core.util.EnvUtil; | ||
| 7 | -import org.pentaho.di.trans.Trans; | ||
| 8 | -import org.pentaho.di.trans.TransMeta; | ||
| 9 | -import org.springframework.beans.factory.InitializingBean; | ||
| 10 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 11 | -import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
| 12 | -import org.springframework.stereotype.Service; | ||
| 13 | -import org.springframework.util.CollectionUtils; | ||
| 14 | -import org.springframework.web.multipart.MultipartFile; | ||
| 15 | - | ||
| 16 | -import java.io.File; | ||
| 17 | -import java.util.HashMap; | ||
| 18 | -import java.util.Map; | ||
| 19 | -import java.util.Properties; | ||
| 20 | - | ||
| 21 | -/** | ||
| 22 | - * Created by xu on 16/6/23. | ||
| 23 | - */ | ||
| 24 | -@Service | ||
| 25 | -@EnableConfigurationProperties(DataToolsProperties.class) | ||
| 26 | -public class DataImportExportServiceImpl implements DataImportExportService, InitializingBean { | ||
| 27 | - | ||
| 28 | - @Autowired | ||
| 29 | - private DataToolsProperties dataToolsProperties; | ||
| 30 | - | ||
| 31 | - /** | ||
| 32 | - * 自定义kettle环境初始化定义。 | ||
| 33 | - */ | ||
| 34 | - private void ktrEnvironmentInit() throws Exception { | ||
| 35 | - // 由于kettle.properties可能没有(没有安装过kettle), | ||
| 36 | - // 导致 EnvUtil.environmentInit() 报找不到kettle.properties文件 | ||
| 37 | - // 所以这里重写 EnvUtil.environmentInit() 方法 | ||
| 38 | - | ||
| 39 | - if(Thread.currentThread().getContextClassLoader() == null) { | ||
| 40 | - Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader()); | ||
| 41 | - } | ||
| 42 | - | ||
| 43 | - // 获取配置文件 | ||
| 44 | - File file = new File(getClass().getResource(dataToolsProperties.getKettleProperties()).toURI()); | ||
| 45 | - Properties kettleProperties = EnvUtil.readProperties(file.getAbsolutePath()); | ||
| 46 | - EnvUtil.applyKettleProperties(kettleProperties); | ||
| 47 | - System.getProperties().put("Internal.Cluster.Size", "1"); | ||
| 48 | - System.getProperties().put("Internal.Slave.Transformation.Number", "0"); | ||
| 49 | - System.getProperties().put("Internal.Slave.Server.Name", "slave-trans-name"); | ||
| 50 | - System.getProperties().put("Internal.Step.CopyNr", "0"); | ||
| 51 | - System.getProperties().put("Internal.Step.Name", "step-name"); | ||
| 52 | - System.getProperties().put("Internal.Step.Partition.ID", "partition-id"); | ||
| 53 | - System.getProperties().put("Internal.Step.Partition.Number", "0"); | ||
| 54 | - System.getProperties().put("Internal.Step.Unique.Count", "1"); | ||
| 55 | - System.getProperties().put("Internal.Step.Unique.Number", "0"); | ||
| 56 | - if(!kettleProperties.containsKey("vfs.sftp.org.apache.commons.vfs2.provider.sftp.SftpFileSystemConfigBuilder.USER_DIR_IS_ROOT")) { | ||
| 57 | - System.getProperties().put("vfs.sftp.org.apache.commons.vfs2.provider.sftp.SftpFileSystemConfigBuilder.USER_DIR_IS_ROOT", "false"); | ||
| 58 | - } | ||
| 59 | - | ||
| 60 | - } | ||
| 61 | - | ||
| 62 | - @Override | ||
| 63 | - public void afterPropertiesSet() throws Exception { | ||
| 64 | - // 初始化kettle环境(自定义) | ||
| 65 | - ktrEnvironmentInit(); | ||
| 66 | - | ||
| 67 | - // 添加全局ktr变量,并覆盖原来的设置 | ||
| 68 | - Map<String, String> kvars = new HashMap<>(); | ||
| 69 | - kvars.put("v_db_ip", dataToolsProperties.getKvarsDbip()); | ||
| 70 | - kvars.put("v_db_uname", dataToolsProperties.getKvarsDbuname()); | ||
| 71 | - kvars.put("v_db_pwd", dataToolsProperties.getKvarsDbpwd()); | ||
| 72 | - kvars.put("v_db_dname", dataToolsProperties.getKvarsDbdname()); | ||
| 73 | - EnvUtil.applyKettleProperties(kvars, true); | ||
| 74 | - KettleEnvironment.init(); | ||
| 75 | - } | ||
| 76 | - | ||
| 77 | - @Override | ||
| 78 | - public File uploadFile(MultipartFile file) throws Exception { | ||
| 79 | - // TODO:以后的文件名要加时间戳 | ||
| 80 | - File newFile = new File( | ||
| 81 | - dataToolsProperties.getFileuploadDir() + File.separator + | ||
| 82 | - file.getOriginalFilename()); | ||
| 83 | - Files.write(file.getBytes(), newFile); | ||
| 84 | - | ||
| 85 | - return newFile; | ||
| 86 | - } | ||
| 87 | - | ||
| 88 | - @Override | ||
| 89 | - public void fileDataImport(MultipartFile datafile, File ktrFile) throws Exception { | ||
| 90 | - // 1、上传数据文件 | ||
| 91 | - File uploadFile = uploadFile(datafile); | ||
| 92 | - | ||
| 93 | - // 2、使用kettle运行封装数据导入逻辑的ktr转换文件 | ||
| 94 | - // 2.1、初始化kettle(组件初始化已经做了) | ||
| 95 | - // 2.2、创建转换元数据,转换 | ||
| 96 | - TransMeta transMeta = new TransMeta(ktrFile.getAbsolutePath()); | ||
| 97 | - Trans trans = new Trans(transMeta); | ||
| 98 | - // 2.3、设定命名参数,用于指定数据文件,注意每个ktr必须都有以下指定的命名参数 | ||
| 99 | - trans.setParameterValue("filepath", uploadFile.getAbsolutePath()); // 指定导入数据文件的位置 | ||
| 100 | - trans.setParameterValue("erroroutputdir", dataToolsProperties.getTransErrordir()); // ktr转换错误输出目录 | ||
| 101 | - // TODO:可以考虑设定日志输出 | ||
| 102 | - // 2.4、执行转换 | ||
| 103 | - trans.execute(null); | ||
| 104 | - // 2.5、等待转换结束 | ||
| 105 | - trans.waitUntilFinished(); | ||
| 106 | - | ||
| 107 | - // 3、判定ktr错误数,注意这种错误代表部分数据错误,不会终止转换执行,一般设计ktr的时候,会有错误输出文件,TODO:以后考虑使用日志实时输出 | ||
| 108 | - if (trans.getErrors() > 0) { | ||
| 109 | - throw new Exception("转换数据部分错误,请查看相关错误输出文件!"); | ||
| 110 | - } | ||
| 111 | - } | ||
| 112 | - | ||
| 113 | - @Override | ||
| 114 | - public void fileDataImport(File datafile, File ktrFile) throws Exception { | ||
| 115 | -// // 1、上传数据文件 | ||
| 116 | -// File uploadFile = datafile; | ||
| 117 | - | ||
| 118 | - // 2、使用kettle运行封装数据导入逻辑的ktr转换文件 | ||
| 119 | - // 2.1、初始化kettle(组件初始化已经做了) | ||
| 120 | - // 2.2、创建转换元数据,转换 | ||
| 121 | - TransMeta transMeta = new TransMeta(ktrFile.getAbsolutePath()); | ||
| 122 | - Trans trans = new Trans(transMeta); | ||
| 123 | - // 2.3、设定命名参数,用于指定数据文件,注意每个ktr必须都有以下指定的命名参数 | ||
| 124 | - trans.setParameterValue("filepath", datafile.getAbsolutePath()); // 指定导入数据文件的位置 | ||
| 125 | - trans.setParameterValue("erroroutputdir", dataToolsProperties.getTransErrordir()); // ktr转换错误输出目录 | ||
| 126 | - // TODO:可以考虑设定日志输出 | ||
| 127 | - // 2.4、执行转换 | ||
| 128 | - trans.execute(null); | ||
| 129 | - // 2.5、等待转换结束 | ||
| 130 | - trans.waitUntilFinished(); | ||
| 131 | - | ||
| 132 | - // 3、判定ktr错误数,注意这种错误代表部分数据错误,不会终止转换执行,一般设计ktr的时候,会有错误输出文件,TODO:以后考虑使用日志实时输出 | ||
| 133 | - if (trans.getErrors() > 0) { | ||
| 134 | - throw new Exception("转换数据部分错误,请查看相关错误输出文件!"); | ||
| 135 | - } | ||
| 136 | - } | ||
| 137 | - | ||
| 138 | - @Override | ||
| 139 | - public File fileDataOutput(String fileName, File ktrFile) throws Exception { | ||
| 140 | - return fileDataOutput(fileName, ktrFile, null); | ||
| 141 | - } | ||
| 142 | - | ||
| 143 | - @Override | ||
| 144 | - public File fileDataOutput(String fileName, File ktrFile, Map<String, Object> param) throws Exception { | ||
| 145 | - // 初始化转换,元数据,转换对象 | ||
| 146 | - TransMeta transMeta = new TransMeta(ktrFile.getAbsolutePath()); | ||
| 147 | - Trans trans = new Trans(transMeta); | ||
| 148 | - // 设定命名参数 | ||
| 149 | - String filepath = dataToolsProperties.getFileoutputDir() + | ||
| 150 | - File.separator + | ||
| 151 | - fileName + | ||
| 152 | - new DateTime().toString("yyyyMMddHHmmss") + ".xls"; | ||
| 153 | - trans.setParameterValue("filepath", filepath); | ||
| 154 | - | ||
| 155 | - // 添加其他参数 | ||
| 156 | - if (!CollectionUtils.isEmpty(param)) { | ||
| 157 | - for (String key : param.keySet()) { | ||
| 158 | - trans.setParameterValue(key, String.valueOf(param.get(key))); | ||
| 159 | - } | ||
| 160 | - } | ||
| 161 | - | ||
| 162 | - // 执行转换 | ||
| 163 | - trans.execute(null); | ||
| 164 | - // 等待转换结束 | ||
| 165 | - trans.waitUntilFinished(); | ||
| 166 | - | ||
| 167 | - if (trans.getErrors() > 0) { | ||
| 168 | - throw new Exception("转换数据部分错误,请查看相关错误输出文件!"); | ||
| 169 | - } | ||
| 170 | - | ||
| 171 | - return new File(filepath); | ||
| 172 | - } | ||
| 173 | - | ||
| 174 | - | ||
| 175 | - // TODO:以后改成下面的样子 | ||
| 176 | -// import java.io.FileInputStream; | ||
| 177 | -// import java.io.FileOutputStream; | ||
| 178 | -// import java.io.IOException; | ||
| 179 | -// import java.io.InputStream; | ||
| 180 | -// import java.util.Iterator; | ||
| 181 | -// | ||
| 182 | -// import org.apache.poi.hssf.usermodel.HSSFCell; | ||
| 183 | -// import org.apache.poi.hssf.usermodel.HSSFRow; | ||
| 184 | -// import org.apache.poi.hssf.usermodel.HSSFSheet; | ||
| 185 | -// import org.apache.poi.hssf.usermodel.HSSFWorkbook; | ||
| 186 | -// | ||
| 187 | -// import org.apache.poi.xssf.usermodel.XSSFCell; | ||
| 188 | -// import org.apache.poi.xssf.usermodel.XSSFRow; | ||
| 189 | -// import org.apache.poi.xssf.usermodel.XSSFSheet; | ||
| 190 | -// import org.apache.poi.xssf.usermodel.XSSFWorkbook; | ||
| 191 | -// | ||
| 192 | -// public class ReadWriteExcelFile { | ||
| 193 | -// | ||
| 194 | -// public static void readXLSFile() throws IOException | ||
| 195 | -// { | ||
| 196 | -// InputStream ExcelFileToRead = new FileInputStream("C:/Test.xls"); | ||
| 197 | -// HSSFWorkbook wb = new HSSFWorkbook(ExcelFileToRead); | ||
| 198 | -// | ||
| 199 | -// HSSFSheet sheet=wb.getSheetAt(0); | ||
| 200 | -// HSSFRow row; | ||
| 201 | -// HSSFCell cell; | ||
| 202 | -// | ||
| 203 | -// Iterator rows = sheet.rowIterator(); | ||
| 204 | -// | ||
| 205 | -// while (rows.hasNext()) | ||
| 206 | -// { | ||
| 207 | -// row=(HSSFRow) rows.next(); | ||
| 208 | -// Iterator cells = row.cellIterator(); | ||
| 209 | -// | ||
| 210 | -// while (cells.hasNext()) | ||
| 211 | -// { | ||
| 212 | -// cell=(HSSFCell) cells.next(); | ||
| 213 | -// | ||
| 214 | -// if (cell.getCellType() == HSSFCell.CELL_TYPE_STRING) | ||
| 215 | -// { | ||
| 216 | -// System.out.print(cell.getStringCellValue()+" "); | ||
| 217 | -// } | ||
| 218 | -// else if(cell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC) | ||
| 219 | -// { | ||
| 220 | -// System.out.print(cell.getNumericCellValue()+" "); | ||
| 221 | -// } | ||
| 222 | -// else | ||
| 223 | -// { | ||
| 224 | -// //U Can Handel Boolean, Formula, Errors | ||
| 225 | -// } | ||
| 226 | -// } | ||
| 227 | -// System.out.println(); | ||
| 228 | -// } | ||
| 229 | -// | ||
| 230 | -// } | ||
| 231 | -// | ||
| 232 | -// public static void writeXLSFile() throws IOException { | ||
| 233 | -// | ||
| 234 | -// String excelFileName = "C:/Test.xls";//name of excel file | ||
| 235 | -// | ||
| 236 | -// String sheetName = "Sheet1";//name of sheet | ||
| 237 | -// | ||
| 238 | -// HSSFWorkbook wb = new HSSFWorkbook(); | ||
| 239 | -// HSSFSheet sheet = wb.createSheet(sheetName) ; | ||
| 240 | -// | ||
| 241 | -// //iterating r number of rows | ||
| 242 | -// for (int r=0;r < 5; r++ ) | ||
| 243 | -// { | ||
| 244 | -// HSSFRow row = sheet.createRow(r); | ||
| 245 | -// | ||
| 246 | -// //iterating c number of columns | ||
| 247 | -// for (int c=0;c < 5; c++ ) | ||
| 248 | -// { | ||
| 249 | -// HSSFCell cell = row.createCell(c); | ||
| 250 | -// | ||
| 251 | -// cell.setCellValue("Cell "+r+" "+c); | ||
| 252 | -// } | ||
| 253 | -// } | ||
| 254 | -// | ||
| 255 | -// FileOutputStream fileOut = new FileOutputStream(excelFileName); | ||
| 256 | -// | ||
| 257 | -// //write this workbook to an Outputstream. | ||
| 258 | -// wb.write(fileOut); | ||
| 259 | -// fileOut.flush(); | ||
| 260 | -// fileOut.close(); | ||
| 261 | -// } | ||
| 262 | -// | ||
| 263 | -// public static void readXLSXFile() throws IOException | ||
| 264 | -// { | ||
| 265 | -// InputStream ExcelFileToRead = new FileInputStream("C:/Test.xlsx"); | ||
| 266 | -// XSSFWorkbook wb = new XSSFWorkbook(ExcelFileToRead); | ||
| 267 | -// | ||
| 268 | -// XSSFWorkbook test = new XSSFWorkbook(); | ||
| 269 | -// | ||
| 270 | -// XSSFSheet sheet = wb.getSheetAt(0); | ||
| 271 | -// XSSFRow row; | ||
| 272 | -// XSSFCell cell; | ||
| 273 | -// | ||
| 274 | -// Iterator rows = sheet.rowIterator(); | ||
| 275 | -// | ||
| 276 | -// while (rows.hasNext()) | ||
| 277 | -// { | ||
| 278 | -// row=(XSSFRow) rows.next(); | ||
| 279 | -// Iterator cells = row.cellIterator(); | ||
| 280 | -// while (cells.hasNext()) | ||
| 281 | -// { | ||
| 282 | -// cell=(XSSFCell) cells.next(); | ||
| 283 | -// | ||
| 284 | -// if (cell.getCellType() == XSSFCell.CELL_TYPE_STRING) | ||
| 285 | -// { | ||
| 286 | -// System.out.print(cell.getStringCellValue()+" "); | ||
| 287 | -// } | ||
| 288 | -// else if(cell.getCellType() == XSSFCell.CELL_TYPE_NUMERIC) | ||
| 289 | -// { | ||
| 290 | -// System.out.print(cell.getNumericCellValue()+" "); | ||
| 291 | -// } | ||
| 292 | -// else | ||
| 293 | -// { | ||
| 294 | -// //U Can Handel Boolean, Formula, Errors | ||
| 295 | -// } | ||
| 296 | -// } | ||
| 297 | -// System.out.println(); | ||
| 298 | -// } | ||
| 299 | -// | ||
| 300 | -// } | ||
| 301 | -// | ||
| 302 | -// public static void writeXLSXFile() throws IOException { | ||
| 303 | -// | ||
| 304 | -// String excelFileName = "C:/Test.xlsx";//name of excel file | ||
| 305 | -// | ||
| 306 | -// String sheetName = "Sheet1";//name of sheet | ||
| 307 | -// | ||
| 308 | -// XSSFWorkbook wb = new XSSFWorkbook(); | ||
| 309 | -// XSSFSheet sheet = wb.createSheet(sheetName) ; | ||
| 310 | -// | ||
| 311 | -// //iterating r number of rows | ||
| 312 | -// for (int r=0;r < 5; r++ ) | ||
| 313 | -// { | ||
| 314 | -// XSSFRow row = sheet.createRow(r); | ||
| 315 | -// | ||
| 316 | -// //iterating c number of columns | ||
| 317 | -// for (int c=0;c < 5; c++ ) | ||
| 318 | -// { | ||
| 319 | -// XSSFCell cell = row.createCell(c); | ||
| 320 | -// | ||
| 321 | -// cell.setCellValue("Cell "+r+" "+c); | ||
| 322 | -// } | ||
| 323 | -// } | ||
| 324 | -// | ||
| 325 | -// FileOutputStream fileOut = new FileOutputStream(excelFileName); | ||
| 326 | -// | ||
| 327 | -// //write this workbook to an Outputstream. | ||
| 328 | -// wb.write(fileOut); | ||
| 329 | -// fileOut.flush(); | ||
| 330 | -// fileOut.close(); | ||
| 331 | -// } | ||
| 332 | -// | ||
| 333 | -// public static void main(String[] args) throws IOException { | ||
| 334 | -// | ||
| 335 | -// writeXLSFile(); | ||
| 336 | -// readXLSFile(); | ||
| 337 | -// | ||
| 338 | -// writeXLSXFile(); | ||
| 339 | -// readXLSXFile(); | ||
| 340 | -// | ||
| 341 | -// } | ||
| 342 | -// | ||
| 343 | -// } | ||
| 344 | -} |
src/main/java/com/bsth/service/schedule/utils/DataToolsServiceImpl.java
| @@ -13,10 +13,9 @@ import org.pentaho.di.trans.Trans; | @@ -13,10 +13,9 @@ import org.pentaho.di.trans.Trans; | ||
| 13 | import org.pentaho.di.trans.TransMeta; | 13 | import org.pentaho.di.trans.TransMeta; |
| 14 | import org.slf4j.Logger; | 14 | import org.slf4j.Logger; |
| 15 | import org.slf4j.LoggerFactory; | 15 | import org.slf4j.LoggerFactory; |
| 16 | -import org.springframework.beans.factory.InitializingBean; | ||
| 17 | import org.springframework.beans.factory.annotation.Autowired; | 16 | import org.springframework.beans.factory.annotation.Autowired; |
| 18 | import org.springframework.boot.context.properties.EnableConfigurationProperties; | 17 | import org.springframework.boot.context.properties.EnableConfigurationProperties; |
| 19 | -import org.springframework.stereotype.Service; | 18 | +import org.springframework.stereotype.Component; |
| 20 | 19 | ||
| 21 | import java.io.File; | 20 | import java.io.File; |
| 22 | import java.io.PrintWriter; | 21 | import java.io.PrintWriter; |
| @@ -24,19 +23,41 @@ import java.io.StringWriter; | @@ -24,19 +23,41 @@ import java.io.StringWriter; | ||
| 24 | import java.util.HashMap; | 23 | import java.util.HashMap; |
| 25 | import java.util.Map; | 24 | import java.util.Map; |
| 26 | import java.util.Properties; | 25 | import java.util.Properties; |
| 26 | +import java.util.concurrent.atomic.AtomicBoolean; | ||
| 27 | 27 | ||
| 28 | /** | 28 | /** |
| 29 | * Created by xu on 17/1/3. | 29 | * Created by xu on 17/1/3. |
| 30 | */ | 30 | */ |
| 31 | -@Service | 31 | +@Component |
| 32 | @EnableConfigurationProperties(DataToolsProperties.class) | 32 | @EnableConfigurationProperties(DataToolsProperties.class) |
| 33 | -public class DataToolsServiceImpl implements DataToolsService, InitializingBean { | 33 | +public class DataToolsServiceImpl implements DataToolsService { |
| 34 | /** 日志记录器 */ | 34 | /** 日志记录器 */ |
| 35 | private static final Logger LOGGER = LoggerFactory.getLogger(DataToolsServiceImpl.class); | 35 | private static final Logger LOGGER = LoggerFactory.getLogger(DataToolsServiceImpl.class); |
| 36 | 36 | ||
| 37 | @Autowired | 37 | @Autowired |
| 38 | private DataToolsProperties dataToolsProperties; | 38 | private DataToolsProperties dataToolsProperties; |
| 39 | 39 | ||
| 40 | + /** 原子操作类 */ | ||
| 41 | + private AtomicBoolean flag = new AtomicBoolean(false); | ||
| 42 | + | ||
| 43 | + private void initKettle() throws Exception { | ||
| 44 | + if (flag.compareAndSet(false, true)) { | ||
| 45 | + LOGGER.info("kettle初始化......"); | ||
| 46 | + | ||
| 47 | + // 初始化kettle环境(自定义) | ||
| 48 | + ktrEnvironmentInit(); | ||
| 49 | + | ||
| 50 | + // 添加全局ktr变量,并覆盖原来的设置 | ||
| 51 | + Map<String, String> kvars = new HashMap<>(); | ||
| 52 | + kvars.put("v_db_ip", dataToolsProperties.getKvarsDbip()); | ||
| 53 | + kvars.put("v_db_uname", dataToolsProperties.getKvarsDbuname()); | ||
| 54 | + kvars.put("v_db_pwd", dataToolsProperties.getKvarsDbpwd()); | ||
| 55 | + kvars.put("v_db_dname", dataToolsProperties.getKvarsDbdname()); | ||
| 56 | + EnvUtil.applyKettleProperties(kvars, true); | ||
| 57 | + KettleEnvironment.init(); | ||
| 58 | + } | ||
| 59 | + } | ||
| 60 | + | ||
| 40 | /** | 61 | /** |
| 41 | * 自定义kettle环境初始化定义。 | 62 | * 自定义kettle环境初始化定义。 |
| 42 | */ | 63 | */ |
| @@ -70,24 +91,11 @@ public class DataToolsServiceImpl implements DataToolsService, InitializingBean | @@ -70,24 +91,11 @@ public class DataToolsServiceImpl implements DataToolsService, InitializingBean | ||
| 70 | } | 91 | } |
| 71 | 92 | ||
| 72 | @Override | 93 | @Override |
| 73 | - public void afterPropertiesSet() throws Exception { | ||
| 74 | - // 初始化kettle环境(自定义) | ||
| 75 | - ktrEnvironmentInit(); | ||
| 76 | - | ||
| 77 | - // 添加全局ktr变量,并覆盖原来的设置 | ||
| 78 | - Map<String, String> kvars = new HashMap<>(); | ||
| 79 | - kvars.put("v_db_ip", dataToolsProperties.getKvarsDbip()); | ||
| 80 | - kvars.put("v_db_uname", dataToolsProperties.getKvarsDbuname()); | ||
| 81 | - kvars.put("v_db_pwd", dataToolsProperties.getKvarsDbpwd()); | ||
| 82 | - kvars.put("v_db_dname", dataToolsProperties.getKvarsDbdname()); | ||
| 83 | - EnvUtil.applyKettleProperties(kvars, true); | ||
| 84 | - KettleEnvironment.init(); | ||
| 85 | - } | ||
| 86 | - | ||
| 87 | - @Override | ||
| 88 | public File uploadFile(String filename, byte[] filedata) throws ScheduleException { | 94 | public File uploadFile(String filename, byte[] filedata) throws ScheduleException { |
| 89 | // 上传文件 | 95 | // 上传文件 |
| 90 | try { | 96 | try { |
| 97 | + initKettle(); | ||
| 98 | + | ||
| 91 | LOGGER.info("start uploadFile...originalFilename={}", filename); | 99 | LOGGER.info("start uploadFile...originalFilename={}", filename); |
| 92 | File newFile = new File(dataToolsProperties.getFileuploadDir() + File.separator + | 100 | File newFile = new File(dataToolsProperties.getFileuploadDir() + File.separator + |
| 93 | filename + "-upload-" + new DateTime().toString("yyyyMMddHHmmss") + ".xls"); | 101 | filename + "-upload-" + new DateTime().toString("yyyyMMddHHmmss") + ".xls"); |
| @@ -127,6 +135,8 @@ public class DataToolsServiceImpl implements DataToolsService, InitializingBean | @@ -127,6 +135,8 @@ public class DataToolsServiceImpl implements DataToolsService, InitializingBean | ||
| 127 | String transLogId = ""; | 135 | String transLogId = ""; |
| 128 | String transMetaLogId = ""; | 136 | String transMetaLogId = ""; |
| 129 | try { | 137 | try { |
| 138 | + initKettle(); | ||
| 139 | + | ||
| 130 | LOGGER.info("start importData...originalFilename={}", file.getAbsolutePath()); | 140 | LOGGER.info("start importData...originalFilename={}", file.getAbsolutePath()); |
| 131 | // 检查参数 | 141 | // 检查参数 |
| 132 | String transpath = String.valueOf(params.get("transpath")); | 142 | String transpath = String.valueOf(params.get("transpath")); |
| @@ -189,6 +199,8 @@ public class DataToolsServiceImpl implements DataToolsService, InitializingBean | @@ -189,6 +199,8 @@ public class DataToolsServiceImpl implements DataToolsService, InitializingBean | ||
| 189 | String transLogId = ""; | 199 | String transLogId = ""; |
| 190 | String transMetaLogId = ""; | 200 | String transMetaLogId = ""; |
| 191 | try { | 201 | try { |
| 202 | + initKettle(); | ||
| 203 | + | ||
| 192 | LOGGER.info("start exportData..."); | 204 | LOGGER.info("start exportData..."); |
| 193 | // 检查参数 | 205 | // 检查参数 |
| 194 | String filename = String.valueOf(params.get("filename")); | 206 | String filename = String.valueOf(params.get("filename")); |
src/main/java/com/bsth/util/ComparableJob.java
0 → 100644
| 1 | +package com.bsth.util; | ||
| 2 | + | ||
| 3 | +import java.util.Comparator; | ||
| 4 | +import java.util.Map; | ||
| 5 | + | ||
| 6 | + | ||
| 7 | +public class ComparableJob implements Comparator<Map<String, Object>>{ | ||
| 8 | + | ||
| 9 | + @Override | ||
| 10 | + public int compare(Map<String, Object> o1, Map<String, Object> o2) { | ||
| 11 | + // TODO Auto-generated method stub | ||
| 12 | + return o1.get("nr").toString().compareTo(o2.get("nr").toString()); | ||
| 13 | + } | ||
| 14 | + | ||
| 15 | +} |
src/main/resources/datatools/ktrs/carsDataInput.ktr
| @@ -86,6 +86,30 @@ | @@ -86,6 +86,30 @@ | ||
| 86 | <notepads> | 86 | <notepads> |
| 87 | </notepads> | 87 | </notepads> |
| 88 | <connection> | 88 | <connection> |
| 89 | + <name>192.168.168.1_jwgl_dw</name> | ||
| 90 | + <server>192.168.168.1</server> | ||
| 91 | + <type>ORACLE</type> | ||
| 92 | + <access>Native</access> | ||
| 93 | + <database>orcl</database> | ||
| 94 | + <port>1521</port> | ||
| 95 | + <username>jwgl_dw</username> | ||
| 96 | + <password>Encrypted 2be98afc86aa7f2e4cb13b977d2adabcd</password> | ||
| 97 | + <servername/> | ||
| 98 | + <data_tablespace/> | ||
| 99 | + <index_tablespace/> | ||
| 100 | + <attributes> | ||
| 101 | + <attribute><code>FORCE_IDENTIFIERS_TO_LOWERCASE</code><attribute>N</attribute></attribute> | ||
| 102 | + <attribute><code>FORCE_IDENTIFIERS_TO_UPPERCASE</code><attribute>N</attribute></attribute> | ||
| 103 | + <attribute><code>IS_CLUSTERED</code><attribute>N</attribute></attribute> | ||
| 104 | + <attribute><code>PORT_NUMBER</code><attribute>1521</attribute></attribute> | ||
| 105 | + <attribute><code>PRESERVE_RESERVED_WORD_CASE</code><attribute>N</attribute></attribute> | ||
| 106 | + <attribute><code>QUOTE_ALL_FIELDS</code><attribute>N</attribute></attribute> | ||
| 107 | + <attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>Y</attribute></attribute> | ||
| 108 | + <attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>Y</attribute></attribute> | ||
| 109 | + <attribute><code>USE_POOLING</code><attribute>N</attribute></attribute> | ||
| 110 | + </attributes> | ||
| 111 | + </connection> | ||
| 112 | + <connection> | ||
| 89 | <name>bus_control_variable</name> | 113 | <name>bus_control_variable</name> |
| 90 | <server>${v_db_ip}</server> | 114 | <server>${v_db_ip}</server> |
| 91 | <type>MYSQL</type> | 115 | <type>MYSQL</type> |
| @@ -298,6 +322,18 @@ | @@ -298,6 +322,18 @@ | ||
| 298 | <group/> | 322 | <group/> |
| 299 | </field> | 323 | </field> |
| 300 | <field> | 324 | <field> |
| 325 | + <name>车辆编码</name> | ||
| 326 | + <type>String</type> | ||
| 327 | + <length>-1</length> | ||
| 328 | + <precision>-1</precision> | ||
| 329 | + <trim_type>none</trim_type> | ||
| 330 | + <repeat>N</repeat> | ||
| 331 | + <format/> | ||
| 332 | + <currency/> | ||
| 333 | + <decimal/> | ||
| 334 | + <group/> | ||
| 335 | + </field> | ||
| 336 | + <field> | ||
| 301 | <name>内部编码</name> | 337 | <name>内部编码</name> |
| 302 | <type>String</type> | 338 | <type>String</type> |
| 303 | <length>-1</length> | 339 | <length>-1</length> |
| @@ -358,7 +394,7 @@ | @@ -358,7 +394,7 @@ | ||
| 358 | <group/> | 394 | <group/> |
| 359 | </field> | 395 | </field> |
| 360 | <field> | 396 | <field> |
| 361 | - <name>供应商名称</name> | 397 | + <name>设备供应厂商</name> |
| 362 | <type>String</type> | 398 | <type>String</type> |
| 363 | <length>-1</length> | 399 | <length>-1</length> |
| 364 | <precision>-1</precision> | 400 | <precision>-1</precision> |
| @@ -444,12 +480,12 @@ | @@ -444,12 +480,12 @@ | ||
| 444 | <update>Y</update> | 480 | <update>Y</update> |
| 445 | </value> | 481 | </value> |
| 446 | <value> | 482 | <value> |
| 447 | - <name>inside_code</name> | ||
| 448 | - <rename>内部编码</rename> | 483 | + <name>car_code</name> |
| 484 | + <rename>车辆编码</rename> | ||
| 449 | <update>Y</update> | 485 | <update>Y</update> |
| 450 | </value> | 486 | </value> |
| 451 | <value> | 487 | <value> |
| 452 | - <name>car_code</name> | 488 | + <name>inside_code</name> |
| 453 | <rename>内部编码</rename> | 489 | <rename>内部编码</rename> |
| 454 | <update>Y</update> | 490 | <update>Y</update> |
| 455 | </value> | 491 | </value> |
| @@ -475,7 +511,7 @@ | @@ -475,7 +511,7 @@ | ||
| 475 | </value> | 511 | </value> |
| 476 | <value> | 512 | <value> |
| 477 | <name>supplier_name</name> | 513 | <name>supplier_name</name> |
| 478 | - <rename>供应商名称</rename> | 514 | + <rename>设备供应厂商</rename> |
| 479 | <update>Y</update> | 515 | <update>Y</update> |
| 480 | </value> | 516 | </value> |
| 481 | <value> | 517 | <value> |
| @@ -683,4 +719,3 @@ | @@ -683,4 +719,3 @@ | ||
| 683 | <slave_transformation>N</slave_transformation> | 719 | <slave_transformation>N</slave_transformation> |
| 684 | 720 | ||
| 685 | </transformation> | 721 | </transformation> |
| 686 | - |
src/main/resources/datatools/ktrs/carsDataOutput.ktr
| @@ -81,6 +81,30 @@ | @@ -81,6 +81,30 @@ | ||
| 81 | <notepads> | 81 | <notepads> |
| 82 | </notepads> | 82 | </notepads> |
| 83 | <connection> | 83 | <connection> |
| 84 | + <name>192.168.168.1_jwgl_dw</name> | ||
| 85 | + <server>192.168.168.1</server> | ||
| 86 | + <type>ORACLE</type> | ||
| 87 | + <access>Native</access> | ||
| 88 | + <database>orcl</database> | ||
| 89 | + <port>1521</port> | ||
| 90 | + <username>jwgl_dw</username> | ||
| 91 | + <password>Encrypted 2be98afc86aa7f2e4cb13b977d2adabcd</password> | ||
| 92 | + <servername/> | ||
| 93 | + <data_tablespace/> | ||
| 94 | + <index_tablespace/> | ||
| 95 | + <attributes> | ||
| 96 | + <attribute><code>FORCE_IDENTIFIERS_TO_LOWERCASE</code><attribute>N</attribute></attribute> | ||
| 97 | + <attribute><code>FORCE_IDENTIFIERS_TO_UPPERCASE</code><attribute>N</attribute></attribute> | ||
| 98 | + <attribute><code>IS_CLUSTERED</code><attribute>N</attribute></attribute> | ||
| 99 | + <attribute><code>PORT_NUMBER</code><attribute>1521</attribute></attribute> | ||
| 100 | + <attribute><code>PRESERVE_RESERVED_WORD_CASE</code><attribute>N</attribute></attribute> | ||
| 101 | + <attribute><code>QUOTE_ALL_FIELDS</code><attribute>N</attribute></attribute> | ||
| 102 | + <attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>Y</attribute></attribute> | ||
| 103 | + <attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>Y</attribute></attribute> | ||
| 104 | + <attribute><code>USE_POOLING</code><attribute>N</attribute></attribute> | ||
| 105 | + </attributes> | ||
| 106 | + </connection> | ||
| 107 | + <connection> | ||
| 84 | <name>bus_control_variable</name> | 108 | <name>bus_control_variable</name> |
| 85 | <server>${v_db_ip}</server> | 109 | <server>${v_db_ip}</server> |
| 86 | <type>MYSQL</type> | 110 | <type>MYSQL</type> |
| @@ -292,6 +316,11 @@ | @@ -292,6 +316,11 @@ | ||
| 292 | <format/> | 316 | <format/> |
| 293 | </field> | 317 | </field> |
| 294 | <field> | 318 | <field> |
| 319 | + <name>车辆编码</name> | ||
| 320 | + <type>String</type> | ||
| 321 | + <format/> | ||
| 322 | + </field> | ||
| 323 | + <field> | ||
| 295 | <name>内部编码</name> | 324 | <name>内部编码</name> |
| 296 | <type>String</type> | 325 | <type>String</type> |
| 297 | <format/> | 326 | <format/> |
| @@ -317,6 +346,11 @@ | @@ -317,6 +346,11 @@ | ||
| 317 | <format/> | 346 | <format/> |
| 318 | </field> | 347 | </field> |
| 319 | <field> | 348 | <field> |
| 349 | + <name>设备供应厂商</name> | ||
| 350 | + <type>String</type> | ||
| 351 | + <format/> | ||
| 352 | + </field> | ||
| 353 | + <field> | ||
| 320 | <name>设备终端号</name> | 354 | <name>设备终端号</name> |
| 321 | <type>String</type> | 355 | <type>String</type> |
| 322 | <format/> | 356 | <format/> |
| @@ -362,6 +396,10 @@ | @@ -362,6 +396,10 @@ | ||
| 362 | <rename>车牌号</rename> | 396 | <rename>车牌号</rename> |
| 363 | <length>-2</length> | 397 | <length>-2</length> |
| 364 | <precision>-2</precision> | 398 | <precision>-2</precision> |
| 399 | + </field> <field> <name>car_code</name> | ||
| 400 | + <rename>车辆编码</rename> | ||
| 401 | + <length>-2</length> | ||
| 402 | + <precision>-2</precision> | ||
| 365 | </field> <field> <name>inside_code</name> | 403 | </field> <field> <name>inside_code</name> |
| 366 | <rename>内部编码</rename> | 404 | <rename>内部编码</rename> |
| 367 | <length>-2</length> | 405 | <length>-2</length> |
src/main/resources/fatso/handle_real_ctl.js
| 1 | -/** | ||
| 2 | - * 处理线调文件 | ||
| 3 | - */ | ||
| 4 | -var fs = require('fs') | ||
| 5 | - , cheerio = require('cheerio') | ||
| 6 | - , minifier = require('./minifier') | ||
| 7 | - , crypto = require("crypto") | ||
| 8 | - , CleanCSS = require('clean-css') | ||
| 9 | - , UglifyJS = require("uglify-js"); | ||
| 10 | -; | ||
| 11 | - | ||
| 12 | -//不参与的目录 | ||
| 13 | -var pName = 'bsth_control' | ||
| 14 | - , path = process.cwd() | ||
| 15 | - //根目录 | ||
| 16 | - , root = path.substr(0, path.indexOf('\\src\\main')) | ||
| 17 | - , workspace = root.substr(0, root.indexOf('\\' + pName)) | ||
| 18 | - //临时目录 | ||
| 19 | - , dest = (workspace + '\\' + pName + '@fatso_copy').replace(/\//g, '\\') | ||
| 20 | - , _static = '\\src\\main\\resources\\static'; | ||
| 21 | - | ||
| 22 | - | ||
| 23 | -var mainFile = dest + _static + '\\real_control_v2\\main.html'; | ||
| 24 | -var mapFile = dest + _static + '\\real_control_v2\\mapmonitor\\real.html'; | ||
| 25 | -var realCtl = { | ||
| 26 | - /** | ||
| 27 | - * 处理线调首页 | ||
| 28 | - */ | ||
| 29 | - handleMain: function (cb) { | ||
| 30 | - //读取文件 | ||
| 31 | - var data = fs.readFileSync(mainFile, 'utf-8') | ||
| 32 | - , $ = cheerio.load(data); | ||
| 33 | - | ||
| 34 | - handleCss($, function () { | ||
| 35 | - handleJs($, mainFile, cb); | ||
| 36 | - }); | ||
| 37 | - }, | ||
| 38 | - /** | ||
| 39 | - * 处理地图模块 | ||
| 40 | - * @param cb | ||
| 41 | - */ | ||
| 42 | - handleMap: function (cb) { | ||
| 43 | - //读取文件 | ||
| 44 | - var data = fs.readFileSync(mapFile, 'utf-8') | ||
| 45 | - , $ = cheerio.load(data); | ||
| 46 | - | ||
| 47 | - handleCss($, function () { | ||
| 48 | - handleJs($, mapFile, cb); | ||
| 49 | - }); | ||
| 50 | - } | ||
| 51 | -}; | ||
| 52 | - | ||
| 53 | -/** | ||
| 54 | - * 处理css | ||
| 55 | - * @type {any} | ||
| 56 | - */ | ||
| 57 | -var handleCss = function ($, cb) { | ||
| 58 | - var cssArray = $('link[rel=stylesheet][merge]'); | ||
| 59 | - //按 merge 值分组 | ||
| 60 | - var cssMap = {}, mergeName; | ||
| 61 | - for (var i = 0, c; c = cssArray[i++];) { | ||
| 62 | - mergeName = $(c).attr('merge'); | ||
| 63 | - if (!cssMap[mergeName]) | ||
| 64 | - cssMap[mergeName] = []; | ||
| 65 | - cssMap[mergeName].push(dest + _static + $(c).attr('href')); | ||
| 66 | - //remove | ||
| 67 | - $(c).remove(); | ||
| 68 | - } | ||
| 69 | - //按 merge 合并压缩css | ||
| 70 | - var ks = get_keys(cssMap), index = 0; | ||
| 71 | - (function () { | ||
| 72 | - if (index >= ks.length) { | ||
| 73 | - cb && cb(); | ||
| 74 | - return; | ||
| 75 | - } | ||
| 76 | - var k = ks[index]; | ||
| 77 | - index++; | ||
| 78 | - var f = arguments.callee; | ||
| 79 | - //合并css | ||
| 80 | - new CleanCSS().minify(cssMap[k], function (error, out) { | ||
| 81 | - var data = out.styles; | ||
| 82 | - var fName = (k + '_' + md5(data)) + '.css'; | ||
| 83 | - //写入 assets css 目录下 | ||
| 84 | - var descFile = dest + _static + '\\real_control_v2\\assets\\css\\' + fName; | ||
| 85 | - fs.open(descFile, 'a', function (err, fd) { | ||
| 86 | - | ||
| 87 | - fs.write(fd, data, function () { | ||
| 88 | - var tag = '<link rel="stylesheet" href="/real_control_v2/assets/css/' + fName + '"/>'; | ||
| 89 | - if ($('head').length > 0) | ||
| 90 | - $('head').append(tag); | ||
| 91 | - else { | ||
| 92 | - if($('link').length > 0) | ||
| 93 | - $('link').last().before(tag); | ||
| 94 | - else | ||
| 95 | - $('div').first().before(tag); | ||
| 96 | - } | ||
| 97 | - console.log(k + ' css', '结束,下一个'); | ||
| 98 | - f(); | ||
| 99 | - }); | ||
| 100 | - }); | ||
| 101 | - }); | ||
| 102 | - })(); | ||
| 103 | -}; | ||
| 104 | - | ||
| 105 | -/** | ||
| 106 | - * 处理js | ||
| 107 | - */ | ||
| 108 | -var handleJs = function ($, file, cb) { | ||
| 109 | - var scriptArray = $('script[merge]'); | ||
| 110 | - //按 merge 值分组 | ||
| 111 | - var jsMap = {}, mergeName; | ||
| 112 | - for (var i = 0, s; s = scriptArray[i++];) { | ||
| 113 | - mergeName = $(s).attr('merge'); | ||
| 114 | - if (!jsMap[mergeName]) | ||
| 115 | - jsMap[mergeName] = []; | ||
| 116 | - jsMap[mergeName].push(dest + _static + $(s).attr('src')); | ||
| 117 | - //remove | ||
| 118 | - $(s).remove(); | ||
| 119 | - } | ||
| 120 | - | ||
| 121 | - //按 merge 合并压缩js | ||
| 122 | - var ks = get_keys(jsMap), index = 0; | ||
| 123 | - (function () { | ||
| 124 | - if (index >= ks.length) { | ||
| 125 | - write(file, $.html()); | ||
| 126 | - console.log(file + ' 结束'.green); | ||
| 127 | - cb && cb(); | ||
| 128 | - return; | ||
| 129 | - } | ||
| 130 | - var k = ks[index]; | ||
| 131 | - index++; | ||
| 132 | - var f = arguments.callee; | ||
| 133 | - //合并压缩js | ||
| 134 | - var result = UglifyJS.minify(jsMap[k]); | ||
| 135 | - var data = result.code; | ||
| 136 | - var fName = (k + '_' + md5(data)) + '.js'; | ||
| 137 | - //写入 assets js 目录下 | ||
| 138 | - var descFile = dest + _static + '\\real_control_v2\\assets\\js\\' + fName; | ||
| 139 | - fs.open(descFile, 'a', function (err, fd) { | ||
| 140 | - | ||
| 141 | - fs.write(fd, data, function () { | ||
| 142 | - var tag = '<script src="/real_control_v2/assets/js/' + fName + '"></script>'; | ||
| 143 | - if ($('body').length > 0) | ||
| 144 | - $('body').append(tag); | ||
| 145 | - else { | ||
| 146 | - //没有body 就写在尾部 | ||
| 147 | - $('*').last().after(tag); | ||
| 148 | - } | ||
| 149 | - console.log(k + ' js', '结束,下一个'); | ||
| 150 | - f(); | ||
| 151 | - }); | ||
| 152 | - }); | ||
| 153 | - })(); | ||
| 154 | -}; | ||
| 155 | - | ||
| 156 | -var get_keys = function (json) { | ||
| 157 | - var array = []; | ||
| 158 | - for (var key in json) { | ||
| 159 | - array.push(key); | ||
| 160 | - } | ||
| 161 | - return array; | ||
| 162 | -}; | ||
| 163 | - | ||
| 164 | -function md5(text) { | ||
| 165 | - return crypto.createHash("md5").update(text).digest("hex"); | ||
| 166 | -} | ||
| 167 | - | ||
| 168 | -function write(file, text) { | ||
| 169 | - fs.writeFile(file, text, function (err) { | ||
| 170 | - if (err) { | ||
| 171 | - console.log(err.toString().red); | ||
| 172 | - process.exit(); | ||
| 173 | - } | ||
| 174 | - console.log(file.green); | ||
| 175 | - }); | ||
| 176 | -} | ||
| 177 | - | 1 | +/** |
| 2 | + * 处理线调文件 | ||
| 3 | + */ | ||
| 4 | +var fs = require('fs') | ||
| 5 | + , cheerio = require('cheerio') | ||
| 6 | + , minifier = require('./minifier') | ||
| 7 | + , crypto = require("crypto") | ||
| 8 | + , CleanCSS = require('clean-css') | ||
| 9 | + , UglifyJS = require("uglify-js"); | ||
| 10 | +; | ||
| 11 | + | ||
| 12 | +//不参与的目录 | ||
| 13 | +var pName = 'bsth_control' | ||
| 14 | + , path = process.cwd() | ||
| 15 | + //根目录 | ||
| 16 | + , root = path.substr(0, path.indexOf('\\src\\main')) | ||
| 17 | + , workspace = root.substr(0, root.indexOf('\\' + pName)) | ||
| 18 | + //临时目录 | ||
| 19 | + , dest = (workspace + '\\' + pName + '@fatso_copy').replace(/\//g, '\\') | ||
| 20 | + , _static = '\\src\\main\\resources\\static'; | ||
| 21 | + | ||
| 22 | + | ||
| 23 | +var mainFile = dest + _static + '\\real_control_v2\\main.html'; | ||
| 24 | +var mapFile = dest + _static + '\\real_control_v2\\mapmonitor\\real.html'; | ||
| 25 | +var realCtl = { | ||
| 26 | + /** | ||
| 27 | + * 处理线调首页 | ||
| 28 | + */ | ||
| 29 | + handleMain: function (cb) { | ||
| 30 | + //读取文件 | ||
| 31 | + var data = fs.readFileSync(mainFile, 'utf-8') | ||
| 32 | + , $ = cheerio.load(data); | ||
| 33 | + | ||
| 34 | + handleCss($, function () { | ||
| 35 | + handleJs($, mainFile, cb); | ||
| 36 | + }); | ||
| 37 | + }, | ||
| 38 | + /** | ||
| 39 | + * 处理地图模块 | ||
| 40 | + * @param cb | ||
| 41 | + */ | ||
| 42 | + handleMap: function (cb) { | ||
| 43 | + //读取文件 | ||
| 44 | + var data = fs.readFileSync(mapFile, 'utf-8') | ||
| 45 | + , $ = cheerio.load(data); | ||
| 46 | + | ||
| 47 | + handleCss($, function () { | ||
| 48 | + handleJs($, mapFile, cb); | ||
| 49 | + }); | ||
| 50 | + } | ||
| 51 | +}; | ||
| 52 | + | ||
| 53 | +/** | ||
| 54 | + * 处理css | ||
| 55 | + * @type {any} | ||
| 56 | + */ | ||
| 57 | +var handleCss = function ($, cb) { | ||
| 58 | + var cssArray = $('link[rel=stylesheet][merge]'); | ||
| 59 | + //按 merge 值分组 | ||
| 60 | + var cssMap = {}, mergeName; | ||
| 61 | + for (var i = 0, c; c = cssArray[i++];) { | ||
| 62 | + mergeName = $(c).attr('merge'); | ||
| 63 | + if (!cssMap[mergeName]) | ||
| 64 | + cssMap[mergeName] = []; | ||
| 65 | + cssMap[mergeName].push(dest + _static + $(c).attr('href')); | ||
| 66 | + //remove | ||
| 67 | + $(c).remove(); | ||
| 68 | + } | ||
| 69 | + //按 merge 合并压缩css | ||
| 70 | + var ks = get_keys(cssMap), index = 0; | ||
| 71 | + (function () { | ||
| 72 | + if (index >= ks.length) { | ||
| 73 | + cb && cb(); | ||
| 74 | + return; | ||
| 75 | + } | ||
| 76 | + var k = ks[index]; | ||
| 77 | + index++; | ||
| 78 | + var f = arguments.callee; | ||
| 79 | + //合并css | ||
| 80 | + new CleanCSS().minify(cssMap[k], function (error, out) { | ||
| 81 | + var data = out.styles; | ||
| 82 | + var fName = (k + '_' + md5(data)) + '.css'; | ||
| 83 | + //写入 assets css 目录下 | ||
| 84 | + var descFile = dest + _static + '\\real_control_v2\\assets\\css\\' + fName; | ||
| 85 | + fs.open(descFile, 'a', function (err, fd) { | ||
| 86 | + | ||
| 87 | + fs.write(fd, data, function () { | ||
| 88 | + var tag = '<link rel="stylesheet" href="/real_control_v2/assets/css/' + fName + '"/>'; | ||
| 89 | + if ($('head').length > 0) | ||
| 90 | + $('head').append(tag); | ||
| 91 | + else { | ||
| 92 | + if($('link').length > 0) | ||
| 93 | + $('link').last().before(tag); | ||
| 94 | + else | ||
| 95 | + $('div').first().before(tag); | ||
| 96 | + } | ||
| 97 | + console.log(k + ' css', '结束,下一个'); | ||
| 98 | + f(); | ||
| 99 | + }); | ||
| 100 | + }); | ||
| 101 | + }); | ||
| 102 | + })(); | ||
| 103 | +}; | ||
| 104 | + | ||
| 105 | +/** | ||
| 106 | + * 处理js | ||
| 107 | + */ | ||
| 108 | +var handleJs = function ($, file, cb) { | ||
| 109 | + var scriptArray = $('script[merge]'); | ||
| 110 | + //按 merge 值分组 | ||
| 111 | + var jsMap = {}, mergeName; | ||
| 112 | + for (var i = 0, s; s = scriptArray[i++];) { | ||
| 113 | + mergeName = $(s).attr('merge'); | ||
| 114 | + if (!jsMap[mergeName]) | ||
| 115 | + jsMap[mergeName] = []; | ||
| 116 | + jsMap[mergeName].push(dest + _static + $(s).attr('src')); | ||
| 117 | + //remove | ||
| 118 | + $(s).remove(); | ||
| 119 | + } | ||
| 120 | + | ||
| 121 | + //按 merge 合并压缩js | ||
| 122 | + var ks = get_keys(jsMap), index = 0; | ||
| 123 | + (function () { | ||
| 124 | + if (index >= ks.length) { | ||
| 125 | + write(file, $.html()); | ||
| 126 | + console.log(file + ' 结束'.green); | ||
| 127 | + cb && cb(); | ||
| 128 | + return; | ||
| 129 | + } | ||
| 130 | + var k = ks[index]; | ||
| 131 | + index++; | ||
| 132 | + var f = arguments.callee; | ||
| 133 | + //合并压缩js | ||
| 134 | + var result = UglifyJS.minify(jsMap[k]); | ||
| 135 | + var data = result.code; | ||
| 136 | + var fName = (k + '_' + md5(data)) + '.js'; | ||
| 137 | + //写入 assets js 目录下 | ||
| 138 | + var descFile = dest + _static + '\\real_control_v2\\assets\\js\\' + fName; | ||
| 139 | + fs.open(descFile, 'a', function (err, fd) { | ||
| 140 | + | ||
| 141 | + fs.write(fd, data, function () { | ||
| 142 | + var tag = '<script src="/real_control_v2/assets/js/' + fName + '"></script>'; | ||
| 143 | + if ($('body').length > 0) | ||
| 144 | + $('body').append(tag); | ||
| 145 | + else { | ||
| 146 | + //没有body 就写在尾部 | ||
| 147 | + $('*').last().after(tag); | ||
| 148 | + } | ||
| 149 | + console.log(k + ' js', '结束,下一个'); | ||
| 150 | + f(); | ||
| 151 | + }); | ||
| 152 | + }); | ||
| 153 | + })(); | ||
| 154 | +}; | ||
| 155 | + | ||
| 156 | +var get_keys = function (json) { | ||
| 157 | + var array = []; | ||
| 158 | + for (var key in json) { | ||
| 159 | + array.push(key); | ||
| 160 | + } | ||
| 161 | + return array; | ||
| 162 | +}; | ||
| 163 | + | ||
| 164 | +function md5(text) { | ||
| 165 | + return crypto.createHash("md5").update(text).digest("hex"); | ||
| 166 | +} | ||
| 167 | + | ||
| 168 | +function write(file, text) { | ||
| 169 | + fs.writeFile(file, text, function (err) { | ||
| 170 | + if (err) { | ||
| 171 | + console.log(err.toString().red); | ||
| 172 | + process.exit(); | ||
| 173 | + } | ||
| 174 | + console.log(file.green); | ||
| 175 | + }); | ||
| 176 | +} | ||
| 177 | + | ||
| 178 | module.exports = realCtl; | 178 | module.exports = realCtl; |
| 179 | \ No newline at end of file | 179 | \ No newline at end of file |
src/main/resources/static/pages/forms/statement/jobSummary.html
| @@ -277,6 +277,27 @@ | @@ -277,6 +277,27 @@ | ||
| 277 | initPinYinSelect2('#line',data,''); | 277 | initPinYinSelect2('#line',data,''); |
| 278 | 278 | ||
| 279 | }) */ | 279 | }) */ |
| 280 | + | ||
| 281 | + jQuery.fn.rowspan = function(colIdx) { //封装的一个JQuery小插件 | ||
| 282 | + return this.each(function(){ | ||
| 283 | + var that; | ||
| 284 | + $('tr', this).each(function(row) { | ||
| 285 | + $('td:eq('+colIdx+')', this).filter(':visible').each(function(col) { | ||
| 286 | + if (that!=null && $(this).html() == $(that).html()) { | ||
| 287 | + rowspan = $(that).attr("rowSpan"); | ||
| 288 | + if (rowspan == undefined) { | ||
| 289 | + $(that).attr("rowSpan",1); | ||
| 290 | + rowspan = $(that).attr("rowSpan"); } | ||
| 291 | + rowspan = Number(rowspan)+1; | ||
| 292 | + $(that).attr("rowSpan",rowspan); | ||
| 293 | + $(this).hide(); | ||
| 294 | + } else { | ||
| 295 | + that = this; | ||
| 296 | + } | ||
| 297 | + }); | ||
| 298 | + }); | ||
| 299 | + }); | ||
| 300 | + } | ||
| 280 | $("#query").on("click",function(){ | 301 | $("#query").on("click",function(){ |
| 281 | var line=$("#line").val();; | 302 | var line=$("#line").val();; |
| 282 | var lineName=$(".select2-selection__rendered").html(); | 303 | var lineName=$(".select2-selection__rendered").html(); |
| @@ -292,6 +313,11 @@ | @@ -292,6 +313,11 @@ | ||
| 292 | var list_lbqk = template('list_lbqk',{list:result}); | 313 | var list_lbqk = template('list_lbqk',{list:result}); |
| 293 | // 把渲染好的模版html文本追加到表格中 | 314 | // 把渲染好的模版html文本追加到表格中 |
| 294 | $('#forms .list_lbqk').html(list_lbqk); | 315 | $('#forms .list_lbqk').html(list_lbqk); |
| 316 | + $('#forms .list_lbqk').rowspan(0); | ||
| 317 | + $('#forms .list_lbqk').rowspan(1); | ||
| 318 | + $('#forms .list_lbqk').rowspan(2); | ||
| 319 | + $('#forms .list_lbqk').rowspan(3); | ||
| 320 | + | ||
| 295 | }) | 321 | }) |
| 296 | 322 | ||
| 297 | $get('/report/jobLjqk',{line:line,date:date},function(result){ | 323 | $get('/report/jobLjqk',{line:line,date:date},function(result){ |
| @@ -328,13 +354,19 @@ | @@ -328,13 +354,19 @@ | ||
| 328 | <td>{{obj.nr}}</td> | 354 | <td>{{obj.nr}}</td> |
| 329 | <td>{{obj.lp}}</td> | 355 | <td>{{obj.lp}}</td> |
| 330 | <td>{{obj.nbbm}}</td> | 356 | <td>{{obj.nbbm}}</td> |
| 331 | - <td>{{obj.jgh}}</td> | 357 | + <td {{if obj.lx ==1}} colspan="2" {{/if}}>{{obj.jgh}}</td> |
| 358 | + {{if obj.lx ==0}} | ||
| 332 | <td>{{obj.dz}}</td> | 359 | <td>{{obj.dz}}</td> |
| 333 | - <td>{{obj.sj}}</td> | 360 | + {{/if}} |
| 361 | + <td {{if obj.lx ==1}} colspan="3" {{/if}}>{{obj.sj}}</td> | ||
| 362 | + {{if obj.lx ==0}} | ||
| 334 | <td> </td> | 363 | <td> </td> |
| 335 | <td>{{obj.lbbc}}</td> | 364 | <td>{{obj.lbbc}}</td> |
| 336 | - <td>{{obj.lblc}}</td> | 365 | + {{/if}} |
| 366 | + <td {{if obj.lx ==1}} colspan="2" {{/if}}>{{obj.lblc}}</td> | ||
| 367 | + {{if obj.lx ==0}} | ||
| 337 | <td>{{obj.jyqp}}</td> | 368 | <td>{{obj.jyqp}}</td> |
| 369 | + {{/if}} | ||
| 338 | </tr> | 370 | </tr> |
| 339 | {{/each}} | 371 | {{/each}} |
| 340 | {{if list.length == 0}} | 372 | {{if list.length == 0}} |
src/main/resources/static/pages/forms/statement/scheduleDaily.html
| @@ -551,7 +551,7 @@ letter-spacing: 20px; | @@ -551,7 +551,7 @@ letter-spacing: 20px; | ||
| 551 | <td>{{obj.fast}}</td> | 551 | <td>{{obj.fast}}</td> |
| 552 | <td>{{obj.slow}}</td> | 552 | <td>{{obj.slow}}</td> |
| 553 | <td>{{obj.fcsj}}</td> | 553 | <td>{{obj.fcsj}}</td> |
| 554 | - <td>{{obj.fcsjActual}} | 554 | + <td style="word-break: keep-all;white-space:nowrap;">{{obj.fcsjActual}} |
| 555 | {{if obj.bcType== "in"}} | 555 | {{if obj.bcType== "in"}} |
| 556 | (进) | 556 | (进) |
| 557 | {{/if}} | 557 | {{/if}} |
src/main/resources/static/pages/mforms/shifdays/shifday.html
src/main/resources/static/pages/scheduleApp/module/core/busConfig/module.js
| @@ -126,8 +126,9 @@ angular.module('ScheduleApp').controller( | @@ -126,8 +126,9 @@ angular.module('ScheduleApp').controller( | ||
| 126 | 126 | ||
| 127 | // 导出excel | 127 | // 导出excel |
| 128 | self.exportData = function() { | 128 | self.exportData = function() { |
| 129 | - if (busConfigService.dataExport()) { | ||
| 130 | - busConfigService.dataExport().then( | 129 | + var p = busConfigService.dataExport(); |
| 130 | + if (p) { | ||
| 131 | + p.then( | ||
| 131 | function(result) { | 132 | function(result) { |
| 132 | fileDownload.downloadFile(result.data, "application/octet-stream", "车辆配置信息.xls"); | 133 | fileDownload.downloadFile(result.data, "application/octet-stream", "车辆配置信息.xls"); |
| 133 | }, | 134 | }, |
src/main/resources/static/pages/scheduleApp/module/core/employeeConfig/module.js
| @@ -127,8 +127,9 @@ angular.module('ScheduleApp').controller( | @@ -127,8 +127,9 @@ angular.module('ScheduleApp').controller( | ||
| 127 | 127 | ||
| 128 | // 导出excel | 128 | // 导出excel |
| 129 | self.exportData = function() { | 129 | self.exportData = function() { |
| 130 | - if (service.dataExport()) { | ||
| 131 | - service.dataExport().then( | 130 | + var p = service.dataExport(); |
| 131 | + if (p) { | ||
| 132 | + p.then( | ||
| 132 | function(result) { | 133 | function(result) { |
| 133 | fileDownload.downloadFile(result.data, "application/octet-stream", "人员配置信息.xls"); | 134 | fileDownload.downloadFile(result.data, "application/octet-stream", "人员配置信息.xls"); |
| 134 | }, | 135 | }, |
src/main/resources/static/pages/scheduleApp/module/core/guideboardManage/module.js
| @@ -131,8 +131,9 @@ angular.module('ScheduleApp').controller( | @@ -131,8 +131,9 @@ angular.module('ScheduleApp').controller( | ||
| 131 | 131 | ||
| 132 | // 导出excel | 132 | // 导出excel |
| 133 | self.exportData = function() { | 133 | self.exportData = function() { |
| 134 | - if (service.dataExport()) { | ||
| 135 | - service.dataExport().then( | 134 | + var p = service.dataExport(); |
| 135 | + if (p) { | ||
| 136 | + p.then( | ||
| 136 | function(result) { | 137 | function(result) { |
| 137 | fileDownload.downloadFile(result.data, "application/octet-stream", "路牌信息.xls"); | 138 | fileDownload.downloadFile(result.data, "application/octet-stream", "路牌信息.xls"); |
| 138 | }, | 139 | }, |
src/test/java/com/bsth/service/schedule/rules/SchedulePlan1Test.java
0 → 100644
| 1 | +package com.bsth.service.schedule.rules; | ||
| 2 | + | ||
| 3 | +import com.bsth.service.schedule.BaseTest; | ||
| 4 | +import org.dbunit.database.DatabaseConnection; | ||
| 5 | +import org.dbunit.database.IDatabaseConnection; | ||
| 6 | +import org.dbunit.dataset.IDataSet; | ||
| 7 | +import org.dbunit.dataset.xml.FlatXmlDataSetBuilder; | ||
| 8 | +import org.dbunit.operation.DatabaseOperation; | ||
| 9 | +import org.junit.After; | ||
| 10 | +import org.junit.Before; | ||
| 11 | +import org.junit.Test; | ||
| 12 | +import org.slf4j.Logger; | ||
| 13 | +import org.slf4j.LoggerFactory; | ||
| 14 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 15 | +import org.springframework.core.io.ClassPathResource; | ||
| 16 | +import org.springframework.core.io.Resource; | ||
| 17 | + | ||
| 18 | +import javax.sql.DataSource; | ||
| 19 | + | ||
| 20 | +/** | ||
| 21 | + * 排班计划测试(手工排班测试)。 | ||
| 22 | + */ | ||
| 23 | +public class SchedulePlan1Test extends BaseTest { | ||
| 24 | + /** 日志记录器 */ | ||
| 25 | + private static final Logger logger = LoggerFactory.getLogger(SchedulePlan1Test.class); | ||
| 26 | + | ||
| 27 | + @Autowired | ||
| 28 | + private DataSource dataSource; | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * 初始化数据。 | ||
| 32 | + */ | ||
| 33 | + @Before | ||
| 34 | + public void initData() throws Exception { | ||
| 35 | + logger.info("载入数据......"); | ||
| 36 | + | ||
| 37 | + // 获取数据库连接 | ||
| 38 | + IDatabaseConnection iDatabaseConnection = new DatabaseConnection(dataSource.getConnection()); | ||
| 39 | + // 获取Dbunit数据源 | ||
| 40 | + Resource res = new ClassPathResource("testdata/d2.xml"); | ||
| 41 | + FlatXmlDataSetBuilder flatXmlDataSetBuilder = new FlatXmlDataSetBuilder(); | ||
| 42 | + flatXmlDataSetBuilder.setColumnSensing(false); | ||
| 43 | + flatXmlDataSetBuilder.setCaseSensitiveTableNames(false); | ||
| 44 | + IDataSet iDataSet = flatXmlDataSetBuilder.build(res.getInputStream()); | ||
| 45 | + | ||
| 46 | + // 载入数据 | ||
| 47 | + DatabaseOperation.CLEAN_INSERT.execute(iDatabaseConnection, iDataSet); | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + /** | ||
| 51 | + * 清除数据。 | ||
| 52 | + */ | ||
| 53 | + @After | ||
| 54 | + public void destoryData() throws Exception { | ||
| 55 | + logger.info("清除数据......"); | ||
| 56 | + // 获取数据库连接 | ||
| 57 | + IDatabaseConnection iDatabaseConnection = new DatabaseConnection(dataSource.getConnection()); | ||
| 58 | + // 获取Dbunit数据源 | ||
| 59 | + Resource res = new ClassPathResource("testdata/d2.xml"); | ||
| 60 | + FlatXmlDataSetBuilder flatXmlDataSetBuilder = new FlatXmlDataSetBuilder(); | ||
| 61 | + flatXmlDataSetBuilder.setColumnSensing(false); | ||
| 62 | + flatXmlDataSetBuilder.setCaseSensitiveTableNames(false); | ||
| 63 | + IDataSet iDataSet = flatXmlDataSetBuilder.build(res.getInputStream()); | ||
| 64 | + | ||
| 65 | + // 清除数据 | ||
| 66 | + DatabaseOperation.DELETE_ALL.execute(iDatabaseConnection, iDataSet); | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + | ||
| 70 | + @Test | ||
| 71 | + public void t1() { | ||
| 72 | + | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + | ||
| 76 | + | ||
| 77 | + | ||
| 78 | + | ||
| 79 | + | ||
| 80 | + | ||
| 81 | + | ||
| 82 | + | ||
| 83 | + | ||
| 84 | + | ||
| 85 | + | ||
| 86 | + | ||
| 87 | + | ||
| 88 | + | ||
| 89 | + | ||
| 90 | + | ||
| 91 | + | ||
| 92 | + | ||
| 93 | + | ||
| 94 | +} |
src/test/java/com/bsth/service/schedule/rules/SchedulePlan2Test.java
0 → 100644
src/test/resources/testdata/new.txt
0 → 100644
| 1 | +1、车狼配置,每辆车都可以配置单独的停车点及相关数据,并提供两种设置模式(早晚,复驶) | ||
| 2 | +2、规则管理,修改规则的界面图形化,更加方便修改 | ||
| 3 | +3、时刻表管理,导入时刻表xls做严格数据判定,时刻表明细修改提供跟方便的图形化修改方式 | ||
| 4 | +4、排班计划管理,提供每次排班的操作信息,时间段,所使用的时刻表,可以查看具体的排班明细(细化到班次) | ||
| 5 | + 生成排班时,提供详细的时刻表统计信息,提供两种排班模式(历史排班优先,规则优先) | ||
| 6 | +5、调度值勤日报,列出每天的基于线路,路牌的排班统计,可以更换车辆,人员 | ||
| 7 | + 此功能从排班计划中抽取出来,单独列出,供调派人员使用 | ||
| 0 | \ No newline at end of file | 8 | \ No newline at end of file |
src/test/resources/testdata/test1.txt
0 → 100644
| 1 | +select * from jwgl_f_t_clxh_workflow_detail a where a.ID_LYSYLB = 36; | ||
| 2 | + | ||
| 3 | +select sum(amount - tl_amount) from jwgl_f_t_clxh_workflow_detail | ||
| 4 | +where | ||
| 5 | +to_date(statdateid, 'YYYYMMDD') >= to_date('20170301', 'YYYYMMDD') | ||
| 6 | +and to_date(statdateid, 'YYYYMMDD') <= to_date('20170331', 'YYYYMMDD') | ||
| 7 | + | ||
| 8 | +select * from JWGL_D_T_LYSYLB | ||
| 9 | + | ||
| 10 | +-- all xh | ||
| 11 | + | ||
| 12 | +select | ||
| 13 | +statdateid statdate | ||
| 14 | +, ssjc gs | ||
| 15 | +, xl xl | ||
| 16 | +, zbh cl | ||
| 17 | +, b.SYLB1 || '-' || b.SYLB2 as lylb | ||
| 18 | +, (sum(amount) - sum(tl_amount)) ch | ||
| 19 | +from JWGL_F_T_CLXH_WORKFLOW_DETAIL a, JWGL_D_T_LYSYLB b | ||
| 20 | +where | ||
| 21 | +to_date(statdateid, 'YYYYMMDD') >= to_date('20170301', 'YYYYMMDD') | ||
| 22 | +and to_date(statdateid, 'YYYYMMDD') <= to_date('20170331', 'YYYYMMDD') | ||
| 23 | +and a.ID_LYSYLB = b.ID(+) | ||
| 24 | +group by | ||
| 25 | +statdateid | ||
| 26 | +, ssjc | ||
| 27 | +, xl | ||
| 28 | +, zbh | ||
| 29 | +, b.SYLB1 || '-' || b.SYLB2 | ||
| 30 | + | ||
| 31 | +-- part1 | ||
| 32 | + | ||
| 33 | +select sum(ch) from | ||
| 34 | +( | ||
| 35 | +select | ||
| 36 | +statdateid statdate | ||
| 37 | +, ssjc gs | ||
| 38 | +, xl xl | ||
| 39 | +, zbh cl | ||
| 40 | +, b.SYLB1 || '-' || b.SYLB2 as lylb | ||
| 41 | +, (sum(amount) - sum(tl_amount)) ch | ||
| 42 | +from JWGL_F_T_CLXH_WORKFLOW_DETAIL a, JWGL_D_T_LYSYLB b | ||
| 43 | +where | ||
| 44 | +to_date(statdateid, 'YYYYMMDD') >= to_date('20170301', 'YYYYMMDD') | ||
| 45 | +and to_date(statdateid, 'YYYYMMDD') <= to_date('20170331', 'YYYYMMDD') | ||
| 46 | +and a.ID_LYSYLB = b.ID(+) | ||
| 47 | +group by | ||
| 48 | +statdateid | ||
| 49 | +, ssjc | ||
| 50 | +, xl | ||
| 51 | +, zbh | ||
| 52 | +, b.SYLB1 || '-' || b.SYLB2 | ||
| 53 | +) | ||
| 54 | +where lylb in ( | ||
| 55 | +'路救-路救', | ||
| 56 | +'小修-小修机工', | ||
| 57 | +'专项-安检', | ||
| 58 | +'专项-节检', | ||
| 59 | +'专项-水箱', | ||
| 60 | +'专项-电瓶', | ||
| 61 | +'小修-小修电工', | ||
| 62 | +'专项-电并', | ||
| 63 | +'小修-小修车身', | ||
| 64 | +'专项-镗固', | ||
| 65 | +'保养-一级保养', | ||
| 66 | +'小修-发动机', | ||
| 67 | +'专项-轮胎', | ||
| 68 | +'分摊-轮胎', | ||
| 69 | +'专项-润滑油', | ||
| 70 | +'总成-差变速', | ||
| 71 | +'总成-大泵', | ||
| 72 | +'总成-小总成', | ||
| 73 | +'总成-发动机', | ||
| 74 | +'保养-二级保养', | ||
| 75 | +'保养-三级保养', | ||
| 76 | +'整修-整修', | ||
| 77 | +'空调-保外', | ||
| 78 | +'空调-保内', | ||
| 79 | +'事故-事故' | ||
| 80 | +) | ||
| 81 | + | ||
| 82 | +-- part2 | ||
| 83 | + | ||
| 84 | +select sum(ch) from | ||
| 85 | +( | ||
| 86 | +select | ||
| 87 | +statdateid statdate | ||
| 88 | +, ssjc gs | ||
| 89 | +, xl xl | ||
| 90 | +, zbh cl | ||
| 91 | +, b.SYLB1 || '-' || b.SYLB2 as lylb | ||
| 92 | +, (sum(amount) - sum(tl_amount)) ch | ||
| 93 | +from JWGL_F_T_CLXH_WORKFLOW_DETAIL a, JWGL_D_T_LYSYLB b | ||
| 94 | +where | ||
| 95 | +to_date(statdateid, 'YYYYMMDD') >= to_date('20170301', 'YYYYMMDD') | ||
| 96 | +and to_date(statdateid, 'YYYYMMDD') <= to_date('20170331', 'YYYYMMDD') | ||
| 97 | +and a.ID_LYSYLB = b.ID(+) | ||
| 98 | +group by | ||
| 99 | +statdateid | ||
| 100 | +, ssjc | ||
| 101 | +, xl | ||
| 102 | +, zbh | ||
| 103 | +, b.SYLB1 || '-' || b.SYLB2 | ||
| 104 | +) | ||
| 105 | +where lylb in( | ||
| 106 | +'分摊-镗固', | ||
| 107 | +'专项-机油', | ||
| 108 | +'分摊-机油', | ||
| 109 | +'总成-其它', | ||
| 110 | +'分摊-工具', | ||
| 111 | +'分摊-辅助料', | ||
| 112 | +'分摊-设备', | ||
| 113 | +'车间经费-车间经费' | ||
| 114 | +) | ||
| 115 | + | ||
| 116 | + | ||
| 117 | + | ||
| 118 | + | ||
| 119 | + | ||
| 120 | + | ||
| 121 | + | ||
| 122 | + | ||
| 123 | + | ||
| 124 | + | ||
| 125 | + | ||
| 126 | + | ||
| 127 | + | ||
| 128 | + | ||
| 129 | + | ||
| 130 | + | ||
| 131 | + | ||
| 132 | + | ||
| 133 | + |
src/test/resources/testdata/test2.txt
0 → 100644
| 1 | + | ||
| 2 | +select * from JWGL_FR_T_CH_REPORT_DATA1; | ||
| 3 | + | ||
| 4 | +select * from JWGL_FR_T_CH_REPORT_DATA2; | ||
| 5 | + | ||
| 6 | +-- sum part1 | ||
| 7 | + | ||
| 8 | +select | ||
| 9 | +( | ||
| 10 | +sum(lj_lj) + sum(xx_xxjg) + sum(xx_xxdg) + sum(zx_db) + sum(xx_xxcs) + sum(zx_tg) + sum(by_b1) + | ||
| 11 | +sum(nvl(future_bx, 0)) + sum(xx_fdj) + sum(zx_lt) + sum(zx_rhy) + sum(zc_cbx) + sum(zc_db) + sum(zc_xzc) + | ||
| 12 | +sum(zc_fdj) + sum(by_b2) + sum(by_b3) + sum(nvl(future_wx_db, 0)) + sum(nvl(future_wxfy, 0)) + sum(nvl(future_ktwx, 0)) + sum(nvl(future_sx, 0)) + | ||
| 13 | +sum(nvl(future_dp, 0)) + sum(zx_zx) + sum(kt_bw) + sum(sg_sg) | ||
| 14 | +) as part1 | ||
| 15 | +from JWGL_FR_T_CH_REPORT_DATA1 | ||
| 16 | +where | ||
| 17 | +statdate >= to_date('20170301', 'YYYYMMDD') | ||
| 18 | +and statdate <= to_date('20170331', 'YYYYMMDD') | ||
| 19 | + | ||
| 20 | +-- sum part2 | ||
| 21 | + | ||
| 22 | +select | ||
| 23 | +( | ||
| 24 | +sum(zx_tg) + sum(jy) + sum(qt) + sum(zcfl) + sum(gj) + sum(sb) + sum(cjjf) | ||
| 25 | +) as part2 | ||
| 26 | +from JWGL_FR_T_CH_REPORT_DATA2 | ||
| 27 | +where statdate = to_date('20170331', 'YYYYMMDD') | ||
| 0 | \ No newline at end of file | 28 | \ No newline at end of file |