| | |
| | | package com.yuanchu.limslaboratory.controller; |
| | | |
| | | import com.yuanchu.limslaboratory.pojo.EquipmentPoint; |
| | | import com.yuanchu.limslaboratory.pojo.MetricalInformation; |
| | | import com.yuanchu.limslaboratory.pojo.dto.UpdateEquipmentPointDto; |
| | | import com.yuanchu.limslaboratory.pojo.dto.UpdateMetricalInformationDto; |
| | | import com.yuanchu.limslaboratory.service.MetricalInformationService; |
| | | import com.yuanchu.limslaboratory.service.UserService; |
| | | import com.yuanchu.limslaboratory.utils.JackSonUtil; |
| | | import com.yuanchu.limslaboratory.utils.RedisUtil; |
| | | import com.yuanchu.limslaboratory.vo.Result; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @author 江苏鵷雏网络科技有限公司 |
| | | * @since 2023-07-20 |
| | | */ |
| | | @Api(tags = "实验室-->设备台账-->4、计量信息") |
| | | @RestController |
| | | @RequestMapping("/metrical-information") |
| | | public class MetricalInformationController { |
| | | |
| | | @Autowired |
| | | private MetricalInformationService metricalInformationService; |
| | | |
| | | @Autowired |
| | | private UserService userService; |
| | | |
| | | @ApiOperation("添加计量信息") |
| | | @PostMapping("/add") |
| | | public Result<?> addMetricalInformation(MetricalInformation metricalInformation, |
| | | @RequestPart(value = "file", required = false) MultipartFile file) { |
| | | Integer isInsertSuccess = metricalInformationService.addEquipmentPointInformation(metricalInformation, file); |
| | | if (isInsertSuccess == 1){ |
| | | return Result.success("添加【"+ metricalInformation.getMeasurementUnit() +"】成功!"); |
| | | } |
| | | return Result.fail("添加【"+ metricalInformation.getMeasurementUnit() +"】失败!设备码点编码重复!"); |
| | | } |
| | | |
| | | @ApiOperation("查询所有计量信息数据") |
| | | @GetMapping("/list") |
| | | public Result<?> getListMetricalInformation() { |
| | | List<Map<String, Object>> list = metricalInformationService.getListEquipmentPointInformation(); |
| | | return Result.success(list); |
| | | } |
| | | |
| | | @ApiOperation("根据计量信息Id删除数据") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "metricalInformationId", value = "计量信息Id", dataTypeClass = Integer.class, required = true) |
| | | }) |
| | | @DeleteMapping("/delete") |
| | | public Result<?> deleteMetricalInformation(Integer metricalInformationId) { |
| | | Integer isDeleteSuccess = metricalInformationService.deleteMetricalInformation(metricalInformationId); |
| | | if (isDeleteSuccess == 1){ |
| | | return Result.success("删除成功!"); |
| | | } |
| | | return Result.fail("删除失败!"); |
| | | } |
| | | |
| | | @ApiOperation("根据计量信息Id更新数据") |
| | | @PutMapping("/update") |
| | | public Result<?> updateMetricalInformation(UpdateMetricalInformationDto updateMetricalInformationDto, |
| | | @RequestPart(value = "file", required = false) MultipartFile file) throws Exception { |
| | | MetricalInformation metricalInformation = JackSonUtil.unmarshal(JackSonUtil.marshal(updateMetricalInformationDto), MetricalInformation.class); |
| | | Integer isUpdateSuccess = metricalInformationService.updateMetricalInformation(metricalInformation, file); |
| | | if (isUpdateSuccess == 1){ |
| | | return Result.success("更新成功!"); |
| | | } |
| | | return Result.fail("更新失败!"); |
| | | } |
| | | |
| | | @ApiOperation("添加计量信息时负责人下拉框数据") |
| | | @GetMapping("/get_user") |
| | | public Result<?> getMapUserInformation() { |
| | | return Result.success(userService.getUserNameAndId()); |
| | | } |
| | | } |