package org.jeecg.modules.eam.controller;
|
|
import java.util.Arrays;
|
import java.util.List;
|
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletResponse;
|
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.system.query.QueryGenerator;
|
import org.jeecg.common.util.oConvertUtils;
|
import org.jeecg.modules.eam.entity.WorkShopDepart;
|
import org.jeecg.modules.eam.model.EamWorkShopDepartTreeModel;
|
import org.jeecg.modules.eam.model.WorkShopIdModel;
|
import org.jeecg.modules.eam.service.IWorkShopDepartService;
|
|
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.jeecg.common.system.base.controller.JeecgController;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.cache.annotation.CacheEvict;
|
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.servlet.ModelAndView;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
|
/**
|
* @Description: 设备车间管理
|
* @Author: jeecg-boot
|
* @Date: 2025-06-30
|
* @Version: V1.0
|
*/
|
@Api(tags="设备车间管理")
|
@RestController
|
@RequestMapping("/eam/workShopDepart")
|
@Slf4j
|
public class WorkShopDepartController extends JeecgController<WorkShopDepart, IWorkShopDepartService> {
|
@Autowired
|
private IWorkShopDepartService workShopDepartService;
|
|
/**
|
* 分页列表查询
|
*
|
* @param workShopDepart
|
* @param pageNo
|
* @param pageSize
|
* @param req
|
* @return
|
*/
|
//@AutoLog(value = "设备车间管理-分页列表查询")
|
@ApiOperation(value="设备车间管理-分页列表查询", notes="设备车间管理-分页列表查询")
|
@GetMapping(value = "/list")
|
public Result<IPage<WorkShopDepart>> queryPageList(WorkShopDepart workShopDepart,
|
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
HttpServletRequest req) {
|
QueryWrapper<WorkShopDepart> queryWrapper = QueryGenerator.initQueryWrapper(workShopDepart, req.getParameterMap());
|
Page<WorkShopDepart> page = new Page<WorkShopDepart>(pageNo, pageSize);
|
IPage<WorkShopDepart> pageList = workShopDepartService.page(page, queryWrapper);
|
return Result.OK(pageList);
|
}
|
|
@AutoLog(value = "设备车间管理-树形列表")
|
@ApiOperation(value = "设备车间管理-树形列表", notes = "设备车间管理-树形列表")
|
@GetMapping(value = "/queryTreeList")
|
public Result<List<EamWorkShopDepartTreeModel>> queryTreeList(@RequestParam(name = "ids", required = false) String ids) {
|
Result<List<EamWorkShopDepartTreeModel>> result = new Result<>();
|
try {
|
if (oConvertUtils.isNotEmpty(ids)) {
|
List<EamWorkShopDepartTreeModel> productionList = workShopDepartService.queryTreeList(ids);
|
result.setResult(productionList);
|
} else {
|
List<EamWorkShopDepartTreeModel> list = workShopDepartService.queryTreeList();
|
result.setResult(list);
|
}
|
result.setSuccess(true);
|
} catch (Exception e) {
|
log.error(e.getMessage(), e);
|
}
|
return result;
|
}
|
|
@AutoLog(value = "产线表-查询树形结构所有产线名称")
|
@ApiOperation(value = "产线表-查询树形结构所有产线名称", notes = "产线表-查询树形结构所有产线名称")
|
@GetMapping(value = "/queryIdTree")
|
public Result<List<WorkShopIdModel>> queryIdTree() {
|
Result<List<WorkShopIdModel>> result = new Result<>();
|
try {
|
List<WorkShopIdModel> list = workShopDepartService.queryProductionIdTreeList();
|
result.setResult(list);
|
result.setSuccess(true);
|
} catch (Exception e) {
|
log.error(e.getMessage(), e);
|
}
|
return result;
|
}
|
|
/**
|
* 添加
|
*
|
* @param WorkShopDepart
|
* @return
|
*/
|
@AutoLog(value = "设备车间管理-添加")
|
@ApiOperation(value = "设备车间管理-添加", notes = "设备车间管理-添加")
|
@PostMapping(value = "/add")
|
@CacheEvict(value = {"eam:cache:workShop:alldata", "eam:cache:workShop:allids"}, allEntries = true)
|
public Result<WorkShopDepart> add(@RequestBody WorkShopDepart WorkShopDepart) {
|
Result<WorkShopDepart> result = new Result<>();
|
try {
|
workShopDepartService.saveWorkShopDepartData(WorkShopDepart);
|
result.success("添加成功!");
|
} catch (Exception e) {
|
log.error(e.getMessage(), e);
|
result.error500("操作失败");
|
}
|
return result;
|
}
|
|
/**
|
* 编辑
|
*
|
* @param WorkShopDepart
|
* @return
|
*/
|
@AutoLog(value = "设备车间管理-编辑")
|
@ApiOperation(value = "设备车间管理-编辑", notes = "设备车间管理-编辑")
|
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
@CacheEvict(value = {"eam:cache:workShop:alldata", "eam:cache:workShop:allids"}, allEntries = true)
|
public Result<WorkShopDepart> edit(@RequestBody WorkShopDepart WorkShopDepart) {
|
Result<WorkShopDepart> result = new Result<>();
|
WorkShopDepart eamProductionEntity = workShopDepartService.getById(WorkShopDepart.getId());
|
if (eamProductionEntity == null) {
|
result.error500("未找到对应实体");
|
} else {
|
boolean ok = workShopDepartService.updateWorkShopDepartDataById(WorkShopDepart);
|
if (ok) {
|
result.success("修改成功!");
|
}
|
}
|
return result;
|
}
|
|
/**
|
* 通过id删除
|
*
|
* @param id
|
* @return
|
*/
|
@AutoLog(value = "设备车间管理-通过id删除")
|
@ApiOperation(value = "设备车间管理-通过id删除", notes = "设备车间管理-通过id删除")
|
@DeleteMapping(value = "/delete")
|
@CacheEvict(value = {"eam:cache:workShop:alldata", "eam:cache:workShop:allids"}, allEntries = true)
|
public Result<WorkShopDepart> delete(@RequestParam(name = "id", required = true) String id) {
|
Result<WorkShopDepart> result = new Result<>();
|
WorkShopDepart WorkShopDepart = workShopDepartService.getById(id);
|
if (WorkShopDepart == null) {
|
result.error500("未找到对应实体");
|
} else {
|
boolean ok = workShopDepartService.delete(id);
|
if (ok) {
|
result.success("删除成功!");
|
}
|
}
|
return result;
|
}
|
|
/**
|
* 批量删除
|
*
|
* @param ids
|
* @return
|
*/
|
@AutoLog(value = "设备车间管理-批量删除")
|
@ApiOperation(value = "设备车间管理-批量删除", notes = "设备车间管理-批量删除")
|
@DeleteMapping(value = "/deleteBatch")
|
@CacheEvict(value = {"eam:cache:workShop:alldata", "eam:cache:workShop:allids"}, allEntries = true)
|
public Result<WorkShopDepart> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
Result<WorkShopDepart> result = new Result<>();
|
if (ids == null || "".equals(ids.trim())) {
|
result.error500("参数不识别!");
|
} else {
|
this.workShopDepartService.deleteBatchWithChildren(Arrays.asList(ids.split(",")));
|
result.success("删除成功!");
|
}
|
return result;
|
}
|
/**
|
* 通过id查询
|
*
|
* @param id
|
* @return
|
*/
|
//@AutoLog(value = "设备车间管理-通过id查询")
|
@ApiOperation(value="设备车间管理-通过id查询", notes="设备车间管理-通过id查询")
|
@GetMapping(value = "/queryById")
|
public Result<WorkShopDepart> queryById(@RequestParam(name="id",required=true) String id) {
|
WorkShopDepart workShopDepart = workShopDepartService.getById(id);
|
if(workShopDepart==null) {
|
return Result.error("未找到对应数据");
|
}
|
return Result.OK(workShopDepart);
|
}
|
|
/**
|
* 导出excel
|
*
|
* @param request
|
* @param workShopDepart
|
*/
|
//@RequiresPermissions("org.jeecg.modules.eam:sys_work_shop_depart:exportXls")
|
@RequestMapping(value = "/exportXls")
|
public ModelAndView exportXls(HttpServletRequest request, WorkShopDepart workShopDepart) {
|
return super.exportXls(request, workShopDepart, WorkShopDepart.class, "设备车间管理");
|
}
|
|
/**
|
* 通过excel导入数据
|
*
|
* @param request
|
* @param response
|
* @return
|
*/
|
//@RequiresPermissions("sys_work_shop_depart:importExcel")
|
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
return super.importExcel(request, response, WorkShopDepart.class);
|
}
|
|
}
|