Commit 5e99b8a669fd0966f2cbd7cfd4d64386f9663854
1 parent
12df3542
PSM-14
Showing
14 changed files
with
653 additions
and
114 deletions
Too many changes to show.
To preserve performance only 14 of 33 files are displayed.
src/main/java/com/bsth/controller/BaseController2.java
| @@ -99,6 +99,12 @@ public class BaseController2<T, ID extends Serializable> { | @@ -99,6 +99,12 @@ public class BaseController2<T, ID extends Serializable> { | ||
| 99 | return t; | 99 | return t; |
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | + @RequestMapping(value="/{id}", method = RequestMethod.POST) | ||
| 103 | + public T update(@RequestBody T t) { | ||
| 104 | + baseService.save(t); | ||
| 105 | + return t; | ||
| 106 | + } | ||
| 107 | + | ||
| 102 | /** | 108 | /** |
| 103 | * | 109 | * |
| 104 | * @Title: findById | 110 | * @Title: findById |
src/main/java/com/bsth/controller/schedule/TTInfoDetailController.java
| @@ -4,20 +4,32 @@ import com.bsth.common.ResponseCode; | @@ -4,20 +4,32 @@ import com.bsth.common.ResponseCode; | ||
| 4 | import com.bsth.controller.BaseController; | 4 | import com.bsth.controller.BaseController; |
| 5 | import com.bsth.entity.CarPark; | 5 | import com.bsth.entity.CarPark; |
| 6 | import com.bsth.entity.LineInformation; | 6 | import com.bsth.entity.LineInformation; |
| 7 | +import com.bsth.entity.StationRoute; | ||
| 8 | +import com.bsth.entity.schedule.GuideboardInfo; | ||
| 7 | import com.bsth.entity.schedule.TTInfoDetail; | 9 | import com.bsth.entity.schedule.TTInfoDetail; |
| 8 | import com.bsth.repository.schedule.TTInfoDetailRepository; | 10 | import com.bsth.repository.schedule.TTInfoDetailRepository; |
| 9 | import com.bsth.service.CarParkService; | 11 | import com.bsth.service.CarParkService; |
| 10 | import com.bsth.service.LineInformationService; | 12 | import com.bsth.service.LineInformationService; |
| 11 | -import com.bsth.service.schedule.TTInfoDetailServiceImpl; | 13 | +import com.bsth.service.StationRouteService; |
| 14 | +import com.bsth.service.schedule.GuideboardInfoService; | ||
| 15 | +import com.bsth.service.schedule.TTInfoDetailService; | ||
| 16 | +import com.bsth.service.schedule.utils.DataImportExportService; | ||
| 17 | +import jxl.Cell; | ||
| 18 | +import jxl.Sheet; | ||
| 19 | +import jxl.Workbook; | ||
| 20 | +import jxl.write.Label; | ||
| 21 | +import jxl.write.WritableSheet; | ||
| 22 | +import jxl.write.WritableWorkbook; | ||
| 12 | import org.apache.commons.lang3.StringUtils; | 23 | import org.apache.commons.lang3.StringUtils; |
| 13 | import org.springframework.beans.factory.annotation.Autowired; | 24 | import org.springframework.beans.factory.annotation.Autowired; |
| 25 | +import org.springframework.util.CollectionUtils; | ||
| 14 | import org.springframework.web.bind.annotation.*; | 26 | import org.springframework.web.bind.annotation.*; |
| 15 | import org.springframework.web.multipart.MultipartFile; | 27 | import org.springframework.web.multipart.MultipartFile; |
| 16 | 28 | ||
| 17 | -import java.util.HashMap; | ||
| 18 | -import java.util.Iterator; | ||
| 19 | -import java.util.List; | ||
| 20 | -import java.util.Map; | 29 | +import java.io.File; |
| 30 | +import java.util.*; | ||
| 31 | +import java.util.regex.Matcher; | ||
| 32 | +import java.util.regex.Pattern; | ||
| 21 | 33 | ||
| 22 | /** | 34 | /** |
| 23 | * Created by xu on 16/7/2. | 35 | * Created by xu on 16/7/2. |
| @@ -26,14 +38,340 @@ import java.util.Map; | @@ -26,14 +38,340 @@ import java.util.Map; | ||
| 26 | @RequestMapping("tidc") | 38 | @RequestMapping("tidc") |
| 27 | public class TTInfoDetailController extends BaseController<TTInfoDetail, Long> { | 39 | public class TTInfoDetailController extends BaseController<TTInfoDetail, Long> { |
| 28 | @Autowired | 40 | @Autowired |
| 29 | - private TTInfoDetailServiceImpl ttInfoDetailService; | 41 | + private TTInfoDetailService ttInfoDetailService; |
| 30 | @Autowired | 42 | @Autowired |
| 31 | private CarParkService carParkService; | 43 | private CarParkService carParkService; |
| 32 | @Autowired | 44 | @Autowired |
| 33 | private LineInformationService lineInformationService; | 45 | private LineInformationService lineInformationService; |
| 34 | @Autowired | 46 | @Autowired |
| 35 | private TTInfoDetailRepository ttInfoDetailRepository; | 47 | private TTInfoDetailRepository ttInfoDetailRepository; |
| 48 | + @Autowired | ||
| 49 | + private DataImportExportService dataImportExportService; | ||
| 50 | + @Autowired | ||
| 51 | + private StationRouteService stationRouteService; | ||
| 52 | + @Autowired | ||
| 53 | + private GuideboardInfoService guideboardInfoService; | ||
| 54 | + | ||
| 55 | + | ||
| 56 | + public static class ExcelFileOutput { | ||
| 57 | + private String fileName; | ||
| 58 | + private List<Map<String, Object>> sheetnames = new ArrayList<>(); | ||
| 59 | + | ||
| 60 | + public String getFileName() { | ||
| 61 | + return fileName; | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + public void setFileName(String fileName) { | ||
| 65 | + this.fileName = fileName; | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + public List<Map<String, Object>> getSheetnames() { | ||
| 69 | + return sheetnames; | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + public void setSheetnames(List<Map<String, Object>> sheetnames) { | ||
| 73 | + this.sheetnames = sheetnames; | ||
| 74 | + } | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + /** | ||
| 78 | + * 1、上传Excel文件,返回文件全路径名,工作区名称列表。 | ||
| 79 | + * @param file | ||
| 80 | + * @return | ||
| 81 | + * @throws Exception | ||
| 82 | + */ | ||
| 83 | + @RequestMapping(value = "/uploadFile", method = RequestMethod.POST) | ||
| 84 | + public ExcelFileOutput fileUpload(MultipartFile file) throws Exception { | ||
| 85 | + // 返回对象 | ||
| 86 | + ExcelFileOutput rs = new ExcelFileOutput(); | ||
| 87 | + | ||
| 88 | + // 上传文件 | ||
| 89 | + File file1 = dataImportExportService.uploadFile(file); | ||
| 90 | + // 获取文件的sheet | ||
| 91 | + Workbook book = Workbook.getWorkbook(file1); | ||
| 92 | + for (Sheet sheet : book.getSheets()) { | ||
| 93 | + String sheetname = sheet.getName(); | ||
| 94 | + Map<String, Object> s = new HashMap<>(); | ||
| 95 | + s.put("name", sheetname); | ||
| 96 | + rs.getSheetnames().add(s); | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + rs.setFileName(file1.getAbsolutePath()); | ||
| 100 | + return rs; | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + /** | ||
| 104 | + * 2、验证sheet(以后放到规则引擎里去做)。 | ||
| 105 | + * @param filename excel文件全路径名 | ||
| 106 | + * @param sheetname sheet名字 | ||
| 107 | + * @param lineid 线路id | ||
| 108 | + * @param linename 线路名称 | ||
| 109 | + * @return | ||
| 110 | + */ | ||
| 111 | + @RequestMapping(value = "/validate/sheet", method = RequestMethod.POST) | ||
| 112 | + public Map<String, Object> validateSheet(String filename, String sheetname, Integer lineid, String linename) throws Exception { | ||
| 113 | + Map<String, Object> rtn = new HashMap<>(); | ||
| 114 | + Workbook book = Workbook.getWorkbook(new File(filename)); | ||
| 115 | + Sheet sheet = book.getSheet(sheetname); | ||
| 116 | + if (sheet.getRows() == 0 || sheet.getColumns() == 0) { // 工作区是否为空 | ||
| 117 | + rtn.put("status", ResponseCode.ERROR); | ||
| 118 | + rtn.put("msg", String.format("%s 工作区没有数据!", sheetname)); | ||
| 119 | + } else { | ||
| 120 | + if (sheet.getRows() <= 1 || sheet.getColumns() <= 1) { | ||
| 121 | + rtn.put("status", ResponseCode.ERROR); | ||
| 122 | + rtn.put("msg", String.format("工作区至少包含2行2列的数据")); | ||
| 123 | + return rtn; | ||
| 124 | + } else { | ||
| 125 | + Cell[] cells = sheet.getRow(0); // 获取第一行数据列 | ||
| 126 | + for (int i = 0; i < cells.length; i++) { | ||
| 127 | + String cell_con = cells[i].getContents(); | ||
| 128 | + if (StringUtils.isEmpty(cell_con)) { | ||
| 129 | + rtn.put("status", ResponseCode.ERROR); | ||
| 130 | + rtn.put("msg", String.format("第1行,第%d列数据不能为空", i + 1)); | ||
| 131 | + return rtn; | ||
| 132 | + } else { | ||
| 133 | + if (i == 0) { // 第一列必须是路牌2个字 | ||
| 134 | + if (!"路牌".equals(cell_con.trim())) { | ||
| 135 | + rtn.put("status", ResponseCode.ERROR); | ||
| 136 | + rtn.put("msg", "第1行,第1列数据必须是路牌2个字"); | ||
| 137 | + return rtn; | ||
| 138 | + } | ||
| 139 | + } else { // 排除出场,进场,其余内容到站点路由里查询,以各个方向的起点站为查询依据 | ||
| 140 | + if ((!"出场".equals(cell_con.trim())) && | ||
| 141 | + (!"进场".equals(cell_con.trim()))) { | ||
| 142 | + Map<String, Object> p1 = new HashMap<>(); | ||
| 143 | + p1.put("line.id_eq", lineid); | ||
| 144 | + p1.put("stationName_eq", cell_con.trim()); | ||
| 145 | + p1.put("stationMark_eq", "B"); | ||
| 146 | + | ||
| 147 | + List<StationRoute> stationRouteList = (List<StationRoute>) stationRouteService.list(p1); | ||
| 148 | + if (CollectionUtils.isEmpty(stationRouteList)) { | ||
| 149 | + rtn.put("status", ResponseCode.ERROR); | ||
| 150 | + rtn.put("msg", String.format("第1行,第%d列数据在%s站点路由中不是起点站", i + 1, linename)); | ||
| 151 | + return rtn; | ||
| 152 | + } else if (stationRouteList.size() > 1) { | ||
| 153 | + rtn.put("status", ResponseCode.ERROR); | ||
| 154 | + rtn.put("msg", String.format("第1行,第%d列数据在%s站点路由中上下行都是起点站", i + 1, linename)); | ||
| 155 | + return rtn; | ||
| 156 | + } | ||
| 157 | + } | ||
| 158 | + | ||
| 159 | + } | ||
| 160 | + } | ||
| 161 | + } | ||
| 162 | + | ||
| 163 | + // 验证路牌内容 | ||
| 164 | + Map<String, Integer> gbindexmap = new HashMap<>(); // 记录每个路牌在第几行 | ||
| 165 | + for (int i = 1; i < sheet.getRows(); i++) { // 从第2行开始验证数据 | ||
| 166 | + Cell bcell = sheet.getRow(i)[0]; // 获取第1列 | ||
| 167 | + String bcell_con = bcell.getContents(); | ||
| 168 | + if (StringUtils.isEmpty(bcell_con)) { | ||
| 169 | + rtn.put("status", ResponseCode.ERROR); | ||
| 170 | + rtn.put("msg", String.format("第%d行,第1列路牌无数据", i + 1)); | ||
| 171 | + return rtn; | ||
| 172 | + } else if (gbindexmap.get(bcell_con.trim()) != null) { | ||
| 173 | + rtn.put("status", ResponseCode.ERROR); | ||
| 174 | + rtn.put("msg", String.format("第%d行,第1列的路牌数据与第%d行,第1列数据重复", | ||
| 175 | + i + 1, | ||
| 176 | + gbindexmap.get(bcell_con.trim()))); | ||
| 177 | + return rtn; | ||
| 178 | + } else { | ||
| 179 | + Map<String, Object> p2 = new HashMap<>(); | ||
| 180 | + p2.put("xl.id_eq", lineid); | ||
| 181 | + p2.put("lpName_eq", bcell_con.trim()); | ||
| 182 | + List<GuideboardInfo> guideboardInfoList = (List<GuideboardInfo>) guideboardInfoService.list(p2); | ||
| 183 | + if (CollectionUtils.isEmpty(guideboardInfoList)) { | ||
| 184 | + rtn.put("status", ResponseCode.ERROR); | ||
| 185 | + rtn.put("msg", String.format("第%d行,第1列的路牌在%s中不存在", i + 1, linename)); | ||
| 186 | + return rtn; | ||
| 187 | + } else if (guideboardInfoList.size() > 1) { | ||
| 188 | + rtn.put("status", ResponseCode.ERROR); | ||
| 189 | + rtn.put("msg", String.format("第%d行,第1列的路牌在%s中重复", i + 1, linename)); | ||
| 190 | + return rtn; | ||
| 191 | + } else { | ||
| 192 | + gbindexmap.put(bcell_con.trim(), i + 1); | ||
| 193 | + } | ||
| 194 | + } | ||
| 195 | + } | ||
| 196 | + | ||
| 197 | + // 班次时间验证,正则表达式,格式hh:mm或者hhmm | ||
| 198 | + String el = "^(([0-1]\\d)|(2[0-4])):[0-5]\\d$"; // hh:mm格式 | ||
| 199 | + String el2 = "^(([0-1]\\d)|(2[0-4]))[0-5]\\d$"; // hhmm格式 | ||
| 200 | + Pattern p = Pattern.compile(el); | ||
| 201 | + Pattern p2 = Pattern.compile(el2); | ||
| 202 | + | ||
| 203 | + for (int i = 1; i < sheet.getRows(); i++) { // 从第2行开始验证数据 | ||
| 204 | + Cell[] bcells = sheet.getRow(i); | ||
| 205 | + for (int j = 1; j < bcells.length; j++) { // 从第2列开始 | ||
| 206 | + String bcell_con = bcells[j].getContents(); | ||
| 207 | + if (StringUtils.isNotEmpty(bcell_con)) { | ||
| 208 | + Matcher m = p.matcher(bcell_con.trim()); | ||
| 209 | + Matcher m2 = p2.matcher(bcell_con.trim()); | ||
| 210 | + if ((!m.matches()) && (!m2.matches())) { | ||
| 211 | + rtn.put("status", ResponseCode.ERROR); | ||
| 212 | + rtn.put("msg", String.format("第%d行,第%d列的发车时间格式不正确,格式应为hh:mm或hhmm", i + 1, j + 1)); | ||
| 213 | + return rtn; | ||
| 214 | + } | ||
| 215 | + } | ||
| 216 | + } | ||
| 217 | + } | ||
| 218 | + } | ||
| 219 | + | ||
| 220 | + } | ||
| 221 | + | ||
| 222 | + rtn.put("status", ResponseCode.SUCCESS); | ||
| 223 | + return rtn; | ||
| 224 | + } | ||
| 225 | + | ||
| 226 | + /** | ||
| 227 | + * 3、验证关联的线路标准信息(以后放到规则引擎里去做)。 | ||
| 228 | + * @param lineinfoid | ||
| 229 | + * @return | ||
| 230 | + */ | ||
| 231 | + @RequestMapping(value = "/validate/lineinfo", method = RequestMethod.GET) | ||
| 232 | + public Map<String, Object> validateAssoLineInfo(Integer lineinfoid) { | ||
| 233 | + Map<String, Object> rtn = new HashMap<>(); | ||
| 234 | + LineInformation lineInformation = lineInformationService.findById(lineinfoid); | ||
| 235 | + if (lineInformation.getUpInMileage() == null) { | ||
| 236 | + rtn.put("status", ResponseCode.ERROR); | ||
| 237 | + rtn.put("msg", "上行进场里程为空"); | ||
| 238 | + return rtn; | ||
| 239 | + } else if (lineInformation.getUpInTimer() == null) { | ||
| 240 | + rtn.put("status", ResponseCode.ERROR); | ||
| 241 | + rtn.put("msg", "上行进场时间为空"); | ||
| 242 | + return rtn; | ||
| 243 | + } else if (lineInformation.getUpOutMileage() == null) { | ||
| 244 | + rtn.put("status", ResponseCode.ERROR); | ||
| 245 | + rtn.put("msg", "上行出场里程为空"); | ||
| 246 | + return rtn; | ||
| 247 | + } else if (lineInformation.getUpOutTimer() == null) { | ||
| 248 | + rtn.put("status", ResponseCode.ERROR); | ||
| 249 | + rtn.put("msg", "上行出场时间为空"); | ||
| 250 | + return rtn; | ||
| 251 | + } else if (lineInformation.getUpMileage() == null) { | ||
| 252 | + rtn.put("status", ResponseCode.ERROR); | ||
| 253 | + rtn.put("msg", "上行班次里程为空"); | ||
| 254 | + return rtn; | ||
| 255 | + } else if (lineInformation.getUpTravelTime() == null) { | ||
| 256 | + rtn.put("status", ResponseCode.ERROR); | ||
| 257 | + rtn.put("msg", "上行班次时间为空"); | ||
| 258 | + return rtn; | ||
| 259 | + } else if (lineInformation.getDownInMileage() == null) { | ||
| 260 | + rtn.put("status", ResponseCode.ERROR); | ||
| 261 | + rtn.put("msg", "下行进场里程为空"); | ||
| 262 | + return rtn; | ||
| 263 | + } else if (lineInformation.getDownInTimer() == null) { | ||
| 264 | + rtn.put("status", ResponseCode.ERROR); | ||
| 265 | + rtn.put("msg", "下行进场时间为空"); | ||
| 266 | + return rtn; | ||
| 267 | + } else if (lineInformation.getDownOutMileage() == null) { | ||
| 268 | + rtn.put("status", ResponseCode.ERROR); | ||
| 269 | + rtn.put("msg", "下行出场里程为空"); | ||
| 270 | + return rtn; | ||
| 271 | + } else if (lineInformation.getDownOutTimer() == null) { | ||
| 272 | + rtn.put("status", ResponseCode.ERROR); | ||
| 273 | + rtn.put("msg", "下行出场时间为空"); | ||
| 274 | + return rtn; | ||
| 275 | + } else if (lineInformation.getDownMileage() == null) { | ||
| 276 | + rtn.put("status", ResponseCode.ERROR); | ||
| 277 | + rtn.put("msg", "下行班次里程为空"); | ||
| 278 | + return rtn; | ||
| 279 | + } else if (lineInformation.getDownTravelTime() == null) { | ||
| 280 | + rtn.put("status", ResponseCode.ERROR); | ||
| 281 | + rtn.put("msg", "下行班次时间为空"); | ||
| 282 | + return rtn; | ||
| 283 | + } else if (StringUtils.isEmpty(lineInformation.getCarPark())) { | ||
| 284 | + rtn.put("status", ResponseCode.ERROR); | ||
| 285 | + rtn.put("msg", "停车场必须选择"); | ||
| 286 | + return rtn; | ||
| 287 | + } | ||
| 288 | + | ||
| 289 | + // 单独验证停车场信息 | ||
| 290 | + String tcccode = lineInformation.getCarPark(); | ||
| 291 | + Map<String, Object> p1 = new HashMap<>(); | ||
| 292 | + p1.put("parkCode_eq", tcccode); | ||
| 293 | + List<CarPark> carParkList = (List<CarPark>) carParkService.list(p1); | ||
| 294 | + if (CollectionUtils.isEmpty(carParkList)) { | ||
| 295 | + rtn.put("status", ResponseCode.ERROR); | ||
| 296 | + rtn.put("msg", String.format("线路标准里的停车场code=%s,在停车场信息中未找到", tcccode)); | ||
| 297 | + return rtn; | ||
| 298 | + } else if (carParkList.size() > 1) { | ||
| 299 | + rtn.put("status", ResponseCode.ERROR); | ||
| 300 | + rtn.put("msg", String.format("线路标准里的停车场code=%s,在停车场信息中有重复数据", tcccode)); | ||
| 301 | + return rtn; | ||
| 302 | + } else { | ||
| 303 | + CarPark carPark = carParkList.get(0); | ||
| 304 | + if (StringUtils.isEmpty(carPark.getParkName())) { | ||
| 305 | + rtn.put("status", ResponseCode.ERROR); | ||
| 306 | + rtn.put("msg", String.format("线路标准里的停车场code=%s,在停车场信息中没有停车场名字", tcccode)); | ||
| 307 | + return rtn; | ||
| 308 | + } | ||
| 309 | + } | ||
| 310 | + | ||
| 311 | + rtn.put("status", ResponseCode.SUCCESS); | ||
| 312 | + return rtn; | ||
| 313 | + } | ||
| 314 | + | ||
| 315 | + /** | ||
| 316 | + * 4、导入时刻表明细数据。 | ||
| 317 | + * @param form | ||
| 318 | + * @return | ||
| 319 | + */ | ||
| 320 | + @RequestMapping(value = "/importfile", method = RequestMethod.POST) | ||
| 321 | + public Map<String, Object> importTTinfo(@RequestParam Map<String, Object> form) throws Exception { | ||
| 322 | + Map<String, Object> rtn = new HashMap<>(); | ||
| 323 | + | ||
| 324 | + // 1、修改已经上传的excel文件,在每个起点站后标示数字,表示第几个班次 | ||
| 325 | + // 2、由于格式问题,需要把内容都转换成字符串 | ||
| 326 | + String filename = (String) form.get("filename"); | ||
| 327 | + List<String> colList = new ArrayList<>(); | ||
| 328 | + Workbook workbook = Workbook.getWorkbook(new File(filename)); | ||
| 329 | + Sheet sheet = workbook.getSheet((String) form.get("sheetname")); | ||
| 330 | + Cell[] cells = sheet.getRow(0); | ||
| 331 | + for (int i = 0; i < cells.length; i++) { | ||
| 332 | + if (i == 0) { | ||
| 333 | + colList.add(cells[i].getContents().trim()); | ||
| 334 | + } else { | ||
| 335 | + colList.add(cells[i].getContents() + i); | ||
| 336 | + } | ||
| 337 | + } | ||
| 338 | + | ||
| 339 | + WritableWorkbook writableWorkbook = Workbook.createWorkbook(new File(filename + "_temp.xls"), workbook); | ||
| 340 | + WritableSheet sheet1 = writableWorkbook.getSheet((String) form.get("sheetname")); | ||
| 341 | + for (int i = 0; i < sheet1.getColumns(); i++) { // 第一行数据 | ||
| 342 | + sheet1.addCell(new Label(i, 0, colList.get(i))); | ||
| 343 | + } | ||
| 344 | + for (int i = 1; i < sheet1.getRows(); i++) { // 第二行开始 | ||
| 345 | + Cell[] cells1 = sheet.getRow(i); | ||
| 346 | + for (int j = 0; j < cells1.length; j++) { | ||
| 347 | + sheet1.addCell(new Label(j, i, cells1[j].getContents())); | ||
| 348 | + } | ||
| 349 | + } | ||
| 350 | + writableWorkbook.write(); | ||
| 351 | + writableWorkbook.close(); | ||
| 352 | + | ||
| 353 | + // 2、删除原有数据 | ||
| 354 | + ttInfoDetailService.deleteByTtinfo(Long.valueOf(form.get("ttid").toString())); | ||
| 355 | + | ||
| 356 | + // 3、导入时刻表 | ||
| 357 | + // 获取停车场名字 | ||
| 358 | + LineInformation lineInformation = lineInformationService.findById(Integer.valueOf(form.get("lineinfo").toString())); | ||
| 359 | + Map<String, Object> p1 = new HashMap<>(); | ||
| 360 | + p1.put("parkCode_eq", lineInformation.getCarPark()); | ||
| 361 | + List<CarPark> carParkList = (List<CarPark>) carParkService.list(p1); | ||
| 362 | + String tccname = carParkList.get(0).getParkName(); | ||
| 363 | + | ||
| 364 | + ttInfoDetailService.fileDataImport( | ||
| 365 | + new File(filename + "_temp.xls"), | ||
| 366 | + (String) form.get("xlname"), | ||
| 367 | + (String) form.get("ttname"), | ||
| 368 | + tccname | ||
| 369 | + ); | ||
| 370 | + | ||
| 371 | + return rtn; | ||
| 372 | + } | ||
| 36 | 373 | ||
| 374 | + //------------- 旧版本 --------------// | ||
| 37 | @RequestMapping(value = "/dataImportExtend", method = RequestMethod.POST) | 375 | @RequestMapping(value = "/dataImportExtend", method = RequestMethod.POST) |
| 38 | public Map<String, Object> uploadDataAndImport( | 376 | public Map<String, Object> uploadDataAndImport( |
| 39 | MultipartFile file, String xlmc, String ttinfoname) throws Exception { | 377 | MultipartFile file, String xlmc, String ttinfoname) throws Exception { |
src/main/java/com/bsth/repository/schedule/TTInfoDetailRepository.java
| @@ -7,8 +7,12 @@ import org.springframework.data.domain.Page; | @@ -7,8 +7,12 @@ import org.springframework.data.domain.Page; | ||
| 7 | import org.springframework.data.domain.Pageable; | 7 | import org.springframework.data.domain.Pageable; |
| 8 | import org.springframework.data.jpa.domain.Specification; | 8 | import org.springframework.data.jpa.domain.Specification; |
| 9 | import org.springframework.data.jpa.repository.EntityGraph; | 9 | import org.springframework.data.jpa.repository.EntityGraph; |
| 10 | +import org.springframework.data.jpa.repository.Modifying; | ||
| 10 | import org.springframework.data.jpa.repository.Query; | 11 | import org.springframework.data.jpa.repository.Query; |
| 11 | import org.springframework.stereotype.Repository; | 12 | import org.springframework.stereotype.Repository; |
| 13 | +import org.springframework.transaction.annotation.Isolation; | ||
| 14 | +import org.springframework.transaction.annotation.Propagation; | ||
| 15 | +import org.springframework.transaction.annotation.Transactional; | ||
| 12 | 16 | ||
| 13 | import java.util.List; | 17 | import java.util.List; |
| 14 | 18 | ||
| @@ -38,4 +42,8 @@ public interface TTInfoDetailRepository extends BaseRepository<TTInfoDetail, Lon | @@ -38,4 +42,8 @@ public interface TTInfoDetailRepository extends BaseRepository<TTInfoDetail, Lon | ||
| 38 | @Query(value = "select tt from TTInfoDetail tt where tt.xl.id = ?1 and tt.ttinfo.id = ?2 and tt.lp.id = ?3 order by tt.fcno asc") | 42 | @Query(value = "select tt from TTInfoDetail tt where tt.xl.id = ?1 and tt.ttinfo.id = ?2 and tt.lp.id = ?3 order by tt.fcno asc") |
| 39 | List<TTInfoDetail> findBcdetails(Integer xlId, Long ttinfoId, Long lpId); | 43 | List<TTInfoDetail> findBcdetails(Integer xlId, Long ttinfoId, Long lpId); |
| 40 | 44 | ||
| 45 | + @Modifying | ||
| 46 | + @Query(value = "delete from TTInfoDetail t where t.ttinfo.id = ?1") | ||
| 47 | + void deleteByTtinfo(Long ttinfoid); | ||
| 48 | + | ||
| 41 | } | 49 | } |
src/main/java/com/bsth/service/schedule/TTInfoDetailService.java
| @@ -2,9 +2,141 @@ package com.bsth.service.schedule; | @@ -2,9 +2,141 @@ package com.bsth.service.schedule; | ||
| 2 | 2 | ||
| 3 | import com.bsth.entity.schedule.TTInfoDetail; | 3 | import com.bsth.entity.schedule.TTInfoDetail; |
| 4 | import com.bsth.service.BaseService; | 4 | import com.bsth.service.BaseService; |
| 5 | +import org.apache.commons.lang3.StringUtils; | ||
| 6 | +import org.springframework.web.multipart.MultipartFile; | ||
| 7 | + | ||
| 8 | +import java.io.File; | ||
| 9 | +import java.util.ArrayList; | ||
| 10 | +import java.util.List; | ||
| 5 | 11 | ||
| 6 | /** | 12 | /** |
| 7 | * Created by xu on 16/7/2. | 13 | * Created by xu on 16/7/2. |
| 8 | */ | 14 | */ |
| 9 | public interface TTInfoDetailService extends BaseService<TTInfoDetail, Long> { | 15 | public interface TTInfoDetailService extends BaseService<TTInfoDetail, Long> { |
| 16 | + | ||
| 17 | + void deleteByTtinfo(Long ttinfoid); | ||
| 18 | + | ||
| 19 | + /** | ||
| 20 | + * 发车信息内部类。 | ||
| 21 | + */ | ||
| 22 | + public static class FcInfo { | ||
| 23 | + /** 时刻明细id */ | ||
| 24 | + private Long ttdid; | ||
| 25 | + /** 发车时间 */ | ||
| 26 | + private String fcsj; | ||
| 27 | + /** 班次类型 */ | ||
| 28 | + private String bc_type; | ||
| 29 | + /** 线路上下行 */ | ||
| 30 | + private String xldir; | ||
| 31 | + /** 是偶分班 */ | ||
| 32 | + private Boolean isfb; | ||
| 33 | + | ||
| 34 | + public FcInfo() { | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + public FcInfo(String ttdid_str, String bc_type, String fcsj, String xldir, String isfb) { | ||
| 38 | + this.ttdid = StringUtils.isEmpty(ttdid_str) ? null : Long.valueOf(ttdid_str); | ||
| 39 | + this.bc_type = bc_type; | ||
| 40 | + this.fcsj = fcsj; | ||
| 41 | + this.xldir = xldir; | ||
| 42 | + if ("N".equals(isfb)) | ||
| 43 | + this.isfb = false; | ||
| 44 | + else if ("Y".equals(isfb)) | ||
| 45 | + this.isfb = true; | ||
| 46 | + else | ||
| 47 | + this.isfb = false; | ||
| 48 | + | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + public Long getTtdid() { | ||
| 52 | + return ttdid; | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + public void setTtdid(Long ttdid) { | ||
| 56 | + this.ttdid = ttdid; | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + public String getFcsj() { | ||
| 60 | + return fcsj; | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + public void setFcsj(String fcsj) { | ||
| 64 | + this.fcsj = fcsj; | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + public String getBc_type() { | ||
| 68 | + return bc_type; | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + public void setBc_type(String bc_type) { | ||
| 72 | + this.bc_type = bc_type; | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + public String getXldir() { | ||
| 76 | + return xldir; | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + public void setXldir(String xldir) { | ||
| 80 | + this.xldir = xldir; | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + public Boolean getIsfb() { | ||
| 84 | + return isfb; | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + public void setIsfb(Boolean isfb) { | ||
| 88 | + this.isfb = isfb; | ||
| 89 | + } | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + /** | ||
| 93 | + * 时刻表编辑用的返回数据。 | ||
| 94 | + */ | ||
| 95 | + public static class EditInfo { | ||
| 96 | + /** 标题数据 */ | ||
| 97 | + private List<String> header = new ArrayList<>(); | ||
| 98 | + /** 内容数据 */ | ||
| 99 | + private List<List<FcInfo>> contents = new ArrayList<>(); | ||
| 100 | + | ||
| 101 | + public List<String> getHeader() { | ||
| 102 | + return header; | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + public void setHeader(List<String> header) { | ||
| 106 | + this.header = header; | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + public List<List<FcInfo>> getContents() { | ||
| 110 | + return contents; | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + public void setContents(List<List<FcInfo>> contents) { | ||
| 114 | + this.contents = contents; | ||
| 115 | + } | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + /** | ||
| 119 | + * 获取待编辑的数据。 | ||
| 120 | + * @param xlid 线路id | ||
| 121 | + * @param ttid 时刻表id | ||
| 122 | + * @return | ||
| 123 | + */ | ||
| 124 | + EditInfo getEditInfo(Integer xlid, Long ttid) throws Exception; | ||
| 125 | + | ||
| 126 | + /** | ||
| 127 | + * 上传并导入数据,和DataImportExportService的同名方法有差别。 | ||
| 128 | + * @param datafile form上传文件 | ||
| 129 | + * @param xlmc 线路名称 | ||
| 130 | + * @param ttinfoname 时刻表名字 | ||
| 131 | + * @param tccname 停车场名字 | ||
| 132 | + * @throws Exception | ||
| 133 | + */ | ||
| 134 | + void fileDataImport(MultipartFile datafile, | ||
| 135 | + String xlmc, | ||
| 136 | + String ttinfoname, | ||
| 137 | + String tccname) throws Exception; | ||
| 138 | + | ||
| 139 | + void fileDataImport(File file, String xlmc, String ttinfoname, String tccname) throws Exception; | ||
| 140 | + | ||
| 141 | + | ||
| 10 | } | 142 | } |
src/main/java/com/bsth/service/schedule/TTInfoDetailServiceImpl.java
| @@ -14,6 +14,9 @@ import org.pentaho.di.trans.TransMeta; | @@ -14,6 +14,9 @@ import org.pentaho.di.trans.TransMeta; | ||
| 14 | import org.springframework.beans.factory.annotation.Autowired; | 14 | import org.springframework.beans.factory.annotation.Autowired; |
| 15 | import org.springframework.boot.context.properties.EnableConfigurationProperties; | 15 | import org.springframework.boot.context.properties.EnableConfigurationProperties; |
| 16 | import org.springframework.stereotype.Service; | 16 | import org.springframework.stereotype.Service; |
| 17 | +import org.springframework.transaction.annotation.Isolation; | ||
| 18 | +import org.springframework.transaction.annotation.Propagation; | ||
| 19 | +import org.springframework.transaction.annotation.Transactional; | ||
| 17 | import org.springframework.web.multipart.MultipartFile; | 20 | import org.springframework.web.multipart.MultipartFile; |
| 18 | 21 | ||
| 19 | import java.io.File; | 22 | import java.io.File; |
| @@ -34,103 +37,10 @@ public class TTInfoDetailServiceImpl extends BaseServiceImpl<TTInfoDetail, Long> | @@ -34,103 +37,10 @@ public class TTInfoDetailServiceImpl extends BaseServiceImpl<TTInfoDetail, Long> | ||
| 34 | @Autowired | 37 | @Autowired |
| 35 | private TTInfoDetailRepository ttInfoDetailRepository; | 38 | private TTInfoDetailRepository ttInfoDetailRepository; |
| 36 | 39 | ||
| 37 | - /** | ||
| 38 | - * 发车信息内部类。 | ||
| 39 | - */ | ||
| 40 | - public static class FcInfo { | ||
| 41 | - /** 时刻明细id */ | ||
| 42 | - private Long ttdid; | ||
| 43 | - /** 发车时间 */ | ||
| 44 | - private String fcsj; | ||
| 45 | - /** 班次类型 */ | ||
| 46 | - private String bc_type; | ||
| 47 | - /** 线路上下行 */ | ||
| 48 | - private String xldir; | ||
| 49 | - /** 是偶分班 */ | ||
| 50 | - private Boolean isfb; | ||
| 51 | - | ||
| 52 | - public FcInfo() { | ||
| 53 | - } | ||
| 54 | - | ||
| 55 | - public FcInfo(String ttdid_str, String bc_type, String fcsj, String xldir, String isfb) { | ||
| 56 | - this.ttdid = StringUtils.isEmpty(ttdid_str) ? null : Long.valueOf(ttdid_str); | ||
| 57 | - this.bc_type = bc_type; | ||
| 58 | - this.fcsj = fcsj; | ||
| 59 | - this.xldir = xldir; | ||
| 60 | - if ("N".equals(isfb)) | ||
| 61 | - this.isfb = false; | ||
| 62 | - else if ("Y".equals(isfb)) | ||
| 63 | - this.isfb = true; | ||
| 64 | - else | ||
| 65 | - this.isfb = false; | ||
| 66 | - | ||
| 67 | - } | ||
| 68 | - | ||
| 69 | - public Long getTtdid() { | ||
| 70 | - return ttdid; | ||
| 71 | - } | ||
| 72 | - | ||
| 73 | - public void setTtdid(Long ttdid) { | ||
| 74 | - this.ttdid = ttdid; | ||
| 75 | - } | ||
| 76 | - | ||
| 77 | - public String getFcsj() { | ||
| 78 | - return fcsj; | ||
| 79 | - } | ||
| 80 | - | ||
| 81 | - public void setFcsj(String fcsj) { | ||
| 82 | - this.fcsj = fcsj; | ||
| 83 | - } | ||
| 84 | - | ||
| 85 | - public String getBc_type() { | ||
| 86 | - return bc_type; | ||
| 87 | - } | ||
| 88 | - | ||
| 89 | - public void setBc_type(String bc_type) { | ||
| 90 | - this.bc_type = bc_type; | ||
| 91 | - } | ||
| 92 | - | ||
| 93 | - public String getXldir() { | ||
| 94 | - return xldir; | ||
| 95 | - } | ||
| 96 | - | ||
| 97 | - public void setXldir(String xldir) { | ||
| 98 | - this.xldir = xldir; | ||
| 99 | - } | ||
| 100 | - | ||
| 101 | - public Boolean getIsfb() { | ||
| 102 | - return isfb; | ||
| 103 | - } | ||
| 104 | - | ||
| 105 | - public void setIsfb(Boolean isfb) { | ||
| 106 | - this.isfb = isfb; | ||
| 107 | - } | ||
| 108 | - } | ||
| 109 | - | ||
| 110 | - /** | ||
| 111 | - * 时刻表编辑用的返回数据。 | ||
| 112 | - */ | ||
| 113 | - public static class EditInfo { | ||
| 114 | - /** 标题数据 */ | ||
| 115 | - private List<String> header = new ArrayList<>(); | ||
| 116 | - /** 内容数据 */ | ||
| 117 | - private List<List<FcInfo>> contents = new ArrayList<>(); | ||
| 118 | - | ||
| 119 | - public List<String> getHeader() { | ||
| 120 | - return header; | ||
| 121 | - } | ||
| 122 | - | ||
| 123 | - public void setHeader(List<String> header) { | ||
| 124 | - this.header = header; | ||
| 125 | - } | ||
| 126 | - | ||
| 127 | - public List<List<FcInfo>> getContents() { | ||
| 128 | - return contents; | ||
| 129 | - } | ||
| 130 | - | ||
| 131 | - public void setContents(List<List<FcInfo>> contents) { | ||
| 132 | - this.contents = contents; | ||
| 133 | - } | 40 | + @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED) |
| 41 | + @Override | ||
| 42 | + public void deleteByTtinfo(Long ttinfoid) { | ||
| 43 | + ttInfoDetailRepository.deleteByTtinfo(ttinfoid); | ||
| 134 | } | 44 | } |
| 135 | 45 | ||
| 136 | /** | 46 | /** |
| @@ -139,6 +49,7 @@ public class TTInfoDetailServiceImpl extends BaseServiceImpl<TTInfoDetail, Long> | @@ -139,6 +49,7 @@ public class TTInfoDetailServiceImpl extends BaseServiceImpl<TTInfoDetail, Long> | ||
| 139 | * @param ttid 时刻表id | 49 | * @param ttid 时刻表id |
| 140 | * @return | 50 | * @return |
| 141 | */ | 51 | */ |
| 52 | + @Override | ||
| 142 | public EditInfo getEditInfo(Integer xlid, Long ttid) throws Exception { | 53 | public EditInfo getEditInfo(Integer xlid, Long ttid) throws Exception { |
| 143 | // 1、使用ktr转换获取输出文件 | 54 | // 1、使用ktr转换获取输出文件 |
| 144 | // 1.1、获取转换用ktr | 55 | // 1.1、获取转换用ktr |
| @@ -215,9 +126,15 @@ public class TTInfoDetailServiceImpl extends BaseServiceImpl<TTInfoDetail, Long> | @@ -215,9 +126,15 @@ public class TTInfoDetailServiceImpl extends BaseServiceImpl<TTInfoDetail, Long> | ||
| 215 | String xlmc, | 126 | String xlmc, |
| 216 | String ttinfoname, | 127 | String ttinfoname, |
| 217 | String tccname) throws Exception { | 128 | String tccname) throws Exception { |
| 218 | - // 1、上传数据文件 | 129 | + // 上传数据文件 |
| 219 | File uploadFile = dataImportExportService.uploadFile(datafile); | 130 | File uploadFile = dataImportExportService.uploadFile(datafile); |
| 131 | + fileDataImport(uploadFile, xlmc, ttinfoname, tccname); | ||
| 220 | 132 | ||
| 133 | + } | ||
| 134 | + | ||
| 135 | + @Override | ||
| 136 | + public void fileDataImport(File uploadFile, String xlmc, String ttinfoname, String tccname) throws Exception { | ||
| 137 | + // 1、上传数据文件 | ||
| 221 | System.out.println("线路名称:" + xlmc); | 138 | System.out.println("线路名称:" + xlmc); |
| 222 | System.out.println("时刻表名称:" + ttinfoname); | 139 | System.out.println("时刻表名称:" + ttinfoname); |
| 223 | System.out.println("停车场名字:" + tccname); | 140 | System.out.println("停车场名字:" + tccname); |
src/main/resources/static/pages/scheduleApp/Gruntfile.js
| @@ -64,7 +64,8 @@ module.exports = function (grunt) { | @@ -64,7 +64,8 @@ module.exports = function (grunt) { | ||
| 64 | }, | 64 | }, |
| 65 | src: [ | 65 | src: [ |
| 66 | 'module/common/dts1/load/loadingWidget.js', // loading界面指令 | 66 | 'module/common/dts1/load/loadingWidget.js', // loading界面指令 |
| 67 | - 'module/common/dts1/validation/remoteValidaton.js',// 服务端验证指令 | 67 | + 'module/common/dts1/validation/remoteValidation.js',// 服务端验证指令 |
| 68 | + 'module/common/dts1/validation/remoteValidationt2.js',// 服务端验证指令(时刻表专用) | ||
| 68 | 'module/common/dts1/select/saSelect.js', // select整合指令1 | 69 | 'module/common/dts1/select/saSelect.js', // select整合指令1 |
| 69 | 'module/common/dts1/select/saSelect2.js', // select整合指令2 | 70 | 'module/common/dts1/select/saSelect2.js', // select整合指令2 |
| 70 | 'module/common/dts1/select/saSelect3.js', // select整合指令3 | 71 | 'module/common/dts1/select/saSelect3.js', // select整合指令3 |
src/main/resources/static/pages/scheduleApp/module/basicInfo/busInfoManage/list.html
| @@ -88,8 +88,8 @@ | @@ -88,8 +88,8 @@ | ||
| 88 | <td> | 88 | <td> |
| 89 | <!--<a href="details.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 详细 </a>--> | 89 | <!--<a href="details.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 详细 </a>--> |
| 90 | <!--<a href="edit.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 修改 </a>--> | 90 | <!--<a href="edit.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 修改 </a>--> |
| 91 | - <a ui-sref="busInfoManage_detail({id: info.id})" class="btn default blue-stripe btn-sm"> 详细 </a> | ||
| 92 | - <a ui-sref="busInfoManage_edit({id: info.id})" class="btn default blue-stripe btn-sm"> 修改 </a> | 91 | + <a ui-sref="busInfoManage_detail({id: info.id})" class="btn btn-info btn-sm"> 详细 </a> |
| 92 | + <a ui-sref="busInfoManage_edit({id: info.id})" class="btn btn-info btn-sm"> 修改 </a> | ||
| 93 | </td> | 93 | </td> |
| 94 | </tr> | 94 | </tr> |
| 95 | </tbody> | 95 | </tbody> |
src/main/resources/static/pages/scheduleApp/module/basicInfo/deviceInfoManage/list.html
| @@ -84,10 +84,10 @@ | @@ -84,10 +84,10 @@ | ||
| 84 | <td> | 84 | <td> |
| 85 | <!--<a href="details.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 详细 </a>--> | 85 | <!--<a href="details.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 详细 </a>--> |
| 86 | <!--<a href="edit.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 修改 </a>--> | 86 | <!--<a href="edit.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 修改 </a>--> |
| 87 | - <a ui-sref="deviceInfoManage_detail({id: info.id})" class="btn default blue-stripe btn-sm"> 详细 </a> | ||
| 88 | - <a ui-sref="deviceInfoManage_edit({id: info.id})" class="btn default blue-stripe btn-sm" ng-if="info.isCancel == '0'"> 修改 </a> | ||
| 89 | - <a ng-click="ctrl.toggleCde(info.id)" class="btn default blue-stripe btn-sm" ng-if="info.isCancel == '0'"> 作废 </a> | ||
| 90 | - <a ng-click="ctrl.toggleCde(info.id)" class="btn default blue-stripe btn-sm" ng-if="info.isCancel == '1'"> 撤销 </a> | 87 | + <a ui-sref="deviceInfoManage_detail({id: info.id})" class="btn btn-info btn-sm"> 详细 </a> |
| 88 | + <a ui-sref="deviceInfoManage_edit({id: info.id})" class="btn btn-info btn-sm" ng-if="info.isCancel == '0'"> 修改 </a> | ||
| 89 | + <a ng-click="ctrl.toggleCde(info.id)" class="btn btn-danger btn-sm" ng-if="info.isCancel == '0'"> 作废 </a> | ||
| 90 | + <a ng-click="ctrl.toggleCde(info.id)" class="btn btn-success btn-sm" ng-if="info.isCancel == '1'"> 撤销 </a> | ||
| 91 | </td> | 91 | </td> |
| 92 | </tr> | 92 | </tr> |
| 93 | </tbody> | 93 | </tbody> |
src/main/resources/static/pages/scheduleApp/module/basicInfo/employeeInfoManage/list.html
| @@ -94,8 +94,8 @@ | @@ -94,8 +94,8 @@ | ||
| 94 | <td> | 94 | <td> |
| 95 | <!--<a href="details.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 详细 </a>--> | 95 | <!--<a href="details.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 详细 </a>--> |
| 96 | <!--<a href="edit.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 修改 </a>--> | 96 | <!--<a href="edit.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 修改 </a>--> |
| 97 | - <a ui-sref="employeeInfoManage_detail({id: info.id})" class="btn default blue-stripe btn-sm"> 详细 </a> | ||
| 98 | - <a ui-sref="employeeInfoManage_edit({id: info.id})" class="btn default blue-stripe btn-sm"> 修改 </a> | 97 | + <a ui-sref="employeeInfoManage_detail({id: info.id})" class="btn btn-info btn-sm"> 详细 </a> |
| 98 | + <a ui-sref="employeeInfoManage_edit({id: info.id})" class="btn btn-info btn-sm"> 修改 </a> | ||
| 99 | </td> | 99 | </td> |
| 100 | </tr> | 100 | </tr> |
| 101 | </tbody> | 101 | </tbody> |
src/main/resources/static/pages/scheduleApp/module/common/dts1/select/saSelect5.js
| @@ -333,6 +333,25 @@ angular.module('ScheduleApp').directive('saSelect5', [ | @@ -333,6 +333,25 @@ angular.module('ScheduleApp').directive('saSelect5', [ | ||
| 333 | }; | 333 | }; |
| 334 | 334 | ||
| 335 | /** | 335 | /** |
| 336 | + * 内部方法,读取本地动态数据源。 | ||
| 337 | + * @param ldata | ||
| 338 | + */ | ||
| 339 | + scope[ctrlAs].$$internal_local_data = function(ldata) { | ||
| 340 | + // 重新创建内部保存的数据 | ||
| 341 | + scope[ctrlAs].$$data_real = []; | ||
| 342 | + // 重新创建内部ui-select显示用数据,默认取10条记录显示 | ||
| 343 | + scope[ctrlAs].$$data = []; | ||
| 344 | + | ||
| 345 | + // 本地动态数据直接显示,暂时不优化 | ||
| 346 | + for (var i = 0; i < ldata.length; i++) { | ||
| 347 | + scope[ctrlAs].$$data_real.push(ldata[i]); | ||
| 348 | + scope[ctrlAs].$$data.push(ldata[i]); | ||
| 349 | + } | ||
| 350 | + | ||
| 351 | + scope[ctrlAs].$$internal_validate_model(); | ||
| 352 | + }; | ||
| 353 | + | ||
| 354 | + /** | ||
| 336 | * 监控dsparams属性变化 | 355 | * 监控dsparams属性变化 |
| 337 | */ | 356 | */ |
| 338 | attr.$observe("dsparams", function(value) { | 357 | attr.$observe("dsparams", function(value) { |
| @@ -348,6 +367,8 @@ angular.module('ScheduleApp').directive('saSelect5', [ | @@ -348,6 +367,8 @@ angular.module('ScheduleApp').directive('saSelect5', [ | ||
| 348 | 367 | ||
| 349 | } else if (obj.type == 'ajax') { | 368 | } else if (obj.type == 'ajax') { |
| 350 | scope[ctrlAs].$$internal_ajax_data(obj.atype, obj.param); | 369 | scope[ctrlAs].$$internal_ajax_data(obj.atype, obj.param); |
| 370 | + } else if (obj.type == 'local') { | ||
| 371 | + scope[ctrlAs].$$internal_local_data(obj.ldata); | ||
| 351 | } else { | 372 | } else { |
| 352 | throw new Error("dsparams参数格式异常=" + obj); | 373 | throw new Error("dsparams参数格式异常=" + obj); |
| 353 | } | 374 | } |
src/main/resources/static/pages/scheduleApp/module/common/dts1/upload/saFileupload.js
0 → 100644
src/main/resources/static/pages/scheduleApp/module/common/dts1/upload/saFileuploadTemplate.html
0 → 100644
| 1 | +<div class="input-group"> | ||
| 2 | + <input type="file" name="file" id="file"/> | ||
| 3 | + | ||
| 4 | + <input type="file" class="form-control" nv-file-select="" uploader="ctrl.uploader"/> | ||
| 5 | + <span class="input-group-btn"> | ||
| 6 | + <button type="button" ng-click="ctrl.clearInputFile()" class="btn btn-default"> | ||
| 7 | + <span class="glyphicon glyphicon-trash"></span> | ||
| 8 | + </button> | ||
| 9 | + <button type="button" class="btn btn-success"> | ||
| 10 | + <span class="glyphicon glyphicon-upload"></span> 上传 | ||
| 11 | + </button> | ||
| 12 | + </span> | ||
| 13 | + | ||
| 14 | + | ||
| 15 | + | ||
| 16 | + | ||
| 17 | +</div> | ||
| 0 | \ No newline at end of file | 18 | \ No newline at end of file |
src/main/resources/static/pages/scheduleApp/module/common/dts1/validation/remoteValidaton.js renamed to src/main/resources/static/pages/scheduleApp/module/common/dts1/validation/remoteValidation.js
| 1 | /** | 1 | /** |
| 2 | - * remoteValidatio指令,远程数据验证验证,作为属性放在某个指令上,依赖与指令的ngModel。 | 2 | + * remoteValidation指令,远程数据验证验证,作为属性放在某个指令上,依赖与指令的ngModel。 |
| 3 | * 属性如下: | 3 | * 属性如下: |
| 4 | * remotevtype(必须):验证类型(在service中有对应映射),如rvtype="xl" | 4 | * remotevtype(必须):验证类型(在service中有对应映射),如rvtype="xl" |
| 5 | * remotevparam(必须):后端判定查询参数,如rvparam={{ {'xl.id_eq': '123'} | json }} | 5 | * remotevparam(必须):后端判定查询参数,如rvparam={{ {'xl.id_eq': '123'} | json }} |
src/main/resources/static/pages/scheduleApp/module/common/dts1/validation/remoteValidationt2.js
0 → 100644
| 1 | +/** | ||
| 2 | + * remoteValidatiot2指令,远程数据验证验证,作为属性放在某个指令上,依赖与指令的ngModel(专门用于时刻表sheet验证)。 | ||
| 3 | + * 属性如下: | ||
| 4 | + * remotevtype(必须):验证类型(在service中有对应映射),如rvtype="xl" | ||
| 5 | + * remotevparam(必须):后端判定查询参数,如rvparam={{ {'xl.id_eq': '123'} | json }} | ||
| 6 | + * | ||
| 7 | + */ | ||
| 8 | +angular.module('ScheduleApp').directive('remoteValidationt2', [ | ||
| 9 | + '$$SearchInfoService_g', | ||
| 10 | + function($$SearchInfoService_g) { | ||
| 11 | + return { | ||
| 12 | + restrict: "A", // 属性 | ||
| 13 | + require: "^ngModel", // 依赖所属指令的ngModel | ||
| 14 | + compile: function(tElem, tAttrs) { | ||
| 15 | + // 验证属性 | ||
| 16 | + if (!tAttrs["remotevtype"]) { // 验证类型 | ||
| 17 | + throw new Error("remotevtype属性必须填写"); | ||
| 18 | + } else if (!$$SearchInfoService_g.validate[tAttrs["remotevtype"]]) { | ||
| 19 | + throw new Error(!tAttrs["remotevtype"] + "验证类型不存在"); | ||
| 20 | + } | ||
| 21 | + if (!tAttrs["remotevparam"]) { // 查询参数 | ||
| 22 | + throw new Error("remotevparam属性必须填写"); | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + // 监听获取的数据 | ||
| 26 | + var $watch_rvtype = undefined; | ||
| 27 | + var $watch_rvparam_obj = undefined; | ||
| 28 | + | ||
| 29 | + // 验证数据 | ||
| 30 | + var $$internal_validate = function(ngModelCtrl, scope) { | ||
| 31 | + if ($watch_rvtype && $watch_rvparam_obj) { | ||
| 32 | + // 获取查询参数模版 | ||
| 33 | + var paramTemplate = $$SearchInfoService_g.validate[$watch_rvtype].template; | ||
| 34 | + if (!paramTemplate) { | ||
| 35 | + throw new Error($watch_rvtype + "查询模版不存在"); | ||
| 36 | + } | ||
| 37 | + // 判定如果参数对象不全,没有完全和模版参数里对应上,则不验证 | ||
| 38 | + var isParamAll = true; | ||
| 39 | + for (var key in paramTemplate) { | ||
| 40 | + if (!$watch_rvparam_obj[key]) { | ||
| 41 | + isParamAll = false; | ||
| 42 | + break; | ||
| 43 | + } | ||
| 44 | + } | ||
| 45 | + if (!isParamAll) { | ||
| 46 | + ngModelCtrl.$setValidity('remote', true); | ||
| 47 | + } else { // 开始验证 | ||
| 48 | + $$SearchInfoService_g.validate[$watch_rvtype].remote.do( | ||
| 49 | + $watch_rvparam_obj, | ||
| 50 | + function(result) { | ||
| 51 | + if (result.status == "SUCCESS") { | ||
| 52 | + ngModelCtrl.$setValidity('remote', true); | ||
| 53 | + } else { | ||
| 54 | + ngModelCtrl.$setValidity('remote', false); | ||
| 55 | + scope.ctrl.ttInfoDetailManageForForm.sheetvaliddesc = result.msg; | ||
| 56 | + } | ||
| 57 | + }, | ||
| 58 | + function(result) { | ||
| 59 | + alert("出错拉"); | ||
| 60 | + ngModelCtrl.$setValidity('remote', true); | ||
| 61 | + } | ||
| 62 | + ); | ||
| 63 | + } | ||
| 64 | + } | ||
| 65 | + }; | ||
| 66 | + | ||
| 67 | + return { | ||
| 68 | + pre: function(scope, element, attr) { | ||
| 69 | + | ||
| 70 | + }, | ||
| 71 | + | ||
| 72 | + post: function(scope, element, attr, ngModelCtrl) { | ||
| 73 | + /** | ||
| 74 | + * 监控验证类型属性变化。 | ||
| 75 | + */ | ||
| 76 | + attr.$observe("remotevtype", function(value) { | ||
| 77 | + if (value && value != "") { | ||
| 78 | + $watch_rvtype = value; | ||
| 79 | + $$internal_validate(ngModelCtrl, scope); | ||
| 80 | + } | ||
| 81 | + }); | ||
| 82 | + /** | ||
| 83 | + * 监控查询结果属性变化。 | ||
| 84 | + */ | ||
| 85 | + attr.$observe("remotevparam", function(value) { | ||
| 86 | + if (value && value != "") { | ||
| 87 | + //if (!ngModelCtrl.$dirty) { // 没有修改过模型数据,不验证 | ||
| 88 | + // return; | ||
| 89 | + //} | ||
| 90 | + $watch_rvparam_obj = JSON.parse(value); | ||
| 91 | + $$internal_validate(ngModelCtrl, scope); | ||
| 92 | + } | ||
| 93 | + }); | ||
| 94 | + } | ||
| 95 | + }; | ||
| 96 | + } | ||
| 97 | + } | ||
| 98 | + } | ||
| 99 | +]); |