Commit e1404cd790325d55c4eb898d51489d59392be83d

Authored by 杨鸣坤
1 parent cd6465a9

计划增加修改状态接口

... ... @@ -116,10 +116,25 @@ public class TkInspectionPlanController extends BaseController {
116 116 .forEach(tkCheckDetailsDTO -> tkCheckDetailsDTO.setTenantId(tkCheckDetailsDTO.getTenantId()));
117 117 }
118 118
119   - TkInspectionPlanDTO dto = tkInspectionPlanService.save(tkInspectionPlanDTO);
  119 + TkInspectionPlanDTO dto = tkInspectionPlanService.save(tkInspectionPlanDTO, false);
120 120 return ResponseEntity.ok(dto);
121 121 }
122 122
  123 + @PostMapping("/changeStatus")
  124 + @PreAuthorize("hasAnyAuthority('TENANT_ADMIN','CUSTOMER_USER')")
  125 + public ResponseEntity<Boolean> changeStatus(@RequestBody TkInspectionPlanDTO tkInspectionPlanDTO) throws ThingsboardException {
  126 + if (tkInspectionPlanDTO == null || tkInspectionPlanDTO.getStatus() == null || StringUtils.isBlank(tkInspectionPlanDTO.getId())) {
  127 + throw new RuntimeException("参数错误!");
  128 + }
  129 +
  130 + TkInspectionPlanDTO saveDto = new TkInspectionPlanDTO();
  131 + saveDto.setStatus(tkInspectionPlanDTO.getStatus());
  132 + saveDto.setId(tkInspectionPlanDTO.getId());
  133 + saveDto.setTenantId(getCurrentUser().getCurrentTenantId());
  134 + tkInspectionPlanService.save(saveDto, true);
  135 + return ResponseEntity.ok(true);
  136 + }
  137 +
123 138 @GetMapping("/detail")
124 139 @PreAuthorize("hasAnyAuthority('TENANT_ADMIN','CUSTOMER_USER')")
125 140 public ResponseEntity<TkInspectionPlanDTO> detail(@RequestParam("id") String id) throws ThingsboardException {
... ...
... ... @@ -7,6 +7,7 @@ import lombok.RequiredArgsConstructor;
7 7 import lombok.extern.slf4j.Slf4j;
8 8 import org.apache.commons.collections4.CollectionUtils;
9 9 import org.apache.commons.collections4.MapUtils;
  10 +import org.apache.commons.lang3.BooleanUtils;
10 11 import org.apache.commons.lang3.StringUtils;
11 12 import org.springframework.stereotype.Service;
12 13 import org.thingsboard.server.common.data.yunteng.core.exception.TkDataValidationException;
... ... @@ -93,7 +94,7 @@ public class TkInspectionPlanServiceImpl extends AbstractBaseService<TkInspectio
93 94 }
94 95
95 96 @Override
96   - public TkInspectionPlanDTO save(TkInspectionPlanDTO tkInspectionPlanDTO) {
  97 + public TkInspectionPlanDTO save(TkInspectionPlanDTO tkInspectionPlanDTO, boolean changeStatus) {
97 98 List<TkCheckDetailsDTO> checkDetailsDTOList = new ArrayList<>(tkInspectionPlanDTO.getTkCheckDetailsDTOList());
98 99 checkDto(tkInspectionPlanDTO);
99 100 TkInspectionPlanEntity entity = new TkInspectionPlanEntity();
... ... @@ -108,6 +109,10 @@ public class TkInspectionPlanServiceImpl extends AbstractBaseService<TkInspectio
108 109 }
109 110
110 111 entity.copyToDTO(tkInspectionPlanDTO);
  112 + if (BooleanUtils.isTrue(changeStatus)) {
  113 + return tkInspectionPlanDTO;
  114 + }
  115 +
111 116 String id = tkInspectionPlanDTO.getId();
112 117 for (int index = 0; index < checkDetailsDTOList.size(); index++) {
113 118 if (CollectionUtils.isEmpty(checkDetailsDTOList)) {
... ...
... ... @@ -11,7 +11,7 @@ public interface TkInspectionPlanService extends BaseService<TkInspectionPlanEnt
11 11
12 12 TkPageData<TkInspectionPlanDTO> page(Map<String, Object> queryMap, String tenantId);
13 13
14   - TkInspectionPlanDTO save(TkInspectionPlanDTO tkInspectionPlanDTO);
  14 + TkInspectionPlanDTO save(TkInspectionPlanDTO tkInspectionPlanDTO, boolean changeStatus);
15 15
16 16 TkInspectionPlanDTO get(String id);
17 17
... ...