Commit 305072ec7cb7bec0ff1dc1188cd135dad65a65a1

Authored by 徐烜
2 parents 464b5cd1 8e5d681a

PSM-15

src/main/java/com/bsth/entity/schedule/EmployeeConfigInfo.java
... ... @@ -49,6 +49,9 @@ public class EmployeeConfigInfo {
49 49 @Formula(" dbbm + 0 ")
50 50 private Integer dbbmFormula;
51 51  
  52 + /** 是否删除(标记) */
  53 + @Column(nullable = false)
  54 + private Boolean isCancel = false;
52 55  
53 56 /** 创建人 */
54 57 @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST)
... ... @@ -96,6 +99,22 @@ public class EmployeeConfigInfo {
96 99 this.jsy = jsy;
97 100 }
98 101  
  102 + public Personnel getSpy() {
  103 + return spy;
  104 + }
  105 +
  106 + public void setSpy(Personnel spy) {
  107 + this.spy = spy;
  108 + }
  109 +
  110 + public String getDbbm() {
  111 + return dbbm;
  112 + }
  113 +
  114 + public void setDbbm(String dbbm) {
  115 + this.dbbm = dbbm;
  116 + }
  117 +
99 118 public Integer getDbbmFormula() {
100 119 return dbbmFormula;
101 120 }
... ... @@ -104,6 +123,14 @@ public class EmployeeConfigInfo {
104 123 this.dbbmFormula = dbbmFormula;
105 124 }
106 125  
  126 + public Boolean getIsCancel() {
  127 + return isCancel;
  128 + }
  129 +
  130 + public void setIsCancel(Boolean isCancel) {
  131 + this.isCancel = isCancel;
  132 + }
  133 +
107 134 public SysUser getCreateBy() {
108 135 return createBy;
109 136 }
... ... @@ -120,22 +147,6 @@ public class EmployeeConfigInfo {
120 147 this.updateBy = updateBy;
121 148 }
122 149  
123   - public Personnel getSpy() {
124   - return spy;
125   - }
126   -
127   - public void setSpy(Personnel spy) {
128   - this.spy = spy;
129   - }
130   -
131   - public String getDbbm() {
132   - return dbbm;
133   - }
134   -
135   - public void setDbbm(String dbbm) {
136   - this.dbbm = dbbm;
137   - }
138   -
139 150 public Date getCreateDate() {
140 151 return createDate;
141 152 }
... ...
src/main/java/com/bsth/entity/search/CustomerSpecs.java
1 1 package com.bsth.entity.search;
2 2  
3   -import java.lang.reflect.Method;
4   -import java.util.ArrayList;
5   -import java.util.List;
6   -import java.util.Map;
7   -import java.util.Set;
8   -import java.util.TreeSet;
9   -
10   -import javax.persistence.criteria.CriteriaBuilder;
11   -import javax.persistence.criteria.CriteriaQuery;
12   -import javax.persistence.criteria.Path;
13   -import javax.persistence.criteria.Predicate;
14   -import javax.persistence.criteria.Root;
15   -
  3 +import com.bsth.entity.search.exception.UnrecognizableSearchSymbolException;
16 4 import org.apache.commons.lang3.StringUtils;
17 5 import org.slf4j.Logger;
18 6 import org.slf4j.LoggerFactory;
19 7 import org.springframework.data.jpa.domain.Specification;
20 8  
21   -import com.bsth.entity.search.exception.UnrecognizableSearchSymbolException;
  9 +import javax.persistence.criteria.*;
  10 +import java.lang.reflect.Method;
  11 +import java.util.*;
22 12  
23 13 /**
24 14 *
... ... @@ -74,6 +64,14 @@ public class CustomerSpecs<T> implements Specification<T> {
74 64 // 值为空的不参与查询
75 65 if (value == null || (value instanceof String && value.equals("")))
76 66 continue;
  67 +
  68 + // 如果是布尔值,转换,限定 'true','false' 字符串
  69 + if ("true".equals(value)) {
  70 + value = Boolean.TRUE;
  71 + }
  72 + if ("false".equals(value)) {
  73 + value = Boolean.FALSE;
  74 + }
77 75  
78 76 try {
79 77 if(!eSet.contains(searchs[1]))
... ...
src/main/java/com/bsth/service/schedule/EmployeeConfigInfoServiceImpl.java
1 1 package com.bsth.service.schedule;
2 2  
  3 +import com.bsth.common.ResponseCode;
  4 +import com.bsth.entity.Line;
3 5 import com.bsth.entity.schedule.EmployeeConfigInfo;
  6 +import com.bsth.entity.schedule.rule.ScheduleRule1Flat;
  7 +import com.bsth.repository.schedule.EmployeeConfigInfoRepository;
4 8 import com.bsth.service.impl.BaseServiceImpl;
  9 +import org.springframework.beans.factory.annotation.Autowired;
5 10 import org.springframework.stereotype.Service;
6 11  
  12 +import javax.transaction.Transactional;
  13 +import java.util.*;
  14 +
7 15 /**
8 16 * Created by xu on 16/5/10.
9 17 */
10 18 @Service
11 19 public class EmployeeConfigInfoServiceImpl extends BaseServiceImpl<EmployeeConfigInfo, Long> implements EmployeeConfigInfoService {
  20 + @Autowired
  21 + private EmployeeConfigInfoRepository employeeConfigInfoRepository;
  22 + @Autowired
  23 + private ScheduleRule1FlatService scheduleRule1FlatService;
  24 +
  25 +
  26 + @Override
  27 + @Transactional
  28 + public Map<String, Object> delete(Long aLong) {
  29 + // 获取待作废的人员配置
  30 + EmployeeConfigInfo employeeConfigInfo = employeeConfigInfoRepository.findOne(aLong);
  31 + // 获取线路
  32 + Line xl = employeeConfigInfo.getXl();
  33 + // 查找线路的规则,比较人员配置信息
  34 + Map<String, Object> param = new HashMap<>();
  35 + param.put("xl.id_eq", xl.getId());
  36 + Iterator<ScheduleRule1Flat> employeeConfigInfoIterator = scheduleRule1FlatService.list(param).iterator();
  37 + List<String> ryConfigIds = new ArrayList<>();
  38 + while (employeeConfigInfoIterator.hasNext()) {
  39 + ScheduleRule1Flat scheduleRule1Flat = employeeConfigInfoIterator.next();
  40 + ryConfigIds.addAll(Arrays.asList(scheduleRule1Flat.getRyConfigIds().split(",")));
  41 + }
  42 +
  43 + Map<String, Object> map = new HashMap<>();
  44 +
  45 + if (ryConfigIds.contains(employeeConfigInfo.getId().toString())) {
  46 + throw new RuntimeException("人员配置已被规则使用,不能删除,请先修改规则!");
  47 + } else {
  48 + employeeConfigInfo.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-directive.js
... ... @@ -2362,7 +2362,7 @@ angular.module(&#39;ScheduleApp&#39;).directive(&#39;saEmployeegroup&#39;, [
2362 2362 console.log("xlidvalue=" + value);
2363 2363  
2364 2364 employeeConfigService_g.rest.list(
2365   - {"xl.id_eq": value, size: 100},
  2365 + {"xl.id_eq": value, "isCancel_eq" : false, size: 100},
2366 2366 function(result) {
2367 2367 // 获取值了
2368 2368 console.log("人员配置获取了");
... ...
src/main/resources/static/pages/scheduleApp/module/common/prj-common-globalservice.js
... ... @@ -222,7 +222,7 @@ angular.module(&#39;ScheduleApp&#39;).factory(&#39;EmployeeConfigService_g&#39;, [&#39;$resource&#39;, f
222 222 return {
223 223 rest : $resource(
224 224 '/eci/:id',
225   - {order: 'createDate', direction: 'ASC', id: '@id_route'},
  225 + {order: 'xl.id,isCancel,dbbmFormula', direction: 'ASC', id: '@id_route'},
226 226 {
227 227 list: {
228 228 method: 'GET',
... ... @@ -235,6 +235,9 @@ angular.module(&#39;ScheduleApp&#39;).factory(&#39;EmployeeConfigService_g&#39;, [&#39;$resource&#39;, f
235 235 },
236 236 save: {
237 237 method: 'POST'
  238 + },
  239 + delete: {
  240 + method: 'DELETE'
238 241 }
239 242 }
240 243 ),
... ...
src/main/resources/static/pages/scheduleApp/module/core/employeeConfig/employeeConfig.js
... ... @@ -57,6 +57,14 @@ angular.module(&#39;ScheduleApp&#39;).factory(&#39;EmployeeConfigService&#39;, [&#39;EmployeeConfigS
57 57 */
58 58 saveDetail: function(obj) {
59 59 return service.rest.save(obj).$promise;
  60 + },
  61 + /**
  62 + * 删除信息。
  63 + * @param id 主键id
  64 + * @returns {*|Function|promise|n}
  65 + */
  66 + deleteDetail: function(id) {
  67 + return service.rest.delete({id: id}).$promise;
60 68 }
61 69 };
62 70 }]);
... ... @@ -183,6 +191,75 @@ angular.module(&#39;ScheduleApp&#39;).controller(&#39;EmployeeConfigListCtrl&#39;, [&#39;EmployeeCon
183 191 self.pageInfo.currentPage = 1;
184 192 self.pageChanaged();
185 193 };
  194 +
  195 + // 删除时刻表
  196 + self.deleteEci = function(id) {
  197 + // TODO:
  198 + employeeConfigService.deleteDetail(id).then(
  199 + function(result) {
  200 + if (result.message) { // 暂时这样做,之后全局拦截
  201 + alert("失败:" + result.message);
  202 + } else {
  203 + alert("作废成功!");
  204 +
  205 + employeeConfigService.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 + employeeConfigService.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 + employeeConfigService.getDetail(id).then(
  228 + function(result) {
  229 + result.isCancel = 'false';
  230 + employeeConfigService.saveDetail(result).then(
  231 + function(result) {
  232 + if (result.message) { // 暂时这样做,之后全局拦截
  233 + alert("失败:" + result.message);
  234 + } else {
  235 + alert("撤销成功!");
  236 +
  237 + employeeConfigService.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 + employeeConfigService.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 +
186 263 }]);
187 264  
188 265 angular.module('ScheduleApp').controller('EmployeeConfigFormCtrl', ['EmployeeConfigService', '$stateParams', '$state', function(employeeConfigService, $stateParams, $state) {
... ...
src/main/resources/static/pages/scheduleApp/module/core/employeeConfig/list.html
... ... @@ -31,24 +31,18 @@
31 31 </div>
32 32 </td>
33 33 <td></td>
34   - <td></td>
35 34 <td>
36   - <div>
37   - <sa-Select3 model="ctrl.searchCondition()"
38   - name="ry"
39   - placeholder="请输拼音..."
40   - dcvalue="{{ctrl.searchCondition()['jsy.id_eq']}}"
41   - dcname="jsy.id_eq"
42   - icname="id"
43   - icnames="personnelName"
44   - datatype="ry"
45   - dataassociate="true"
46   - dataparam="{{ {'companyCode_eq': ctrl.searchCondition()['xl.company_eq']} | json }}" >
47   - </sa-Select3>
48   - </div>
  35 + <input type="text" class="form-control form-filter input-sm" ng-model="ctrl.searchCondition()['jsy.jobCode_like']" placeholder="输入工号..."/>
  36 + </td>
  37 + <td>
  38 + <input type="text" class="form-control form-filter input-sm" ng-model="ctrl.searchCondition()['jsy.personnelName_like']" placeholder="输入姓名..."/>
  39 + </td>
  40 + <td>
  41 + <input type="text" class="form-control form-filter input-sm" ng-model="ctrl.searchCondition()['spy.jobCode_like']" placeholder="输入工号..."/>
  42 + </td>
  43 + <td>
  44 + <input type="text" class="form-control form-filter input-sm" ng-model="ctrl.searchCondition()['spy.personnelName_like']" placeholder="输入姓名..."/>
49 45 </td>
50   - <td></td>
51   - <td></td>
52 46 <td>
53 47 <button class="btn btn-sm green btn-outline filter-submit margin-bottom"
54 48 ng-click="ctrl.pageChanaged()">
... ... @@ -63,7 +57,7 @@
63 57  
64 58 </thead>
65 59 <tbody>
66   - <tr ng-repeat="info in ctrl.pageInfo.infos" class="odd gradeX">
  60 + <tr ng-repeat="info in ctrl.pageInfo.infos" ng-class="{odd: true, gradeX: true, danger: info.isCancel}">
67 61 <td>
68 62 <span ng-bind="$index + 1"></span>
69 63 </td>
... ... @@ -89,7 +83,9 @@
89 83 <!--<a href="details.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 详细 </a>-->
90 84 <!--<a href="edit.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 修改 </a>-->
91 85 <a ui-sref="employeeConfig_detail({id: info.id})" class="btn default blue-stripe btn-sm"> 详细 </a>
92   - <a ui-sref="employeeConfig_edit({id: info.id})" class="btn default blue-stripe btn-sm"> 修改 </a>
  86 + <a ui-sref="employeeConfig_edit({id: info.id})" class="btn default blue-stripe btn-sm" ng-if="info.isCancel == '0'"> 修改 </a>
  87 + <a ng-click="ctrl.deleteEci(info.id)" class="btn default blue-stripe btn-sm" ng-if="info.isCancel == '0'"> 作废 </a>
  88 + <a ng-click="ctrl.redoDeleteEci(info.id)" class="btn default blue-stripe btn-sm" ng-if="info.isCancel == '1'"> 撤销 </a>
93 89 </td>
94 90 </tr>
95 91 </tbody>
... ...