Commit aab36a0f6059a8efc45fa58fce2dc2dcf29fca66

Authored by 徐烜
2 parents 3678d3fe 2c04aa55

Merge branch 'PSM_22_23_24' into minhang

Showing 25 changed files with 2213 additions and 866 deletions

Too many changes to show.

To preserve performance only 25 of 45 files are displayed.

src/main/java/com/bsth/controller/schedule/BController.java 0 → 100644
  1 +package com.bsth.controller.schedule;
  2 +
  3 +import com.bsth.common.ResponseCode;
  4 +import com.bsth.service.schedule.BService;
  5 +import com.bsth.service.schedule.ScheduleException;
  6 +import com.google.common.base.Splitter;
  7 +import org.springframework.beans.factory.annotation.Autowired;
  8 +import org.springframework.data.domain.PageRequest;
  9 +import org.springframework.data.domain.Sort;
  10 +import org.springframework.web.bind.annotation.*;
  11 +
  12 +import java.io.Serializable;
  13 +import java.util.ArrayList;
  14 +import java.util.HashMap;
  15 +import java.util.List;
  16 +import java.util.Map;
  17 +
  18 +/**
  19 + * 基础控制器。
  20 + */
  21 +public class BController<T, ID extends Serializable> {
  22 + @Autowired
  23 + protected BService<T, ID> bService;
  24 +
  25 + // CRUD 操作
  26 + // Create操作
  27 + @RequestMapping(method = RequestMethod.POST)
  28 + public Map<String, Object> save(@RequestBody T t) {
  29 + T t_saved = bService.save(t);
  30 + Map<String, Object> rtn = new HashMap<>();
  31 + rtn.put("status", ResponseCode.SUCCESS);
  32 + rtn.put("data", t_saved);
  33 + return rtn;
  34 + }
  35 + // Update操作
  36 + @RequestMapping(value="/{id}", method = RequestMethod.POST)
  37 + public Map<String, Object> update(@RequestBody T t) {
  38 + return save(t);
  39 + }
  40 + // Research操作
  41 + @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  42 + public Map<String, Object> findById(@PathVariable("id") ID id) {
  43 + T t = bService.findById(id);
  44 + Map<String, Object> rtn = new HashMap<>();
  45 + rtn.put("status", ResponseCode.SUCCESS);
  46 + rtn.put("data", t);
  47 + return rtn;
  48 + }
  49 + @RequestMapping(value = "/all", method = RequestMethod.GET)
  50 + public Map<String, Object> list(@RequestParam Map<String, Object> param) {
  51 + List<T> tList = bService.list(param);
  52 + Map<String, Object> rtn = new HashMap<>();
  53 + rtn.put("status", ResponseCode.SUCCESS);
  54 + rtn.put("data", tList);
  55 + return rtn;
  56 + }
  57 + @RequestMapping(method = RequestMethod.GET)
  58 + public Map<String, Object> list(
  59 + @RequestParam Map<String, Object> map,
  60 + @RequestParam(defaultValue = "0") int page,
  61 + @RequestParam(defaultValue = "10") int size,
  62 + @RequestParam(defaultValue = "id") String order,
  63 + @RequestParam(defaultValue = "DESC") String direction) {
  64 + // 允许多个字段排序,order可以写单个字段,也可以写多个字段
  65 + // 多个字段格式:{col1},{col2},{col3},....,{coln}
  66 + List<String> order_columns = Splitter.on(",").trimResults().splitToList(order);
  67 + // 多字段排序:DESC,ASC...
  68 + List<String> order_dirs = Splitter.on(",").trimResults().splitToList(direction);
  69 +
  70 + Map<String, Object> rtn = new HashMap<>();
  71 +
  72 + if (order_dirs.size() == 1) { // 所有字段采用一种排序
  73 + rtn.put("status", ResponseCode.SUCCESS);
  74 + if (order_dirs.get(0).equals("ASC")) {
  75 + rtn.put("data", bService.list(map, new PageRequest(page, size, new Sort(Sort.Direction.ASC, order_columns))));
  76 + } else {
  77 + rtn.put("data", bService.list(map, new PageRequest(page, size, new Sort(Sort.Direction.DESC, order_columns))));
  78 + }
  79 + } else if (order_columns.size() == order_dirs.size()) {
  80 + List<Sort.Order> orderList = new ArrayList<>();
  81 + for (int i = 0; i < order_columns.size(); i++) {
  82 + if (null != order_dirs.get(i) && order_dirs.get(i).equals("ASC")) {
  83 + orderList.add(new Sort.Order(Sort.Direction.ASC, order_columns.get(i)));
  84 + } else {
  85 + orderList.add(new Sort.Order(Sort.Direction.DESC, order_columns.get(i)));
  86 + }
  87 + }
  88 + rtn.put("status", ResponseCode.SUCCESS);
  89 + rtn.put("data", bService.list(map, new PageRequest(page, size, new Sort(orderList))));
  90 + } else {
  91 + throw new RuntimeException("多字段排序参数格式问题,排序顺序和字段数不一致");
  92 + }
  93 +
  94 + return rtn;
  95 +
  96 + }
  97 +
  98 + // Delete操作
  99 + @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
  100 + public Map<String, Object> delete(@PathVariable("id") ID id) {
  101 + Map<String, Object> rtn = new HashMap<>();
  102 + try {
  103 + bService.delete(id);
  104 + rtn.put("status", ResponseCode.SUCCESS);
  105 + } catch (ScheduleException exp) {
  106 + rtn.put("status", ResponseCode.ERROR);
  107 + rtn.put("msg", exp.getMessage());
  108 + }
  109 +
  110 + return rtn;
  111 + }
  112 +
  113 +}
... ...
src/main/java/com/bsth/controller/schedule/GuideboardInfoController.java
1 1 package com.bsth.controller.schedule;
2 2  
3   -import com.bsth.controller.BaseController;
  3 +import com.bsth.common.ResponseCode;
4 4 import com.bsth.entity.schedule.GuideboardInfo;
5   -import com.bsth.repository.schedule.GuideboardInfoRepository;
  5 +import com.bsth.service.schedule.GuideboardInfoService;
  6 +import com.bsth.service.schedule.ScheduleException;
6 7 import com.bsth.service.schedule.utils.DataToolsProperties;
7 8 import org.springframework.beans.factory.annotation.Autowired;
8 9 import org.springframework.boot.context.properties.EnableConfigurationProperties;
9   -import org.springframework.web.bind.annotation.PathVariable;
10   -import org.springframework.web.bind.annotation.RequestMapping;
11   -import org.springframework.web.bind.annotation.RequestMethod;
12   -import org.springframework.web.bind.annotation.RestController;
  10 +import org.springframework.web.bind.annotation.*;
13 11  
14   -import java.util.List;
  12 +import java.util.HashMap;
15 13 import java.util.Map;
16 14  
17 15 /**
18   - * Created by xu on 16/5/11.
  16 + * 路牌管理控制器。
19 17 */
20 18 @RestController
21 19 @RequestMapping("gic")
22 20 @EnableConfigurationProperties(DataToolsProperties.class)
23   -public class GuideboardInfoController extends BaseController<GuideboardInfo, Long> {
  21 +public class GuideboardInfoController extends BController<GuideboardInfo, Long> {
24 22 @Autowired
25   - private DataToolsProperties dataToolsProperties;
26   - @Autowired
27   - private GuideboardInfoRepository guideboardInfoRepository;
28   -
29   - @Override
30   - protected String getDataImportKtrClasspath() {
31   - return dataToolsProperties.getGuideboardsDatainputktr();
32   - }
  23 + private GuideboardInfoService guideboardInfoService;
  24 +// @Autowired
  25 +// private DataToolsProperties dataToolsProperties;
  26 +// @Autowired
  27 +// private GuideboardInfoRepository guideboardInfoRepository;
  28 +//
  29 +// @Override
  30 +// protected String getDataImportKtrClasspath() {
  31 +// return dataToolsProperties.getGuideboardsDatainputktr();
  32 +// }
  33 +//
  34 +// @Override
  35 +// public GuideboardInfo findById(@PathVariable("id") Long aLong) {
  36 +// return guideboardInfoRepository.findOneExtend(aLong);
  37 +// }
  38 +//
  39 +//
  40 +// @RequestMapping(value = "/ttlpnames", method = RequestMethod.GET)
  41 +// public List<Map<String, Object>> findLpName(Long ttid) {
  42 +// return guideboardInfoRepository.findLpName(ttid);
  43 +// }
33 44  
34   - @Override
35   - public GuideboardInfo findById(@PathVariable("id") Long aLong) {
36   - return guideboardInfoRepository.findOneExtend(aLong);
  45 + @RequestMapping(value = "/validate1", method = RequestMethod.GET)
  46 + public Map<String, Object> validate1(@RequestParam Map<String, Object> param) {
  47 + Map<String, Object> rtn = new HashMap<>();
  48 + try {
  49 + // 路牌编号验证
  50 + GuideboardInfo guideboardInfo = new GuideboardInfo(
  51 + param.get("xl.id_eq"),
  52 + param.get("lpNo_eq"),
  53 + null
  54 + );
  55 + guideboardInfoService.validate(guideboardInfo);
  56 + rtn.put("status", ResponseCode.SUCCESS);
  57 + } catch (ScheduleException exp) {
  58 + rtn.put("status", ResponseCode.ERROR);
  59 + rtn.put("msg", exp.getMessage());
  60 + }
  61 + return rtn;
37 62 }
38 63  
39   -
40   - @RequestMapping(value = "/ttlpnames", method = RequestMethod.GET)
41   - public List<Map<String, Object>> findLpName(Long ttid) {
42   - return guideboardInfoRepository.findLpName(ttid);
  64 + @RequestMapping(value = "/validate2", method = RequestMethod.GET)
  65 + public Map<String, Object> validate2(@RequestParam Map<String, Object> param) {
  66 + Map<String, Object> rtn = new HashMap<>();
  67 + try {
  68 + // 路牌名称验证
  69 + GuideboardInfo guideboardInfo = new GuideboardInfo(
  70 + param.get("xl.id_eq"),
  71 + null,
  72 + param.get("lpName_eq")
  73 + );
  74 + guideboardInfoService.validate(guideboardInfo);
  75 + rtn.put("status", ResponseCode.SUCCESS);
  76 + } catch (ScheduleException exp) {
  77 + rtn.put("status", ResponseCode.ERROR);
  78 + rtn.put("msg", exp.getMessage());
  79 + }
  80 + return rtn;
43 81 }
44 82 }
... ...
src/main/java/com/bsth/entity/Line.java
1 1 package com.bsth.entity;
2 2  
  3 +import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
3 4 import org.springframework.format.annotation.DateTimeFormat;
4 5  
5 6 import javax.persistence.*;
... ... @@ -23,6 +24,7 @@ import java.util.Date;
23 24  
24 25 @Entity
25 26 @Table(name = "bsth_c_line")
  27 +@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler","fieldHandler"})
26 28 public class Line implements Serializable {
27 29  
28 30 @Id
... ...
src/main/java/com/bsth/entity/schedule/GuideboardInfo.java
... ... @@ -2,9 +2,9 @@ package com.bsth.entity.schedule;
2 2  
3 3 import com.bsth.entity.Line;
4 4 import com.bsth.entity.sys.SysUser;
  5 +import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
5 6  
6 7 import javax.persistence.*;
7   -import javax.persistence.Table;
8 8 import java.util.Date;
9 9  
10 10 /**
... ... @@ -17,6 +17,7 @@ import java.util.Date;
17 17 @NamedAttributeNode("xl")
18 18 })
19 19 })
  20 +@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler","fieldHandler"})
20 21 public class GuideboardInfo {
21 22  
22 23 /** 主键Id */
... ... @@ -38,6 +39,10 @@ public class GuideboardInfo {
38 39 @Column(nullable = false)
39 40 private String lpType;
40 41  
  42 + /** 是否删除(标记) */
  43 + @Column(nullable = false)
  44 + private Boolean isCancel = false;
  45 +
41 46 /** 创建人 */
42 47 @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST)
43 48 private SysUser createBy;
... ... @@ -53,6 +58,30 @@ public class GuideboardInfo {
53 58 private Date updateDate;
54 59  
55 60  
  61 + public GuideboardInfo() {}
  62 +
  63 + public GuideboardInfo(Object xlid, Object lpNo, Object lpName) {
  64 + Integer xlid_ = xlid == null ? null : Integer.valueOf(xlid.toString());
  65 + Integer lpNo_ = lpNo == null ? null : Integer.valueOf(lpNo.toString());
  66 + String lpName_ = lpName == null ? null : String.valueOf(lpName);
  67 +
  68 + if (xlid_ != null) {
  69 + Line line = new Line();
  70 + line.setId(xlid_);
  71 + this.xl = line;
  72 + }
  73 +
  74 + this.lpNo = lpNo_;
  75 + this.lpName = lpName_;
  76 + }
  77 +
  78 + public GuideboardInfo(Integer xlid, Integer lpNo) {
  79 + this(xlid, lpNo, null);
  80 + }
  81 + public GuideboardInfo(Integer xlid, String lpName) {
  82 + this(xlid, null, lpName);
  83 + }
  84 +
56 85 public Long getId() {
57 86 return id;
58 87 }
... ... @@ -124,4 +153,12 @@ public class GuideboardInfo {
124 153 public void setUpdateDate(Date updateDate) {
125 154 this.updateDate = updateDate;
126 155 }
  156 +
  157 + public Boolean getIsCancel() {
  158 + return isCancel;
  159 + }
  160 +
  161 + public void setIsCancel(Boolean isCancel) {
  162 + this.isCancel = isCancel;
  163 + }
127 164 }
... ...
src/main/java/com/bsth/service/schedule/BService.java 0 → 100644
  1 +package com.bsth.service.schedule;
  2 +
  3 +import org.springframework.data.domain.Page;
  4 +import org.springframework.data.domain.Pageable;
  5 +
  6 +import java.io.Serializable;
  7 +import java.util.List;
  8 +import java.util.Map;
  9 +
  10 +/**
  11 + * 基础service接口。
  12 + */
  13 +public interface BService<T, ID extends Serializable> {
  14 + // CRUD 操作
  15 + // Create,Update操作
  16 + T save(T t);
  17 + <S extends T> List<S> bulkSave(List<S> entities); // 批量保存(TODO:待测试)
  18 + // Research操作
  19 + T findById(ID id);
  20 + List<T> findAll();
  21 + Page<T> list(Map<String, Object> param, Pageable pageable);
  22 + List<T> list(Map<String, Object> param);
  23 + // Delete操作
  24 + void delete(ID id) throws ScheduleException;
  25 +}
... ...
src/main/java/com/bsth/service/schedule/GuideboardInfoService.java
1 1 package com.bsth.service.schedule;
2 2  
3 3 import com.bsth.entity.schedule.GuideboardInfo;
4   -import com.bsth.service.BaseService;
5 4  
6 5 /**
7 6 * Created by xu on 16/5/11.
8 7 */
9   -public interface GuideboardInfoService extends BaseService<GuideboardInfo, Long> {
  8 +public interface GuideboardInfoService extends BService<GuideboardInfo, Long> {
  9 + public void validate(GuideboardInfo guideboardInfo) throws ScheduleException;
  10 + public void toggleCancel(Long id) throws ScheduleException;
10 11 }
... ...
src/main/java/com/bsth/service/schedule/GuideboardInfoServiceImpl.java deleted 100644 → 0
1   -package com.bsth.service.schedule;
2   -
3   -import com.bsth.entity.schedule.GuideboardInfo;
4   -import com.bsth.service.impl.BaseServiceImpl;
5   -import org.springframework.stereotype.Service;
6   -
7   -/**
8   - * Created by xu on 16/5/11.
9   - */
10   -@Service
11   -public class GuideboardInfoServiceImpl extends BaseServiceImpl<GuideboardInfo, Long> implements GuideboardInfoService {
12   -}
src/main/java/com/bsth/service/schedule/ScheduleException.java 0 → 100644
  1 +package com.bsth.service.schedule;
  2 +
  3 +/**
  4 + * Created by xu on 16/12/5.
  5 + */
  6 +public class ScheduleException extends Exception {
  7 + public ScheduleException(String message) {
  8 + super("计划调度业务错误==>>" + message);
  9 + }
  10 +}
... ...
src/main/java/com/bsth/service/schedule/impl/BServiceImpl.java 0 → 100644
  1 +package com.bsth.service.schedule.impl;
  2 +
  3 +import com.bsth.entity.search.CustomerSpecs;
  4 +import com.bsth.repository.BaseRepository;
  5 +import com.bsth.service.schedule.BService;
  6 +import com.bsth.service.schedule.ScheduleException;
  7 +import org.slf4j.Logger;
  8 +import org.slf4j.LoggerFactory;
  9 +import org.springframework.beans.factory.annotation.Autowired;
  10 +import org.springframework.beans.factory.annotation.Value;
  11 +import org.springframework.data.domain.Page;
  12 +import org.springframework.data.domain.Pageable;
  13 +import org.springframework.data.jpa.domain.Specification;
  14 +
  15 +import javax.persistence.EntityManager;
  16 +import java.io.Serializable;
  17 +import java.util.ArrayList;
  18 +import java.util.List;
  19 +import java.util.Map;
  20 +
  21 +/**
  22 + * 基础BService实现。
  23 + */
  24 +public class BServiceImpl<T, ID extends Serializable> implements BService<T, ID> {
  25 + @Autowired
  26 + private BaseRepository<T, ID> baseRepository;
  27 + @Autowired
  28 + private EntityManager entityManager;
  29 + @Value("${hibernate.jdbc.batch_size}")
  30 + private int batchSize;
  31 +
  32 + /** 日志记录器 */
  33 + protected Logger logger = LoggerFactory.getLogger(this.getClass());
  34 +
  35 + // CRUD 操作
  36 + // Create,Update操作
  37 + @Override
  38 + public T save(T t) {
  39 + if (logger.isDebugEnabled()) {
  40 + logger.debug("save...");
  41 + }
  42 + return baseRepository.save(t);
  43 + }
  44 + @Override
  45 + public <S extends T> List<S> bulkSave(List<S> entities) {
  46 + if (logger.isDebugEnabled()) {
  47 + logger.debug("bulkSave...");
  48 + }
  49 +
  50 + // 不使用内部批量保存,自己实现批量保存
  51 + final List<S> savedEntities = new ArrayList<>(entities.size());
  52 + int i = 0;
  53 + for (S t : entities) {
  54 + entityManager.persist(t);
  55 + savedEntities.add(t);
  56 + i++;
  57 + if (i % batchSize == 0) {
  58 + entityManager.flush();
  59 + entityManager.clear();
  60 + }
  61 + }
  62 + return savedEntities;
  63 + }
  64 +
  65 + // Research操作
  66 + @Override
  67 + public T findById(ID id) {
  68 + if (logger.isDebugEnabled()) {
  69 + logger.debug("findById...");
  70 + }
  71 +
  72 + return baseRepository.findOne(id);
  73 + }
  74 + @Override
  75 + public List<T> findAll() {
  76 + if (logger.isDebugEnabled()) {
  77 + logger.debug("findAll...");
  78 + }
  79 +
  80 + return (List<T>) baseRepository.findAll();
  81 + }
  82 + @Override
  83 + public Page<T> list(Map<String, Object> param, Pageable pageable) {
  84 + if (logger.isDebugEnabled()) {
  85 + logger.debug("list(...,pageable)...");
  86 + }
  87 +
  88 + // 自定义查询参数
  89 + Specification<T> specification = new CustomerSpecs<>(param);
  90 + return baseRepository.findAll(specification, pageable);
  91 + }
  92 + @Override
  93 + public List<T> list(Map<String, Object> param) {
  94 + if (logger.isDebugEnabled()) {
  95 + logger.debug("list...");
  96 + }
  97 +
  98 + // 自定义查询参数
  99 + Specification<T> specification = new CustomerSpecs<>(param);
  100 + return baseRepository.findAll(specification);
  101 + }
  102 + // Delete操作
  103 + @Override
  104 + public void delete(ID id) throws ScheduleException {
  105 + if (logger.isDebugEnabled()) {
  106 + logger.debug("delete...");
  107 + }
  108 +
  109 + baseRepository.delete(id);
  110 + }
  111 +}
... ...
src/main/java/com/bsth/service/schedule/impl/GuideboardInfoServiceImpl.java 0 → 100644
  1 +package com.bsth.service.schedule.impl;
  2 +
  3 +import com.bsth.entity.schedule.GuideboardInfo;
  4 +import com.bsth.entity.schedule.TTInfoDetail;
  5 +import com.bsth.service.schedule.GuideboardInfoService;
  6 +import com.bsth.service.schedule.ScheduleException;
  7 +import com.bsth.service.schedule.TTInfoDetailService;
  8 +import org.springframework.beans.factory.annotation.Autowired;
  9 +import org.springframework.stereotype.Service;
  10 +import org.springframework.util.CollectionUtils;
  11 +
  12 +import javax.transaction.Transactional;
  13 +import java.util.HashMap;
  14 +import java.util.List;
  15 +import java.util.Map;
  16 +
  17 +/**
  18 + * 路牌信息服务。
  19 + */
  20 +@Service
  21 +public class GuideboardInfoServiceImpl extends BServiceImpl<GuideboardInfo, Long> implements GuideboardInfoService {
  22 + @Autowired
  23 + private TTInfoDetailService ttInfoDetailService;
  24 +
  25 + // 验证方法
  26 + @Transactional
  27 + public void validate(GuideboardInfo guideboardInfo) throws ScheduleException {
  28 + // 查询条件
  29 + Map<String, Object> param = new HashMap<>();
  30 + if (guideboardInfo.getId() != null)
  31 + param.put("id_ne", guideboardInfo.getId());
  32 +
  33 + if (guideboardInfo.getXl() == null || guideboardInfo.getXl().getId() == null) {
  34 + throw new ScheduleException("线路未选择");
  35 + } else {
  36 + param.put("xl.id_eq", guideboardInfo.getXl().getId());
  37 +
  38 +// param.put("isCancel_eq", false); // 作废的也算入判定区
  39 + if (guideboardInfo.getLpNo() != null) {
  40 + if (guideboardInfo.getLpName() != null) {
  41 + // 如果两个都写了,分开查询
  42 + param.put("lpNo_eq", guideboardInfo.getLpNo());
  43 + if (!CollectionUtils.isEmpty(list(param))) {
  44 + throw new ScheduleException("路牌编号重复");
  45 + }
  46 + param.remove("lpNo_eq");
  47 + param.put("lpName_eq", guideboardInfo.getLpName());
  48 + if (!CollectionUtils.isEmpty(list(param))) {
  49 + throw new ScheduleException("路牌名称重复");
  50 + }
  51 +
  52 + } else {
  53 + param.put("lpNo_eq", guideboardInfo.getLpNo());
  54 + if (!CollectionUtils.isEmpty(list(param))) {
  55 + throw new ScheduleException("路牌编号重复");
  56 + }
  57 + }
  58 + } else {
  59 + if (guideboardInfo.getLpName() != null) {
  60 + param.put("lpName_eq", guideboardInfo.getLpName());
  61 + if (!CollectionUtils.isEmpty(list(param))) {
  62 + throw new ScheduleException("路牌名字重复");
  63 + }
  64 + } else {
  65 + // 都为空
  66 + throw new ScheduleException("路牌编号名字都为空");
  67 + }
  68 + }
  69 + }
  70 +
  71 + }
  72 +
  73 + @Transactional
  74 + @Override
  75 + public void delete(Long aLong) throws ScheduleException {
  76 + // 删除操作就是作废操作
  77 + toggleCancel(aLong);
  78 + }
  79 +
  80 + // 作废方法
  81 + @Transactional
  82 + public void toggleCancel(Long id) throws ScheduleException {
  83 + GuideboardInfo guideboardInfo = findById(id);
  84 + Map<String, Object> param = new HashMap<>();
  85 + if (guideboardInfo.getIsCancel()) {
  86 + validate(guideboardInfo);
  87 + guideboardInfo.setIsCancel(false);
  88 + } else {
  89 + param.clear();
  90 + param.put("xl.id_eq", guideboardInfo.getXl().getId());
  91 + param.put("ttinfo.isCancel_eq", false);
  92 + param.put("lp.id_eq", guideboardInfo.getId());
  93 + List<TTInfoDetail> ttInfoDetailList = (List<TTInfoDetail>) ttInfoDetailService.list(param);
  94 + if (CollectionUtils.isEmpty(ttInfoDetailList)) {
  95 + guideboardInfo.setIsCancel(true);
  96 + } else {
  97 + throw new ScheduleException("在时刻表" +
  98 + ttInfoDetailList.get(0).getTtinfo().getName() +
  99 + "已使用,无法删除!");
  100 + }
  101 + }
  102 + }
  103 +
  104 +}
... ...
src/main/resources/static/pages/scheduleApp/Gruntfile.js
... ... @@ -14,6 +14,9 @@ module.exports = function (grunt) {
14 14 },
15 15 concat_route: { // 所有模块的route配置合并的js文件
16 16 src: ['module/common/prj-common-ui-route-state.js']
  17 + },
  18 + concat_service: { // 所有模块的servie服务合并的js文件
  19 + src: ['module/common/prj-common-globalservice.js']
17 20 }
18 21  
19 22 //,
... ... @@ -69,11 +72,13 @@ module.exports = function (grunt) {
69 72 'module/common/dts1/load/loadingWidget.js', // loading界面指令
70 73 'module/common/dts1/validation/remoteValidation.js',// 服务端验证指令
71 74 'module/common/dts1/validation/remoteValidationt2.js',// 服务端验证指令(时刻表专用)
  75 + 'module/common/dts1/validation/remoteValidation3.js',// 服务端验证指令
72 76 'module/common/dts1/select/saSelect.js', // select整合指令1
73 77 'module/common/dts1/select/saSelect2.js', // select整合指令2
74 78 'module/common/dts1/select/saSelect3.js', // select整合指令3
75 79 'module/common/dts1/select/saSelect4.js', // select整合指令4
76 80 'module/common/dts1/select/saSelect5.js', // select整合指令5
  81 + 'module/common/dts2/ttinfotable/mySelect.js', // select整合指令
77 82 'module/common/dts1/radioButton/saRadiogroup.js', // 单选框组整合指令
78 83 'module/common/dts1/checkbox/saCheckboxgroup.js', // 多选框组整合指令
79 84 'module/common/dts2/dateGroup/saDategroup.js', // 特殊日期选择指令
... ... @@ -104,6 +109,26 @@ module.exports = function (grunt) {
104 109 'module/core/ttInfoManage/detailedit/route.js' // 时刻表明细管理模块
105 110 ],
106 111 dest: 'module/common/prj-common-ui-route-state.js'
  112 + },
  113 + service: {
  114 + options: {
  115 + banner: '//所有模块service配置\n'
  116 + },
  117 + src: [
  118 + 'module/basicInfo/busInfoManage/service.js', // 车辆基础信息管理service
  119 + 'module/basicInfo/deviceInfoManage/service.js', // 设备信息管理service
  120 + 'module/basicInfo/employeeInfoManage/service.js', // 人员基础信息管理service
  121 + 'module/core/busConfig/service.js', // 车辆配置service
  122 + 'module/core/busLineInfoStat/service.js', // 线路运营概览service
  123 + 'module/core/employeeConfig/service.js', // 人员配置service
  124 + 'module/core/guideboardManage/service.js', // 路牌管理service
  125 + 'module/core/rerunManage/service.js', // 套跑管理service
  126 + 'module/core/schedulePlanManage/service.js', // 排班计划管理service
  127 + 'module/core/scheduleRuleManage/service.js', // 排班规则管理service
  128 + 'module/core/ttInfoManage/service.js', // 时刻表管理service
  129 + 'module/common/prj-common-globalservice-legacy.js' // 其他用service
  130 + ],
  131 + dest: 'module/common/prj-common-globalservice.js'
107 132 }
108 133 },
109 134  
... ... @@ -440,4 +465,14 @@ module.exports = function (grunt) {
440 465 'clean:concat_route', 'concat:route'
441 466 ]);
442 467  
  468 + /*
  469 + 定义了一个service的grunt任务
  470 + 任务组有顺序,如下说明:
  471 + 1、clean:concat_route,清除合并生成的prj-common-globalservice.js文件
  472 + 2、concat:route,重新合并prj-common-globalservice.js文件
  473 + */
  474 + grunt.registerTask('service', [
  475 + 'clean:concat_service', 'concat:service'
  476 + ]);
  477 +
443 478 };
444 479 \ No newline at end of file
... ...
src/main/resources/static/pages/scheduleApp/module/basicInfo/busInfoManage/service.js 0 → 100644
  1 +// 车辆信息service
  2 +angular.module('ScheduleApp').factory('BusInfoManageService_g', ['$resource', function($resource) {
  3 + return {
  4 + rest: $resource(
  5 + '/cars/:id',
  6 + {order: 'carCode', direction: 'ASC', id: '@id_route'},
  7 + {
  8 + list: {
  9 + method: 'GET',
  10 + params: {
  11 + page: 0
  12 + }
  13 + },
  14 + get: {
  15 + method: 'GET'
  16 + },
  17 + save: {
  18 + method: 'POST'
  19 + }
  20 + }
  21 + ),
  22 + import: $resource(
  23 + '/cars/importfile',
  24 + {},
  25 + {
  26 + do: {
  27 + method: 'POST',
  28 + headers: {
  29 + 'Content-Type': 'application/x-www-form-urlencoded'
  30 + },
  31 + transformRequest: function(obj) {
  32 + var str = [];
  33 + for (var p in obj) {
  34 + str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
  35 + }
  36 + return str.join("&");
  37 + }
  38 + }
  39 + }
  40 + ),
  41 + validate: $resource(
  42 + '/cars/validate/:type',
  43 + {},
  44 + {
  45 + insideCode: {
  46 + method: 'GET'
  47 + }
  48 + }
  49 + ),
  50 + dataTools: $resource(
  51 + '/cars/:type',
  52 + {},
  53 + {
  54 + dataExport: {
  55 + method: 'GET',
  56 + responseType: "arraybuffer",
  57 + params: {
  58 + type: "dataExport"
  59 + },
  60 + transformResponse: function(data, headers){
  61 + return {data : data};
  62 + }
  63 + }
  64 + }
  65 + )
  66 + };
  67 +}]);
0 68 \ No newline at end of file
... ...
src/main/resources/static/pages/scheduleApp/module/basicInfo/deviceInfoManage/service.js 0 → 100644
  1 +// 车辆设备信息service
  2 +angular.module('ScheduleApp').factory('DeviceInfoManageService_g', ['$resource', function($resource) {
  3 + return $resource(
  4 + '/cde/:id',
  5 + {order: 'xl,isCancel,cl,qyrq', direction: 'ASC,ASC,ASC,DESC', id: '@id_route'},
  6 + {
  7 + list: {
  8 + method: 'GET',
  9 + params: {
  10 + page: 0
  11 + }
  12 + },
  13 + get: {
  14 + method: 'GET'
  15 + },
  16 + save: {
  17 + method: 'POST'
  18 + },
  19 + delete: {
  20 + method: 'DELETE'
  21 + }
  22 + }
  23 + );
  24 +}]);
0 25 \ No newline at end of file
... ...
src/main/resources/static/pages/scheduleApp/module/basicInfo/employeeInfoManage/service.js 0 → 100644
  1 +// 人员信息service
  2 +angular.module('ScheduleApp').factory('EmployeeInfoManageService_g', ['$resource', function($resource) {
  3 + return {
  4 + rest : $resource(
  5 + '/personnel/:id',
  6 + {order: 'jobCode', direction: 'ASC', id: '@id_route'},
  7 + {
  8 + list: {
  9 + method: 'GET',
  10 + params: {
  11 + page: 0
  12 + }
  13 + },
  14 + get: {
  15 + method: 'GET'
  16 + },
  17 + save: {
  18 + method: 'POST'
  19 + }
  20 + }
  21 + ),
  22 + validate: $resource(
  23 + '/personnel/validate/:type',
  24 + {},
  25 + {
  26 + jobCode: {
  27 + method: 'GET'
  28 + }
  29 + }
  30 + ),
  31 + dataTools: $resource(
  32 + '/personnel/:type',
  33 + {},
  34 + {
  35 + dataExport: {
  36 + method: 'GET',
  37 + responseType: "arraybuffer",
  38 + params: {
  39 + type: "dataExport"
  40 + },
  41 + transformResponse: function(data, headers){
  42 + return {data : data};
  43 + }
  44 + }
  45 + }
  46 + )
  47 + };
  48 +}]);
... ...
src/main/resources/static/pages/scheduleApp/module/common/directives/.gitkeep.txt 0 → 100644
src/main/resources/static/pages/scheduleApp/module/common/directives/select/mySelect.js 0 → 100644
  1 +/**
  2 + * mySelect指令,封装uiselect指令,封装内部数据获取,只支持单选
  3 + * cm(必须):绑定外部对象,因为关联的字段不只一个,单独使用ngModel不够
  4 + * cmoptions(必须):描述绑定的逻辑配置对象,格式如下:
  5 + *
  6 + * // TODO:
  7 + */
  8 +angular.module('ScheduleApp').directive('mySelect', [
  9 + function() {
  10 + return {
  11 + restrict: 'E',
  12 + template: '<div>bioxuxuan</div>',
  13 + require: 'ngModel',
  14 + compile: function(tElem, tAttrs) {
  15 + return {
  16 + pre: function(scope, element, attr) {
  17 +
  18 + },
  19 + post: function(scope, element, attr, ngModelCtr) {
  20 + // model -> view
  21 + ngModelCtr.$formatters.push(function(modelValue) {
  22 + // 监控model的变化
  23 + if (typeof modelValue != "undefined") {
  24 + console.log(modelValue);
  25 +
  26 + return modelValue;
  27 + }
  28 + });
  29 +
  30 + ngModelCtr.$render = function() {
  31 + if (typeof scope.ctrl.say != "undefined") {
  32 + element.find('div').css('color', 'red');
  33 + }
  34 + };
  35 +
  36 + ngModelCtr.$setViewValue("init value");
  37 +
  38 +
  39 + }
  40 + }
  41 + }
  42 + }
  43 + }
  44 +]);
0 45 \ No newline at end of file
... ...
src/main/resources/static/pages/scheduleApp/module/common/directives/select/mySelectTemplate.html 0 → 100644
  1 +<div class="input-group" name="指令compile阶段设定1"
  2 + ng-model="$saSelectCtrl.$$internalmodel">
  3 + <ui-select ng-model="$saSelectCtrl.$$internal_select_value" on-select="$saSelectCtrl.$$internal_select_fn($item)"
  4 + theme="bootstrap" >
  5 + <ui-select-match placeholder="指令compile阶段设定">指令compile阶段设定2</ui-select-match>
  6 + <ui-select-choices repeat="指令compile阶段设定3"
  7 + refresh="$saSelectCtrl.$$internal_refresh_fn($select.search)"
  8 + refresh-delay="10">
  9 +
  10 + 指令compile阶段设定777
  11 +
  12 + </ui-select-choices>
  13 + </ui-select>
  14 + <span class="input-group-btn">
  15 + <button type="button" ng-click="$saSelectCtrl.$$internal_remove_fn()" class="btn btn-default">
  16 + <span class="glyphicon glyphicon-trash"></span>
  17 + </button>
  18 + </span>
  19 +</div>
0 20 \ No newline at end of file
... ...
src/main/resources/static/pages/scheduleApp/module/common/dts1/select/saSelect5.js
... ... @@ -124,23 +124,40 @@ angular.module(&#39;ScheduleApp&#39;).directive(&#39;saSelect5&#39;, [
124 124  
125 125 // 添加选中事件处理函数
126 126 scope[ctrlAs].$$internal_select_fn = function($item) {
127   - eval("scope[ctrlAs].model" + "." + $dcname_attr + " = $item" + "." + $icname_attr + ";");
  127 + if ($dcname_attr.indexOf('_') > 0) {
  128 + scope[ctrlAs].model[$dcname_attr] = $item[$icname_attr];
  129 + } else {
  130 + eval("scope[ctrlAs].model" + "." + $dcname_attr + " = $item" + "." + $icname_attr + ";");
  131 + }
  132 +
128 133  
129 134 eval("var obj=" + $cmaps_attr);
130 135 for (var mc in obj) { // model的字段名:内部数据源对应字段名
131 136 var ic = obj[mc]; // 内部数据源对应字段
132   - eval("scope[ctrlAs].model" + "." + mc + " = $item" + "." + ic + ";");
  137 + if (mc.indexOf('_') > 0) {
  138 + scope[ctrlAs].model[mc] = $item[ic];
  139 + } else {
  140 + eval("scope[ctrlAs].model" + "." + mc + " = $item" + "." + ic + ";");
  141 + }
133 142 }
134 143 };
135 144  
136 145 // 删除选中事件处理函数
137 146 scope[ctrlAs].$$internal_remove_fn = function() {
138   - eval("scope[ctrlAs].model" + "." + $dcname_attr + " = undefined;");
  147 + if ($dcname_attr.indexOf('_') > 0) {
  148 + scope[ctrlAs].model[$dcname_attr] = undefined;
  149 + } else {
  150 + eval("scope[ctrlAs].model" + "." + $dcname_attr + " = undefined;");
  151 + }
139 152  
140 153 eval("var obj=" + $cmaps_attr);
141 154 var mc; // model的字段名
142 155 for (mc in obj) {
143   - eval("scope[ctrlAs].model" + "." + mc + " = undefined;");
  156 + if (mc.indexOf('_') > 0) {
  157 + scope[ctrlAs].model[mc] = undefined;
  158 + } else {
  159 + eval("scope[ctrlAs].model" + "." + mc + " = undefined;");
  160 + }
144 161 }
145 162 };
146 163  
... ... @@ -381,7 +398,11 @@ angular.module(&#39;ScheduleApp&#39;).directive(&#39;saSelect5&#39;, [
381 398 */
382 399 scope.$watch(
383 400 function() {
384   - return eval("scope." + ctrlAs + ".model" + "." + $dcname_attr);
  401 + if ($dcname_attr.indexOf('_') > 0) {
  402 + return scope[ctrlAs].model[$dcname_attr];
  403 + } else {
  404 + return eval("scope." + ctrlAs + ".model" + "." + $dcname_attr);
  405 + }
385 406 },
386 407 function(newValue, oldValue) {
387 408 if (newValue === undefined && oldValue === undefined) {
... ...
src/main/resources/static/pages/scheduleApp/module/common/dts1/validation/remoteValidation.js
... ... @@ -27,7 +27,7 @@ angular.module(&#39;ScheduleApp&#39;).directive(&#39;remoteValidation&#39;, [
27 27 var $watch_rvparam_obj = undefined;
28 28  
29 29 // 验证数据
30   - var $$internal_validate = function(ngModelCtrl) {
  30 + var $$internal_validate = function(ngModelCtrl, scope) {
31 31 if ($watch_rvtype && $watch_rvparam_obj) {
32 32 // 获取查询参数模版
33 33 var paramTemplate = $$SearchInfoService_g.validate[$watch_rvtype].template;
... ... @@ -52,6 +52,7 @@ angular.module(&#39;ScheduleApp&#39;).directive(&#39;remoteValidation&#39;, [
52 52 ngModelCtrl.$setValidity('remote', true);
53 53 } else {
54 54 ngModelCtrl.$setValidity('remote', false);
  55 + scope.$remote_msg = result.msg;
55 56 }
56 57 },
57 58 function(result) {
... ... @@ -74,7 +75,7 @@ angular.module(&#39;ScheduleApp&#39;).directive(&#39;remoteValidation&#39;, [
74 75 attr.$observe("remotevtype", function(value) {
75 76 if (value && value != "") {
76 77 $watch_rvtype = value;
77   - $$internal_validate(ngModelCtrl);
  78 + $$internal_validate(ngModelCtrl, scope);
78 79 }
79 80 });
80 81 /**
... ... @@ -86,7 +87,7 @@ angular.module(&#39;ScheduleApp&#39;).directive(&#39;remoteValidation&#39;, [
86 87 return;
87 88 }
88 89 $watch_rvparam_obj = JSON.parse(value);
89   - $$internal_validate(ngModelCtrl);
  90 + $$internal_validate(ngModelCtrl, scope);
90 91 }
91 92 });
92 93 }
... ...
src/main/resources/static/pages/scheduleApp/module/common/dts1/validation/remoteValidation3.js 0 → 100644
  1 +/**
  2 + * remoteValidationt3 远程验证指令(监控依赖的model变化)
  3 + * 属性如下:
  4 + * remotevtype(必须):验证类型(在service中有对应映射),如rvtype="xl"
  5 + * remotemodel(必须):关联的model
  6 + * remotemodelcol(必须):关联的model属性
  7 + */
  8 +angular.module('ScheduleApp').directive(
  9 + 'remoteValidation3',
  10 + [
  11 + '$$SearchInfoService_g',
  12 + '$q',
  13 + function($$SearchInfoService_g, $q) {
  14 + return {
  15 + restrict: 'A', // 属性
  16 + require: '^ngModel', // 依赖所属指令的ngModel
  17 + compile: function(tElem, tAttrs) {
  18 + var remotevtype_attr = tAttrs['remotevtype'];
  19 + var remotemodel_attr = tAttrs['remotemodel'];
  20 + var remotemodelcol_attr = tAttrs['remotemodelcol'];
  21 + if (!remotevtype_attr) {
  22 + throw new Error("remotevtype属性必须填写");
  23 + }
  24 + if (!remotemodel_attr) {
  25 + throw new Error("remotemodel属性必须填写");
  26 + }
  27 + if (!remotemodelcol_attr) {
  28 + throw new Error("remotemodelcol属性必须填写");
  29 + }
  30 +
  31 + return {
  32 + pre: function(scope, element, attr) {
  33 +
  34 + },
  35 +
  36 + post: function(scope, element, attr, ngModelCtrl) {
  37 + ngModelCtrl.$asyncValidators.remote =
  38 + function(modelValue, viewValue) {
  39 + var deferred = $q.defer();
  40 +
  41 + // 远端验证service
  42 + var param = JSON.parse(attr['remotemodel']);
  43 + console.log(param);
  44 + param[remotemodelcol_attr] = modelValue;
  45 + $$SearchInfoService_g.validate[remotevtype_attr].remote.do(
  46 + param,
  47 + function(result) {
  48 + if (result.status == "SUCCESS") {
  49 + deferred.resolve();
  50 + } else {
  51 + scope.$remote_msg = result.msg;
  52 + deferred.reject();
  53 + }
  54 + },
  55 + function(result) {
  56 + deferred.reject();
  57 + }
  58 + );
  59 +
  60 + return deferred.promise;
  61 + };
  62 + }
  63 + };
  64 + }
  65 + }
  66 + }
  67 + ]
  68 +);
0 69 \ No newline at end of file
... ...
src/main/resources/static/pages/scheduleApp/module/common/dts2/ttinfotable/mySelect.js 0 → 100644
  1 +/**
  2 + * mySelect指令,封装uiselect指令,封装内部数据获取,只支持单选
  3 + * cm(必须):绑定外部对象,因为关联的字段不只一个,单独使用ngModel不够
  4 + * cmoptions(必须):描述绑定的逻辑配置对象,格式如下:
  5 + *
  6 + * // TODO:
  7 + */
  8 +angular.module('ScheduleApp').directive('mySelect', [
  9 + function() {
  10 + return {
  11 + restrict: 'E',
  12 + template: '<div>bioxuxuan</div>',
  13 + require: 'ngModel',
  14 + compile: function(tElem, tAttrs) {
  15 + return {
  16 + pre: function(scope, element, attr) {
  17 +
  18 + },
  19 + post: function(scope, element, attr, ngModelCtr) {
  20 + // model -> view
  21 + ngModelCtr.$formatters.push(function(modelValue) {
  22 + // 监控model的变化
  23 + if (typeof modelValue != "undefined") {
  24 + console.log(modelValue);
  25 +
  26 + return modelValue;
  27 + }
  28 + });
  29 +
  30 + ngModelCtr.$render = function() {
  31 + if (typeof scope.ctrl.say != "undefined") {
  32 + element.find('div').css('color', 'red');
  33 + }
  34 + };
  35 +
  36 + ngModelCtr.$setViewValue("init value");
  37 +
  38 +
  39 + }
  40 + }
  41 + }
  42 + }
  43 + }
  44 +]);
0 45 \ No newline at end of file
... ...
src/main/resources/static/pages/scheduleApp/module/common/dts2/ttinfotable/mySelectTemplate.html 0 → 100644
  1 +<div class="input-group" name="指令compile阶段设定1"
  2 + ng-model="$saSelectCtrl.$$internalmodel">
  3 + <ui-select ng-model="$saSelectCtrl.$$internal_select_value" on-select="$saSelectCtrl.$$internal_select_fn($item)"
  4 + theme="bootstrap" >
  5 + <ui-select-match placeholder="指令compile阶段设定">指令compile阶段设定2</ui-select-match>
  6 + <ui-select-choices repeat="指令compile阶段设定3"
  7 + refresh="$saSelectCtrl.$$internal_refresh_fn($select.search)"
  8 + refresh-delay="10">
  9 +
  10 + 指令compile阶段设定777
  11 +
  12 + </ui-select-choices>
  13 + </ui-select>
  14 + <span class="input-group-btn">
  15 + <button type="button" ng-click="$saSelectCtrl.$$internal_remove_fn()" class="btn btn-default">
  16 + <span class="glyphicon glyphicon-trash"></span>
  17 + </button>
  18 + </span>
  19 +</div>
0 20 \ No newline at end of file
... ...
src/main/resources/static/pages/scheduleApp/module/common/prj-common-directive.js
... ... @@ -49,7 +49,7 @@ angular.module(&#39;ScheduleApp&#39;).directive(&#39;remoteValidation&#39;, [
49 49 var $watch_rvparam_obj = undefined;
50 50  
51 51 // 验证数据
52   - var $$internal_validate = function(ngModelCtrl) {
  52 + var $$internal_validate = function(ngModelCtrl, scope) {
53 53 if ($watch_rvtype && $watch_rvparam_obj) {
54 54 // 获取查询参数模版
55 55 var paramTemplate = $$SearchInfoService_g.validate[$watch_rvtype].template;
... ... @@ -74,6 +74,7 @@ angular.module(&#39;ScheduleApp&#39;).directive(&#39;remoteValidation&#39;, [
74 74 ngModelCtrl.$setValidity('remote', true);
75 75 } else {
76 76 ngModelCtrl.$setValidity('remote', false);
  77 + scope.$remote_msg = result.msg;
77 78 }
78 79 },
79 80 function(result) {
... ... @@ -96,7 +97,7 @@ angular.module(&#39;ScheduleApp&#39;).directive(&#39;remoteValidation&#39;, [
96 97 attr.$observe("remotevtype", function(value) {
97 98 if (value && value != "") {
98 99 $watch_rvtype = value;
99   - $$internal_validate(ngModelCtrl);
  100 + $$internal_validate(ngModelCtrl, scope);
100 101 }
101 102 });
102 103 /**
... ... @@ -108,7 +109,7 @@ angular.module(&#39;ScheduleApp&#39;).directive(&#39;remoteValidation&#39;, [
108 109 return;
109 110 }
110 111 $watch_rvparam_obj = JSON.parse(value);
111   - $$internal_validate(ngModelCtrl);
  112 + $$internal_validate(ngModelCtrl, scope);
112 113 }
113 114 });
114 115 }
... ... @@ -218,6 +219,74 @@ angular.module(&#39;ScheduleApp&#39;).directive(&#39;remoteValidationt2&#39;, [
218 219 }
219 220 ]);
220 221  
  222 +/**
  223 + * remoteValidationt3 远程验证指令(监控依赖的model变化)
  224 + * 属性如下:
  225 + * remotevtype(必须):验证类型(在service中有对应映射),如rvtype="xl"
  226 + * remotemodel(必须):关联的model
  227 + * remotemodelcol(必须):关联的model属性
  228 + */
  229 +angular.module('ScheduleApp').directive(
  230 + 'remoteValidation3',
  231 + [
  232 + '$$SearchInfoService_g',
  233 + '$q',
  234 + function($$SearchInfoService_g, $q) {
  235 + return {
  236 + restrict: 'A', // 属性
  237 + require: '^ngModel', // 依赖所属指令的ngModel
  238 + compile: function(tElem, tAttrs) {
  239 + var remotevtype_attr = tAttrs['remotevtype'];
  240 + var remotemodel_attr = tAttrs['remotemodel'];
  241 + var remotemodelcol_attr = tAttrs['remotemodelcol'];
  242 + if (!remotevtype_attr) {
  243 + throw new Error("remotevtype属性必须填写");
  244 + }
  245 + if (!remotemodel_attr) {
  246 + throw new Error("remotemodel属性必须填写");
  247 + }
  248 + if (!remotemodelcol_attr) {
  249 + throw new Error("remotemodelcol属性必须填写");
  250 + }
  251 +
  252 + return {
  253 + pre: function(scope, element, attr) {
  254 +
  255 + },
  256 +
  257 + post: function(scope, element, attr, ngModelCtrl) {
  258 + ngModelCtrl.$asyncValidators.remote =
  259 + function(modelValue, viewValue) {
  260 + var deferred = $q.defer();
  261 +
  262 + // 远端验证service
  263 + var param = JSON.parse(attr['remotemodel']);
  264 + console.log(param);
  265 + param[remotemodelcol_attr] = modelValue;
  266 + $$SearchInfoService_g.validate[remotevtype_attr].remote.do(
  267 + param,
  268 + function(result) {
  269 + if (result.status == "SUCCESS") {
  270 + deferred.resolve();
  271 + } else {
  272 + scope.$remote_msg = result.msg;
  273 + deferred.reject();
  274 + }
  275 + },
  276 + function(result) {
  277 + deferred.reject();
  278 + }
  279 + );
  280 +
  281 + return deferred.promise;
  282 + };
  283 + }
  284 + };
  285 + }
  286 + }
  287 + }
  288 + ]
  289 +);
221 290  
222 291 angular.module('ScheduleApp').directive("saSelect", ['$timeout', function($timeout) {
223 292 return {
... ... @@ -1331,23 +1400,40 @@ angular.module(&#39;ScheduleApp&#39;).directive(&#39;saSelect5&#39;, [
1331 1400  
1332 1401 // 添加选中事件处理函数
1333 1402 scope[ctrlAs].$$internal_select_fn = function($item) {
1334   - eval("scope[ctrlAs].model" + "." + $dcname_attr + " = $item" + "." + $icname_attr + ";");
  1403 + if ($dcname_attr.indexOf('_') > 0) {
  1404 + scope[ctrlAs].model[$dcname_attr] = $item[$icname_attr];
  1405 + } else {
  1406 + eval("scope[ctrlAs].model" + "." + $dcname_attr + " = $item" + "." + $icname_attr + ";");
  1407 + }
  1408 +
1335 1409  
1336 1410 eval("var obj=" + $cmaps_attr);
1337 1411 for (var mc in obj) { // model的字段名:内部数据源对应字段名
1338 1412 var ic = obj[mc]; // 内部数据源对应字段
1339   - eval("scope[ctrlAs].model" + "." + mc + " = $item" + "." + ic + ";");
  1413 + if (mc.indexOf('_') > 0) {
  1414 + scope[ctrlAs].model[mc] = $item[ic];
  1415 + } else {
  1416 + eval("scope[ctrlAs].model" + "." + mc + " = $item" + "." + ic + ";");
  1417 + }
1340 1418 }
1341 1419 };
1342 1420  
1343 1421 // 删除选中事件处理函数
1344 1422 scope[ctrlAs].$$internal_remove_fn = function() {
1345   - eval("scope[ctrlAs].model" + "." + $dcname_attr + " = undefined;");
  1423 + if ($dcname_attr.indexOf('_') > 0) {
  1424 + scope[ctrlAs].model[$dcname_attr] = undefined;
  1425 + } else {
  1426 + eval("scope[ctrlAs].model" + "." + $dcname_attr + " = undefined;");
  1427 + }
1346 1428  
1347 1429 eval("var obj=" + $cmaps_attr);
1348 1430 var mc; // model的字段名
1349 1431 for (mc in obj) {
1350   - eval("scope[ctrlAs].model" + "." + mc + " = undefined;");
  1432 + if (mc.indexOf('_') > 0) {
  1433 + scope[ctrlAs].model[mc] = undefined;
  1434 + } else {
  1435 + eval("scope[ctrlAs].model" + "." + mc + " = undefined;");
  1436 + }
1351 1437 }
1352 1438 };
1353 1439  
... ... @@ -1588,7 +1674,11 @@ angular.module(&#39;ScheduleApp&#39;).directive(&#39;saSelect5&#39;, [
1588 1674 */
1589 1675 scope.$watch(
1590 1676 function() {
1591   - return eval("scope." + ctrlAs + ".model" + "." + $dcname_attr);
  1677 + if ($dcname_attr.indexOf('_') > 0) {
  1678 + return scope[ctrlAs].model[$dcname_attr];
  1679 + } else {
  1680 + return eval("scope." + ctrlAs + ".model" + "." + $dcname_attr);
  1681 + }
1592 1682 },
1593 1683 function(newValue, oldValue) {
1594 1684 if (newValue === undefined && oldValue === undefined) {
... ... @@ -1608,6 +1698,50 @@ angular.module(&#39;ScheduleApp&#39;).directive(&#39;saSelect5&#39;, [
1608 1698 };
1609 1699 }
1610 1700 ]);
  1701 +/**
  1702 + * mySelect指令,封装uiselect指令,封装内部数据获取,只支持单选
  1703 + * cm(必须):绑定外部对象,因为关联的字段不只一个,单独使用ngModel不够
  1704 + * cmoptions(必须):描述绑定的逻辑配置对象,格式如下:
  1705 + *
  1706 + * // TODO:
  1707 + */
  1708 +angular.module('ScheduleApp').directive('mySelect', [
  1709 + function() {
  1710 + return {
  1711 + restrict: 'E',
  1712 + template: '<div>bioxuxuan</div>',
  1713 + require: 'ngModel',
  1714 + compile: function(tElem, tAttrs) {
  1715 + return {
  1716 + pre: function(scope, element, attr) {
  1717 +
  1718 + },
  1719 + post: function(scope, element, attr, ngModelCtr) {
  1720 + // model -> view
  1721 + ngModelCtr.$formatters.push(function(modelValue) {
  1722 + // 监控model的变化
  1723 + if (typeof modelValue != "undefined") {
  1724 + console.log(modelValue);
  1725 +
  1726 + return modelValue;
  1727 + }
  1728 + });
  1729 +
  1730 + ngModelCtr.$render = function() {
  1731 + if (typeof scope.ctrl.say != "undefined") {
  1732 + element.find('div').css('color', 'red');
  1733 + }
  1734 + };
  1735 +
  1736 + ngModelCtr.$setViewValue("init value");
  1737 +
  1738 +
  1739 + }
  1740 + }
  1741 + }
  1742 + }
  1743 + }
  1744 +]);
1611 1745  
1612 1746 /**
1613 1747 * saRadiogroup指令
... ...
src/main/resources/static/pages/scheduleApp/module/common/prj-common-globalservice-legacy.js 0 → 100644
  1 +// 项目通用的全局service服务,供不同的controller使用,自定义指令不使用
  2 +
  3 +// 文件下载服务
  4 +angular.module('ScheduleApp').factory('FileDownload_g', function() {
  5 + return {
  6 + downloadFile: function (data, mimeType, fileName) {
  7 + var success = false;
  8 + var blob = new Blob([data], { type: mimeType });
  9 + try {
  10 + if (navigator.msSaveBlob)
  11 + navigator.msSaveBlob(blob, fileName);
  12 + else {
  13 + // Try using other saveBlob implementations, if available
  14 + var saveBlob = navigator.webkitSaveBlob || navigator.mozSaveBlob || navigator.saveBlob;
  15 + if (saveBlob === undefined) throw "Not supported";
  16 + saveBlob(blob, fileName);
  17 + }
  18 + success = true;
  19 + } catch (ex) {
  20 + console.log("saveBlob method failed with the following exception:");
  21 + console.log(ex);
  22 + }
  23 +
  24 + if (!success) {
  25 + // Get the blob url creator
  26 + var urlCreator = window.URL || window.webkitURL || window.mozURL || window.msURL;
  27 + if (urlCreator) {
  28 + // Try to use a download link
  29 + var link = document.createElement('a');
  30 + if ('download' in link) {
  31 + // Try to simulate a click
  32 + try {
  33 + // Prepare a blob URL
  34 + var url = urlCreator.createObjectURL(blob);
  35 + link.setAttribute('href', url);
  36 +
  37 + // Set the download attribute (Supported in Chrome 14+ / Firefox 20+)
  38 + link.setAttribute("download", fileName);
  39 +
  40 + // Simulate clicking the download link
  41 + var event = document.createEvent('MouseEvents');
  42 + event.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
  43 + link.dispatchEvent(event);
  44 + success = true;
  45 +
  46 + } catch (ex) {
  47 + console.log("Download link method with simulated click failed with the following exception:");
  48 + console.log(ex);
  49 + }
  50 + }
  51 +
  52 + if (!success) {
  53 + // Fallback to window.location method
  54 + try {
  55 + // Prepare a blob URL
  56 + // Use application/octet-stream when using window.location to force download
  57 + var url = urlCreator.createObjectURL(blob);
  58 + window.location = url;
  59 + console.log("Download link method with window.location succeeded");
  60 + success = true;
  61 + } catch (ex) {
  62 + console.log("Download link method with window.location failed with the following exception:");
  63 + console.log(ex);
  64 + }
  65 + }
  66 + }
  67 + }
  68 +
  69 + if (!success) {
  70 + // Fallback to window.open method
  71 + console.log("No methods worked for saving the arraybuffer, using last resort window.open");
  72 + window.open("", '_blank', '');
  73 + }
  74 + }
  75 + };
  76 +});
  77 +
  78 +
  79 +/**
  80 + * saSelect2指令,根据属性值,动态载入数据,然后支持拼音搜索,点击右边的按钮清除选择并重新载入数据。
  81 + * 1、compile阶段使用的属性如下:
  82 + * required:用于和表单验证连接,指定成required="true"才有效。
  83 + * 2、link阶段使用的属性如下
  84 + * model:关联的模型对象
  85 + * name:表单验证时需要的名字
  86 + * type:关联的那种数据值(xl/cl/ry)-> 对应线路信息/车辆信息/人员信息,后面有的继续加
  87 + * modelcolname1:关联的模型字段名字1(一般应该是编码字段)
  88 + * modelcolname2:关联的模型字段名字2(一般应该是名字字段)
  89 + * datacolname1;内部数据对应的字段名字1(与模型字段1对应)
  90 + * datacolname2:内部数据对应的字段名字2(与模型字段2对应)
  91 + * showcolname:下拉框显示的内部数据字段名(注意:不是模型数据字段名),TODO:以后考虑放动态表达式,并在compile阶段使用
  92 + * placeholder:select placeholder字符串描述
  93 + *
  94 + * $$pyFilter,内部的filter指令,结合简拼音进行拼音过滤。
  95 + * $$SearchInfoService_g,内部使用的数据服务
  96 + */
  97 +// saSelect2指令使用的内部信service
  98 +angular.module('ScheduleApp').factory('$$SearchInfoService_g', ['$resource', function($resource) {
  99 + return {
  100 + xl: $resource(
  101 + '/line/:type',
  102 + {order: 'name', direction: 'ASC'},
  103 + {
  104 + list: {
  105 + method: 'GET',
  106 + isArray: true
  107 + }
  108 + }
  109 + ),
  110 + xlinfo: $resource(
  111 + '/lineInformation/:type',
  112 + {order: 'line.name', direction: 'ASC'},
  113 + {
  114 + list: {
  115 + method: 'GET',
  116 + isArray: true
  117 + }
  118 + }
  119 + ),
  120 + zd: $resource(
  121 + '/stationroute/stations',
  122 + {order: 'stationCode', direction: 'ASC'},
  123 + {
  124 + list: {
  125 + method: 'GET',
  126 + isArray: true
  127 + }
  128 + }
  129 + ),
  130 + tcc: $resource(
  131 + '/carpark/:type',
  132 + {order: 'parkCode', direction: 'ASC'},
  133 + {
  134 + list: {
  135 + method: 'GET',
  136 + isArray: true
  137 + }
  138 + }
  139 + ),
  140 + ry: $resource(
  141 + '/personnel/:type',
  142 + {order: 'personnelName', direction: 'ASC'},
  143 + {
  144 + list: {
  145 + method: 'GET',
  146 + isArray: true
  147 + }
  148 + }
  149 + ),
  150 + cl: $resource(
  151 + '/cars/:type',
  152 + {order: "insideCode", direction: 'ASC'},
  153 + {
  154 + list: {
  155 + method: 'GET',
  156 + isArray: true
  157 + }
  158 + }
  159 + ),
  160 + ttInfo: $resource(
  161 + '/tic/:type',
  162 + {order: "name", direction: 'ASC'},
  163 + {
  164 + list: {
  165 + method: 'GET',
  166 + isArray: true
  167 + }
  168 + }
  169 + ),
  170 + lpInfo: $resource(
  171 + '/gic/ttlpnames',
  172 + {order: "lpName", direction: 'ASC'},
  173 + {
  174 + list: {
  175 + method: 'GET',
  176 + isArray: true
  177 + }
  178 + }
  179 + ),
  180 + lpInfo2: $resource(
  181 + '/gic/:type',
  182 + {order: "lpName", direction: 'ASC'},
  183 + {
  184 + list: {
  185 + method: 'GET',
  186 + isArray: true
  187 + }
  188 + }
  189 + ),
  190 + cci: $resource(
  191 + '/cci/cars',
  192 + {},
  193 + {
  194 + list: {
  195 + method: 'GET',
  196 + isArray: true
  197 + }
  198 + }
  199 +
  200 + ),
  201 + cci2: $resource(
  202 + '/cci/:type',
  203 + {},
  204 + {
  205 + list: {
  206 + method: 'GET',
  207 + isArray: true
  208 + }
  209 + }
  210 + ),
  211 + cci3: $resource(
  212 + '/cci/cars2',
  213 + {},
  214 + {
  215 + list: {
  216 + method: 'GET',
  217 + isArray: true
  218 + }
  219 + }
  220 +
  221 + ),
  222 + eci: $resource(
  223 + '/eci/jsy',
  224 + {},
  225 + {
  226 + list: {
  227 + method: 'GET',
  228 + isArray: true
  229 + }
  230 + }
  231 + ),
  232 + eci2: $resource(
  233 + '/eci/spy',
  234 + {},
  235 + {
  236 + list: {
  237 + method: 'GET',
  238 + isArray: true
  239 + }
  240 + }
  241 + ),
  242 + eci3: $resource(
  243 + '/eci/:type',
  244 + {},
  245 + {
  246 + list: {
  247 + method: 'GET',
  248 + isArray: true
  249 + }
  250 + }
  251 + ),
  252 +
  253 +
  254 + validate: { // remoteValidation指令用到的resource
  255 + gbv1: { // 路牌序号验证
  256 + template: {'xl.id_eq': -1, 'lpNo_eq': 'ddd'},
  257 + remote: $resource(
  258 + '/gic/validate1',
  259 + {},
  260 + {
  261 + do: {
  262 + method: 'GET'
  263 + }
  264 + }
  265 + )
  266 + },
  267 + gbv2: { // 路牌名称验证
  268 + template: {'xl.id_eq': -1, 'lpName_eq': 'ddd'},
  269 + remote: $resource(
  270 + '/gic/validate2',
  271 + {},
  272 + {
  273 + do: {
  274 + method: 'GET'
  275 + }
  276 + }
  277 + )
  278 + },
  279 +
  280 + cl1: { // 车辆自编号不能重复验证
  281 + template: {'insideCode_eq': '-1'}, // 查询参数模版
  282 + remote: $resource( // $resource封装对象
  283 + '/cars/validate/equale',
  284 + {},
  285 + {
  286 + do: {
  287 + method: 'GET'
  288 + }
  289 + }
  290 + )
  291 + },
  292 + cde1: { // 车辆设备启用日期验证
  293 + template: {'qyrq': 0, 'xl': 1, 'cl': 1}, // 日期毫秒
  294 + remote: $resource( // $resource封装对象
  295 + '/cde//validate/qyrq',
  296 + {},
  297 + {
  298 + do: {
  299 + method: 'GET'
  300 + }
  301 + }
  302 + )
  303 + },
  304 + ttc1: { // 时刻表名字验证
  305 + template: {'xl.id_eq': -1, 'name_eq': 'ddd'},
  306 + remote: $resource( // $resource封装对象
  307 + '/tic/validate/equale',
  308 + {},
  309 + {
  310 + do: {
  311 + method: 'GET'
  312 + }
  313 + }
  314 + )
  315 + },
  316 + sheet: { // 时刻表sheet工作区验证
  317 + template: {'filename': '', 'sheetname': '', 'lineid': -1, 'linename': ''},
  318 + remote: $resource( // $resource封装对象
  319 + '/tidc/validate/sheet',
  320 + {},
  321 + {
  322 + do: {
  323 + method: 'POST',
  324 + headers: {
  325 + 'Content-Type': 'application/x-www-form-urlencoded'
  326 + },
  327 + transformRequest: function(obj) {
  328 + var str = [];
  329 + for (var p in obj) {
  330 + str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
  331 + }
  332 + return str.join("&");
  333 + }
  334 + }
  335 + }
  336 + )
  337 + },
  338 + sheetli: { // 时刻表线路标准验证
  339 + template: {'lineinfoid': -1},
  340 + remote: $resource( // $resource封装对象
  341 + '/tidc/validate/lineinfo',
  342 + {},
  343 + {
  344 + do: {
  345 + method: 'GET'
  346 + }
  347 + }
  348 + )
  349 + }
  350 + }
  351 +
  352 + //validate: $resource(
  353 + // '/cars/validate/:type',
  354 + // {},
  355 + // {
  356 + // insideCode: {
  357 + // method: 'GET'
  358 + // }
  359 + // }
  360 + //)
  361 +
  362 +
  363 +
  364 + }
  365 +}]);
  366 +
  367 +
  368 +
... ...
src/main/resources/static/pages/scheduleApp/module/common/prj-common-globalservice.js
1   -// 项目通用的全局service服务,供不同的controller使用,自定义指令不使用
2   -
3   -// 文件下载服务
4   -angular.module('ScheduleApp').factory('FileDownload_g', function() {
5   - return {
6   - downloadFile: function (data, mimeType, fileName) {
7   - var success = false;
8   - var blob = new Blob([data], { type: mimeType });
9   - try {
10   - if (navigator.msSaveBlob)
11   - navigator.msSaveBlob(blob, fileName);
12   - else {
13   - // Try using other saveBlob implementations, if available
14   - var saveBlob = navigator.webkitSaveBlob || navigator.mozSaveBlob || navigator.saveBlob;
15   - if (saveBlob === undefined) throw "Not supported";
16   - saveBlob(blob, fileName);
17   - }
18   - success = true;
19   - } catch (ex) {
20   - console.log("saveBlob method failed with the following exception:");
21   - console.log(ex);
22   - }
23   -
24   - if (!success) {
25   - // Get the blob url creator
26   - var urlCreator = window.URL || window.webkitURL || window.mozURL || window.msURL;
27   - if (urlCreator) {
28   - // Try to use a download link
29   - var link = document.createElement('a');
30   - if ('download' in link) {
31   - // Try to simulate a click
32   - try {
33   - // Prepare a blob URL
34   - var url = urlCreator.createObjectURL(blob);
35   - link.setAttribute('href', url);
36   -
37   - // Set the download attribute (Supported in Chrome 14+ / Firefox 20+)
38   - link.setAttribute("download", fileName);
39   -
40   - // Simulate clicking the download link
41   - var event = document.createEvent('MouseEvents');
42   - event.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
43   - link.dispatchEvent(event);
44   - success = true;
45   -
46   - } catch (ex) {
47   - console.log("Download link method with simulated click failed with the following exception:");
48   - console.log(ex);
49   - }
50   - }
51   -
52   - if (!success) {
53   - // Fallback to window.location method
54   - try {
55   - // Prepare a blob URL
56   - // Use application/octet-stream when using window.location to force download
57   - var url = urlCreator.createObjectURL(blob);
58   - window.location = url;
59   - console.log("Download link method with window.location succeeded");
60   - success = true;
61   - } catch (ex) {
62   - console.log("Download link method with window.location failed with the following exception:");
63   - console.log(ex);
64   - }
65   - }
66   - }
67   - }
68   -
69   - if (!success) {
70   - // Fallback to window.open method
71   - console.log("No methods worked for saving the arraybuffer, using last resort window.open");
72   - window.open("", '_blank', '');
73   - }
74   - }
75   - };
76   -});
77   -
78   -// 车辆信息service
79   -angular.module('ScheduleApp').factory('BusInfoManageService_g', ['$resource', function($resource) {
80   - return {
81   - rest: $resource(
82   - '/cars/:id',
83   - {order: 'carCode', direction: 'ASC', id: '@id_route'},
84   - {
85   - list: {
86   - method: 'GET',
87   - params: {
88   - page: 0
89   - }
90   - },
91   - get: {
92   - method: 'GET'
93   - },
94   - save: {
95   - method: 'POST'
96   - }
97   - }
98   - ),
99   - import: $resource(
100   - '/cars/importfile',
101   - {},
102   - {
103   - do: {
104   - method: 'POST',
105   - headers: {
106   - 'Content-Type': 'application/x-www-form-urlencoded'
107   - },
108   - transformRequest: function(obj) {
109   - var str = [];
110   - for (var p in obj) {
111   - str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
112   - }
113   - return str.join("&");
114   - }
115   - }
116   - }
117   - ),
118   - validate: $resource(
119   - '/cars/validate/:type',
120   - {},
121   - {
122   - insideCode: {
123   - method: 'GET'
124   - }
125   - }
126   - ),
127   - dataTools: $resource(
128   - '/cars/:type',
129   - {},
130   - {
131   - dataExport: {
132   - method: 'GET',
133   - responseType: "arraybuffer",
134   - params: {
135   - type: "dataExport"
136   - },
137   - transformResponse: function(data, headers){
138   - return {data : data};
139   - }
140   - }
141   - }
142   - )
143   - };
144   -}]);
145   -// 人员信息service
146   -angular.module('ScheduleApp').factory('EmployeeInfoManageService_g', ['$resource', function($resource) {
147   - return {
148   - rest : $resource(
149   - '/personnel/:id',
150   - {order: 'jobCode', direction: 'ASC', id: '@id_route'},
151   - {
152   - list: {
153   - method: 'GET',
154   - params: {
155   - page: 0
156   - }
157   - },
158   - get: {
159   - method: 'GET'
160   - },
161   - save: {
162   - method: 'POST'
163   - }
164   - }
165   - ),
166   - validate: $resource(
167   - '/personnel/validate/:type',
168   - {},
169   - {
170   - jobCode: {
171   - method: 'GET'
172   - }
173   - }
174   - ),
175   - dataTools: $resource(
176   - '/personnel/:type',
177   - {},
178   - {
179   - dataExport: {
180   - method: 'GET',
181   - responseType: "arraybuffer",
182   - params: {
183   - type: "dataExport"
184   - },
185   - transformResponse: function(data, headers){
186   - return {data : data};
187   - }
188   - }
189   - }
190   - )
191   - };
192   -}]);
193   -// 车辆设备信息service
194   -angular.module('ScheduleApp').factory('DeviceInfoManageService_g', ['$resource', function($resource) {
195   - return $resource(
196   - '/cde/:id',
197   - {order: 'xl,isCancel,cl,qyrq', direction: 'ASC,ASC,ASC,DESC', id: '@id_route'},
198   - {
199   - list: {
200   - method: 'GET',
201   - params: {
202   - page: 0
203   - }
204   - },
205   - get: {
206   - method: 'GET'
207   - },
208   - save: {
209   - method: 'POST'
210   - },
211   - delete: {
212   - method: 'DELETE'
213   - }
214   - }
215   - );
216   -}]);
217   -
218   -// 车辆配置service
219   -angular.module('ScheduleApp').factory('BusConfigService_g', ['$resource', function($resource) {
220   - return {
221   - rest : $resource(
222   - '/cci/:id',
223   - {order: 'xl.id,cl.insideCode,isCancel', direction: 'ASC', id: '@id_route'},
224   - {
225   - list: {
226   - method: 'GET',
227   - params: {
228   - page: 0
229   - }
230   - },
231   - get: {
232   - method: 'GET'
233   - },
234   - save: {
235   - method: 'POST'
236   - }
237   - }
238   - )
239   - };
240   -}]);
241   -
242   -// 人员配置service
243   -angular.module('ScheduleApp').factory('EmployeeConfigService_g', ['$resource', function($resource) {
244   - return {
245   - rest : $resource(
246   - '/eci/:id',
247   - {order: 'xl.id,isCancel,dbbmFormula', direction: 'ASC', id: '@id_route'},
248   - {
249   - list: {
250   - method: 'GET',
251   - params: {
252   - page: 0
253   - }
254   - },
255   - get: {
256   - method: 'GET'
257   - },
258   - save: {
259   - method: 'POST'
260   - },
261   - delete: {
262   - method: 'DELETE'
263   - }
264   - }
265   - ),
266   - validate: $resource( // TODO:
267   - '/personnel/validate/:type',
268   - {},
269   - {
270   - jobCode: {
271   - method: 'GET'
272   - }
273   - }
274   - )
275   - };
276   -}]);
277   -
278   -// 路牌管理service
279   -angular.module('ScheduleApp').factory('GuideboardManageService_g', ['$resource', function($resource) {
280   - return {
281   - rest: $resource(
282   - '/gic/:id',
283   - {order: 'createDate', direction: 'DESC', id: '@id_route'},
284   - {
285   - list: {
286   - method: 'GET',
287   - params: {
288   - page: 0
289   - }
290   - },
291   - get: {
292   - method: 'GET'
293   - },
294   - save: {
295   - method: 'POST'
296   - }
297   - }
298   - )
299   - };
300   -}]);
301   -
302   -// 排班管理service
303   -angular.module('ScheduleApp').factory('ScheduleRuleManageService_g', ['$resource', function($resource) {
304   - return {
305   - rest: $resource(
306   - '/sr1fc/:id',
307   - {order: 'createDate', direction: 'DESC', id: '@id_route'},
308   - {
309   - list: {
310   - method: 'GET',
311   - params: {
312   - page: 0
313   - }
314   - },
315   - get: {
316   - method: 'GET'
317   - },
318   - save: {
319   - method: 'POST'
320   - },
321   - delete: {
322   - method: 'DELETE'
323   - }
324   - }
325   - )
326   - };
327   -}]);
328   -
329   -// 套跑管理service
330   -angular.module('ScheduleApp').factory('rerunManageService_g', ['$resource', function($resource) {
331   - return {
332   - rest: $resource(
333   - 'rms/:id',
334   - {order: 'rerunXl.id,isCancel', direction: 'ASC', id: '@id_route'},
335   - {
336   - list: {
337   - method: 'GET',
338   - params: {
339   - page: 0
340   - }
341   - },
342   - get: {
343   - method: 'GET'
344   - },
345   - save: {
346   - method: 'POST'
347   - },
348   - delete: {
349   - method: 'DELETE'
350   - }
351   - }
352   - )
353   - };
354   -}]);
355   -
356   -// 时刻表管理service
357   -angular.module('ScheduleApp').factory('TimeTableManageService_g', ['$resource', function($resource) {
358   - return {
359   - rest: $resource(
360   - '/tic/:id',
361   - {order: 'xl,isCancel,isEnableDisTemplate,qyrq', direction: 'DESC,ASC,DESC,DESC', id: '@id'},
362   - {
363   - list: {
364   - method: 'GET',
365   - params: {
366   - page: 0
367   - }
368   - }
369   - }
370   - )
371   - };
372   -}]);
373   -// 时刻表明细管理service
374   -angular.module('ScheduleApp').factory('TimeTableDetailManageService_g', ['$resource', function($resource) {
375   - return {
376   - rest: $resource(
377   - '/tidc/:id',
378   - {order: 'createDate', direction: 'DESC', id: '@id_route'},
379   - {
380   - get: {
381   - method: 'GET'
382   - },
383   - save: {
384   - method: 'POST'
385   - }
386   - }
387   - ),
388   - import: $resource(
389   - '/tidc/importfile',
390   - {},
391   - {
392   - do: {
393   - method: 'POST',
394   - headers: {
395   - 'Content-Type': 'application/x-www-form-urlencoded'
396   - },
397   - transformRequest: function(obj) {
398   - var str = [];
399   - for (var p in obj) {
400   - str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
401   - }
402   - return str.join("&");
403   - }
404   - }
405   - }
406   - ),
407   - edit: $resource(
408   - '/tidc/edit/:xlid/:ttid',
409   - {},
410   - {
411   - list: {
412   - method: 'GET'
413   - }
414   - }
415   - ),
416   - bcdetails: $resource(
417   - '/tidc/bcdetail',
418   - {},
419   - {
420   - list: {
421   - method: 'GET',
422   - isArray: true
423   - }
424   - }
425   - ),
426   - dataTools: $resource(
427   - '/tidc/:type',
428   - {},
429   - {
430   - dataExport: {
431   - method: 'GET',
432   - responseType: "arraybuffer",
433   - params: {
434   - type: "dataExportExt"
435   - },
436   - transformResponse: function(data, headers){
437   - return {data : data};
438   - }
439   - }
440   - }
441   - )
442   -
443   - // TODO:导入数据
444   - };
445   -}]);
446   -
447   -
448   -
449   -// 排班计划管理service
450   -angular.module('ScheduleApp').factory('SchedulePlanManageService_g', ['$resource', function($resource) {
451   - return {
452   - rest : $resource(
453   - '/spc/:id',
454   - {order: 'xl.id,createDate', direction: 'DESC,DESC', id: '@id_route'},
455   - {
456   - list: {
457   - method: 'GET',
458   - params: {
459   - page: 0
460   - }
461   - },
462   - get: {
463   - method: 'GET'
464   - },
465   - save: {
466   - method: 'POST'
467   - },
468   - delete: {
469   - method: 'DELETE'
470   - }
471   - }
472   - ),
473   - tommorw: $resource(
474   - '/spc/tommorw',
475   - {},
476   - {
477   - list: {
478   - method: 'GET'
479   - }
480   - }
481   - )
482   - };
483   -}]);
484   -
485   -// 排班计划明细管理service
486   -angular.module('ScheduleApp').factory('SchedulePlanInfoManageService_g', ['$resource', function($resource) {
487   - return {
488   - rest : $resource(
489   - '/spic/:id',
490   - {order: 'scheduleDate,lp,fcno', direction: 'ASC,ASC,ASC', id: '@id_route'},
491   - {
492   - list: {
493   - method: 'GET',
494   - params: {
495   - page: 0
496   - }
497   - },
498   - get: {
499   - method: 'GET'
500   - },
501   - save: {
502   - method: 'POST'
503   - }
504   - }
505   - ),
506   - groupinfo : $resource(
507   - '/spic/groupinfos/:xlid/:sdate',
508   - {},
509   - {
510   - list: {
511   - method: 'GET',
512   - isArray: true
513   - }
514   - }
515   - ),
516   - updateGroupInfo : $resource(
517   - '/spic/groupinfos/update',
518   - {},
519   - {
520   - update: {
521   - method: 'POST'
522   - }
523   - }
524   - )
525   - };
526   -}]);
527   -
528   -// 线路运营统计service
529   -angular.module('ScheduleApp').factory('BusLineInfoStatService_g', ['$resource', function($resource) {
530   - return $resource(
531   - '/bic/:id',
532   - {order: 'createDate', direction: 'DESC', id: '@id_route'}, // TODO:以后需要根据属性对象的属性查询
533   - {
534   - list: {
535   - method: 'GET',
536   - params: {
537   - page: 0
538   - }
539   - }
540   - }
541   - );
542   -}]);
543   -
544   -
545   -
546   -
547   -/**
548   - * saSelect2指令,根据属性值,动态载入数据,然后支持拼音搜索,点击右边的按钮清除选择并重新载入数据。
549   - * 1、compile阶段使用的属性如下:
550   - * required:用于和表单验证连接,指定成required="true"才有效。
551   - * 2、link阶段使用的属性如下
552   - * model:关联的模型对象
553   - * name:表单验证时需要的名字
554   - * type:关联的那种数据值(xl/cl/ry)-> 对应线路信息/车辆信息/人员信息,后面有的继续加
555   - * modelcolname1:关联的模型字段名字1(一般应该是编码字段)
556   - * modelcolname2:关联的模型字段名字2(一般应该是名字字段)
557   - * datacolname1;内部数据对应的字段名字1(与模型字段1对应)
558   - * datacolname2:内部数据对应的字段名字2(与模型字段2对应)
559   - * showcolname:下拉框显示的内部数据字段名(注意:不是模型数据字段名),TODO:以后考虑放动态表达式,并在compile阶段使用
560   - * placeholder:select placeholder字符串描述
561   - *
562   - * $$pyFilter,内部的filter指令,结合简拼音进行拼音过滤。
563   - * $$SearchInfoService_g,内部使用的数据服务
564   - */
565   -// saSelect2指令使用的内部信service
566   -angular.module('ScheduleApp').factory('$$SearchInfoService_g', ['$resource', function($resource) {
567   - return {
568   - xl: $resource(
569   - '/line/:type',
570   - {order: 'name', direction: 'ASC'},
571   - {
572   - list: {
573   - method: 'GET',
574   - isArray: true
575   - }
576   - }
577   - ),
578   - xlinfo: $resource(
579   - '/lineInformation/:type',
580   - {order: 'line.name', direction: 'ASC'},
581   - {
582   - list: {
583   - method: 'GET',
584   - isArray: true
585   - }
586   - }
587   - ),
588   - zd: $resource(
589   - '/stationroute/stations',
590   - {order: 'stationCode', direction: 'ASC'},
591   - {
592   - list: {
593   - method: 'GET',
594   - isArray: true
595   - }
596   - }
597   - ),
598   - tcc: $resource(
599   - '/carpark/:type',
600   - {order: 'parkCode', direction: 'ASC'},
601   - {
602   - list: {
603   - method: 'GET',
604   - isArray: true
605   - }
606   - }
607   - ),
608   - ry: $resource(
609   - '/personnel/:type',
610   - {order: 'personnelName', direction: 'ASC'},
611   - {
612   - list: {
613   - method: 'GET',
614   - isArray: true
615   - }
616   - }
617   - ),
618   - cl: $resource(
619   - '/cars/:type',
620   - {order: "insideCode", direction: 'ASC'},
621   - {
622   - list: {
623   - method: 'GET',
624   - isArray: true
625   - }
626   - }
627   - ),
628   - ttInfo: $resource(
629   - '/tic/:type',
630   - {order: "name", direction: 'ASC'},
631   - {
632   - list: {
633   - method: 'GET',
634   - isArray: true
635   - }
636   - }
637   - ),
638   - lpInfo: $resource(
639   - '/gic/ttlpnames',
640   - {order: "lpName", direction: 'ASC'},
641   - {
642   - list: {
643   - method: 'GET',
644   - isArray: true
645   - }
646   - }
647   - ),
648   - lpInfo2: $resource(
649   - '/gic/:type',
650   - {order: "lpName", direction: 'ASC'},
651   - {
652   - list: {
653   - method: 'GET',
654   - isArray: true
655   - }
656   - }
657   - ),
658   - cci: $resource(
659   - '/cci/cars',
660   - {},
661   - {
662   - list: {
663   - method: 'GET',
664   - isArray: true
665   - }
666   - }
667   -
668   - ),
669   - cci2: $resource(
670   - '/cci/:type',
671   - {},
672   - {
673   - list: {
674   - method: 'GET',
675   - isArray: true
676   - }
677   - }
678   - ),
679   - cci3: $resource(
680   - '/cci/cars2',
681   - {},
682   - {
683   - list: {
684   - method: 'GET',
685   - isArray: true
686   - }
687   - }
688   -
689   - ),
690   - eci: $resource(
691   - '/eci/jsy',
692   - {},
693   - {
694   - list: {
695   - method: 'GET',
696   - isArray: true
697   - }
698   - }
699   - ),
700   - eci2: $resource(
701   - '/eci/spy',
702   - {},
703   - {
704   - list: {
705   - method: 'GET',
706   - isArray: true
707   - }
708   - }
709   - ),
710   - eci3: $resource(
711   - '/eci/:type',
712   - {},
713   - {
714   - list: {
715   - method: 'GET',
716   - isArray: true
717   - }
718   - }
719   - ),
720   -
721   -
722   - validate: { // remoteValidation指令用到的resource
723   - cl1: { // 车辆自编号不能重复验证
724   - template: {'insideCode_eq': '-1'}, // 查询参数模版
725   - remote: $resource( // $resource封装对象
726   - '/cars/validate/equale',
727   - {},
728   - {
729   - do: {
730   - method: 'GET'
731   - }
732   - }
733   - )
734   - },
735   - cde1: { // 车辆设备启用日期验证
736   - template: {'qyrq': 0, 'xl': 1, 'cl': 1}, // 日期毫秒
737   - remote: $resource( // $resource封装对象
738   - '/cde//validate/qyrq',
739   - {},
740   - {
741   - do: {
742   - method: 'GET'
743   - }
744   - }
745   - )
746   - },
747   - ttc1: { // 时刻表名字验证
748   - template: {'xl.id_eq': -1, 'name_eq': 'ddd'},
749   - remote: $resource( // $resource封装对象
750   - '/tic/validate/equale',
751   - {},
752   - {
753   - do: {
754   - method: 'GET'
755   - }
756   - }
757   - )
758   - },
759   - sheet: { // 时刻表sheet工作区验证
760   - template: {'filename': '', 'sheetname': '', 'lineid': -1, 'linename': ''},
761   - remote: $resource( // $resource封装对象
762   - '/tidc/validate/sheet',
763   - {},
764   - {
765   - do: {
766   - method: 'POST',
767   - headers: {
768   - 'Content-Type': 'application/x-www-form-urlencoded'
769   - },
770   - transformRequest: function(obj) {
771   - var str = [];
772   - for (var p in obj) {
773   - str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
774   - }
775   - return str.join("&");
776   - }
777   - }
778   - }
779   - )
780   - },
781   - sheetli: { // 时刻表线路标准验证
782   - template: {'lineinfoid': -1},
783   - remote: $resource( // $resource封装对象
784   - '/tidc/validate/lineinfo',
785   - {},
786   - {
787   - do: {
788   - method: 'GET'
789   - }
790   - }
791   - )
792   - }
793   - }
794   -
795   - //validate: $resource(
796   - // '/cars/validate/:type',
797   - // {},
798   - // {
799   - // insideCode: {
800   - // method: 'GET'
801   - // }
802   - // }
803   - //)
804   -
805   -
806   -
807   - }
808   -}]);
809   -
810   -
811   -
  1 +//所有模块service配置
  2 +// 车辆信息service
  3 +angular.module('ScheduleApp').factory('BusInfoManageService_g', ['$resource', function($resource) {
  4 + return {
  5 + rest: $resource(
  6 + '/cars/:id',
  7 + {order: 'carCode', direction: 'ASC', id: '@id_route'},
  8 + {
  9 + list: {
  10 + method: 'GET',
  11 + params: {
  12 + page: 0
  13 + }
  14 + },
  15 + get: {
  16 + method: 'GET'
  17 + },
  18 + save: {
  19 + method: 'POST'
  20 + }
  21 + }
  22 + ),
  23 + import: $resource(
  24 + '/cars/importfile',
  25 + {},
  26 + {
  27 + do: {
  28 + method: 'POST',
  29 + headers: {
  30 + 'Content-Type': 'application/x-www-form-urlencoded'
  31 + },
  32 + transformRequest: function(obj) {
  33 + var str = [];
  34 + for (var p in obj) {
  35 + str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
  36 + }
  37 + return str.join("&");
  38 + }
  39 + }
  40 + }
  41 + ),
  42 + validate: $resource(
  43 + '/cars/validate/:type',
  44 + {},
  45 + {
  46 + insideCode: {
  47 + method: 'GET'
  48 + }
  49 + }
  50 + ),
  51 + dataTools: $resource(
  52 + '/cars/:type',
  53 + {},
  54 + {
  55 + dataExport: {
  56 + method: 'GET',
  57 + responseType: "arraybuffer",
  58 + params: {
  59 + type: "dataExport"
  60 + },
  61 + transformResponse: function(data, headers){
  62 + return {data : data};
  63 + }
  64 + }
  65 + }
  66 + )
  67 + };
  68 +}]);
  69 +// 车辆设备信息service
  70 +angular.module('ScheduleApp').factory('DeviceInfoManageService_g', ['$resource', function($resource) {
  71 + return $resource(
  72 + '/cde/:id',
  73 + {order: 'xl,isCancel,cl,qyrq', direction: 'ASC,ASC,ASC,DESC', id: '@id_route'},
  74 + {
  75 + list: {
  76 + method: 'GET',
  77 + params: {
  78 + page: 0
  79 + }
  80 + },
  81 + get: {
  82 + method: 'GET'
  83 + },
  84 + save: {
  85 + method: 'POST'
  86 + },
  87 + delete: {
  88 + method: 'DELETE'
  89 + }
  90 + }
  91 + );
  92 +}]);
  93 +// 人员信息service
  94 +angular.module('ScheduleApp').factory('EmployeeInfoManageService_g', ['$resource', function($resource) {
  95 + return {
  96 + rest : $resource(
  97 + '/personnel/:id',
  98 + {order: 'jobCode', direction: 'ASC', id: '@id_route'},
  99 + {
  100 + list: {
  101 + method: 'GET',
  102 + params: {
  103 + page: 0
  104 + }
  105 + },
  106 + get: {
  107 + method: 'GET'
  108 + },
  109 + save: {
  110 + method: 'POST'
  111 + }
  112 + }
  113 + ),
  114 + validate: $resource(
  115 + '/personnel/validate/:type',
  116 + {},
  117 + {
  118 + jobCode: {
  119 + method: 'GET'
  120 + }
  121 + }
  122 + ),
  123 + dataTools: $resource(
  124 + '/personnel/:type',
  125 + {},
  126 + {
  127 + dataExport: {
  128 + method: 'GET',
  129 + responseType: "arraybuffer",
  130 + params: {
  131 + type: "dataExport"
  132 + },
  133 + transformResponse: function(data, headers){
  134 + return {data : data};
  135 + }
  136 + }
  137 + }
  138 + )
  139 + };
  140 +}]);
  141 +
  142 +// 车辆配置service
  143 +angular.module('ScheduleApp').factory('BusConfigService_g', ['$resource', function($resource) {
  144 + return {
  145 + rest : $resource(
  146 + '/cci/:id',
  147 + {order: 'xl.id,cl.insideCode,isCancel', direction: 'ASC', id: '@id_route'},
  148 + {
  149 + list: {
  150 + method: 'GET',
  151 + params: {
  152 + page: 0
  153 + }
  154 + },
  155 + get: {
  156 + method: 'GET'
  157 + },
  158 + save: {
  159 + method: 'POST'
  160 + }
  161 + }
  162 + )
  163 + };
  164 +}]);
  165 +// 线路运营统计service
  166 +angular.module('ScheduleApp').factory('BusLineInfoStatService_g', ['$resource', function($resource) {
  167 + return $resource(
  168 + '/bic/:id',
  169 + {order: 'createDate', direction: 'DESC', id: '@id_route'}, // TODO:以后需要根据属性对象的属性查询
  170 + {
  171 + list: {
  172 + method: 'GET',
  173 + params: {
  174 + page: 0
  175 + }
  176 + }
  177 + }
  178 + );
  179 +}]);
  180 +
  181 +// 人员配置service
  182 +angular.module('ScheduleApp').factory('EmployeeConfigService_g', ['$resource', function($resource) {
  183 + return {
  184 + rest : $resource(
  185 + '/eci/:id',
  186 + {order: 'xl.id,isCancel,dbbmFormula', direction: 'ASC', id: '@id_route'},
  187 + {
  188 + list: {
  189 + method: 'GET',
  190 + params: {
  191 + page: 0
  192 + }
  193 + },
  194 + get: {
  195 + method: 'GET'
  196 + },
  197 + save: {
  198 + method: 'POST'
  199 + },
  200 + delete: {
  201 + method: 'DELETE'
  202 + }
  203 + }
  204 + ),
  205 + validate: $resource( // TODO:
  206 + '/personnel/validate/:type',
  207 + {},
  208 + {
  209 + jobCode: {
  210 + method: 'GET'
  211 + }
  212 + }
  213 + )
  214 + };
  215 +}]);
  216 +// 路牌管理service
  217 +angular.module('ScheduleApp').factory('GuideboardManageService_g', ['$resource', function($resource) {
  218 + return {
  219 + rest: $resource(
  220 + '/gic/:id',
  221 + {order: 'xl,isCancel', direction: 'DESC,ASC', id: '@id_route'},
  222 + {
  223 + list: {
  224 + method: 'GET',
  225 + params: {
  226 + page: 0
  227 + }
  228 + },
  229 + get: {
  230 + method: 'GET',
  231 + transformResponse: function(rs) {
  232 + var dst = angular.fromJson(rs);
  233 + if (dst.status == 'SUCCESS') {
  234 + return dst.data;
  235 + } else {
  236 + return dst;
  237 + }
  238 + }
  239 + },
  240 + save: {
  241 + method: 'POST'
  242 + }
  243 + // 内部还有默认的方法delete
  244 + }
  245 + )
  246 + };
  247 +}]);
  248 +// 套跑管理service
  249 +angular.module('ScheduleApp').factory('rerunManageService_g', ['$resource', function($resource) {
  250 + return {
  251 + rest: $resource(
  252 + 'rms/:id',
  253 + {order: 'rerunXl.id,isCancel', direction: 'ASC', id: '@id_route'},
  254 + {
  255 + list: {
  256 + method: 'GET',
  257 + params: {
  258 + page: 0
  259 + }
  260 + },
  261 + get: {
  262 + method: 'GET'
  263 + },
  264 + save: {
  265 + method: 'POST'
  266 + },
  267 + delete: {
  268 + method: 'DELETE'
  269 + }
  270 + }
  271 + )
  272 + };
  273 +}]);
  274 +// 排班计划管理service
  275 +angular.module('ScheduleApp').factory('SchedulePlanManageService_g', ['$resource', function($resource) {
  276 + return {
  277 + rest : $resource(
  278 + '/spc/:id',
  279 + {order: 'xl.id,createDate', direction: 'DESC,DESC', id: '@id_route'},
  280 + {
  281 + list: {
  282 + method: 'GET',
  283 + params: {
  284 + page: 0
  285 + }
  286 + },
  287 + get: {
  288 + method: 'GET'
  289 + },
  290 + save: {
  291 + method: 'POST'
  292 + },
  293 + delete: {
  294 + method: 'DELETE'
  295 + }
  296 + }
  297 + ),
  298 + tommorw: $resource(
  299 + '/spc/tommorw',
  300 + {},
  301 + {
  302 + list: {
  303 + method: 'GET'
  304 + }
  305 + }
  306 + )
  307 + };
  308 +}]);
  309 +
  310 +// 排班计划明细管理service
  311 +angular.module('ScheduleApp').factory('SchedulePlanInfoManageService_g', ['$resource', function($resource) {
  312 + return {
  313 + rest : $resource(
  314 + '/spic/:id',
  315 + {order: 'scheduleDate,lp,fcno', direction: 'ASC,ASC,ASC', id: '@id_route'},
  316 + {
  317 + list: {
  318 + method: 'GET',
  319 + params: {
  320 + page: 0
  321 + }
  322 + },
  323 + get: {
  324 + method: 'GET'
  325 + },
  326 + save: {
  327 + method: 'POST'
  328 + }
  329 + }
  330 + ),
  331 + groupinfo : $resource(
  332 + '/spic/groupinfos/:xlid/:sdate',
  333 + {},
  334 + {
  335 + list: {
  336 + method: 'GET',
  337 + isArray: true
  338 + }
  339 + }
  340 + ),
  341 + updateGroupInfo : $resource(
  342 + '/spic/groupinfos/update',
  343 + {},
  344 + {
  345 + update: {
  346 + method: 'POST'
  347 + }
  348 + }
  349 + )
  350 + };
  351 +}]);
  352 +// 排班管理service
  353 +angular.module('ScheduleApp').factory('ScheduleRuleManageService_g', ['$resource', function($resource) {
  354 + return {
  355 + rest: $resource(
  356 + '/sr1fc/:id',
  357 + {order: 'createDate', direction: 'DESC', id: '@id_route'},
  358 + {
  359 + list: {
  360 + method: 'GET',
  361 + params: {
  362 + page: 0
  363 + }
  364 + },
  365 + get: {
  366 + method: 'GET'
  367 + },
  368 + save: {
  369 + method: 'POST'
  370 + },
  371 + delete: {
  372 + method: 'DELETE'
  373 + }
  374 + }
  375 + )
  376 + };
  377 +}]);
  378 +
  379 +// 时刻表管理service
  380 +angular.module('ScheduleApp').factory('TimeTableManageService_g', ['$resource', function($resource) {
  381 + return {
  382 + rest: $resource(
  383 + '/tic/:id',
  384 + {order: 'xl,isCancel,isEnableDisTemplate,qyrq', direction: 'DESC,ASC,DESC,DESC', id: '@id'},
  385 + {
  386 + list: {
  387 + method: 'GET',
  388 + params: {
  389 + page: 0
  390 + }
  391 + }
  392 + }
  393 + )
  394 + };
  395 +}]);
  396 +
  397 +// 时刻表明细管理service
  398 +angular.module('ScheduleApp').factory('TimeTableDetailManageService_g', ['$resource', function($resource) {
  399 + return {
  400 + rest: $resource(
  401 + '/tidc/:id',
  402 + {order: 'createDate', direction: 'DESC', id: '@id_route'},
  403 + {
  404 + get: {
  405 + method: 'GET'
  406 + },
  407 + save: {
  408 + method: 'POST'
  409 + }
  410 + }
  411 + ),
  412 + import: $resource(
  413 + '/tidc/importfile',
  414 + {},
  415 + {
  416 + do: {
  417 + method: 'POST',
  418 + headers: {
  419 + 'Content-Type': 'application/x-www-form-urlencoded'
  420 + },
  421 + transformRequest: function(obj) {
  422 + var str = [];
  423 + for (var p in obj) {
  424 + str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
  425 + }
  426 + return str.join("&");
  427 + }
  428 + }
  429 + }
  430 + ),
  431 + edit: $resource(
  432 + '/tidc/edit/:xlid/:ttid',
  433 + {},
  434 + {
  435 + list: {
  436 + method: 'GET'
  437 + }
  438 + }
  439 + ),
  440 + bcdetails: $resource(
  441 + '/tidc/bcdetail',
  442 + {},
  443 + {
  444 + list: {
  445 + method: 'GET',
  446 + isArray: true
  447 + }
  448 + }
  449 + ),
  450 + dataTools: $resource(
  451 + '/tidc/:type',
  452 + {},
  453 + {
  454 + dataExport: {
  455 + method: 'GET',
  456 + responseType: "arraybuffer",
  457 + params: {
  458 + type: "dataExportExt"
  459 + },
  460 + transformResponse: function(data, headers){
  461 + return {data : data};
  462 + }
  463 + }
  464 + }
  465 + )
  466 +
  467 + // TODO:导入数据
  468 + };
  469 +}]);
  470 +// 项目通用的全局service服务,供不同的controller使用,自定义指令不使用
  471 +
  472 +// 文件下载服务
  473 +angular.module('ScheduleApp').factory('FileDownload_g', function() {
  474 + return {
  475 + downloadFile: function (data, mimeType, fileName) {
  476 + var success = false;
  477 + var blob = new Blob([data], { type: mimeType });
  478 + try {
  479 + if (navigator.msSaveBlob)
  480 + navigator.msSaveBlob(blob, fileName);
  481 + else {
  482 + // Try using other saveBlob implementations, if available
  483 + var saveBlob = navigator.webkitSaveBlob || navigator.mozSaveBlob || navigator.saveBlob;
  484 + if (saveBlob === undefined) throw "Not supported";
  485 + saveBlob(blob, fileName);
  486 + }
  487 + success = true;
  488 + } catch (ex) {
  489 + console.log("saveBlob method failed with the following exception:");
  490 + console.log(ex);
  491 + }
  492 +
  493 + if (!success) {
  494 + // Get the blob url creator
  495 + var urlCreator = window.URL || window.webkitURL || window.mozURL || window.msURL;
  496 + if (urlCreator) {
  497 + // Try to use a download link
  498 + var link = document.createElement('a');
  499 + if ('download' in link) {
  500 + // Try to simulate a click
  501 + try {
  502 + // Prepare a blob URL
  503 + var url = urlCreator.createObjectURL(blob);
  504 + link.setAttribute('href', url);
  505 +
  506 + // Set the download attribute (Supported in Chrome 14+ / Firefox 20+)
  507 + link.setAttribute("download", fileName);
  508 +
  509 + // Simulate clicking the download link
  510 + var event = document.createEvent('MouseEvents');
  511 + event.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
  512 + link.dispatchEvent(event);
  513 + success = true;
  514 +
  515 + } catch (ex) {
  516 + console.log("Download link method with simulated click failed with the following exception:");
  517 + console.log(ex);
  518 + }
  519 + }
  520 +
  521 + if (!success) {
  522 + // Fallback to window.location method
  523 + try {
  524 + // Prepare a blob URL
  525 + // Use application/octet-stream when using window.location to force download
  526 + var url = urlCreator.createObjectURL(blob);
  527 + window.location = url;
  528 + console.log("Download link method with window.location succeeded");
  529 + success = true;
  530 + } catch (ex) {
  531 + console.log("Download link method with window.location failed with the following exception:");
  532 + console.log(ex);
  533 + }
  534 + }
  535 + }
  536 + }
  537 +
  538 + if (!success) {
  539 + // Fallback to window.open method
  540 + console.log("No methods worked for saving the arraybuffer, using last resort window.open");
  541 + window.open("", '_blank', '');
  542 + }
  543 + }
  544 + };
  545 +});
  546 +
  547 +
  548 +/**
  549 + * saSelect2指令,根据属性值,动态载入数据,然后支持拼音搜索,点击右边的按钮清除选择并重新载入数据。
  550 + * 1、compile阶段使用的属性如下:
  551 + * required:用于和表单验证连接,指定成required="true"才有效。
  552 + * 2、link阶段使用的属性如下
  553 + * model:关联的模型对象
  554 + * name:表单验证时需要的名字
  555 + * type:关联的那种数据值(xl/cl/ry)-> 对应线路信息/车辆信息/人员信息,后面有的继续加
  556 + * modelcolname1:关联的模型字段名字1(一般应该是编码字段)
  557 + * modelcolname2:关联的模型字段名字2(一般应该是名字字段)
  558 + * datacolname1;内部数据对应的字段名字1(与模型字段1对应)
  559 + * datacolname2:内部数据对应的字段名字2(与模型字段2对应)
  560 + * showcolname:下拉框显示的内部数据字段名(注意:不是模型数据字段名),TODO:以后考虑放动态表达式,并在compile阶段使用
  561 + * placeholder:select placeholder字符串描述
  562 + *
  563 + * $$pyFilter,内部的filter指令,结合简拼音进行拼音过滤。
  564 + * $$SearchInfoService_g,内部使用的数据服务
  565 + */
  566 +// saSelect2指令使用的内部信service
  567 +angular.module('ScheduleApp').factory('$$SearchInfoService_g', ['$resource', function($resource) {
  568 + return {
  569 + xl: $resource(
  570 + '/line/:type',
  571 + {order: 'name', direction: 'ASC'},
  572 + {
  573 + list: {
  574 + method: 'GET',
  575 + isArray: true
  576 + }
  577 + }
  578 + ),
  579 + xlinfo: $resource(
  580 + '/lineInformation/:type',
  581 + {order: 'line.name', direction: 'ASC'},
  582 + {
  583 + list: {
  584 + method: 'GET',
  585 + isArray: true
  586 + }
  587 + }
  588 + ),
  589 + zd: $resource(
  590 + '/stationroute/stations',
  591 + {order: 'stationCode', direction: 'ASC'},
  592 + {
  593 + list: {
  594 + method: 'GET',
  595 + isArray: true
  596 + }
  597 + }
  598 + ),
  599 + tcc: $resource(
  600 + '/carpark/:type',
  601 + {order: 'parkCode', direction: 'ASC'},
  602 + {
  603 + list: {
  604 + method: 'GET',
  605 + isArray: true
  606 + }
  607 + }
  608 + ),
  609 + ry: $resource(
  610 + '/personnel/:type',
  611 + {order: 'personnelName', direction: 'ASC'},
  612 + {
  613 + list: {
  614 + method: 'GET',
  615 + isArray: true
  616 + }
  617 + }
  618 + ),
  619 + cl: $resource(
  620 + '/cars/:type',
  621 + {order: "insideCode", direction: 'ASC'},
  622 + {
  623 + list: {
  624 + method: 'GET',
  625 + isArray: true
  626 + }
  627 + }
  628 + ),
  629 + ttInfo: $resource(
  630 + '/tic/:type',
  631 + {order: "name", direction: 'ASC'},
  632 + {
  633 + list: {
  634 + method: 'GET',
  635 + isArray: true
  636 + }
  637 + }
  638 + ),
  639 + lpInfo: $resource(
  640 + '/gic/ttlpnames',
  641 + {order: "lpName", direction: 'ASC'},
  642 + {
  643 + list: {
  644 + method: 'GET',
  645 + isArray: true
  646 + }
  647 + }
  648 + ),
  649 + lpInfo2: $resource(
  650 + '/gic/:type',
  651 + {order: "lpName", direction: 'ASC'},
  652 + {
  653 + list: {
  654 + method: 'GET',
  655 + isArray: true
  656 + }
  657 + }
  658 + ),
  659 + cci: $resource(
  660 + '/cci/cars',
  661 + {},
  662 + {
  663 + list: {
  664 + method: 'GET',
  665 + isArray: true
  666 + }
  667 + }
  668 +
  669 + ),
  670 + cci2: $resource(
  671 + '/cci/:type',
  672 + {},
  673 + {
  674 + list: {
  675 + method: 'GET',
  676 + isArray: true
  677 + }
  678 + }
  679 + ),
  680 + cci3: $resource(
  681 + '/cci/cars2',
  682 + {},
  683 + {
  684 + list: {
  685 + method: 'GET',
  686 + isArray: true
  687 + }
  688 + }
  689 +
  690 + ),
  691 + eci: $resource(
  692 + '/eci/jsy',
  693 + {},
  694 + {
  695 + list: {
  696 + method: 'GET',
  697 + isArray: true
  698 + }
  699 + }
  700 + ),
  701 + eci2: $resource(
  702 + '/eci/spy',
  703 + {},
  704 + {
  705 + list: {
  706 + method: 'GET',
  707 + isArray: true
  708 + }
  709 + }
  710 + ),
  711 + eci3: $resource(
  712 + '/eci/:type',
  713 + {},
  714 + {
  715 + list: {
  716 + method: 'GET',
  717 + isArray: true
  718 + }
  719 + }
  720 + ),
  721 +
  722 +
  723 + validate: { // remoteValidation指令用到的resource
  724 + gbv1: { // 路牌序号验证
  725 + template: {'xl.id_eq': -1, 'lpNo_eq': 'ddd'},
  726 + remote: $resource(
  727 + '/gic/validate1',
  728 + {},
  729 + {
  730 + do: {
  731 + method: 'GET'
  732 + }
  733 + }
  734 + )
  735 + },
  736 + gbv2: { // 路牌名称验证
  737 + template: {'xl.id_eq': -1, 'lpName_eq': 'ddd'},
  738 + remote: $resource(
  739 + '/gic/validate2',
  740 + {},
  741 + {
  742 + do: {
  743 + method: 'GET'
  744 + }
  745 + }
  746 + )
  747 + },
  748 +
  749 + cl1: { // 车辆自编号不能重复验证
  750 + template: {'insideCode_eq': '-1'}, // 查询参数模版
  751 + remote: $resource( // $resource封装对象
  752 + '/cars/validate/equale',
  753 + {},
  754 + {
  755 + do: {
  756 + method: 'GET'
  757 + }
  758 + }
  759 + )
  760 + },
  761 + cde1: { // 车辆设备启用日期验证
  762 + template: {'qyrq': 0, 'xl': 1, 'cl': 1}, // 日期毫秒
  763 + remote: $resource( // $resource封装对象
  764 + '/cde//validate/qyrq',
  765 + {},
  766 + {
  767 + do: {
  768 + method: 'GET'
  769 + }
  770 + }
  771 + )
  772 + },
  773 + ttc1: { // 时刻表名字验证
  774 + template: {'xl.id_eq': -1, 'name_eq': 'ddd'},
  775 + remote: $resource( // $resource封装对象
  776 + '/tic/validate/equale',
  777 + {},
  778 + {
  779 + do: {
  780 + method: 'GET'
  781 + }
  782 + }
  783 + )
  784 + },
  785 + sheet: { // 时刻表sheet工作区验证
  786 + template: {'filename': '', 'sheetname': '', 'lineid': -1, 'linename': ''},
  787 + remote: $resource( // $resource封装对象
  788 + '/tidc/validate/sheet',
  789 + {},
  790 + {
  791 + do: {
  792 + method: 'POST',
  793 + headers: {
  794 + 'Content-Type': 'application/x-www-form-urlencoded'
  795 + },
  796 + transformRequest: function(obj) {
  797 + var str = [];
  798 + for (var p in obj) {
  799 + str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
  800 + }
  801 + return str.join("&");
  802 + }
  803 + }
  804 + }
  805 + )
  806 + },
  807 + sheetli: { // 时刻表线路标准验证
  808 + template: {'lineinfoid': -1},
  809 + remote: $resource( // $resource封装对象
  810 + '/tidc/validate/lineinfo',
  811 + {},
  812 + {
  813 + do: {
  814 + method: 'GET'
  815 + }
  816 + }
  817 + )
  818 + }
  819 + }
  820 +
  821 + //validate: $resource(
  822 + // '/cars/validate/:type',
  823 + // {},
  824 + // {
  825 + // insideCode: {
  826 + // method: 'GET'
  827 + // }
  828 + // }
  829 + //)
  830 +
  831 +
  832 +
  833 + }
  834 +}]);
  835 +
  836 +
  837 +
... ...