|
@@ -4,22 +4,24 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.dc.eventpoi.ExcelHelper;
|
|
|
import com.dragon.tj.portal.auth.model.LoginUser;
|
|
|
+import com.dragon.tj.portal.auth.util.SecurityUtils;
|
|
|
import com.dragon.tj.portal.common.base.R;
|
|
|
-import com.dragon.tj.portal.entity.AppInfo;
|
|
|
-import com.dragon.tj.portal.entity.BusinessInfo;
|
|
|
-import com.dragon.tj.portal.entity.InstallInfo;
|
|
|
-import com.dragon.tj.portal.entity.PageParam;
|
|
|
+import com.dragon.tj.portal.entity.*;
|
|
|
import com.dragon.tj.portal.mapper.BusinessMapper;
|
|
|
import com.dragon.tj.portal.mapper.app.AppInfoMapper;
|
|
|
import com.dragon.tj.portal.mapper.app.InstallInfoMapper;
|
|
|
-import com.dragon.tj.portal.service.BusinessService;
|
|
|
-import com.dragon.tj.portal.service.SysDictService;
|
|
|
+import com.dragon.tj.portal.service.*;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.core.io.ClassPathResource;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import java.io.*;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -41,6 +43,12 @@ public class BusinessServiceImpl implements BusinessService {
|
|
|
@Autowired
|
|
|
private SysDictService sysDictService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SysDictItemService sysDictItemService;
|
|
|
+
|
|
|
+ private static List<SysDictItem> businessTypeDict;
|
|
|
+
|
|
|
+
|
|
|
/*
|
|
|
* CRUD
|
|
|
* */
|
|
@@ -229,5 +237,71 @@ public class BusinessServiceImpl implements BusinessService {
|
|
|
return businessMapper.updateById(businessInfo);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public boolean batchAdd(MultipartFile file) {
|
|
|
+ InputStream inputStream = null;
|
|
|
+ try {
|
|
|
+ inputStream = file.getInputStream();
|
|
|
+// String path = AppService.class.getClassLoader().getResource("").getPath();
|
|
|
+// path = URLDecoder.decode(path, "UTF-8");
|
|
|
+// FileInputStream tempFis = new FileInputStream(new File(path + "file/businessTemplete.xlsx"));
|
|
|
+ ClassPathResource classPathResource = new ClassPathResource("file/businessTemplete.xlsx");
|
|
|
+ InputStream tempFis = classPathResource.getInputStream();
|
|
|
+
|
|
|
+ List<BusinessInfo> businessInfos = ExcelHelper.parseExcelToObject(
|
|
|
+ new BufferedInputStream(tempFis),
|
|
|
+ inputStream,
|
|
|
+ BusinessInfo.class,true);
|
|
|
+
|
|
|
+ businessInfos.forEach(businessInfo -> {
|
|
|
+ BusinessInfo businessInfo1 = parseBusinessInfo(businessInfo);
|
|
|
+ this.add(businessInfo1, SecurityUtils.getLoginUser());
|
|
|
+ });
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ if (inputStream != null){
|
|
|
+ try {
|
|
|
+ inputStream.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ private BusinessInfo parseBusinessInfo(BusinessInfo businessInfo) {
|
|
|
+ List<SysDictItem> businessTypeDict = getBusinessTypeDict();
|
|
|
+
|
|
|
+ //类型表码转换
|
|
|
+ String appTypeName = businessInfo.getTypeName();
|
|
|
+ SysDictItem sysDictItem = businessTypeDict.stream()
|
|
|
+ .filter(t -> t.getLabel().equals(appTypeName))
|
|
|
+ .findFirst().get();
|
|
|
+ businessInfo.setBusinessType(sysDictItem.getId());
|
|
|
+
|
|
|
+ //获取Appinfo
|
|
|
+ QueryWrapper<AppInfo> wrapper = new QueryWrapper<>();
|
|
|
+ wrapper.eq(businessInfo.getAppName() != null,
|
|
|
+ "system_name",businessInfo.getAppName());
|
|
|
+
|
|
|
+ AppInfo appInfo = appInfoMapper.selectOne(wrapper);
|
|
|
+ businessInfo.setAppId(appInfo.getId());
|
|
|
+
|
|
|
+ return businessInfo;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public List<SysDictItem> getBusinessTypeDict(){
|
|
|
+ if (businessTypeDict == null || businessTypeDict.size() == 0) {
|
|
|
+ businessTypeDict = sysDictItemService.list(Wrappers.<SysDictItem>query().lambda().eq(SysDictItem::getType, "business_type").orderByAsc(SysDictItem::getSort));
|
|
|
+ }
|
|
|
+
|
|
|
+ return businessTypeDict;
|
|
|
+ }
|
|
|
|
|
|
}
|