|
@@ -10,19 +10,26 @@ 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.*;
|
|
|
+import com.dragon.tj.portal.entity.AppInfo;
|
|
|
+import com.dragon.tj.portal.entity.InstallInfo;
|
|
|
+import com.dragon.tj.portal.entity.PageParam;
|
|
|
+import com.dragon.tj.portal.entity.SysDictItem;
|
|
|
import com.dragon.tj.portal.mapper.app.AppInfoMapper;
|
|
|
import com.dragon.tj.portal.mapper.app.InstallInfoMapper;
|
|
|
import com.dragon.tj.portal.service.AppService;
|
|
|
import com.dragon.tj.portal.service.FileManageService;
|
|
|
import com.dragon.tj.portal.service.SysDictItemService;
|
|
|
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.stereotype.Service;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
-import java.io.*;
|
|
|
+import java.io.BufferedInputStream;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -30,7 +37,7 @@ import java.util.Map;
|
|
|
|
|
|
@Service
|
|
|
public class AppServiceImpl implements AppService {
|
|
|
-
|
|
|
+ private static final Logger LOGGER = LoggerFactory.getLogger(AppServiceImpl.class);
|
|
|
|
|
|
@Autowired
|
|
|
private AppInfoMapper appInfoMapper;
|
|
@@ -46,7 +53,7 @@ public class AppServiceImpl implements AppService {
|
|
|
|
|
|
private static List<SysDictItem> appTypeDict;
|
|
|
|
|
|
- public List<SysDictItem> getAppTypeDict(){
|
|
|
+ public List<SysDictItem> getAppTypeDict() {
|
|
|
if (appTypeDict == null || appTypeDict.size() == 0) {
|
|
|
appTypeDict = sysDictItemService.list(Wrappers.<SysDictItem>query().lambda().eq(SysDictItem::getType, "app_type").orderByAsc(SysDictItem::getSort));
|
|
|
}
|
|
@@ -107,8 +114,8 @@ public class AppServiceImpl implements AppService {
|
|
|
//应用事权单位名称
|
|
|
queryWrapper.like(StringUtils.isNotEmpty(appInfo.getDeptName()), AppInfo::getDeptName, appInfo.getDeptName());
|
|
|
//应用类型
|
|
|
- queryWrapper.eq(appInfo.getAppType() != null,AppInfo::getAppType, appInfo.getAppType());
|
|
|
- queryWrapper.eq(appInfo.getDelFlag() != null,AppInfo::getDelFlag, appInfo.getDelFlag());
|
|
|
+ queryWrapper.eq(appInfo.getAppType() != null, AppInfo::getAppType, appInfo.getAppType());
|
|
|
+ queryWrapper.eq(appInfo.getDelFlag() != null, AppInfo::getDelFlag, appInfo.getDelFlag());
|
|
|
|
|
|
rowPage.addOrder(OrderItem.desc(appInfoPage.getOrder()));
|
|
|
|
|
@@ -169,31 +176,31 @@ public class AppServiceImpl implements AppService {
|
|
|
|
|
|
map.put("delFlag", params.getDelFlag());
|
|
|
Integer appType = params.getAppType();
|
|
|
- if (appType != null){
|
|
|
+ if (appType != null) {
|
|
|
List<SysDictItem> appTypeList = getAppTypeDict();
|
|
|
- SysDictItem specialToolDict = appTypeList.stream().filter(item -> "专项工具".equals(item.getLabel())).findFirst().get();
|
|
|
+ SysDictItem specialToolDict = appTypeList.stream().filter(item -> "专项工具".equals(item.getLabel())).findFirst().get();
|
|
|
map.put("std", specialToolDict.getId());//专项工具
|
|
|
|
|
|
- if (specialToolDict.getId().compareTo(appType) == 0){
|
|
|
+ if (specialToolDict.getId().compareTo(appType) == 0) {
|
|
|
map.put("isSt", 1);//专项工具查询
|
|
|
}
|
|
|
}
|
|
|
|
|
|
map.put("idcard", loginUser.getIdCard());
|
|
|
|
|
|
- return appInfoMapper.getInstalledApp(iPage,map);
|
|
|
+ return appInfoMapper.getInstalledApp(iPage, map);
|
|
|
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
- * 应用统计
|
|
|
- * */
|
|
|
+ * 应用统计
|
|
|
+ * */
|
|
|
@Override
|
|
|
public void updateAppStat() {
|
|
|
//获取app安装次数
|
|
|
- List<Map<String,Long>> apps = installInfoMapper.getAppInstallCount();
|
|
|
+ List<Map<String, Long>> apps = installInfoMapper.getAppInstallCount();
|
|
|
//更新star
|
|
|
- apps.forEach(app ->{
|
|
|
+ apps.forEach(app -> {
|
|
|
AppInfo appInfo = new AppInfo();
|
|
|
appInfo.setId(app.get("appId"));
|
|
|
appInfo.setStar(app.get("count"));
|
|
@@ -205,7 +212,7 @@ public class AppServiceImpl implements AppService {
|
|
|
@Override
|
|
|
public int clickIncr(Long id) {
|
|
|
QueryWrapper<AppInfo> wrapper = new QueryWrapper<>();
|
|
|
- wrapper.eq("id",id);
|
|
|
+ wrapper.eq("id", id);
|
|
|
AppInfo appInfo = appInfoMapper.selectOne(wrapper);
|
|
|
appInfo.setId(id);
|
|
|
appInfo.setHits(appInfo.getHits() + 1);
|
|
@@ -228,7 +235,7 @@ public class AppServiceImpl implements AppService {
|
|
|
List<AppInfo> appInfos = ExcelHelper.parseExcelToObject(
|
|
|
new BufferedInputStream(tempFis),
|
|
|
inputStream,
|
|
|
- AppInfo.class,true);
|
|
|
+ AppInfo.class, true);
|
|
|
|
|
|
appInfos.forEach(appInfo -> {
|
|
|
AppInfo appInfo1 = parseAppInfo(appInfo);
|
|
@@ -236,9 +243,10 @@ public class AppServiceImpl implements AppService {
|
|
|
});
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
+ LOGGER.error("上传出错", e);
|
|
|
+ return false;
|
|
|
} finally {
|
|
|
- if (inputStream != null){
|
|
|
+ if (inputStream != null) {
|
|
|
try {
|
|
|
inputStream.close();
|
|
|
} catch (IOException e) {
|
|
@@ -246,7 +254,6 @@ public class AppServiceImpl implements AppService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -261,11 +268,11 @@ public class AppServiceImpl implements AppService {
|
|
|
appInfo.setAppType(sysDictItem.getId());
|
|
|
|
|
|
//在用标识转换
|
|
|
- appInfo.setActiveFlag("在用".equals(appInfo.getActiveName()) ? 1:0);
|
|
|
+ appInfo.setActiveFlag("在用".equals(appInfo.getActiveName()) ? 1 : 0);
|
|
|
|
|
|
//图标处理
|
|
|
byte[] iconImageByte = appInfo.getImage();
|
|
|
- if (iconImageByte.length > 0){
|
|
|
+ if (iconImageByte.length > 0) {
|
|
|
|
|
|
appInfo.setIcon(fileManageService.upload(
|
|
|
iconImageByte,
|