|
|
@@ -3,8 +3,6 @@ package com.sckw.system.service;
|
|
|
import java.util.*;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import com.sckw.core.exception.SystemException;
|
|
|
@@ -40,7 +38,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
* @date 2023-05-31
|
|
|
*/
|
|
|
@Service
|
|
|
-public class KwsEnterpriseService extends ServiceImpl<KwsEnterpriseDao, KwsEnterprise> {
|
|
|
+public class KwsEnterpriseService {
|
|
|
|
|
|
@Autowired
|
|
|
private KwsEnterpriseDao kwsEnterpriseDao;
|
|
|
@@ -93,16 +91,18 @@ public class KwsEnterpriseService extends ServiceImpl<KwsEnterpriseDao, KwsEnter
|
|
|
long entId = reqVo.getId();
|
|
|
KwsEnterprise kwsEnterprise = checkKwsEnterpriseById(entId);
|
|
|
BeanUtils.copyProperties(reqVo, kwsEnterprise);
|
|
|
- if (!this.updateById(kwsEnterprise)) {
|
|
|
+ if (kwsEnterpriseDao.update(kwsEnterprise) <= 0) {
|
|
|
throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
|
|
|
}
|
|
|
|
|
|
/*2、更新企业类型*/
|
|
|
- LambdaQueryWrapper<KwsEntType> kwsEntTypeLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- kwsEntTypeLambdaQueryWrapper.eq(KwsEntType::getEntId, entId);
|
|
|
-// List<KwsEntType> kwsEntTypes = kwsEntTypeDao.selectList(kwsEntTypeLambdaQueryWrapper);
|
|
|
List<KwsEntType> kwsEntTypes = null;
|
|
|
- List<String> typeReqList = Arrays.stream(reqVo.getEntTypes().split(",")).toList();
|
|
|
+ List<String> typeReqList = new ArrayList<>();
|
|
|
+ String entTypes = reqVo.getEntTypes();
|
|
|
+ if (StringUtils.isNotBlank(entTypes)) {
|
|
|
+ typeReqList = Arrays.stream(entTypes.split(",")).toList();
|
|
|
+ }
|
|
|
+
|
|
|
//若入参传来的type在表里面本来就有则不管,没有就新增
|
|
|
typeReqList.forEach(item -> {
|
|
|
if (CollectionUtils.isEmpty(kwsEntTypes) || kwsEntTypes.stream().filter(x -> x.getType() == Integer.parseInt(item)).findAny().isPresent()) {
|
|
|
@@ -119,8 +119,9 @@ public class KwsEnterpriseService extends ServiceImpl<KwsEnterpriseDao, KwsEnter
|
|
|
|
|
|
//若表里的type没有在入参传来的type里则做逻辑删除,有就不管
|
|
|
if (CollectionUtils.isNotEmpty(kwsEntTypes)) {
|
|
|
+ List<String> finalTypeReqList = typeReqList;
|
|
|
kwsEntTypes.forEach(item -> {
|
|
|
- if (typeReqList.contains(String.valueOf(item.getType()))) {
|
|
|
+ if (finalTypeReqList.contains(String.valueOf(item.getType()))) {
|
|
|
item.setDelFlag(Global.YES);
|
|
|
if (kwsEntTypeDao.update(item) <= 0) {
|
|
|
throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
|
|
|
@@ -130,7 +131,21 @@ public class KwsEnterpriseService extends ServiceImpl<KwsEnterpriseDao, KwsEnter
|
|
|
}
|
|
|
|
|
|
/*更新证书信息*/
|
|
|
+ //1、没有传则全部删除
|
|
|
List<BusinessLicense> certificates = reqVo.getCertificates();
|
|
|
+ if (CollectionUtils.isEmpty(certificates)) {
|
|
|
+ List<KwsEntCertificate> kwsEntCertificates = kwsEntCertificateDao.selectByEntId(entId);
|
|
|
+ if (!CollectionUtils.isEmpty(kwsEntCertificates)) {
|
|
|
+ kwsEntCertificates.forEach(item -> {
|
|
|
+ item.setDelFlag(Global.YES);
|
|
|
+ if(kwsEntCertificateDao.update(item) <= 0){
|
|
|
+ throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
certificates.forEach(item -> {
|
|
|
long id = item.getId();
|
|
|
if (Objects.isNull(id)) {
|
|
|
@@ -153,8 +168,8 @@ public class KwsEnterpriseService extends ServiceImpl<KwsEnterpriseDao, KwsEnter
|
|
|
}
|
|
|
|
|
|
public KwsEntCertificate checkEntCertificate(long id){
|
|
|
- KwsEntCertificate kwsEntCertificate = kwsEntCertificateDao.selectById(id);
|
|
|
- if(Objects.isNull(kwsEntCertificate) || kwsEntCertificate.getDelFlag() == Global.NO){
|
|
|
+ KwsEntCertificate kwsEntCertificate = kwsEntCertificateDao.selectByKey(id);
|
|
|
+ if(Objects.isNull(kwsEntCertificate) || kwsEntCertificate.getDelFlag() == Global.YES){
|
|
|
throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.ENTCERTIFICATES_NOT_EXISTS);
|
|
|
}
|
|
|
return kwsEntCertificate;
|
|
|
@@ -192,16 +207,7 @@ public class KwsEnterpriseService extends ServiceImpl<KwsEnterpriseDao, KwsEnter
|
|
|
* @date: 2023/6/9
|
|
|
*/
|
|
|
public List<KwsEnterprise> findList(EntFindPageReqVo reqVo) {
|
|
|
- LambdaQueryWrapper<KwsEnterprise> wrapper = new LambdaQueryWrapper<>();
|
|
|
- wrapper.eq(StringUtils.isNotBlank(reqVo.getFirmName()), KwsEnterprise::getFirmName, reqVo.getFirmName());
|
|
|
- wrapper.eq(StringUtils.isNotBlank(reqVo.getContacts()), KwsEnterprise::getContacts, reqVo.getContacts());
|
|
|
- wrapper.eq(StringUtils.isNotBlank(reqVo.getTelephone()), KwsEnterprise::getTelephone, reqVo.getTelephone());
|
|
|
- wrapper.eq(StringUtils.isNotBlank(reqVo.getLegalName()), KwsEnterprise::getLegalName, reqVo.getLegalName());
|
|
|
- wrapper.eq(StringUtils.isNotBlank(reqVo.getLegalTelephone()), KwsEnterprise::getLegalTelephone, reqVo.getLegalTelephone());
|
|
|
- wrapper.eq(!Objects.isNull(reqVo.getApproval()), KwsEnterprise::getApproval, reqVo.getApproval());
|
|
|
- wrapper.eq(KwsEnterprise::getDelFlag, Global.NO);
|
|
|
- wrapper.orderByDesc(KwsEnterprise::getCreateTime);
|
|
|
- return this.list(wrapper);
|
|
|
+ return kwsEnterpriseDao.findList(reqVo);
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -246,8 +252,7 @@ public class KwsEnterpriseService extends ServiceImpl<KwsEnterpriseDao, KwsEnter
|
|
|
kwsEnterprise.setMemberLevel(0);
|
|
|
kwsEnterprise.setRegTime(new Date());
|
|
|
kwsEnterprise.setApproval(ApprovalEnum.NO.getCode());
|
|
|
- kwsEnterpriseDao.insertPPPPP(kwsEnterprise);
|
|
|
- if (!this.save(kwsEnterprise)) {
|
|
|
+ if (kwsEnterpriseDao.insert(kwsEnterprise) <= 0) {
|
|
|
throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
|
|
|
}
|
|
|
|
|
|
@@ -257,9 +262,16 @@ public class KwsEnterpriseService extends ServiceImpl<KwsEnterpriseDao, KwsEnter
|
|
|
KwsEntType kwsEntType = new KwsEntType();
|
|
|
kwsEntType.setEntId(entId);
|
|
|
kwsEntType.setType(Integer.parseInt(item));
|
|
|
+ kwsEntType.setId(new IdWorker(1).nextId());
|
|
|
+ kwsEntType.setDelFlag(Global.NO);
|
|
|
+ kwsEntType.setStatus(Global.NO);
|
|
|
+ kwsEntType.setCreateBy(1L);
|
|
|
+ kwsEntType.setUpdateBy(1L);
|
|
|
+ kwsEntType.setCreateTime(new Date());
|
|
|
+ kwsEntType.setUpdateTime(new Date());
|
|
|
kwsEntTypes.add(kwsEntType);
|
|
|
});
|
|
|
- if (kwsEntTypeDao.insertForBatchtest(kwsEntTypes) != kwsEntTypes.size()) {
|
|
|
+ if (kwsEntTypeDao.saveBatch(kwsEntTypes) != kwsEntTypes.size()) {
|
|
|
throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
|
|
|
}
|
|
|
|
|
|
@@ -269,10 +281,17 @@ public class KwsEnterpriseService extends ServiceImpl<KwsEnterpriseDao, KwsEnter
|
|
|
KwsEntCertificate kwsEntCertificate = new KwsEntCertificate();
|
|
|
//todo 上传证书正反面,将url放到两个入参里
|
|
|
kwsEntCertificate.setEntId(entId);
|
|
|
+ kwsEntCertificate.setId(new IdWorker(1).nextId());
|
|
|
+ kwsEntCertificate.setDelFlag(Global.NO);
|
|
|
+ kwsEntCertificate.setStatus(Global.NO);
|
|
|
+ kwsEntCertificate.setCreateBy(1L);
|
|
|
+ kwsEntCertificate.setUpdateBy(1L);
|
|
|
+ kwsEntCertificate.setCreateTime(new Date());
|
|
|
+ kwsEntCertificate.setUpdateTime(new Date());
|
|
|
BeanUtils.copyProperties(item, kwsEntCertificate);
|
|
|
kwsEntCertificates.add(kwsEntCertificate);
|
|
|
});
|
|
|
- if (kwsEntCertificateDao.insertForBatch(kwsEntCertificates) != kwsEntCertificates.size()) {
|
|
|
+ if (kwsEntCertificateDao.saveBatch(kwsEntCertificates) != kwsEntCertificates.size()) {
|
|
|
throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
|
|
|
}
|
|
|
}
|
|
|
@@ -284,11 +303,8 @@ public class KwsEnterpriseService extends ServiceImpl<KwsEnterpriseDao, KwsEnter
|
|
|
public void approval(KwsEntCheckTrack kwsEntCheckTrack) {
|
|
|
/*更新企业信息主表审批状态*/
|
|
|
KwsEnterprise kwsEnterprise = checkKwsEnterpriseById(kwsEntCheckTrack.getEntId());
|
|
|
- LambdaUpdateChainWrapper<KwsEnterprise> wrapper = new LambdaUpdateChainWrapper<>(kwsEnterpriseDao);
|
|
|
- wrapper.eq(KwsEnterprise::getId, kwsEnterprise.getId());
|
|
|
- wrapper.eq(KwsEnterprise::getApproval, ApprovalEnum.NO.getCode());
|
|
|
- wrapper.set(KwsEnterprise::getApproval, kwsEntCheckTrack.getStatus());
|
|
|
- if (!wrapper.update()) {
|
|
|
+ kwsEnterprise.setApproval(kwsEntCheckTrack.getStatus());
|
|
|
+ if (kwsEnterpriseDao.update(kwsEnterprise) <= 0) {
|
|
|
throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
|
|
|
}
|
|
|
|
|
|
@@ -299,11 +315,8 @@ public class KwsEnterpriseService extends ServiceImpl<KwsEnterpriseDao, KwsEnter
|
|
|
}
|
|
|
|
|
|
private KwsEnterprise checkKwsEnterpriseById(long id) {
|
|
|
- LambdaQueryWrapper<KwsEnterprise> wrapper = new LambdaQueryWrapper<>();
|
|
|
- wrapper.eq(KwsEnterprise::getId, id);
|
|
|
- wrapper.eq(KwsEnterprise::getDelFlag, Global.NO);
|
|
|
- KwsEnterprise kwsEnterprise = this.getOne(wrapper);
|
|
|
- if (Objects.isNull(kwsEnterprise)) {
|
|
|
+ KwsEnterprise kwsEnterprise = kwsEnterpriseDao.selectByKey(id);
|
|
|
+ if (Objects.isNull(kwsEnterprise) || kwsEnterprise.getDelFlag() == Global.YES) {
|
|
|
throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.ENT_NOT_EXISTS);
|
|
|
}
|
|
|
return kwsEnterprise;
|
|
|
@@ -325,10 +338,7 @@ public class KwsEnterpriseService extends ServiceImpl<KwsEnterpriseDao, KwsEnter
|
|
|
*/
|
|
|
public List<CertificateResVo> certificate(Long id) {
|
|
|
/*查企业资质*/
|
|
|
- LambdaQueryWrapper<KwsEntCertificate> wrapper = new LambdaQueryWrapper<>();
|
|
|
- wrapper.eq(KwsEntCertificate::getEntId, id);
|
|
|
- wrapper.eq(KwsEntCertificate::getDelFlag, Global.NO);
|
|
|
- List<KwsEntCertificate> kwsEntCertificates = kwsEntCertificateDao.selectList(wrapper);
|
|
|
+ List<KwsEntCertificate> kwsEntCertificates = kwsEntCertificateDao.selectByEntId(id);
|
|
|
if (CollectionUtils.isEmpty(kwsEntCertificates)) {
|
|
|
throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.ENTCERTIFICATES_NOT_EXISTS);
|
|
|
}
|