| | |
| | | package com.ruoyi.basic.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.*; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.basic.dto.*; |
| | | import com.ruoyi.basic.enums.BasicTreeEnums; |
| | | import com.ruoyi.basic.enums.StandardProductListChcekTypeEnums; |
| | | import com.ruoyi.basic.enums.StandardProductListOperationTypeEnums; |
| | | import com.ruoyi.basic.mapper.*; |
| | | import com.ruoyi.basic.pojo.*; |
| | | import com.ruoyi.basic.service.StandardMethodListService; |
| | | import com.ruoyi.basic.service.StandardMethodService; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.common.utils.QueryWrappers; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.basic.service.StandardProductListService; |
| | | import lombok.AllArgsConstructor; |
| | | import org.apache.catalina.security.SecurityUtil; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | |
| | | @Autowired |
| | | private StandardProductListUpdateRecordMapper standardProductListUpdateRecordMapper; |
| | | |
| | | @Autowired |
| | | private StandardProductListUpdateRecordRelMapper standardProductListUpdateRecordRelMapper; |
| | | |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | /** |
| | | * 标准树下检验项处理 |
| | | * @param standardProductListDto |
| | | * 标准树下检验项提交 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void productListOperate(StandardProductListDto standardProductListDto) { |
| | | StandardProductList standardProductList = new StandardProductList(); |
| | | standardProductList.setId(standardProductListDto.getId()); |
| | | StandardProductListUpdateRecord standardProductListUpdateRecord = new StandardProductListUpdateRecord(); |
| | | // 审核通过 |
| | | if(StandardProductListOperationTypeEnums.PASS_CHECK_OP.getCode().equals(standardProductListDto.getOperationStatus())){ |
| | | // 删除备份数据 |
| | | standardProductListBackupRelMapper.deleteById(standardProductListDto.getId()); |
| | | standardProductList.setCheckStatus(StandardProductListChcekTypeEnums.PASS_CHECK.getCode()); |
| | | // 审核不通过 |
| | | }else if(StandardProductListOperationTypeEnums.NO_PASS_CHECK_OP.getCode().equals(standardProductListDto.getOperationStatus())) { |
| | | // 还原数据 |
| | | StandardProductListBackupRel standardProductListBackupRel = standardProductListBackupRelMapper.selectById(standardProductListDto.getId()); |
| | | if(ObjectUtils.isEmpty(standardProductListBackupRel)){ |
| | | throw new RuntimeException("备份数据查找失败"); |
| | | } |
| | | BeanUtils.copyProperties(standardProductListBackupRel, standardProductList); |
| | | standardProductList.setCheckStatus(StandardProductListChcekTypeEnums.NO_PASS_CHECK.getCode()); |
| | | // 提交 |
| | | }else if(StandardProductListOperationTypeEnums.SUBMIT_OP.getCode().equals(standardProductListDto.getOperationStatus())) { |
| | | standardProductListUpdateRecord.setOperationType(StandardProductListOperationTypeEnums.PASS_CHECK_OP.getCode()); |
| | | standardProductList.setCheckStatus(StandardProductListChcekTypeEnums.CHECK_ING.getCode()); |
| | | } else { |
| | | throw new RuntimeException("操作有误"); |
| | | } |
| | | // 新增操作记录 |
| | | standardProductListUpdateRecord.setStandardProductListId(standardProductListDto.getId()); |
| | | standardProductListUpdateRecord.setOperationType(standardProductListDto.getOperationStatus()); |
| | | public void productListSubmit(StandardProductListUpdateRecord standardProductListUpdateRecord) { |
| | | // 查询所有待审核的数据 |
| | | QueryWrapper<StandardProductList> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("check_status",StandardProductListChcekTypeEnums.WAIT_CHECK.getCode()); |
| | | List<StandardProductList> unCheckStandardProductListArray = standardProductListMapper.selectList(queryWrapper); |
| | | |
| | | List<Long> standardProductListIds = new ArrayList<>(); |
| | | // 插入修改记录 |
| | | standardProductListUpdateRecordMapper.insert(standardProductListUpdateRecord); |
| | | // 修改审核状态 |
| | | standardProductList.setCheckStatus(standardProductListDto.getOperationStatus()); |
| | | standardProductListMapper.updateById(standardProductList); |
| | | // 插入修改记录关联表 |
| | | List<StandardProductListUpdateRecordRel> standardProductListUpdateRecordRelList = new ArrayList<>(); |
| | | for (StandardProductList standardProductList : unCheckStandardProductListArray) { |
| | | StandardProductListUpdateRecordRel standardProductListUpdateRecordRel = new StandardProductListUpdateRecordRel(); |
| | | BeanUtils.copyProperties(standardProductList, standardProductListUpdateRecordRel); |
| | | standardProductListUpdateRecordRel.setId(null); |
| | | standardProductListUpdateRecordRel.setStandardProductListId(standardProductList.getId()); |
| | | standardProductListUpdateRecordRel.setStandardProductListUpdateRecordId(standardProductListUpdateRecord.getId()); |
| | | standardProductListUpdateRecordRelList.add(standardProductListUpdateRecordRel); |
| | | standardProductListUpdateRecordRelMapper.insert(standardProductListUpdateRecordRel); |
| | | standardProductListIds.add(standardProductList.getId()); |
| | | } |
| | | |
| | | // 修改标准树下检查项状态为审核中 |
| | | standardProductListMapper.updateProductListCheckStatus(standardProductListIds,StandardProductListChcekTypeEnums.CHECK_ING.getCode()); |
| | | } |
| | | |
| | | /** |
| | | * 标准树下检验项修改记录分页查询 |
| | | * @param page |
| | | * @param record |
| | | * @return |
| | | * 标准树下检验项审核 |
| | | * @param standardProductListUpdateRecord |
| | | */ |
| | | @Override |
| | | public IPage<StandardProductListUpdateRecord> standardProductListRecordPage(Page page, StandardProductListUpdateRecord record) { |
| | | return standardProductListUpdateRecordMapper.standardProductListRecordPage(page,QueryWrappers.queryWrappers(record)); |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void productListCheck(StandardProductListUpdateRecord standardProductListUpdateRecord) { |
| | | // 查询所有审核中的数据 |
| | | QueryWrapper<StandardProductList> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("check_status",StandardProductListChcekTypeEnums.CHECK_ING.getCode()); |
| | | List<StandardProductList> standardProductListArray = standardProductListMapper.selectList(queryWrapper); |
| | | if(CollectionUtils.isEmpty(standardProductListArray)){ |
| | | return; |
| | | } |
| | | List<Long> standardProductListIds = new ArrayList<>(); |
| | | for (StandardProductList standardProductList : standardProductListArray) { |
| | | standardProductListIds.add(standardProductList.getId()); |
| | | } |
| | | // 审核通过 |
| | | if(StandardProductListChcekTypeEnums.PASS_CHECK.getCode().equals(standardProductListUpdateRecord.getCheckStatus())){ |
| | | // 删除备份数据 |
| | | standardProductListBackupRelMapper.deleteBatchIds(standardProductListIds); |
| | | // 修改状态 |
| | | standardProductListMapper.updateProductListCheckStatus(standardProductListIds,StandardProductListChcekTypeEnums.PASS_CHECK.getCode()); |
| | | } |
| | | // 审核未通过 |
| | | if(StandardProductListChcekTypeEnums.NO_PASS_CHECK.getCode().equals(standardProductListUpdateRecord.getCheckStatus())){ |
| | | // 查询所有的备份数据 |
| | | List<StandardProductListBackupRel> standardProductListBackupRelList = standardProductListBackupRelMapper.selectBatchIds(standardProductListIds); |
| | | // 回滚数据 |
| | | for (StandardProductListBackupRel standardProductListBackupRel : standardProductListBackupRelList) { |
| | | StandardProductList standardProductList = new StandardProductList(); |
| | | BeanUtils.copyProperties(standardProductListBackupRel, standardProductList); |
| | | standardProductList.setCheckStatus(""); |
| | | standardProductListMapper.updateById(standardProductList); |
| | | } |
| | | // 删除备份数据 |
| | | standardProductListBackupRelMapper.deleteBatchIds(standardProductListIds); |
| | | } |
| | | standardProductListUpdateRecordMapper.updateById(standardProductListUpdateRecord); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |