| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.config.TenantContext; |
| | | import org.jeecg.common.constant.CommonCacheConstant; |
| | | import org.jeecg.common.system.query.QueryGenerator; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.common.util.RedisUtil; |
| | | import org.jeecg.common.util.TokenUtils; |
| | | import org.jeecg.common.util.oConvertUtils; |
| | | import org.jeecg.config.mybatis.MybatisPlusSaasConfig; |
| | | import org.jeecg.modules.dry.common.CacheConstants; |
| | |
| | | import org.jeecg.common.system.base.controller.JeecgController; |
| | | import org.jetbrains.annotations.NotNull; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.cache.annotation.CacheEvict; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import org.springframework.web.multipart.MultipartHttpServletRequest; |
| | |
| | | //是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】 |
| | | if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){ |
| | | dryEquipment.setTenantId(oConvertUtils.getInt(TenantContext.getTenant(),0)); |
| | | //fix: shiro排除的接口无法从jwt获取tenantId |
| | | String tenantId = TokenUtils.getTenantIdByRequest(req); |
| | | if(StringUtils.isNotEmpty(tenantId)){ |
| | | dryEquipment.setTenantId(Integer.parseInt(tenantId)); |
| | | } |
| | | } |
| | | //------------------------------------------------------------------------------------------------ |
| | | QueryWrapper<DryEquipment> queryWrapper = QueryGenerator.initQueryWrapper(dryEquipment, req.getParameterMap()); |
| | |
| | | queryWrapper.orderByAsc("code"); |
| | | List<DryEquipment> eqps = dryEquipmentService.list(queryWrapper); |
| | | List<DryEquipmentVo> equipmentVos = new ArrayList<>(); |
| | | if(eqps == null){ |
| | | return equipmentVos; |
| | | } |
| | | |
| | | eqps.stream().forEach(item -> { |
| | | DryEquipmentVo dryEquipmentVo = BeanUtil.toBean(item, DryEquipmentVo.class); |
| | | DryEqpType dryEqpType = dryEqpTypeService.getById(item.getType()); |
| | | if(dryEqpType == null){ |
| | | equipmentVos.add(dryEquipmentVo); |
| | | return; |
| | | } |
| | | dryEquipmentVo.setType(dryEqpType.getName()); |
| | | dryEquipmentVo.setDryEfficiency(dryEqpType.getDryEfficiency()); |
| | | dryEquipmentVo.setSteamConsumption(dryEqpType.getSteamConsumption()); |
| | |
| | | @ApiOperation(value="干燥机-添加", notes="干燥机-添加") |
| | | @RequiresPermissions("dry:dry_equipment:add") |
| | | @PostMapping(value = "/add") |
| | | @CacheEvict(value = {CommonCacheConstant.DRY_CACHE_TENANT_EQUS_LIST,CommonCacheConstant.DRY_CACHE_TENANT_EQUS},allEntries=true) |
| | | public Result<String> add(@RequestBody DryEquipment dryEquipment) { |
| | | dryEquipmentService.save(dryEquipment); |
| | | redisUtil.del(CacheConstants.RedisKeyEnum.EQP_MAP.getCode()); |
| | | return Result.OK("添加成功!"); |
| | | } |
| | | |
| | |
| | | @ApiOperation(value="干燥机-编辑", notes="干燥机-编辑") |
| | | @RequiresPermissions("dry:dry_equipment:edit") |
| | | @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) |
| | | @CacheEvict(value = {CommonCacheConstant.DRY_CACHE_TENANT_EQUS_LIST,CommonCacheConstant.DRY_CACHE_TENANT_EQUS},allEntries=true) |
| | | public Result<String> edit(@RequestBody DryEquipment dryEquipment) { |
| | | // 删除redis缓存 |
| | | redisUtil.del(CacheConstants.RedisKeyEnum.EQP_MAP.getCode()); |
| | | dryEquipmentService.updateById(dryEquipment); |
| | | |
| | | return Result.OK("编辑成功!"); |
| | | } |
| | | |
| | |
| | | @ApiOperation(value="干燥机-通过id删除", notes="干燥机-通过id删除") |
| | | @RequiresPermissions("dry:dry_equipment:delete") |
| | | @DeleteMapping(value = "/delete") |
| | | @CacheEvict(value = {CommonCacheConstant.DRY_CACHE_TENANT_EQUS_LIST,CommonCacheConstant.DRY_CACHE_TENANT_EQUS},allEntries=true) |
| | | public Result<String> delete(@RequestParam(name="id",required=true) String id) { |
| | | redisUtil.del(CacheConstants.RedisKeyEnum.EQP_MAP.getCode()); |
| | | dryEquipmentService.removeById(id); |
| | |
| | | @ApiOperation(value="干燥机-批量删除", notes="干燥机-批量删除") |
| | | @RequiresPermissions("dry:dry_equipment:deleteBatch") |
| | | @DeleteMapping(value = "/deleteBatch") |
| | | @CacheEvict(value = {CommonCacheConstant.DRY_CACHE_TENANT_EQUS_LIST,CommonCacheConstant.DRY_CACHE_TENANT_EQUS},allEntries=true) |
| | | 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(","))); |