| | |
| | | import doumeemes.service.system.SystemDataPermissionService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.authz.annotation.RequiresPermissions; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import org.springframework.web.multipart.MultipartHttpServletRequest; |
| | | import org.springframework.web.multipart.commons.CommonsMultipartResolver; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 生产设备信息接口 |
| | |
| | | |
| | | @Autowired |
| | | private DeviceExtService deviceExtService; |
| | | |
| | | |
| | | @Autowired |
| | | private DeviceService deviceService; |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | QueryDeviceExtDTO queryDeviceExtDTO=new QueryDeviceExtDTO(); |
| | | Device queryDeviceExtDTO=new Device(); |
| | | queryDeviceExtDTO.setDeleted(Constants.ZERO); |
| | | queryDeviceExtDTO.setCode(device.getCode()); |
| | | queryDeviceExtDTO.setRootDepartId(getLoginUser().getRootDepartment().getId()); |
| | | List<DeviceExtListVO> list= deviceExtService.getListByCondition(queryDeviceExtDTO); |
| | | List<Device> list= deviceService.findList(queryDeviceExtDTO); |
| | | if(list.size()>0){ |
| | | if(!Constants.equalsInteger(list.get(0).getId(),device.getId())){ |
| | | return ApiResponse.failed("设备编码,不允许添加"); |
| | |
| | | find.setModel(device.getModel()); |
| | | find.setProcedureId(device.getProcedureId()); |
| | | find.setStationCode(device.getStationCode()); |
| | | find.setType(device.getType()); |
| | | find.setType(Objects.nonNull(device.getType()) ? device.getType() : Constants.ONE); |
| | | find.setGroupId(device.getGroupId()); |
| | | find.setProduceWarehouseLocationId(device.getProduceWarehouseLocationId()); |
| | | find.setFinishWarehouseLocationId(device.getFinishWarehouseLocationId()); |
| | | deviceService.updateById(find); |
| | | if(StringUtils.isNotBlank(device.getUserIds())){ |
| | | deviceService.dealDeviceUserId(Constants.ONE,device.getUserIds(),device.getId(),getLoginUser()); |
| | | }else { |
| | | UserDevice userDevice = new UserDevice(); |
| | | userDevice.setDeviceId(device.getId()); |
| | | userDeviceService.delete(userDevice); |
| | | } |
| | | |
| | | return ApiResponse.success(null); |
| | |
| | | return ApiResponse.success(list); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "批量导入计划", notes = "批量导入计划", httpMethod = "POST", position = 6) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "folder", value = "文件夹", required = true, paramType = "query", dataType = "String", dataTypeClass = String.class), |
| | | }) |
| | | @PostMapping(value = "/importBatch", headers = "content-type=multipart/form-data") |
| | | // @RequiresPermissions("business:salaryparam:create") |
| | | public ApiResponse importBatch(String folder, HttpServletRequest request, HttpServletResponse response) throws Exception { |
| | | CommonsMultipartResolver multipartResovler = new CommonsMultipartResolver(); |
| | | if (multipartResovler.isMultipart(request)) { |
| | | MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; |
| | | Iterator<String> it = multipartRequest.getFileNames(); |
| | | while (it.hasNext()) { |
| | | MultipartFile file = multipartRequest.getFile((String) it.next()); |
| | | deviceService.importPlans(file); |
| | | break; |
| | | } |
| | | } |
| | | return ApiResponse.success( null); |
| | | } |
| | | |
| | | } |