| | |
| | | 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 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.common.util.oConvertUtils; |
| | | import org.jeecg.modules.mdc.dto.MdcEquipmentDto; |
| | | import org.jeecg.modules.mdc.entity.MdcEquipment; |
| | | import org.jeecg.modules.mdc.entity.MdcEquipmentMonitor; |
| | |
| | | @AutoLog(value = "设备表-加载部门设备树") |
| | | @ApiOperation(value = "设备表-加载部门设备树", notes = "设备表-加载部门设备树") |
| | | @GetMapping(value = "/queryTreeListByDepart") |
| | | public Result<List<MdcEquipmentTree>> queryTreeListByDepart() { |
| | | public Result<List<MdcEquipmentTree>> queryTreeListByDepart(@RequestParam(name = "key", required = false) String key) { |
| | | Result<List<MdcEquipmentTree>> result = new Result<>(); |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | String userId = user.getId(); |
| | | try { |
| | | List<MdcEquipmentTree> mdcEquipmentTreeList = mdcEquipmentService.loadTreeListByDepart(userId); |
| | | List<MdcEquipmentTree> mdcEquipmentTreeList = mdcEquipmentService.loadTreeListByDepart(userId, key); |
| | | result.setSuccess(true); |
| | | result.setResult(mdcEquipmentTreeList); |
| | | } catch (Exception e) { |
| | |
| | | @AutoLog(value = "设备表-加载产线设备树") |
| | | @ApiOperation(value = "设备表-加载产线设备树", notes = "设备表-加载产线设备树") |
| | | @GetMapping(value = "/queryTreeListByProduction") |
| | | public Result<List<MdcEquipmentTree>> queryTreeListByProduction() { |
| | | public Result<List<MdcEquipmentTree>> queryTreeListByProduction(@RequestParam(name = "key", required = false) String key) { |
| | | Result<List<MdcEquipmentTree>> result = new Result<>(); |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | String userId = user.getId(); |
| | | try { |
| | | List<MdcEquipmentTree> mdcEquipmentTreeList = mdcEquipmentService.loadTreeListByProduction(userId); |
| | | List<MdcEquipmentTree> mdcEquipmentTreeList = mdcEquipmentService.loadTreeListByProduction(userId, key); |
| | | result.setSuccess(true); |
| | | result.setResult(mdcEquipmentTreeList); |
| | | } catch (Exception e) { |
| | |
| | | * @param mdcEquipment |
| | | */ |
| | | @RequestMapping(value = "/exportXls") |
| | | public ModelAndView exportXls(HttpServletRequest request, MdcEquipment mdcEquipment) { |
| | | public ModelAndView exportXls(HttpServletRequest request, MdcEquipmentVo mdcEquipment) { |
| | | // Step.1 组装查询条件 |
| | | QueryWrapper<MdcEquipment> queryWrapper = QueryGenerator.initQueryWrapper(mdcEquipment, request.getParameterMap()); |
| | | //QueryWrapper<MdcEquipment> queryWrapper = QueryGenerator.initQueryWrapper(mdcEquipment, request.getParameterMap()); |
| | | //Step.2 AutoPoi 导出Excel |
| | | ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); |
| | | String selections = request.getParameter("selections"); |
| | | if (!oConvertUtils.isEmpty(selections)) { |
| | | queryWrapper.in("id", selections.split(",")); |
| | | 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())); |
| | | }); |
| | | } |
| | | List<MdcEquipment> pageList = mdcEquipmentService.list(queryWrapper); |
| | | mv.addObject(NormalExcelConstants.FILE_NAME, "设备列表"); |
| | | mv.addObject(NormalExcelConstants.CLASS, MdcEquipment.class); |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | |
| | | } |
| | | return Result.OK("反馈成功!"); |
| | | } |
| | | |
| | | |
| | | @AutoLog(value = "设备表-通过车间ids获取设备树") |
| | | @ApiOperation(value = "设备表-通过车间ids获取设备树", notes = "设备表-通过车间ids获取设备树") |
| | | @GetMapping(value = "/loadTreeListByProductionIds") |
| | | public Result<?> loadTreeListByProductionIds(@RequestParam(name = "ids", required = true) String ids) { |
| | | Result<List<MdcEquipmentTree>> result = new Result<>(); |
| | | try { |
| | | List<MdcEquipmentTree> mdcEquipmentTreeList = mdcEquipmentService.loadTreeListByProductionIds(ids); |
| | | result.setSuccess(true); |
| | | result.setResult(mdcEquipmentTreeList); |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage(), e); |
| | | } |
| | | return result; |
| | | } |
| | | } |