|
@@ -11,6 +11,7 @@ import com.ym.mec.biz.dal.dto.SysUserDto;
|
|
|
import com.ym.mec.biz.dal.entity.ImGroup;
|
|
|
import com.ym.mec.biz.dal.entity.ImLiveBroadcastRoom;
|
|
|
import com.ym.mec.biz.dal.entity.ImLiveRoomPurview;
|
|
|
+import com.ym.mec.biz.dal.enums.TemplateTypeEnum;
|
|
|
import com.ym.mec.biz.service.ImLiveBroadcastRoomService;
|
|
|
import com.ym.mec.biz.service.ImLiveRoomPurviewService;
|
|
|
import com.ym.mec.common.exception.BizException;
|
|
@@ -18,12 +19,20 @@ import com.ym.mec.common.page.PageInfo;
|
|
|
import com.ym.mec.common.page.PageUtil;
|
|
|
import com.ym.mec.common.page.WrapperUtil;
|
|
|
import com.ym.mec.common.tenant.TenantContextHolder;
|
|
|
+import com.ym.mec.util.excel.POIUtil;
|
|
|
+import com.ym.mec.util.ini.IniFileUtil;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.core.io.ClassPathResource;
|
|
|
+import org.springframework.dao.DuplicateKeyException;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import java.io.ByteArrayInputStream;
|
|
|
+import java.io.InputStream;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
@@ -198,6 +207,55 @@ public class ImLiveRoomPurviewServiceImpl extends ServiceImpl<ImLiveRoomPurviewD
|
|
|
return PageUtil.pageInfo(baseMapper.selectRoomPurviewGroup(pageInfo, param));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 导入观看权限-人员n
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public String importPurviewUser(MultipartFile file, String roomUid) throws Exception {
|
|
|
+ Map<String, List<Map<String, Object>>> sheetsListMap = POIUtil.importExcel(
|
|
|
+ new ByteArrayInputStream(file.getBytes()), 0, file.getOriginalFilename());
|
|
|
+ InputStream inputStream = new ClassPathResource("columnMapper.ini").getInputStream();
|
|
|
+ Map<String, String> columns = IniFileUtil.readIniFile(inputStream, TemplateTypeEnum.LIVE_ROOM_PURVIEW_USER.getMsg());
|
|
|
+ List<ImLiveRoomPurview> purviewList = new ArrayList<>();
|
|
|
+ Integer id = getSysUser().getId();
|
|
|
+ Date now = new Date();
|
|
|
+ for (String e : sheetsListMap.keySet()) {
|
|
|
+ List<Map<String, Object>> sheet = sheetsListMap.get(e);
|
|
|
+ for (Map<String, Object> row : sheet) {
|
|
|
+ if (row.size() == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ ImLiveRoomPurview obj = new ImLiveRoomPurview();
|
|
|
+ obj.setRoomUid(roomUid);
|
|
|
+ obj.setType("STUDENT");
|
|
|
+ obj.setCreatedBy(id);
|
|
|
+ obj.setCreatedTime(now);
|
|
|
+ for (String s : row.keySet()) {
|
|
|
+ if (!columns.containsKey(s)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (columns.get(s).equals("userId")) {
|
|
|
+ if (null == row.get(s) || StringUtils.isBlank(row.get(s).toString())) {
|
|
|
+ log.error("导入异常:{}不可为空", s);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ obj.setUserId(Integer.valueOf(row.get(s).toString()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ purviewList.add(obj);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ baseMapper.insertBatch(purviewList);
|
|
|
+ } catch (DuplicateKeyException dupKeyEx) {
|
|
|
+ log.error("数据导入重复: " + dupKeyEx.getCause());
|
|
|
+ throw new BizException("数据重复:" + dupKeyEx.getCause());
|
|
|
+ } catch (Exception ex) {
|
|
|
+ throw new BizException("导入数据出错:" + ex, ex);
|
|
|
+ }
|
|
|
+ return "成功导入 " + purviewList.size() + "条";
|
|
|
+ }
|
|
|
+
|
|
|
private SysUser getSysUser() {
|
|
|
//修改机构基础信息
|
|
|
return Optional.ofNullable(sysUserFeignService.queryUserInfo())
|