| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import org.apache.poi.hssf.record.DVALRecord; |
| | | import org.jeecg.common.api.vo.CommonGenericTree; |
| | | 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.eam.entity.Area; |
| | | import org.jeecg.modules.eam.entity.FaultCause; |
| | | import org.jeecg.modules.eam.entity.Team; |
| | | import org.jeecg.modules.eam.service.IAreaService; |
| | | import org.jeecg.modules.eam.service.ITeamService; |
| | |
| | | @Api(tags = "车间 前端控制器") |
| | | @RestController |
| | | @RequestMapping("/base/area") |
| | | public class AreaController { |
| | | public class AreaController extends JeecgController<Area,IAreaService> { |
| | | |
| | | @Autowired |
| | | private IAreaService areaService; |
| | |
| | | @ApiOperation(value = "车间-新增", notes = "车间-新增") |
| | | @PostMapping("/add") |
| | | public Result<?> add(@RequestBody Area area) { |
| | | String parentId = area.getParentId(); |
| | | if("-1".equals(parentId)){ |
| | | area.setType("1"); |
| | | }else{ |
| | | Area nextArea = areaService.getById(parentId); |
| | | String type = nextArea.getType(); |
| | | if("1".equals(type)){ |
| | | area.setType("2"); |
| | | }else{ |
| | | area.setType("3"); |
| | | } |
| | | } |
| | | area.setStatus(CommonConstant.STATUS_1); |
| | | areaService.save(area); |
| | | return Result.ok("新增成功"); |
| | |
| | | return Result.ok("更新成功!"); |
| | | } |
| | | |
| | | @GetMapping(value = "/getAlllist") |
| | | public Result<?> getAlllist(Area area, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, |
| | | @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) { |
| | | // QueryWrapper<Area> queryWrapper = QueryGenerator.initQueryWrapper(area, req.getParameterMap()); |
| | | QueryWrapper<Area> queryWrapper = Wrappers.query(); |
| | | Page<Area> page = new Page<Area>(pageNo, pageSize); |
| | | |
| | | String num = area.getNum(); |
| | | String name = area.getName(); |
| | | String parentId = area.getParentId(); |
| | | if(StringUtils.isNotBlank(parentId)){ |
| | | queryWrapper.eq("parent_id", parentId); |
| | | }else{ |
| | | queryWrapper.eq("parent_id", "-1"); |
| | | } |
| | | if(StringUtils.isNotBlank(num)){ |
| | | queryWrapper.like("num", num); |
| | | } |
| | | if(StringUtils.isNotBlank(name)){ |
| | | queryWrapper.like("name", name); |
| | | } |
| | | IPage<Area> pageList = areaService.page(page, queryWrapper); |
| | | List<Area> records = pageList.getRecords(); |
| | | for (Area record : records) { |
| | | String id = record.getId(); |
| | | List<Area> areas = areaService.lambdaQuery().eq(Area::getParentId, id).eq(Area::getDelFlag, "0").list(); |
| | | record.setNextAreas(areas); |
| | | } |
| | | return Result.OK(pageList); |
| | | } |
| | | |
| | | /** |
| | | * @MethodName: loadTree |
| | | * @Description: 故障原因 树 |
| | | */ |
| | | @GetMapping("/loadTree") |
| | | public Result<?> loadTree(HttpServletRequest httpServletRequest) { |
| | | List<CommonGenericTree> list = areaService.loadTree(); |
| | | return Result.ok(list); |
| | | } |
| | | |
| | | |
| | | } |