From 23855599412c4d61b38d78f0f3abd3430a48b5b1 Mon Sep 17 00:00:00 2001 From: zhangherong <571457620@qq.com> Date: 星期三, 25 六月 2025 11:51:38 +0800 Subject: [PATCH] Merge branch 'mdc_hyjs_master' --- lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentController.java | 554 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 554 insertions(+), 0 deletions(-) diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentController.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentController.java new file mode 100644 index 0000000..5c1e872 --- /dev/null +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentController.java @@ -0,0 +1,554 @@ +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; + } +} -- Gitblit v1.9.3