¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.limslaboratory.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | |
| | | import java.text.ParseException; |
| | | import java.util.*; |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.yuanchu.limslaboratory.pojo.Inspection; |
| | | import com.yuanchu.limslaboratory.pojo.vo.InspectionVo; |
| | | import com.yuanchu.limslaboratory.service.LinkBasicInformationService; |
| | | import com.yuanchu.limslaboratory.service.RawMaterialService; |
| | | 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 com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.limslaboratory.service.InspectionService; |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * ç³è¯·è¡¨(Inspection)表æ§å¶å± |
| | | * |
| | | * @author zss |
| | | * @since 2023-08-03 13:03:36 |
| | | */ |
| | | @Api(tags = "è¯éªç®¡ç-->æ£éªç³è¯·") |
| | | @RestController |
| | | @RequestMapping("/inspection") |
| | | public class InspectionController { |
| | | |
| | | @Autowired |
| | | private InspectionService inspectionService; |
| | | |
| | | @Resource |
| | | RawMaterialService rawMaterialService; |
| | | |
| | | @Resource |
| | | LinkBasicInformationService linkBasicInformationService; |
| | | |
| | | @ApiOperation(value = "æ¥è¯¢æ£éªç³è¯·åå表") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "pageSize", value = "页æ°", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "countSize", value = "æ¡æ°/页", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "message", value = "ç³è¯·åå·/åææåç§°", dataTypeClass = String.class) |
| | | }) |
| | | @GetMapping("/selectInspectsList") |
| | | public Result selectInspectsList(int pageSize, int countSize, String message) { |
| | | IPage<Map<String, Object>> inspectionPage = inspectionService.selectInspectsList(new Page<Object>(pageSize, countSize), message); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("total", inspectionPage.getTotal()); |
| | | map.put("row", inspectionPage.getRecords()); |
| | | return Result.success(map); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "æ¥è¯¢æææ¥æ£") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "type", value = "ç±»å", dataTypeClass = Integer.class, required = true) |
| | | }) |
| | | @GetMapping("/selectAll") |
| | | public Result selectAll(Integer type) { |
| | | switch (type) { |
| | | case 0 : |
| | | //åææ |
| | | return Result.success(rawMaterialService.selectRawmaAll()); |
| | | case 1 : |
| | | //å§æå |
| | | return Result.success(linkBasicInformationService.selectLinkAll()); |
| | | case 2 : |
| | | //æåæ£éª |
| | | return Result.success("请è¾å
¥æ£éªä¿¡æ¯!"); |
| | | } |
| | | return Result.fail("ç±»åé误!"); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "éæ©åæææ¥æ£") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "id", value = "åæææ¥æ£åid", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "startTime", value = "æ£éªå¼å§æ¥æ", dataTypeClass = String.class, required = true), |
| | | @ApiImplicitParam(name = "endTime", value = "æ£éªç»ææ¥æ", dataTypeClass = String.class, required = true) |
| | | }) |
| | | @GetMapping("/selectRawmaById") |
| | | public Result selectRawmaById(Integer id, String startTime, String endTime) throws ParseException { |
| | | return Result.success(rawMaterialService.selectRawmaById(id,startTime,endTime)); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "éæ©å§ææ¥æ£åæ ·å") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "bid", value = "å§ææ¥æ£åid", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "did", value = "å§ææ¥æ£æ ·åid", dataTypeClass = Integer.class, required = true) |
| | | }) |
| | | @GetMapping("/selectLinkByid") |
| | | public Result selectLinkByid(Integer bid, Integer did) { |
| | | return Result.success(linkBasicInformationService.selectLinkByid(bid, did)); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "æ°å¢æ£éªå") |
| | | @PostMapping("/addInspect") |
| | | public Result addInspect(@RequestHeader("token") String token, @RequestBody InspectionVo inspectionVo) throws Exception { |
| | | Object object = RedisUtil.get(token); |
| | | Map<String, Object> unmarshal = JackSonUtil.unmarshal(JackSonUtil.marshal(object), Map.class); |
| | | return Result.success(inspectionService.addInspect((Integer) unmarshal.get("id"), inspectionVo)); |
| | | } |
| | | |
| | | @ApiOperation(value = "æ ¹æ®æ£éªåidæ¥è¯¢åæææ£éªå详æ
") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "id", value = "æ£éªåid", dataTypeClass = Integer.class, required = true) |
| | | }) |
| | | @GetMapping("/selectInspectsListById") |
| | | public Result selectInspectsListById(Integer id) { |
| | | return Result.success(inspectionService.selectInspectsListById(id)); |
| | | } |
| | | |
| | | @ApiOperation(value = "䏿¥(æ´æ°æ£éªç¶æ)") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "id", value = "æ£éªåid", dataTypeClass = Integer.class, required = true) |
| | | }) |
| | | @PostMapping("/updateInspectsById") |
| | | public Result updateInspectsById(Integer id) { |
| | | //妿已ç»ä¸æ¥äºä¸è½å䏿¬¡ä¸æ¥ |
| | | Inspection inspection = inspectionService.getById(id); |
| | | if (ObjectUtils.isNotEmpty(inspection.getInspectionStatus())) { |
| | | return Result.fail("å·²ç»ä¸æ¥è¿äº,ä¸è½åæ¬¡ä¸æ¥!"); |
| | | } |
| | | return Result.success(inspectionService.updateInspectsById(id)); |
| | | } |
| | | |
| | | |
| | | } |
| | | |