|
@@ -1,5 +1,6 @@
|
|
|
package cn.com.ty.lift.enterprise.oa.controller;
|
|
|
|
|
|
+import cn.com.ty.lift.common.constants.ApiConstants;
|
|
|
import cn.com.ty.lift.common.model.CountPage;
|
|
|
import cn.com.ty.lift.common.utils.ValuePool;
|
|
|
import cn.com.ty.lift.common.verify.Val;
|
|
@@ -11,6 +12,7 @@ import cn.com.ty.lift.enterprise.oa.entity.LiftCertificate;
|
|
|
import cn.com.ty.lift.enterprise.oa.service.LiftCertificateService;
|
|
|
import cn.com.xwy.boot.web.dto.RestResponse;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
@@ -19,6 +21,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
+import java.util.List;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -117,14 +120,33 @@ public class LiftCertificateController {
|
|
|
public RestResponse add(@Valid @RequestBody LiftCertificate entity) {
|
|
|
Long ownerId = entity.getOwnerId();
|
|
|
Long mtCompanyId = entity.getMtCompanyId();
|
|
|
-
|
|
|
- int count = liftCertificateService.countByUserAndMtCompany(ownerId, mtCompanyId);
|
|
|
- Validate.notTrue(count > 0, ValuePool.LIFT_CERT_HAD_EXIST);
|
|
|
- entity.setStatus(1);
|
|
|
-
|
|
|
- boolean result = liftCertificateService.saveOrUpdate(entity);
|
|
|
+// int count = liftCertificateService.countByUserAndMtCompany(ownerId, mtCompanyId);
|
|
|
+ List<LiftCertificate> list = liftCertificateService.list(Wrappers.<LiftCertificate>lambdaQuery().
|
|
|
+ eq(LiftCertificate::getOwnerId, ownerId).
|
|
|
+ eq(LiftCertificate::getMtCompanyId, mtCompanyId).
|
|
|
+ ne(LiftCertificate::getStatus, ApiConstants.LiftCertificate.NULL));
|
|
|
+ boolean result;
|
|
|
+ if (list.size() > 0) {
|
|
|
+ log.debug("操作证数量大于0,批量更新操作证信息");
|
|
|
+ list.forEach(l -> {
|
|
|
+ l.setCode(entity.getCode());
|
|
|
+ l.setIssuanceAgency(entity.getIssuanceAgency());
|
|
|
+ l.setExpirationDate(entity.getExpirationDate());
|
|
|
+ l.setCertificateType(entity.getCertificateType());
|
|
|
+ l.setFirstImgUrl(entity.getFirstImgUrl());
|
|
|
+ l.setSecondImgUrl(entity.getSecondImgUrl());
|
|
|
+ l.setStatus(ApiConstants.LiftCertificate.AUDIT);
|
|
|
+ });
|
|
|
+ result = liftCertificateService.updateBatchById(list);
|
|
|
+ } else {
|
|
|
+ log.debug("没有操作证,设置操作证状态为待审核,保存操作证");
|
|
|
+ entity.setStatus(ApiConstants.LiftCertificate.AUDIT);
|
|
|
+ result = liftCertificateService.saveOrUpdate(entity);
|
|
|
+ }
|
|
|
+// Validate.notTrue(list.size() > 0, ValuePool.LIFT_CERT_HAD_EXIST);
|
|
|
return RestResponse.success(result);
|
|
|
|
|
|
+
|
|
|
}
|
|
|
@PostMapping("findByUser")
|
|
|
@Validation(fields = {"ownerId","mtCompanyId"})
|