Commit a7bc09a8ff89fc86cb780f988f5a59080b8f4404

Authored by 徐烜
1 parent 0732ca21

update

src/main/java/com/bsth/controller/schedule/TTInfoController.java
... ... @@ -7,6 +7,7 @@ import com.bsth.repository.schedule.TTInfoRepository;
7 7 import com.bsth.service.schedule.utils.DataToolsProperties;
8 8 import org.springframework.beans.factory.annotation.Autowired;
9 9 import org.springframework.boot.context.properties.EnableConfigurationProperties;
  10 +import org.springframework.data.domain.Page;
10 11 import org.springframework.web.bind.annotation.*;
11 12  
12 13 import java.util.Map;
... ... @@ -59,4 +60,13 @@ public class TTInfoController extends BaseController<TTInfo, Long> {
59 60 // 一般比较自编号是否重复
60 61 return baseService.validateEquale(map);
61 62 }
  63 +
  64 + @Override
  65 + public Page<TTInfo> list(@RequestParam Map<String, Object> map, @RequestParam(defaultValue = "0") int page, @RequestParam(defaultValue = "10") int size, @RequestParam(defaultValue = "id") String order, @RequestParam(defaultValue = "DESC") String direction) {
  66 + // 如果有isCancel键值,将其值变成boolean
  67 + if (map.get("isCancel_eq") != null)
  68 + map.put("isCancel_eq", new Boolean(map.get("isCancel_eq").toString()));
  69 +
  70 + return super.list(map, page, size, order, direction);
  71 + }
62 72 }
... ...
src/main/java/com/bsth/entity/schedule/TTInfo.java
... ... @@ -41,6 +41,9 @@ public class TTInfo {
41 41 /** 是否启用调度模版 */
42 42 @Column(nullable = false)
43 43 private Boolean isEnableDisTemplate;
  44 + /** 是否删除(标记) */
  45 + @Column(nullable = false)
  46 + private Boolean isCancel = false;
44 47  
45 48 /** 模版类型(TODO:时刻表,间隔式,这个以后用枚举还是字典再议,现在先用文字) */
46 49 private String templateType;
... ... @@ -193,4 +196,11 @@ public class TTInfo {
193 196 this.updateDate = updateDate;
194 197 }
195 198  
  199 + public Boolean getIsCancel() {
  200 + return isCancel;
  201 + }
  202 +
  203 + public void setIsCancel(Boolean isCancel) {
  204 + this.isCancel = isCancel;
  205 + }
196 206 }
... ...
src/main/java/com/bsth/service/schedule/TTInfoServiceImpl.java
1 1 package com.bsth.service.schedule;
2 2  
  3 +import com.bsth.common.ResponseCode;
3 4 import com.bsth.entity.schedule.TTInfo;
4   -import com.bsth.repository.schedule.TTInfoDetailRepository;
  5 +import com.bsth.repository.schedule.TTInfoRepository;
5 6 import com.bsth.service.impl.BaseServiceImpl;
6 7 import org.springframework.beans.factory.annotation.Autowired;
  8 +import org.springframework.dao.DataIntegrityViolationException;
7 9 import org.springframework.stereotype.Service;
8 10  
9 11 import javax.transaction.Transactional;
  12 +import java.util.HashMap;
10 13 import java.util.Map;
11 14  
12 15 /**
... ... @@ -16,11 +19,21 @@ import java.util.Map;
16 19 @Transactional
17 20 public class TTInfoServiceImpl extends BaseServiceImpl<TTInfo, Long> implements TTInfoService {
18 21 @Autowired
19   - private TTInfoDetailRepository ttInfoDetailRepository;
  22 + private TTInfoRepository ttInfoRepository;
20 23  
21 24 @Override
22 25 public Map<String, Object> delete(Long aLong) {
23   - ttInfoDetailRepository.deleteByTtinfoId(aLong);
24   - return super.delete(aLong);
  26 + TTInfo ttInfo = ttInfoRepository.findOne(aLong);
  27 + ttInfo.setIsCancel(true);
  28 +
  29 + Map<String, Object> map = new HashMap<>();
  30 + try{
  31 + ttInfoRepository.save(ttInfo);
  32 + map.put("status", ResponseCode.SUCCESS);
  33 + }catch(DataIntegrityViolationException de){
  34 + map.put("status", ResponseCode.ERROR);
  35 + map.put("msg", "“完整性约束”校验失败,请检查要删除的对象是否存在外键约束");
  36 + }
  37 + return map;
25 38 }
26 39 }
... ...
src/main/java/com/bsth/service/schedule/rules/strategy/IStrategyImpl.java
... ... @@ -37,6 +37,7 @@ public class IStrategyImpl implements IStrategy {
37 37 // 查询参数
38 38 Map<String, Object> param = new HashMap<>();
39 39 param.put("xl.id_eq", xlId); // 线路id
  40 + param.put("isCancel_eq", false); // 没有作废
40 41 param.put("isEnableDisTemplate_eq", true); // 是否启用
41 42 Iterable<TTInfo> ttInfoIterable = ttInfoService.list(param);
42 43 Iterator<TTInfo> ttInfoIterator = ttInfoIterable.iterator();
... ...
src/main/resources/static/pages/scheduleApp/module/common/prj-common-globalservice.js
... ... @@ -201,7 +201,8 @@ angular.module(&#39;ScheduleApp&#39;).factory(&#39;TimeTableManageService_g&#39;, [&#39;$resource&#39;,
201 201 list: {
202 202 method: 'GET',
203 203 params: {
204   - page: 0
  204 + page: 0,
  205 + isCancel_eq: 'false'
205 206 }
206 207 },
207 208 get: {
... ...
src/main/resources/static/pages/scheduleApp/module/core/timeTableManage/list.html
... ... @@ -70,14 +70,14 @@
70 70 class="btn default blue-stripe btn-sm"> 编辑 </a>
71 71 <a ng-click="ctrl.importData($index)" class="btn default blue-stripe btn-sm"> 导入 </a>
72 72 <a href="javascript:" class="btn default blue-stripe btn-sm"> 导出 </a>
73   - <a href="javascript:" class="btn default blue-stripe btn-sm"> 模版 </a>
  73 + <a href="javascript:" class="btn default blue-stripe btn-sm"> 清空 </a>
74 74 </td>
75 75 <td>
76 76 <!--<a href="details.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 详细 </a>-->
77 77 <!--<a href="edit.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 修改 </a>-->
78 78 <a ui-sref="timeTableManage_detail({id: info.id})" class="btn default blue-stripe btn-sm"> 详细 </a>
79 79 <a ui-sref="timeTableManage_edit({id: info.id})" class="btn default blue-stripe btn-sm"> 修改 </a>
80   - <a ng-click="ctrl.deleteTTinfo(info.id)" class="btn default blue-stripe btn-sm"> 删除 </a>
  80 + <a ng-click="ctrl.deleteTTinfo(info.id)" class="btn default blue-stripe btn-sm"> 作废 </a>
81 81 </td>
82 82 </tr>
83 83 </tbody>
... ...
src/main/resources/static/pages/scheduleApp/module/core/timeTableManage/timeTableManage.js
... ... @@ -195,14 +195,14 @@ angular.module(&#39;ScheduleApp&#39;).controller(&#39;TimeTableManageListCtrl&#39;, [&#39;TimeTableM
195 195 // TODO:
196 196 timeTableManageService.deleteDetail(id).then(
197 197 function(result) {
198   - alert("删除成功!");
  198 + alert("作废成功!");
199 199  
200 200 timeTableManageService.getPage().then(
201 201 function(result) {
202 202 self.pageInfo.totalItems = result.totalElements;
203 203 self.pageInfo.currentPage = result.number + 1;
204 204 self.pageInfo.infos = result.content;
205   - schedulePlanManageService.setCurrentPageNo(result.number + 1);
  205 + timeTableManageService.setCurrentPageNo(result.number + 1);
206 206 },
207 207 function(result) {
208 208 alert("出错啦!");
... ...