Commit a7bc09a8ff89fc86cb780f988f5a59080b8f4404
1 parent
0732ca21
update
Showing
7 changed files
with
44 additions
and
9 deletions
src/main/java/com/bsth/controller/schedule/TTInfoController.java
| @@ -7,6 +7,7 @@ import com.bsth.repository.schedule.TTInfoRepository; | @@ -7,6 +7,7 @@ import com.bsth.repository.schedule.TTInfoRepository; | ||
| 7 | import com.bsth.service.schedule.utils.DataToolsProperties; | 7 | import com.bsth.service.schedule.utils.DataToolsProperties; |
| 8 | import org.springframework.beans.factory.annotation.Autowired; | 8 | import org.springframework.beans.factory.annotation.Autowired; |
| 9 | import org.springframework.boot.context.properties.EnableConfigurationProperties; | 9 | import org.springframework.boot.context.properties.EnableConfigurationProperties; |
| 10 | +import org.springframework.data.domain.Page; | ||
| 10 | import org.springframework.web.bind.annotation.*; | 11 | import org.springframework.web.bind.annotation.*; |
| 11 | 12 | ||
| 12 | import java.util.Map; | 13 | import java.util.Map; |
| @@ -59,4 +60,13 @@ public class TTInfoController extends BaseController<TTInfo, Long> { | @@ -59,4 +60,13 @@ public class TTInfoController extends BaseController<TTInfo, Long> { | ||
| 59 | // 一般比较自编号是否重复 | 60 | // 一般比较自编号是否重复 |
| 60 | return baseService.validateEquale(map); | 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,6 +41,9 @@ public class TTInfo { | ||
| 41 | /** 是否启用调度模版 */ | 41 | /** 是否启用调度模版 */ |
| 42 | @Column(nullable = false) | 42 | @Column(nullable = false) |
| 43 | private Boolean isEnableDisTemplate; | 43 | private Boolean isEnableDisTemplate; |
| 44 | + /** 是否删除(标记) */ | ||
| 45 | + @Column(nullable = false) | ||
| 46 | + private Boolean isCancel = false; | ||
| 44 | 47 | ||
| 45 | /** 模版类型(TODO:时刻表,间隔式,这个以后用枚举还是字典再议,现在先用文字) */ | 48 | /** 模版类型(TODO:时刻表,间隔式,这个以后用枚举还是字典再议,现在先用文字) */ |
| 46 | private String templateType; | 49 | private String templateType; |
| @@ -193,4 +196,11 @@ public class TTInfo { | @@ -193,4 +196,11 @@ public class TTInfo { | ||
| 193 | this.updateDate = updateDate; | 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 | package com.bsth.service.schedule; | 1 | package com.bsth.service.schedule; |
| 2 | 2 | ||
| 3 | +import com.bsth.common.ResponseCode; | ||
| 3 | import com.bsth.entity.schedule.TTInfo; | 4 | import com.bsth.entity.schedule.TTInfo; |
| 4 | -import com.bsth.repository.schedule.TTInfoDetailRepository; | 5 | +import com.bsth.repository.schedule.TTInfoRepository; |
| 5 | import com.bsth.service.impl.BaseServiceImpl; | 6 | import com.bsth.service.impl.BaseServiceImpl; |
| 6 | import org.springframework.beans.factory.annotation.Autowired; | 7 | import org.springframework.beans.factory.annotation.Autowired; |
| 8 | +import org.springframework.dao.DataIntegrityViolationException; | ||
| 7 | import org.springframework.stereotype.Service; | 9 | import org.springframework.stereotype.Service; |
| 8 | 10 | ||
| 9 | import javax.transaction.Transactional; | 11 | import javax.transaction.Transactional; |
| 12 | +import java.util.HashMap; | ||
| 10 | import java.util.Map; | 13 | import java.util.Map; |
| 11 | 14 | ||
| 12 | /** | 15 | /** |
| @@ -16,11 +19,21 @@ import java.util.Map; | @@ -16,11 +19,21 @@ import java.util.Map; | ||
| 16 | @Transactional | 19 | @Transactional |
| 17 | public class TTInfoServiceImpl extends BaseServiceImpl<TTInfo, Long> implements TTInfoService { | 20 | public class TTInfoServiceImpl extends BaseServiceImpl<TTInfo, Long> implements TTInfoService { |
| 18 | @Autowired | 21 | @Autowired |
| 19 | - private TTInfoDetailRepository ttInfoDetailRepository; | 22 | + private TTInfoRepository ttInfoRepository; |
| 20 | 23 | ||
| 21 | @Override | 24 | @Override |
| 22 | public Map<String, Object> delete(Long aLong) { | 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,6 +37,7 @@ public class IStrategyImpl implements IStrategy { | ||
| 37 | // 查询参数 | 37 | // 查询参数 |
| 38 | Map<String, Object> param = new HashMap<>(); | 38 | Map<String, Object> param = new HashMap<>(); |
| 39 | param.put("xl.id_eq", xlId); // 线路id | 39 | param.put("xl.id_eq", xlId); // 线路id |
| 40 | + param.put("isCancel_eq", false); // 没有作废 | ||
| 40 | param.put("isEnableDisTemplate_eq", true); // 是否启用 | 41 | param.put("isEnableDisTemplate_eq", true); // 是否启用 |
| 41 | Iterable<TTInfo> ttInfoIterable = ttInfoService.list(param); | 42 | Iterable<TTInfo> ttInfoIterable = ttInfoService.list(param); |
| 42 | Iterator<TTInfo> ttInfoIterator = ttInfoIterable.iterator(); | 43 | Iterator<TTInfo> ttInfoIterator = ttInfoIterable.iterator(); |
src/main/resources/static/pages/scheduleApp/module/common/prj-common-globalservice.js
| @@ -201,7 +201,8 @@ angular.module('ScheduleApp').factory('TimeTableManageService_g', ['$resource', | @@ -201,7 +201,8 @@ angular.module('ScheduleApp').factory('TimeTableManageService_g', ['$resource', | ||
| 201 | list: { | 201 | list: { |
| 202 | method: 'GET', | 202 | method: 'GET', |
| 203 | params: { | 203 | params: { |
| 204 | - page: 0 | 204 | + page: 0, |
| 205 | + isCancel_eq: 'false' | ||
| 205 | } | 206 | } |
| 206 | }, | 207 | }, |
| 207 | get: { | 208 | get: { |
src/main/resources/static/pages/scheduleApp/module/core/timeTableManage/list.html
| @@ -70,14 +70,14 @@ | @@ -70,14 +70,14 @@ | ||
| 70 | class="btn default blue-stripe btn-sm"> 编辑 </a> | 70 | class="btn default blue-stripe btn-sm"> 编辑 </a> |
| 71 | <a ng-click="ctrl.importData($index)" class="btn default blue-stripe btn-sm"> 导入 </a> | 71 | <a ng-click="ctrl.importData($index)" class="btn default blue-stripe btn-sm"> 导入 </a> |
| 72 | <a href="javascript:" class="btn default blue-stripe btn-sm"> 导出 </a> | 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 | </td> | 74 | </td> |
| 75 | <td> | 75 | <td> |
| 76 | <!--<a href="details.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 详细 </a>--> | 76 | <!--<a href="details.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 详细 </a>--> |
| 77 | <!--<a href="edit.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 修改 </a>--> | 77 | <!--<a href="edit.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 修改 </a>--> |
| 78 | <a ui-sref="timeTableManage_detail({id: info.id})" class="btn default blue-stripe btn-sm"> 详细 </a> | 78 | <a ui-sref="timeTableManage_detail({id: info.id})" class="btn default blue-stripe btn-sm"> 详细 </a> |
| 79 | <a ui-sref="timeTableManage_edit({id: info.id})" class="btn default blue-stripe btn-sm"> 修改 </a> | 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 | </td> | 81 | </td> |
| 82 | </tr> | 82 | </tr> |
| 83 | </tbody> | 83 | </tbody> |
src/main/resources/static/pages/scheduleApp/module/core/timeTableManage/timeTableManage.js
| @@ -195,14 +195,14 @@ angular.module('ScheduleApp').controller('TimeTableManageListCtrl', ['TimeTableM | @@ -195,14 +195,14 @@ angular.module('ScheduleApp').controller('TimeTableManageListCtrl', ['TimeTableM | ||
| 195 | // TODO: | 195 | // TODO: |
| 196 | timeTableManageService.deleteDetail(id).then( | 196 | timeTableManageService.deleteDetail(id).then( |
| 197 | function(result) { | 197 | function(result) { |
| 198 | - alert("删除成功!"); | 198 | + alert("作废成功!"); |
| 199 | 199 | ||
| 200 | timeTableManageService.getPage().then( | 200 | timeTableManageService.getPage().then( |
| 201 | function(result) { | 201 | function(result) { |
| 202 | self.pageInfo.totalItems = result.totalElements; | 202 | self.pageInfo.totalItems = result.totalElements; |
| 203 | self.pageInfo.currentPage = result.number + 1; | 203 | self.pageInfo.currentPage = result.number + 1; |
| 204 | self.pageInfo.infos = result.content; | 204 | self.pageInfo.infos = result.content; |
| 205 | - schedulePlanManageService.setCurrentPageNo(result.number + 1); | 205 | + timeTableManageService.setCurrentPageNo(result.number + 1); |
| 206 | }, | 206 | }, |
| 207 | function(result) { | 207 | function(result) { |
| 208 | alert("出错啦!"); | 208 | alert("出错啦!"); |