Commit c8b77c0c8cfb9ee9c3156f626ce6aaa148301fd7

Authored by 徐烜
2 parents 305072ec 58a35adb

Merge branch 'PSM-16' into qingpu

src/main/java/com/bsth/entity/schedule/CarConfigInfo.java
... ... @@ -53,6 +53,10 @@ public class CarConfigInfo implements Serializable {
53 53 @Column(nullable = false)
54 54 private int isSwitch;
55 55  
  56 + /** 是否删除(标记) */
  57 + @Column(nullable = false)
  58 + private Boolean isCancel = false;
  59 +
56 60 /** 创建人 */
57 61 @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST)
58 62 private SysUser createBy;
... ... @@ -170,4 +174,12 @@ public class CarConfigInfo implements Serializable {
170 174 public void setUpdateDate(Date updateDate) {
171 175 this.updateDate = updateDate;
172 176 }
  177 +
  178 + public Boolean getIsCancel() {
  179 + return isCancel;
  180 + }
  181 +
  182 + public void setIsCancel(Boolean isCancel) {
  183 + this.isCancel = isCancel;
  184 + }
173 185 }
... ...
src/main/java/com/bsth/service/schedule/CarConfigInfoServiceImpl.java
1 1 package com.bsth.service.schedule;
2 2  
  3 +import com.bsth.common.ResponseCode;
3 4 import com.bsth.entity.schedule.CarConfigInfo;
  5 +import com.bsth.entity.schedule.rule.ScheduleRule1Flat;
  6 +import com.bsth.repository.schedule.CarConfigInfoRepository;
4 7 import com.bsth.service.impl.BaseServiceImpl;
  8 +import org.springframework.beans.factory.annotation.Autowired;
5 9 import org.springframework.stereotype.Service;
6 10  
  11 +import javax.transaction.Transactional;
  12 +import java.util.*;
  13 +
7 14 /**
8 15 * Created by xu on 16/5/9.
9 16 */
10 17 @Service
11 18 public class CarConfigInfoServiceImpl extends BaseServiceImpl<CarConfigInfo, Long> implements CarConfigInfoService {
  19 + @Autowired
  20 + private CarConfigInfoRepository carConfigInfoRepository;
  21 + @Autowired
  22 + private ScheduleRule1FlatService scheduleRule1FlatService;
  23 +
  24 + @Override
  25 + @Transactional
  26 + public Map<String, Object> delete(Long aLong) {
  27 + // 获取待作废的车辆配置
  28 + CarConfigInfo carConfigInfo = carConfigInfoRepository.findOne(aLong);
  29 + // 查询有无规则使用过此车辆配置
  30 + Map<String, Object> param = new HashMap<>();
  31 + param.put("carConfigInfo.id_eq", carConfigInfo.getId());
  32 + Iterator<ScheduleRule1Flat> scheduleRule1FlatIterator =
  33 + scheduleRule1FlatService.list(param).iterator();
  34 + boolean isExist = false;
  35 + while (scheduleRule1FlatIterator.hasNext()) {
  36 + ScheduleRule1Flat scheduleRule1Flat = scheduleRule1FlatIterator.next();
  37 + if (scheduleRule1Flat.getCarConfigInfo().getId().equals(carConfigInfo.getId())) {
  38 + isExist = true;
  39 + break;
  40 + }
  41 + }
  42 +
  43 + Map<String, Object> map = new HashMap<>();
  44 +
  45 + if (isExist) {
  46 + throw new RuntimeException("车辆配置已被规则使用,不能删除,请先修改规则!");
  47 + } else {
  48 + carConfigInfo.setIsCancel(true);
  49 + map.put("status", ResponseCode.SUCCESS);
  50 + }
  51 +
  52 + return map;
  53 +
  54 + }
12 55 }
... ...
src/main/resources/static/pages/scheduleApp/module/common/prj-common-globalservice.js
... ... @@ -198,7 +198,7 @@ angular.module(&#39;ScheduleApp&#39;).factory(&#39;BusConfigService_g&#39;, [&#39;$resource&#39;, functi
198 198 return {
199 199 rest : $resource(
200 200 '/cci/:id',
201   - {order: 'createDate', direction: 'ASC', id: '@id_route'},
  201 + {order: 'xl.id,cl.insideCode,isCancel', direction: 'ASC', id: '@id_route'},
202 202 {
203 203 list: {
204 204 method: 'GET',
... ...
src/main/resources/static/pages/scheduleApp/module/core/busConfig/busConfig.js
... ... @@ -56,6 +56,14 @@ angular.module(&#39;ScheduleApp&#39;).factory(&#39;BusConfigService&#39;, [&#39;BusConfigService_g&#39;,
56 56 */
57 57 saveDetail: function(obj) {
58 58 return service.rest.save(obj).$promise;
  59 + },
  60 + /**
  61 + * 删除信息。
  62 + * @param id 主键id
  63 + * @returns {*|Function|promise|n}
  64 + */
  65 + deleteDetail: function(id) {
  66 + return service.rest.delete({id: id}).$promise;
59 67 }
60 68 };
61 69  
... ... @@ -184,6 +192,74 @@ angular.module(&#39;ScheduleApp&#39;).controller(&#39;BusConfigListCtrl&#39;, [&#39;BusConfigService
184 192 self.pageChanaged();
185 193 };
186 194  
  195 + // 删除时刻表
  196 + self.deleteEci = function(id) {
  197 + // TODO:
  198 + busConfigService.deleteDetail(id).then(
  199 + function(result) {
  200 + if (result.message) { // 暂时这样做,之后全局拦截
  201 + alert("失败:" + result.message);
  202 + } else {
  203 + alert("作废成功!");
  204 +
  205 + busConfigService.getPage().then(
  206 + function(result) {
  207 + self.pageInfo.totalItems = result.totalElements;
  208 + self.pageInfo.currentPage = result.number + 1;
  209 + self.pageInfo.infos = result.content;
  210 + busConfigService.setCurrentPageNo(result.number + 1);
  211 + },
  212 + function(result) {
  213 + alert("出错啦!");
  214 + }
  215 + );
  216 + }
  217 +
  218 + },
  219 + function(result) {
  220 + alert("出错啦!" + result);
  221 + }
  222 + );
  223 + };
  224 +
  225 + // 撤销修改
  226 + self.redoDeleteEci = function(id) {
  227 + busConfigService.getDetail(id).then(
  228 + function(result) {
  229 + result.isCancel = 'false';
  230 + busConfigService.saveDetail(result).then(
  231 + function(result) {
  232 + if (result.message) { // 暂时这样做,之后全局拦截
  233 + alert("失败:" + result.message);
  234 + } else {
  235 + alert("撤销成功!");
  236 +
  237 + busConfigService.getPage().then(
  238 + function(result) {
  239 + self.pageInfo.totalItems = result.totalElements;
  240 + self.pageInfo.currentPage = result.number + 1;
  241 + self.pageInfo.infos = result.content;
  242 + busConfigService.setCurrentPageNo(result.number + 1);
  243 + },
  244 + function(result) {
  245 + alert("出错啦!");
  246 + }
  247 + );
  248 + }
  249 + },
  250 + function(result) {
  251 + // TODO:弹出框方式以后改
  252 + alert("出错啦!");
  253 + }
  254 + );
  255 + },
  256 + function(result) {
  257 + // TODO:弹出框方式以后改
  258 + alert("出错啦!");
  259 + }
  260 + );
  261 + };
  262 +
187 263 }]);
188 264  
189 265 angular.module('ScheduleApp').controller('BusConfigFormCtrl', ['BusConfigService', '$stateParams', '$state', '$scope', function(busConfigService, $stateParams, $state, $scope) {
... ...
src/main/resources/static/pages/scheduleApp/module/core/busConfig/list.html
... ... @@ -27,13 +27,13 @@
27 27 </sa-Select3>
28 28 </div>
29 29 </td>
  30 + <td>
  31 + <input type="text" class="form-control form-filter input-sm" ng-model="ctrl.searchCondition()['cl.insideCode_like']" placeholder="输入内部编号..."/>
  32 + </td>
30 33 <td></td>
31 34 <td></td>
32 35 <td></td>
33 36 <td>
34   - <input type="text" class="form-control form-filter input-sm" ng-model="ctrl.searchCondition().tcd_like"/>
35   - </td>
36   - <td>
37 37 <button class="btn btn-sm green btn-outline filter-submit margin-bottom"
38 38 ng-click="ctrl.pageChanaged()">
39 39 <i class="fa fa-search"></i> 搜索</button>
... ... @@ -47,7 +47,7 @@
47 47  
48 48 </thead>
49 49 <tbody>
50   - <tr ng-repeat="info in ctrl.pageInfo.infos" class="odd gradeX">
  50 + <tr ng-repeat="info in ctrl.pageInfo.infos" ng-class="{odd: true, gradeX: true, danger: info.isCancel}">
51 51 <td>
52 52 <span ng-bind="$index + 1"></span>
53 53 </td>
... ... @@ -70,7 +70,9 @@
70 70 <!--<a href="details.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 详细 </a>-->
71 71 <!--<a href="edit.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 修改 </a>-->
72 72 <a ui-sref="busConfig_detail({id: info.id})" class="btn default blue-stripe btn-sm"> 详细 </a>
73   - <a ui-sref="busConfig_edit({id: info.id})" class="btn default blue-stripe btn-sm"> 修改 </a>
  73 + <a ui-sref="busConfig_edit({id: info.id})" class="btn default blue-stripe btn-sm" ng-if="info.isCancel == '0'"> 修改 </a>
  74 + <a ng-click="ctrl.deleteEci(info.id)" class="btn default blue-stripe btn-sm" ng-if="info.isCancel == '0'"> 作废 </a>
  75 + <a ng-click="ctrl.redoDeleteEci(info.id)" class="btn default blue-stripe btn-sm" ng-if="info.isCancel == '1'"> 撤销 </a>
74 76 </td>
75 77 </tr>
76 78 </tbody>
... ...
src/main/resources/static/pages/scheduleApp/module/core/scheduleRuleManage/form.html
... ... @@ -72,7 +72,7 @@
72 72 icnames="cl.insideCode"
73 73 datatype="cci2"
74 74 dataassociate="true"
75   - dataparam="{{ {'xl.id_eq': ctrl.scheduleRuleManageForSave.xl.id} | json }}"
  75 + dataparam="{{ {'xl.id_eq': ctrl.scheduleRuleManageForSave.xl.id, 'isCancel_eq': false} | json }}"
76 76 mlp="true"
77 77 required >
78 78 </sa-Select3>
... ...