“linengliang”
2023-09-18 0db15ae012591c51e98b226c274045323af4f58d
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EquipmentSparesController.java
@@ -7,6 +7,7 @@
import javax.servlet.http.HttpServletResponse;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.eam.entity.Equipment;
import org.jeecg.modules.eam.entity.EquipmentSpares;
import org.jeecg.modules.eam.entity.EquipmentStructure;
import org.jeecg.modules.eam.service.IEquipmentSparesService;
@@ -18,6 +19,8 @@
import org.jeecg.modules.eam.service.IEquipmentStructureService;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.modules.spare.entity.SparePart;
import org.jeecg.modules.spare.service.ISparePartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
@@ -41,7 +44,9 @@
   @Autowired
   private IEquipmentStructureService equipmentStructureService;
    @Autowired
   private ISparePartService sparePartService;
   /**
    * 分页列表查询
    *
@@ -95,7 +100,7 @@
       }
       return Result.ok(equipmentSparesList);
    }
   /**
    *   添加
    *
@@ -110,7 +115,18 @@
      equipmentSparesService.save(equipmentSpares);
      return Result.OK("添加成功!");
   }
   @PutMapping(value = "/editByEquipment")
   public Result<String> addByEquipment(@RequestBody Equipment equipment) {
      List<EquipmentSpares> list = equipment.getEquipmentSparesList();
      equipmentSparesService.remove(new QueryWrapper<EquipmentSpares>().eq("equipment_id",equipment.getId()));
      for(EquipmentSpares equipmentSpares:list){
         equipmentSpares.setEquipmentId(equipment.getId());
      }
       equipmentSparesService.saveBatch(list);
       return Result.OK("编辑成功!");
   }
   /**
    *  编辑
    *
@@ -125,7 +141,7 @@
      equipmentSparesService.updateById(equipmentSpares);
      return Result.OK("编辑成功!");
   }
   /**
    *   通过id删除
    *
@@ -142,7 +158,7 @@
      equipmentSparesService.updateById(equipmentSpares);
      return Result.OK("删除成功!");
   }
   /**
    *  批量删除
    *
@@ -163,7 +179,7 @@
//      this.equipmentSparesService.removeByIds(Arrays.asList(ids.split(",")));
      return Result.OK("批量删除成功!");
   }
   /**
    * 通过id查询
    *
@@ -205,6 +221,31 @@
    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
        return super.importExcel(request, response, EquipmentSpares.class);
    }
    @GetMapping(value = "/myPage")
    public Result<IPage<EquipmentSpares>> myPage(EquipmentSpares equipmentSpares,
                                           @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                           @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
                                           HttpServletRequest req) {
       QueryWrapper<EquipmentSpares> queryWrapper = QueryGenerator.initQueryWrapper(equipmentSpares, req.getParameterMap());
       Page<EquipmentSpares> page = new Page<EquipmentSpares>(pageNo, pageSize);
       IPage<EquipmentSpares> pageList = equipmentSparesService.myPage(page, equipmentSpares);
       return Result.OK(pageList);
    }
    @GetMapping(value = "/myList")
    public Result<?> myList(@RequestParam(name = "id", required = true) String id){
       return Result.OK(equipmentSparesService.getListByEquipmentId(id));
    }
    @GetMapping(value = "/sparePartlist")
    public Result<IPage<SparePart>> queryPageList(SparePart sparePart,
                                       @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                       @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
                                       HttpServletRequest req) {
       QueryWrapper<SparePart> queryWrapper = QueryGenerator.initQueryWrapper(sparePart, req.getParameterMap());
       Page<SparePart> page = new Page<SparePart>(pageNo, pageSize);
       IPage<SparePart> pageList = sparePartService.page(page, queryWrapper);
       return Result.OK(pageList);
    }