Commit 6e18daafb1e62d528ca5a3b10852c1932437340e
PSM-15
Showing
3 changed files
with
82 additions
and
30 deletions
Too many changes to show.
To preserve performance only 3 of 7 files are displayed.
src/main/java/com/bsth/entity/schedule/EmployeeConfigInfo.java
| @@ -49,6 +49,9 @@ public class EmployeeConfigInfo { | @@ -49,6 +49,9 @@ public class EmployeeConfigInfo { | ||
| 49 | @Formula(" dbbm + 0 ") | 49 | @Formula(" dbbm + 0 ") |
| 50 | private Integer dbbmFormula; | 50 | private Integer dbbmFormula; |
| 51 | 51 | ||
| 52 | + /** 是否删除(标记) */ | ||
| 53 | + @Column(nullable = false) | ||
| 54 | + private Boolean isCancel = false; | ||
| 52 | 55 | ||
| 53 | /** 创建人 */ | 56 | /** 创建人 */ |
| 54 | @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST) | 57 | @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST) |
| @@ -96,6 +99,22 @@ public class EmployeeConfigInfo { | @@ -96,6 +99,22 @@ public class EmployeeConfigInfo { | ||
| 96 | this.jsy = jsy; | 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 | public Integer getDbbmFormula() { | 118 | public Integer getDbbmFormula() { |
| 100 | return dbbmFormula; | 119 | return dbbmFormula; |
| 101 | } | 120 | } |
| @@ -104,6 +123,14 @@ public class EmployeeConfigInfo { | @@ -104,6 +123,14 @@ public class EmployeeConfigInfo { | ||
| 104 | this.dbbmFormula = dbbmFormula; | 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 | public SysUser getCreateBy() { | 134 | public SysUser getCreateBy() { |
| 108 | return createBy; | 135 | return createBy; |
| 109 | } | 136 | } |
| @@ -120,22 +147,6 @@ public class EmployeeConfigInfo { | @@ -120,22 +147,6 @@ public class EmployeeConfigInfo { | ||
| 120 | this.updateBy = updateBy; | 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 | public Date getCreateDate() { | 150 | public Date getCreateDate() { |
| 140 | return createDate; | 151 | return createDate; |
| 141 | } | 152 | } |
src/main/java/com/bsth/entity/search/CustomerSpecs.java
| 1 | package com.bsth.entity.search; | 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 | import org.apache.commons.lang3.StringUtils; | 4 | import org.apache.commons.lang3.StringUtils; |
| 17 | import org.slf4j.Logger; | 5 | import org.slf4j.Logger; |
| 18 | import org.slf4j.LoggerFactory; | 6 | import org.slf4j.LoggerFactory; |
| 19 | import org.springframework.data.jpa.domain.Specification; | 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,6 +64,14 @@ public class CustomerSpecs<T> implements Specification<T> { | ||
| 74 | // 值为空的不参与查询 | 64 | // 值为空的不参与查询 |
| 75 | if (value == null || (value instanceof String && value.equals(""))) | 65 | if (value == null || (value instanceof String && value.equals(""))) |
| 76 | continue; | 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 | try { | 76 | try { |
| 79 | if(!eSet.contains(searchs[1])) | 77 | if(!eSet.contains(searchs[1])) |
src/main/java/com/bsth/service/schedule/EmployeeConfigInfoServiceImpl.java
| 1 | package com.bsth.service.schedule; | 1 | package com.bsth.service.schedule; |
| 2 | 2 | ||
| 3 | +import com.bsth.common.ResponseCode; | ||
| 4 | +import com.bsth.entity.Line; | ||
| 3 | import com.bsth.entity.schedule.EmployeeConfigInfo; | 5 | import com.bsth.entity.schedule.EmployeeConfigInfo; |
| 6 | +import com.bsth.entity.schedule.rule.ScheduleRule1Flat; | ||
| 7 | +import com.bsth.repository.schedule.EmployeeConfigInfoRepository; | ||
| 4 | import com.bsth.service.impl.BaseServiceImpl; | 8 | import com.bsth.service.impl.BaseServiceImpl; |
| 9 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 5 | import org.springframework.stereotype.Service; | 10 | import org.springframework.stereotype.Service; |
| 6 | 11 | ||
| 12 | +import javax.transaction.Transactional; | ||
| 13 | +import java.util.*; | ||
| 14 | + | ||
| 7 | /** | 15 | /** |
| 8 | * Created by xu on 16/5/10. | 16 | * Created by xu on 16/5/10. |
| 9 | */ | 17 | */ |
| 10 | @Service | 18 | @Service |
| 11 | public class EmployeeConfigInfoServiceImpl extends BaseServiceImpl<EmployeeConfigInfo, Long> implements EmployeeConfigInfoService { | 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 | } |