| | |
| | | package org.jeecg.modules.dry.controller; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | import java.net.URLDecoder; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.config.TenantContext; |
| | | import org.jeecg.common.system.query.QueryGenerator; |
| | | import org.jeecg.common.util.RedisUtil; |
| | | import org.jeecg.common.util.oConvertUtils; |
| | | import org.jeecg.config.mybatis.MybatisPlusSaasConfig; |
| | | import org.jeecg.modules.dry.common.CacheConstants; |
| | | import org.jeecg.modules.dry.entity.DryEqpType; |
| | | import org.jeecg.modules.dry.entity.DryEquipment; |
| | | import org.jeecg.modules.dry.service.IDryEqpTypeService; |
| | | import org.jeecg.modules.dry.service.IDryEquipmentService; |
| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import org.jeecg.modules.dry.vo.DryEquipmentVo; |
| | | import org.jeecgframework.poi.excel.ExcelImportUtil; |
| | | import org.jeecgframework.poi.excel.def.NormalExcelConstants; |
| | | import org.jeecgframework.poi.excel.entity.ExportParams; |
| | |
| | | @Autowired |
| | | private IDryEqpTypeService dryEqpTypeService; |
| | | |
| | | |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | /** |
| | | * 分页列表查询 |
| | | * |
| | |
| | | |
| | | @ApiOperation(value="查询所有干燥机", notes="查询所有干燥机") |
| | | @GetMapping(value = "/listAll") |
| | | public Result<List<DryEquipment>> queryAllEquipment(DryEquipment dryEquipment, HttpServletRequest req) { |
| | | public Result<List<DryEquipmentVo>> queryAllEquipment(DryEquipment dryEquipment, HttpServletRequest req) { |
| | | //------------------------------------------------------------------------------------------------ |
| | | //是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】 |
| | | if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){ |
| | |
| | | |
| | | queryWrapper.orderByAsc("code"); |
| | | List<DryEquipment> eqps = dryEquipmentService.list(queryWrapper); |
| | | List<DryEquipmentVo> equipmentVos = new ArrayList<>(); |
| | | eqps.stream().forEach(item -> { |
| | | item.setType(dryEqpTypeService.getById(item.getType()).getName()); |
| | | DryEquipmentVo dryEquipmentVo = BeanUtil.toBean(item, DryEquipmentVo.class); |
| | | DryEqpType dryEqpType = dryEqpTypeService.getById(item.getType()); |
| | | dryEquipmentVo.setType(dryEqpType.getName()); |
| | | dryEquipmentVo.setDryEfficiency(dryEqpType.getDryEfficiency()); |
| | | dryEquipmentVo.setSteamConsumption(dryEqpType.getSteamConsumption()); |
| | | dryEquipmentVo.setPowerConsumption(dryEqpType.getPowerConsumption()); |
| | | equipmentVos.add(dryEquipmentVo); |
| | | }); |
| | | return Result.OK(eqps); |
| | | return Result.OK(equipmentVos); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 添加 |
| | |
| | | @RequiresPermissions("dry:dry_equipment:edit") |
| | | @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) |
| | | public Result<String> edit(@RequestBody DryEquipment dryEquipment) { |
| | | redisUtil.del(CacheConstants.RedisKeyEnum.EQP_MAP.getCode()); |
| | | dryEquipmentService.updateById(dryEquipment); |
| | | |
| | | return Result.OK("编辑成功!"); |
| | | } |
| | | |
| | |
| | | @RequiresPermissions("dry:dry_equipment:delete") |
| | | @DeleteMapping(value = "/delete") |
| | | public Result<String> delete(@RequestParam(name="id",required=true) String id) { |
| | | redisUtil.del(CacheConstants.RedisKeyEnum.EQP_MAP.getCode()); |
| | | dryEquipmentService.removeById(id); |
| | | return Result.OK("删除成功!"); |
| | | } |
| | |
| | | @RequiresPermissions("dry:dry_equipment:deleteBatch") |
| | | @DeleteMapping(value = "/deleteBatch") |
| | | public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) { |
| | | redisUtil.del(CacheConstants.RedisKeyEnum.EQP_MAP.getCode()); |
| | | this.dryEquipmentService.removeByIds(Arrays.asList(ids.split(","))); |
| | | return Result.OK("批量删除成功!"); |
| | | } |
| | |
| | | //@AutoLog(value = "干燥机-通过id查询") |
| | | @ApiOperation(value="干燥机-通过id查询", notes="干燥机-通过id查询") |
| | | @GetMapping(value = "/queryById") |
| | | public Result<DryEquipment> queryById(@RequestParam(name="id",required=true) String id) { |
| | | public Result<DryEquipmentVo> queryById(@RequestParam(name="id",required=true) String id) { |
| | | DryEquipment dryEquipment = dryEquipmentService.getById(id); |
| | | dryEquipment.setType(dryEqpTypeService.getById(dryEquipment.getType()).getName()); |
| | | DryEquipmentVo dryEquipmentVo = BeanUtil.toBean(dryEquipment, DryEquipmentVo.class); |
| | | DryEqpType dryEqpType = dryEqpTypeService.getById(dryEquipment.getType()); |
| | | dryEquipmentVo.setType(dryEqpType.getName()); |
| | | dryEquipmentVo.setDryEfficiency(dryEqpType.getDryEfficiency()); |
| | | dryEquipmentVo.setSteamConsumption(dryEqpType.getSteamConsumption()); |
| | | dryEquipmentVo.setPowerConsumption(dryEqpType.getPowerConsumption()); |
| | | if(dryEquipment==null) { |
| | | return Result.error("未找到对应数据"); |
| | | } |
| | | return Result.OK(dryEquipment); |
| | | return Result.OK(dryEquipmentVo); |
| | | } |
| | | |
| | | /** |