| | |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.dto.*; |
| | | import com.ruoyi.system.dto.BatchCollectSamplesDTO; |
| | | import com.ruoyi.system.dto.BatchSendSamplesDTO; |
| | | import com.ruoyi.system.dto.TSamplingRecordDTO; |
| | | import com.ruoyi.system.mapper.SysUserMapper; |
| | | import com.ruoyi.system.model.*; |
| | | import com.ruoyi.system.query.TSamplingRecordQuery; |
| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | |
| | | */ |
| | | @Api(tags = "取样记录管理") |
| | | @RestController |
| | | @RequestMapping("/t-sampling-record") |
| | | @RequestMapping("") |
| | | public class TSamplingRecordController { |
| | | |
| | | private final TSamplingRecordService samplingRecordService; |
| | |
| | | private final ISysUserService sysUserService; |
| | | private final SysUserMapper sysUserMapper; |
| | | private final TSamplingRecordOperationService samplingRecordOperationService; |
| | | private final TExperimentDispatchService experimentDispatchService; |
| | | private final TProjectProposalService projectProposalService; |
| | | private final TProjectTeamService projectTeamService; |
| | | private final TProjectTeamStaffService projectTeamStaffService; |
| | | @Autowired |
| | | public TSamplingRecordController(TSamplingRecordService samplingRecordService, TokenService tokenService, ISysUserService sysUserService, SysUserMapper sysUserMapper, TSamplingRecordOperationService samplingRecordOperationService) { |
| | | public TSamplingRecordController(TSamplingRecordService samplingRecordService, TokenService tokenService, ISysUserService sysUserService, SysUserMapper sysUserMapper, TSamplingRecordOperationService samplingRecordOperationService, TExperimentDispatchService experimentDispatchService, TProjectProposalService projectProposalService, TProjectTeamService projectTeamService, TProjectTeamStaffService projectTeamStaffService) { |
| | | this.samplingRecordService = samplingRecordService; |
| | | this.tokenService = tokenService; |
| | | this.sysUserService = sysUserService; |
| | | this.sysUserMapper = sysUserMapper; |
| | | this.samplingRecordOperationService = samplingRecordOperationService; |
| | | this.experimentDispatchService = experimentDispatchService; |
| | | this.projectProposalService = projectProposalService; |
| | | this.projectTeamService = projectTeamService; |
| | | this.projectTeamStaffService = projectTeamStaffService; |
| | | } |
| | | |
| | | /** |
| | | * 获取取样记录管理列表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:samplingRecord:list')") |
| | | @ApiOperation(value = "获取取样记录分页列表") |
| | | //@PreAuthorize("@ss.hasPermi('system:samplingRecord:list')") |
| | | @ApiOperation(value = "获取取样记录分页列表", response = TSamplingRecordQuery.class) |
| | | @PostMapping(value = "/api/t-sampling-record/pageList") |
| | | public R<PageInfo<TSamplingRecordVO>> pageList(@RequestBody String param) { |
| | | TSamplingRecordQuery query = JSON.parseObject(param, TSamplingRecordQuery.class); |
| | |
| | | /** |
| | | * 添加取样记录管理 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:samplingRecord:add')") |
| | | //@PreAuthorize("@ss.hasPermi('system:samplingRecord:add')") |
| | | @Log(title = "取样记录信息-新增取样记录", businessType = BusinessType.INSERT) |
| | | @ApiOperation(value = "添加取样记录",response = TSamplingRecordDTO.class) |
| | | @PostMapping(value = "/api/t-sampling-record/add") |
| | | public R<Boolean> add(@RequestBody String param) { |
| | | TSamplingRecordDTO dto = JSON.parseObject(param,TSamplingRecordDTO.class); |
| | | // TODO 生成取样单编号 |
| | | |
| | | // 通过当前用户查询项目组 |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | TProjectTeamStaff projectTeamStaff = projectTeamStaffService.getOne(Wrappers.lambdaQuery(TProjectTeamStaff.class) |
| | | .eq(TProjectTeamStaff::getUserId, userId) |
| | | .last("LIMIT 1")); |
| | | if(Objects.isNull(projectTeamStaff)){ |
| | | return R.fail("当前用户未分配项目组,无法创建项目课题方案"); |
| | | } |
| | | // 查询项目组 |
| | | TProjectTeam projectTeam = projectTeamService.getById(projectTeamStaff.getTeamId()); |
| | | if(Objects.isNull(projectTeam)){ |
| | | return R.fail("项目组不存在"); |
| | | } |
| | | if(projectTeam.getStatus() == 2){ |
| | | return R.fail("项目组已封存,无法创建项目课题方案"); |
| | | } |
| | | // 生成取样单编号 |
| | | String format = new SimpleDateFormat("yyyyMMdd").format(new Date()); |
| | | String samplingCode = projectTeam.getTeamName() + "-" + format.substring(2) + "S"; |
| | | |
| | | // 查询上个项目课题方案的序号 |
| | | long count = samplingRecordService.count(Wrappers.lambdaQuery(TSamplingRecord.class) |
| | | .like(TSamplingRecord::getSamplingCode, samplingCode)); |
| | | samplingCode = samplingCode + String.format("%02d", count+1); |
| | | dto.setSamplingCode(samplingCode); |
| | | |
| | | samplingRecordService.save(dto); |
| | | List<TSamplingRecordOperation> samplingRecordOperations = dto.getSamplingRecordOperations(); |
| | | samplingRecordOperations.forEach(samplingRecordOperation -> { |
| | |
| | | /** |
| | | * 修改取样记录 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:samplingRecord:edit')") |
| | | //@PreAuthorize("@ss.hasPermi('system:samplingRecord:edit')") |
| | | @Log(title = "取样记录信息-修改取样记录", businessType = BusinessType.UPDATE) |
| | | @ApiOperation(value = "修改取样记录") |
| | | @PostMapping(value = "/api/t-sampling-record/update") |
| | |
| | | /** |
| | | * 修改取样操作记录 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:samplingRecordOperation:edit')") |
| | | //@PreAuthorize("@ss.hasPermi('system:samplingRecordOperation:edit')") |
| | | @Log(title = "取样记录信息-修改取样操作记录", businessType = BusinessType.UPDATE) |
| | | @ApiOperation(value = "修改取样操作记录") |
| | | @PostMapping(value = "/api/t-sampling-record/updateRecordOperation") |
| | |
| | | /** |
| | | * 修改取样操作记录 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:samplingRecordOperation:edit')") |
| | | //@PreAuthorize("@ss.hasPermi('system:samplingRecordOperation:edit')") |
| | | @Log(title = "取样记录信息-实验员提交取样记录", businessType = BusinessType.UPDATE) |
| | | @ApiOperation(value = "实验员提交取样记录") |
| | | @PostMapping(value = "/api/t-sampling-record/commitRecord") |
| | |
| | | /** |
| | | * 查看取样记录详情 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:samplingRecord:detail')") |
| | | //@PreAuthorize("@ss.hasPermi('system:samplingRecord:detail')") |
| | | @ApiOperation(value = "查看取样记录详情") |
| | | @GetMapping(value = "/open/t-sampling-record/getDetailById") |
| | | public R<TSamplingRecordVO> getDetailById(@RequestParam String id) { |
| | |
| | | |
| | | // 查询取样操作记录 |
| | | samplingRecordVO.setSamplingRecordOperations(samplingRecordOperationService.list(Wrappers.lambdaQuery(TSamplingRecordOperation.class).eq(TSamplingRecordOperation::getSamplingId, id))); |
| | | |
| | | // 查询实验调度信息 |
| | | TExperimentDispatch experimentDispatch = experimentDispatchService.getById(samplingRecordVO.getDispatchId()); |
| | | if(Objects.nonNull(experimentDispatch)){ |
| | | // 查询课题方案名称 |
| | | TProjectProposal projectProposal = projectProposalService.getById(experimentDispatch.getProposalId()); |
| | | if(Objects.nonNull(projectProposal)){ |
| | | experimentDispatch.setProjectName(projectProposal.getProjectName()); |
| | | } |
| | | } |
| | | samplingRecordVO.setExperimentDispatch(experimentDispatch); |
| | | return R.ok(samplingRecordVO); |
| | | } |
| | | |
| | | /** |
| | | * 删除取样记录 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:samplingRecord:delete')") |
| | | //@PreAuthorize("@ss.hasPermi('system:samplingRecord:delete')") |
| | | @Log(title = "取样记录信息-删除取样记录", businessType = BusinessType.DELETE) |
| | | @ApiOperation(value = "删除取样记录") |
| | | @DeleteMapping(value = "/open/t-sampling-record/deleteById") |
| | |
| | | /** |
| | | * 批量删除取样记录 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:samplingRecord:delete')") |
| | | //@PreAuthorize("@ss.hasPermi('system:samplingRecord:delete')") |
| | | @Log(title = "取样记录信息-删除取样记录", businessType = BusinessType.DELETE) |
| | | @ApiOperation(value = "批量删除取样记录") |
| | | @DeleteMapping(value = "/open/t-sampling-record/deleteByIds") |
| | |
| | | /** |
| | | * 批量送样 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:samplingRecord:sendSamples')") |
| | | //@PreAuthorize("@ss.hasPermi('system:samplingRecord:sendSamples')") |
| | | @Log(title = "取样记录信息-批量送样", businessType = BusinessType.UPDATE) |
| | | @ApiOperation(value = "批量送样") |
| | | @ApiOperation(value = "批量送样",response = BatchSendSamplesDTO.class) |
| | | @PostMapping(value = "/open/t-sampling-record/batchSendSamples") |
| | | public R<Boolean> batchSendSamples(@RequestBody String param) { |
| | | BatchSendSamplesDTO batchSendSamplesDTO = JSON.parseObject(param, BatchSendSamplesDTO.class); |
| | |
| | | /** |
| | | * 批量删除取样记录 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:samplingRecord:collectSamples')") |
| | | //@PreAuthorize("@ss.hasPermi('system:samplingRecord:collectSamples')") |
| | | @Log(title = "取样记录信息-批量收样", businessType = BusinessType.UPDATE) |
| | | @ApiOperation(value = "批量收样") |
| | | @ApiOperation(value = "批量收样",response = BatchCollectSamplesDTO.class) |
| | | @PostMapping(value = "/open/t-sampling-record/batchCollectSamples") |
| | | public R<Boolean> batchCollectSamples(@RequestBody String param) { |
| | | BatchCollectSamplesDTO batchCollectSamplesDTO = JSON.parseObject(param, BatchCollectSamplesDTO.class); |