|  |  |  | 
|---|
|  |  |  | import javax.servlet.http.HttpServletRequest; | 
|---|
|  |  |  | import javax.servlet.http.HttpServletResponse; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.Iterator; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 生产设备信息接口 | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | 
|---|
|  |  |  | Iterator<String> it = multipartRequest.getFileNames(); | 
|---|
|  |  |  | while (it.hasNext()) { | 
|---|
|  |  |  | MultipartFile file = multipartRequest.getFile((String) it.next()); | 
|---|
|  |  |  | deviceExtService.importPlans(file); | 
|---|
|  |  |  | deviceService.importPlans(file); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|