| | |
| | | package doumeemes.service.business.impl; |
| | | |
| | | import doumeemes.core.constants.ResponseStatus; |
| | | import doumeemes.core.exception.BusinessException; |
| | | import doumeemes.core.model.ApiResponse; |
| | | import doumeemes.core.model.LoginUserInfo; |
| | | import doumeemes.core.model.PageData; |
| | |
| | | import doumeemes.core.utils.Constants; |
| | | import doumeemes.core.utils.DateUtil; |
| | | import doumeemes.core.utils.Utils; |
| | | import doumeemes.core.utils.excel.EasyExcelUtil; |
| | | import doumeemes.core.utils.redis.RedisUtil; |
| | | import doumeemes.dao.business.DepartmentMapper; |
| | | import doumeemes.dao.business.DeviceMapper; |
| | | import doumeemes.dao.business.UserDeviceMapper; |
| | | import doumeemes.dao.business.model.CompanyUser; |
| | | import doumeemes.dao.business.model.Department; |
| | | import doumeemes.dao.business.model.Device; |
| | | import doumeemes.dao.business.model.UserDevice; |
| | | import doumeemes.dao.ext.dto.DeviceImportDTO; |
| | | import doumeemes.dao.ext.dto.QueryDeviceExtDTO; |
| | | import doumeemes.dao.ext.vo.DeviceExtListVO; |
| | | import doumeemes.service.business.DeviceService; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | |
| | | private DeviceExtService deviceExtService; |
| | | @Autowired |
| | | private UserDeviceMapper userDeviceMapper; |
| | | |
| | | @Autowired |
| | | private DepartmentMapper departmentMapper; |
| | | |
| | | @Override |
| | | public Integer create(Device device) { |
| | |
| | | } |
| | | } |
| | | |
| | | @Transactional(rollbackFor = {Exception.class, BusinessException.class}) |
| | | @Override |
| | | public void importPlans(MultipartFile file) { |
| | | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | if(!Constants.equalsInteger(user.getType(),Constants.USERTYPE.COM)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,您无权限进行该操作!"); |
| | | } |
| | | //解析excel |
| | | List<DeviceImportDTO> plansList = EasyExcelUtil.importExcel(file, 1, 1, DeviceImportDTO.class); |
| | | if(plansList == null || plansList.size()==0){ |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "导入数据内容有误!"); |
| | | } |
| | | |
| | | plansList.forEach(s->{ |
| | | |
| | | if (StringUtils.isBlank(s.getDeviceName()) |
| | | || s.getDeviceName().length() > 50 |
| | | || StringUtils.isBlank(s.getDepartName()) |
| | | || StringUtils.isBlank(s.getProcedureName()) |
| | | || StringUtils.isBlank(s.getProduceWarehouseLocationName()) |
| | | || StringUtils.isBlank(s.getFinishWarehouseLocationName())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"导入数据内容有误"); |
| | | } |
| | | }); |
| | | |
| | | |
| | | QueryWrapper<Department> wrapper = new QueryWrapper<>(); |
| | | wrapper.lambda().eq(Department::getRootId,user.getRootDepartment().getId()); |
| | | departmentMapper.selectList(wrapper); |
| | | |
| | | plansList.forEach(s->{ |
| | | |
| | | Device device = new Device(); |
| | | device.setDeleted(Constants.ZERO); |
| | | device.setCreateUser(user.getId()); |
| | | device.setCreateTime(new Date()); |
| | | device.setUpdateUser(user.getId()); |
| | | device.setUpdateTime(new Date()); |
| | | // device.setRemark(); |
| | | // device.setRootDepartId(); |
| | | // device.setDepartId(); |
| | | // device.setProcedureId(); |
| | | // device.setCode(); |
| | | // device.setType(); |
| | | // device.setName(); |
| | | // device.setModel(); |
| | | // device.setStatus(); |
| | | // device.setSupplier(); |
| | | // device.setStationCode(); |
| | | // device.setGroupId(); |
| | | // device.setSerialNum(); |
| | | // device.setProduceWarehouseLocationId(); |
| | | // device.setProduceWarehouseId(); |
| | | // device.setFinishWarehouseLocationId(); |
| | | // device.setFinishWarehouseId(); |
| | | // device.setUserIds(); |
| | | deviceMapper.insert(device); |
| | | }); |
| | | } |
| | | |
| | | |
| | | public synchronized String getNextCode(Integer comId ){ |
| | | String prefix = "S-" + DateUtil.getDate(new Date(),"yyyyMMdd") +"-"; |