¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.dry.controller; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | import java.io.IOException; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URLDecoder; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | 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.DryEquipment; |
| | | import org.jeecg.modules.dry.service.IDryEqpTypeService; |
| | | import org.jeecg.modules.dry.service.IDryEquipmentService; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import org.jeecgframework.poi.excel.ExcelImportUtil; |
| | | import org.jeecgframework.poi.excel.def.NormalExcelConstants; |
| | | import org.jeecgframework.poi.excel.entity.ExportParams; |
| | | import org.jeecgframework.poi.excel.entity.ImportParams; |
| | | import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; |
| | | import org.jeecg.common.system.base.controller.JeecgController; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import org.springframework.web.multipart.MultipartHttpServletRequest; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | import com.alibaba.fastjson.JSON; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.jeecg.common.aspect.annotation.AutoLog; |
| | | import org.apache.shiro.authz.annotation.RequiresPermissions; |
| | | |
| | | /** |
| | | * @Description: å¹²ç¥æº |
| | | * @Author: jeecg-boot |
| | | * @Date: 2023-03-08 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Api(tags="å¹²ç¥æº") |
| | | @RestController |
| | | @RequestMapping("/dry/dryEquipment") |
| | | @Slf4j |
| | | public class DryEquipmentController extends JeecgController<DryEquipment, IDryEquipmentService> { |
| | | @Autowired |
| | | private IDryEquipmentService dryEquipmentService; |
| | | |
| | | @Autowired |
| | | private IDryEqpTypeService dryEqpTypeService; |
| | | |
| | | |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | /** |
| | | * å页å表æ¥è¯¢ |
| | | * |
| | | * @param dryEquipment |
| | | * @param pageNo |
| | | * @param pageSize |
| | | * @param req |
| | | * @return |
| | | */ |
| | | //@AutoLog(value = "å¹²ç¥æº-å页å表æ¥è¯¢") |
| | | @ApiOperation(value="å¹²ç¥æº-å页å表æ¥è¯¢", notes="å¹²ç¥æº-å页å表æ¥è¯¢") |
| | | @GetMapping(value = "/list") |
| | | public Result<IPage<DryEquipment>> queryPageList(DryEquipment dryEquipment, |
| | | @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, |
| | | @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, |
| | | HttpServletRequest req) { |
| | | //------------------------------------------------------------------------------------------------ |
| | | //æ¯å¦å¼å¯ç³»ç»ç®¡ç模åçå¤ç§æ·æ°æ®é离ãSAASå¤ç§æ·æ¨¡å¼ã |
| | | if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){ |
| | | dryEquipment.setTenantId(oConvertUtils.getInt(TenantContext.getTenant(),0)); |
| | | } |
| | | //------------------------------------------------------------------------------------------------ |
| | | QueryWrapper<DryEquipment> queryWrapper = QueryGenerator.initQueryWrapper(dryEquipment, req.getParameterMap()); |
| | | Page<DryEquipment> page = new Page<DryEquipment>(pageNo, pageSize); |
| | | IPage<DryEquipment> pageList = dryEquipmentService.page(page, queryWrapper); |
| | | return Result.OK(pageList); |
| | | } |
| | | |
| | | @ApiOperation(value="æ¥è¯¢ææå¹²ç¥æº", notes="æ¥è¯¢ææå¹²ç¥æº") |
| | | @GetMapping(value = "/listAll") |
| | | public Result<List<DryEquipment>> queryAllEquipment(DryEquipment dryEquipment, HttpServletRequest req) { |
| | | //------------------------------------------------------------------------------------------------ |
| | | //æ¯å¦å¼å¯ç³»ç»ç®¡ç模åçå¤ç§æ·æ°æ®é离ãSAASå¤ç§æ·æ¨¡å¼ã |
| | | if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){ |
| | | dryEquipment.setTenantId(oConvertUtils.getInt(TenantContext.getTenant(),0)); |
| | | } |
| | | //------------------------------------------------------------------------------------------------ |
| | | QueryWrapper<DryEquipment> queryWrapper = QueryGenerator.initQueryWrapper(dryEquipment, req.getParameterMap()); |
| | | |
| | | queryWrapper.orderByAsc("code"); |
| | | List<DryEquipment> eqps = dryEquipmentService.list(queryWrapper); |
| | | eqps.stream().forEach(item -> { |
| | | item.setType(dryEqpTypeService.getById(item.getType()).getName()); |
| | | }); |
| | | return Result.OK(eqps); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * æ·»å |
| | | * |
| | | * @param dryEquipment |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "å¹²ç¥æº-æ·»å ") |
| | | @ApiOperation(value="å¹²ç¥æº-æ·»å ", notes="å¹²ç¥æº-æ·»å ") |
| | | @RequiresPermissions("dry:dry_equipment:add") |
| | | @PostMapping(value = "/add") |
| | | public Result<String> add(@RequestBody DryEquipment dryEquipment) { |
| | | dryEquipmentService.save(dryEquipment); |
| | | return Result.OK("æ·»å æåï¼"); |
| | | } |
| | | |
| | | /** |
| | | * ç¼è¾ |
| | | * |
| | | * @param dryEquipment |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "å¹²ç¥æº-ç¼è¾") |
| | | @ApiOperation(value="å¹²ç¥æº-ç¼è¾", notes="å¹²ç¥æº-ç¼è¾") |
| | | @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("ç¼è¾æå!"); |
| | | } |
| | | |
| | | /** |
| | | * éè¿idå é¤ |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "å¹²ç¥æº-éè¿idå é¤") |
| | | @ApiOperation(value="å¹²ç¥æº-éè¿idå é¤", notes="å¹²ç¥æº-éè¿idå é¤") |
| | | @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("å 餿å!"); |
| | | } |
| | | |
| | | /** |
| | | * æ¹éå é¤ |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "å¹²ç¥æº-æ¹éå é¤") |
| | | @ApiOperation(value="å¹²ç¥æº-æ¹éå é¤", notes="å¹²ç¥æº-æ¹éå é¤") |
| | | @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("æ¹éå 餿å!"); |
| | | } |
| | | |
| | | /** |
| | | * éè¿idæ¥è¯¢ |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | //@AutoLog(value = "å¹²ç¥æº-éè¿idæ¥è¯¢") |
| | | @ApiOperation(value="å¹²ç¥æº-éè¿idæ¥è¯¢", notes="å¹²ç¥æº-éè¿idæ¥è¯¢") |
| | | @GetMapping(value = "/queryById") |
| | | public Result<DryEquipment> queryById(@RequestParam(name="id",required=true) String id) { |
| | | DryEquipment dryEquipment = dryEquipmentService.getById(id); |
| | | dryEquipment.setType(dryEqpTypeService.getById(dryEquipment.getType()).getName()); |
| | | if(dryEquipment==null) { |
| | | return Result.error("æªæ¾å°å¯¹åºæ°æ®"); |
| | | } |
| | | return Result.OK(dryEquipment); |
| | | } |
| | | |
| | | /** |
| | | * 导åºexcel |
| | | * |
| | | * @param request |
| | | * @param dryEquipment |
| | | */ |
| | | @RequiresPermissions("dry:dry_equipment:exportXls") |
| | | @RequestMapping(value = "/exportXls") |
| | | public ModelAndView exportXls(HttpServletRequest request, DryEquipment dryEquipment) { |
| | | return super.exportXls(request, dryEquipment, DryEquipment.class, "å¹²ç¥æº"); |
| | | } |
| | | |
| | | /** |
| | | * éè¿excel导å
¥æ°æ® |
| | | * |
| | | * @param request |
| | | * @param response |
| | | * @return |
| | | */ |
| | | @RequiresPermissions("dry:dry_equipment:importExcel") |
| | | @RequestMapping(value = "/importExcel", method = RequestMethod.POST) |
| | | public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { |
| | | return super.importExcel(request, response, DryEquipment.class); |
| | | } |
| | | |
| | | } |