¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.mdc.controller; |
| | | |
| | | 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 io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | 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.vo.LoginUser; |
| | | import org.jeecg.modules.mdc.entity.MdcEquipment; |
| | | import org.jeecg.modules.mdc.entity.MdcEquipmentMonitor; |
| | | import org.jeecg.modules.mdc.model.MdcEquipmentTree; |
| | | import org.jeecg.modules.mdc.service.IMdcEquipmentDepartService; |
| | | import org.jeecg.modules.mdc.service.IMdcEquipmentService; |
| | | import org.jeecg.modules.mdc.service.IMdcProductionEquipmentService; |
| | | 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; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @Description: 设å¤è¡¨ |
| | | * @Author: liuS |
| | | * @Date: 2023-03-22 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Slf4j |
| | | @Api(tags = "设å¤è¡¨") |
| | | @RestController |
| | | @RequestMapping("/mdc/mdcEquipment") |
| | | public class MdcEquipmentController extends JeecgController<MdcEquipment, IMdcEquipmentService> { |
| | | |
| | | @Resource |
| | | private IMdcEquipmentService mdcEquipmentService; |
| | | |
| | | @Resource |
| | | private IMdcEquipmentDepartService mdcEquipmentDepartService; |
| | | |
| | | @Resource |
| | | private IMdcProductionEquipmentService mdcProductionEquipmentService; |
| | | |
| | | /** |
| | | * å页å表æ¥è¯¢ |
| | | * |
| | | * @param mdcEquipment |
| | | * @param pageNo |
| | | * @param pageSize |
| | | * @param req |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "设å¤è¡¨-å页å表æ¥è¯¢") |
| | | @ApiOperation(value = "设å¤è¡¨-å页å表æ¥è¯¢", notes = "设å¤è¡¨-å页å表æ¥è¯¢") |
| | | @GetMapping(value = "/list") |
| | | 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()); |
| | | Page<MdcEquipment> page = new Page<MdcEquipment>(pageNo, pageSize); |
| | | IPage<MdcEquipment> pageList = mdcEquipmentService.pageList(page, mdcEquipment, req); |
| | | |
| | | //æ¹éæ¥è¯¢è®¾å¤çæå±é¨é¨å产线 |
| | | //step.1 å
æ¿å°å
¨é¨ç equipmentIds |
| | | //step.2 éè¿ equipmentIdsï¼ä¸æ¬¡æ§æ¥è¯¢è®¾å¤çæå±é¨é¨å产线åå |
| | | List<String> equipmentIds = pageList.getRecords().stream().map(MdcEquipment::getId).collect(Collectors.toList()); |
| | | if (equipmentIds != null && !equipmentIds.isEmpty()) { |
| | | Map<String, String> equDepNames = mdcEquipmentService.getDepNamesByEquipmentIds(equipmentIds); |
| | | Map<String, String> equProNames = mdcEquipmentService.getProNamesByEquipmentIds(equipmentIds); |
| | | pageList.getRecords().forEach(item -> { |
| | | item.setOrgCodeTxt(equDepNames.get(item.getId())); |
| | | item.setProductionName(equProNames.get(item.getId())); |
| | | }); |
| | | } |
| | | |
| | | return Result.OK(pageList); |
| | | } |
| | | |
| | | /** |
| | | * éæ©è®¾å¤å页å表 |
| | | */ |
| | | @AutoLog(value = "设å¤è¡¨-éæ©è®¾å¤å页å表") |
| | | @ApiOperation(value = "设å¤è¡¨-éæ©è®¾å¤å页å表", notes = "设å¤è¡¨-éæ©è®¾å¤å页å表") |
| | | @GetMapping(value = "/findEquipmentList") |
| | | public Result<IPage<MdcEquipment>> findEquipmentList(MdcEquipmentVo mdcEquipment, |
| | | @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, |
| | | @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, |
| | | HttpServletRequest req) { |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | String userId = user.getId(); |
| | | Page<MdcEquipment> page = new Page<MdcEquipment>(pageNo, pageSize); |
| | | IPage<MdcEquipment> pageList = mdcEquipmentService.findEquipmentList(page, userId, mdcEquipment); |
| | | return Result.OK(pageList); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨æ·æ¥è¯¢è®¾å¤åè¡¨ä¿¡æ¯ |
| | | */ |
| | | @AutoLog(value = "设å¤è¡¨-æ ¹æ®ç¨æ·æ¥è¯¢è®¾å¤å表信æ¯") |
| | | @ApiOperation(value = "设å¤è¡¨-æ ¹æ®ç¨æ·æ¥è¯¢è®¾å¤å表信æ¯", notes = "设å¤è¡¨-æ ¹æ®ç¨æ·æ¥è¯¢è®¾å¤å表信æ¯") |
| | | @GetMapping(value = "/getEquipmentList") |
| | | public Result<List<MdcEquipment>> getEquipmentList() { |
| | | List<MdcEquipment> list = mdcEquipmentService.getEquipmentList(); |
| | | return Result.OK(list); |
| | | } |
| | | |
| | | /** |
| | | * 设å¤çæ§å表 |
| | | */ |
| | | @AutoLog(value = "设å¤è¡¨-设å¤çæ§å表") |
| | | @ApiOperation(value = "设å¤è¡¨-设å¤çæ§å表", notes = "设å¤è¡¨-设å¤çæ§å表") |
| | | @GetMapping(value = "/queryEquipmentMonitorList") |
| | | public Result<List<MdcEquipmentMonitor>> queryEquipmentMonitorList(@RequestParam(name = "key", required = false) String key) { |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | String userId = user.getId(); |
| | | List<MdcEquipmentMonitor> list = mdcEquipmentService.queryEquipmentMonitorList(userId, key); |
| | | return Result.OK(list); |
| | | } |
| | | |
| | | @AutoLog(value = "设å¤è¡¨-设å¤å®æ¶è¯¦ç»ä¿¡æ¯") |
| | | @ApiOperation(value = "设å¤è¡¨-设å¤å®æ¶è¯¦ç»ä¿¡æ¯", notes = "设å¤è¡¨-设å¤å®æ¶è¯¦ç»ä¿¡æ¯") |
| | | @GetMapping(value = "/mdcEquipmentDetailedInfo") |
| | | public Result<?> mdcEquipmentDetailedInfo(@RequestParam(name = "id", required = true) String id) { |
| | | Map<String, Object> result = mdcEquipmentService.mdcEquipmentDetailedInfo(id); |
| | | return Result.OK(result); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®é¨é¨æ¥è¯¢è®¾å¤å页å表 |
| | | */ |
| | | @AutoLog(value = "设å¤é¨é¨è¡¨-æ ¹æ®é¨é¨æ¥è¯¢è®¾å¤å页å表") |
| | | @ApiOperation(value = "设å¤é¨é¨è¡¨-æ ¹æ®é¨é¨æ¥è¯¢è®¾å¤å页å表", notes = "设å¤é¨é¨è¡¨-æ ¹æ®é¨é¨æ¥è¯¢è®¾å¤å页å表") |
| | | @GetMapping(value = "/equipmentListByDepart") |
| | | public Result<IPage<MdcEquipment>> equipmentListByDepart(@RequestParam(name = "departId", required = true) String departId, |
| | | @RequestParam(name = "equipmentId", required = false) String equipmentId, |
| | | @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, |
| | | @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, |
| | | HttpServletRequest req) { |
| | | Page<MdcEquipment> page = new Page<MdcEquipment>(pageNo, pageSize); |
| | | IPage<MdcEquipment> pageList = mdcEquipmentService.pageListByDepId(page, departId, equipmentId); |
| | | return Result.OK(pageList); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®äº§çº¿æ¥è¯¢è®¾å¤å页å表 |
| | | */ |
| | | @AutoLog(value = "设å¤äº§çº¿è¡¨-æ ¹æ®äº§çº¿æ¥è¯¢è®¾å¤å页å表") |
| | | @ApiOperation(value = "设å¤äº§çº¿è¡¨-æ ¹æ®äº§çº¿æ¥è¯¢è®¾å¤å页å表", notes = "设å¤äº§çº¿è¡¨-æ ¹æ®äº§çº¿æ¥è¯¢è®¾å¤å页å表") |
| | | @GetMapping(value = "/equipmentListByProduction") |
| | | public Result<IPage<MdcEquipment>> equipmentListByProduction(@RequestParam(name = "productionId", required = true) String productionId, |
| | | @RequestParam(name = "equipmentId", required = false) String equipmentId, |
| | | @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, |
| | | @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, |
| | | HttpServletRequest req) { |
| | | Page<MdcEquipment> page = new Page<MdcEquipment>(pageNo, pageSize); |
| | | IPage<MdcEquipment> pageList = mdcEquipmentService.pageListByProId(page, productionId, equipmentId); |
| | | return Result.OK(pageList); |
| | | } |
| | | |
| | | /** |
| | | * ç§»é¤é¨é¨å设å¤å
³ç³» |
| | | */ |
| | | @AutoLog(value = "设å¤é¨é¨è¡¨-ç§»é¤é¨é¨å设å¤å
³ç³»") |
| | | @ApiOperation(value = "设å¤é¨é¨è¡¨-ç§»é¤é¨é¨å设å¤å
³ç³»", notes = "设å¤é¨é¨è¡¨-ç§»é¤é¨é¨å设å¤å
³ç³»") |
| | | @PostMapping(value = "/removeEquipmentForDepart") |
| | | public Result<?> removeEquipmentForDepart(@RequestParam(name = "departId", required = true) String departId, |
| | | @RequestParam(name = "equipmentId", required = true) String equipmentId) { |
| | | if (StringUtils.isNotBlank(departId) && StringUtils.isNotBlank(equipmentId)) { |
| | | mdcEquipmentService.removeEquipmentForDepart(departId, equipmentId); |
| | | } |
| | | return Result.OK("ç§»é¤æåï¼"); |
| | | } |
| | | |
| | | /** |
| | | * æ¹éç§»é¤é¨é¨å设å¤å
³ç³» |
| | | */ |
| | | @AutoLog(value = "设å¤é¨é¨è¡¨-æ¹éç§»é¤é¨é¨å设å¤å
³ç³»") |
| | | @ApiOperation(value = "设å¤é¨é¨è¡¨-æ¹éç§»é¤é¨é¨å设å¤å
³ç³»", notes = "设å¤é¨é¨è¡¨-æ¹éç§»é¤é¨é¨å设å¤å
³ç³»") |
| | | @PostMapping(value = "/removeEquipmentsForDepart") |
| | | public Result<?> removeEquipmentsForDepart(@RequestParam(name = "departId", required = true) String departId, |
| | | @RequestParam(name = "equipmentIds", required = true) String equipmentIds) { |
| | | if (StringUtils.isNotBlank(departId) && StringUtils.isNotBlank(equipmentIds)) { |
| | | List<String> equipmentIdList = Arrays.asList(equipmentIds.split(",")); |
| | | mdcEquipmentService.removeEquipmentsForDepart(departId, equipmentIdList); |
| | | } |
| | | return Result.OK("æ¹éç§»é¤æåï¼"); |
| | | } |
| | | |
| | | /** |
| | | * æ¹éç§»é¤äº§çº¿å设å¤å
³ç³» |
| | | */ |
| | | @AutoLog(value = "设å¤äº§çº¿è¡¨-æ¹éç§»é¤äº§çº¿å设å¤å
³ç³»") |
| | | @ApiOperation(value = "设å¤äº§çº¿è¡¨-æ¹éç§»é¤äº§çº¿å设å¤å
³ç³»", notes = "设å¤äº§çº¿è¡¨-æ¹éç§»é¤äº§çº¿å设å¤å
³ç³»") |
| | | @PostMapping(value = "/removeEquipmentsForProduction") |
| | | public Result<?> removeEquipmentsForProduction(@RequestParam(name = "productionId", required = true) String productionId, |
| | | @RequestParam(name = "equipmentIds", required = true) String equipmentIds) { |
| | | if (StringUtils.isNotBlank(productionId) && StringUtils.isNotBlank(equipmentIds)) { |
| | | List<String> equipmentIdList = Arrays.asList(equipmentIds.split(",")); |
| | | mdcEquipmentService.removeEquipmentsForProduction(productionId, equipmentIdList); |
| | | } |
| | | return Result.OK("æ¹éç§»é¤æåï¼"); |
| | | } |
| | | |
| | | /** |
| | | * ç§»é¤äº§çº¿å设å¤å
³ç³» |
| | | */ |
| | | @AutoLog(value = "设å¤äº§çº¿è¡¨-ç§»é¤äº§çº¿å设å¤å
³ç³»") |
| | | @ApiOperation(value = "设å¤äº§çº¿è¡¨-ç§»é¤äº§çº¿å设å¤å
³ç³»", notes = "设å¤äº§çº¿è¡¨-ç§»é¤äº§çº¿å设å¤å
³ç³»") |
| | | @PostMapping(value = "/removeEquipmentForProduction") |
| | | public Result<?> removeEquipmentForProduction(@RequestParam(name = "productionId", required = true) String productionId, |
| | | @RequestParam(name = "equipmentId", required = true) String equipmentId) { |
| | | if (StringUtils.isNotBlank(productionId) && StringUtils.isNotBlank(equipmentId)) { |
| | | mdcEquipmentService.removeEquipmentForProduction(productionId, equipmentId); |
| | | } |
| | | return Result.OK("ç§»é¤æåï¼"); |
| | | } |
| | | |
| | | /** |
| | | * æ·»å |
| | | * |
| | | * @param mdcEquipment |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "设å¤è¡¨-æ·»å ") |
| | | @ApiOperation(value = "设å¤è¡¨-æ·»å ", notes = "设å¤è¡¨-æ·»å ") |
| | | @PostMapping(value = "/add") |
| | | public Result<MdcEquipment> add(@RequestBody MdcEquipment mdcEquipment) { |
| | | 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("æ·»å æåï¼"); |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage(), e); |
| | | result.error500("æä½å¤±è´¥"); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * ç¼è¾ |
| | | * |
| | | * @param mdcEquipment |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "设å¤è¡¨-ç¼è¾") |
| | | @ApiOperation(value = "设å¤è¡¨-ç¼è¾", notes = "设å¤è¡¨-ç¼è¾") |
| | | @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST}) |
| | | public Result<MdcEquipment> edit(@RequestBody MdcEquipment mdcEquipment) { |
| | | Result<MdcEquipment> result = new Result<>(); |
| | | try { |
| | | MdcEquipment mdcEquipment1 = mdcEquipmentService.getById(mdcEquipment.getId()); |
| | | if (mdcEquipment1 == null) { |
| | | result.error500("æªæ¾å°å¯¹åºå®ä½"); |
| | | } else { |
| | | mdcEquipmentService.editMdcEquipment(mdcEquipment); |
| | | result.success("ä¿®æ¹æå!"); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage(), e); |
| | | result.error500("æä½å¤±è´¥"); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * éè¿idå é¤ |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "设å¤è¡¨-éè¿idå é¤") |
| | | @ApiOperation(value = "设å¤è¡¨-éè¿idå é¤", notes = "设å¤è¡¨-éè¿idå é¤") |
| | | @DeleteMapping(value = "/delete") |
| | | public Result<?> delete(@RequestParam(name = "id", required = true) String id) { |
| | | if (StringUtils.isNotBlank(id)) { |
| | | mdcEquipmentService.deleteById(id); |
| | | } |
| | | return Result.OK("å 餿å!"); |
| | | } |
| | | |
| | | /** |
| | | * æ¹éå é¤ |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "设å¤è¡¨-æ¹éå é¤") |
| | | @ApiOperation(value = "设å¤è¡¨-æ¹éå é¤", notes = "设å¤è¡¨-æ¹éå é¤") |
| | | @DeleteMapping(value = "/deleteBatch") |
| | | public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) { |
| | | if (StringUtils.isNotBlank(ids)) { |
| | | this.mdcEquipmentService.deleteByIds(Arrays.asList(ids.split(","))); |
| | | } |
| | | return Result.OK("æ¹éå 餿åï¼"); |
| | | } |
| | | |
| | | /** |
| | | * éè¿idæ¥è¯¢ |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "设å¤è¡¨-éè¿idæ¥è¯¢") |
| | | @ApiOperation(value = "设å¤è¡¨-éè¿idæ¥è¯¢", notes = "设å¤è¡¨-éè¿idæ¥è¯¢") |
| | | @GetMapping(value = "/queryById") |
| | | public Result<MdcEquipment> queryById(@RequestParam(name = "id", required = true) String id) { |
| | | Result<MdcEquipment> result = new Result<>(); |
| | | MdcEquipment mdcEquipment = mdcEquipmentService.getById(id); |
| | | if (mdcEquipment == null) { |
| | | result.error500("æªæ¾å°å¯¹åºå®ä½ï¼"); |
| | | } else { |
| | | result.setResult(mdcEquipment); |
| | | result.setSuccess(true); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢æå®è®¾å¤åé¨é¨å
³èçæ°æ® |
| | | */ |
| | | @AutoLog(value = "设å¤è¡¨-æ¥è¯¢æå®è®¾å¤åé¨é¨å
³èçæ°æ®") |
| | | @ApiOperation(value = "设å¤è¡¨-æ¥è¯¢æå®è®¾å¤åé¨é¨å
³èçæ°æ®", notes = "设å¤è¡¨-æ¥è¯¢æå®è®¾å¤åé¨é¨å
³èçæ°æ®") |
| | | @GetMapping(value = "/equipmentDepartList") |
| | | public Result<List<DepartIdModel>> getEquipmentDepartList(@RequestParam(name = "equipmentId", required = true) String equipmentId) { |
| | | Result<List<DepartIdModel>> result = new Result<>(); |
| | | try { |
| | | List<DepartIdModel> depIdModelList = this.mdcEquipmentDepartService.queryDepartIdsOfEquipment(equipmentId); |
| | | if (depIdModelList != null && !depIdModelList.isEmpty()) { |
| | | result.setSuccess(true); |
| | | result.setMessage("æ¥æ¾æå"); |
| | | result.setResult(depIdModelList); |
| | | } else { |
| | | result.setSuccess(false); |
| | | result.setMessage("æ¥æ¾å¤±è´¥"); |
| | | } |
| | | return result; |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage(), e); |
| | | result.setSuccess(false); |
| | | result.setMessage("æ¥æ¾è¿ç¨ä¸åºç°äºå¼å¸¸: " + e.getMessage()); |
| | | return result; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢æå®è®¾å¤å产线å
³èçæ°æ® |
| | | */ |
| | | @AutoLog(value = "设å¤è¡¨-æ¥è¯¢æå®è®¾å¤å产线å
³èçæ°æ®") |
| | | @ApiOperation(value = "设å¤è¡¨-æ¥è¯¢æå®è®¾å¤å产线å
³èçæ°æ®", notes = "设å¤è¡¨-æ¥è¯¢æå®è®¾å¤å产线å
³èçæ°æ®") |
| | | @GetMapping(value = "/equipmentProductionList") |
| | | public Result<List<ProductionIdModel>> getEquipmentProductionList(@RequestParam(name = "equipmentId", required = true) String equipmentId) { |
| | | Result<List<ProductionIdModel>> result = new Result<>(); |
| | | try { |
| | | List<ProductionIdModel> proIdModelList = this.mdcProductionEquipmentService.queryProductionIdsOfEquipment(equipmentId); |
| | | if (proIdModelList != null && !proIdModelList.isEmpty()) { |
| | | result.setSuccess(true); |
| | | result.setMessage("æ¥æ¾æå"); |
| | | result.setResult(proIdModelList); |
| | | } else { |
| | | result.setSuccess(false); |
| | | result.setMessage("æ¥æ¾å¤±è´¥"); |
| | | } |
| | | return result; |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage(), e); |
| | | result.setSuccess(false); |
| | | result.setMessage("æ¥æ¾è¿ç¨ä¸åºç°äºå¼å¸¸: " + e.getMessage()); |
| | | return result; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * å è½½é¨é¨è®¾å¤æ |
| | | */ |
| | | @AutoLog(value = "设å¤è¡¨-å è½½é¨é¨è®¾å¤æ ") |
| | | @ApiOperation(value = "设å¤è¡¨-å è½½é¨é¨è®¾å¤æ ", notes = "设å¤è¡¨-å è½½é¨é¨è®¾å¤æ ") |
| | | @GetMapping(value = "/queryTreeListByDepart") |
| | | public Result<List<MdcEquipmentTree>> queryTreeListByDepart() { |
| | | Result<List<MdcEquipmentTree>> result = new Result<>(); |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | String userId = user.getId(); |
| | | try { |
| | | List<MdcEquipmentTree> mdcEquipmentTreeList = mdcEquipmentService.loadTreeListByDepart(userId); |
| | | result.setSuccess(true); |
| | | result.setResult(mdcEquipmentTreeList); |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage(), e); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * å è½½äº§çº¿è®¾å¤æ |
| | | */ |
| | | @AutoLog(value = "设å¤è¡¨-å è½½äº§çº¿è®¾å¤æ ") |
| | | @ApiOperation(value = "设å¤è¡¨-å è½½äº§çº¿è®¾å¤æ ", notes = "设å¤è¡¨-å è½½äº§çº¿è®¾å¤æ ") |
| | | @GetMapping(value = "/queryTreeListByProduction") |
| | | public Result<List<MdcEquipmentTree>> queryTreeListByProduction() { |
| | | Result<List<MdcEquipmentTree>> result = new Result<>(); |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | String userId = user.getId(); |
| | | try { |
| | | List<MdcEquipmentTree> mdcEquipmentTreeList = mdcEquipmentService.loadTreeListByProduction(userId); |
| | | result.setSuccess(true); |
| | | result.setResult(mdcEquipmentTreeList); |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage(), e); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 导åºexcel |
| | | * |
| | | * @param request |
| | | * @param mdcEquipment |
| | | */ |
| | | @RequestMapping(value = "/exportXls") |
| | | 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; |
| | | } |
| | | |
| | | /** |
| | | * éè¿excel导å
¥æ°æ® |
| | | * |
| | | * @param request |
| | | * @param response |
| | | * @return |
| | | */ |
| | | @RequestMapping(value = "/importExcel", method = RequestMethod.POST) |
| | | public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { |
| | | return super.importExcel(request, response, MdcEquipment.class); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®äº§çº¿å±çº§æ¥è¯¢åä¸ªè®¾å¤ |
| | | * |
| | | * @param pid |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "设å¤è¡¨-æ ¹æ®äº§çº¿å±çº§æ¥è¯¢å个设å¤") |
| | | @ApiOperation(value = "设å¤è¡¨-æ ¹æ®äº§çº¿å±çº§æ¥è¯¢å个设å¤", notes = "设å¤è¡¨-æ ¹æ®äº§çº¿å±çº§æ¥è¯¢å个设å¤") |
| | | @GetMapping("/getEquipmentByPid") |
| | | public Result<MdcEquipment> getEquipmentByPid(@RequestParam(name = "pid", required = false) String pid) { |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | String userId = user.getId(); |
| | | MdcEquipment mdcEquipment = mdcEquipmentService.getEquipmentByPid(pid, userId); |
| | | return Result.OK(mdcEquipment); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®é¨é¨å±çº§æ¥è¯¢åä¸ªè®¾å¤ |
| | | * |
| | | * @param pid |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "设å¤è¡¨-æ ¹æ®é¨é¨å±çº§æ¥è¯¢å个设å¤") |
| | | @ApiOperation(value = "设å¤è¡¨-æ ¹æ®é¨é¨å±çº§æ¥è¯¢å个设å¤", notes = "设å¤è¡¨-æ ¹æ®é¨é¨å±çº§æ¥è¯¢å个设å¤") |
| | | @GetMapping("/getEquipmentByDepPid") |
| | | public Result<MdcEquipment> getEquipmentByDepPid(@RequestParam(name = "pid", required = false) String pid) { |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | String userId = user.getId(); |
| | | 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("å馿åï¼"); |
| | | } |
| | | |
| | | |
| | | @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; |
| | | } |
| | | } |