|
|
@@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.http.HttpStatus;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
@@ -11,14 +12,10 @@ import com.zhongzheng.bo.SysCertificateBo;
|
|
|
import com.zhongzheng.common.filter.CustomException;
|
|
|
import com.zhongzheng.common.model.TableDataInfo;
|
|
|
import com.zhongzheng.common.util.DateUtils;
|
|
|
-import com.zhongzheng.domian.SysCertificate;
|
|
|
-import com.zhongzheng.domian.SysCompany;
|
|
|
-import com.zhongzheng.domian.SysPerson;
|
|
|
+import com.zhongzheng.domian.*;
|
|
|
import com.zhongzheng.mapper.SysCertificateMapper;
|
|
|
import com.zhongzheng.mapper.SysPersonMapper;
|
|
|
-import com.zhongzheng.service.ISysCertificateService;
|
|
|
-import com.zhongzheng.service.ISysCompanyService;
|
|
|
-import com.zhongzheng.service.ISysPersonService;
|
|
|
+import com.zhongzheng.service.*;
|
|
|
import com.zhongzheng.vo.MajorVo;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -50,6 +47,15 @@ public class SysCertificateServiceImpl extends ServiceImpl<SysCertificateMapper,
|
|
|
@Autowired
|
|
|
private SysCertificateMapper certMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysCertificateAdditionService certadditionService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ISysCertificateTypeService certTypeSeaService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ICertificateMajorService majorService;
|
|
|
+
|
|
|
|
|
|
|
|
|
public void checklegal(long personId,long userid)
|
|
|
@@ -64,6 +70,68 @@ public class SysCertificateServiceImpl extends ServiceImpl<SysCertificateMapper,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public TableDataInfo<SysCertificate> selectList(SysCertificateBo entity) {
|
|
|
+ if (ObjectUtil.isEmpty(entity.getPageSize()) || entity.getPageSize() < 1) {
|
|
|
+ entity.setPageSize(-1);
|
|
|
+ entity.setPageNum(1);
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(entity.getCompanyName())){
|
|
|
+ SysCompany company = sysCompanyService.selectCompanyByName(entity.getCompanyName(),entity.getUserId());
|
|
|
+ if(ObjectUtil.isEmpty(company)){
|
|
|
+ return new TableDataInfo<>();
|
|
|
+ }
|
|
|
+ entity.setCompanyId(entity.getCompanyId());
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(entity.getPersonName())){
|
|
|
+ List<SysCompany> c_list=sysCompanyService.selectCompanyByUserid(entity.getUserId());
|
|
|
+ if(c_list.isEmpty()){
|
|
|
+ return new TableDataInfo<>();
|
|
|
+ }
|
|
|
+ List<Long> companyIdList= c_list.stream().map(SysCompany::getCompanyId).collect(Collectors.toList());
|
|
|
+ List<SysPerson> p_list= sysPersonService.selectPersonByName(entity.getPersonName(),companyIdList);
|
|
|
+ if(p_list!=null&&p_list.size()==0){
|
|
|
+ return new TableDataInfo<>();
|
|
|
+ }
|
|
|
+ List<Long> uids=p_list.stream().map(SysPerson::getPersonId).collect(Collectors.toList());
|
|
|
+ entity.setPersonIds(uids);
|
|
|
+ }
|
|
|
+
|
|
|
+ IPage<SysCertificate> pageinfo = certMapper.selectCerListByCertBo(new Page<>(entity.getPageNum(), entity.getPageSize()), entity);
|
|
|
+ TableDataInfo<SysCertificate> info = new TableDataInfo();
|
|
|
+
|
|
|
+ if(pageinfo.getRecords().size()>0) {
|
|
|
+ List<Long> cetList = pageinfo.getRecords().stream().map(SysCertificate::getCertificateId).collect(Collectors.toList());
|
|
|
+ List<SysCertificateAddition> cetAddList= certadditionService.selectCertificateAdditionByCertIds(cetList);
|
|
|
+
|
|
|
+ for (SysCertificate element : pageinfo.getRecords()) {
|
|
|
+ List<SysCertificateAddition> arraylist=cetAddList.stream().filter(cet->cet.getCertificateId().equals(element.getCertificateId())).collect(Collectors.toList());
|
|
|
+ MajorVo[] majorVos=new MajorVo[arraylist.size()];
|
|
|
+ int i=0;
|
|
|
+ for (SysCertificateAddition m : arraylist) {
|
|
|
+ majorVos[i]=new MajorVo();
|
|
|
+ majorVos[i].setMajorId(m.getMajorId());
|
|
|
+ majorVos[i].setMajorName(m.getMajorName());
|
|
|
+ majorVos[i].setCertificateAdditionId(m.getCertificateAdditionId());
|
|
|
+ majorVos[i].setExpiryDate(m.getExpiryDate());
|
|
|
+ }
|
|
|
+
|
|
|
+ element.setMajorVoList(majorVos);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ info.setTotal(pageinfo.getTotal());
|
|
|
+ info.setRows(pageinfo.getRecords());
|
|
|
+
|
|
|
+ return info;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public TableDataInfo<SysCertificate> selectCertificateList(SysCertificateBo entity) {
|
|
|
if (ObjectUtil.isEmpty(entity.getPageSize()) || entity.getPageSize() < 1) {
|
|
|
@@ -71,7 +139,8 @@ public class SysCertificateServiceImpl extends ServiceImpl<SysCertificateMapper,
|
|
|
entity.setPageNum(1);
|
|
|
}
|
|
|
TableDataInfo<SysCertificate> info = new TableDataInfo<>();
|
|
|
- LambdaQueryWrapper<SysCertificate> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ LambdaQueryWrapper<SysCertificate> queryWrapper = new LambdaQueryWrapper<SysCertificate>();
|
|
|
+
|
|
|
queryWrapper.eq(SysCertificate::getStatus, 1);
|
|
|
if(StringUtils.isNotBlank(entity.getCompanyName())){
|
|
|
SysCompany company = sysCompanyService.selectCompanyByName(entity.getCompanyName(),entity.getUserId());
|
|
|
@@ -125,7 +194,7 @@ public class SysCertificateServiceImpl extends ServiceImpl<SysCertificateMapper,
|
|
|
throw new CustomException("参数未有客户信息");
|
|
|
}
|
|
|
|
|
|
- if(entity.getPersonId()==0&& !StringUtils.isNotBlank(entity.getPersonName())){
|
|
|
+ if(entity.getPersonId()==0&& StringUtils.isNotBlank(entity.getPersonName())){
|
|
|
SysPerson person=new SysPerson();
|
|
|
person.setPersonName(entity.getPersonName());
|
|
|
person.setCompanyId(entity.getCompanyId());
|
|
|
@@ -138,45 +207,85 @@ public class SysCertificateServiceImpl extends ServiceImpl<SysCertificateMapper,
|
|
|
int i_count=0;
|
|
|
SysCertificate info = getOne(new LambdaUpdateWrapper<SysCertificate>().eq(SysCertificate::getPersonId,entity.getPersonId())
|
|
|
.eq(SysCertificate::getStatus,1)
|
|
|
- .eq(SysCertificate::getCertificateTypeId,entity.getCertificateTypeId()));
|
|
|
-
|
|
|
+ .eq(SysCertificate::getCertificateTypeId2,entity.getCertificateTypeId2()));
|
|
|
|
|
|
- boolean ishascert=false;
|
|
|
-
|
|
|
- if(info!=null&&info.getCertificateId()>0){
|
|
|
- ishascert=true;
|
|
|
+ if(info!=null)
|
|
|
+ {
|
|
|
+ entity.setCertificateId(info.getCertificateId());
|
|
|
+ return updateCertificate(entity,entity.getUserId());
|
|
|
}
|
|
|
|
|
|
- for (MajorVo element:entity.getMajorVoList())
|
|
|
+ Long certificateId= 0L;
|
|
|
+ SysCertificateType sysCertificateType2=new SysCertificateType();
|
|
|
+ if(entity.getCertificateTypeId2()>0) {
|
|
|
+ sysCertificateType2 = certTypeSeaService.selectCertificateById(entity.getCertificateTypeId2());
|
|
|
+ }
|
|
|
+ SysCertificateType sysCertificateType=certTypeSeaService.selectCertificateById(entity.getCertificateTypeId());
|
|
|
+ if(info==null)
|
|
|
{
|
|
|
- i_count++;
|
|
|
SysCertificate model = new SysCertificate();
|
|
|
- model.setCreator(entity.getUserId());
|
|
|
- model.setCompanyId(entity.getCompanyId());
|
|
|
- model.setPersonId(entity.getPersonId());
|
|
|
- model.setExpiryDate(entity.getExpiryDate());
|
|
|
- model.setCertificateNumber(entity.getCertificateNumber());
|
|
|
+ model.setCertificateType(entity.getCertificateTypeId());
|
|
|
model.setCertificateName(entity.getCertificateName());
|
|
|
- model.setTenantId(entity.getTenantId());
|
|
|
+ model.setUserId(entity.getUserId());
|
|
|
+ model.setCertificateTypeId2(entity.getCertificateTypeId2());
|
|
|
+ model.setCertificateTypeId( entity.getCertificateTypeId());
|
|
|
+ model.setCertificateNumber(entity.getCertificateNumber());
|
|
|
+ model.setPersonId(entity.getPersonId());
|
|
|
+ model.setCompanyId(entity.getCompanyId());
|
|
|
+ model.setCreator(entity.getUserId());
|
|
|
model.setCreateTime(DateUtils.getNowTime());
|
|
|
model.setStatus(1);
|
|
|
- model.setCertificateType(entity.getCertificateType());
|
|
|
- model.setCertificateTypeId(entity.getCertificateTypeId());
|
|
|
- model.setCertificateTypeId2(entity.getCertificateTypeId2());
|
|
|
- String majorName = element.getMajorName();
|
|
|
- Long majorId = element.getExpiryDate();
|
|
|
- if(i_count==1)
|
|
|
+ if(entity.getMajorId()>0)
|
|
|
{
|
|
|
- if(ishascert)
|
|
|
- {
|
|
|
- model.setIsPrimary(0);
|
|
|
- }else {
|
|
|
- model.setIsPrimary(1);
|
|
|
- }
|
|
|
- }else {
|
|
|
- model.setIsPrimary(0);
|
|
|
+ CertificateMajor major = majorService.selectCertificateMajorById(entity.getMajorId());
|
|
|
+ model.setMajorName(major.getMajorName());
|
|
|
+ }
|
|
|
+ if(sysCertificateType!=null)
|
|
|
+ {
|
|
|
+ model.setCertificateTypeName(sysCertificateType.getCertificateTypeName());
|
|
|
+ }
|
|
|
+ if(sysCertificateType2!=null) {
|
|
|
+ model.setCertificateTypeName2(sysCertificateType2.getCertificateTypeName());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ save(model);
|
|
|
+ certificateId=model.getCertificateId();
|
|
|
+ }else {
|
|
|
+ certificateId=info.getCertificateId();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ boolean ishascert=false;
|
|
|
+
|
|
|
+ if(info!=null&&info.getCertificateId()>0){
|
|
|
+ ishascert=true;
|
|
|
+ }
|
|
|
+
|
|
|
+ boolean b = sysCertificateType!=null&& sysCertificateType.getMajorType() == 0;
|
|
|
+ if(b) {
|
|
|
+ SysCertificateBo certModel = new SysCertificateBo();
|
|
|
+ certModel.setUserId(entity.getUserId());
|
|
|
+ certModel.setCompanyId(entity.getCompanyId());
|
|
|
+ certModel.setCertificateId(entity.getCertificateId());
|
|
|
+ certModel.setIsHasMajor(0);
|
|
|
+ certadditionService.updateCertificateAddition(certModel, entity.getUserId());
|
|
|
+ count++;
|
|
|
+
|
|
|
+ }else {
|
|
|
+
|
|
|
+ for (MajorVo element : entity.getMajorVoList()) {
|
|
|
+ SysCertificateBo certModel = new SysCertificateBo();
|
|
|
+ certModel.setUserId(entity.getUserId());
|
|
|
+ certModel.setIsHasMajor(1);
|
|
|
+ certModel.setCompanyId(entity.getCompanyId());
|
|
|
+ certModel.setCertificateId(certificateId);
|
|
|
+ certModel.setExpiryDate(element.getExpiryDate());
|
|
|
+ certModel.setMajorId(element.getMajorId());
|
|
|
+ certModel.setMajorName(element.getMajorName());
|
|
|
+ certadditionService.updateCertificateAddition(certModel, entity.getUserId());
|
|
|
+ count++;
|
|
|
}
|
|
|
- count=count+ certMapper.insert (model);
|
|
|
}
|
|
|
|
|
|
return count;
|
|
|
@@ -200,33 +309,69 @@ public class SysCertificateServiceImpl extends ServiceImpl<SysCertificateMapper,
|
|
|
entity.setPersonId(person.getPersonId());
|
|
|
|
|
|
}
|
|
|
- int count = 0;
|
|
|
- int i_count=0;
|
|
|
- for (MajorVo element:entity.getMajorVoList())
|
|
|
+
|
|
|
+ SysCertificate model = new SysCertificate();
|
|
|
+ model.setCertificateType(entity.getCertificateTypeId());
|
|
|
+ model.setCertificateName(entity.getCertificateName());
|
|
|
+ model.setUserId(entity.getUserId());
|
|
|
+
|
|
|
+ model.setCertificateTypeId2(entity.getCertificateTypeId2());
|
|
|
+ model.setCertificateTypeId( entity.getCertificateTypeId());
|
|
|
+ model.setCertificateNumber(entity.getCertificateNumber());
|
|
|
+ model.setPersonId(entity.getPersonId());
|
|
|
+ model.setCompanyId(entity.getCompanyId());
|
|
|
+ model.setCreator(entity.getUserId());
|
|
|
+ model.setCreateTime(DateUtils.getNowTime());
|
|
|
+ model.setStatus(1);
|
|
|
+ SysCertificateType sysCertificateType=certTypeSeaService.selectCertificateById(entity.getCertificateTypeId());
|
|
|
+ SysCertificateType sysCertificateType2=new SysCertificateType();
|
|
|
+ if(entity.getCertificateTypeId2()>0) {
|
|
|
+ sysCertificateType2 = certTypeSeaService.selectCertificateById(entity.getCertificateTypeId2());
|
|
|
+ }
|
|
|
+ if(sysCertificateType!=null)
|
|
|
{
|
|
|
- i_count++;
|
|
|
- SysCertificate model = new SysCertificate();
|
|
|
-// model.setCertificateId(element.getCertificateId());
|
|
|
- model.setCreator(entity.getUserId());
|
|
|
- model.setCompanyId(entity.getCompanyId());
|
|
|
- model.setPersonId(entity.getPersonId());
|
|
|
- model.setExpiryDate(entity.getExpiryDate());
|
|
|
- model.setCertificateNumber(entity.getCertificateNumber());
|
|
|
- model.setCertificateName(entity.getCertificateName());
|
|
|
- model.setTenantId(entity.getTenantId());
|
|
|
- model.setCreateTime(DateUtils.getNowTime());
|
|
|
- model.setStatus(1);
|
|
|
- model.setCertificateType(entity.getCertificateType());
|
|
|
- model.setCertificateTypeId(entity.getCertificateTypeId());
|
|
|
- model.setCertificateTypeId2(entity.getCertificateTypeId2());
|
|
|
- String majorName = element.getMajorName();
|
|
|
- Long majorId = element.getExpiryDate();
|
|
|
- if(model.getCertificateId()>0) {
|
|
|
- count = count + certMapper.updateById(model);
|
|
|
- }else {
|
|
|
- model.setIsPrimary(0);
|
|
|
- count = count + certMapper.insert(model);
|
|
|
+ model.setCertificateTypeName(sysCertificateType.getCertificateTypeName());
|
|
|
+ }
|
|
|
+ if(sysCertificateType2!=null) {
|
|
|
+ model.setCertificateTypeName2(sysCertificateType2.getCertificateTypeName());
|
|
|
+ }
|
|
|
|
|
|
+ if(entity.getMajorId()>0)
|
|
|
+ {
|
|
|
+ CertificateMajor major = majorService.selectCertificateMajorById(entity.getMajorId());
|
|
|
+ model.setMajorName(major.getMajorName());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ update(model, new LambdaQueryWrapper<SysCertificate>().eq(SysCertificate::getCertificateId,entity.getCertificateId()));
|
|
|
+ int count = 0;
|
|
|
+ int i_count=0;
|
|
|
+ boolean b = sysCertificateType!=null&& sysCertificateType.getMajorType() == 0;
|
|
|
+ if(b) {
|
|
|
+ SysCertificateBo certModel = new SysCertificateBo();
|
|
|
+ certModel.setUserId(entity.getUserId());
|
|
|
+ certModel.setCompanyId(entity.getCompanyId());
|
|
|
+ certModel.setCertificateId(entity.getCertificateId());
|
|
|
+ certModel.setIsHasMajor(0);
|
|
|
+ certadditionService.updateCertificateAddition(certModel, entity.getUserId());
|
|
|
+ count++;
|
|
|
+
|
|
|
+ }else {
|
|
|
+
|
|
|
+
|
|
|
+ for (MajorVo element : entity.getMajorVoList()) {
|
|
|
+
|
|
|
+ SysCertificateBo certModel = new SysCertificateBo();
|
|
|
+ certModel.setUserId(entity.getUserId());
|
|
|
+ certModel.setIsHasMajor(1);
|
|
|
+ certModel.setCompanyId(entity.getCompanyId());
|
|
|
+ certModel.setCertificateId(entity.getCertificateId());
|
|
|
+ certModel.setExpiryDate(element.getExpiryDate());
|
|
|
+ certModel.setMajorId(element.getMajorId());
|
|
|
+ certModel.setMajorName(element.getMajorName());
|
|
|
+ certModel.setCertificateAdditionId(element.getCertificateAdditionId());
|
|
|
+ certadditionService.updateCertificateAddition(certModel, entity.getUserId());
|
|
|
+ count++;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -235,6 +380,23 @@ public class SysCertificateServiceImpl extends ServiceImpl<SysCertificateMapper,
|
|
|
|
|
|
@Override
|
|
|
public boolean deleteCertificateById(Long id, long userid) {
|
|
|
+
|
|
|
+ SysCertificate cert=certMapper.selectById(id);
|
|
|
+ SysCompany sysCompany=sysCompanyService.getById(cert.getCompanyId());
|
|
|
+ if(sysCompany.getUserId()!=userid)
|
|
|
+ {
|
|
|
+ throw new CustomException("非法操作,当前客户不是属于您的");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<SysCertificateAddition> list=certadditionService.selectCertificateAdditionByCertId(id);
|
|
|
+ if(!list.isEmpty())
|
|
|
+ {
|
|
|
+ for (SysCertificateAddition element:list)
|
|
|
+ {
|
|
|
+ certadditionService.deleteCertificateAdditionById(element.getCertificateAdditionId(),userid);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
SysCertificate model = new SysCertificate();
|
|
|
model.setCertificateId(id);
|
|
|
model.setStatus(-1);
|