package org.jeecg.modules.mes.controller; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 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.lang.StringUtils; 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.modules.mes.entity.MesProductionOrder; import org.jeecg.modules.mes.enums.ProductionOrderStatus; import org.jeecg.modules.mes.service.IMesProductionOrderService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; /** * @Description: SAP生产订单 * @Author: jeecg-boot * @Date: 2025-07-04 * @Version: V1.0 */ @Api(tags = "SAP生产订单") @RestController @RequestMapping("/mes/productionOrder") @Slf4j public class MesProductionOrderController extends JeecgController { @Autowired private IMesProductionOrderService mesProductionOrderService; /** * 分页列表查询 * * @param mesProductionOrder * @param pageNo * @param pageSize * @param req * @return */ @ApiOperation(value = "SAP生产订单-分页列表查询", notes = "SAP生产订单-分页列表查询") @GetMapping(value = "/list") public Result> queryPageList(MesProductionOrder mesProductionOrder, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) { QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(mesProductionOrder, req.getParameterMap()); Page page = new Page(pageNo, pageSize); IPage pageList = mesProductionOrderService.page(page, queryWrapper); return Result.OK(pageList); } /** * 编辑 * * @param mesProductionOrder * @return */ @AutoLog(value = "SAP生产订单-编辑") @ApiOperation(value = "SAP生产订单-编辑", notes = "SAP生产订单-编辑") @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST}) public Result edit(@RequestBody MesProductionOrder mesProductionOrder) { mesProductionOrderService.updateById(mesProductionOrder); return Result.OK("编辑成功!"); } /** * 通过id查询 * * @param id * @return */ @ApiOperation(value = "SAP生产订单-通过id查询", notes = "SAP生产订单-通过id查询") @GetMapping(value = "/queryById") public Result queryById(@RequestParam(name = "id", required = true) String id) { MesProductionOrder mesProductionOrder = mesProductionOrderService.getById(id); if (mesProductionOrder == null) { return Result.error("未找到对应数据"); } return Result.OK(mesProductionOrder); } @ApiOperation(value = "SAP生产订单-查询可报工的生产订单", notes = "SAP生产订单-查询可报工的生产订单") @GetMapping(value = "/selectReportWorkOrderList") public Result selectReportWorkOrderList(MesProductionOrder mesProductionOrder) { if (StringUtils.isBlank(mesProductionOrder.getMaterialNumber())) { return Result.error("请传入必要的查询参数!"); } List orderList = mesProductionOrderService.list(new LambdaQueryWrapper() .eq(MesProductionOrder::getMaterialNumber, mesProductionOrder.getMaterialNumber()) .eq(MesProductionOrder::getOrderStatus, ProductionOrderStatus.REL.name()) .eq(MesProductionOrder::getDelFlag, CommonConstant.DEL_FLAG_0) .orderByAsc(MesProductionOrder::getPlanStart)); List> res = orderList.stream().map(order -> { Map map = new HashMap<>(); map.put("title", order.getOrderCode()); map.put("label", order.getOrderCode()); map.put("value", order.getId()); return map; }).collect(Collectors.toList()); return Result.OK(res); } }