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); } lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/Equipment.java
@@ -324,4 +324,6 @@ private Date newEnd; @TableField(exist = false) private String newABCTag; @TableField(exist = false) List<EquipmentSpares> equipmentSparesList; } lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/EquipmentSpares.java
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; import org.jeecg.common.aspect.annotation.Dict; import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.system.base.entity.JeecgEntity; import org.jeecgframework.poi.excel.annotation.Excel; @@ -42,7 +43,10 @@ private java.lang.Double changeCycle; @ApiModelProperty(value = "更换周期单位") @Dict(dictTable = "mom_base_unit",dicCode = "id",dicText = "name") private String unitId; @TableField(exist = false) private String unitName; @ApiModelProperty(value = "上次更换周期") private java.util.Date laseChangeTime; @@ -96,4 +100,13 @@ @ApiModelProperty(value = "精度参数分类编码/名称") @TableField(exist = false) private String equipmentStructureNumName; @TableField(exist = false) private String name; @TableField(exist = false) private String num; @TableField(exist = false) private String model; @TableField(exist = false) private String specification; } lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/EquipmentSparesMapper.java
@@ -1,10 +1,12 @@ package org.jeecg.modules.eam.mapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.ibatis.annotations.Param; import org.jeecg.modules.eam.entity.EquipmentSpares; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import java.util.List; import java.util.Map; /** @@ -17,4 +19,7 @@ IPage<Map<String, Object>> getEquipmentSparesList(IPage<Map> pageData, @Param("params") Map<String,Object> params); List<EquipmentSpares> getPagesByEquipmentId(Page<EquipmentSpares> page,@Param("equipmentId") String equipmentId); List<EquipmentSpares> getPagesByEquipmentId(@Param("equipmentId") String equipmentId); } lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/EquipmentSparesMapper.xml
@@ -44,4 +44,25 @@ </if> ORDER BY t1.create_time desc </select> </mapper> <select id="getPagesByEquipmentId" resultType="org.jeecg.modules.eam.entity.EquipmentSpares"> select t1.id id, t2.id sparePartId, t2.name name, t2.num num, t2.model model, t2.specification specification, t2.main_unit_id unitId, t3.name unitName, t1.equipment_id equipmentId from mom_eam_equipment_spares t1 left join mom_eam_spare_part t2 on t1.spare_part_id = t2.id left join mom_base_unit t3 on t2.main_unit_id = t3.id where t1.del_flag = 0 and t1.equipment_id=#{equipmentId} </select> </mapper> lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/IEquipmentSparesService.java
@@ -1,9 +1,12 @@ package org.jeecg.modules.eam.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.ibatis.annotations.Param; import org.jeecg.modules.eam.entity.EquipmentSpares; import com.baomidou.mybatisplus.extension.service.IService; import java.util.List; import java.util.Map; /** @@ -16,4 +19,8 @@ IPage<Map<String, Object>> getEquipmentSparesList(Integer pageNo, Integer pageSize, Map<String, Object> params); IPage<EquipmentSpares> myPage(Page<EquipmentSpares> page,EquipmentSpares equipmentSpares); List<EquipmentSpares> getListByEquipmentId( String equipmentId); } lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EquipmentSparesServiceImpl.java
@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import java.util.List; import java.util.Map; /** @@ -25,4 +26,14 @@ IPage<Map> pageData = new Page<Map>(pageNo, pageSize); return super.getBaseMapper().getEquipmentSparesList(pageData,params); } @Override public IPage<EquipmentSpares> myPage(Page<EquipmentSpares> page, EquipmentSpares equipmentSpares) { return page.setRecords(baseMapper.getPagesByEquipmentId(page,equipmentSpares.getEquipmentId())); } @Override public List<EquipmentSpares> getListByEquipmentId(String equipmentId) { return baseMapper.getPagesByEquipmentId(equipmentId); } }