package com.ho.business.controller;

import cn.hutool.core.bean.BeanUtil;
import com.github.pagehelper.PageInfo;
import com.ho.business.common.BusiTool;
import com.ho.business.constant.DeviceTypeConstant;
import com.ho.business.constant.StationYcTypeConstant;
import com.ho.business.entity.DeviceType;
import com.ho.business.entity.Picture;
import com.ho.business.entity.Station;
import com.ho.business.entity.StationSn;
import com.ho.business.feignclient.FlowFeignClient;
import com.ho.business.feignclient.UserFeignClient;
import com.ho.business.service.*;
import com.ho.business.vo.req.*;
import com.ho.business.vo.req.device.DeviceTypeConfigAddReq;
import com.ho.business.vo.req.picture.PictureQueryReq;
import com.ho.business.vo.req.station.StationStatusReq;
import com.ho.business.vo.resp.*;
import com.ho.business.vo.resp.station.NationStation;
import com.ho.business.vo.resp.station.StationResp;
import com.ho.business.vo.resp.station.StationStatus;
import com.ho.common.tools.annotation.LogAnnotation;
import com.ho.common.tools.annotation.NotSportEnOperation;
import com.ho.common.tools.annotation.TokenIgnore;
import com.ho.common.tools.constant.CommonConstant;
import com.ho.common.tools.constant.ContextConstant;
import com.ho.common.tools.constant.RedisKeyConstant;
import com.ho.common.tools.entity.SimpleUser;
import com.ho.common.tools.entity.UserDetailRespVO;
import com.ho.common.tools.exception.BaseResponseCode;
import com.ho.common.tools.exception.BusinessException;
import com.ho.common.tools.exception.DataResult;
import com.ho.common.tools.service.RedisService;
import com.ho.common.tools.util.PageResult;
import com.ho.common.tools.util.PageUtils;
import com.ho.user.api.entity.SysDept;
import com.ho.user.api.vo.req.QueryDeptReqVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @Description 电站管理
 * Author yule
 * Date 2022/8/29 16:37
 */
@RequestMapping(ContextConstant.BUSINESS + "station")
@RestController
@Api(tags = "业务模块-电站管理")
public class StationController {

    @Autowired
    private StationService stationService;

    @Autowired
    private DeviceService deviceService;

    @Autowired
    private DeviceTypeConfigService deviceTypeConfigService;


    @Autowired
    private StationSnService stationSnService;

    @Autowired
    private RedisService redisService;

    @Autowired
    private PictureService pictureService;

    @Autowired
    private UserFeignClient userFeignClient;

    @Autowired
    FlowFeignClient flowFeignClient;

    @Autowired
    BusiTool busiTool;

    @Value("${spring.profiles.active}")
    private String env;


    @PostMapping("add")
    @ApiOperation(value = "新增电站接口")
    @LogAnnotation(title = "电站管理", action = "新增电站信息")
    //@HzPermission(PermissionConstant.SYS_STATIONMANAGE_ADD)
    @NotSportEnOperation
    public DataResult<Station> add(@RequestBody @Valid StationReqVO vo, HttpServletRequest request) {
        DataResult<Station> result = new DataResult<>();
        Station station = stationService.selectByName(vo.getName());
        if (station != null) {
            throw new BusinessException(BaseResponseCode.STATION_ALREADY_EXISTS);
        }
        QueryDeptReqVO queryDeptReqVO = new QueryDeptReqVO();
        queryDeptReqVO.setDeptId(vo.getDeptId());
        DataResult<SysDept> dataResult = userFeignClient.getTopDept(queryDeptReqVO);
        SysDept data = dataResult.getData();
        vo.setGroupId(data.getId());
        Station add = stationService.insertStation(vo);
        vo.setId(add.getId());
        result.setData(add);
        String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
        List<Integer> ids = new ArrayList<>();
        ids.add(add.getId());
        redisService.updateSimpleUserByToken(token, CommonConstant.UpdateMethod.ADD, ids);
        return result;
    }

    @DeleteMapping("id")
    @ApiOperation(value = "删除电站接口")
    @LogAnnotation(title = "电站管理", action = "删除电站信息")
    //@HzPermission(PermissionConstant.SYS_STATIONMANAGE_DELETE)
    public DataResult deleteByIds(@RequestBody List<Integer> ids, HttpServletRequest request) {
        for (Integer id : ids) {
            //如果电站下有拓扑数据不给删除
            List<DeviceRespVO> deviceRespVOS = deviceService.selectByStationIdAndPId(id, null);
            if (!deviceRespVOS.isEmpty()) {
                throw new BusinessException(BaseResponseCode.STATION_NO_DELETED);
            }
            //如果有工单数据不给删除
            DataResult<Integer> result = flowFeignClient.selectWorkOrderByStationId(id);
            if (result.getData() != null) {
                Integer orderNum = result.getData();
                if (orderNum > 0) {
                    throw new BusinessException(BaseResponseCode.STATION_NO_DELETED);
                }
            }
        }
        //删除电站数据及其先关数据
        stationService.deletedByIds(ids);
        String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
        redisService.updateSimpleUserByToken(token, CommonConstant.UpdateMethod.DELETE, ids);
        return DataResult.success();
    }

    @PutMapping("update")
    @ApiOperation(value = "更新电站接口")
    @LogAnnotation(title = "电站管理", action = "更新电站信息")
    @NotSportEnOperation
    //@HzPermission(PermissionConstant.SYS_STATIONMANAGE_EDIT)
    public DataResult update(@RequestBody @Valid StationPutReqVO vo, HttpServletRequest request) {
        Station stationValue = stationService.selectById(vo.getId());
        Station station = stationService.selectByNameAndId(vo.getName(), vo.getId(), vo.getDeptId());
        if (station != null) {
            throw new BusinessException(BaseResponseCode.STATION_ALREADY_EXISTS);
        }
        if (stationValue != null) {
            if (stationValue.getName() != vo.getName()) {
                //对数据进行处理
                DeviceTypeConfigAddReq reqVo = new DeviceTypeConfigAddReq();
                reqVo.setStationId(vo.getId());
                reqVo.setName(vo.getName());
                deviceTypeConfigService.update(reqVo);
            }
        }
        //vo.setGroupId(user.getGroupId());
        stationService.update(vo);

        return DataResult.success();
    }

    @PostMapping("/{id}")
    @ApiOperation(value = "根据id查询电站接口")
    public DataResult<StationRespVO> selectByIds(@PathVariable @Valid Integer id) {
        DataResult<StationRespVO> result = DataResult.success();
        List<Integer> ids = new ArrayList<>();
        ids.add(id);
        List<StationRespVO> stations = stationService.selectByIds(ids,null);
        StationRespVO stationRespVO = new StationRespVO();
        if (!stations.isEmpty()) {
            stationRespVO = stations.get(0);
            //查询图片对象
            List<PictureRespVO> pictureResps = pictureService.selectBySrcId(id);
            stationRespVO.setPictureResps(pictureResps);
            //根据类型和电站查询，有数据则返回logo图片信息
            Picture pictureRespVO = pictureService.selectByStationAndType(id, CommonConstant.PICTURE.LOGO);
            stationRespVO.setLogoPicture(pictureRespVO);
            //查询sn编码对象
            List<StationSn> stationSnList = stationSnService.getSnListByStationId(id);
            List<String> snList = stationSnList.stream().map(s -> {
                return s.getSn();
            }).collect(Collectors.toList());
            stationRespVO.setSnList(snList);
            result.setData(stationRespVO);
        }
        return result;
    }

    @PostMapping("getLogo/{id}")
    @ApiOperation(value = "根据id获取电站Logo接口")
    public DataResult<Picture> getLogo(@PathVariable @Valid Integer id) {
        Picture pictureRespVO = pictureService.selectByStationAndType(id, CommonConstant.PICTURE.LOGO);
        return DataResult.success(pictureRespVO);
    }

    //根据dept_id查询电站信息
    @PostMapping("selectByDeptId")
    public DataResult<List<Station>> selectByDeptId(@RequestBody QueryDeptReqVO queryDeptReqVO) {
        DataResult<List<Station>> result = DataResult.success();
        List<Station> stations = stationService.selectByDeptId(queryDeptReqVO);
        result.setData(stations);
        return result;
    }


    @PostMapping("/page")
    @ApiOperation(value = "分页查询电站接口")
    public DataResult<PageResult<StationRespVO>> page(@RequestBody @Valid StationPageReqVO stationPageReqVO, HttpServletRequest request) {
        DataResult<PageResult<StationRespVO>> result = DataResult.success();
        String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
        SimpleUser user = redisService.getSimpleUserByToken(token);
        //如果登录人为超级管理员则返回空数据
        if (user.getPlatSuper()) {
            PageResult<StationRespVO> pageResult = new PageResult<>();
            pageResult.setList(new ArrayList<>());
            return DataResult.success(pageResult);
        }
        PageResult<StationRespVO> stationRespVOPageVO = stationService.selectPage(stationPageReqVO, user);
        result.setData(stationRespVOPageVO);
        return result;
    }

    @PostMapping("/all")
    @ApiOperation(value = "查询所有电站接口")
    public DataResult<List<Station>> all() {
        DataResult<List<Station>> result = DataResult.success();
        List<Station> stations = stationService.selectAll();
        result.setData(stations);
        return result;
    }

    @GetMapping()
    @ApiOperation(value = "查询电站类型接口")
    public DataResult<List<DeviceType>> getTypes() {
        DataResult<List<DeviceType>> result = DataResult.success();
        List<DeviceType> deviceTypeList = stationService.selectType();
        result.setData(deviceTypeList);
        return result;
    }

    @PostMapping()
    @ApiOperation(value = "根据登录人员查询所属电站")
    public DataResult<List<Station>> belongingToStation(HttpServletRequest request) {
        List<Station> stationsList = new ArrayList<>();
        //根据所属集团查询电站
        String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
        String lang = request.getHeader(CommonConstant.LANG);
        SimpleUser user = redisService.getSimpleUserByToken(token);
        if (user.getPlatSuper()) {
            return DataResult.success(stationsList);
        }
        List<Station> stations = new ArrayList<>();
        List<Integer> stationIds = user.getStationIds();
        //OPEN环境需要只显示人员所属电站
//        if (EnvConstant.DEV.equals(env) || EnvConstant.OPEN.equals(env)) {
        if (stationIds != null && !stationIds.isEmpty()) {
            List<StationRespVO> stationRespVOS = stationService.selectByIds(stationIds,lang);
            for (StationRespVO stationRespVO : stationRespVOS) {
                Station station = new Station();
                BeanUtil.copyProperties(stationRespVO, station);
                stations.add(station);
            }
        }
//        } else {
//            stations = stationService.selectByGroupId(user.getGroupId());
//        }
        if (stations == null || stations.isEmpty()) {
            return DataResult.success(stationsList);
        }
        return DataResult.success(stations);
    }

    @PostMapping("/provinceStation")
    @ApiOperation(value = "根据省份分组")
    public DataResult<List<ProvinceStation>> getProvinceStationList(HttpServletRequest request) {
        List<ProvinceStation> stationsList = new ArrayList<>();
        //根据所属集团查询电站
        String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
        SimpleUser user = redisService.getSimpleUserByToken(token);
        if (user.getPlatSuper()) {
            return DataResult.success(stationsList);
        }
        stationsList = stationService.getProvinceStationList(user);
        return DataResult.success(stationsList);
    }

    @PostMapping("/nationStation")
    @ApiOperation(value = "根据国家分组")
    public DataResult<StationResp> getNationStationList(HttpServletRequest request) {
        StationResp resp = new StationResp();
        //根据所属集团查询电站
        String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
        SimpleUser user = redisService.getSimpleUserByToken(token);
        if (user.getPlatSuper()) {
            List<NationStation> stationsList = new ArrayList<>();
            resp.setList(stationsList);
            return DataResult.success(resp);
        }
        user.setLang(request.getHeader(CommonConstant.LANG));
        resp = stationService.getNationStationList(user);
        return DataResult.success(resp);
    }


    @PostMapping("/getProvince")
    @ApiOperation(value = "根据id查询电站省份")
    public DataResult<PrvinceRespVO> getProvince(@RequestBody @Valid StationPutReqVO vo) {
        Station station = stationService.selectById(vo.getId());
        PrvinceRespVO respVO = new PrvinceRespVO();
        if (station == null) {
            return DataResult.success(respVO);
        }
        BeanUtils.copyProperties(station, respVO);
        respVO.setName(station.getProvince().replace(CommonConstant.ChineseProvinces.PROVINCE, "").replace(CommonConstant.ChineseProvinces.CITY, ""));
        return DataResult.success(respVO);
    }

    @PostMapping("/selectByName")
    @ApiOperation(value = "根据电站名称查询电站")
    public DataResult<List<Station>> selectByName(@RequestBody @Valid WorkOrderStationReqVO vo, HttpServletRequest request) {
        List<Station> stations = new ArrayList<>();
        //根据所属集团查询电站
        String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
        SimpleUser user = redisService.getSimpleUserByToken(token);
        if (user.getPlatSuper()) {
            return DataResult.success(stations);
        }
        stations = stationService.selectByDimName(vo, user);
        return DataResult.success(stations);
    }

    @PostMapping("/findStationStatus")
    @ApiOperation(value = "集团下电站状态查询(APP新增)")
    public DataResult<List<StationStatus>> findStationStatus(HttpServletRequest request) {
        //根据所属集团查询电站
        String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
        SimpleUser user = redisService.getSimpleUserByToken(token);
        List<StationStatus> stationStatusList = new ArrayList<>();
        //先设置3种类型的数据
        StationStatus stationStatusNormal = new StationStatus();
        stationStatusNormal.setStatusType("normal");
        stationStatusNormal.setStatusName("正常");
        stationStatusList.add(stationStatusNormal);
        StationStatus stationStatusOffline = new StationStatus();
        stationStatusOffline.setStatusType("offline");
        stationStatusOffline.setStatusName("离线");
        stationStatusList.add(stationStatusOffline);
        StationStatus stationStatusFault = new StationStatus();
        stationStatusFault.setStatusType("fault");
        stationStatusFault.setStatusName("故障");
        stationStatusList.add(stationStatusFault);
        return DataResult.success(stationStatusList);
    }

    @PostMapping("/findListByStationStatus")
    @ApiOperation(value = "根据电站状态查询电站接口 (分页)(APP新增)")
    public DataResult<PageResult<Station>> findListByStationStatus(@RequestBody StationStatusReq stationStatusReq, HttpServletRequest request) {
        //根据所属集团查询电站
        String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
        SimpleUser user = redisService.getSimpleUserByToken(token);
        String status = stationStatusReq.getStationStatus();
        //查所有电站
        List<Station> stations = stationService.selectByGroupId(user.getGroupId());
        //结果电站集合
        List<Station> resultList = new ArrayList<>();
        //包含3种 ，正常、离线、故障；其中：离线可以从SN心跳缓存中直接拿到并对比最后更新时间，故障电站可以根据告警模块接口直接拿到
        //如果是正常电站，那么就用总电站数 - (离线+故障)
        //离线电站,如果电站对应sn的缓存时间超过5分钟认为是离线
        if (StationYcTypeConstant.OFFLINE.equals(status)) {
            resultList = stationService.getOfflineStations(stations);
        }
        //故障电站,调用告警模块接口
        else if (StationYcTypeConstant.FAULT.equals(status)) {
            //故障电站暂时设置为0


            /*AlarmConfigQueryVo alarmConfigQueryVo = new AlarmConfigQueryVo();
            alarmConfigQueryVo.setGroupId(user.getGroupId());
            DataResult<List<StationStatusRespVO>> listDataResult = flowFeignClient.normalStation(alarmConfigQueryVo);
            if (listDataResult.isSuccess() && listDataResult.getData() != null) {
                List<StationStatusRespVO> stationStatusList = listDataResult.getData();
                Map<Integer, Boolean> stationStatusMap = stationStatusList.stream()
                        .collect(Collectors.toMap(StationStatusRespVO::getStationId, StationStatusRespVO::getStationStatus));
                for (Station station : stations) {
                    if (stationStatusMap.containsKey(station.getId())) {
                        //status是 false就是故障
                        if (!stationStatusMap.get(station.getId())) {
                            resultList.add(station);
                        }
                    }
                }
            }*/
        }
        //正常的: 全部的 - 离线的 - 故障的
        else if (StationYcTypeConstant.NORMAL.equals(status)) {
            //先找离线的
            List<Station> offlineStations = stationService.getOfflineStations(stations);
            Map<Integer, Station> offlineMap = offlineStations.stream().collect(Collectors.toMap(Station::getId, Station -> Station));
            Map<Integer, Boolean> stationStatusMap = new HashMap<>();
            //故障的map
            /*AlarmConfigQueryVo alarmConfigQueryVo = new AlarmConfigQueryVo();
            alarmConfigQueryVo.setGroupId(user.getGroupId());
            DataResult<List<StationStatusRespVO>> listDataResult = flowFeignClient.normalStation(alarmConfigQueryVo);
            if (listDataResult.isSuccess() && listDataResult.getData() != null) {
                List<StationStatusRespVO> stationStatusList = listDataResult.getData();
                stationStatusMap = stationStatusList.stream()
                        .collect(Collectors.toMap(StationStatusRespVO::getStationId, StationStatusRespVO::getStationStatus));
            }*/
            for (Station station : stations) {
                //是否离线的
                if (offlineMap.containsKey(station.getId())) {
                    continue;
                }
                //是否故障的
                /*if (stationStatusMap.containsKey(station.getId())) {
                    if (!stationStatusMap.get(station.getId())) {
                        continue;
                    }
                }*/
                resultList.add(station);
            }
        }
        //不传状态 ,就查所有电站
        else if (status == null) {
            resultList = stations;
        }
        //内存分页
        PageResult<Station> pageResult = new PageResult<>();
        if (!resultList.isEmpty()) {
            List list = PageUtils.dealList(resultList, stationStatusReq.getPageNum(), stationStatusReq.getPageSize());
            pageResult = PageUtils.getPageResult(new PageInfo<>(list));
            pageResult.setTotalRows(resultList.size());
            pageResult.setTotalPages(resultList.size() / stationStatusReq.getPageSize() + 1);
        } else {
            pageResult = PageUtils.getPageResult(new PageInfo<>(new ArrayList<>()));
        }
        return DataResult.success(pageResult);
    }

    @PostMapping("/pageList")
    @ApiOperation(value = "分页查询电站接口(同步电站筛选时使用)")
    public DataResult<PageResult<StationRespVO>> pageList(@RequestBody @Valid StationPageListReqVO stationPageReqVO, HttpServletRequest request) {
        DataResult<PageResult<StationRespVO>> result = DataResult.success();
        String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
        SimpleUser user = redisService.getSimpleUserByToken(token);
        //如果登录人为超级管理员则返回空数据
        if (user.getPlatSuper()) {
            PageResult<StationRespVO> pageResult = new PageResult<>();
            pageResult.setList(new ArrayList<>());
            return DataResult.success(pageResult);
        }
        stationPageReqVO.setGroupId(user.getGroupId());
        PageResult<StationRespVO> stationRespVOPageVO = stationService.selectPageList(stationPageReqVO);
        result.setData(stationRespVOPageVO);
        return result;
    }

    /********************************以下为apk升级包相关的代码begin*************************************/
    @ApiOperation(value = "获取文件列表")
    @PostMapping("/filePage")
    public DataResult<List<PictureRespVO>> filePage() {
        List<PictureRespVO> list = pictureService.selectAllFile();
        return DataResult.success(list);
    }

    @ApiOperation(value = "获取最新的文件")
    @PostMapping("/selectLastOne")
    @TokenIgnore
    public DataResult<PictureRespVO> selectLastOne(@Param("version") String version) {
        PictureRespVO respVO = pictureService.selectLastOne(version);
        return DataResult.success(respVO);
    }

    @ApiOperation(value = "上传文件")
    @PostMapping("/uploadFile")
    public DataResult<Picture> uploadFile(@RequestParam MultipartFile file, @Param("version") String version, @Param("updateLog") String updateLog, @Param("ownerOrg") String ownerOrg, HttpServletRequest request) {
        String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
        SimpleUser user = redisService.getSimpleUserByToken(token);
        String bucket = DeviceTypeConstant.GROUP + user.getGroupId();
        Picture picture = pictureService.uploadFile(file, version, updateLog, ownerOrg, bucket);
        return DataResult.success(picture);
    }
    /********************************apk升级包相关的代码end*************************************/

    @ApiOperation(value = "上传logo文件")
    @PostMapping("/uploadLogoFile")
    public DataResult<Picture> uploadLogoFile(@RequestParam MultipartFile file, @Param("ownerOrg") String ownerOrg, HttpServletRequest request) {
        String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
        SimpleUser user = redisService.getSimpleUserByToken(token);
        String bucket = DeviceTypeConstant.GROUP + user.getGroupId();
        Picture picture = pictureService.uploadLogoFile(file, ownerOrg, bucket);
        return DataResult.success(picture);
    }

    @ApiOperation(value = "删除文件")
    @PostMapping("/deleteFile")
    public DataResult deleteFile(@Param("pictureId") Integer pictureId, HttpServletRequest request) {
        String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
        SimpleUser user = redisService.getSimpleUserByToken(token);
        //集团id拼接桶名称
        //桶使用固定minio
        String bucket = "filestore";
        pictureService.deletedFile(bucket, user.getGroupId(), pictureId);
        return DataResult.success();
    }

    /**********************************************************/
    /**
     * 上传文件到minio服务器
     *
     * @param vo
     * @return
     */
    @PostMapping("/uploadFileToMinIo")
    @ApiOperation(value = "上传文件到minio服务器")
    public DataResult<Picture> uploadFile(@RequestBody StationReq vo, HttpServletRequest request) {
        Picture picture = pictureService.insertPicture(vo, request);
        return DataResult.success(picture);
    }


    @PostMapping("/queryFile")
    @ApiOperation(value = "查询上传minio文件服务器的文件")
    public DataResult<List<Picture>> queryFile(@RequestBody PictureQueryReq vo) {
        List<Picture> pictures = pictureService.selectAllFileByParams(vo);
        return DataResult.success(pictures);
    }
    /**********************************************************/

    /***********************组态上传图片*********************/
    @ApiOperation(value = "上传组态缩率图文件")
    @PostMapping("/uploadPicture")
    public DataResult<Picture> uploadPicture(@RequestParam MultipartFile file, @Param("isPrivate") Integer isPrivate, @Param("type") Integer type, HttpServletRequest request) {
        String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
        UserDetailRespVO user = redisService.getUserDetailByToken(token);
        //isPrivate(1:私有 2:公有)
        Picture picture = pictureService.uploadPicture(file, type, user, isPrivate);
        return DataResult.success(picture);
    }

    @PostMapping("/queryPicture")
    @ApiOperation(value = "查询上传文件")
    public DataResult<List<Picture>> queryPicture(@RequestBody PictureQueryReq vo, HttpServletRequest request) {
        if (vo.getNeedUser() != null && CommonConstant.ONE.equals(vo.getNeedUser())) {
            String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
            UserDetailRespVO user = redisService.getUserDetailByToken(token);
            vo.setOwnerUser(user.getUsername());
        }
        List<Picture> pictures = pictureService.selectAllFileByParam(vo);
        return DataResult.success(pictures);
    }

    @ApiOperation(value = "删除文件")
    @PostMapping("/deletePicture")
    public DataResult deletePicture(@Param("pictureId") Integer pictureId) {
        pictureService.deletePicture(pictureId);
        return DataResult.success();
    }

    /**********************************************************/


    @ApiOperation(value = "获取术语词典")
    @TokenIgnore
    @PostMapping("/getTermDictionary")
    public DataResult getTermDictionary(@RequestBody(required = false) String language) {
        List<Map<String,String>> result =stationService.getTermDictionary(language);
        return DataResult.success(result);
    }
}
