|
@@ -19,14 +19,15 @@ import com.sckw.core.utils.IdWorker;
|
|
|
import com.sckw.core.utils.StringUtils;
|
|
import com.sckw.core.utils.StringUtils;
|
|
|
import com.sckw.core.web.constant.HttpStatus;
|
|
import com.sckw.core.web.constant.HttpStatus;
|
|
|
import com.sckw.core.web.context.LoginUserHolder;
|
|
import com.sckw.core.web.context.LoginUserHolder;
|
|
|
|
|
+import com.sckw.core.web.model.EntCertificateInfo;
|
|
|
import com.sckw.system.api.model.dto.req.RegisterReqDto;
|
|
import com.sckw.system.api.model.dto.req.RegisterReqDto;
|
|
|
import com.sckw.system.api.model.dto.res.RegisterResDto;
|
|
import com.sckw.system.api.model.dto.res.RegisterResDto;
|
|
|
import com.sckw.system.dao.*;
|
|
import com.sckw.system.dao.*;
|
|
|
import com.sckw.system.model.*;
|
|
import com.sckw.system.model.*;
|
|
|
import com.sckw.system.model.pojo.FindEntUserPojo;
|
|
import com.sckw.system.model.pojo.FindEntUserPojo;
|
|
|
|
|
+import com.sckw.system.model.pojo.FindManagePojo;
|
|
|
import com.sckw.system.model.vo.req.*;
|
|
import com.sckw.system.model.vo.req.*;
|
|
|
import com.sckw.system.model.vo.res.CertificateResVo;
|
|
import com.sckw.system.model.vo.res.CertificateResVo;
|
|
|
-import com.sckw.system.model.vo.res.IdResVo;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -65,7 +66,7 @@ public class KwsEnterpriseService {
|
|
|
private KwsDeptService kwsDeptService;
|
|
private KwsDeptService kwsDeptService;
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
- private KwsMenuService kwsMenuService;
|
|
|
|
|
|
|
+ private CommonService commonService;
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private KwsRoleService kwsRoleService;
|
|
private KwsRoleService kwsRoleService;
|
|
@@ -313,12 +314,12 @@ public class KwsEnterpriseService {
|
|
|
KwsEntCertificate kwsEntCertificate = new KwsEntCertificate();
|
|
KwsEntCertificate kwsEntCertificate = new KwsEntCertificate();
|
|
|
//todo 上传证书正反面,将url放到两个入参里
|
|
//todo 上传证书正反面,将url放到两个入参里
|
|
|
kwsEntCertificate.setEntId(entId);
|
|
kwsEntCertificate.setEntId(entId);
|
|
|
- kwsEntCertificate.setStatus(Global.NO);
|
|
|
|
|
kwsEntCertificate.setCreateBy(userId);
|
|
kwsEntCertificate.setCreateBy(userId);
|
|
|
kwsEntCertificate.setCreateTime(date);
|
|
kwsEntCertificate.setCreateTime(date);
|
|
|
kwsEntCertificate.setUpdateBy(userId);
|
|
kwsEntCertificate.setUpdateBy(userId);
|
|
|
kwsEntCertificate.setUpdateTime(date);
|
|
kwsEntCertificate.setUpdateTime(date);
|
|
|
kwsEntCertificate.setDelFlag(Global.NO);
|
|
kwsEntCertificate.setDelFlag(Global.NO);
|
|
|
|
|
+ kwsEntCertificate.setStatus(ApprovalEnum.PROCESS.getCode());
|
|
|
BeanUtils.copyProperties(businessLicense, kwsEntCertificate);
|
|
BeanUtils.copyProperties(businessLicense, kwsEntCertificate);
|
|
|
kwsEntCertificate.setId(new IdWorker(1).nextId());
|
|
kwsEntCertificate.setId(new IdWorker(1).nextId());
|
|
|
kwsEntCertificates.add(kwsEntCertificate);
|
|
kwsEntCertificates.add(kwsEntCertificate);
|
|
@@ -344,55 +345,65 @@ public class KwsEnterpriseService {
|
|
|
* 企业审批
|
|
* 企业审批
|
|
|
*/
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void approval(KwsEntCheckTrack kwsEntCheckTrack) throws SystemException {
|
|
|
|
|
|
|
+ public void approval(ApprovalReqVo reqVo) throws SystemException {
|
|
|
|
|
+ Integer status = reqVo.getStatus();
|
|
|
|
|
+ Long entId = null;
|
|
|
|
|
+ String certificateIds = reqVo.getCertificateIds();
|
|
|
|
|
+ List<KwsEntCertificate> kwsEntCertificates = new ArrayList<>();
|
|
|
|
|
+ for (String id : certificateIds.split(",")) {
|
|
|
|
|
+ KwsEntCertificate kwsEntCertificate = kwsEntCertificateDao.selectByKey(Long.parseLong(id));
|
|
|
|
|
+ if (Objects.isNull(kwsEntCertificate)) {
|
|
|
|
|
+ throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
|
|
|
|
|
+ }
|
|
|
|
|
+ kwsEntCertificate.setStatus(ApprovalEnum.OK.getCode() == status ? Global.NO : Global.YES);
|
|
|
|
|
+ kwsEntCertificateDao.update(kwsEntCertificate);
|
|
|
|
|
+
|
|
|
|
|
+ List<KwsEntCertificate> previous = kwsEntCertificateDao.findByEntType(kwsEntCertificate.getEntId(), kwsEntCertificate.getType());
|
|
|
|
|
+ previous = previous.stream().filter(item -> item.getId() != Long.parseLong(id)).toList();
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(previous)) {
|
|
|
|
|
+ for (KwsEntCertificate kwsEntCertificate1 : previous) {
|
|
|
|
|
+ kwsEntCertificate1.setDelFlag(Global.YES);
|
|
|
|
|
+ kwsEntCertificateDao.update(kwsEntCertificate1);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ entId = kwsEntCertificate.getEntId();
|
|
|
|
|
+ kwsEntCertificates.add(kwsEntCertificate);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/*更新企业信息主表审批状态*/
|
|
/*更新企业信息主表审批状态*/
|
|
|
- Long entId = kwsEntCheckTrack.getEntId();
|
|
|
|
|
KwsEnterprise kwsEnterprise = checkKwsEnterpriseById(entId);
|
|
KwsEnterprise kwsEnterprise = checkKwsEnterpriseById(entId);
|
|
|
Integer currentApproval = kwsEnterprise.getApproval();
|
|
Integer currentApproval = kwsEnterprise.getApproval();
|
|
|
- kwsEnterprise.setApproval(kwsEntCheckTrack.getStatus());
|
|
|
|
|
|
|
+ kwsEnterprise.setApproval(reqVo.getStatus());
|
|
|
if (kwsEnterpriseDao.approval(kwsEnterprise) <= 0) {
|
|
if (kwsEnterpriseDao.approval(kwsEnterprise) <= 0) {
|
|
|
throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
|
|
throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*新增审批记录*/
|
|
/*新增审批记录*/
|
|
|
|
|
+ KwsEntCheckTrack kwsEntCheckTrack = new KwsEntCheckTrack();
|
|
|
|
|
+ kwsEntCheckTrack.setEntId(entId);
|
|
|
if (kwsEntCheckTrackDao.insert(kwsEntCheckTrack) <= 0) {
|
|
if (kwsEntCheckTrackDao.insert(kwsEntCheckTrack) <= 0) {
|
|
|
throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
|
|
throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*第一次审批通过(非更新资质审批通过),构建机构角色等*/
|
|
/*第一次审批通过(非更新资质审批通过),构建机构角色等*/
|
|
|
- if (ApprovalEnum.OK.getCode() == kwsEntCheckTrack.getStatus() && ApprovalEnum.PROCESS.getCode() == currentApproval) {
|
|
|
|
|
- /*审批通过,构建管理员角色及权限*/
|
|
|
|
|
- /*1、新增管理员机构*/
|
|
|
|
|
- KwsDept kwsDept = new KwsDept();
|
|
|
|
|
- Integer systemType = SystemTypeEnum.COMPANY.getCode();
|
|
|
|
|
- long deptId = new IdWorker(1L).nextId();
|
|
|
|
|
- kwsDept.setEntId(entId);
|
|
|
|
|
- kwsDept.setName(Global.MANAGE_DEPT_NAME);
|
|
|
|
|
- kwsDept.setSystemType(systemType);
|
|
|
|
|
- kwsDept.setCompany(Global.NO);
|
|
|
|
|
- kwsDept.setId(deptId);
|
|
|
|
|
- kwsDeptService.add(kwsDept);
|
|
|
|
|
-
|
|
|
|
|
- /*2、新增管理员角色*/
|
|
|
|
|
- EditRoleReqVo editRoleReqVo = new EditRoleReqVo();
|
|
|
|
|
- List<KwsMenu> list = kwsMenuService.selectAll();
|
|
|
|
|
- if (CollectionUtils.isEmpty(list)) {
|
|
|
|
|
- throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
|
|
|
|
|
- }
|
|
|
|
|
- editRoleReqVo.setName(Global.MANAGE_NAME);
|
|
|
|
|
- editRoleReqVo.setCurrentUnitId(entId);
|
|
|
|
|
- editRoleReqVo.setMenuIds(String.join(",", list.stream().map(KwsMenu::getId).map(String::valueOf).toList()));
|
|
|
|
|
- editRoleReqVo.setVisiblePersonal(false);
|
|
|
|
|
- IdResVo idResVo = kwsRoleService.add(editRoleReqVo);
|
|
|
|
|
-
|
|
|
|
|
- /*3、绑定角色等*/
|
|
|
|
|
- KwsUser userByAccount = kwsUserService.getUserByAccount(kwsEnterprise.getPhone(), SystemTypeEnum.COMPANY.getCode());
|
|
|
|
|
- if (Objects.isNull(userByAccount)) {
|
|
|
|
|
- throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
|
|
|
|
|
|
|
+ if (ApprovalEnum.OK.getCode() == status) {
|
|
|
|
|
+ commonService.updateEntCertificate(entId, BeanUtils.copyToList(kwsEntCertificates, EntCertificateInfo.class));
|
|
|
|
|
+ if (ApprovalEnum.PROCESS.getCode() == currentApproval) {
|
|
|
|
|
+ /*审批通过,绑定角色*/
|
|
|
|
|
+ FindManagePojo findManagePojo = kwsEnterpriseDao.findManageInfoByEntIdBeforeApproval(entId);
|
|
|
|
|
+ if (Objects.isNull(findManagePojo)) {
|
|
|
|
|
+ throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
|
|
|
|
|
+ }
|
|
|
|
|
+ KwsUser userByAccount = kwsUserService.getUserByAccount(kwsEnterprise.getPhone(), SystemTypeEnum.COMPANY.getCode());
|
|
|
|
|
+ if (Objects.isNull(userByAccount)) {
|
|
|
|
|
+ throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
|
|
|
|
|
+ }
|
|
|
|
|
+ kwsUserService.fillUserRole(String.valueOf(findManagePojo.getRoleId()),userByAccount.getId(), SystemTypeEnum.COMPANY.getCode());
|
|
|
}
|
|
}
|
|
|
- kwsUserService.fillUserRole(String.valueOf(idResVo.getId()),userByAccount.getId(), systemType);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private KwsEnterprise checkKwsEnterpriseById(long id) throws SystemException {
|
|
private KwsEnterprise checkKwsEnterpriseById(long id) throws SystemException {
|
|
@@ -421,9 +432,9 @@ public class KwsEnterpriseService {
|
|
|
/**
|
|
/**
|
|
|
* 企业证件信息
|
|
* 企业证件信息
|
|
|
*/
|
|
*/
|
|
|
- public List<CertificateResVo> certificate(Long id) throws SystemException {
|
|
|
|
|
|
|
+ public List<CertificateResVo> certificate(Long entId) throws SystemException {
|
|
|
/*查企业资质*/
|
|
/*查企业资质*/
|
|
|
- List<KwsEntCertificate> kwsEntCertificates = kwsEntCertificateDao.selectByEntId(id);
|
|
|
|
|
|
|
+ List<KwsEntCertificate> kwsEntCertificates = kwsEntCertificateDao.selectByEntId(entId);
|
|
|
if (CollectionUtils.isEmpty(kwsEntCertificates)) {
|
|
if (CollectionUtils.isEmpty(kwsEntCertificates)) {
|
|
|
throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.ENTCERTIFICATES_NOT_EXISTS);
|
|
throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.ENTCERTIFICATES_NOT_EXISTS);
|
|
|
}
|
|
}
|
|
@@ -439,6 +450,28 @@ public class KwsEnterpriseService {
|
|
|
return list;
|
|
return list;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 企业证件信息
|
|
|
|
|
+ */
|
|
|
|
|
+ public List<CertificateResVo> queryCertificate(Long entId) throws SystemException {
|
|
|
|
|
+ /*查企业资质*/
|
|
|
|
|
+ List<KwsEntCertificate> kwsEntCertificates = kwsEntCertificateDao.selectByEntId(entId);
|
|
|
|
|
+ if (CollectionUtils.isEmpty(kwsEntCertificates)) {
|
|
|
|
|
+ return Collections.emptyList();
|
|
|
|
|
+ }
|
|
|
|
|
+ /*拼装返参*/
|
|
|
|
|
+ List<CertificateResVo> list = new ArrayList<>();
|
|
|
|
|
+ kwsEntCertificates.forEach(item -> {
|
|
|
|
|
+ CertificateResVo certificateResVo = new CertificateResVo();
|
|
|
|
|
+ certificateResVo.setTypeName(Objects.requireNonNull(EntTypeEnum.getName(item.getType())).getName());
|
|
|
|
|
+ BeanUtils.copyProperties(item, certificateResVo);
|
|
|
|
|
+ list.add(certificateResVo);
|
|
|
|
|
+ });
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* @param userId 用户id
|
|
* @param userId 用户id
|
|
|
* @return KwsEnterprise
|
|
* @return KwsEnterprise
|
|
@@ -476,4 +509,38 @@ public class KwsEnterpriseService {
|
|
|
public List<KwsEntCheckTrack> entCheck(Long entId) {
|
|
public List<KwsEntCheckTrack> entCheck(Long entId) {
|
|
|
return kwsEntCheckTrackDao.findList(entId);
|
|
return kwsEntCheckTrackDao.findList(entId);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @param reqVo 入参
|
|
|
|
|
+ * @desc: 更新企业资质
|
|
|
|
|
+ * @author: czh
|
|
|
|
|
+ * @date: 2023/6/29
|
|
|
|
|
+ */
|
|
|
|
|
+ public void updateCertificate(UpdateCertificateReqVo reqVo) {
|
|
|
|
|
+ for (BusinessLicense businessLicense : reqVo.getCertificateInfo()) {
|
|
|
|
|
+ long id = businessLicense.getId();
|
|
|
|
|
+ KwsEntCertificate kwsEntCertificate = kwsEntCertificateDao.selectByKey(id);
|
|
|
|
|
+ if (Objects.isNull(kwsEntCertificate)) {
|
|
|
|
|
+ throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ kwsEntCertificate.setCode(businessLicense.getCode());
|
|
|
|
|
+ kwsEntCertificate.setCertificateMian(businessLicense.getCertificateMian());
|
|
|
|
|
+ kwsEntCertificate.setCertificateRevolt(businessLicense.getCertificateRevolt());
|
|
|
|
|
+ kwsEntCertificate.setExpireTime(businessLicense.getExpireTime());
|
|
|
|
|
+ kwsEntCertificate.setRemark(businessLicense.getRemark());
|
|
|
|
|
+ kwsEntCertificate.setStatus(Global.YES);
|
|
|
|
|
+ kwsEntCertificate.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
|
|
+ kwsEntCertificate.setUpdateTime(new Date());
|
|
|
|
|
+ kwsEntCertificate.setDelFlag(Global.NO);
|
|
|
|
|
+ if (kwsEntCertificateDao.update(kwsEntCertificate) <= 0) {
|
|
|
|
|
+ throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ KwsEnterprise kwsEnterprise = new KwsEnterprise();
|
|
|
|
|
+ kwsEnterprise.setId(kwsEntCertificate.getEntId());
|
|
|
|
|
+ kwsEnterprise.setApproval(ApprovalEnum.REFRESH.getCode());
|
|
|
|
|
+ kwsEnterpriseDao.update(kwsEnterprise);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|