| | |
| | | package org.jeecg.modules.mdc.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import io.swagger.annotations.Api; |
| | |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.aspect.annotation.AutoLog; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | | import org.jeecg.common.system.base.controller.JeecgController; |
| | | import org.jeecg.common.system.query.QueryGenerator; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.modules.mdc.dto.MdcEquipmentDto; |
| | | import org.jeecg.modules.mdc.entity.MdcEquipment; |
| | |
| | | import org.jeecg.modules.mdc.vo.MdcEquipmentVo; |
| | | import org.jeecg.modules.system.model.DepartIdModel; |
| | | import org.jeecg.modules.system.model.ProductionIdModel; |
| | | import org.jeecgframework.poi.excel.def.NormalExcelConstants; |
| | | import org.jeecgframework.poi.excel.entity.ExportParams; |
| | | import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | |
| | |
| | | @AutoLog(value = "设备表-分页列表查询") |
| | | @ApiOperation(value = "设备表-分页列表查询", notes = "设备表-分页列表查询") |
| | | @GetMapping(value = "/list") |
| | | public Result<IPage<MdcEquipment>> queryPageList(MdcEquipment mdcEquipment, |
| | | public Result<IPage<MdcEquipment>> queryPageList(MdcEquipmentVo mdcEquipment, |
| | | @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, |
| | | @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, |
| | | HttpServletRequest req) { |
| | | QueryWrapper<MdcEquipment> queryWrapper = QueryGenerator.initQueryWrapper(mdcEquipment, req.getParameterMap()); |
| | | //QueryWrapper<MdcEquipment> queryWrapper = QueryGenerator.initQueryWrapper(mdcEquipment, req.getParameterMap()); |
| | | Page<MdcEquipment> page = new Page<MdcEquipment>(pageNo, pageSize); |
| | | IPage<MdcEquipment> pageList = mdcEquipmentService.page(page, queryWrapper); |
| | | IPage<MdcEquipment> pageList = mdcEquipmentService.pageList(page, mdcEquipment, req); |
| | | |
| | | //批量查询设备的所属部门和产线 |
| | | //step.1 先拿到全部的 equipmentIds |
| | |
| | | Result<MdcEquipment> result = new Result<>(); |
| | | String selectedDeparts = mdcEquipment.getSelectedDeparts(); |
| | | String selectedProduction = mdcEquipment.getSelectedProduction(); |
| | | mdcEquipment.setEquipmentStatus(CommonConstant.STATUS_NORMAL); |
| | | try { |
| | | mdcEquipmentService.saveMdcEquipment(mdcEquipment, selectedDeparts, selectedProduction); |
| | | result.success("添加成功!"); |
| | |
| | | * @param mdcEquipment |
| | | */ |
| | | @RequestMapping(value = "/exportXls") |
| | | public ModelAndView exportXls(HttpServletRequest request, MdcEquipment mdcEquipment) { |
| | | return super.exportXls(request, mdcEquipment, MdcEquipment.class, "设备表"); |
| | | public ModelAndView exportXls(HttpServletRequest request, MdcEquipmentVo mdcEquipment) { |
| | | // Step.1 组装查询条件 |
| | | //QueryWrapper<MdcEquipment> queryWrapper = QueryGenerator.initQueryWrapper(mdcEquipment, request.getParameterMap()); |
| | | //Step.2 AutoPoi 导出Excel |
| | | ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); |
| | | List<MdcEquipment> pageList = mdcEquipmentService.exportXlsList(mdcEquipment); |
| | | List<String> equipmentIds = pageList.stream().map(MdcEquipment::getId).collect(Collectors.toList()); |
| | | if (!equipmentIds.isEmpty()) { |
| | | Map<String, String> equDepNames = mdcEquipmentService.getDepNamesByEquipmentIds(equipmentIds); |
| | | Map<String, String> equProNames = mdcEquipmentService.getProNamesByEquipmentIds(equipmentIds); |
| | | pageList.forEach(item -> { |
| | | item.setOrgCodeTxt(equDepNames.get(item.getId())); |
| | | item.setProductionName(equProNames.get(item.getId())); |
| | | }); |
| | | } |
| | | mv.addObject(NormalExcelConstants.FILE_NAME, "设备列表"); |
| | | mv.addObject(NormalExcelConstants.CLASS, MdcEquipment.class); |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | ExportParams exportParams = new ExportParams("设备列表数据", "导出人:" + user.getRealname(), "导出信息"); |
| | | // exportParams.setImageBasePath(upLoadPath); |
| | | mv.addObject(NormalExcelConstants.PARAMS, exportParams); |
| | | mv.addObject(NormalExcelConstants.DATA_LIST, pageList); |
| | | return mv; |
| | | } |
| | | |
| | | /** |
| | |
| | | MdcEquipment mdcEquipment = mdcEquipmentService.getEquipmentByDepPid(pid, userId); |
| | | return Result.OK(mdcEquipment); |
| | | } |
| | | |
| | | /** |
| | | * 手动上报设备异常及说明 |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "设备表-手动上报设备异常及说明") |
| | | @ApiOperation(value = "设备表-手动上报设备异常及说明", notes = "设备表-手动上报设备异常及说明") |
| | | @GetMapping("/updateEquipmentStatus") |
| | | public Result<?> updateEquipmentStatus(@RequestParam(name = "id", required = true) String id) { |
| | | Result result = new Result<>(); |
| | | try { |
| | | MdcEquipment mdcEquipment1 = mdcEquipmentService.getById(id); |
| | | if (mdcEquipment1 == null) { |
| | | result.error500("未找到对应实体"); |
| | | } else { |
| | | LambdaUpdateWrapper<MdcEquipment> updateWrapper = new LambdaUpdateWrapper<MdcEquipment>(); |
| | | updateWrapper.eq(MdcEquipment::getId, id); |
| | | if (CommonConstant.STATUS_NORMAL.equals(mdcEquipment1.getEquipmentStatus())) { |
| | | updateWrapper.set(MdcEquipment::getEquipmentStatus, CommonConstant.STATUS_DISABLE); |
| | | } else { |
| | | updateWrapper.set(MdcEquipment::getEquipmentStatus, CommonConstant.STATUS_NORMAL); |
| | | } |
| | | mdcEquipmentService.update(updateWrapper); |
| | | result.success("反馈成功!"); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage(), e); |
| | | result.error500("操作失败"); |
| | | } |
| | | return Result.OK("反馈成功!"); |
| | | } |
| | | } |