| | |
| | | package com.ruoyi.management.service.impl; |
| | | |
| | | import com.ruoyi.management.domain.SlAuditRecord; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.management.domain.*; |
| | | |
| | | import com.ruoyi.management.mapper.SlAuditRecordMapper; |
| | | import com.ruoyi.management.domain.dto.AuditRecordDTO; |
| | | import com.ruoyi.management.domain.dto.AuditRecordQuery; |
| | | import com.ruoyi.management.mapper.*; |
| | | import com.ruoyi.management.service.SlAuditRecordService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Service |
| | | public class SlAuditRecordServiceImpl extends ServiceImpl<SlAuditRecordMapper, SlAuditRecord> implements SlAuditRecordService { |
| | | |
| | | @Resource |
| | | private SlAuditMapper slAuditMapper; |
| | | |
| | | @Resource |
| | | private SlVolumeProductionRkglMapper slVolumeProductionRkglMapper; |
| | | |
| | | @Resource |
| | | private SlVolumeProductionCkglMapper slVolumeProductionCKglMapper; |
| | | |
| | | @Resource |
| | | private SlVolumeProductionZyglMapper slVolumeProductionZyglMapper; |
| | | |
| | | @Resource |
| | | private SysUserClient sysUserClient; |
| | | |
| | | @Override |
| | | public List<SlAuditRecord> getSlAuditRecord(AuditRecordQuery auditRecordQuery) { |
| | | LambdaQueryWrapper<SlAuditRecord> wrapper= Wrappers.lambdaQuery(); |
| | | wrapper.eq(SlAuditRecord::getAuditId,auditRecordQuery.getAuditId()); |
| | | wrapper.eq( SlAuditRecord::getDelFlag,0); |
| | | wrapper.orderByAsc(SlAuditRecord::getType); |
| | | List<SlAuditRecord> page1 = this.list(wrapper); |
| | | for (int i = 0; i < page1.size(); i++) { |
| | | page1.get(i).setIsPlatform(0); |
| | | SlAudit slAudit = slAuditMapper.selectById(page1.get(i).getAuditId()); |
| | | if (slAudit!=null){ |
| | | String shenhId = slAudit.getAuditUserId(); |
| | | if (StringUtils.hasLength(shenhId)){ |
| | | String[] split = shenhId.split(","); |
| | | // 取最后一个 |
| | | shenhId = split[split.length - 1]; |
| | | SysUser data = sysUserClient.getSysUser(Long.valueOf(shenhId)).getData(); |
| | | if (data!=null){ |
| | | // 判断当前审核人是不是平台管理员 |
| | | if (data.getUserType().equals("00")){ |
| | | page1.get(i).setIsPlatform(1); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (page1.get(i).getState() == 3){ |
| | | assert slAudit != null; |
| | | page1.get(i).setRefuseReason(slAudit.getCause()); |
| | | } |
| | | } |
| | | |
| | | return page1; |
| | | } |
| | | |
| | | @Override |
| | | public void updSlAuditRecord(AuditRecordDTO auditRecordDTO) { |
| | | SlAudit slAudit = slAuditMapper.selectById(auditRecordDTO.getAuditId()); |
| | | SlAuditRecord byId = this.getOne(new QueryWrapper<SlAuditRecord>() |
| | | .eq("type", auditRecordDTO.getType()) |
| | | .eq("audit_id", auditRecordDTO.getAuditId())); |
| | | String auditUserId = slAudit.getAuditUserId(); |
| | | if (StringUtils.hasLength(auditUserId)){ |
| | | slAudit.setAuditUserId(slAudit.getAuditUserId()+","+SecurityUtils.getUserId()); |
| | | }else{ |
| | | slAudit.setAuditUserId(SecurityUtils.getUserId()+""); |
| | | } |
| | | Long userid = SecurityUtils.getUserId(); |
| | | SysUser data = sysUserClient.getSysUser(userid).getData(); |
| | | if (auditRecordDTO.getState()==2){ |
| | | byId.setShenhName(data.getNickName()); |
| | | byId.setShenhTime(new Date()); |
| | | byId.setState(auditRecordDTO.getState()); |
| | | this.updateById(byId); |
| | | if (slAudit.getState()==1){ |
| | | slAudit.setState(2); |
| | | LambdaQueryWrapper<SlAuditRecord> wrapper= Wrappers.lambdaQuery(); |
| | | wrapper.eq(SlAuditRecord::getAuditId,auditRecordDTO.getAuditId()); |
| | | wrapper.eq(SlAuditRecord::getType,2); |
| | | wrapper.eq( SlAuditRecord::getDelFlag,0); |
| | | SlAuditRecord one = this.getOne(wrapper); |
| | | slAudit.setShenhId(one.getShenhId()); |
| | | slAuditMapper.updateById(slAudit); |
| | | if (slAudit.getType()==1){ |
| | | SlVolumeProductionRkgl slVolumeProductionRkgl = slVolumeProductionRkglMapper.selectById(slAudit.getRkId()); |
| | | slVolumeProductionRkgl.setAuditStatus(2); |
| | | slVolumeProductionRkgl.setReasonsRefusal(auditRecordDTO.getCause()); |
| | | slVolumeProductionRkglMapper.updateById(slVolumeProductionRkgl); |
| | | } |
| | | if (slAudit.getType()==2){ |
| | | SlVolumeProductionCkgl slVolumeProductionCkgl = slVolumeProductionCKglMapper.selectById(slAudit.getRkId()); |
| | | slVolumeProductionCkgl.setAuditStatus(2); |
| | | slVolumeProductionCkgl.setReasonsRefusal(auditRecordDTO.getCause()); |
| | | slVolumeProductionCKglMapper.updateById(slVolumeProductionCkgl); |
| | | } |
| | | if (slAudit.getType()==3){ |
| | | SlVolumeProductionZygl slVolumeProductionZygl = slVolumeProductionZyglMapper.selectById(slAudit.getRkId()); |
| | | slVolumeProductionZygl.setAuditStatus(2); |
| | | slVolumeProductionZygl.setReasonsRefusal(auditRecordDTO.getCause()); |
| | | slVolumeProductionZyglMapper.updateById(slVolumeProductionZygl); |
| | | } |
| | | |
| | | } else if (slAudit.getState()==2){ |
| | | slAudit.setState(3); |
| | | LambdaQueryWrapper<SlAuditRecord> wrapper= Wrappers.lambdaQuery(); |
| | | wrapper.eq(SlAuditRecord::getAuditId,auditRecordDTO.getAuditId()); |
| | | wrapper.eq(SlAuditRecord::getType,3); |
| | | wrapper.eq(SlAuditRecord::getDelFlag,0); |
| | | SlAuditRecord one = this.getOne(wrapper); |
| | | slAudit.setShenhId(one.getShenhId()); |
| | | slAuditMapper.updateById(slAudit); |
| | | if (slAudit.getType()==1){ |
| | | SlVolumeProductionRkgl slVolumeProductionRkgl = slVolumeProductionRkglMapper.selectById(slAudit.getRkId()); |
| | | slVolumeProductionRkgl.setAuditStatus(3); |
| | | slVolumeProductionRkgl.setReasonsRefusal(auditRecordDTO.getCause()); |
| | | slVolumeProductionRkglMapper.updateById(slVolumeProductionRkgl); |
| | | } |
| | | if (slAudit.getType()==2){ |
| | | SlVolumeProductionCkgl slVolumeProductionCkgl = slVolumeProductionCKglMapper.selectById(slAudit.getRkId()); |
| | | slVolumeProductionCkgl.setAuditStatus(3); |
| | | slVolumeProductionCkgl.setReasonsRefusal(auditRecordDTO.getCause()); |
| | | slVolumeProductionCKglMapper.updateById(slVolumeProductionCkgl); |
| | | } |
| | | if (slAudit.getType()==3){ |
| | | SlVolumeProductionZygl slVolumeProductionZygl = slVolumeProductionZyglMapper.selectById(slAudit.getRkId()); |
| | | slVolumeProductionZygl.setAuditStatus(3); |
| | | slVolumeProductionZygl.setReasonsRefusal(auditRecordDTO.getCause()); |
| | | slVolumeProductionZyglMapper.updateById(slVolumeProductionZygl); |
| | | } |
| | | |
| | | }else if (slAudit.getState()==3){ |
| | | slAudit.setState(4); |
| | | slAuditMapper.updateById(slAudit); |
| | | if (slAudit.getType()==1){ |
| | | SlVolumeProductionRkgl slVolumeProductionRkgl = slVolumeProductionRkglMapper.selectById(slAudit.getRkId()); |
| | | slVolumeProductionRkgl.setAuditStatus(4); |
| | | slVolumeProductionRkgl.setPresentState(3); |
| | | slVolumeProductionRkgl.setReasonsRefusal(auditRecordDTO.getCause()); |
| | | slVolumeProductionRkglMapper.updateById(slVolumeProductionRkgl); |
| | | } |
| | | if (slAudit.getType()==2){ |
| | | SlVolumeProductionCkgl slVolumeProductionCkgl = slVolumeProductionCKglMapper.selectById(slAudit.getRkId()); |
| | | slVolumeProductionCkgl.setAuditStatus(4); |
| | | slVolumeProductionCkgl.setPresentState(3); |
| | | slVolumeProductionCkgl.setReasonsRefusal(auditRecordDTO.getCause()); |
| | | slVolumeProductionCKglMapper.updateById(slVolumeProductionCkgl); |
| | | } |
| | | if (slAudit.getType()==3){ |
| | | SlVolumeProductionZygl slVolumeProductionZygl = slVolumeProductionZyglMapper.selectById(slAudit.getRkId()); |
| | | slVolumeProductionZygl.setAuditStatus(4); |
| | | slVolumeProductionZygl.setPresentState(3); |
| | | slVolumeProductionZygl.setReasonsRefusal(auditRecordDTO.getCause()); |
| | | slVolumeProductionZyglMapper.updateById(slVolumeProductionZygl); |
| | | } |
| | | |
| | | } |
| | | |
| | | }else if (auditRecordDTO.getState()==3){ |
| | | byId.setShenhName(data.getNickName()); |
| | | byId.setShenhTime(new Date()); |
| | | byId.setState(auditRecordDTO.getState()); |
| | | this.updateById(byId); |
| | | LambdaQueryWrapper<SlAuditRecord> wrapper= Wrappers.lambdaQuery(); |
| | | wrapper.eq(SlAuditRecord::getAuditId,auditRecordDTO.getAuditId()); |
| | | wrapper.eq(SlAuditRecord::getType,3); |
| | | wrapper.eq(SlAuditRecord::getDelFlag,0); |
| | | SlAuditRecord one = this.getOne(wrapper); |
| | | slAudit.setShenhId(one.getShenhId()); |
| | | slAudit.setCause(auditRecordDTO.getCause()); |
| | | slAudit.setState(5); |
| | | slAuditMapper.updateById(slAudit); |
| | | if (slAudit.getType()==1){ |
| | | SlVolumeProductionRkgl slVolumeProductionRkgl = slVolumeProductionRkglMapper.selectById(slAudit.getRkId()); |
| | | slVolumeProductionRkgl.setAuditStatus(5); |
| | | slVolumeProductionRkgl.setPresentState(2); |
| | | slVolumeProductionRkgl.setReasonsRefusal(auditRecordDTO.getCause()); |
| | | slVolumeProductionRkglMapper.updateById(slVolumeProductionRkgl); |
| | | } |
| | | if (slAudit.getType()==2){ |
| | | SlVolumeProductionCkgl slVolumeProductionCkgl = slVolumeProductionCKglMapper.selectById(slAudit.getRkId()); |
| | | slVolumeProductionCkgl.setAuditStatus(5); |
| | | slVolumeProductionCkgl.setPresentState(2); |
| | | slVolumeProductionCkgl.setReasonsRefusal(auditRecordDTO.getCause()); |
| | | slVolumeProductionCKglMapper.updateById(slVolumeProductionCkgl); |
| | | } |
| | | if (slAudit.getType()==3){ |
| | | SlVolumeProductionZygl slVolumeProductionZygl = slVolumeProductionZyglMapper.selectById(slAudit.getRkId()); |
| | | slVolumeProductionZygl.setAuditStatus(5); |
| | | slVolumeProductionZygl.setPresentState(2); |
| | | slVolumeProductionZygl.setReasonsRefusal(auditRecordDTO.getCause()); |
| | | slVolumeProductionZyglMapper.updateById(slVolumeProductionZygl); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | } |