package com.hssx.cloudmodel.controller; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.hssx.cloudmodel.entity.MouldEquipment; import com.hssx.cloudmodel.entity.User; import com.hssx.cloudmodel.service.MouldEquipmentService; import com.hssx.cloudmodel.service.UserService; import com.hssx.cloudmodel.util.HttpRespMsg; import com.hssx.cloudmodel.util.PageUtil; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; /** * * @author 吴涛涛 * @since 2019-08-02 */ @Controller @RequestMapping("/mouldequipment") public class MouldEquipmentController { @Autowired private MouldEquipmentService mouldEquipmentService; @Autowired private UserService userService; /** * 添加/修改模具设备 * 添加参数:equipmentName 设备名称,useLife 使用年限, equipmentNo 设备编号 , * 修改时需多传的参数 id 设备id, belongCompanyId 所属公司id ,equipmentName 设备名称 * @return */ @ApiOperation("添加/修改模具设备") @RequestMapping("/addOrUpdate") @ResponseBody public HttpRespMsg addOrUpdate(MouldEquipment mouldEquipment,String token) { HttpRespMsg msg = new HttpRespMsg(); QueryWrapper qw = new QueryWrapper<>(); qw.eq("head_imgurl",token); User user = userService.getOne(qw); msg = mouldEquipmentService.addAndUpdateMouldEquipment(mouldEquipment,user); return msg; } /** * 启用设备 * 传参 id 设备id ,isUse 启用传 1 * @return */ @ApiOperation("启用设备") @RequestMapping("/use") @ResponseBody public HttpRespMsg use(MouldEquipment mouldEquipment,String token) { HttpRespMsg msg = new HttpRespMsg(); QueryWrapper qw = new QueryWrapper<>(); qw.eq("head_imgurl",token); User user = userService.getOne(qw); msg = mouldEquipmentService.isUse(mouldEquipment,user); return msg; } /** * 创建模具时获取资产方公司的设备列表 * 参数 belongCompanyId 当前登录人公司id * @return */ @ApiOperation("获取资产方公司的设备列表") @RequestMapping("/getMouldEquipmentList") @ResponseBody public HttpRespMsg getMouldEquipmentList(MouldEquipment mouldEquipment){ HttpRespMsg msg = new HttpRespMsg(); msg.data = mouldEquipmentService.list(new QueryWrapper().eq("belong_company_id", mouldEquipment.getBelongCompanyId())); return msg; } /** * 设备列表(仅仅只有超级管理员能够看到) * 参数 token 用户唯一身份凭证 * @return */ @ApiOperation("设备列表") @RequestMapping("/getEquipmentList") @ResponseBody public HttpRespMsg getMouldEquipmentList(@RequestParam(required = false) String token, PageUtil page){ HttpRespMsg msg = new HttpRespMsg(); QueryWrapper qw = new QueryWrapper<>(); qw.eq("head_imgurl",token); User user = userService.getOne(qw); msg = mouldEquipmentService.getList(user,page); return msg; } }