|
|
|
|
@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import com.biutag.supervision.common.UserContextHolder; |
|
|
|
|
import com.biutag.supervision.constants.AppConstants; |
|
|
|
|
import com.biutag.supervision.constants.enums.RoleCodeEnum; |
|
|
|
|
import com.biutag.supervision.constants.enums.SuperviseReportTypeEnum; |
|
|
|
|
import com.biutag.supervision.mapper.SuperviseReportMapper; |
|
|
|
|
import com.biutag.supervision.pojo.entity.*; |
|
|
|
|
import com.biutag.supervision.pojo.model.UserAuth; |
|
|
|
|
@ -21,11 +22,14 @@ import com.biutag.supervision.pojo.vo.SamplingVo;
|
|
|
|
|
import com.biutag.supervision.pojo.vo.SuperviseReportVo; |
|
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Objects; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
@RequiredArgsConstructor |
|
|
|
|
@Service |
|
|
|
|
@ -36,6 +40,8 @@ public class SuperviseReportService extends ServiceImpl<SuperviseReportMapper, S
|
|
|
|
|
private final SuperviseReportFileService superviseReportFileService; |
|
|
|
|
|
|
|
|
|
private final NegativeService negativeService; |
|
|
|
|
|
|
|
|
|
private final SuperviseReportDepartService superviseReportDepartService; |
|
|
|
|
/** |
|
|
|
|
* 分页查询 |
|
|
|
|
* */ |
|
|
|
|
@ -56,7 +62,9 @@ public class SuperviseReportService extends ServiceImpl<SuperviseReportMapper, S
|
|
|
|
|
queryWrapper.in("t.crt_depart_id", orgIds); |
|
|
|
|
} |
|
|
|
|
//查询条件
|
|
|
|
|
queryWrapper.like(StrUtil.isNotEmpty(queryParam.getReportName()),"t.report_name",queryParam.getReportName()) |
|
|
|
|
queryWrapper |
|
|
|
|
.eq(Objects.nonNull(queryParam.getType()), "t.type", queryParam.getType()) |
|
|
|
|
.like(StrUtil.isNotEmpty(queryParam.getReportName()),"t.report_name",queryParam.getReportName()) |
|
|
|
|
.like(StrUtil.isNotEmpty(queryParam.getCrtUser()),"t.crt_user",queryParam.getCrtUser()) |
|
|
|
|
.groupBy("t.id").orderByDesc("t.crt_time"); |
|
|
|
|
|
|
|
|
|
@ -72,7 +80,6 @@ public class SuperviseReportService extends ServiceImpl<SuperviseReportMapper, S
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Page<Negative> negativePage(SuperviseReportQueryParam param){ |
|
|
|
|
LambdaQueryWrapper<Negative> queryWrapper=new LambdaQueryWrapper<>(); |
|
|
|
|
queryWrapper.eq(Negative::getReportId,param.getId()); |
|
|
|
|
@ -81,9 +88,11 @@ public class SuperviseReportService extends ServiceImpl<SuperviseReportMapper, S
|
|
|
|
|
Page<Negative> page = negativeService.page(Page.of(param.getCurrent(), param.getSize()), queryWrapper); |
|
|
|
|
return page; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 保存或修改 |
|
|
|
|
* */ |
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
public boolean addOrUpdate(SuperviseReportVo vo){ |
|
|
|
|
SuperviseReport report =new SuperviseReport(); |
|
|
|
|
BeanUtil.copyProperties(vo,report); |
|
|
|
|
@ -97,14 +106,38 @@ public class SuperviseReportService extends ServiceImpl<SuperviseReportMapper, S
|
|
|
|
|
report.setCrtUser(user.getNickName()); |
|
|
|
|
report.setCrtEmpNo(user.getEmpNo()); |
|
|
|
|
} |
|
|
|
|
if(baseMapper.insertOrUpdate(report) ){ |
|
|
|
|
|
|
|
|
|
if (SuperviseReportTypeEnum.NOTICE.getValue().equals(vo.getType())) { |
|
|
|
|
if (CollectionUtil.isNotEmpty(vo.getDepartIds())) { |
|
|
|
|
List<SupDepart> departs = departService.listByIds(vo.getDepartIds()); |
|
|
|
|
String departNames = departs.stream().map(SupDepart::getShortName).collect(Collectors.joining("、")); |
|
|
|
|
report.setDepartName(departNames); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(saveOrUpdate(report) ){ |
|
|
|
|
if (SuperviseReportTypeEnum.NOTICE.getValue().equals(vo.getType())) { |
|
|
|
|
if (StrUtil.isNotBlank(vo.getId())) { |
|
|
|
|
superviseReportDepartService.remove(new LambdaQueryWrapper<SuperviseReportDepart>().eq(SuperviseReportDepart::getSuperviseId, vo.getId())); |
|
|
|
|
} |
|
|
|
|
if (CollectionUtil.isNotEmpty(vo.getDepartIds())) { |
|
|
|
|
List<SupDepart> departs = departService.listByIds(vo.getDepartIds()); |
|
|
|
|
List<SuperviseReportDepart> list = departs.stream().map(d -> { |
|
|
|
|
SuperviseReportDepart reportDepart = new SuperviseReportDepart(); |
|
|
|
|
reportDepart.setDepartId(d.getId()); |
|
|
|
|
reportDepart.setDepartName(d.getShortName()); |
|
|
|
|
reportDepart.setSuperviseId(vo.getId()); |
|
|
|
|
return reportDepart; |
|
|
|
|
}).toList(); |
|
|
|
|
superviseReportDepartService.saveBatch(list); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if( CollectionUtil.isNotEmpty(vo.getFiles())){ |
|
|
|
|
superviseReportFileService.remove(new LambdaQueryWrapper<SuperviseReportFile>().eq(SuperviseReportFile::getSuperviseId,report.getId())); |
|
|
|
|
vo.getFiles().forEach(s->{ |
|
|
|
|
s.setSuperviseId(report.getId()); |
|
|
|
|
s.setCrtTime(LocalDateTime.now()); |
|
|
|
|
}); |
|
|
|
|
return superviseReportFileService.saveOrUpdateBatch(vo.getFiles()); |
|
|
|
|
return superviseReportFileService.saveOrUpdateBatch(vo.getFiles()); |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
}else{ |
|
|
|
|
|