heweichun 1 день назад
Родитель
Сommit
faed4e67ce

+ 6 - 1
src/main/java/com/zhongzheng/bo/SysCertificateBo.java

@@ -84,13 +84,18 @@ public class SysCertificateBo
     @ApiModelProperty("身份证")
     private String idCard;
 
+    @ApiModelProperty("1主项,0增项")
+    private Integer isPrimary;
+
+
+
     @ApiModelProperty("分页大小")
     private Integer pageSize;
     /** 当前页数 */
     @ApiModelProperty("当前页数")
     private Integer pageNum;
 
-    @ApiModelProperty("证书类型 1个人,2企业")
+    @ApiModelProperty("证书类型 1企业安全生产许可证书,2员工证书,3企业资质")
     private Integer certificateType;
 
 

+ 136 - 0
src/main/java/com/zhongzheng/common/filter/GlobalExceptionHandler.java

@@ -0,0 +1,136 @@
+package com.zhongzheng.common.filter;
+
+import cn.hutool.core.lang.Validator;
+import cn.hutool.http.HttpStatus;
+import com.zhongzheng.common.model.AjaxResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.dao.DataAccessException;
+import org.springframework.security.access.AccessDeniedException;
+import org.springframework.security.authentication.AccountExpiredException;
+import org.springframework.security.core.userdetails.UsernameNotFoundException;
+import org.springframework.validation.BindException;
+import org.springframework.web.bind.MethodArgumentNotValidException;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.RestControllerAdvice;
+import org.springframework.web.servlet.NoHandlerFoundException;
+
+import javax.validation.ConstraintViolationException;
+import java.sql.SQLException;
+
+/**
+ * 全局异常处理器
+ *
+ * @author zhongzheng
+ */
+@RestControllerAdvice
+public class GlobalExceptionHandler
+{
+    private static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class);
+
+    /**
+     * 基础异常
+     */
+    @ExceptionHandler(BaseException.class)
+    public AjaxResult baseException(BaseException e)
+    {
+        return AjaxResult.error(e.getMessage());
+    }
+
+    /**
+     * 业务异常
+     */
+    @ExceptionHandler(CustomException.class)
+    public AjaxResult businessException(CustomException e)
+    {
+        if (Validator.isNull(e.getCode()))
+        {
+            return AjaxResult.error(e.getMessage());
+        }
+        return AjaxResult.error(e.getCode(), e.getMessage());
+    }
+
+    /**
+     * sql错误
+     */
+    @ExceptionHandler({SQLException.class, DataAccessException.class})
+    public AjaxResult handleAllSqlExceptions(Exception e)
+    {
+        log.error(e.getMessage(), e);
+        return AjaxResult.error(HttpStatus.HTTP_INTERNAL_ERROR, "非法操作,请稍后再试");
+    }
+
+    @ExceptionHandler(NoHandlerFoundException.class)
+    public AjaxResult handlerNoFoundException(Exception e)
+    {
+        log.error(e.getMessage(), e);
+        return AjaxResult.error(HttpStatus.HTTP_NOT_FOUND, "路径不存在,请检查路径是否正确");
+    }
+
+    @ExceptionHandler(AccessDeniedException.class)
+    public AjaxResult handleAuthorizationException(AccessDeniedException e)
+    {
+        log.error(e.getMessage());
+        if("用户验证错误".equals(e.getMessage())){
+            return AjaxResult.error(HttpStatus.HTTP_UNAUTHORIZED, "用户验证错误");
+        }else{
+            return AjaxResult.error(HttpStatus.HTTP_FORBIDDEN, "没有权限,请联系管理员授权");
+        }
+
+    }
+
+    @ExceptionHandler(AccountExpiredException.class)
+    public AjaxResult handleAccountExpiredException(AccountExpiredException e)
+    {
+        log.error(e.getMessage(), e);
+        return AjaxResult.error(e.getMessage());
+    }
+
+    @ExceptionHandler(UsernameNotFoundException.class)
+    public AjaxResult handleUsernameNotFoundException(UsernameNotFoundException e)
+    {
+        log.error(e.getMessage(), e);
+        return AjaxResult.error(e.getMessage());
+    }
+
+    @ExceptionHandler(Exception.class)
+    public AjaxResult handleException(Exception e)
+    {
+        log.error(e.getMessage(), e);
+        return AjaxResult.error(e.getMessage());
+    }
+
+
+    /**
+     * 自定义验证异常
+     */
+    @ExceptionHandler(BindException.class)
+    public AjaxResult validatedBindException(BindException e)
+    {
+        log.error(e.getMessage(), e);
+        String message = e.getAllErrors().get(0).getDefaultMessage();
+        return AjaxResult.error(message);
+    }
+
+    /**
+     * 自定义验证异常
+     */
+    @ExceptionHandler(ConstraintViolationException.class)
+    public AjaxResult constraintViolationException(ConstraintViolationException e) {
+        log.error(e.getMessage(), e);
+        String message = e.getConstraintViolations().iterator().next().getMessage();
+        return AjaxResult.error(message);
+    }
+
+    /**
+     * 自定义验证异常
+     */
+    @ExceptionHandler(MethodArgumentNotValidException.class)
+    public Object validExceptionHandler(MethodArgumentNotValidException e)
+    {
+        log.error(e.getMessage(), e);
+        String message = e.getBindingResult().getFieldError().getDefaultMessage();
+        return AjaxResult.error(message);
+    }
+
+}

+ 2 - 0
src/main/java/com/zhongzheng/common/util/DateUtils.java

@@ -749,4 +749,6 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
         return map;
     }
 
+
+
 }

+ 60 - 31
src/main/java/com/zhongzheng/controller/SysCompanyController.java

@@ -35,8 +35,7 @@ import static net.sf.jsqlparser.util.validation.metadata.NamedObject.user;
 @Api(tags ="我的客户管理")
 @RestController
 @RequestMapping("/system/company")
-public class SysCompanyController extends BaseController
-{
+public class SysCompanyController extends BaseController {
     @Autowired
     private ISysCompanyService companyService;
     @Autowired
@@ -57,6 +56,8 @@ public class SysCompanyController extends BaseController
     @Autowired
     private ISysCertificateTypeService typeService;
 
+    @Autowired
+    private ISysCertificateAdditionService additionService;
 
 
     @ApiOperation("客户列表")
@@ -78,10 +79,10 @@ public class SysCompanyController extends BaseController
 
         company.setSource("自有");
         SysCustomerSea sea = seaService.selectCustomerSeaByName(company.getCompanyName());
-        if(sea!=null){
+        if (sea != null) {
             throw new CustomException("企业已存在公海中,请直接在公海中领取!");
         }
-        return toAjax(companyService.insertCompany(company)>0?1:0);
+        return toAjax(companyService.insertCompany(company) > 0 ? 1 : 0);
     }
 
     @ApiOperation("编辑企业")
@@ -92,7 +93,7 @@ public class SysCompanyController extends BaseController
         Long userId = loginUser.getUser().getUserId();
         company.setUserId(userId);
         company.setSource("自有");
-        return toAjax(companyService.updateCompany(company,company.getUserId()));
+        return toAjax(companyService.updateCompany(company, company.getUserId()));
     }
 
     @ApiOperation("删除人")
@@ -101,7 +102,7 @@ public class SysCompanyController extends BaseController
 
         LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
         Long userId = loginUser.getUser().getUserId();
-        return toAjax(companyService.deleteCompanyById(entity.getCompanyId(),userId));
+        return toAjax(companyService.deleteCompanyById(entity.getCompanyId(), userId));
     }
 
     @ApiOperation("客户联系人列表")
@@ -117,13 +118,13 @@ public class SysCompanyController extends BaseController
         LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
         Long userId = loginUser.getUser().getUserId();
         entity.setUserId(userId);
-        return toAjax(companyContactsService.insertSysCompanyContacts(entity)>0?1:0);
+        return toAjax(companyContactsService.insertSysCompanyContacts(entity) > 0 ? 1 : 0);
     }
 
     @ApiOperation("编辑企业联系人")
     @PostMapping("/contact/edit")
     public AjaxResult contact_edit(@Validated @RequestBody SysCompanyContacts entity) {
-        return toAjax(companyContactsService.updateSysCompanyContacts(entity)>0?1:0);
+        return toAjax(companyContactsService.updateSysCompanyContacts(entity) > 0 ? 1 : 0);
     }
 
     @ApiOperation("删除企业联系人")
@@ -146,7 +147,7 @@ public class SysCompanyController extends BaseController
         LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
         Long userId = loginUser.getUser().getUserId();
         entity.setCreator(userId);
-        return toAjax(personService.insertPerson(entity)>0?1:0);
+        return toAjax(personService.insertPerson(entity) > 0 ? 1 : 0);
     }
 
     @ApiOperation("编辑企业员工")
@@ -155,7 +156,7 @@ public class SysCompanyController extends BaseController
         LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
         Long userId = loginUser.getUser().getUserId();
 
-        return toAjax(personService.updatePerson(entity,userId)>0?1:0);
+        return toAjax(personService.updatePerson(entity, userId) > 0 ? 1 : 0);
     }
 
     @ApiOperation("删除企业员工")
@@ -164,12 +165,12 @@ public class SysCompanyController extends BaseController
 
         LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
         Long userId = loginUser.getUser().getUserId();
-        return toAjax(personService.deletePersonById(entity.getPersonId(),userId));
+        return toAjax(personService.deletePersonById(entity.getPersonId(), userId));
     }
 
     @ApiOperation("员工证书列表")
     @GetMapping("/cert/list")
-    public TableDataInfo<SysCertificate>  cert_list(SysCertificateBo model) {
+    public TableDataInfo<SysCertificate> cert_list(SysCertificateBo model) {
 
         LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
         model.setUserId(loginUser.getUser().getUserId());
@@ -179,7 +180,7 @@ public class SysCompanyController extends BaseController
 
     @ApiOperation("企业安全生产许可证书列表")
     @GetMapping("/cert/safetyList")
-    public TableDataInfo<SysCertificate>  cert_safety_license_list(SysCertificateBo model) {
+    public TableDataInfo<SysCertificate> cert_safety_license_list(SysCertificateBo model) {
 
         LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
         model.setUserId(loginUser.getUser().getUserId());
@@ -187,9 +188,10 @@ public class SysCompanyController extends BaseController
         //model.setUserId(1L);
         return certService.selectEnterpriseCerList(model);
     }
+
     @ApiOperation("企业资质证书列表")
     @GetMapping("/cert/qualificationList")
-    public TableDataInfo<SysCertificate>  cert_qualification_list(SysCertificateBo model) {
+    public TableDataInfo<SysCertificate> cert_qualification_list(SysCertificateBo model) {
         LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
         model.setUserId(loginUser.getUser().getUserId());
         model.setCertificateTypeId(3);
@@ -200,10 +202,10 @@ public class SysCompanyController extends BaseController
 
     @ApiOperation("添加证书")
     @PostMapping("/cert/add")
-    public AjaxResult cert_add(@Validated @RequestBody SysCertificateBo model) {
+    public AjaxResult cert_add(@RequestBody SysCertificateBo model) {
         LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
         model.setUserId(loginUser.getUser().getUserId());
-        return toAjax(certService.insertCertificate(model)>0?1:0);
+        return toAjax(certService.insertCertificate(model) > 0 ? 1 : 0);
     }
 
     @ApiOperation("编辑证书")
@@ -211,7 +213,7 @@ public class SysCompanyController extends BaseController
     public AjaxResult cert_edit(@Validated @RequestBody SysCertificateBo model) {
         LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
         model.setUserId(loginUser.getUser().getUserId());
-        return toAjax(certService.updateCertificate(model,model.getUserId()));
+        return toAjax(certService.updateCertificate(model, model.getUserId()));
     }
 
     @ApiOperation("删除证书")
@@ -219,39 +221,66 @@ public class SysCompanyController extends BaseController
     public AjaxResult cert_del(@Validated @RequestBody SysCertificateBo model) {
         LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
         model.setUserId(loginUser.getUser().getUserId());
-        return toAjax(certService.deleteCertificateById(model.getCertificateId(),model.getUserId()));
+        return toAjax(certService.deleteCertificateById(model.getCertificateId(), model.getUserId()));
     }
+
     @ApiOperation("获取证书类型列表 parentId=2 个人证书")
     @GetMapping("/cert/certificate_type_list")
-    public TableDataInfo<SysCertificateType>  certificate_type_list(Integer parentId) {
+    public TableDataInfo<SysCertificateType> certificate_type_list(Integer parentId) {
 
         return typeService.selectCertificateTypeListByCode(parentId);
     }
 
 
+    @ApiOperation("获取专业列表")
+    @GetMapping("/cert/major_list")
+    public TableDataInfo<CertificateMajor> cert_major_list(Integer certificateTypeId) {
 
-@ApiOperation("获取专业列表")
-@GetMapping("/cert/major_list")
-public TableDataInfo<CertificateMajor>  cert_major_list(Integer certificateTypeId) {
+        return majorService.selectCertificateMajorList(certificateTypeId);
+    }
 
-    return majorService.selectCertificateMajorList(certificateTypeId);
-}
 
+    @ApiOperation("员工证书预警列表")
+    @GetMapping("/cert/personWarningList")
+    public TableDataInfo<SysCertificate> cert_person_warning_list(SysCertificateBo model) {
 
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        model.setUserId(loginUser.getUser().getUserId());
+        //model.setUserId(1L);
+        model.setWarningState(1);
+        return certService.selectList(model);
+    }
 
-    @ApiOperation("证书预警列表")
-    @GetMapping("/cert/warningList")
-    public TableDataInfo<SysCertificate>  cert_warning_list(SysCertificateBo model) {
+    @ApiOperation("企业安全生产许可证书预警列表")
+    @GetMapping("/cert/safetyWarningList")
+    public TableDataInfo<SysCertificate> cert_safety_warning_list(SysCertificateBo model) {
 
-        //LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
-        //model.setUserId(loginUser.getUser().getUserId());
-        model.setUserId(1L);
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        model.setUserId(loginUser.getUser().getUserId());
+        model.setCertificateTypeId(1);
         model.setWarningState(1);
-        return certService.selectList(model);
+        //model.setUserId(1L);
+        return certService.selectEnterpriseCerList(model);
     }
 
+    @ApiOperation("企业资质预警列表")
+    @GetMapping("/cert/qualificationWarningList")
+    public TableDataInfo<SysCertificate> cert_qualification_warning_list(SysCertificateBo model) {
 
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        model.setUserId(loginUser.getUser().getUserId());
+        model.setCertificateTypeId(3);
+        model.setWarningState(1);
+        //model.setUserId(1L);
+        return certService.selectEnterpriseCerList(model);
+    }
 
+    @ApiOperation("删除证书增项")
+    @GetMapping("/cert/addition_del/{id}")
+    public AjaxResult cert_addition_del(@PathVariable("id") Long id) {
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        return toAjax(additionService.deleteCertificateAdditionById(id, loginUser.getUser().getUserId()));
+    }
 
 
 

+ 4 - 0
src/main/java/com/zhongzheng/domian/SysCompany.java

@@ -88,6 +88,10 @@ public class SysCompany implements Serializable
     private  String customerStatus;
 
 
+    /** 所属于行业  */
+    private  String industry;
+
+
 
     /** 0未成交,1已成交 */
     private Integer tradedType;

+ 6 - 1
src/main/java/com/zhongzheng/domian/SysPerson.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
+import com.zhongzheng.common.util.EncryptHandler;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.NoArgsConstructor;
@@ -62,15 +63,16 @@ public class SysPerson implements Serializable
      * 出生日期
      */
     private long birthDate;
-
     /**
      * 身份证号
      */
+    @TableField(typeHandler = EncryptHandler.class)
     private String idCard;
 
     /**
      * 联系电话
      */
+    @TableField(typeHandler = EncryptHandler.class)
     private String phone;
 
     /**
@@ -145,6 +147,9 @@ public class SysPerson implements Serializable
 
 
 
+
+
+
     /** 分页大小 */
     @ApiModelProperty("分页大小")
     @TableField(exist = false)

+ 4 - 0
src/main/java/com/zhongzheng/service/ISysCertificateService.java

@@ -44,6 +44,10 @@ public interface ISysCertificateService extends IService<SysCertificate> {
 
     public boolean deleteCertificateById(Long id, long userid);
 
+    public  void  CertificateWarning();
+
+
+
 
 
 

+ 4 - 0
src/main/java/com/zhongzheng/service/impl/SysCertificateAdditionServiceImpl.java

@@ -86,6 +86,7 @@ public class SysCertificateAdditionServiceImpl extends ServiceImpl<SysCertificat
         model.setCreateTime(DateUtils.getNowTime());
         model.setStatus(1);
         model.setMajorId(entity.getMajorId());
+
         model.setMajorName(entity.getMajorName());
         model.setCertificateAdditionId(entity.getCertificateAdditionId());
         String majorName = entity.getMajorName();
@@ -101,6 +102,9 @@ public class SysCertificateAdditionServiceImpl extends ServiceImpl<SysCertificat
             if(p==null){
 
                 certAddMapper.insert(model);
+            }else {
+                model.setCertificateAdditionId(p.getCertificateAdditionId());
+                certAddMapper.updateById(model);
             }
         }
     }

+ 113 - 37
src/main/java/com/zhongzheng/service/impl/SysCertificateServiceImpl.java

@@ -12,6 +12,7 @@ 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.common.util.EncryptHandler;
 import com.zhongzheng.domian.*;
 import com.zhongzheng.mapper.SysCertificateMapper;
 import com.zhongzheng.mapper.SysPersonMapper;
@@ -109,6 +110,16 @@ public class SysCertificateServiceImpl extends ServiceImpl<SysCertificateMapper,
                 List<SysCertificateAddition> arraylist=cetAddList.stream().filter(cet->cet.getCertificateId().equals(element.getCertificateId())).collect(Collectors.toList());
                 MajorVo[] majorVos=new MajorVo[arraylist.size()];
                 int i=0;
+                try {
+                    if (StringUtils.isNotBlank(element.getIdCard())) {
+                        element.setIdCard(EncryptHandler.decrypt(element.getIdCard()));
+                    }
+                    if (StringUtils.isNotBlank(element.getPhone())) {
+                        element.setPhone(EncryptHandler.decrypt(element.getPhone()));
+                    }
+                } catch (Exception e) {
+                    /// throw new RuntimeException(e);
+                }
                 for (SysCertificateAddition m : arraylist) {
                     majorVos[i]=new MajorVo();
                     majorVos[i].setMajorId(m.getMajorId());
@@ -173,6 +184,18 @@ public class SysCertificateServiceImpl extends ServiceImpl<SysCertificateMapper,
         }
 
         Page<SysCertificate> page = page(new Page<>(entity.getPageNum(), entity.getPageSize()),queryWrapper );
+        page.getRecords().forEach(element -> {
+            try {
+                if (StringUtils.isNotBlank(element.getIdCard())) {
+                    element.setIdCard(EncryptHandler.decrypt(element.getIdCard()));
+                }
+                if (StringUtils.isNotBlank(element.getPhone())) {
+                    element.setPhone(EncryptHandler.decrypt(element.getPhone()));
+                }
+            } catch (Exception e) {
+               /// throw new RuntimeException(e);
+            }
+        });
         info.setRows(page.getRecords());
         info.setTotal(page.getTotal());
         info.setCode(HttpStatus.HTTP_OK);
@@ -233,32 +256,42 @@ public class SysCertificateServiceImpl extends ServiceImpl<SysCertificateMapper,
 
     @Override
     public long insertCertificate(SysCertificateBo entity) {
-        if(entity.getPersonId()==0&&entity.getPersonName().isEmpty()){
-            throw new CustomException("参数未有企业员工信息");
-        }
-        if(entity.getCompanyId()==0&&entity.getCompanyName().isEmpty()){
-            throw new CustomException("参数未有客户信息");
-        }
+        if(entity.getCertificateType()==2) {
+            if (entity.getPersonId() == 0 && entity.getPersonName().isEmpty()) {
+                throw new CustomException("参数未有企业员工信息");
+            }
+            if (entity.getCompanyId() == 0 && entity.getCompanyName().isEmpty()) {
+                throw new CustomException("参数未有客户信息");
+            }
+
 
-        if(entity.getPersonId()==0&& StringUtils.isNotBlank(entity.getPersonName())){
-            SysPerson person=new SysPerson();
-            person.setPersonName(entity.getPersonName());
-            person.setCompanyId(entity.getCompanyId());
-            person.setCreator(entity.getUserId());
-            sysPersonService.getPersonByNameAndNoInert(person);
-            entity.setPersonId(person.getPersonId());
+            if (entity.getPersonId() == 0 && StringUtils.isNotBlank(entity.getPersonName())) {
+                SysPerson person = new SysPerson();
+                person.setPersonName(entity.getPersonName());
+                person.setCompanyId(entity.getCompanyId());
+                person.setCreator(entity.getUserId());
+                sysPersonService.getPersonByNameAndNoInert(person);
+                entity.setPersonId(person.getPersonId());
 
+            }
         }
         int count = 0;
         int i_count=0;
-        SysCertificate info = getOne(new LambdaUpdateWrapper<SysCertificate>().eq(SysCertificate::getPersonId,entity.getPersonId())
-                .eq(SysCertificate::getStatus,1)
-                .eq(SysCertificate::getCertificateTypeId2,entity.getCertificateTypeId2()));
+        SysCertificate info =null;
+        if(entity.getCertificateType()==2) {
+            info = getOne(new LambdaUpdateWrapper<SysCertificate>().eq(SysCertificate::getPersonId, entity.getPersonId())
+                    .eq(SysCertificate::getStatus, 1)
+                    .eq(SysCertificate::getCertificateTypeId2, entity.getCertificateTypeId2()));
+        }else {
+            info = getOne(new LambdaUpdateWrapper<SysCertificate>().eq(SysCertificate::getCompanyId, entity.getCompanyId())
+                    .eq(SysCertificate::getStatus, 1)
+                    .eq(SysCertificate::getCertificateTypeId2, entity.getCertificateTypeId2()));
+        }
 
-        if(info!=null)
-        {
+
+        if(info!=null&&entity.getCertificateType()==2) {
             entity.setCertificateId(info.getCertificateId());
-           return updateCertificate(entity,entity.getUserId());
+            return updateCertificate(entity, entity.getUserId());
         }
 
         Long certificateId= 0L;
@@ -280,6 +313,9 @@ public class SysCertificateServiceImpl extends ServiceImpl<SysCertificateMapper,
             model.setCompanyId(entity.getCompanyId());
             model.setCreator(entity.getUserId());
             model.setCreateTime(DateUtils.getNowTime());
+            model.setIssuerName(entity.getIssuerName());
+            model.setIssueDate(entity.getIssueDate());
+            model.setIsPrimary(entity.getIsPrimary());
             model.setStatus(1);
             if(entity.getMajorId()>0)
             {
@@ -293,11 +329,13 @@ public class SysCertificateServiceImpl extends ServiceImpl<SysCertificateMapper,
             if(sysCertificateType2!=null) {
                 model.setCertificateTypeName2(sysCertificateType2.getCertificateTypeName());
             }
-
-
             save(model);
             certificateId=model.getCertificateId();
         }else {
+            if(entity.getCertificateType()!=2)
+            {
+                throw new CustomException("证书已存在!");
+            }
             certificateId=info.getCertificateId();
         }
 
@@ -313,7 +351,8 @@ public class SysCertificateServiceImpl extends ServiceImpl<SysCertificateMapper,
             SysCertificateBo certModel = new SysCertificateBo();
             certModel.setUserId(entity.getUserId());
             certModel.setCompanyId(entity.getCompanyId());
-            certModel.setCertificateId(entity.getCertificateId());
+            certModel.setCertificateId(certificateId);
+            certModel.setExpiryDate(entity.getExpiryDate());
             certModel.setIsHasMajor(0);
             certadditionService.updateCertificateAddition(certModel, entity.getUserId());
             count++;
@@ -328,7 +367,8 @@ public class SysCertificateServiceImpl extends ServiceImpl<SysCertificateMapper,
                 certModel.setCertificateId(certificateId);
                 certModel.setExpiryDate(element.getExpiryDate());
                 certModel.setMajorId(element.getMajorId());
-                certModel.setMajorName(element.getMajorName());
+               CertificateMajor major= majorService.selectCertificateMajorById(element.getMajorId());
+                certModel.setMajorName(major.getMajorName());
                 certadditionService.updateCertificateAddition(certModel, entity.getUserId());
                 count++;
             }
@@ -339,23 +379,26 @@ public class SysCertificateServiceImpl extends ServiceImpl<SysCertificateMapper,
 
     @Override
     public int updateCertificate(SysCertificateBo entity, long userid) {
-        if(entity.getPersonId()==0&&entity.getPersonName().isEmpty()){
-            throw new CustomException("参数未有企业员工信息");
-        }
-        if(entity.getCompanyId()==0&&entity.getCompanyName().isEmpty()){
-            throw new CustomException("参数未有客户信息");
-        }
+        if(entity.getCertificateType()==2) {
+            if (entity.getPersonId() == 0 && entity.getPersonName().isEmpty()) {
+                throw new CustomException("参数未有企业员工信息");
+            }
+            if (entity.getCompanyId() == 0 && entity.getCompanyName().isEmpty()) {
+                throw new CustomException("参数未有客户信息");
+            }
+            if(entity.getPersonId()==0&& !StringUtils.isNotBlank(entity.getPersonName())){
+                SysPerson person=new SysPerson();
+                person.setPersonName(entity.getPersonName());
+                person.setCompanyId(entity.getCompanyId());
+                person.setCreator(entity.getUserId());
+                sysPersonService.getPersonByNameAndNoInert(person);
+                entity.setPersonId(person.getPersonId());
 
-        if(entity.getPersonId()==0&& !StringUtils.isNotBlank(entity.getPersonName())){
-            SysPerson person=new SysPerson();
-            person.setPersonName(entity.getPersonName());
-            person.setCompanyId(entity.getCompanyId());
-            person.setCreator(entity.getUserId());
-            sysPersonService.getPersonByNameAndNoInert(person);
-            entity.setPersonId(person.getPersonId());
+            }
 
         }
 
+
         SysCertificate model = new SysCertificate();
         model.setCertificateType(entity.getCertificateTypeId());
         model.setCertificateName(entity.getCertificateName());
@@ -368,6 +411,9 @@ public class SysCertificateServiceImpl extends ServiceImpl<SysCertificateMapper,
         model.setCompanyId(entity.getCompanyId());
         model.setCreator(entity.getUserId());
         model.setCreateTime(DateUtils.getNowTime());
+        model.setIssuerName(entity.getIssuerName());
+        model.setIssueDate(entity.getIssueDate());
+        model.setIsPrimary(entity.getIsPrimary());
         model.setStatus(1);
         SysCertificateType sysCertificateType=certTypeSeaService.selectCertificateById(entity.getCertificateTypeId());
         SysCertificateType sysCertificateType2=new SysCertificateType();
@@ -398,6 +444,7 @@ public class SysCertificateServiceImpl extends ServiceImpl<SysCertificateMapper,
             certModel.setUserId(entity.getUserId());
             certModel.setCompanyId(entity.getCompanyId());
             certModel.setCertificateId(entity.getCertificateId());
+            certModel.setExpiryDate(entity.getExpiryDate());
             certModel.setIsHasMajor(0);
             certadditionService.updateCertificateAddition(certModel, entity.getUserId());
             count++;
@@ -414,7 +461,8 @@ public class SysCertificateServiceImpl extends ServiceImpl<SysCertificateMapper,
                 certModel.setCertificateId(entity.getCertificateId());
                 certModel.setExpiryDate(element.getExpiryDate());
                 certModel.setMajorId(element.getMajorId());
-                certModel.setMajorName(element.getMajorName());
+                CertificateMajor major= majorService.selectCertificateMajorById(element.getMajorId());
+                certModel.setMajorName(major.getMajorName());
                 certModel.setCertificateAdditionId(element.getCertificateAdditionId());
                 certadditionService.updateCertificateAddition(certModel, entity.getUserId());
                 count++;
@@ -450,4 +498,32 @@ public class SysCertificateServiceImpl extends ServiceImpl<SysCertificateMapper,
         model.setUpdateTime(DateUtils.getNowTime());
         return certMapper.updateById(model)>0;
     }
+
+    @Override
+    public void CertificateWarning() {
+        SysCertificateBo entity= new SysCertificateBo();
+        entity.setWarningState(2);
+        TableDataInfo<SysCertificate> info =  selectList(entity);
+
+        List<SysCertificateType> sysCertificateTypeList=certTypeSeaService.list(new LambdaQueryWrapper<SysCertificateType>().eq(SysCertificateType::getStatus,1));
+        info.getRows().forEach(cert->{
+            SysCertificateType certType=sysCertificateTypeList.stream().filter(s->s.getCertificateTypeId().equals(cert.getCertificateTypeId())).findFirst().orElse(null);
+            if(certType!=null)
+            {
+                if(certType.getWarningTime()>0)
+                {
+
+                   if(cert.getExpiryDate()>0&&cert.getExpiryDate()<DateUtils.getDayAfter(System.currentTimeMillis(),certType.getWarningTime())  )
+                   {
+
+                       cert.setWarningState(1);
+                       cert.setWarningTime(System.currentTimeMillis());
+
+                   }
+                }
+            }
+        });
+
+
+    }
 }

+ 19 - 3
src/main/java/com/zhongzheng/service/impl/SysPersonServiceImpl.java

@@ -51,7 +51,9 @@ public class SysPersonServiceImpl extends ServiceImpl<SysPersonMapper, SysPerson
         if(StringUtils.isBlank(entity.getIdCard())){
             return false;
         }
-        SysPerson info = getOne(new LambdaUpdateWrapper<SysPerson>().eq(SysPerson::getIdCard,entity.getIdCard())
+
+        String idcard=EncryptHandler.encrypt(entity.getIdCard());
+        SysPerson info = getOne(new LambdaUpdateWrapper<SysPerson>().eq(SysPerson::getIdCard,idcard)
                 .eq(SysPerson::getStatus,1)
                 .eq(SysPerson::getCompanyId,entity.getCompanyId()));
         if (Validator.isNotNull(info)) {
@@ -71,7 +73,8 @@ public class SysPersonServiceImpl extends ServiceImpl<SysPersonMapper, SysPerson
             return false;
         }
 
-        SysPerson info = getOne(new LambdaUpdateWrapper<SysPerson>().eq(SysPerson::getPhone,entity.getPhone())
+        String phone=entity.getPhone();
+        SysPerson info = getOne(new LambdaUpdateWrapper<SysPerson>().eq(SysPerson::getPhone,phone)
                 .eq(SysPerson::getStatus,1)
                 .eq(SysPerson::getCompanyId,entity.getCompanyId()));
         if (Validator.isNotNull(info)) {
@@ -99,6 +102,7 @@ public class SysPersonServiceImpl extends ServiceImpl<SysPersonMapper, SysPerson
         queryWrapper.eq(ObjectUtils.isNotNull(entity.getCompanyId()), SysPerson::getCompanyId, entity.getCompanyId());
         queryWrapper.eq(ObjectUtils.isNotNull(entity.getPersonName()), SysPerson::getPersonName, entity.getPersonName());
         Page<SysPerson> page = page(new Page<>(entity.getPageNum(), entity.getPageSize()),queryWrapper );
+
         info.setRows(page.getRecords());
         info.setTotal(page.getTotal());
         info.setCode(HttpStatus.HTTP_OK);
@@ -120,7 +124,13 @@ public class SysPersonServiceImpl extends ServiceImpl<SysPersonMapper, SysPerson
             throw new CustomException("手机号重复了");
         }
         entity.setCreateTime(DateUtils.getNowTime());
-        entity.setIdCard(EncryptHandler.encrypt(entity.getIdCard()));
+        entity.setStatus(1);
+       /* if(StringUtils.isNotBlank( entity.getIdCard())) {
+            entity.setIdCard(EncryptHandler.encrypt(entity.getIdCard()));
+        }
+        if(StringUtils.isNotBlank(entity.getPhone())) {
+            entity.setPhone(EncryptHandler.encrypt(entity.getPhone()));
+        }*/
         personMapper.insert(entity);
         return entity.getPersonId();
 
@@ -137,6 +147,12 @@ public class SysPersonServiceImpl extends ServiceImpl<SysPersonMapper, SysPerson
         checklegal(entity.getPersonId(),userid);
         entity.setUpdateTime(DateUtils.getNowTime());
         entity.setModifier(userid);
+        if(StringUtils.isNotBlank( entity.getIdCard())) {
+            entity.setIdCard(EncryptHandler.encrypt(entity.getIdCard()));
+        }
+        if(StringUtils.isNotBlank(entity.getPhone())) {
+            entity.setPhone(EncryptHandler.encrypt(entity.getPhone()));
+        }
         return personMapper.updateById(entity);
     }
 

+ 6 - 2
src/main/java/com/zhongzheng/vo/MajorVo.java

@@ -24,14 +24,18 @@ public class MajorVo {
      */
     private String majorName;
 
-
     /**
      * 过期时间
      */
     private Long expiryDate;
 
 
-    public Long CertificateAdditionId;
+    public Long certificateAdditionId;
+
+    /**
+     * 1主项,0增项
+     */
+    public  Integer isPrimary;
 
 
 }

+ 18 - 9
src/main/resources/mapper/SysCertificateMapper.xml

@@ -25,13 +25,13 @@
             AND a.person_id =#{cet.personId}
         </if>
         <if test="cet.certificateType != null and cet.certificateType != ''">
-            AND certificateType =#{cet.certificateType}
+            AND a.certificate_type =#{cet.certificateType}
         </if>
         <if test="cet.certificateTypeId != null and cet.certificateTypeId != ''">
-            AND certificateTypeId =#{cet.certificateTypeId}
+            AND a.certificate_type_Id =#{cet.certificateTypeId}
         </if>
         <if test="cet.certificateTypeId2 != null and cet.certificateTypeId2 != ''">
-            AND certificateTypeId2 =#{cet.certificateTypeId2}
+            AND a.certificate_type_Id2 =#{cet.certificateTypeId2}
         </if>
         <if test="cet.beginTime != null and cet.beginTime != ''">
             AND b.expiry_date >=#{cet.beginTime}
@@ -41,12 +41,15 @@
             <![CDATA[ AND b.expiry_date <= #{cet.endTime} ]]>
         </if>
 
-        <if test="cet.warningState != null and cet.warningState != ''">
+        <if test="cet.warningState != null and cet.warningState ==1">
             AND b.warning_state >=#{cet.warningState}
         </if>
+        <if test="cet.warningState != null and cet.warningState ==2">
+            AND (b.warning_state  is null or b.warning_state=0)
+        </if>
 
         <if test="cet.personIds != null and cet.personIds.size()>0">
-            AND company_id in
+            AND a.company_id in
             <foreach item="id" collection="cet.personIds" open="(" separator="," close=")">
                 #{id}
             </foreach>
@@ -72,13 +75,13 @@
         </if>
 
         <if test="cet.certificateType != null and cet.certificateType != ''">
-            AND certificateType =#{cet.certificateType}
+            AND certificate_type =#{cet.certificateType}
         </if>
         <if test="cet.certificateTypeId != null and cet.certificateTypeId != ''">
-            AND certificateTypeId =#{cet.certificateTypeId}
+            AND a.certificate_type_id =#{cet.certificateTypeId}
         </if>
         <if test="cet.certificateTypeId2 != null and cet.certificateTypeId2 != ''">
-            AND certificateTypeId2 =#{cet.certificateTypeId2}
+            AND a.certificate_type_id2 =#{cet.certificateTypeId2}
         </if>
         <if test="cet.beginTime != null and cet.beginTime != ''">
             AND b.expiry_date >=#{cet.beginTime}
@@ -88,9 +91,15 @@
             <![CDATA[ AND b.expiry_date <= #{cet.endTime} ]]>
         </if>
 
-        <if test="cet.warningState != null and cet.warningState != ''">
+        <if test="cet.warningState != null and cet.warningState ==1">
             AND b.warning_state >=#{cet.warningState}
         </if>
+        <if test="cet.warningState != null and cet.warningState ==2">
+            AND (b.warning_state  is null or b.warning_state=0)
+        </if>
+
+
+
 
 
     </select>