| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.dto.TTestMethodConfirmSheetDTO; |
| | | import com.ruoyi.system.dto.TestMethodConfirmSheetSignDTO; |
| | | import com.ruoyi.system.mapper.SysUserMapper; |
| | | import com.ruoyi.system.model.TTestMethodConfirmSheet; |
| | | import com.ruoyi.system.model.TTestMethodConfirmSheetTerm; |
| | | import com.ruoyi.system.query.TTestMethodConfirmSheetQuery; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import com.ruoyi.system.service.TTestMethodConfirmSheetService; |
| | | import com.ruoyi.system.service.TTestMethodConfirmSheetTermService; |
| | | import com.ruoyi.system.vo.TTestMethodConfirmSheetVO; |
| | | import io.swagger.annotations.Api; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | 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.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | @Api(tags = "检验方法确认单管理") |
| | | @RestController |
| | | @RequestMapping("/t-test-method-confirm-sheet") |
| | | @RequestMapping("") |
| | | public class TTestMethodConfirmSheetController { |
| | | private final TTestMethodConfirmSheetService testMethodConfirmSheetService; |
| | | private final TokenService tokenService; |
| | | private final ISysUserService sysUserService; |
| | | private final SysUserMapper sysUserMapper; |
| | | private final TTestMethodConfirmSheetTermService testMethodConfirmSheetTermService; |
| | | @Autowired |
| | | public TTestMethodConfirmSheetController(TTestMethodConfirmSheetService testMethodConfirmSheetService, TokenService tokenService, ISysUserService sysUserService, SysUserMapper sysUserMapper, TTestMethodConfirmSheetTermService testMethodConfirmSheetTermService) { |
| | | this.testMethodConfirmSheetService = testMethodConfirmSheetService; |
| | | this.tokenService = tokenService; |
| | | this.sysUserService = sysUserService; |
| | | this.sysUserMapper = sysUserMapper; |
| | | this.testMethodConfirmSheetTermService = testMethodConfirmSheetTermService; |
| | | } |
| | | |
| | | /** |
| | | * 获取检验方法确认单管理列表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:testMethodConfirmSheet:list')") |
| | | @ApiOperation(value = "获取检验方法确认单分页列表") |
| | | @PostMapping(value = "/api/t-test-method-confirm-sheet/pageList") |
| | | public R<PageInfo<TTestMethodConfirmSheetVO>> pageList(@RequestBody String param) { |
| | | TTestMethodConfirmSheetQuery query = JSON.parseObject(param, TTestMethodConfirmSheetQuery.class); |
| | | return R.ok(testMethodConfirmSheetService.pageList(query)); |
| | | } |
| | | |
| | | /** |
| | | * 添加检验方法确认单管理 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:testMethodConfirmSheet:add')") |
| | | @Log(title = "检验方法确认单信息-新增检验方法确认单", businessType = BusinessType.INSERT) |
| | | @ApiOperation(value = "添加检验方法确认单",response = TTestMethodConfirmSheetDTO.class) |
| | | @PostMapping(value = "/api/t-test-method-confirm-sheet/add") |
| | | public R<Boolean> add(@RequestBody String param) { |
| | | TTestMethodConfirmSheetDTO dto = JSON.parseObject(param,TTestMethodConfirmSheetDTO.class); |
| | | testMethodConfirmSheetService.save(dto); |
| | | List<TTestMethodConfirmSheetTerm> testMethodConfirmSheetTerms = dto.getTestMethodConfirmSheetTerms(); |
| | | testMethodConfirmSheetTerms.forEach(testMethodConfirmSheetTerm -> { |
| | | testMethodConfirmSheetTerm.setTestId(dto.getId()); |
| | | testMethodConfirmSheetTerm.setStatus(1); |
| | | }); |
| | | testMethodConfirmSheetTermService.saveBatch(testMethodConfirmSheetTerms); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 修改检验方法确认单 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:testMethodConfirmSheet:edit')") |
| | | @Log(title = "检验方法确认单信息-修改检验方法确认单", businessType = BusinessType.UPDATE) |
| | | @ApiOperation(value = "修改检验方法确认单") |
| | | @PostMapping(value = "/api/t-test-method-confirm-sheet/update") |
| | | public R<Boolean> update(@RequestBody String param) { |
| | | TTestMethodConfirmSheetDTO dto = JSON.parseObject(param,TTestMethodConfirmSheetDTO.class); |
| | | testMethodConfirmSheetService.updateById(dto); |
| | | testMethodConfirmSheetTermService.remove(Wrappers.lambdaQuery(TTestMethodConfirmSheetTerm.class).eq(TTestMethodConfirmSheetTerm::getTestId,dto.getId())); |
| | | List<TTestMethodConfirmSheetTerm> testMethodConfirmSheetTerms = dto.getTestMethodConfirmSheetTerms(); |
| | | testMethodConfirmSheetTerms.forEach(testMethodConfirmSheetTerm -> { |
| | | testMethodConfirmSheetTerm.setTestId(dto.getId()); |
| | | testMethodConfirmSheetTerm.setStatus(1); |
| | | }); |
| | | testMethodConfirmSheetTermService.saveBatch(testMethodConfirmSheetTerms); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 查看检验方法确认单详情 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:testMethodConfirmSheet:detail')") |
| | | @ApiOperation(value = "查看检验方法确认单详情") |
| | | @GetMapping(value = "/open/t-test-method-confirm-sheet/getDetailById") |
| | | public R<TTestMethodConfirmSheetVO> getDetailById(@RequestParam String id) { |
| | | TTestMethodConfirmSheet testMethodConfirmSheet = testMethodConfirmSheetService.getById(id); |
| | | TTestMethodConfirmSheetVO testMethodConfirmSheetVO = new TTestMethodConfirmSheetVO(); |
| | | BeanUtils.copyProperties(testMethodConfirmSheet, testMethodConfirmSheetVO); |
| | | |
| | | // 获取检测项 |
| | | List<TTestMethodConfirmSheetTerm> testMethodConfirmSheetTerms = testMethodConfirmSheetTermService.list(Wrappers.lambdaQuery(TTestMethodConfirmSheetTerm.class) |
| | | .eq(TTestMethodConfirmSheetTerm::getTestId, id)); |
| | | testMethodConfirmSheetVO.setTestMethodConfirmSheetTerms(testMethodConfirmSheetTerms); |
| | | |
| | | return R.ok(testMethodConfirmSheetVO); |
| | | } |
| | | |
| | | /** |
| | | * 删除检验方法确认单 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:testMethodConfirmSheet:delete')") |
| | | @Log(title = "检验方法确认单信息-删除检验方法确认单", businessType = BusinessType.DELETE) |
| | | @ApiOperation(value = "删除检验方法确认单") |
| | | @DeleteMapping(value = "/open/t-test-method-confirm-sheet/deleteById") |
| | | public R<Boolean> deleteById(@RequestParam String id) { |
| | | // 删除检测项 |
| | | testMethodConfirmSheetTermService.remove(Wrappers.lambdaQuery(TTestMethodConfirmSheetTerm.class).eq(TTestMethodConfirmSheetTerm::getTestId, id)); |
| | | return R.ok(testMethodConfirmSheetService.removeById(id)); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除检验方法确认单 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:testMethodConfirmSheet:delete')") |
| | | @Log(title = "检验方法确认单信息-删除检验方法确认单", businessType = BusinessType.DELETE) |
| | | @ApiOperation(value = "批量删除检验方法确认单") |
| | | @DeleteMapping(value = "/open/t-test-method-confirm-sheet/deleteByIds") |
| | | public R<Boolean> deleteByIds(@RequestBody List<String> ids) { |
| | | // 删除检测项 |
| | | testMethodConfirmSheetTermService.remove(Wrappers.lambdaQuery(TTestMethodConfirmSheetTerm.class).in(TTestMethodConfirmSheetTerm::getTestId, ids)); |
| | | return R.ok(testMethodConfirmSheetService.removeByIds(ids)); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除检验方法确认单 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:testMethodConfirmSheet:sign')") |
| | | @Log(title = "检验方法确认单信息-检验方法确认单签字", businessType = BusinessType.UPDATE) |
| | | @ApiOperation(value = "检验方法确认单签字") |
| | | @PostMapping(value = "/api/t-test-method-confirm-sheet/sign") |
| | | public R<Boolean> sign(@RequestBody String param) { |
| | | TestMethodConfirmSheetSignDTO testMethodConfirmSheetSign = JSON.parseObject(param, TestMethodConfirmSheetSignDTO.class); |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | testMethodConfirmSheetService.update(Wrappers.lambdaUpdate(TTestMethodConfirmSheet.class) |
| | | .eq(TTestMethodConfirmSheet::getId, testMethodConfirmSheetSign.getTestMethodConfirmSheetId()) |
| | | .set(TTestMethodConfirmSheet::getAuditStatus, testMethodConfirmSheetSign.getAuditStatus()) |
| | | .set(TTestMethodConfirmSheet::getSignTime, LocalDateTime.now()) |
| | | .set(TTestMethodConfirmSheet::getAuditPersonId, userId) |
| | | .set(TTestMethodConfirmSheet::getConfirmSign, testMethodConfirmSheetSign.getConfirmSign())); |
| | | return R.ok(); |
| | | } |
| | | } |
| | | |