| | |
| | | package com.yuanchu.limslaboratory.controller; |
| | | |
| | | |
| | | import cn.hutool.core.date.DateUnit; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.limslaboratory.annotation.AuthHandler; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.constraints.NotNull; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @ApiOperation("添加设备码点") |
| | | @PostMapping("/add") |
| | | @AuthHandler |
| | | public Result<?> addEquipmentPointInformation(@RequestHeader("X-Token") String token, @RequestBody EquipmentPoint equipmentPoint) throws Exception { |
| | | public Result<?> addEquipmentPointInformation(@RequestHeader("X-Token") String token, @RequestBody List<EquipmentPoint> equipmentPoints) throws Exception { |
| | | Object object = RedisUtil.get(token); |
| | | Map<String, Object> unmarshal = JackSonUtil.unmarshal(JackSonUtil.marshal(object), Map.class); |
| | | equipmentPoint.setUserId((Integer) unmarshal.get("id")); |
| | | Integer isInsertSuccess = equipmentPointService.addEquipmentPointInformation(equipmentPoint); |
| | | if (isInsertSuccess == 1){ |
| | | return Result.success("添加【"+ equipmentPoint.getEquipmentPointName() +"】成功!"); |
| | | equipmentPoints.forEach(e->{ |
| | | e.setUserId((Integer) unmarshal.get("id")); |
| | | e.setCreateTime(new Date()); |
| | | e.setUpdateTime(new Date()); |
| | | }); |
| | | if(equipmentPointService.addEquipmentPointInformation(equipmentPoints)>0){ |
| | | return Result.success("添加成功"); |
| | | } |
| | | return Result.fail("添加【"+ equipmentPoint.getEquipmentPointName() +"】失败!设备码点编码重复!"); |
| | | return Result.fail("添加失败"); |
| | | } |
| | | |
| | | @ApiOperation("根据仪器Id查询对应设备码点数据") |
| | |
| | | @AuthHandler |
| | | public Result<?> getListEquipmentPointInformation(String InstrumentId) { |
| | | List<Map<String, Object>> list = equipmentPointService.getListEquipmentPointInformation(InstrumentId); |
| | | list.forEach(l->{ |
| | | l.put("instrumentId",null); |
| | | }); |
| | | return Result.success(list); |
| | | } |
| | | |