zhoushihao
2 天以前 4e3b8155722b66e25df3c6fd42cc586b68dea391
hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/bigstorage/controller/BigStorageCageDetailsController.java
@@ -1,15 +1,28 @@
package com.mes.bigstorage.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.mes.bigstorage.entity.BigStorageCageDetails;
import com.mes.bigstorage.entity.dto.GlassInfoLackDTO;
import com.mes.bigstorage.entity.dto.TemperingGlassCountDTO;
import com.mes.bigstorage.entity.vo.BigStorageQueryVO;
import com.mes.bigstorage.service.BigStorageCageDetailsService;
import com.mes.bigstorage.service.BigStorageCageService;
import com.mes.common.config.Const;
import com.mes.utils.RedisUtil;
import com.mes.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
 * <p>
@@ -19,55 +32,170 @@
 * @author zhoush
 * @since 2024-03-27
 */
@Api(description = "理片笼详情")
@Api(tags = "理片笼详情")
@RestController
@RequestMapping("/bigStorageCageDetails")
public class BigStorageCageDetailsController {
    @Autowired
    private BigStorageCageDetailsService bigStorageCageDetailsService;
    @Autowired
    private BigStorageCageService bigStorageCageService;
    @Resource
    private RedisUtil redisUtil;
    @ApiOperation("玻璃详情查询")
    @PostMapping("/selectBigStorageCageDetails")
    public Result selectBigStorageCageDetails(String glassId) {
        BigStorageCageDetails bigStorageCageDetails=bigStorageCageDetailsService.selectBigStorageCageDetails(glassId);
        return Result.build(200,"查询成功",bigStorageCageDetails);
    public Result selectBigStorageCageDetails(@RequestBody Map map) {
        List<BigStorageCageDetails> bigStorageCageDetails = bigStorageCageDetailsService.selectBigStorageCageDetails(map.get("glassId").toString());
        if (bigStorageCageDetails.size() > 0) {
            return Result.build(200, "查询成功", bigStorageCageDetails);
        } else {
            return Result.build(200, "查询失败,无此玻璃id", bigStorageCageDetails);
        }
    }
    @ApiOperation("理片笼详情添加")
    @PostMapping("/insertBigStorageCageDetails")
    public Result insertBigStorageCageDetails(BigStorageCageDetails bigStorageCageDetails) {
    public Result insertBigStorageCageDetails(@RequestBody BigStorageCageDetails bigStorageCageDetails) {
        bigStorageCageDetailsService.insertBigStorageCageDetails(bigStorageCageDetails);
        return Result.build(200,"添加成功",1);
        return Result.build(200, "添加成功", bigStorageCageService.querybigStorageCageDetail());
    }
    @ApiOperation("理片笼详情删除")
    @PostMapping("/deleteBigStorageCageDetails")
    public Result deleteBigStorageCageDetails(BigStorageCageDetails bigStorageCageDetails) {
    public Result deleteBigStorageCageDetails(@RequestBody BigStorageCageDetails bigStorageCageDetails) {
        bigStorageCageDetailsService.deleteBigStorageCageDetails(bigStorageCageDetails);
        return Result.build(200,"删除成功",1);
        return Result.build(200, "删除成功", bigStorageCageService.querybigStorageCageDetail());
    }
    @ApiOperation("理片笼任务破损0/拿走1")
    @ApiOperation("理片笼笼内玻璃破损0/拿走1")
    @PostMapping("/damageBigStorageCageDetails")
    public Result damageBigStorageCageDetails(BigStorageCageDetails bigStorageCageDetails,int status) {
        bigStorageCageDetailsService.damageBigStorageCageDetails(bigStorageCageDetails.getGlassId(),status);
        return Result.build(200,"破损成功",1);
    public Result damageBigStorageCageDetails(@RequestBody BigStorageCageDetails bigStorageCageDetails, int status) {
        bigStorageCageDetailsService.damageBigStorageCageDetails(bigStorageCageDetails.getGlassId(), status);
        return Result.build(200, "破损/拿走成功", 1);
    }
    @ApiOperation("理片笼任务完成")
    @PostMapping("/finishBigStorageCageDetails")
    public Result finishBigStorageCageDetails(BigStorageCageDetails bigStorageCageDetails) {
    public Result finishBigStorageCageDetails(@RequestBody BigStorageCageDetails bigStorageCageDetails) {
        bigStorageCageDetailsService.finishBigStorageCageDetails(bigStorageCageDetails);
        return Result.build(200,"破损成功",1);
        return Result.build(200, "任务完成成功", 1);
    }
    @ApiOperation("理片笼任务出片")
    @PostMapping("/outBigStorageCageDetails")
    public Result outBigStorageCageDetails(BigStorageCageDetails bigStorageCageDetails) {
    public Result outBigStorageCageDetails(@RequestBody BigStorageCageDetails bigStorageCageDetails) {
        bigStorageCageDetailsService.outBigStorageCageDetails(bigStorageCageDetails);
        return Result.build(200,"破损成功",1);
        return Result.build(200, "出片添加成功", 1);
    }
    @ApiOperation("指定钢化")
    @PostMapping("/TemperingGlass")
    public Result temperingGlass(@RequestBody BigStorageCageDetails bigStorageCageDetails) {
        boolean result = bigStorageCageDetailsService
                .temperingGlass(bigStorageCageDetails.getTemperingLayoutId().toString(), bigStorageCageDetails.getEngineerId(), bigStorageCageDetails.getTemperingFeedSequence().toString());
        if (result == true) {
            return Result.build(200, "指定钢化成功", 1);
        } else {
            return Result.build(200, "已存在钢化任务,请等待钢化完成再指定钢化", 1);
        }
    }
    @ApiOperation("指定钢化工程")
    @PostMapping("/appointTemperingEngineerId")
    public Result appointTemperingEngineerId(String engineerId) {
        boolean result = bigStorageCageDetailsService.appointTemperingEngineerId(engineerId);
        if (result == true) {
            return Result.build(200, "指定钢化成功", 1);
        } else {
            return Result.build(200, "已存在钢化任务,请等待钢化完成再指定钢化", 1);
        }
    }
    @ApiOperation("取消当前钢化")
    @PostMapping("/cancelTemperingTask")
    public Result<Boolean> cancelTemperingTask() {
        boolean result = bigStorageCageDetailsService.cancelTemperingTask();
        if (result == true) {
            return Result.build(200, "取消当前钢化成功", result);
        } else {
            return Result.build(200, "取消当前钢化失败", result);
        }
    }
    @ApiOperation("钢化/非钢化查询:0 非钢化  1:钢化")
    @PostMapping("/selectTemperingGlass")
    public Result<List<TemperingGlassCountDTO>> selectTemperingGlass(int isTempering) {
        return Result.build(200, "查询成功", bigStorageCageDetailsService.selectTemperingGlass(isTempering));
    }
    @ApiOperation("笼内实际数量查询")
    @PostMapping("/queryRealGlassInfo")
    public Result<List<BigStorageCageDetails>> queryRealGlassInfo(@RequestBody BigStorageQueryVO bigStorageQueryVO) {
        return Result.build(200, "查询成功", bigStorageCageDetailsService.queryRealGlassInfo(bigStorageQueryVO));
    }
    @ApiOperation("缺片数量查询")
    @PostMapping("/queryLackGlassInfo")
    public Result<List<GlassInfoLackDTO>> queryLackGlassInfo(@RequestBody BigStorageQueryVO bigStorageQueryVO) {
        return Result.build(200, "查询成功", bigStorageCageDetailsService.queryLackGlassInfo(bigStorageQueryVO));
    }
    @ApiOperation("是否调度开关")
    @PostMapping("/dispatchSwitch")
    public Result dispatchSwitch(Boolean flag) {
        bigStorageCageDetailsService.dispatchSwitch(flag);
        return Result.build(200, "修改成功", redisUtil.getCacheObject("dispatchSwitch"));
    }
    @ApiOperation("是否钢化开关")
    @PostMapping("/temperingSwitch")
    public Result temperingSwitch(Boolean flag) {
        bigStorageCageDetailsService.temperingSwitch(flag);
        return Result.build(200, "修改成功", redisUtil.getCacheObject("temperingSwitch"));
    }
    @ApiOperation("流程卡查询")
    @PostMapping("/selectFlowCardByCache")
    public Result selectFlowCardByCache() {
        List<Map<String, Object>> flowCardIdCount = bigStorageCageDetailsService.listMaps(
                new QueryWrapper<BigStorageCageDetails>()
                        .select("flow_card_id,layer,count(*) as count")
                        .eq("state", Const.GLASS_STATE_IN)
                        .eq("tempering_layout_id", 0)
                        .groupBy("flow_card_id,layer")
        );
        return Result.build(200, "查询成功", flowCardIdCount);
    }
    @ApiOperation("指定流程卡")
    @PostMapping("/appointFlowCard")
    public Result appointFlowCard(@RequestBody BigStorageCageDetails bigStorageCageDetails) {
        List<BigStorageCageDetails> bigStorageCageDetailsList = bigStorageCageDetailsService.list(
                new LambdaQueryWrapper<BigStorageCageDetails>()
                        .eq(BigStorageCageDetails::getState, Const.GLASS_STATE_ARTIFICIAL)
        );
        if (bigStorageCageDetailsList.size() == 0) {
            bigStorageCageDetailsService.update(
                    new LambdaUpdateWrapper<BigStorageCageDetails>()
                            .set(BigStorageCageDetails::getState, Const.GLASS_STATE_ARTIFICIAL)
                            .eq(BigStorageCageDetails::getFlowCardId, bigStorageCageDetails.getFlowCardId())
                            .eq(BigStorageCageDetails::getLayer, bigStorageCageDetails.getLayer())
                            .eq(BigStorageCageDetails::getState, Const.GLASS_STATE_IN)
            );
            return Result.build(200, "指定流程卡成功", 1);
        } else {
            return Result.build(200, "指定流程卡成功", 1);
        }
    }
    @ApiOperation("大理片笼报破损")
    @PostMapping("/bigStorageGlassDamageByGlassId")
    public Result<String> bigStorageGlassDamageByGlassId(@RequestBody Map<String, String> map) {
        String glassId = map.get("glassId");
        return Result.build(200, "报破损成功", bigStorageCageDetailsService.bigStorageGlassDamageByGlassId(glassId));
    }
}