package org.springblade.modules.securityapply.service.impl; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.support.Condition; import org.springblade.modules.securityapply.entity.SecurityApply; import org.springblade.modules.securityapply.mapper.SecurityApplyMapper; import org.springblade.modules.securityapply.service.SecurityApplyService; import org.springblade.modules.securityapply.vo.SecurityApplyVO; import org.springblade.modules.securitypaper.entity.SecurityPaper; import org.springblade.modules.securitypaper.service.SecurityPaperService; import org.springblade.modules.system.entity.User; import org.springblade.modules.system.service.IUserService; import org.springblade.modules.system.service.MyAsyncService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Date; import java.util.List; /** * 保安员证申诉服务实现类 * * @author zhongrj * @since 2022-03-03 */ @Service public class SecurityApplyServiceImpl extends ServiceImpl implements SecurityApplyService { @Autowired private MyAsyncService myAsyncService; @Autowired private IUserService userService; @Autowired private SecurityPaperService securityPaperService; /** * 自定义分页查询保安员证申诉数据 * @param page * @param securityApply * @return */ @Override public IPage selectSecurityApplyPage(IPage page, SecurityApplyVO securityApply) { return page.setRecords(baseMapper.selectSecurityApplyPage(page, securityApply)); } /** * 审核 * @param securityApply * @return */ @Override public Object audit(SecurityApply securityApply) { //查询用户信息 SecurityApply apply = this.getById(securityApply.getId()); User user = userService.getById(apply.getUserId()); //判断审核状态 if (securityApply.getAuditStatus().equals(1)){ //审核通过,判断是否为重复审核通过,即查询保安证编号库是否已存在该编号,如果已存在,则不新增,否则则新增,同时修改改保安员的保安证编号 //1.1 查询该编号是否已在存储库存在 SecurityPaper securityPaper = new SecurityPaper(); securityPaper.setNumber(apply.getNumber()); List list = securityPaperService.list(Condition.getQueryWrapper(securityPaper)); if (list.size()>0){ //判断该编号对应的人员是否为同一人 for (SecurityPaper paper : list) { if (!paper.getIdCardNo().equals(user.getCardid())){ //其他人员已占用该编号 throw new ServiceException("保安证编号:["+ apply.getNumber() +"] 已存在"); } } }else { //新增 SecurityPaper securityPaper1 = new SecurityPaper(); securityPaper1.setNumber(apply.getNumber()); securityPaper1.setCreateTime(new Date()); securityPaper1.setIdCardNo(user.getCardid()); securityPaper1.setUserId(user.getId()); securityPaper1.setExamId(apply.getId()); securityPaper1.setPeopleName(user.getRealName()); securityPaper1.setSource(2); //插入保安证存储库 securityPaperService.save(securityPaper1); //用户保安证编号更新 user.setHold("1"); user.setSecuritynumber(apply.getNumber()); user.setUpdateTime(new Date()); boolean status = userService.updateById(user); if (status) { //内网数据同步 String s1 = "update blade_user set hold = " + user.getHold() + ",securitynumber = " + "'" + user.getSecuritynumber() + "'" + ",update_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:dd").format(user.getUpdateTime()) + "'" + " " + "where id = " + "'" + user.getId() + "'"; myAsyncService.FTP(s1); } } } //证件核实申请更新并返回 return this.updateById(securityApply); } /** * 批量审核 * @param securityApply * @return */ @Override public Object batchAudit(SecurityApplyVO securityApply) { //取出id List list = Arrays.asList(securityApply.getIds().split(",")); //遍历 for (String s : list) { SecurityApply securityApply1 = new SecurityApply(); securityApply1.setAuditTime(securityApply.getAuditTime()); securityApply1.setAuditStatus(securityApply.getAuditStatus()); securityApply1.setId(Long.parseLong(s)); //审核 audit(securityApply1); } //返回 return null; } }