Commit 2462c4efff6a4f428c9a94dda217c59e0179e072

Authored by 杨鸣坤
1 parent 6438f678

楚江ERP:锁价无规格操作申请单取消

@@ -250,4 +250,18 @@ public class SpecLockDelayApplicationController extends DefaultBaseController { @@ -250,4 +250,18 @@ public class SpecLockDelayApplicationController extends DefaultBaseController {
250 return InvokeResultBuilder.success(result); 250 return InvokeResultBuilder.success(result);
251 } 251 }
252 252
  253 +
  254 + /**
  255 + * 订单申请延期取消
  256 + */
  257 + @ApiOperation("订单申请延期取消")
  258 + @GetMapping("/cancel")
  259 + public InvokeResult<Void> cancel(@NotBlank(message = "id不能为空!") String id) {
  260 +
  261 + specLockDelayApplicationService.cancelApplication(id);
  262 +
  263 + specLockDelayApplicationService.cleanCacheByKey(id);
  264 +
  265 + return InvokeResultBuilder.success();
  266 + }
253 } 267 }
@@ -41,4 +41,18 @@ public enum CustomerDevelopStatus implements BaseEnum<Integer> { @@ -41,4 +41,18 @@ public enum CustomerDevelopStatus implements BaseEnum<Integer> {
41 } 41 }
42 return null; 42 return null;
43 } 43 }
  44 +
  45 + /**
  46 + * 通过name获取desc(安全版本,不区分大小写)
  47 + * @param name 枚举名称
  48 + * @return 描述信息
  49 + */
  50 + public static String getDescByNameSafe(String name) {
  51 + for (CustomerDevelopStatus status : values()) {
  52 + if (status.name().equalsIgnoreCase(name)) {
  53 + return status.getDesc();
  54 + }
  55 + }
  56 + return null;
  57 + }
44 } 58 }
@@ -165,7 +165,7 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic @@ -165,7 +165,7 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
165 || FlowInstanceStatus.TERMINATION.getCode().equals(flowStatus)) { 165 || FlowInstanceStatus.TERMINATION.getCode().equals(flowStatus)) {
166 specLockDelayApplicationService.updateAuditStatus(businessId, "REFUSE"); 166 specLockDelayApplicationService.updateAuditStatus(businessId, "REFUSE");
167 } else if (FlowInstanceStatus.UNDO.getCode().equals(flowStatus)) { 167 } else if (FlowInstanceStatus.UNDO.getCode().equals(flowStatus)) {
168 - specLockDelayApplicationService.updateAuditStatus(businessId, "CANCEL"); 168 + specLockDelayApplicationService.updateAuditStatus(businessId, "REFUSE");
169 } 169 }
170 } 170 }
171 171
@@ -121,12 +121,13 @@ public class SpecLockDelayApplicationServiceImpl extends BaseMpServiceImpl<SpecL @@ -121,12 +121,13 @@ public class SpecLockDelayApplicationServiceImpl extends BaseMpServiceImpl<SpecL
121 throw new DefaultClientException("锁价无规格操作申请单不存在!"); 121 throw new DefaultClientException("锁价无规格操作申请单不存在!");
122 } 122 }
123 123
  124 + if (!CustomerDevelopStatus.REFUSE.name().equals(data.getApprovalStatus())) {
  125 + throw new DefaultClientException(CustomerDevelopStatus.getDescByNameSafe(data.getApprovalStatus()) + "的状态的锁价无规格操作申请单不允许修改!");
  126 + }
  127 +
124 LambdaUpdateWrapper<SpecLockDelayApplication> updateWrapper = Wrappers.lambdaUpdate(SpecLockDelayApplication.class) 128 LambdaUpdateWrapper<SpecLockDelayApplication> updateWrapper = Wrappers.lambdaUpdate(SpecLockDelayApplication.class)
125 - .set(SpecLockDelayApplication::getContractId, vo.getContractId())  
126 .set(SpecLockDelayApplication::getSpecLockDate, vo.getSpecLockDate()) 129 .set(SpecLockDelayApplication::getSpecLockDate, vo.getSpecLockDate())
127 - .set(SpecLockDelayApplication::getApplicationCount, vo.getApplicationCount())  
128 .set(SpecLockDelayApplication::getDelayReason, vo.getDelayReason()) 130 .set(SpecLockDelayApplication::getDelayReason, vo.getDelayReason())
129 - .set(SpecLockDelayApplication::getApprovalStatus, vo.getApprovalStatus())  
130 .eq(SpecLockDelayApplication::getId, vo.getId()); 131 .eq(SpecLockDelayApplication::getId, vo.getId());
131 132
132 getBaseMapper().update(updateWrapper); 133 getBaseMapper().update(updateWrapper);
@@ -163,6 +164,44 @@ public class SpecLockDelayApplicationServiceImpl extends BaseMpServiceImpl<SpecL @@ -163,6 +164,44 @@ public class SpecLockDelayApplicationServiceImpl extends BaseMpServiceImpl<SpecL
163 cleanCacheByKey(id); 164 cleanCacheByKey(id);
164 } 165 }
165 166
  167 + @Override
  168 + @OpLog(type = OtherOpLogType.class, name = "锁价无规格操作申请单取消,ID:{}", params = {"#id"})
  169 + @Transactional(rollbackFor = Exception.class)
  170 + public void cancelApplication(String id) {
  171 + SpecLockDelayApplication data = getBaseMapper().selectById(id);
  172 + if (ObjectUtil.isNull(data)) {
  173 + throw new DefaultClientException("锁价无规格操作申请单不存在!");
  174 + }
  175 +
  176 + if (CustomerDevelopStatus.CANCEL.name().equals(data.getApprovalStatus())) {
  177 + throw new DefaultClientException("锁价无规格操作申请单已经取消!");
  178 + }
  179 +
  180 + if (!CustomerDevelopStatus.REFUSE.name().equals(data.getApprovalStatus())) {
  181 + throw new DefaultClientException(CustomerDevelopStatus.getDescByNameSafe(data.getApprovalStatus()) + "的状态的锁价无规格操作申请单不允许取消!");
  182 + }
  183 +
  184 + Wrapper<SpecLockDelayApplication> wrapper = Wrappers.lambdaUpdate(SpecLockDelayApplication.class)
  185 + .set(SpecLockDelayApplication::getApprovalStatus, CustomerDevelopStatus.CANCEL.name())
  186 + .set(SpecLockDelayApplication::getApprovedAt, LocalDateTime.now())
  187 + .set(SpecLockDelayApplication::getApproverId, SecurityUtil.getCurrentUser().getId())
  188 + .eq(SpecLockDelayApplication::getId, id);
  189 +
  190 + getBaseMapper().update(wrapper);
  191 +
  192 + UpdateSpecLockDelayApplicationVo vo = new UpdateSpecLockDelayApplicationVo();
  193 + vo.setId(id);
  194 + vo.setApprovalStatus(CustomerDevelopStatus.CANCEL.name());
  195 + vo.setApprovedAt(LocalDateTime.now());
  196 + vo.setApproverId(SecurityUtil.getCurrentUser().getId());
  197 +
  198 +
  199 + OpLogUtil.setVariable("id", id);
  200 + OpLogUtil.setExtra(vo);
  201 +
  202 + cleanCacheByKey(id);
  203 + }
  204 +
166 @CacheEvict(value = SpecLockDelayApplication.CACHE_NAME, key = "@cacheVariables.tenantId() + #key") 205 @CacheEvict(value = SpecLockDelayApplication.CACHE_NAME, key = "@cacheVariables.tenantId() + #key")
167 @Override 206 @Override
168 public void cleanCacheByKey(Serializable key) { 207 public void cleanCacheByKey(Serializable key) {
@@ -60,5 +60,12 @@ public interface SpecLockDelayApplicationService extends BaseMpService<SpecLockD @@ -60,5 +60,12 @@ public interface SpecLockDelayApplicationService extends BaseMpService<SpecLockD
60 */ 60 */
61 void updateAuditStatus(String id, String approvedStatus); 61 void updateAuditStatus(String id, String approvedStatus);
62 62
  63 + /**
  64 + * 取消申请
  65 + *
  66 + * @param id
  67 + */
  68 + void cancelApplication(String id);
  69 +
63 } 70 }
64 71